Undo revision 23130 which was a merge with 2.5, a messy one because I did something...
[blender.git] / source / blender / editors / space_text / text_ops.c
index 7751355..4c9f47e 100644 (file)
@@ -176,7 +176,6 @@ void TEXT_OT_new(wmOperatorType *ot)
 {
        /* identifiers */
        ot->name= "New";
-    ot->description= "Create a new text data block.";
        ot->idname= "TEXT_OT_new";
 
        /* api callbacks */
@@ -224,7 +223,6 @@ void TEXT_OT_open(wmOperatorType *ot)
 {
        /* identifiers */
        ot->name= "Open";
-    ot->description= "Open a new text data block.";
        ot->idname= "TEXT_OT_open";
 
        /* api callbacks */
@@ -262,7 +260,6 @@ void TEXT_OT_reload(wmOperatorType *ot)
 {
        /* identifiers */
        ot->name= "Reload";
-    ot->description= "Reload active text data block from its file.";
        ot->idname= "TEXT_OT_reload";
 
        /* api callbacks */
@@ -273,9 +270,48 @@ void TEXT_OT_reload(wmOperatorType *ot)
 
 /******************* delete operator *********************/
 
+static void text_unlink(Main *bmain, Text *text)
+{
+       bScreen *scr;
+       ScrArea *area;
+       SpaceLink *sl;
+
+       /* XXX this ifdef is in fact dangerous, if python is
+        * disabled it will leave invalid pointers in files! */
+
+#ifndef DISABLE_PYTHON
+       // XXX BPY_free_pyconstraint_links(text);
+       // XXX free_text_controllers(text);
+       // XXX free_dome_warp_text(text);
+
+       /* equivalently for pynodes: */
+       if(0) // XXX nodeDynamicUnlinkText ((ID*)text))
+               ; // XXX notifier: allqueue(REDRAWNODE, 0);
+#endif
+       
+       for(scr= bmain->screen.first; scr; scr= scr->id.next) {
+               for(area= scr->areabase.first; area; area= area->next) {
+                       for(sl= area->spacedata.first; sl; sl= sl->next) {
+                               if(sl->spacetype==SPACE_TEXT) {
+                                       SpaceText *st= (SpaceText*) sl;
+                                       
+                                       if(st->text==text) {
+                                               st->text= NULL;
+                                               st->top= 0;
+                                               
+                                               if(st==area->spacedata.first)
+                                                       ED_area_tag_redraw(area);
+                                       }
+                               }
+                       }
+               }
+       }
+
+       free_libblock(&bmain->text, text);
+}
+
 static int unlink_exec(bContext *C, wmOperator *op)
 {
-       Main *bmain= CTX_data_main(C);
        SpaceText *st= CTX_wm_space_text(C);
        Text *text= CTX_data_edit_text(C);
 
@@ -291,8 +327,7 @@ static int unlink_exec(bContext *C, wmOperator *op)
                }
        }
 
-       unlink_text(bmain, text);
-       free_libblock(&bmain->text, text);
+       text_unlink(CTX_data_main(C), text);
        WM_event_add_notifier(C, NC_TEXT|NA_REMOVED, text);
 
        return OPERATOR_FINISHED;
@@ -302,7 +337,6 @@ void TEXT_OT_unlink(wmOperatorType *ot)
 {
        /* identifiers */
        ot->name= "Unlink";
-    ot->description= "Unlink active text data block.";
        ot->idname= "TEXT_OT_unlink";
 
        /* api callbacks */
@@ -333,7 +367,6 @@ void TEXT_OT_make_internal(wmOperatorType *ot)
 {
        /* identifiers */
        ot->name= "Make Internal";
-    ot->description= "Make active text file internal.";
        ot->idname= "TEXT_OT_make_internal";
 
        /* api callbacks */
@@ -402,7 +435,6 @@ void TEXT_OT_save(wmOperatorType *ot)
 {
        /* identifiers */
        ot->name= "Save";
-    ot->description= "Save active text data block.";
        ot->idname= "TEXT_OT_save";
 
        /* api callbacks */
@@ -458,7 +490,6 @@ void TEXT_OT_save_as(wmOperatorType *ot)
 {
        /* identifiers */
        ot->name= "Save As";
-    ot->description= "Save active text file with options.";
        ot->idname= "TEXT_OT_save_as";
 
        /* api callbacks */
@@ -496,7 +527,6 @@ void TEXT_OT_run_script(wmOperatorType *ot)
 {
        /* identifiers */
        ot->name= "Run Script";
-    ot->description= "Run active script.";
        ot->idname= "TEXT_OT_run_script";
 
        /* api callbacks */
@@ -511,6 +541,7 @@ static int refresh_pyconstraints_exec(bContext *C, wmOperator *op)
 {
 #ifndef DISABLE_PYTHON
        Text *text= CTX_data_edit_text(C);
+       Scene *scene= CTX_data_scene(C);
        Object *ob;
        bConstraint *con;
        short update;
@@ -540,7 +571,7 @@ static int refresh_pyconstraints_exec(bContext *C, wmOperator *op)
                }
                
                if(update) {
-                       DAG_id_flush_update(&ob->id, OB_RECALC_DATA);
+                       DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
                }
        }
 #endif
@@ -552,7 +583,6 @@ void TEXT_OT_refresh_pyconstraints(wmOperatorType *ot)
 {
        /* identifiers */
        ot->name= "Refresh PyConstraints";
-    ot->description= "Refresh all pyconstraints.";
        ot->idname= "TEXT_OT_refresh_pyconstraints";
 
        /* api callbacks */
@@ -674,7 +704,6 @@ void TEXT_OT_paste(wmOperatorType *ot)
 {
        /* identifiers */
        ot->name= "Paste";
-    ot->description= "Paste text from clipboard.";
        ot->idname= "TEXT_OT_paste";
 
        /* api callbacks */
@@ -715,7 +744,6 @@ void TEXT_OT_copy(wmOperatorType *ot)
 {
        /* identifiers */
        ot->name= "Copy";
-    ot->description= "Copy selected text to clipboard.";
        ot->idname= "TEXT_OT_copy";
 
        /* api callbacks */
@@ -746,7 +774,6 @@ void TEXT_OT_cut(wmOperatorType *ot)
 {
        /* identifiers */
        ot->name= "Cut";
-    ot->description= "Cut selected text to clipboard.";
        ot->idname= "TEXT_OT_cut";
 
        /* api callbacks */
@@ -782,7 +809,6 @@ void TEXT_OT_indent(wmOperatorType *ot)
 {
        /* identifiers */
        ot->name= "Indent";
-    ot->description= "Indent selected text.";
        ot->idname= "TEXT_OT_indent";
 
        /* api callbacks */
@@ -818,7 +844,6 @@ void TEXT_OT_unindent(wmOperatorType *ot)
 {
        /* identifiers */
        ot->name= "Unindent";
-    ot->description= "Unindent selected text.";
        ot->idname= "TEXT_OT_unindent";
 
        /* api callbacks */
@@ -859,7 +884,6 @@ void TEXT_OT_line_break(wmOperatorType *ot)
 {
        /* identifiers */
        ot->name= "Line Break";
-    ot->description= "Insert line break at cursor position.";
        ot->idname= "TEXT_OT_line_break";
 
        /* api callbacks */
@@ -892,7 +916,6 @@ void TEXT_OT_comment(wmOperatorType *ot)
 {
        /* identifiers */
        ot->name= "Comment";
-    ot->description= "Convert selected text to comment.";
        ot->idname= "TEXT_OT_comment";
 
        /* api callbacks */
@@ -926,7 +949,6 @@ void TEXT_OT_uncomment(wmOperatorType *ot)
 {
        /* identifiers */
        ot->name= "Uncomment";
-    ot->description= "Convert selected comment to text.";
        ot->idname= "TEXT_OT_uncomment";
 
        /* api callbacks */
@@ -1068,7 +1090,6 @@ void TEXT_OT_convert_whitespace(wmOperatorType *ot)
 {
        /* identifiers */
        ot->name= "Convert Whitespace";
-    ot->description= "Convert whitespaces by type.";
        ot->idname= "TEXT_OT_convert_whitespace";
 
        /* api callbacks */
@@ -1099,7 +1120,6 @@ void TEXT_OT_select_all(wmOperatorType *ot)
 {
        /* identifiers */
        ot->name= "Select All";
-    ot->description= "Select all text.";
        ot->idname= "TEXT_OT_select_all";
 
        /* api callbacks */
@@ -1127,7 +1147,6 @@ void TEXT_OT_select_line(wmOperatorType *ot)
 {
        /* identifiers */
        ot->name= "Select Line";
-    ot->description= "Select text by line.";
        ot->idname= "TEXT_OT_select_line";
 
        /* api clinebacks */
@@ -1165,7 +1184,6 @@ void TEXT_OT_previous_marker(wmOperatorType *ot)
 {
        /* identifiers */
        ot->name= "Previous Marker";
-    ot->description= "Move to previous marker.";
        ot->idname= "TEXT_OT_previous_marker";
 
        /* api callbacks */
@@ -1203,7 +1221,6 @@ void TEXT_OT_next_marker(wmOperatorType *ot)
 {
        /* identifiers */
        ot->name= "Next Marker";
-    ot->description= "Move to next marker";
        ot->idname= "TEXT_OT_next_marker";
 
        /* api callbacks */
@@ -1231,7 +1248,6 @@ void TEXT_OT_markers_clear(wmOperatorType *ot)
 {
        /* identifiers */
        ot->name= "Clear All Markers";
-    ot->description= "Clear all markers.";
        ot->idname= "TEXT_OT_markers_clear";
 
        /* api callbacks */
@@ -1439,7 +1455,7 @@ static int move_cursor(bContext *C, int type, int select)
        ARegion *ar= CTX_wm_region(C);
 
        /* ensure we have the right region, it's optional */
-       if(ar && ar->regiontype != RGN_TYPE_WINDOW)
+       if(ar->regiontype != RGN_TYPE_WINDOW)
                ar= NULL;
 
        switch(type) {
@@ -1515,7 +1531,6 @@ void TEXT_OT_move(wmOperatorType *ot)
 {
        /* identifiers */
        ot->name= "Move Cursor";
-    ot->description= "Move cursor to position type.";
        ot->idname= "TEXT_OT_move";
        
        /* api callbacks */
@@ -1542,7 +1557,6 @@ void TEXT_OT_move_select(wmOperatorType *ot)
 {
        /* identifiers */
        ot->name= "Move Select";
-    ot->description= "Make selection from current cursor position to new cursor position type.";
        ot->idname= "TEXT_OT_move_select";
        
        /* api callbacks */
@@ -1582,7 +1596,6 @@ void TEXT_OT_jump(wmOperatorType *ot)
 {
        /* identifiers */
        ot->name= "Jump";
-    ot->description= "Jump cursor to line.";
        ot->idname= "TEXT_OT_jump";
 
        /* api callbacks */
@@ -1635,7 +1648,6 @@ void TEXT_OT_delete(wmOperatorType *ot)
 {
        /* identifiers */
        ot->name= "Delete";
-    ot->description= "Delete text by cursor position.";
        ot->idname= "TEXT_OT_delete";
        
        /* api callbacks */
@@ -1816,10 +1828,6 @@ void TEXT_OT_scroll(wmOperatorType *ot)
 {
        /* identifiers */
        ot->name= "Scroll";
-    /*don't really see the difference between this and
-      scroll_bar. Both do basically the same thing (aside 
-      from keymaps).*/
-    ot->description= "Scroll text screen.";
        ot->idname= "TEXT_OT_scroll";
        
        /* api callbacks */
@@ -1868,10 +1876,6 @@ void TEXT_OT_scroll_bar(wmOperatorType *ot)
 {
        /* identifiers */
        ot->name= "Scrollbar";
-    /*don't really see the difference between this and
-      scroll. Both do basically the same thing (aside 
-      from keymaps).*/
-    ot->description= "Scroll text screen.";
        ot->idname= "TEXT_OT_scroll_bar";
        
        /* api callbacks */
@@ -2147,7 +2151,6 @@ void TEXT_OT_cursor_set(wmOperatorType *ot)
 {
        /* identifiers */
        ot->name= "Set Cursor";
-    ot->description= "Set cursor selection.";
        ot->idname= "TEXT_OT_cursor_set";
        
        /* api callbacks */
@@ -2271,7 +2274,6 @@ void TEXT_OT_insert(wmOperatorType *ot)
 {
        /* identifiers */
        ot->name= "Insert";
-    ot->description= "Insert text at cursor position.";
        ot->idname= "TEXT_OT_insert";
        
        /* api callbacks */
@@ -2376,7 +2378,6 @@ void TEXT_OT_find(wmOperatorType *ot)
 {
        /* identifiers */
        ot->name= "Find";
-    ot->description= "Find specified text.";
        ot->idname= "TEXT_OT_find";
 
        /* api callbacks */
@@ -2395,7 +2396,6 @@ void TEXT_OT_replace(wmOperatorType *ot)
 {
        /* identifiers */
        ot->name= "Replace";
-    ot->description= "Replace text with specified text.";
        ot->idname= "TEXT_OT_replace";
 
        /* api callbacks */
@@ -2414,7 +2414,6 @@ void TEXT_OT_mark_all(wmOperatorType *ot)
 {
        /* identifiers */
        ot->name= "Mark All";
-    ot->description= "Mark all specified text.";
        ot->idname= "TEXT_OT_mark_all";
 
        /* api callbacks */
@@ -2444,7 +2443,6 @@ void TEXT_OT_find_set_selected(wmOperatorType *ot)
 {
        /* identifiers */
        ot->name= "Find Set Selected";
-    ot->description= "Find specified text and set as selected.";
        ot->idname= "TEXT_OT_find_set_selected";
 
        /* api callbacks */
@@ -2471,7 +2469,6 @@ void TEXT_OT_replace_set_selected(wmOperatorType *ot)
 {
        /* identifiers */
        ot->name= "Replace Set Selected";
-    ot->description= "Replace text with specified text and set as selected.";
        ot->idname= "TEXT_OT_replace_set_selected";
 
        /* api callbacks */
@@ -2634,7 +2631,6 @@ void TEXT_OT_to_3d_object(wmOperatorType *ot)
 {
        /* identifiers */
        ot->name= "To 3D Object";
-    ot->description= "Create 3d text object from active text data block.";
        ot->idname= "TEXT_OT_to_3d_object";
        
        /* api callbacks */