From c6fa1febba224ac1852ab6257540ec7c7147b2f4 Mon Sep 17 00:00:00 2001 From: Nick Treleaven Date: Thu, 3 Aug 2006 13:27:30 +0000 Subject: [PATCH] Wrap calltip and prevent it obscuring the current line git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@666 ea778897-0a13-0410-b9d1-a72fbfd435f5 --- ChangeLog | 6 ++++++ src/sci_cb.c | 5 ++++- src/utils.c | 22 ++++++++++++++++++++++ src/utils.h | 4 ++++ 4 files changed, 36 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 2b3dff856..36e1599e0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2006-08-03 Nick Treleaven + + * src/utils.c, src/utils.h, src/sci_cb.c: + Wrap calltip and prevent it obscuring the current line. + + 2006-08-02 Enrico Tröger * src/callbacks.c: diff --git a/src/sci_cb.c b/src/sci_cb.c index cfe4be773..ddb455de2 100644 --- a/src/sci_cb.c +++ b/src/sci_cb.c @@ -351,6 +351,7 @@ void sci_cb_close_block(ScintillaObject *sci, gint pos) gboolean sci_cb_show_calltip(ScintillaObject *sci, gint pos, gint idx) { + gint orig_pos = pos; //the position for the calltip gint lexer; gint style; gchar word[GEANY_MAX_WORD_LENGTH]; @@ -368,6 +369,7 @@ gboolean sci_cb_show_calltip(ScintillaObject *sci, gint pos, gint idx) gchar c; // position of '(' is unknown, so go backwards to find it pos = SSM(sci, SCI_GETCURRENTPOS, 0, 0); + orig_pos = pos; // I'm not sure if utils_is_opening_brace() is a good idea, but it is the simplest way, // but we need something more intelligent than only check for '(' because e.g. LaTeX // uses {, [ or ( @@ -397,7 +399,8 @@ gboolean sci_cb_show_calltip(ScintillaObject *sci, gint pos, gint idx) else calltip = g_strconcat(tag->name, " ", tag->atts.entry.arglist, NULL); - SSM(sci, SCI_CALLTIPSHOW, pos, (sptr_t) calltip); + utils_wrap_string(calltip, -1); + SSM(sci, SCI_CALLTIPSHOW, orig_pos, (sptr_t) calltip); g_free(calltip); } diff --git a/src/utils.c b/src/utils.c index 96492cd9e..d62a732c4 100644 --- a/src/utils.c +++ b/src/utils.c @@ -2532,3 +2532,25 @@ void utils_document_show_hide(gint idx) app->ignore_callback = FALSE; } + + +/* Wraps a string in place, replacing a space with a newline character. + * wrapstart is the minimum position to start wrapping or -1 for default */ +gboolean utils_wrap_string(gchar *string, gint wrapstart) +{ + gchar *pos, *linestart; + gboolean ret = FALSE; + + if (wrapstart < 0) wrapstart = 80; + + for (pos = linestart = string; *pos != '\0'; pos++) + { + if (pos - linestart >= wrapstart && *pos == ' ') + { + *pos = '\n'; + linestart = pos; + ret = TRUE; + } + } + return ret; +} diff --git a/src/utils.h b/src/utils.h index 8c04957e6..c180c3119 100644 --- a/src/utils.h +++ b/src/utils.h @@ -227,4 +227,8 @@ gboolean utils_is_unicode_charset(const gchar *string); void utils_document_show_hide(gint idx); +/* Wraps a string in place, replacing a space with a newline character. + * wrapstart is the minimum position to start wrapping or -1 for default */ +gboolean utils_wrap_string(gchar *string, gint wrapstart); + #endif