diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2009-03-01 02:33:35 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2009-03-01 02:33:35 +0300 |
commit | 6cc89b9d4e6ab17bea0631b1be800dd9a022db23 (patch) | |
tree | 356e3649b94ec7f5a144f1fa6304f5646c4b9bf1 /source/blender/makesrna/intern/rna_space.c | |
parent | 2469305376856e0f53b4ffdbe2bf2576fa25809c (diff) |
2.5: Text Editor back.
There was very little structure in this code, using many globals
and duplicated code. Now it should be better structured. Most
things should work, the main parts that are not back yet are the
python plugins and markers. Notes:
* Blenfont is used for drawing the text, nicely anti-aliased.
* A monospace truetype font was added, since that is needed for
the text editor. It's Bitstream Vera Sans Mono. This is the
default gnome terminal font, but it doesn't fit entirely well
with the other font I think, can be changed easily of course.
* Clipboard copy/cut/paste now always uses the system clipboard,
the code for the own cut buffer was removed.
* The interface buttons should support copy/cut/paste again now
as well.
* WM_clipboard_text_get/WM_clipboard_text_set were added to the
windowmanager code.
* Find panel is now a kind of second header, instead of a panel.
This needs especially a way to start editing the text field
immediately on open still.
* Operators are independent of the actual space when possible,
was a bit of puzzling but got it solved nice with notifiers,
and some lazy init for syntax highlight in the drawing code.
* RNA was created for the text editor space and used for buttons.
* Operators:
* New, Open, Reload, Save, Save As, Make Internal
* Run Script, Refresh Pyconstraints
* Copy, Cut, Paste
* Convert Whitespace, Uncomment, Comment, Indent, Unindent
* Line Break, Insert
* Next Marker, Previous Marker, Clear All Markers, Mark All
* Select Line, Select All
* Jump, Move, Move Select, Delete, Toggle Overwrite
* Scroll, Scroll Bar, Set Cursor, Line Number
* Find and Replace, Find, Replace, Find Set Selected,
Replace Set Selected
* To 3D Object
* Resolve Conflict
Diffstat (limited to 'source/blender/makesrna/intern/rna_space.c')
-rw-r--r-- | source/blender/makesrna/intern/rna_space.c | 84 |
1 files changed, 82 insertions, 2 deletions
diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index 793727d4d7b..c889a0ec195 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -31,6 +31,8 @@ #include "DNA_space_types.h" +#include "WM_types.h" + #ifdef RNA_RUNTIME #include "DNA_scene_types.h" @@ -58,12 +60,12 @@ static StructRNA* rna_Space_refine(struct PointerRNA *ptr) /*case SPACE_INFO: return &RNA_SpaceUserPreferences; case SPACE_SEQ: - return &RNA_SpaceSequenceEditor; + return &RNA_SpaceSequenceEditor;*/ case SPACE_TEXT: return &RNA_SpaceTextEditor; //case SPACE_IMASEL: // return &RNA_SpaceImageBrowser; - case SPACE_SOUND: + /*case SPACE_SOUND: return &RNA_SpaceAudioWindow; case SPACE_ACTION: return &RNA_SpaceDopeSheetEditor; @@ -93,6 +95,14 @@ static void rna_SpaceImage_paint_update(bContext *C, PointerRNA *ptr) brush_check_exists(&scene->toolsettings->imapaint.brush); } +void rna_SpaceTextEditor_word_wrap_set(PointerRNA *ptr, int value) +{ + SpaceText *st= (SpaceText*)(ptr->data); + + st->wordwrap= value; + st->left= 0; +} + #else static void rna_def_space(BlenderRNA *brna) @@ -304,10 +314,80 @@ static void rna_def_space_image(BlenderRNA *brna) rna_def_space_image_uv(brna); } +static void rna_def_space_text(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + static EnumPropertyItem font_size_items[] = { + {12, "SCREEN_12", "Screen 12", ""}, + {15, "SCREEN_15", "Screen 15", ""}, + {0, NULL, NULL, NULL}}; + + srna= RNA_def_struct(brna, "SpaceTextEditor", "Space"); + RNA_def_struct_sdna(srna, "SpaceText"); + RNA_def_struct_ui_text(srna, "Space Text Editor", "Text editor space data."); + + /* text */ + prop= RNA_def_property(srna, "text", PROP_POINTER, PROP_NONE); + RNA_def_property_ui_text(prop, "Text", "Text displayed and edited in this space."); + + /* display */ + prop= RNA_def_property(srna, "syntax_highlight", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "showsyntax", 0); + RNA_def_property_ui_text(prop, "Syntax Highlight", "Syntax highlight for scripting."); + RNA_def_property_update(prop, NC_TEXT|ND_DISPLAY, NULL); + + prop= RNA_def_property(srna, "word_wrap", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "wordwrap", 0); + RNA_def_property_boolean_funcs(prop, NULL, "rna_SpaceTextEditor_word_wrap_set"); + RNA_def_property_ui_text(prop, "Word Wrap", "Wrap words if there is not enough horizontal space."); + RNA_def_property_update(prop, NC_TEXT|ND_DISPLAY, NULL); + + prop= RNA_def_property(srna, "line_numbers", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "showlinenrs", 0); + RNA_def_property_ui_text(prop, "Line Numbers", "Show line numbers next to the text."); + RNA_def_property_update(prop, NC_TEXT|ND_DISPLAY, NULL); + + prop= RNA_def_property(srna, "overwrite", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_ui_text(prop, "Overwrite", "Overwrite characters when typing rather than inserting them."); + RNA_def_property_update(prop, NC_TEXT|ND_DISPLAY, NULL); + + prop= RNA_def_property(srna, "tab_width", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "tabnumber"); + RNA_def_property_range(prop, 2, 8); + RNA_def_property_ui_text(prop, "Tab Width", "Number of spaces to display tabs with."); + RNA_def_property_update(prop, NC_TEXT|ND_DISPLAY, NULL); + + prop= RNA_def_property(srna, "font_size", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "lheight"); + RNA_def_property_enum_items(prop, font_size_items); + RNA_def_property_ui_text(prop, "Font Size", "Font size to use for displaying the text."); + RNA_def_property_update(prop, NC_TEXT|ND_DISPLAY, NULL); + + /* find */ + prop= RNA_def_property(srna, "find_all", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flags", ST_FIND_ALL); + RNA_def_property_ui_text(prop, "Find All", "Search in all text datablocks, instead of only the active one."); + + prop= RNA_def_property(srna, "find_wrap", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flags", ST_FIND_WRAP); + RNA_def_property_ui_text(prop, "Find Wrap", "Search again from the start of the file when reaching the end."); + + prop= RNA_def_property(srna, "find_text", PROP_STRING, PROP_NONE); + RNA_def_property_string_sdna(prop, NULL, "findstr"); + RNA_def_property_ui_text(prop, "Find Text", "Text to search for with the find tool."); + + prop= RNA_def_property(srna, "replace_text", PROP_STRING, PROP_NONE); + RNA_def_property_string_sdna(prop, NULL, "replacestr"); + RNA_def_property_ui_text(prop, "Replace Text", "Text to replace selected text with using the replace tool."); +} + void RNA_def_space(BlenderRNA *brna) { rna_def_space(brna); rna_def_space_image(brna); + rna_def_space_text(brna); } #endif |