Commit Graph

255 Commits (github/fork/sternenseemann/patch-1)

Author SHA1 Message Date
Gonçalo Silva 3f4f8292ca Use markup regexp for character count
Deferring to Pandoc is not without its faults. It still requires
processing (eg. horizontal rules turning into 72 dashes). It is
significantly slower and resource hungry.

On the reverse, the markup regexps have improved over time and are able
to handle the task.
2019-07-25 00:16:26 +01:00
Gonçalo Silva aae38ddb5f Prevent scroll when only one of the text view or preview are scrollable 2019-07-25 00:16:26 +01:00
Gonçalo Silva d78602c4db Fix synchronized scrolling without MathJax 2019-07-25 00:16:26 +01:00
Gonçalo Silva df79f9329e Rename WebView to PreviewWebView 2019-07-25 00:16:26 +01:00
Gonçalo Silva 0b13fdddc5 Remove unused offset in markup handler 2019-07-25 00:16:26 +01:00
Gonçalo Silva eec633437b Improve inline preview
- Uses commonly defined regexp
- Removed dependency on gnome-web-photo, use WebView instead
- Improved lexicon rendering
2019-07-25 00:16:26 +01:00
Gonçalo Silva 8e97b7ae2c Quality of life improvements for regexp
Includes:
* Moving them into an independent file
* Using named groups for clarity
* Support for multi-line list items
* Better handling of block markup at start / end of document (eg. hr)
* Better handling of the separation around block items (eg. space around a list)
2019-07-25 00:16:26 +01:00
Manuel Genovés 213ff104e5 Update license 2019-07-05 20:47:49 +02:00
Gonçalo Silva 828f4b0bf1
Remove unused NUMERICLIST 2019-05-22 19:30:36 +01:00
Gonçalo Silva 21387ea6a7 Fix scroll jump when previewing documents with math
MathJax loads asynchronously and can alter the height of the document.
Altering the height alters the scroll.

Ensure MathJax is either unused or finished loading before reading
scroll from the preview.
2019-05-17 06:59:41 +01:00
somas95 a0638f6912
Merge pull request #161 from goncalossilva/patch-1
Fix file paths
2019-05-12 21:12:04 +02:00
Gonçalo Silva c5abc531e0 Fix scrolling glitch during preview
Typing while in preview mode would occasionally lead to a scrolling
glitch, where scroll would briefly be at 0, before jumping to the
location it was supposed to be in in the first case.

This happened due to the async nature of JS calls, in the following
scenario:
1. Load
2. Read started
3. Read finished
4. Read started
5. Load
6. Read finished

The results from op 4 would be invalid due to loading in-between, and
handling the result in 6 would set the wrong scroll value.

This change ensures results are discarded whenever we are waiting for
them and a new load starts.
2019-05-08 04:11:35 +01:00
Gonçalo Silva e39694571d
Fix file paths
`path_to_file`'s argument is an absolute path, which already contains a leading `/`. Having an additional slash (ie. `file:////some/path`) actually breaks things, eg. the export flow using local assets.
2019-05-08 03:12:59 +01:00
Gonçalo Silva 250519f319 Improve gspell_view encapsulation inside TextView 2019-05-04 16:33:09 +01:00
Gonçalo Silva c2d0bde9f8 Replace set_value(X, type(Y)) with set_type(X, Y) for Settings 2019-05-04 16:33:09 +01:00
Gonçalo Silva 939edcc762 Allow disabling scroll sync 2019-05-04 16:33:09 +01:00
Gonçalo Silva db652ef84f Ensure text view is focused when toggling preview
Consistent with other menu options.
2019-05-04 16:33:09 +01:00
Gonçalo Silva a0a19ffbe7 Replace get_value(X).get_Y() with get_Y(X) for Settings 2019-05-04 16:33:09 +01:00
Gonçalo Silva c2a43c374a Remove unused class 2019-05-04 16:33:09 +01:00
Gonçalo Silva e80b61cf9d Work-around for unwanted scroll while resizing the editor
The problem: When a TextView *with vertical margins set* is resized, it
scrolls upwards automatically. It's not entirely clear why this happens,
but removing the top/bottom margins fixes the issue entirely.

