[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [16087] branches/soc-2008-quorn/source/ blender/src: Added a Marker sub-menu to the Edit menu in the text space header.

Ian Thompson quornian at googlemail.com
Wed Aug 13 23:13:58 CEST 2008


Revision: 16087
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=16087
Author:   quorn
Date:     2008-08-13 23:13:56 +0200 (Wed, 13 Aug 2008)

Log Message:
-----------
Added a Marker sub-menu to the Edit menu in the text space header.

Modified Paths:
--------------
    branches/soc-2008-quorn/source/blender/src/drawtext.c
    branches/soc-2008-quorn/source/blender/src/header_text.c

Modified: branches/soc-2008-quorn/source/blender/src/drawtext.c
===================================================================
--- branches/soc-2008-quorn/source/blender/src/drawtext.c	2008-08-13 20:33:57 UTC (rev 16086)
+++ branches/soc-2008-quorn/source/blender/src/drawtext.c	2008-08-13 21:13:56 UTC (rev 16087)
@@ -2455,7 +2455,7 @@
 	text= st->text;
 	if (!text || text->id.lib || text->curl != text->sell) return 0;
 
-	marker= txt_find_marker(text, text->curl, text->curc, 0);
+	marker= txt_find_marker(text, text->sell, text->selc, 0);
 	if (!marker) {
 		/* Find the next temporary marker */
 		if (evnt==TABKEY) {

Modified: branches/soc-2008-quorn/source/blender/src/header_text.c
===================================================================
--- branches/soc-2008-quorn/source/blender/src/header_text.c	2008-08-13 20:33:57 UTC (rev 16086)
+++ branches/soc-2008-quorn/source/blender/src/header_text.c	2008-08-13 21:13:56 UTC (rev 16087)
@@ -42,6 +42,7 @@
 
 #include "BMF_Api.h"
 #include "BIF_language.h"
+#include "MEM_guardedalloc.h"
 
 #include "BSE_headerbuttons.h"
 
@@ -315,9 +316,14 @@
 		txt_write_file(text);
 		break;
 	case 6:
+		text->flags |= TXT_ISMEM | TXT_ISDIRTY | TXT_ISTMP;
+		MEM_freeN(text->name);
+		text->name= NULL;
+		break;
+	case 7:
 		run_python_script(st);
 		break;
-	case 7:
+	case 8:
 	{
 		Object *ob;
 		bConstraint *con;
@@ -491,6 +497,57 @@
 	}
 }
 
+/* action executed after clicking in Markers menu */
+static void do_text_editmenu_markermenu(void *arg, int event)
+{
+	SpaceText *st= curarea->spacedata.first; /* bad but cant pass as an arg here */
+	Text *text;
+	TextMarker *mrk;
+	ScrArea *sa;
+	int lineno;
+	
+	if (st==NULL || st->spacetype != SPACE_TEXT) return;
+	
+	text = st->text;
+	
+	switch(event) {
+	case 1:
+		txt_clear_markers(text, 0);
+		break;
+	case 2:
+		lineno= txt_get_span(text->lines.first, text->curl);
+		mrk= text->markers.first;
+		while (mrk && (mrk->lineno<lineno || (mrk->lineno==lineno && mrk->start <= text->curc)))
+			mrk= mrk->next;
+		if (!mrk) mrk= text->markers.first;
+		if (mrk) {
+			txt_move_to(text, mrk->lineno, mrk->start, 0);
+			txt_move_to(text, mrk->lineno, mrk->end, 1);
+		}
+		break;
+	case 3:
+		lineno= txt_get_span(text->lines.first, text->curl);
+		mrk= text->markers.last;
+		while (mrk && (mrk->lineno>lineno || (mrk->lineno==lineno && mrk->end > text->curc)))
+			mrk= mrk->prev;
+		if (!mrk) mrk= text->markers.last;
+		if (mrk) {
+			txt_move_to(text, mrk->lineno, mrk->start, 0);
+			txt_move_to(text, mrk->lineno, mrk->end, 1);
+		}
+		break;
+	default:
+		break;
+	}
+
+	for (sa= G.curscreen->areabase.first; sa; sa= sa->next) {
+		SpaceText *st= sa->spacedata.first;
+		if (st && st->spacetype==SPACE_TEXT) {
+			scrarea_queue_redraw(sa);
+		}
+	}
+}
+
 /* action executed after clicking in Format menu */
 static void do_text_formatmenu(void *arg, int event)
 {
@@ -600,6 +657,25 @@
 	return block;
 }
 
+/* Select menu */
+static uiBlock *text_editmenu_markermenu(void *arg_unused)
+{
+	uiBlock *block;
+	short yco = 20, menuwidth = 120;
+
+	block= uiNewBlock(&curarea->uiblocks, "text_editmenu_markermenu", UI_EMBOSSP, UI_HELV, G.curscreen->mainwin);
+	uiBlockSetButmFunc(block, do_text_editmenu_markermenu, NULL);
+
+	uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Clear All", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 1, "");
+	uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Next Marker", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 2, "");
+	uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Previous Marker", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 3, "");
+	
+	uiBlockSetDirection(block, UI_RIGHT);
+	uiTextBoundsBlock(block, 60);
+	
+	return block;
+}
+
 void do_text_formatmenu_convert(void *arg, int event)
 {
 	SpaceText *st= curarea->spacedata.first; /* bad but cant pass as an arg here */
@@ -713,6 +789,7 @@
 	uiDefBut(block, SEPR, 0, "",        0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
 	uiDefIconTextBlockBut(block, text_editmenu_viewmenu, NULL, ICON_RIGHTARROW_THIN, "View|Alt Shift V   ", 0, yco-=20, 120, 19, "");
 	uiDefIconTextBlockBut(block, text_editmenu_selectmenu, NULL, ICON_RIGHTARROW_THIN, "Select|Alt Shift S   ", 0, yco-=20, 120, 19, "");
+	uiDefIconTextBlockBut(block, text_editmenu_markermenu, NULL, ICON_RIGHTARROW_THIN, "Markers", 0, yco-=20, 120, 19, "");
 	uiDefBut(block, SEPR, 0, "",        0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
 	uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Jump...|Alt J", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 7, "");
 	uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Find And Replace...|Alt F", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 8, "");
@@ -754,12 +831,15 @@
 		uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Save|Alt S", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 4, "");
 		uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Save As...", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 5, "");
 		
+		if (text->name)
+			uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Make Internal", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 6, "");
+
 		uiDefBut(block, SEPR, 0, "",        0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
 		
-		uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Run Python Script|Alt P", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 6, "");
+		uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Run Python Script|Alt P", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 7, "");
 		
 		if (BPY_is_pyconstraint(text))
-			uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Refresh All PyConstraints", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 7, "");
+			uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Refresh All PyConstraints", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 8, "");
 			
 		uiDefBut(block, SEPR, 0, "",        0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
 	}





More information about the Bf-blender-cvs mailing list