summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMaxime Coste <frrrwww@gmail.com>2011-09-22 14:02:07 +0000
committerMaxime Coste <frrrwww@gmail.com>2011-09-22 14:02:07 +0000
commit03c199420ebeb186b89211bec8bfb1c1463bf8a8 (patch)
tree81a4764e0084ce041c4dcf904d65b87f2dc5355e /src
parenta8cac32fe052ce8e8f2d7061423be82f37cec543 (diff)
basic g (go) command, gg/gt goes to first line, gb goes to last
Diffstat (limited to 'src')
-rw-r--r--src/main.cc27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/main.cc b/src/main.cc
index 191c82f8..7ab02efd 100644
--- a/src/main.cc
+++ b/src/main.cc
@@ -248,6 +248,32 @@ void do_insert(Window& window, bool append = false)
}
}
+void do_go(Window& window, int count)
+{
+ BufferCoord target;
+ if (count != 0)
+ {
+ target.line = count;
+ }
+ else
+ {
+ char c = getch();
+ switch (c)
+ {
+ case 'g':
+ case 't':
+ target.line = 0;
+ break;
+ case 'b':
+ target.line = window.buffer().line_count() - 1;
+ break;
+ }
+ }
+
+ BufferIterator target_it = window.buffer().iterator_at(target);
+ window.move_cursor_to(window.line_and_column_at(target_it));
+}
+
Window* current_window;
void edit(const CommandParameters& params)
@@ -348,6 +374,7 @@ std::unordered_map<char, std::function<void (Window& window, int count)>> keymap
{ 'a', [](Window& window, int count) { do_insert(window, true); } },
{ 'o', [](Window& window, int count) { window.select(true, select_line); window.append("\n"); do_insert(window, true); } },
+ { 'g', do_go },
{ ':', [](Window& window, int count) { do_command(); } },
{ ' ', [](Window& window, int count) { window.empty_selections(); } },