-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Scroll position sync support #43
base: master
Are you sure you want to change the base?
Scroll position sync support #43
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's pretty hard to read and without comments, so i needed a lot of motivation to review it sorry
} | ||
} | ||
if (highestLowerBoundElement) { | ||
highestLowerBoundElement.scrollIntoViewIfNeeded(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why "if needed"? isn't the standard just "scrollIntoView"?
@@ -9,12 +9,79 @@ | |||
|
|||
_ = init_gettext() | |||
|
|||
SCRIPT_SCROLL_TO_CURSOR = """ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the script could be in a separate file, and loaded in the init. This way, it could be a js file with syntax coloration
@@ -278,6 +279,9 @@ def _on_reload_unsafe(self): | |||
return | |||
start, end = doc.get_bounds() | |||
unsaved_text = doc.get_text(start, end, True) | |||
cursor_position = doc.get_property("cursor-position") | |||
text_iter = doc.get_iter_at_offset(cursor_position) | |||
self._webview_manager.set_cursor_position (text_iter.get_line()+1, text_iter.get_line_offset()+1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why "+1"? does it not understand zeros? then isn't it problematic that you set cursor_row and column as 0 in the init?
Added support for syncing the scroll position of the webview with the position of the cursor.
I also tried to create a
python3-markdown
plugin as described in my comment in issue #35, but I could only find a hack solution. For lists and code blocks, for example, it only outputs the source line of the beginning of the list or code block, respectively.The
sourcepos
extension frompandoc
is only available for thecommonmark
,commonmark_x
andgfm
formats. This pull request changes the input format tocommonmark
and for using features like tables etc., the required extensions needs to be enabled or one of the other two formats can be used.Currently, the position is always synced when the document is reloaded, but I think a new option in the preference window can be added for activating or deactivating the synchronization of the scroll position.