[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [52515] trunk/blender: Text Editor: remove text marker functionality.

Justin Dailey dail8859 at yahoo.com
Fri Nov 23 15:33:14 CET 2012


Revision: 52515
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=52515
Author:   dail
Date:     2012-11-23 14:33:14 +0000 (Fri, 23 Nov 2012)
Log Message:
-----------
Text Editor: remove text marker functionality. Patch [#33251]

Modified Paths:
--------------
    trunk/blender/release/scripts/startup/bl_ui/space_text.py
    trunk/blender/source/blender/blenkernel/BKE_text.h
    trunk/blender/source/blender/blenkernel/intern/text.c
    trunk/blender/source/blender/blenloader/intern/readfile.c
    trunk/blender/source/blender/blenloader/intern/writefile.c
    trunk/blender/source/blender/editors/space_text/space_text.c
    trunk/blender/source/blender/editors/space_text/text_draw.c
    trunk/blender/source/blender/editors/space_text/text_intern.h
    trunk/blender/source/blender/editors/space_text/text_ops.c
    trunk/blender/source/blender/editors/space_text/text_python.c
    trunk/blender/source/blender/makesdna/DNA_text_types.h
    trunk/blender/source/blender/makesrna/RNA_access.h
    trunk/blender/source/blender/makesrna/intern/rna_text.c

Modified: trunk/blender/release/scripts/startup/bl_ui/space_text.py
===================================================================
--- trunk/blender/release/scripts/startup/bl_ui/space_text.py	2012-11-23 13:41:25 UTC (rev 52514)
+++ trunk/blender/release/scripts/startup/bl_ui/space_text.py	2012-11-23 14:33:14 UTC (rev 52515)
@@ -137,9 +137,6 @@
         row.operator("text.replace_set_selected", text="", icon='TEXT')
         col.operator("text.replace")
 
-        # mark
-        layout.operator("text.mark_all")
-
         # settings
         layout.prop(st, "use_match_case")
         row = layout.row()
@@ -216,17 +213,6 @@
         layout.operator("text.select_line")
 
 
-class TEXT_MT_edit_markers(Menu):
-    bl_label = "Markers"
-
-    def draw(self, context):
-        layout = self.layout
-
-        layout.operator("text.markers_clear")
-        layout.operator("text.next_marker")
-        layout.operator("text.previous_marker")
-
-
 class TEXT_MT_format(Menu):
     bl_label = "Format"
 
@@ -290,7 +276,6 @@
         layout.separator()
 
         layout.menu("TEXT_MT_edit_select")
-        layout.menu("TEXT_MT_edit_markers")
 
         layout.separator()
 

Modified: trunk/blender/source/blender/blenkernel/BKE_text.h
===================================================================
--- trunk/blender/source/blender/blenkernel/BKE_text.h	2012-11-23 13:41:25 UTC (rev 52514)
+++ trunk/blender/source/blender/blenkernel/BKE_text.h	2012-11-23 14:33:14 UTC (rev 52515)
@@ -100,14 +100,6 @@
 void	txt_duplicate_line	(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, const unsigned 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);
-short	txt_clear_markers					(struct Text *text, int group, int flags);
-struct TextMarker	*txt_find_marker		(struct Text *text, struct TextLine *line, int curs, int group, int flags);
-struct TextMarker	*txt_find_marker_region	(struct Text *text, struct TextLine *line, int start, int end, int group, int flags);
-struct TextMarker	*txt_prev_marker		(struct Text *text, struct TextMarker *marker);
-struct TextMarker	*txt_next_marker		(struct Text *text, struct TextMarker *marker);
-
 /* utility functions, could be moved somewhere more generic but are python/text related  */
 int text_check_bracket(const char ch);
 int text_check_delim(const char ch);
@@ -161,10 +153,6 @@
 
 #define UNDO_DUPLICATE  040
 
-/* Marker flags */
-#define TMARK_TEMP		0x01	/* Remove on non-editing events, don't save */
-#define TMARK_EDITALL	0x02	/* Edit all markers of the same group as one */
-
 #ifdef __cplusplus
 }
 #endif

Modified: trunk/blender/source/blender/blenkernel/intern/text.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/text.c	2012-11-23 13:41:25 UTC (rev 52514)
+++ trunk/blender/source/blender/blenkernel/intern/text.c	2012-11-23 14:33:14 UTC (rev 52515)
@@ -96,17 +96,6 @@
  * If the user moves the cursor the st containing that cursor should
  * be popped ... other st's retain their own top location.
  *
- * Markers
- * --
- * The mrk->flags define the behavior and relationships between markers. The
- * upper two bytes are used to hold a group ID, the lower two are normal flags. If
- * TMARK_EDITALL is set the group ID defines which other markers should be edited.
- *
- * The mrk->clr field is used to visually group markers where the flags may not
- * match. A template system, for example, may allow editing of repeating tokens
- * (in one group) but include other marked positions (in another group) all in the
- * same template with the same color.
- *
  * Undo
  * --
  * Undo/Redo works by storing
@@ -174,7 +163,6 @@
 	}
 	
 	BLI_freelistN(&text->lines);
