Branch: refs/heads/master Author: Jiří Techet techet@gmail.com Committer: GitHub noreply@github.com Date: Fri, 24 May 2024 20:14:51 UTC Commit: 7da755364ccbed6b25463845e9afe970840e579d https://github.com/geany/geany-plugins/commit/7da755364ccbed6b25463845e9afe9...
Log Message: ----------- Merge pull request #1349 from scresto09/vimode-handle-fold-marginclick
Vimode: handle fold and margin click event
Modified Paths: -------------- vimode/src/utils.c vimode/src/utils.h vimode/src/vi.c
Modified: vimode/src/utils.c 25 lines changed, 25 insertions(+), 0 deletions(-) =================================================================== @@ -228,3 +228,28 @@ void ensure_current_line_expanded(ScintillaObject *sci) if (!SSM(sci, SCI_GETLINEVISIBLE, line, 0)) SSM(sci, SCI_ENSUREVISIBLE, line, 0); } + + +gint jump_to_expended_parent(ScintillaObject *sci, gint line) +{ + gint fold_parent = line; + + /* go through the parents as long as they are not visible */ + while (SSM(sci, SCI_GETLINEVISIBLE, fold_parent, 0) == FALSE) + { + gint prev_parent = SSM(sci, SCI_GETFOLDPARENT, fold_parent, 0); + + if (prev_parent == -1) + break; + fold_parent = prev_parent; + } + + if (fold_parent != line) + { + /* move the cursor on the visible line before the fold */ + gint pos = SSM(sci, SCI_POSITIONFROMLINE, fold_parent, 0); + SET_POS(sci, pos, TRUE); + } + + return fold_parent; +}
Modified: vimode/src/utils.h 2 lines changed, 2 insertions(+), 0 deletions(-) =================================================================== @@ -34,4 +34,6 @@ void perform_substitute(ScintillaObject *sci, const gchar *cmd, gint from, gint gint get_line_number_rel(ScintillaObject *sci, gint shift); void ensure_current_line_expanded(ScintillaObject *sci);
+gint jump_to_expended_parent(ScintillaObject *sci, gint line); + #endif
Modified: vimode/src/vi.c 9 lines changed, 9 insertions(+), 0 deletions(-) =================================================================== @@ -312,6 +312,15 @@ gboolean vi_notify_sci(SCNotification *nt) if (nt->nmhdr.code == SCN_MODIFIED && (nt->modificationType & SC_MOD_BEFOREINSERT && nt->modificationType & SC_PERFORMED_UNDO) && nt->length > 1) undo_update(&ctx, nt->position);
+ if (nt->nmhdr.code == SCN_MARGINCLICK) + { + if (nt->margin == 2) + { + gint line = GET_CUR_LINE(sci); + jump_to_expended_parent(sci, line); + } + } + /* This makes sure that when we click behind the end of line in command mode, * the cursor is not placed BEHIND the last character but ON the last character. * We want to ignore this when doing selection with mouse as it breaks things. */
-------------- This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).