Commit Graph

298 Commits (ui)

Author SHA1 Message Date
Manuel Genovés 17c20199f5 use A4 papersize by default 2019-11-29 13:28:19 +01:00
Manuel Genovés 8ac8728e3b implement hack to fade away the headerbar 2019-11-23 02:11:32 +01:00
Manuel Genovés 0e2f731ff4 Use a .ui file to define the headerbar
This makes all the headerbar code more readable and easier to tweak
2019-11-11 01:27:39 +01:00
Manuel Genovés 10f98f35b8 fix filename path 2019-11-10 19:02:22 +01:00
Manuel Genovés f4809faf19 Merge branch 'master' 2019-11-05 12:28:08 +01:00
Manuel Genovés 3af59e2c1d initial port to gresources 2019-11-04 23:05:03 +01:00
Manuel Genoves ca0b458ca1 fix non flatpak data paths 2019-10-30 01:29:35 +01:00
Manuel Genoves e39e515e6d fix data path for non flatpak installs 2019-10-30 01:14:56 +01:00
Gonçalo Silva ec2f33e248 Add 'url' regexp group to LINK_ALT
Enables inline preview.
2019-07-25 23:57:27 +01:00
Gonçalo Silva 3bb813895e Fix warning when opening file
set/clear text should count as a single user action.
2019-07-25 00:18:33 +01:00
Gonçalo Silva 128ce54761 Handle inline code correctly
Inline code shouldn't have its "paragraph-background" set, as it's not a
block-level element.
2019-07-25 00:18:33 +01:00
Gonçalo Silva b4696cda30 Don't scroll when opening documents, only when pasting text 2019-07-25 00:18:33 +01:00
Gonçalo Silva 05cdfe0599 Use CommonMark's regexp for autolink / autoemail
Ref: https://github.com/commonmark/commonmark.js/blob/master/lib/inlines.js#L62-L64

Also avoids special handling in stats counter.
2019-07-25 00:18:33 +01:00
Manuel Genovés 63ff2659fc There is no necessity to strip + signs from URIS
Closes #171
2019-07-25 00:18:33 +01:00
Manuel Genovés 53a9f4ebbd manage open_file errors 2019-07-25 00:18:33 +01:00
Manuel Genovés 3cae19c0cc catch exporting errors.
Fixes #164
2019-07-25 00:18:33 +01:00
Manuel Genovés 3e661b8d9d support https in the alt link markdown query 2019-07-25 00:18:33 +01:00
Manuel Genovés 300c386631 Added handling of alternate form of urls 2019-07-25 00:18:33 +01:00
Gonçalo Silva 7c3d4d9364 Adjust regex tests for CommonMark, improve inline regexp 2019-07-25 00:18:33 +01:00
Gonçalo Silva 23cddba0d0 Add shortcut for find and replace
Also renames "search" to "find" as most other Gtk apps.
2019-07-25 00:18:33 +01:00
Gonçalo Silva 859ad84524 Improve handling of bold italic
**_bolditalic_** and other mixed combinations now work.
2019-07-25 00:18:33 +01:00
Gonçalo Silva 7ea8f67216 Add code highlighting
Removes previously added indent. Reused for math.
2019-07-25 00:18:33 +01:00
Gonçalo Silva bd2d78b86a Add format inserts to the undo stack as single actions
Also fixes undoing list items.
2019-07-25 00:18:33 +01:00
Gonçalo Silva 0b6e84bf8c Add search and replace to the undo stack as a single action
This is specially important for search and replace *all*.
2019-07-25 00:18:33 +01:00
Gonçalo Silva aa3f5c3430 Remove unused file, reformat helpers 2019-07-25 00:18:33 +01:00
Gonçalo Silva e3b99e823b Undo support for begin-user-action and end-user-action
Allows keeping track of multiple changes within a single action together.
2019-07-25 00:18:07 +01:00
Gonçalo Silva d9014b12e7 Open preview links in the browser 2019-07-25 00:18:07 +01:00
Gonçalo Silva efb1a02f30 Use file name for link description and image caption 2019-07-25 00:18:07 +01:00
Gonçalo Silva ef4009fcd6 Keep file:// prefix for drag & droped files 2019-07-25 00:18:07 +01:00
Gonçalo Silva 7c6d2c12a3 Fix erroneous unescaping of link uris
Unescaped links won't work when containing special characters.
2019-07-25 00:18:07 +01:00
Gonçalo Silva 1cc2fc5a4c Fix presenting window after drag & drop 2019-07-25 00:18:07 +01:00
Manuel Genovés adcb73b129 fix small regex errors in header queries 2019-07-25 00:18:07 +01:00
Manuel Genovés c8ea808623 fix math REGEX expression 2019-07-25 00:18:07 +01:00
Gonçalo Silva 55e5cd3856 Use `selection_bound` instead of `insert` to markup/scroll 2019-07-25 00:16:26 +01:00
Gonçalo Silva 3fa56afaef Reduce sync scrolling precision
High precision leads to micro-scrolling, and 1e-4 is more than enough.
2019-07-25 00:16:26 +01:00
Gonçalo Silva 55d82856c2 Fix list markup parsing
Subsequent list items were being erroneously discarded.
2019-07-25 00:16:26 +01:00
Gonçalo Silva 931d92bdfd Move markup to a worker process
A worker thread works in practice, but the GIL takes a significant toll
as the code is computationally heavy. The result is a hogged UI,
specially when other threads are involved (eg. stats counter).

A worker process is faster, hogs the UI significantly less, at the cost
of slightly higher memory usage.

As side-effects:
- UberWriter can now comfortably handle much larger documents
- Text selection is much more responsive
2019-07-25 00:16:26 +01:00
Gonçalo Silva bb279d0379 Move stats counting to a worker process
A worker thread works in practice, but the GIL takes a significant toll
as the code is computationally heavy. The result is a hogged UI,
specially when other threads are involved (eg. markup handler).

A worker process is faster, hogs the UI significantly less, at the cost
of slightly higher memory usage.
2019-07-25 00:16:26 +01:00
Gonçalo Silva 0d87299040 Fix paragraph counting
Markdown requires at least 2 newlines to form a paragraph.
2019-07-25 00:16:26 +01:00
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
Manuel Genovés f0f2f05670 Merge branch 'master' 2019-05-18 18:51:45 +02: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
Manuel Genovés 7e34e9cc62 Merge branch 'master' 2019-05-12 21:24:30 +02: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
Manuel Genovés bc24251461 even with master 2019-05-04 21:15:24 +02: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
Manuel Genovés 844890507c add path to headerbar subtitle 2019-04-14 20:15:46 +02:00