-	BLI_freelistN(&text->markers);
 
 	if (text->name) MEM_freeN(text->name);
 	MEM_freeN(text->undo_buf);
@@ -202,7 +190,6 @@
 		ta->flags |= TXT_TABSTOSPACES;
 
 	ta->lines.first = ta->lines.last = NULL;
-	ta->markers.first = ta->markers.last = NULL;
 
 	tmp = (TextLine *) MEM_mallocN(sizeof(TextLine), "textline");
 	tmp->line = (char *) MEM_mallocN(1, "textline_string");
@@ -398,7 +385,6 @@
 	ta->id.us = 1;
 
 	ta->lines.first = ta->lines.last = NULL;
-	ta->markers.first = ta->markers.last = NULL;
 	ta->curl = ta->sell = NULL;
 
 	if ((U.flag & USER_TXT_TABSTOSPACES_DISABLE) == 0)
@@ -495,7 +481,6 @@
 	tan->flags = ta->flags | TXT_ISDIRTY;
 	
 	tan->lines.first = tan->lines.last = NULL;
-	tan->markers.first = tan->markers.last = NULL;
 	tan->curl = tan->sell = NULL;
 	
 	tan->nlines = ta->nlines;
@@ -1150,9 +1135,7 @@
 static void txt_delete_sel(Text *text)
 {
 	TextLine *tmpl;
-	TextMarker *mrk;
 	char *buf;
-	int move, lineno;
 	
 	if (!text) return;
 	if (!text->curl) return;
@@ -1169,29 +1152,7 @@
 	}
 
 	buf = MEM_mallocN(text->curc + (text->sell->len - text->selc) + 1, "textline_string");
-	
-	if (text->curl != text->sell) {
-		txt_clear_marker_region(text, text->curl, text->curc, text->curl->len, 0, 0);
-		move = txt_get_span(text->curl, text->sell);
-	}
-	else {
-		mrk = txt_find_marker_region(text, text->curl, text->curc, text->selc, 0, 0);
-		if (mrk && (mrk->start > text->curc || mrk->end < text->selc))
-			txt_clear_marker_region(text, text->curl, text->curc, text->selc, 0, 0);
-		move = 0;
-	}
 
-	mrk = txt_find_marker_region(text, text->sell, text->selc - 1, text->sell->len, 0, 0);
-	if (mrk) {
-		lineno = mrk->lineno;
-		do {
-			mrk->lineno -= move;
-			if (mrk->start > text->curc) mrk->start -= text->selc - text->curc;
-			mrk->end -= text->selc - text->curc;
-			mrk = mrk->next;
-		} while (mrk && mrk->lineno == lineno);
-	}
-
 	strncpy(buf, text->curl->line, text->curc);
 	strcpy(buf + text->curc, text->sell->line + text->selc);
 	buf[text->curc + (text->sell->len - text->selc)] = 0;
@@ -1419,19 +1380,9 @@
 	return buf;
 }
 
