diff options
author | Ian Thompson <quornian@googlemail.com> | 2008-06-17 23:26:26 +0400 |
---|---|---|
committer | Ian Thompson <quornian@googlemail.com> | 2008-06-17 23:26:26 +0400 |
commit | 05ce388f358b1cfa7bc7c63e29bd772efbf25d39 (patch) | |
tree | a176fe91e6409a60cbd1c93fcb489136f5c56bb0 /source/blender/blenkernel/intern/text.c | |
parent | 48bf0ef2edbde0b098cf1f3717087821e0e743e3 (diff) |
Added functions to the BPy Text object for positioning the cursor and inserting text. It seems Text.write() actually inserts *then* moves to the end of the buffer, so it doesn't really append as it says in the docs. However, with these new functions both appending and inserting can be achieved.
Diffstat (limited to 'source/blender/blenkernel/intern/text.c')
-rw-r--r-- | source/blender/blenkernel/intern/text.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c index 1c7b505752f..fbb94289166 100644 --- a/source/blender/blenkernel/intern/text.c +++ b/source/blender/blenkernel/intern/text.c @@ -829,6 +829,11 @@ void txt_move_eof (Text *text, short sel) void txt_move_toline (Text *text, unsigned int line, short sel) { + txt_move_to(text, line, 0, sel); +} + +void txt_move_to (Text *text, unsigned int line, unsigned int ch, short sel) +{ TextLine **linep, *oldl; int *charp, oldc; unsigned int i; @@ -845,10 +850,12 @@ void txt_move_toline (Text *text, unsigned int line, short sel) if ((*linep)->next) *linep= (*linep)->next; else break; } - *charp= 0; + if (ch>(*linep)->len) + ch= (*linep)->len; + *charp= ch; if(!sel) txt_pop_sel(text); - if(!undoing) txt_undo_add_toop(text, sel?UNDO_STO:UNDO_CTO, txt_get_span(text->lines.first, oldl), oldc, txt_get_span(text->lines.first, *linep), (unsigned short)*charp); + if(!undoing) txt_undo_add_toop(text, sel?UNDO_STO:UNDO_CTO, txt_get_span(text->lines.first, oldl), oldc, txt_get_span(text->lines.first, *linep), (unsigned short)*charp); } /****************************/ |