The work-around: enforcing the scroll scale between a resize starting
and the UI becoming idle again. This is a hack, and the experience is
not great (the scroll is visibly unstable for a few ms), but it patches
and old bug in UberWriter.

The better solution: Figuring out how to prevent it from happening,
either by somehow ensuring the TextView does not do this, or by
approaching the layout differently where the margin is not set on the
TextView itself.
2019-05-04 16:33:09 +01:00
Gonçalo Silva 7a2e6d5d8f Fix unwanted scroll while resizing the preview 2019-05-04 16:33:09 +01:00
Gonçalo Silva 7ff1df4371 Optimize markup update on margin/indent change
Updating text tags is expensive, so avoid it unless necessary.

A place where this was felt was when pasting large text.
2019-05-04 16:33:09 +01:00
Gonçalo Silva ebbbd73056 Disable search during full-width preview 2019-05-04 16:33:09 +01:00
Gonçalo Silva 86cffc40ec Improve full-width preview workflow 2019-05-04 16:33:09 +01:00
Gonçalo Silva dc0652e3ed Improve documentation for the new preview 2019-05-04 16:33:09 +01:00
Gonçalo Silva 65e7028843 Add toggle between various preview modes
Including:
* Full-width (original)
* Half-width
* Half-height
* Windowed
2019-05-04 16:33:09 +01:00
Gonçalo Silva f72f61ae7d Fix stats' i18n 2019-05-04 16:33:09 +01:00
Gonçalo Silva 2cb161307c Improve side-by-side experience
Includes multiple improvements to scroll syncing, preview re-render,
layout separation, etc
2019-05-04 16:33:09 +01:00
Gonçalo Silva 5e770510ee Add support for side-by-side preview
Fixes #59
2019-05-04 16:33:09 +01:00
Gonçalo Silva bc23fa9b0b Make characters-per-line configurable
This is in preparation for the side-by-side preview, where the editor
needs to become more adaptable. It indirectly fixes #141, as users can
now change the desired line-length, although there is no UI setting for
it.
2019-05-04 16:33:09 +01:00
Gonçalo Silva 562cc7e200 Sync scroll between text view and web view
Scrolling is synced via scroll percentage. This works for most cases,
but breaks down on very large or complex documents. It is consistent
with the approach other editors use (eg. iA Writer), but in the future
we should explore alternatives that don't incur in edge cases.

The syncing itself is done via JavaScript. It could be argued that a
`WebExtension` is the better approach, but it is considerably more
complex for such a simple use case and it would be painful to implement
until UberWriter's build system is updated, since it requires
implementing a C extension.

Fixes #55
2019-05-04 16:33:09 +01:00
somas95 b9e2720eed
Merge pull request #159 from goncalossilva/fix.markup
Small markup fixes
2019-05-04 14:18:12 +02:00
Manuel Genovés 249e78c746 Migrate to gspell 2019-05-04 14:11:23 +02:00
Gonçalo Silva 241ba567e4 Fix character count with horizontal rules
Pandoc's conversion to plain text converts horizontal rules to a
sequence of 72 dashes. This update ensures that subsequent dashes
are ignored when counting characters.
2019-05-01 19:04:50 +01:00
Gonçalo Silva 9238a82d4d Fix #154 2019-05-01 19:04:27 +01:00
somas95 dc80c6763a
Merge pull request #158 from UberWriter/flatpak-improvements
Flatpak improvements
2019-05-01 16:50:15 +02:00
Christopher Davis e0cea3654a Migrate to gspell
gtkspellcheck is abandoned; Use gspell instead.

