diff options
author | Stephen Swaney <sswaney@centurytel.net> | 2004-10-15 03:37:04 +0400 |
---|---|---|
committer | Stephen Swaney <sswaney@centurytel.net> | 2004-10-15 03:37:04 +0400 |
commit | 4ac462990516d2d6996ee402f27559bce16deac2 (patch) | |
tree | 80400154c078a82e8e2addb613c25906e914b8f6 /source/blender/src/drawtext.c | |
parent | 9d579591a3d5352b70c27073a0df3dd598cf5182 (diff) |
a patch for the Text editor contributed by themeyers.
adds new features for indenting and commenting.
Note: I am not sure if the best menu spot for these features
is under the Select menu, but we can argue about that later.
They do work on a selection, though.
from the mailing list post:
1&2. Added Indent/Unindent under Edit->Select
just select the text you want to indent and go to the menu (
note if nothing is selected Indent will just indent ( tab )
the line the line )
3&4. Added Comment/Uncomment to the same menu
same applies as above
5. Added Tab setting on the menu bar in text editor
Sets the number of spaces a tab ==
changing the setting will change the hole script
6. Added Auto indent
when you hit enter it goes to the next line at the same
tab number and the line above it ( needs more testing and input)
Diffstat (limited to 'source/blender/src/drawtext.c')
-rw-r--r-- | source/blender/src/drawtext.c | 41 |
1 files changed, 38 insertions, 3 deletions
diff --git a/source/blender/src/drawtext.c b/source/blender/src/drawtext.c index 0758198ab86..88895ed1983 100644 --- a/source/blender/src/drawtext.c +++ b/source/blender/src/drawtext.c @@ -156,12 +156,13 @@ void free_txt_data(void) { } static int render_string (char *in) { + SpaceText *st= curarea->spacedata.first; int r= 0, i; while(*in) { if (*in=='\t') { - if (temp_char_pos && *(in-1)=='\t') i= TXT_TABSIZE; - else i= TXT_TABSIZE - (temp_char_pos%TXT_TABSIZE); + if (temp_char_pos && *(in-1)=='\t') i= st->tabnumber; + else i= st->tabnumber - (temp_char_pos%st->tabnumber); while(i--) temp_char_write(' ', r); } else temp_char_write(*in, r); @@ -975,6 +976,24 @@ void run_python_script(SpaceText *st) } } +void set_tabs(Text *text) { + + TextLine *line = text->curl; + SpaceText *st = curarea->spacedata.first; + int pos = 0; + int max; + max = line->len; + st->currtab_set = 0; + while ( pos < max-1) { + if (line->line[pos] == '\t') { + st->currtab_set++; + pos++; + } + else { + pos++; + } + } +} void winqreadtextspace(ScrArea *sa, void *spacedata, BWinEvent *evt) { @@ -1045,7 +1064,7 @@ void winqreadtextspace(ScrArea *sa, void *spacedata, BWinEvent *evt) if (event==LEFTMOUSE) { if (val) { short mval[2]; - + set_tabs(text); getmouseco_areawin(mval); if (mval[0]>2 && mval[0]<20 && mval[1]>2 && mval[1]<curarea->winy-2) { @@ -1324,41 +1343,57 @@ void winqreadtextspace(ScrArea *sa, void *spacedata, BWinEvent *evt) break; case TABKEY: txt_add_char(text, '\t'); + st->currtab_set++; + printf("currenttab_set is :%d\n", st->currtab_set); pop_space_text(st); do_draw= 1; break; case RETKEY: txt_split_curline(text); + int a = 0; + while ( a < st->currtab_set) + { + txt_add_char(text, '\t'); + a++; + } do_draw= 1; pop_space_text(st); break; case BACKSPACEKEY: txt_backspace_char(text); + set_tabs(text); do_draw= 1; pop_space_text(st); break; case DELKEY: + if ( text->curl->line[text->curc] == '\t') { + st->currtab_set--; + } txt_delete_char(text); do_draw= 1; pop_space_text(st); break; case DOWNARROWKEY: txt_move_down(text, G.qual & LR_SHIFTKEY); + set_tabs(text); do_draw= 1; pop_space_text(st); break; case LEFTARROWKEY: txt_move_left(text, G.qual & LR_SHIFTKEY); + set_tabs(text); do_draw= 1; pop_space_text(st); break; case RIGHTARROWKEY: txt_move_right(text, G.qual & LR_SHIFTKEY); + set_tabs(text); do_draw= 1; pop_space_text(st); break; case UPARROWKEY: txt_move_up(text, G.qual & LR_SHIFTKEY); + set_tabs(text); do_draw= 1; pop_space_text(st); break; |