diff options
Diffstat (limited to 'source/blender/src/header_text.c')
-rw-r--r-- | source/blender/src/header_text.c | 215 |
1 files changed, 22 insertions, 193 deletions
diff --git a/source/blender/src/header_text.c b/source/blender/src/header_text.c index eeea43ec57a..cf6d21ff264 100644 --- a/source/blender/src/header_text.c +++ b/source/blender/src/header_text.c @@ -42,7 +42,6 @@ #include "BMF_Api.h" #include "BIF_language.h" -#include "MEM_guardedalloc.h" #include "BSE_headerbuttons.h" @@ -53,7 +52,6 @@ #include "DNA_constraint_types.h" #include "DNA_action_types.h" -#include "BIF_gl.h" /* for glRasterPos2i */ #include "BIF_drawtext.h" #include "BIF_interface.h" #include "BIF_resources.h" @@ -130,7 +128,7 @@ void do_text_buttons(unsigned short event) st->top= 0; pop_space_text(st); - if (st->showsyntax) txt_format_text(st); + if (st->showsyntax) get_format_string(st); allqueue(REDRAWTEXT, 0); allqueue(REDRAWHEADERS, 0); } @@ -196,20 +194,14 @@ void do_text_buttons(unsigned short event) break; case B_TAB_NUMBERS: - if (st->showsyntax) txt_format_text(st); + if (st->showsyntax) get_format_string(st); allqueue(REDRAWTEXT, 0); allqueue(REDRAWHEADERS, 0); break; case B_SYNTAX: - if (st->showsyntax) txt_format_text(st); - allqueue(REDRAWTEXT, 0); - allqueue(REDRAWHEADERS, 0); - break; - case B_TEXTPLUGINS: - allqueue(REDRAWHEADERS, 0); - break; - case B_WORDWRAP: - st->left= 0; + if (st->showsyntax) { + get_format_string(st); + } allqueue(REDRAWTEXT, 0); allqueue(REDRAWHEADERS, 0); break; @@ -247,37 +239,6 @@ static uiBlock *text_template_scriptsmenu (void *args_unused) return block; } -static void do_text_plugin_scriptsmenu(void *arg, int event) -{ - BPY_menu_do_python(PYMENU_TEXTPLUGIN, event); - - allqueue(REDRAWIMAGE, 0); -} - -static uiBlock *text_plugin_scriptsmenu (void *args_unused) -{ - uiBlock *block; - BPyMenu *pym; - int i= 0; - short yco = 20, menuwidth = 120; - - block= uiNewBlock(&curarea->uiblocks, "text_plugin_scriptsmenu", UI_EMBOSSP, UI_HELV, G.curscreen->mainwin); - uiBlockSetButmFunc(block, do_text_plugin_scriptsmenu, NULL); - - /* note that we acount for the N previous entries with i+20: */ - for (pym = BPyMenuTable[PYMENU_TEXTPLUGIN]; pym; pym = pym->next, i++) { - - uiDefIconTextBut(block, BUTM, 1, ICON_PYTHON, pym->name, 0, yco-=20, menuwidth, 19, - NULL, 0.0, 0.0, 1, i, - pym->tooltip?pym->tooltip:pym->filename); - } - - uiBlockSetDirection(block, UI_RIGHT); - uiTextBoundsBlock(block, 60); - - return block; -} - /* action executed after clicking in File menu */ static void do_text_filemenu(void *arg, int event) { @@ -307,7 +268,7 @@ static void do_text_filemenu(void *arg, int event) if (!reopen_text(text)) { error("Could not reopen file"); } - if (st->showsyntax) txt_format_text(st); + if (st->showsyntax) get_format_string(st); } break; case 5: @@ -316,14 +277,9 @@ static void do_text_filemenu(void *arg, int event) 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 8: + case 7: { Object *ob; bConstraint *con; @@ -384,17 +340,11 @@ static void do_text_editmenu(void *arg, int event) switch(event) { case 1: txt_do_undo(text); - pop_space_text(st); break; case 2: txt_do_redo(text); - pop_space_text(st); break; case 3: - if (text && text->id.lib) { - error_libdata(); - break; - } txt_copy_clipboard(text); txt_cut_sel(text); pop_space_text(st); @@ -404,12 +354,8 @@ static void do_text_editmenu(void *arg, int event) txt_copy_clipboard(text); break; case 5: - if (text && text->id.lib) { - error_libdata(); - break; - } txt_paste_clipboard(text); - if (st->showsyntax) txt_format_text(st); + if (st->showsyntax) get_format_string(st); break; case 6: txt_print_cutbuffer(); @@ -418,11 +364,10 @@ static void do_text_editmenu(void *arg, int event) jumptoline_interactive(st); break; case 8: - case 9: - find_and_replace(st, 0); + txt_find_panel(st,1); break; - case 10: - find_and_replace(st, 1); + case 9: + txt_find_panel(st,0); break; default: break; @@ -498,57 +443,6 @@ static void do_text_editmenu_selectmenu(void *arg, int event) } } -/* 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, 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) { @@ -562,10 +456,6 @@ static void do_text_formatmenu(void *arg, int event) switch(event) { case 3: - if (text && text->id.lib) { - error_libdata(); - break; - } if (txt_has_sel(text)) { txt_order_cursors(text); indent(text); @@ -576,10 +466,6 @@ static void do_text_formatmenu(void *arg, int event) break; } case 4: - if (text && text->id.lib) { - error_libdata(); - break; - } if ( txt_has_sel(text)) { txt_order_cursors(text); unindent(text); @@ -587,26 +473,18 @@ static void do_text_formatmenu(void *arg, int event) } break; case 5: - if (text && text->id.lib) { - error_libdata(); - break; - } if ( txt_has_sel(text)) { txt_order_cursors(text); comment(text); - if (st->showsyntax) txt_format_text(st); + if (st->showsyntax) get_format_string(st); break; } break; case 6: - if (text && text->id.lib) { - error_libdata(); - break; - } if ( txt_has_sel(text)) { txt_order_cursors(text); uncomment(text); - if (st->showsyntax) txt_format_text(st); + if (st->showsyntax) get_format_string(st); break; } break; @@ -658,25 +536,6 @@ static uiBlock *text_editmenu_selectmenu(void *arg_unused) 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 */ @@ -790,12 +649,10 @@ static uiBlock *text_editmenu(void *arg_unused) 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, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Find Next|Alt F", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 9, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Replace|Alt H", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 10, ""); + uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Find...|Alt Ctrl F", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 8, ""); + uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Find Again|Alt F", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 9, ""); uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); uiDefIconTextBlockBut(block, text_editmenu_to3dmenu, NULL, ICON_RIGHTARROW_THIN, "Text to 3d Object", 0, yco-=20, 120, 19, ""); @@ -833,21 +690,17 @@ static uiBlock *text_filemenu(void *arg_unused) 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, 7, ""); + uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Run Python Script|Alt P", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 6, ""); 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, 8, ""); + uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Refresh All PyConstraints", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 7, ""); uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); } uiDefIconTextBlockBut(block, text_template_scriptsmenu, NULL, ICON_RIGHTARROW_THIN, "Script Templates", 0, yco-=20, 120, 19, ""); - uiDefIconTextBlockBut(block, text_plugin_scriptsmenu, NULL, ICON_RIGHTARROW_THIN, "Text Plugins", 0, yco-=20, 120, 19, ""); if(curarea->headertype==HEADERTOP) { uiBlockSetDirection(block, UI_DOWN); @@ -862,15 +715,13 @@ static uiBlock *text_filemenu(void *arg_unused) } /* header */ -#define HEADER_PATH_MAX 260 void text_buttons(void) { uiBlock *block; SpaceText *st= curarea->spacedata.first; Text *text; short xco, xmax; - char naam[256], fname[HEADER_PATH_MAX], headtxt[HEADER_PATH_MAX+17]; - int len; + char naam[256]; if (st==NULL || st->spacetype != SPACE_TEXT) return; @@ -928,9 +779,8 @@ void text_buttons(void) else uiDefIconBut(block, BUT,B_FULL, ICON_FULLSCREEN, xco,0,XIC,YIC, 0, 0, 0, 0, 0, "Makes current window full screen (CTRL+Down arrow)"); uiDefIconButI(block, ICONTOG, B_TEXTLINENUM, ICON_LONGDISPLAY, xco+=XIC,0,XIC,YIC, &st->showlinenrs, 0, 0, 0, 0, "Displays line numbers"); - uiDefIconButI(block, ICONTOG, B_WORDWRAP, ICON_WORDWRAP, xco+=XIC,0,XIC,YIC, &st->wordwrap, 0, 0, 0, 0, "Enables word wrap"); - uiDefIconButI(block, ICONTOG, B_SYNTAX, ICON_SYNTAX, xco+=XIC,0,XIC,YIC, &st->showsyntax, 0, 0, 0, 0, "Enables syntax highlighting"); - uiDefIconButI(block, ICONTOG, B_TEXTPLUGINS, ICON_PYTHON, xco+=XIC,0,XIC,YIC, &st->doplugins, 0, 0, 0, 0, "Enables Python text plugins"); + + uiDefIconButI(block, ICONTOG, B_SYNTAX, ICON_SYNTAX, xco+=XIC,0,XIC,YIC, &st->showsyntax, 0, 0, 0, 0, "Enables Syntax Highlighting"); uiBlockEndAlign(block); /* STD TEXT BUTTONS */ @@ -954,30 +804,9 @@ void text_buttons(void) uiDefButI(block, MENU, B_TEXTFONT, "Screen 12 %x0|Screen 15%x1", xco,0,100,YIC, &st->font_id, 0, 0, 0, 0, "Displays available fonts"); xco+=110; - uiDefButI(block, NUM, B_TAB_NUMBERS, "Tab:", xco, 0, XIC+50, YIC, &st->tabnumber, 2, 8, 0, 0, "Set spacing of Tab"); + uiDefButI(block, NUM, B_TAB_NUMBERS, "Tab:", xco, 0, XIC+50, YIC, &st->tabnumber, 2, 8, 0, 0, "Set spacing of Tab"); xco+= XIC+50; - - /* File info */ - if (text) { - if (text->name) { - len = strlen(text->name); - if (len > HEADER_PATH_MAX-1) - len = HEADER_PATH_MAX-1; - strncpy(fname, text->name, len); - fname[len]='\0'; - if (text->flags & TXT_ISDIRTY) - sprintf(headtxt, "File: *%s (unsaved)", fname); - else - sprintf(headtxt, "File: %s", fname); - } else { - sprintf(headtxt, text->id.lib?"Text: External":"Text: Internal"); - } - BIF_ThemeColor(TH_MENU_TEXT); - glRasterPos2i(xco+=XIC, 5); - BMF_DrawString(G.font, headtxt); - xco += BMF_GetStringWidth(G.font, headtxt); - } - + /* always as last */ curarea->headbutlen= xco+2*XIC; |