diff options
author | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2012-11-10 21:00:33 +0100 |
---|---|---|
committer | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2012-11-10 21:00:33 +0100 |
commit | a59315f2f37b99dcee66ce0e875838b4a28ee253 (patch) | |
tree | 1d86be5d89dc5a992d9ffb494d029aab9f906b5e | |
parent | 406ddaa73a75e34eb57db18dfc62c7d8208d141a (diff) | |
download | sciteco-a59315f2f37b99dcee66ce0e875838b4a28ee253.tar.gz |
support 0EB...$ command
* same as EB...$, but displays the buffer ring in the filename popup with the current file highlighted immediately after the EB
-rw-r--r-- | qbuffers.cpp | 21 | ||||
-rw-r--r-- | qbuffers.h | 16 |
2 files changed, 35 insertions, 2 deletions
diff --git a/qbuffers.cpp b/qbuffers.cpp index 61eab15..289683a 100644 --- a/qbuffers.cpp +++ b/qbuffers.cpp @@ -5,11 +5,14 @@ #include <glib/gprintf.h> #include <glib/gstdio.h> +#include "gtk-info-popup.h" + #include <Scintilla.h> #include "sciteco.h" #include "undo.h" #include "parser.h" +#include "expressions.h" #include "qbuffers.h" Ring ring; @@ -110,7 +113,7 @@ Ring::close(void) Buffer *buffer = current; buffer->close(); - current = LIST_NEXT(buffer, buffers) ? : LIST_FIRST(&head); + current = buffer->next() ? : first(); if (!current) edit(NULL); @@ -137,6 +140,22 @@ StateFile::do_edit(const gchar *filename) ring.undo_close(); } +void +StateFile::initial(void) +{ + gint64 id = expressions.pop_num_calc(1, -1); + + if (id == 0) { + for (Buffer *cur = ring.first(); cur; cur = cur->next()) + gtk_info_popup_add_filename(filename_popup, + GTK_INFO_POPUP_FILE, + cur->filename ? : "(Unnamed)", + cur == ring.current); + + gtk_widget_show(GTK_WIDGET(filename_popup)); + } +} + State * StateFile::done(const gchar *str) { @@ -50,6 +50,12 @@ public: g_free(filename); } + inline Buffer * + next(void) + { + return LIST_NEXT(this, buffers); + } + inline void set_filename(const gchar *filename) { @@ -82,15 +88,22 @@ public: extern class Ring { LIST_HEAD(Head, Buffer) head; - Buffer *current; public: + Buffer *current; + Ring() : current(NULL) { LIST_INIT(&head); } ~Ring(); + inline Buffer * + first(void) + { + return LIST_FIRST(&head); + } + Buffer *find(const gchar *filename); bool edit(const gchar *filename); @@ -119,6 +132,7 @@ class StateFile : public StateExpectString { private: void do_edit(const gchar *filename); + void initial(void); State *done(const gchar *str); }; |