[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [22004] branches/blender2.5/blender: - console remove doubles with command history

Campbell Barton ideasman42 at gmail.com
Wed Jul 29 02:37:37 CEST 2009


Revision: 22004
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=22004
Author:   campbellbarton
Date:     2009-07-29 02:37:37 +0200 (Wed, 29 Jul 2009)

Log Message:
-----------
- console remove doubles with command history
- povray file removal was uncommented

Modified Paths:
--------------
    branches/blender2.5/blender/release/io/engine_render_pov.py
    branches/blender2.5/blender/release/ui/space_console.py
    branches/blender2.5/blender/source/blender/editors/space_console/console_ops.c

Modified: branches/blender2.5/blender/release/io/engine_render_pov.py
===================================================================
--- branches/blender2.5/blender/release/io/engine_render_pov.py	2009-07-29 00:18:13 UTC (rev 22003)
+++ branches/blender2.5/blender/release/io/engine_render_pov.py	2009-07-29 00:37:37 UTC (rev 22004)
@@ -502,9 +502,8 @@
 	
 	def _cleanup(self):
 		for f in (self.temp_file_in, self.temp_file_ini, self.temp_file_out):
-			#try:		os.remove(f)
-			#except:	pass
-			pass
+			try:		os.remove(f)
+			except:	pass
 		
 		self.update_stats("", "")
 	

Modified: branches/blender2.5/blender/release/ui/space_console.py
===================================================================
--- branches/blender2.5/blender/release/ui/space_console.py	2009-07-29 00:18:13 UTC (rev 22003)
+++ branches/blender2.5/blender/release/ui/space_console.py	2009-07-29 00:37:37 UTC (rev 22004)
@@ -182,7 +182,7 @@
 		else:				sc.prompt = self.PROMPT
 		
 		# insert a new blank line
-		bpy.ops.console.history_append(text="", current_character=0)
+		bpy.ops.console.history_append(text="", current_character=0, remove_duplicates= True)
 		
 		# Insert the output into the editor
 		# not quite correct because the order might have changed, but ok 99% of the time.

Modified: branches/blender2.5/blender/source/blender/editors/space_console/console_ops.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/space_console/console_ops.c	2009-07-29 00:18:13 UTC (rev 22003)
+++ branches/blender2.5/blender/source/blender/editors/space_console/console_ops.c	2009-07-29 00:37:37 UTC (rev 22004)
@@ -88,6 +88,21 @@
 		console_scrollback_free(sc, sc->scrollback.first);
 }
 
+static ConsoleLine * console_history_find(SpaceConsole *sc, const char *str, ConsoleLine *cl_ignore)
+{
+	ConsoleLine *cl;
+
+	for(cl= sc->history.last; cl; cl= cl->prev) {
+		if (cl==cl_ignore)
+			continue;
+
+		if(strcmp(str, cl->line)==0)
+			return cl;
+	}
+
+	return NULL;
+}
+
 /* return 0 if no change made, clamps the range */
 static int console_line_cursor_set(ConsoleLine *cl, int cursor)
 {
@@ -476,11 +491,23 @@
 static int history_append_exec(bContext *C, wmOperator *op)
 {
 	ConsoleLine *ci= console_history_verify(C);
-	
-	
 	char *str= RNA_string_get_alloc(op->ptr, "text", NULL, 0); /* own this text in the new line, dont free */
 	int cursor= RNA_int_get(op->ptr, "current_character");
-	
+	short rem_dupes= RNA_boolean_get(op->ptr, "remove_duplicates");
+
+	if(rem_dupes) {
+		SpaceConsole *sc= CTX_wm_space_console(C);
+		ConsoleLine *cl;
+
+		while((cl= console_history_find(sc, ci->line, ci)))
+			console_history_free(sc, cl);
+
+		if(strcmp(str, ci->line)==0) {
+			MEM_freeN(str);
+			return OPERATOR_FINISHED;
+		}
+	}
+
 	ci= console_history_add_str(C, str, 1); /* own the string */
 	console_line_cursor_set(ci, cursor);
 	
@@ -505,6 +532,7 @@
 	/* properties */
 	RNA_def_string(ot->srna, "text", "", 0, "Text", "Text to insert at the cursor position.");	
 	RNA_def_int(ot->srna, "current_character", 0, 0, INT_MAX, "Cursor", "The index of the cursor.", 0, 10000);
+	RNA_def_boolean(ot->srna, "remove_duplicates", 0, "Remove Duplicates", "Remove duplicate items in the history");
 }
 
 





More information about the Bf-blender-cvs mailing list