-static void txt_shift_markers(Text *text, int lineno, int count)
-{
-	TextMarker *marker;
-
-	for (marker = text->markers.first; marker; marker = marker->next)
-		if (marker->lineno >= lineno) {
-			marker->lineno += count;
-		}
-}
-
 void txt_insert_buf(Text *text, const char *in_buffer)
 {
-	int l = 0, u, len, lineno = -1, count = 0;
+	int l = 0, u, len;
 	size_t i = 0, j;
 	TextLine *add;
 	char *buffer;
@@ -1458,9 +1409,6 @@
 	else { undoing = u; MEM_freeN(buffer); return; }
 	i++;
 
-	/* Read as many full lines as we can */
-	lineno = txt_get_span(text->lines.first, text->curl);
-
 	while (i < len) {
 		l = 0;
 
@@ -1472,14 +1420,8 @@
 			add = txt_new_linen(buffer + (i - l), l);
 			BLI_insertlinkbefore(&text->lines, text->curl, add);
 			i++;
-			count++;
 		}
 		else {
-			if (count) {
-				txt_shift_markers(text, lineno, count);
-				count = 0;
-			}
-
 			for (j = i - l; j < i && j < len; )
 				txt_add_raw_char(text, BLI_str_utf8_as_unicode_step(buffer, &j));
 			break;
@@ -1488,10 +1430,6 @@
 	
 	MEM_freeN(buffer);
 
-	if (count) {
-		txt_shift_markers(text, lineno, count);
-	}
-
 	undoing = u;
 }
 
@@ -2324,31 +2262,13 @@
 void txt_split_curline(Text *text)
 {
 	TextLine *ins;
-	TextMarker *mrk;
 	char *left, *right;
-	int lineno = -1;
 	
 	if (!text) return;
 	if (!text->curl) return;
 
 	txt_delete_sel(text);
 
-	/* Move markers */
-
-	lineno = txt_get_span(text->lines.first, text->curl);
-	mrk = text->markers.first;
-	while (mrk) {
-		if (mrk->lineno == lineno && mrk->start > text->curc) {
-			mrk->lineno++;
-			mrk->start -= text->curc;
-			mrk->end -= text->curc;
-		}
-		else if (mrk->lineno > lineno) {
-			mrk->lineno++;
-		}
-		mrk = mrk->next;
-	}
-
 	/* Make the two half strings */
 
 	left = MEM_mallocN(text->curc + 1, "textline_string");
@@ -2385,25 +2305,9 @@
 
 static void txt_delete_line(Text *text, TextLine *line)
 {
-	TextMarker *mrk = NULL, *nxt;
-
 	if (!text) return;
 	if (!text->curl) return;
 
-	/* warning, this can be _slow_ when deleting many lines! */
-	if ((mrk = text->markers.first)) {
-		int lineno = txt_get_span(text->lines.first, line);
-		mrk = text->markers.first;
-		while (mrk) {
-			nxt = mrk->next;
-			if (mrk->lineno == lineno)
-				BLI_freelinkN(&text->markers, mrk);
-			else if (mrk->lineno > lineno)
-				mrk->lineno--;
-			mrk = nxt;
-		}
-	}
-
 	BLI_remlink(&text->lines, line);
 	
 	if (line->line) MEM_freeN(line->line);
@@ -2418,27 +2322,11 @@
 static void txt_combine_lines(Text *text, TextLine *linea, TextLine *lineb)
 {
 	char *tmp;
-	TextMarker *mrk = NULL;
 
 	if (!text) return;
 	
 	if (!linea || !lineb) return;
 
-	mrk = txt_find_marker_region(text, lineb, 0, lineb->len, 0, 0);
-	if (mrk) {
-		int lineno;
-		lineno = mrk->lineno;
-		do {
-			mrk->lineno--;
-			mrk->start += linea->len;
-			mrk->end += linea->len;
-			mrk = mrk->next;
-		} while (mrk && mrk->lineno == lineno);
-	}
-#if 0  /* UNUSED */
-	if (lineno == -1)
-		lineno = txt_get_span(text->lines.first, lineb);
-#endif
 
 	tmp = MEM_mallocN(linea->len + lineb->len + 1, "textline_string");
 	
@@ -2492,27 +2380,7 @@
 	}
 	else { /* Just deleting a char */
 		size_t c_len = 0;
-		TextMarker *mrk;
 		c = BLI_str_utf8_as_unicode_and_size(text->curl->line + text->curc, &c_len);
-
-		mrk = txt_find_marker_region(text, text->curl, text->curc - c_len, text->curl->len, 0, 0);
-		if (mrk) {
-			int lineno = mrk->lineno;
-			if (mrk->end == text->curc) {
-				if ((mrk->flags & TMARK_TEMP) && !(mrk->flags & TMARK_EDITALL)) {
-					txt_clear_markers(text, mrk->group, TMARK_TEMP);
-				}
-				else {
-					BLI_freelinkN(&text->markers, mrk);
-				}
-				return;
-			}
-			do {
-				if (mrk->start > text->curc) mrk->start -= c_len;
-				mrk->end -= c_len;
-				mrk = mrk->next;
-			} while (mrk && mrk->lineno == lineno);
-		}
 		
 		memmove(text->curl->line + text->curc, text->curl->line + text->curc + c_len, text->curl->len - text->curc - c_len + 1);
 
@@ -2556,28 +2424,8 @@
 	}
 	else { /* Just backspacing a char */
 		size_t c_len = 0;
-		TextMarker *mrk;
 		char *prev = BLI_str_prev_char_utf8(text->curl->line + text->curc);
 		c = BLI_str_utf8_as_unicode_and_size(prev, &c_len);
-
-		mrk = txt_find_marker_region(text, text->curl, text->curc - c_len, text->curl->len, 0, 0);
-		if (mrk) {
-			int lineno = mrk->lineno;
-			if (mrk->start == text->curc) {
-				if ((mrk->flags & TMARK_TEMP) && !(mrk->flags & TMARK_EDITALL)) {
-					txt_clear_markers(text, mrk->group, TMARK_TEMP);
-				}
-				else {
-					BLI_freelinkN(&text->markers, mrk);
-				}
-				return;
-			}
-			do {

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list