diff options
-rw-r--r-- | cmdline.cpp | 11 | ||||
-rw-r--r-- | interface-gtk.cpp | 10 | ||||
-rw-r--r-- | interface-gtk.h | 2 | ||||
-rw-r--r-- | interface.h | 2 | ||||
-rw-r--r-- | main.cpp | 3 |
5 files changed, 15 insertions, 13 deletions
diff --git a/cmdline.cpp b/cmdline.cpp index 557e056..31badb5 100644 --- a/cmdline.cpp +++ b/cmdline.cpp @@ -13,7 +13,7 @@ #include "undo.h" static inline const gchar *process_edit_cmd(gchar key); -static gchar *macro_echo(const gchar *macro, const gchar *prefix = ""); +static gchar *macro_echo(const gchar *macro); static gchar *filename_complete(const gchar *filename, gchar completed = ' '); static const gchar *last_occurrence(const gchar *str, @@ -65,7 +65,7 @@ cmdline_keypress(gchar key) /* * Echo command line */ - echo = macro_echo(cmdline, "*"); + echo = macro_echo(cmdline); interface.cmdline_update(echo); g_free(echo); } @@ -135,15 +135,14 @@ process_edit_cmd(gchar key) } static gchar * -macro_echo(const gchar *macro, const gchar *prefix) +macro_echo(const gchar *macro) { gchar *result, *rp; if (!macro) - return g_strdup(prefix); + return g_strdup(""); - result = (gchar *)g_malloc(strlen(prefix) + strlen(macro)*5 + 1); - rp = g_stpcpy(result, prefix); + rp = result = (gchar *)g_malloc(strlen(macro)*5 + 1); for (const gchar *p = macro; *p; p++) { switch (*p) { diff --git a/interface-gtk.cpp b/interface-gtk.cpp index 55e546e..7fc645e 100644 --- a/interface-gtk.cpp +++ b/interface-gtk.cpp @@ -106,10 +106,14 @@ InterfaceGtk::msg(MessageType type, const gchar *fmt, ...) } void -InterfaceGtk::cmdline_update(const gchar *cmdline_str) +InterfaceGtk::cmdline_update(const gchar *cmdline) { - gtk_entry_set_text(GTK_ENTRY(cmdline_widget), cmdline_str); - gtk_editable_set_position(GTK_EDITABLE(cmdline_widget), -1); + gint pos = 1; + + gtk_entry_set_text(GTK_ENTRY(cmdline_widget), "*"); + gtk_editable_insert_text(GTK_EDITABLE(cmdline_widget), + cmdline, -1, &pos); + gtk_editable_set_position(GTK_EDITABLE(cmdline_widget), pos); } void diff --git a/interface-gtk.h b/interface-gtk.h index e6b9166..95a58d7 100644 --- a/interface-gtk.h +++ b/interface-gtk.h @@ -40,7 +40,7 @@ public: iMessage, wParam, lParam); } - void cmdline_update(const gchar *cmdline); + void cmdline_update(const gchar *cmdline = ""); void popup_add_filename(PopupFileType type, const gchar *filename, bool highlight = false); diff --git a/interface.h b/interface.h index cf261fb..6e43392 100644 --- a/interface.h +++ b/interface.h @@ -34,7 +34,7 @@ public: virtual sptr_t ssm(unsigned int iMessage, uptr_t wParam = 0, sptr_t lParam = 0) = 0; - virtual void cmdline_update(const gchar *cmdline) = 0; + virtual void cmdline_update(const gchar *cmdline = "") = 0; enum PopupFileType { POPUP_FILE, @@ -101,8 +101,7 @@ main(int argc, char **argv) undo.enabled = true; - interface.cmdline_update("*"); - + interface.cmdline_update(); interface.event_loop(); return 0; |