Page Menu
Home
Search
Configure Global Search
Log In
Files
F10285
line_break_spaces.patch
Public
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Authored By
Fabian Fricke (frigi)
Nov 13 2013, 2:12 PM
Size
2 KB
Subscribers
None
line_break_spaces.patch
View Options
Index: source/blender/blenkernel/BKE_text.h
===================================================================
--- source/blender/blenkernel/BKE_text.h (revision 30873)
+++ source/blender/blenkernel/BKE_text.h (working copy)
@@ -92,7 +92,7 @@
void comment (struct Text *text);
void indent (struct Text *text);
void uncomment (struct Text *text);
-int setcurr_tab (struct Text *text);
+int setcurr_tab_spaces (struct Text *text, int space);
void txt_add_marker (struct Text *text, struct TextLine *line, int start, int end, char color[4], int group, int flags);
short txt_clear_marker_region (struct Text *text, struct TextLine *line, int start, int end, int group, int flags);
Index: source/blender/blenkernel/intern/text.c
===================================================================
--- source/blender/blenkernel/intern/text.c (revision 30873)
+++ source/blender/blenkernel/intern/text.c (working copy)
@@ -2683,7 +2683,7 @@
}
}
-int setcurr_tab (Text *text)
+int setcurr_tab_spaces (Text *text, int space)
{
int i = 0;
int test = 0;
@@ -2693,9 +2693,9 @@
if (!text) return 0;
if (!text->curl) return 0;
- while (text->curl->line[i] == '\t')
+ while (text->curl->line[i] == '\t' || ( (text->flags & TXT_TABSTOSPACES) && text->curl->line[i] == ' ') )
{
- //we only count thos tabs that are before any text or before the curs;
+ //we only count those tabs/spaces that are before any text or before the curs;
if (i == text->curc)
{
return i;
@@ -2718,7 +2718,7 @@
}
}
if (indent) {
- i++;
+ i += space;
}
}
@@ -2729,7 +2729,7 @@
{
if(strcspn(text->curl->line, back_words[test]) < strcspn(text->curl->line, comm))
{
- i--;
+ i -= space;
}
}
}
Index: source/blender/editors/space_text/text_ops.c
===================================================================
--- source/blender/editors/space_text/text_ops.c (revision 30873)
+++ source/blender/editors/space_text/text_ops.c (working copy)
@@ -902,15 +902,22 @@
static int line_break_exec(bContext *C, wmOperator *op)
{
+ SpaceText *st= CTX_wm_space_text(C);
Text *text= CTX_data_edit_text(C);
- int a, curtab;
+ int a, curts;
+ int space = (text->flags & TXT_TABSTOSPACES) ? st->tabnumber : 1;
- // double check tabs before splitting the line
- curtab= setcurr_tab(text);
+ // double check tabs/spaces before splitting the line
+ curts= setcurr_tab_spaces(text, space);
txt_split_curline(text);
- for(a=0; a < curtab; a++)
- txt_add_char(text, '\t');
+ for(a=0; a < curts; a++) {
+ if (text->flags & TXT_TABSTOSPACES) {
+ txt_add_char(text, ' ');
+ } else {
+ txt_add_char(text, '\t');
+ }
+ }
if(text->curl) {
if(text->curl->prev)
File Metadata
Details
Mime Type
text/x-diff
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
2d/25/6f8df67b53bf7d56d73201df6481
Event Timeline
Log In to Comment