From 5ee9dcade2334649489a0a9b5c1b858706582136 Mon Sep 17 00:00:00 2001 From: Phil Longstaff Date: Fri, 25 Sep 2009 23:36:56 +0000 Subject: [PATCH] Enhancement bug 589787 - Multi-line up/down scroll for register transaction Notes field text Patch by James Raehl git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@18348 57a11ea4-9604-0410-9ed3-97b8803252fd --- .../register-gnome/gnucash-item-edit.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/register/register-gnome/gnucash-item-edit.c b/src/register/register-gnome/gnucash-item-edit.c index aa4a23e7a7..18a7b4dc31 100644 --- a/src/register/register-gnome/gnucash-item-edit.c +++ b/src/register/register-gnome/gnucash-item-edit.c @@ -168,6 +168,8 @@ gnc_item_edit_update_offset (GncItemEdit *item_edit, TextDrawInfo *info) static void gnc_item_edit_draw_info (GncItemEdit *item_edit, int x, int y, TextDrawInfo *info) { + const char LINE_FEED = 0x0a; + SheetBlock *block; SheetBlockStyle *style; GtkEditable *editable; @@ -178,7 +180,7 @@ gnc_item_edit_draw_info (GncItemEdit *item_edit, int x, int y, TextDrawInfo *inf int xd, yd, wd, hd, dx, dy; int start_pos, end_pos; - int toggle_space, cursor_pos, cursor_byte_pos; + int toggle_space, cursor_pos, cursor_byte_pos, pos, loc; const gchar *text; PangoRectangle strong_pos; PangoAttribute *attr; @@ -214,6 +216,21 @@ gnc_item_edit_draw_info (GncItemEdit *item_edit, int x, int y, TextDrawInfo *inf gtk_editable_get_selection_bounds (editable, &start_pos, &end_pos); + if (cursor_pos == cursor_byte_pos) { + /* display at character after LF before cursor_pos */ + /* (but not for UTF-8, which is messier to implement) */ + for (pos = 0, loc = 0; pos <= start_pos; pos++) { + if ((pos > 0) && (text[pos-1] == LINE_FEED)) { + loc = pos; + } + } + text += loc; + start_pos -= loc; + end_pos -= loc; + cursor_pos -= loc; + cursor_byte_pos = g_utf8_offset_to_pointer (text, cursor_pos) - text; + } + info->layout = gtk_widget_create_pango_layout (GTK_WIDGET (item_edit->sheet), text); /* Selection */