Revision: 19014 http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=19014 Author: blendix Date: 2009-02-17 20:55:20 +0100 (Tue, 17 Feb 2009)
Log Message: ----------- 2.5: Text edit mode operators back. Took me a while getting them nicely repeatable, and splitting up the big edit_text operator into individual operator so it's all nicely scriptable, documented, configurable, etc.. * Insert Text, Line Break, Insert Lorem * Toggle Case, Set Case, Toggle Style, Set Style, Set Material * Copy Text, Cut Text, Paste Text, Paste File, Paste Buffer * Move, Move Select, Delete * Change Spacing, Change Character Notes * Text (datablock) to Object doesn't work yet, will need to implement text editor context for that. * Some shortcut keys don't work because screen/wm overrides them, ctrl+x, ctrl+left/right. That override goes top down which works well for some cases, but here we need to override in the other direction. * There's no unicode support in RNA, or the user interface code for that matter, but text strings can contain these characters. At the moment it stores a UTF-8 string in char arrays, which is supposed to be nicely compatible with ascii. Seems reasonable to add support for UTF-8 in the interface code, python bindings, .. eventually? Modified Paths: -------------- branches/blender2.5/blender/source/blender/blenkernel/intern/font.c branches/blender2.5/blender/source/blender/editors/curve/curve_intern.h branches/blender2.5/blender/source/blender/editors/curve/curve_ops.c branches/blender2.5/blender/source/blender/editors/curve/editcurve.c branches/blender2.5/blender/source/blender/editors/curve/editfont.c branches/blender2.5/blender/source/blender/editors/include/ED_curve.h branches/blender2.5/blender/source/blender/editors/include/ED_screen.h branches/blender2.5/blender/source/blender/editors/include/UI_interface.h branches/blender2.5/blender/source/blender/editors/interface/interface_regions.c branches/blender2.5/blender/source/blender/editors/object/object_edit.c branches/blender2.5/blender/source/blender/editors/object/object_intern.h branches/blender2.5/blender/source/blender/editors/object/object_ops.c branches/blender2.5/blender/source/blender/editors/screen/screen_ops.c branches/blender2.5/blender/source/blender/editors/space_view3d/view3d_header.c Modified: branches/blender2.5/blender/source/blender/blenkernel/intern/font.c =================================================================== --- branches/blender2.5/blender/source/blender/blenkernel/intern/font.c 2009-02-17 19:37:47 UTC (rev 19013) +++ branches/blender2.5/blender/source/blender/blenkernel/intern/font.c 2009-02-17 19:55:20 UTC (rev 19014) @@ -658,7 +658,7 @@ VChar *che; struct chartrans *chartransdata=NULL, *ct; float *f, xof, yof, xtrax, linedist, *linedata, *linedata2, *linedata3, *linedata4; - float twidth; + float twidth, maxlen= 0; int i, slen, j; int curbox; int selstart, selend; @@ -826,8 +826,6 @@ } } if(ascii== '\n' || ascii== '\r' || ascii==0 || ct->dobreak) { - float maxlen; - ct->xof= xof; ct->yof= yof; ct->linenr= lnr; Modified: branches/blender2.5/blender/source/blender/editors/curve/curve_intern.h =================================================================== --- branches/blender2.5/blender/source/blender/editors/curve/curve_intern.h 2009-02-17 19:37:47 UTC (rev 19013) +++ branches/blender2.5/blender/source/blender/editors/curve/curve_intern.h 2009-02-17 19:55:20 UTC (rev 19014) @@ -36,29 +36,57 @@ char *ED_lorem; /* editfont.c */ -void FONT_OT_textedit(struct wmOperatorType *ot); +enum { DEL_ALL, DEL_NEXT_CHAR, DEL_PREV_CHAR, DEL_SELECTION, DEL_NEXT_SEL, DEL_PREV_SEL }; +enum { CASE_LOWER, CASE_UPPER }; +enum { LINE_BEGIN, LINE_END, PREV_CHAR, NEXT_CHAR, PREV_WORD, NEXT_WORD, + PREV_LINE, NEXT_LINE, PREV_PAGE, NEXT_PAGE }; +void FONT_OT_insert_text(struct wmOperatorType *ot); +void FONT_OT_line_break(struct wmOperatorType *ot); +void FONT_OT_insert_lorem(struct wmOperatorType *ot); +void FONT_OT_text_to_object(struct wmOperatorType *ot); + +void FONT_OT_toggle_case(struct wmOperatorType *ot); +void FONT_OT_set_case(struct wmOperatorType *ot); +void FONT_OT_toggle_style(struct wmOperatorType *ot); +void FONT_OT_set_style(struct wmOperatorType *ot); +void FONT_OT_set_material(struct wmOperatorType *ot); + +void FONT_OT_copy_text(struct wmOperatorType *ot); +void FONT_OT_cut_text(struct wmOperatorType *ot); +void FONT_OT_paste_text(struct wmOperatorType *ot); +void FONT_OT_paste_file(struct wmOperatorType *ot); +void FONT_OT_paste_buffer(struct wmOperatorType *ot); + +void FONT_OT_move(struct wmOperatorType *ot); +void FONT_OT_move_select(struct wmOperatorType *ot); +void FONT_OT_delete(struct wmOperatorType *ot); + +void FONT_OT_change_character(struct wmOperatorType *ot); +void FONT_OT_change_spacing(struct wmOperatorType *ot); + /* editcurve.c */ +void CURVE_OT_hide(struct wmOperatorType *ot); +void CURVE_OT_reveal(struct wmOperatorType *ot); + void CURVE_OT_separate(struct wmOperatorType *ot); -void CURVE_OT_switch_direction(struct wmOperatorType *ot); +void CURVE_OT_duplicate(struct wmOperatorType *ot); +void CURVE_OT_delete(struct wmOperatorType *ot); + void CURVE_OT_set_weight(struct wmOperatorType *ot); void CURVE_OT_set_radius(struct wmOperatorType *ot); +void CURVE_OT_set_spline_type(struct wmOperatorType *ot); +void CURVE_OT_set_handle_type(struct wmOperatorType *ot); +void CURVE_OT_set_smooth(struct wmOperatorType *ot); +void CURVE_OT_clear_tilt(struct wmOperatorType *ot); + void CURVE_OT_smooth(struct wmOperatorType *ot); void CURVE_OT_smooth_radius(struct wmOperatorType *ot); + void CURVE_OT_de_select_first(struct wmOperatorType *ot); void CURVE_OT_de_select_last(struct wmOperatorType *ot); void CURVE_OT_de_select_all(struct wmOperatorType *ot); -void CURVE_OT_hide(struct wmOperatorType *ot); -void CURVE_OT_reveal(struct wmOperatorType *ot); void CURVE_OT_select_inverse(struct wmOperatorType *ot); -void CURVE_OT_subdivide(struct wmOperatorType *ot); -void CURVE_OT_set_spline_type(struct wmOperatorType *ot); -void CURVE_OT_set_handle_type(struct wmOperatorType *ot); -void CURVE_OT_make_segment(struct wmOperatorType *ot); -void CURVE_OT_spin(struct wmOperatorType *ot); -void CURVE_OT_add_vertex(struct wmOperatorType *ot); -void CURVE_OT_extrude(struct wmOperatorType *ot); -void CURVE_OT_toggle_cyclic(struct wmOperatorType *ot); void CURVE_OT_select_linked(struct wmOperatorType *ot); void CURVE_OT_select_row(struct wmOperatorType *ot); void CURVE_OT_select_next(struct wmOperatorType *ot); @@ -67,11 +95,15 @@ void CURVE_OT_select_less(struct wmOperatorType *ot); void CURVE_OT_select_random(struct wmOperatorType *ot); void CURVE_OT_select_every_nth(struct wmOperatorType *ot); -void CURVE_OT_duplicate(struct wmOperatorType *ot); -void CURVE_OT_delete(struct wmOperatorType *ot); -void CURVE_OT_set_smooth(struct wmOperatorType *ot); -void CURVE_OT_clear_tilt(struct wmOperatorType *ot); +void CURVE_OT_switch_direction(struct wmOperatorType *ot); +void CURVE_OT_subdivide(struct wmOperatorType *ot); +void CURVE_OT_make_segment(struct wmOperatorType *ot); +void CURVE_OT_spin(struct wmOperatorType *ot); +void CURVE_OT_add_vertex(struct wmOperatorType *ot); +void CURVE_OT_extrude(struct wmOperatorType *ot); +void CURVE_OT_toggle_cyclic(struct wmOperatorType *ot); + void CURVE_OT_specials_menu(struct wmOperatorType *ot); #endif /* ED_UTIL_INTERN_H */ Modified: branches/blender2.5/blender/source/blender/editors/curve/curve_ops.c =================================================================== --- branches/blender2.5/blender/source/blender/editors/curve/curve_ops.c 2009-02-17 19:37:47 UTC (rev 19013) +++ branches/blender2.5/blender/source/blender/editors/curve/curve_ops.c 2009-02-17 19:55:20 UTC (rev 19014) @@ -31,6 +31,7 @@ #include "MEM_guardedalloc.h" +#include "DNA_curve_types.h" #include "DNA_object_types.h" #include "DNA_scene_types.h" #include "DNA_screen_types.h" @@ -95,8 +96,30 @@ void ED_operatortypes_curve(void) { - WM_operatortype_append(FONT_OT_textedit); + WM_operatortype_append(FONT_OT_insert_text); + WM_operatortype_append(FONT_OT_line_break); + WM_operatortype_append(FONT_OT_insert_lorem); + WM_operatortype_append(FONT_OT_text_to_object); + WM_operatortype_append(FONT_OT_toggle_case); + WM_operatortype_append(FONT_OT_set_case); + WM_operatortype_append(FONT_OT_toggle_style); + WM_operatortype_append(FONT_OT_set_style); + WM_operatortype_append(FONT_OT_set_material); + + WM_operatortype_append(FONT_OT_copy_text); + WM_operatortype_append(FONT_OT_cut_text); + WM_operatortype_append(FONT_OT_paste_text); + WM_operatortype_append(FONT_OT_paste_file); + WM_operatortype_append(FONT_OT_paste_buffer); + + WM_operatortype_append(FONT_OT_move); + WM_operatortype_append(FONT_OT_move_select); + WM_operatortype_append(FONT_OT_delete); + + WM_operatortype_append(FONT_OT_change_character); + WM_operatortype_append(FONT_OT_change_spacing); + WM_operatortype_append(CURVE_OT_hide); WM_operatortype_append(CURVE_OT_reveal); @@ -143,8 +166,48 @@ ListBase *keymap= WM_keymap_listbase(wm, "Font", 0, 0); /* only set in editmode font, by space_view3d listener */ - WM_keymap_add_item(keymap, "FONT_OT_textedit", KM_TEXTINPUT, KM_ANY, KM_ANY, 0); + RNA_enum_set(WM_keymap_add_item(keymap, "FONT_OT_toggle_style", BKEY, KM_PRESS, KM_CTRL, 0)->ptr, "style", CU_BOLD); + RNA_enum_set(WM_keymap_add_item(keymap, "FONT_OT_toggle_style", IKEY, KM_PRESS, KM_CTRL, 0)->ptr, "style", CU_ITALIC); + RNA_enum_set(WM_keymap_add_item(keymap, "FONT_OT_toggle_style", UKEY, KM_PRESS, KM_CTRL, 0)->ptr, "style", CU_UNDERLINE); + RNA_enum_set(WM_keymap_add_item(keymap, "FONT_OT_delete", DELKEY, KM_PRESS, 0, 0)->ptr, "type", DEL_NEXT_SEL); + RNA_enum_set(WM_keymap_add_item(keymap, "FONT_OT_delete", BACKSPACEKEY, KM_PRESS, 0, 0)->ptr, "type", DEL_PREV_SEL); + RNA_enum_set(WM_keymap_add_item(keymap, "FONT_OT_delete", BACKSPACEKEY, KM_PRESS, KM_CTRL, 0)->ptr, "type", DEL_ALL); + + RNA_enum_set(WM_keymap_add_item(keymap, "FONT_OT_move", HOMEKEY, KM_PRESS, 0, 0)->ptr, "type", LINE_BEGIN); + RNA_enum_set(WM_keymap_add_item(keymap, "FONT_OT_move", ENDKEY, KM_PRESS, 0, 0)->ptr, "type", LINE_END); + RNA_enum_set(WM_keymap_add_item(keymap, "FONT_OT_move", LEFTARROWKEY, KM_PRESS, 0, 0)->ptr, "type", PREV_CHAR); + RNA_enum_set(WM_keymap_add_item(keymap, "FONT_OT_move", RIGHTARROWKEY, KM_PRESS, 0, 0)->ptr, "type", NEXT_CHAR); + RNA_enum_set(WM_keymap_add_item(keymap, "FONT_OT_move", LEFTARROWKEY, KM_PRESS, KM_CTRL, 0)->ptr, "type", PREV_WORD); + RNA_enum_set(WM_keymap_add_item(keymap, "FONT_OT_move", RIGHTARROWKEY, KM_PRESS, KM_CTRL, 0)->ptr, "type", NEXT_WORD); + RNA_enum_set(WM_keymap_add_item(keymap, "FONT_OT_move", UPARROWKEY, KM_PRESS, 0, 0)->ptr, "type", PREV_LINE); + RNA_enum_set(WM_keymap_add_item(keymap, "FONT_OT_move", DOWNARROWKEY, KM_PRESS, 0, 0)->ptr, "type", NEXT_LINE); + RNA_enum_set(WM_keymap_add_item(keymap, "FONT_OT_move", PAGEUPKEY, KM_PRESS, 0, 0)->ptr, "type", PREV_PAGE); + RNA_enum_set(WM_keymap_add_item(keymap, "FONT_OT_move", PAGEDOWNKEY, KM_PRESS, 0, 0)->ptr, "type", NEXT_PAGE); + + RNA_enum_set(WM_keymap_add_item(keymap, "FONT_OT_move_select", HOMEKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "type", LINE_BEGIN); + RNA_enum_set(WM_keymap_add_item(keymap, "FONT_OT_move_select", ENDKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "type", LINE_END); + RNA_enum_set(WM_keymap_add_item(keymap, "FONT_OT_move_select", LEFTARROWKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "type", PREV_CHAR); + RNA_enum_set(WM_keymap_add_item(keymap, "FONT_OT_move_select", RIGHTARROWKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "type", NEXT_CHAR); + RNA_enum_set(WM_keymap_add_item(keymap, "FONT_OT_move_select", LEFTARROWKEY, KM_PRESS, KM_SHIFT|KM_CTRL, 0)->ptr, "type", PREV_WORD); + RNA_enum_set(WM_keymap_add_item(keymap, "FONT_OT_move_select", RIGHTARROWKEY, KM_PRESS, KM_SHIFT|KM_CTRL, 0)->ptr, "type", NEXT_WORD); + RNA_enum_set(WM_keymap_add_item(keymap, "FONT_OT_move_select", UPARROWKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "type", PREV_LINE); + RNA_enum_set(WM_keymap_add_item(keymap, "FONT_OT_move_select", DOWNARROWKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "type", NEXT_LINE); + RNA_enum_set(WM_keymap_add_item(keymap, "FONT_OT_move_select", PAGEUPKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "type", PREV_PAGE); + RNA_enum_set(WM_keymap_add_item(keymap, "FONT_OT_move_select", PAGEDOWNKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "type", NEXT_PAGE); + + RNA_int_set(WM_keymap_add_item(keymap, "FONT_OT_change_spacing", LEFTARROWKEY, KM_PRESS, KM_ALT, 0)->ptr, "delta", -1); + RNA_int_set(WM_keymap_add_item(keymap, "FONT_OT_change_spacing", RIGHTARROWKEY, KM_PRESS, KM_ALT, 0)->ptr, "delta", 1); @@ Diff output truncated at 10240 characters. @@ _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org http://lists.blender.org/mailman/listinfo/bf-blender-cvs