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
This commit is contained in:
Nick Treleaven 2006-08-03 13:27:30 +00:00
parent 51f4486876
commit c6fa1febba
4 changed files with 36 additions and 1 deletions

View File

@ -1,3 +1,9 @@
2006-08-03 Nick Treleaven <nick.treleaven@btinternet.com>
* 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 <enrico.troeger@uvena.de> 2006-08-02 Enrico Tröger <enrico.troeger@uvena.de>
* src/callbacks.c: * src/callbacks.c:

View File

@ -351,6 +351,7 @@ void sci_cb_close_block(ScintillaObject *sci, gint pos)
gboolean sci_cb_show_calltip(ScintillaObject *sci, gint pos, gint idx) gboolean sci_cb_show_calltip(ScintillaObject *sci, gint pos, gint idx)
{ {
gint orig_pos = pos; //the position for the calltip
gint lexer; gint lexer;
gint style; gint style;
gchar word[GEANY_MAX_WORD_LENGTH]; gchar word[GEANY_MAX_WORD_LENGTH];
@ -368,6 +369,7 @@ gboolean sci_cb_show_calltip(ScintillaObject *sci, gint pos, gint idx)
gchar c; gchar c;
// position of '(' is unknown, so go backwards to find it // position of '(' is unknown, so go backwards to find it
pos = SSM(sci, SCI_GETCURRENTPOS, 0, 0); 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, // 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 // but we need something more intelligent than only check for '(' because e.g. LaTeX
// uses {, [ or ( // uses {, [ or (
@ -397,7 +399,8 @@ gboolean sci_cb_show_calltip(ScintillaObject *sci, gint pos, gint idx)
else else
calltip = g_strconcat(tag->name, " ", tag->atts.entry.arglist, NULL); 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); g_free(calltip);
} }

View File

@ -2532,3 +2532,25 @@ void utils_document_show_hide(gint idx)
app->ignore_callback = FALSE; 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;
}

View File

@ -227,4 +227,8 @@ gboolean utils_is_unicode_charset(const gchar *string);
void utils_document_show_hide(gint idx); 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 #endif