Closes https://github.com/UberWriter/uberwriter/issues/93
2019-04-28 23:03:10 -04:00
Gonçalo Silva ddcf76df47 Set text view padding in Python instead of CSS
Otherwise scrolling calculations will be slightly offset, as the CSS
padding is added *on top* of any other margin.
2019-04-21 01:50:49 +01:00
Gonçalo Silva 81f9104d9f Split gtk and web CSS into separate directories
Helps clean up the CSS selection on the export dialog, as only Web CSS
is useful in that scenario.
2019-04-21 01:50:49 +01:00
Gonçalo Silva e87de1424e Remove hard-coding from Gtk-related CSS
It's unecessary, since Adwaita and most popular themes provide a defined
set of public colors.

For reference, see: https://github.com/GNOME/gtk/blob/master/gtk/theme/Adwaita/_colors-public.scss
2019-04-21 01:32:26 +01:00
Manuel Genovés 3d26dc2b25 flatpak improvements 2019-04-20 18:24:21 +02:00
Ryan Gonzalez 32bb70a261 Flatpak fixes (ref. #111) 2019-04-19 13:06:13 -05:00
Gonçalo Silva dccc645430 Add paragraphs stat 2019-04-19 11:26:21 +01:00
Gonçalo Silva c19f57f64b Add statistics for sentences and read time, allow user to toggle default
Fixes #63
2019-04-19 11:23:16 +01:00
Gonçalo Silva 1a7443fd3c Switch to a more powerful and accurate stats counter
The new stats counter is able to count characters, words, sentences, and
reading time.

It does so more accurately than before, by leveraging Pandoc's plain
format, and a few simple regular expressions that besides accuracy, also
improve support for Asian languages. It's all done on a background
thread to avoid hogging the UI.
2019-04-19 11:23:16 +01:00
Gonçalo Silva f6c62fb459 Tooltip capitalization fix 2019-04-19 11:23:16 +01:00
Gonçalo Silva dfe7cc420e Fix opening recents popover affecting font size 2019-04-19 00:00:33 +01:00
Gonçalo Silva 567e74c99e Fix active search going out of bounds 2019-04-17 02:15:59 +01:00
Gonçalo Silva d98208e0e9 Cleanup left-over from removing ODT as a default export option 2019-04-17 02:10:19 +01:00
Gonçalo Silva 8159ad9e25 Tweak breakpoints to ensure it conforms to the documented spec 2019-04-17 02:07:15 +01:00
Gonçalo Silva c9958b6c12 Prevent exception when exiting while waiting for scroll 2019-04-16 01:15:11 +01:00
Gonçalo Silva 41377c24bb Further remove unecessary prefixes 2019-04-15 03:01:59 +01:00
Gonçalo Silva 9f41bfac8d Add input format setting
Supports Pandoc's Markdown, Commonmark, GitHub Flavored Markdown,
MultiMarkdown and Plain Markdown.

Fixes #17
Fixes #122
2019-04-15 02:50:28 +01:00
Gonçalo Silva ce4a13278d Organize export formats by type, more copy fixes 2019-04-15 02:50:28 +01:00
Gonçalo Silva fbef0143e2 Use correct mime type for markdown, split markdown/plain text 2019-04-15 02:50:14 +01:00
Gonçalo Silva 4b32617ca7 Update pandoc help link 2019-04-15 02:50:14 +01:00
Gonçalo Silva 50729b0d34 Introduce pypandoc for pandoc calls 2019-04-15 02:50:05 +01:00
Gonçalo Silva 1842a849ad Fix warning due to missing argument 2019-04-13 03:45:27 +01:00
Gonçalo Silva af9d1adf7c Uniformize header/status bar reveal duration 2019-04-13 03:45:09 +01:00
Gonçalo Silva 58e2d2e0be Remove uneeded threads_init calls 2019-04-13 02:47:26 +01:00
Gonçalo Silva ef54c752ba Fix replace row missing after hiding
The replace row would be consistently missing after losing focus
(ie. hiding), and would be inconsistent with the button state.
2019-04-13 02:45:21 +01:00
Gonçalo Silva 5be563ccc7 Fix search and replace
TextIter must not be reused in between buffer changes. This resulted in
unpredictable behavior when using search and replace. For instance,
in the following string:

This _is_ a _test_ of _search_ and _replace_

Searching for "_" and replacing with "**" sequentially would:

[0] This **is_ a _test_
[1] This ****is a _test_
[2] This ****is a **test_
[2] This ****is a ****test

Replace had similar results.
2019-04-13 02:45:15 +01:00
Gonçalo Silva ac7e18b0b3 Improve auto-scrolling after pasting very large documents
There were 2 problems.

When pasting very large documents, the height calculations will be
temporarily incorrect while the content is rendered over several frames.
This is addressed by waiting for the UI to be idle to scroll.

Additionally, the scroll time (typically 200ms) needs an adjustment as
well. Starting at 200ms, it now scales linearly with distance, amounting
to roughly 4 seconds with Pandoc's user guide.
2019-04-13 02:00:13 +01:00
Gonçalo Silva bf657891c6 Add link markup
Fixes #90
2019-04-13 02:00:13 +01:00
Gonçalo Silva 86c924972b Add support for code blocks, improve overall markup handling
This commit adds markup support for code blocks, styling them in a
conservative manner, similar to blockquotes, solely indenting them.

Partially fixes #90

Code-wise, this means marking up around the cursor becomes exponentially
more complex, as a change in one line can affect multiple lines. Solving
it is non-trivial, so the whole document is always marked up.

Marking up the whole document is irrelevant for small to medium
documents, but can incur in a performance penalty for
very large documents (empirical testing: 1M characters takes ~0.15s).
To alleviate this, GLib.idle_add is used to ensure that markup is only
parsed and applied when the UI is idle. Again, small to medium-sized
documents see no difference. For very large documents, markup will be
slightly delayed to allow for a fluid typing experience.

It's important to note that the previous flows frequently used full
document markup: paste, focus mode, and search and replace.
In some extreme cases, doubly parsing (eg. paste + text change).
For very large documents, doing any of these actions would freeze the UI
unconditionally, so in more ways than one this is an upgrade.

Lastly, it's a little overzealous: with over 1M characters the UI itself
struggles more than parsing.

In sum:
* Markup is always applied to the whole document
* The code is simpler
* There is never double work
* Markup is applied when the UI is idle, for a more smooth experience
* Multi-line formatting is now possible to do reliably
2019-04-13 02:00:13 +01:00
Gonçalo Silva c5d2322b96 Fix cursor position changes not scrolling in focus mode 2019-04-13 02:00:13 +01:00
Gonçalo Silva 372d2c8a65 Remove tick callback after scrolling is done
Adding a tick callback starts updating the frame clock:
d1cdb9b5cf/gtk/gtkwidget.c (L3629)

Gdk's documentation implies that this is taxing, as it continuously
requests a new frame (which makes sense, this API is for animations):
https://developer.gnome.org/gdk3/stable/GdkFrameClock.html#gdk-frame-clock-begin-updating

Most likely fixes #75
2019-04-13 02:00:13 +01:00
Gonçalo Silva 6688eb259e Refactor textview / textbuffer into separate modules
Changes include:
* Much better encapsulation of textview/textbuffer, with each isolated
responsibility living independently on its own class/file.
* Less code overall
* Various small fixes around the components involved, such as:
  * Indentation of nested lists (fixes #120)
  * Unwanted scroll on select all (ctrl+a)
* Removal of unused code around the components involved
* Fixes for scrollbar location, now at the edge of the window
2019-04-13 02:00:13 +01:00
Gonçalo Silva 16a8ac78db Fix changing theme while app is running not applying until restart
Overall refactoring of how the theme is set, bounding it to the window
instead of the application, which generally makes it easier to listen
for the "style-updated" signal.
2019-04-11 05:23:34 +01:00
Gonçalo Silva 99641125ba Uniformize main class <> file naming 2019-04-11 03:49:59 +01:00
Gonçalo Silva 30df10cab6 Allow following system theme *and* forcing light / dark theme 2019-04-11 03:42:15 +01:00
Gonçalo Silva 7a9b878d02 Copy improvements
Smaller improvements around capitalization, tense and style.
2019-04-11 03:42:15 +01:00
Manuel Genovés 23c1b2e42a Fix and improve shortcuts 2019-04-06 20:27:42 +02:00
Manuel Genovés 129041795a use pep8 naming style for modules and classes 2019-04-01 22:40:59 +02:00
Manuel Genovés d19068bc2c move all modules to /uberwriter 2019-04-01 18:00:17 +02:00
Gonçalo Silva 3f87bd1d22 Add Hemingway Mode
Closes #40
2019-03-27 02:29:29 +00:00
Manuel Genovés 6d7bfe82cb unclutter the terminal output 2019-03-26 22:02:05 +01:00
Gonçalo Silva bef52648c7 Remove hard-coded colors from MarkupBuffer
Instead, use colors set in the theme.
2019-03-26 15:09:21 +00:00
Gonçalo Silva 95e6d89514 Add support for HighContrast and HighContrastInverse themes 2019-03-26 15:09:21 +00:00
Gonçalo Silva 52f1c9f692 Add back support for Arc, Arc-Darker and Arc-Dark themes 2019-03-26 15:09:21 +00:00
Gonçalo Silva e7359c5776 Encapsulate theme handling
The Theme class encapsulates theme handling, by listing default themes
and providing means to access their gtk/web css.

Besides cleaning things up, it makes it easy to support custom themes
in the future. The user just needs to provide two CSS files, and we'll
be able to instantiate and use a Theme from that.
2019-03-26 15:09:21 +00:00
Gonçalo Silva ea566b8d73 Make preview responsive
Uses the same breakpoints as the text editor.
2019-03-26 15:07:11 +00:00
Gonçalo Silva 6a2de711cf Reload preview when theme changes 2019-03-24 05:25:51 +00:00
Gonçalo Silva 174e027076 Revert "add debug flag to webview"
This reverts commit 43c9584369.
2019-03-24 04:57:06 +00:00
Gonçalo Silva 4b146f69e6 Fix preview flash on toggle
While WebKit2 is loading, it renders a blank (white) page.
This causes it to flash briefly, while the content is not yet loaded.

Waiting for it to finish using the load-change event fixes the issue.

Fixes #112
2019-03-23 17:05:02 +00:00
Manuel Genovés 43c9584369 add debug flag to webview 2019-03-21 21:35:36 +01:00
somas95 8372eee85c
Merge branch 'master' into refactoring 2019-03-09 20:43:48 +01:00
Manuel Genovés fb47539dd8 initial theme stylesheets support 2019-03-09 19:53:28 +01:00
Manuel Genovés 6528702f55 update deprecated methods, linting 2019-01-27 20:22:24 +01:00
Manuel Genovés 7169bf9a03 update imports, basic linting 2019-01-27 20:20:56 +01:00
Manuel Genovés a1a50d4890 Remember autospellchek status 2019-01-27 16:42:36 +01:00
Manuel Genovés 66ccfb47c3 recents popover: open document on single click 2018-12-22 14:28:17 +01:00
Manuel Genovés 7066f446d2 Fix padding in "unsaved changes" modal 2018-12-14 20:47:15 +01:00
Manuel Genovés 56e718be15 allow disabling overlay within preferences window 2018-12-14 20:01:00 +01:00
Manuel Genovés 3fd91923ee Join open and recents buttons 2018-12-14 19:34:06 +01:00
somas95 226b4e81dc
Merge pull request #96 from UberWriter/styles
update styles
2018-12-06 14:51:36 +01:00
Manuel Genovés 4bb6862f0e make headerbar autohidding toggeable 2018-12-06 14:29:10 +01:00
Manuel Genovés 47c169882e update styles 2018-12-06 14:22:07 +01:00
Manuel Genovés d664308efd trailing whitespace 2018-12-05 20:32:35 +01:00
Manuel Genovés 772b1ba6db Make the overlay toggable 2018-12-05 20:27:19 +01:00