From a59315f2f37b99dcee66ce0e875838b4a28ee253 Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Sat, 10 Nov 2012 21:00:33 +0100 Subject: support 0EB...$ command * same as EB...$, but displays the buffer ring in the filename popup with the current file highlighted immediately after the EB --- qbuffers.cpp | 21 ++++++++++++++++++++- 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 #include +#include "gtk-info-popup.h" + #include #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) { diff --git a/qbuffers.h b/qbuffers.h index eb4c2d4..b837423 100644 --- a/qbuffers.h +++ b/qbuffers.h @@ -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); }; -- cgit v1.2.3