[gnome-builder/wip/libide] libide: jump to file percentage with %
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/libide] libide: jump to file percentage with %
- Date: Sat, 7 Mar 2015 04:34:35 +0000 (UTC)
commit 3f65394a34f875347f0cea5ce8bb4c075fa25ae7
Author: Christian Hergert <christian hergert me>
Date: Fri Mar 6 20:33:49 2015 -0800
libide: jump to file percentage with %
data/keybindings/vim.css | 2 ++
libide/ide-source-view-movements.c | 30 ++++++++++++++++++++++++++++++
2 files changed, 32 insertions(+), 0 deletions(-)
---
diff --git a/data/keybindings/vim.css b/data/keybindings/vim.css
index 84a40ce..e023266 100644
--- a/data/keybindings/vim.css
+++ b/data/keybindings/vim.css
@@ -90,6 +90,8 @@
{
bind "0" { "append-to-count" (0)
"set-mode" ("vim-normal-with-count", transient) };
+ bind "percent" { "movement" (line-percentage, 0, 1, 1)
+ "set-mode" ("vim-normal-with-count", transient) };
}
@binding-set builder-vim-source-view-normal
diff --git a/libide/ide-source-view-movements.c b/libide/ide-source-view-movements.c
index dfdc8a8..bfa2935 100644
--- a/libide/ide-source-view-movements.c
+++ b/libide/ide-source-view-movements.c
@@ -1008,6 +1008,35 @@ ide_source_view_movements_sentence_end (Movement *mv)
_ide_vim_iter_forward_sentence_end (&mv->insert);
}
+static void
+ide_source_view_movements_line_percentage (Movement *mv)
+{
+ GtkTextBuffer *buffer;
+ GtkTextIter end;
+ guint end_line;
+
+ buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (mv->self));
+ gtk_text_buffer_get_end_iter (buffer, &end);
+ end_line = gtk_text_iter_get_line (&end);
+
+ if (!mv->count)
+ {
+ gtk_text_iter_set_line (&mv->insert, 0);
+ }
+ else
+ {
+ guint line;
+
+ mv->count = MAX (1, mv->count);
+ line = (float)end_line * (mv->count / 100.0);
+ gtk_text_iter_set_line (&mv->insert, line);
+ }
+
+ mv->count = 0;
+
+ ide_source_view_movements_first_nonspace_char (mv);
+}
+
void
_ide_source_view_apply_movement (IdeSourceView *self,
IdeSourceViewMovement movement,
@@ -1167,6 +1196,7 @@ _ide_source_view_apply_movement (IdeSourceView *self,
break;
case IDE_SOURCE_VIEW_MOVEMENT_LINE_PERCENTAGE:
+ ide_source_view_movements_line_percentage (&mv);
break;
case IDE_SOURCE_VIEW_MOVEMENT_LINE_CHARS:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]