summaryrefslogtreecommitdiff
path: root/app/wlib/gtklib/text.c
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff-webhosting.net>2020-08-22 14:05:41 +0200
committerJörg Frings-Fürst <debian@jff-webhosting.net>2020-08-22 14:05:41 +0200
commitb55285a77da0e0b829e4ce8d7e09debaabc68e15 (patch)
treef622559ef65bbdd3e1c5bdb06098a8f89eec0563 /app/wlib/gtklib/text.c
parentd3897ce090dbeb220ed2c782f095597e417cf3cc (diff)
parentd1ae75703e1ed81d65ea16946dcdb77e7a13adc9 (diff)
Merge branch 'feature/upstream' into develop
Diffstat (limited to 'app/wlib/gtklib/text.c')
-rw-r--r--app/wlib/gtklib/text.c24
1 files changed, 19 insertions, 5 deletions
diff --git a/app/wlib/gtklib/text.c b/app/wlib/gtklib/text.c
index f7ba288..0812ace 100644
--- a/app/wlib/gtklib/text.c
+++ b/app/wlib/gtklib/text.c
@@ -98,6 +98,8 @@ void wTextAppend(wText_p bt,
{
GtkTextBuffer *tb;
GtkTextIter ti1;
+ GtkTextMark *tm;
+
if (bt->text == 0) {
abort();
@@ -109,6 +111,18 @@ void wTextAppend(wText_p bt,
// append to end of buffer
gtk_text_buffer_get_end_iter(tb, &ti1);
gtk_text_buffer_insert(tb, &ti1, text, -1);
+
+ if ( bt->option & BT_TOP ) {
+ // and scroll to start of text
+ gtk_text_buffer_get_start_iter(tb, &ti1);
+ } else {
+ // and scroll to end of text
+ gtk_text_buffer_get_end_iter(tb, &ti1);
+ }
+ tm = gtk_text_buffer_create_mark(tb, NULL, &ti1, TRUE );
+ gtk_text_view_scroll_mark_onscreen (GTK_TEXT_VIEW(bt->text), tm );
+ gtk_text_buffer_delete_mark( tb, tm );
+
bt->changed = FALSE;
}
@@ -116,7 +130,7 @@ void wTextAppend(wText_p bt,
* Get the text from a text buffer in system codepage
* The caller is responsible for free'ing the allocated storage.
*
- * \todo handling of return from gtkConvertOutput can be improved
+ * Dont convert from UTF8
*
* \param bt IN the text widget
* \return pointer to the converted text
@@ -135,8 +149,8 @@ static char *wlibGetText(wText_p bt)
tb = gtk_text_view_get_buffer(GTK_TEXT_VIEW(bt->text));
gtk_text_buffer_get_bounds(tb, &ti1, &ti2);
cp = gtk_text_buffer_get_text(tb, &ti1, &ti2, FALSE);
- cp1 = wlibConvertOutput(cp);
- res = strdup(cp1);
+ //cp1 = wlibConvertOutput(cp);
+ res = strdup(cp);
g_free(cp);
return res;
}
@@ -375,7 +389,7 @@ wBool_t wTextPrint(
* Get the length of text
*
* \param bt IN the text widget
- * \return length of string
+ * \return length of string including terminating \0
*/
int wTextGetSize(wText_p bt)
@@ -383,7 +397,7 @@ int wTextGetSize(wText_p bt)
char *cp = wlibGetText(bt);
int len = strlen(cp);
free(cp);
- return len;
+ return len + 1;
}
/**