X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Flyx_cb.C;h=5a6679495ed32a04fb02cca4949c588f70e70176;hb=a858be7332e331e0244e4dba7b0931b6072ffd3d;hp=4e9e78d556dd2058619d9f566d9d0b2aab07405d;hpb=3635ff7370f8baa6ce64a62268710d09e3a0a34a;p=lyx.git diff --git a/src/lyx_cb.C b/src/lyx_cb.C index 4e9e78d556..5a6679495e 100644 --- a/src/lyx_cb.C +++ b/src/lyx_cb.C @@ -17,6 +17,7 @@ #include #include "LString.h" +#include "support/lstrings.h" #include "lyx_main.h" #include FORMS_H_LOCATION #include "lyx.h" @@ -42,7 +43,7 @@ #include "combox.h" #include "bufferlist.h" #include "support/filetools.h" -#include "pathstack.h" +#include "support/path.h" #include "filedlg.h" #include "lyx_gui_misc.h" #include "LyXView.h" // only because of form_main @@ -464,7 +465,7 @@ int MenuRunLaTeX(Buffer *buffer) s = _("One error detected"); t = _("You should try to fix it."); } else { - s += ret; + s += tostr(ret); s += _(" errors detected."); t = _("You should try to fix them."); } @@ -496,7 +497,7 @@ int MenuBuildProg(Buffer *buffer) s = _("One error detected"); t = _("You should try to fix it."); } else { - s += ret; + s += tostr(ret); s += _(" errors detected."); t = _("You should try to fix them."); } @@ -525,7 +526,7 @@ int MenuRunChktex(Buffer *buffer) s = _("One warning found."); t = _("Use 'Edit->Go to Error' to find it."); } else { - s += ret; + s += tostr(ret); s += _(" warnings found."); t = _("Use 'Edit->Go to Error' to find them."); } @@ -549,9 +550,8 @@ int MakeDVIOutput(Buffer *buffer) path = buffer->tmppath; } if (!buffer->isDviClean()) { - PathPush(path); + Path p(path); ret = MenuRunLaTeX(buffer); - PathPop(); } return ret; } @@ -581,7 +581,7 @@ bool RunScript(Buffer *buffer, bool wait, if (lyxrc->use_tempdir || (IsDirWriteable(path) < 1)) { path = buffer->tmppath; } - PathPush(path); + Path p(path); cmd = command + ' ' + SpaceLess(name); Systemcalls one; @@ -622,7 +622,6 @@ bool RunScript(Buffer *buffer, bool wait, result = one.startscript(wait ? Systemcalls::Wait : Systemcalls::DontWait, cmd); } - PathPop(); return (result==0); } @@ -706,10 +705,9 @@ bool MenuRunDvips(Buffer *buffer, bool wait=false) if (lyxrc->use_tempdir || (IsDirWriteable(path) < 1)){ path = buffer->tmppath; } - PathPush(path); + Path p(path); bool ret = RunScript(buffer, wait, command); AllowInput(); - PathPop(); return ret; } @@ -734,9 +732,8 @@ bool MenuPreviewPS(Buffer *buffer) if (lyxrc->use_tempdir || (IsDirWriteable(path) < 1)){ path = buffer->tmppath; } - PathPush(path); + Path p(path); bool ret = RunScript(buffer, false, lyxrc->view_ps_command, ps); - PathPop(); AllowInput(); return ret; } @@ -758,7 +755,7 @@ void MenuFax(Buffer *buffer) if (lyxrc->use_tempdir || (IsDirWriteable(path) < 1)) { path = buffer->tmppath; } - PathPush(path); + Path p(path); if (!lyxrc->fax_program.empty()) { string help2 = lyxrc->fax_program; subst(help2, "$$FName",ps); @@ -766,7 +763,6 @@ void MenuFax(Buffer *buffer) Systemcalls one(Systemcalls::System, help2); } else send_fax(ps,lyxrc->fax_command); - PathPop(); } @@ -824,11 +820,10 @@ bool MenuPreview(Buffer *buffer) if (lyxrc->use_tempdir || (IsDirWriteable(path) < 1)){ path = buffer->tmppath; } - PathPush(path); + Path p(path); // Run dvi-viewer string command = lyxrc->view_dvi_command + paper ; bool ret = RunScript(buffer, false, command); - PathPop(); return ret; } @@ -971,7 +966,7 @@ void MenuPrint(Buffer *buffer) } else { fl_show_form(fd_form_print->form_print, - FL_PLACE_MOUSE | FL_FREE_SIZE, FL_FULLBORDER, + FL_PLACE_MOUSE, FL_FULLBORDER, _("Print")); } } @@ -1152,6 +1147,8 @@ void InsertAsciiFile(string const & f, bool asParagraph) void MenuShowTableOfContents() { + static int ow = -1, oh; + TocUpdateCB(0, 0); if (fd_form_toc->form_toc->visible) { fl_raise_form(fd_form_toc->form_toc); @@ -1159,6 +1156,11 @@ void MenuShowTableOfContents() fl_show_form(fd_form_toc->form_toc, FL_PLACE_MOUSE | FL_FREE_SIZE, FL_FULLBORDER, _("Table Of Contents")); + if (ow < 0) { + ow = fd_form_toc->form_toc->w; + oh = fd_form_toc->form_toc->h; + } + fl_set_form_minsize(fd_form_toc->form_toc,ow,oh); } } @@ -1181,6 +1183,8 @@ void MenuInsertLabel(const char *arg) void MenuInsertRef() { + static int ow = -1, oh; + RefUpdateCB(0, 0); if (fd_form_ref->form_ref->visible) { fl_raise_form(fd_form_ref->form_ref); @@ -1188,6 +1192,11 @@ void MenuInsertRef() fl_show_form(fd_form_ref->form_ref, FL_PLACE_MOUSE | FL_FREE_SIZE, FL_FULLBORDER, _("Insert Reference")); + if (ow < 0) { + ow = fd_form_ref->form_ref->w; + oh = fd_form_ref->form_ref->h; + } + fl_set_form_minsize(fd_form_ref->form_ref,ow,oh); } } @@ -1211,7 +1220,7 @@ void MenuPasteSelection(char at) } -void FootCB(FL_OBJECT*, long) +extern "C" void FootCB(FL_OBJECT*, long) { if (!current_view->available()) return; @@ -1226,8 +1235,7 @@ void FootCB(FL_OBJECT*, long) void LayoutsCB(int sel, void *) { - string tmp; - tmp += sel; + string tmp = tostr(sel); current_view->getOwner()->getLyXFunc()->Dispatch(LFUN_LAYOUTNO, tmp.c_str()); } @@ -1254,7 +1262,7 @@ int RunLinuxDoc(int flag, string const & filename) if (lyxrc->use_tempdir || (IsDirWriteable(path) < 1)) { path = current_view->currentBuffer()->tmppath; } - PathPush (path); + Path p(path); if (flag != -1) { if (!current_view->available()) @@ -1300,7 +1308,6 @@ int RunLinuxDoc(int flag, string const & filename) break; } - PathPop(); AllowInput(); current_view->currentBuffer()->redraw(); @@ -1326,7 +1333,7 @@ int RunDocBook(int flag, string const & filename) if (lyxrc->use_tempdir || (IsDirWriteable(path) < 1)) { path = current_view->currentBuffer()->tmppath; } - PathPush (path); + Path p(path); if (!current_view->available()) return 0; @@ -1357,7 +1364,6 @@ int RunDocBook(int flag, string const & filename) break; } - PathPop(); AllowInput(); current_view->currentBuffer()->redraw(); @@ -1465,12 +1471,19 @@ void AllFloats(char flag, char figmar) void MenuLayoutCharacter() { + static int ow = -1, oh; + if (fd_form_character->form_character->visible) { fl_raise_form(fd_form_character->form_character); } else { fl_show_form(fd_form_character->form_character, FL_PLACE_MOUSE | FL_FREE_SIZE,FL_FULLBORDER, _("Character Style")); + if (ow < 0) { + ow = fd_form_character->form_character->w; + oh = fd_form_character->form_character->h; + } + fl_set_form_minsize(fd_form_character->form_character,ow,oh); } } @@ -1672,7 +1685,7 @@ void MenuLayoutParagraph() fl_raise_form(fd_form_paragraph->form_paragraph); } else { fl_show_form(fd_form_paragraph->form_paragraph, - FL_PLACE_MOUSE | FL_FREE_SIZE,FL_FULLBORDER, + FL_PLACE_MOUSE, FL_FULLBORDER, _("Paragraph Environment")); } } @@ -1923,8 +1936,7 @@ void MenuLayoutDocument() fl_raise_form(fd_form_document->form_document); } else { fl_show_form(fd_form_document->form_document, - FL_PLACE_MOUSE | FL_FREE_SIZE, - FL_FULLBORDER, + FL_PLACE_MOUSE, FL_FULLBORDER, _("Document Layout")); } } @@ -1962,8 +1974,7 @@ void MenuLayoutQuotes() fl_raise_form(fd_form_quotes->form_quotes); } else { fl_show_form(fd_form_quotes->form_quotes, - FL_PLACE_MOUSE | FL_FREE_SIZE, - FL_FULLBORDER, + FL_PLACE_MOUSE, FL_FULLBORDER, _("Quotes")); } } @@ -2002,6 +2013,8 @@ bool UpdateLayoutPreamble() void MenuLayoutPreamble() { + static int ow = -1, oh; + if (UpdateLayoutPreamble()) { if (fd_form_preamble->form_preamble->visible) { fl_raise_form(fd_form_preamble->form_preamble); @@ -2010,6 +2023,12 @@ void MenuLayoutPreamble() FL_PLACE_MOUSE | FL_FREE_SIZE, FL_FULLBORDER, _("LaTeX Preamble")); + if (ow < 0) { + ow = fd_form_preamble->form_preamble->w; + oh = fd_form_preamble->form_preamble->h; + } + fl_set_form_minsize(fd_form_preamble->form_preamble, + ow,oh); } } } @@ -2313,7 +2332,7 @@ void ToggleAndShow(LyXFont const & font) } -void MarginCB(FL_OBJECT *, long) +extern "C" void MarginCB(FL_OBJECT *, long) { if (current_view->available()) { minibuffer->Set(_("Inserting margin note...")); @@ -2325,7 +2344,7 @@ void MarginCB(FL_OBJECT *, long) } -void FigureCB(FL_OBJECT *, long) +extern "C" void FigureCB(FL_OBJECT *, long) { if (fd_form_figure->form_figure->visible) { fl_raise_form(fd_form_figure->form_figure); @@ -2337,13 +2356,13 @@ void FigureCB(FL_OBJECT *, long) } -void TableCB(FL_OBJECT *, long) +extern "C" void TableCB(FL_OBJECT *, long) { if (fd_form_table->form_table->visible) { fl_raise_form(fd_form_table->form_table); } else { fl_show_form(fd_form_table->form_table, - FL_PLACE_MOUSE | FL_FREE_SIZE, FL_FULLBORDER, + FL_PLACE_MOUSE, FL_FULLBORDER, _("Insert Table")); } } @@ -2419,7 +2438,7 @@ void PasteCB() } -void MeltCB(FL_OBJECT *, long) +extern "C" void MeltCB(FL_OBJECT *, long) { if (!current_view->available()) return; @@ -2436,7 +2455,7 @@ void MeltCB(FL_OBJECT *, long) // if decInc == 0, depth change taking mouse button number into account // if decInc == 1, increment depth // if decInc == -1, decrement depth -void DepthCB(FL_OBJECT *ob, long decInc) +extern "C" void DepthCB(FL_OBJECT *ob, long decInc) { int button = 1; @@ -2559,7 +2578,7 @@ void FreeCB() /* callbacks for form form_title */ -void TimerCB(FL_OBJECT *, long) +extern "C" void TimerCB(FL_OBJECT *, long) { // only if the form still exists if (fd_form_title->form_title != 0) { @@ -2574,7 +2593,7 @@ void TimerCB(FL_OBJECT *, long) /* callbacks for form form_paragraph */ -void ParagraphVSpaceCB(FL_OBJECT* obj, long ) +extern "C" void ParagraphVSpaceCB(FL_OBJECT* obj, long ) { // "Synchronize" the choices and input fields, making it // impossible to commit senseless data. @@ -2625,7 +2644,7 @@ void ParagraphVSpaceCB(FL_OBJECT* obj, long ) } -void ParagraphApplyCB(FL_OBJECT *, long) +extern "C" void ParagraphApplyCB(FL_OBJECT *, long) { if (!current_view->available()) return; @@ -2701,13 +2720,13 @@ void ParagraphApplyCB(FL_OBJECT *, long) } -void ParagraphCancelCB(FL_OBJECT *, long) +extern "C" void ParagraphCancelCB(FL_OBJECT *, long) { fl_hide_form(fd_form_paragraph->form_paragraph); } -void ParagraphOKCB(FL_OBJECT *ob, long data) +extern "C" void ParagraphOKCB(FL_OBJECT *ob, long data) { ParagraphApplyCB(ob, data); ParagraphCancelCB(ob, data); @@ -2716,7 +2735,7 @@ void ParagraphOKCB(FL_OBJECT *ob, long data) /* callbacks for form form_character */ -void CharacterApplyCB(FL_OBJECT *, long) +extern "C" void CharacterApplyCB(FL_OBJECT *, long) { // we set toggleall locally here, since it should be true for // all other uses of ToggleAndShow() (JMarc) @@ -2726,13 +2745,13 @@ void CharacterApplyCB(FL_OBJECT *, long) } -void CharacterCloseCB(FL_OBJECT *, long) +extern "C" void CharacterCloseCB(FL_OBJECT *, long) { fl_hide_form(fd_form_character->form_character); } -void CharacterOKCB(FL_OBJECT *ob, long data) +extern "C" void CharacterOKCB(FL_OBJECT *ob, long data) { CharacterApplyCB(ob,data); CharacterCloseCB(ob,data); @@ -2763,7 +2782,7 @@ void UpdateDocumentButtons(BufferParams const ¶ms) } -void ChoiceClassCB(FL_OBJECT *ob, long) +extern "C" void ChoiceClassCB(FL_OBJECT *ob, long) { ProhibitInput(); if (lyxstyle.Load(fl_get_choice(ob)-1)) { @@ -2788,7 +2807,7 @@ void ChoiceClassCB(FL_OBJECT *ob, long) } -void DocumentDefskipCB(FL_OBJECT *obj, long) +extern "C" void DocumentDefskipCB(FL_OBJECT *obj, long) { // "Synchronize" the choice and the input field, so that it // is impossible to commit senseless data. @@ -2817,7 +2836,7 @@ void DocumentDefskipCB(FL_OBJECT *obj, long) } -void DocumentSpacingCB(FL_OBJECT *obj, long) +extern "C" void DocumentSpacingCB(FL_OBJECT *obj, long) { // "Synchronize" the choice and the input field, so that it // is impossible to commit senseless data. @@ -2839,7 +2858,7 @@ void DocumentSpacingCB(FL_OBJECT *obj, long) } -void DocumentApplyCB(FL_OBJECT *, long) +extern "C" void DocumentApplyCB(FL_OBJECT *, long) { bool redo = false; BufferParams *params = &(current_view->currentBuffer()->params); @@ -2894,7 +2913,7 @@ void DocumentApplyCB(FL_OBJECT *, long) if (ret==1) s= _("One paragraph couldn't be converted"); else { - s += ret; + s += tostr(ret); s += _(" paragraphs couldn't be converted"); } WriteAlert(_("Conversion Errors!"),s, @@ -2993,20 +3012,20 @@ void DocumentApplyCB(FL_OBJECT *, long) } -void DocumentCancelCB(FL_OBJECT *, long) +extern "C" void DocumentCancelCB(FL_OBJECT *, long) { fl_hide_form(fd_form_document->form_document); } -void DocumentOKCB(FL_OBJECT *ob, long data) +extern "C" void DocumentOKCB(FL_OBJECT *ob, long data) { DocumentCancelCB(ob,data); DocumentApplyCB(ob,data); } -void DocumentBulletsCB(FL_OBJECT *, long) +extern "C" void DocumentBulletsCB(FL_OBJECT *, long) { bulletForm(); // bullet callbacks etc. in bullet_panel.C -- ARRae @@ -3064,7 +3083,7 @@ void InsertCorrectQuote() /* callbacks for form form_quotes */ -void QuotesApplyCB(FL_OBJECT *, long) +extern "C" void QuotesApplyCB(FL_OBJECT *, long) { if (!current_view->available()) return; @@ -3103,13 +3122,13 @@ void QuotesApplyCB(FL_OBJECT *, long) } -void QuotesCancelCB(FL_OBJECT *, long) +extern "C" void QuotesCancelCB(FL_OBJECT *, long) { fl_hide_form(fd_form_quotes->form_quotes); } -void QuotesOKCB(FL_OBJECT *ob, long data) +extern "C" void QuotesOKCB(FL_OBJECT *ob, long data) { QuotesApplyCB(ob, data); QuotesCancelCB(ob, data); @@ -3119,13 +3138,13 @@ void QuotesOKCB(FL_OBJECT *ob, long data) /* callbacks for form form_preamble */ -void PreambleCancelCB(FL_OBJECT *, long) +extern "C" void PreambleCancelCB(FL_OBJECT *, long) { fl_hide_form(fd_form_preamble->form_preamble); } -void PreambleApplyCB(FL_OBJECT *, long) +extern "C" void PreambleApplyCB(FL_OBJECT *, long) { if (!current_view->available()) return; @@ -3137,7 +3156,7 @@ void PreambleApplyCB(FL_OBJECT *, long) } -void PreambleOKCB(FL_OBJECT *ob, long data) +extern "C" void PreambleOKCB(FL_OBJECT *ob, long data) { PreambleApplyCB(ob, data); PreambleCancelCB(ob, data); @@ -3146,7 +3165,7 @@ void PreambleOKCB(FL_OBJECT *ob, long data) /* callbacks for form form_table */ -void TableApplyCB(FL_OBJECT *, long) +extern "C" void TableApplyCB(FL_OBJECT *, long) { int xsize,ysize; if (!current_view->getScreen()) @@ -3224,13 +3243,13 @@ void TableApplyCB(FL_OBJECT *, long) } -void TableCancelCB(FL_OBJECT *, long) +extern "C" void TableCancelCB(FL_OBJECT *, long) { fl_hide_form(fd_form_table->form_table); } -void TableOKCB(FL_OBJECT *ob, long data) +extern "C" void TableOKCB(FL_OBJECT *ob, long data) { TableApplyCB(ob,data); TableCancelCB(ob,data); @@ -3239,7 +3258,7 @@ void TableOKCB(FL_OBJECT *ob, long data) /* callbacks for form form_print */ -void PrintCancelCB(FL_OBJECT *, long) +extern "C" void PrintCancelCB(FL_OBJECT *, long) { fl_hide_form(fd_form_print->form_print); } @@ -3251,7 +3270,7 @@ static bool stringOnlyContains (string const & LStr, const char * cset) return strspn(cstr,cset) == strlen(cstr) ; } -void PrintApplyCB(FL_OBJECT *, long) +extern "C" void PrintApplyCB(FL_OBJECT *, long) { if (!current_view->available()) return; @@ -3391,7 +3410,7 @@ void PrintApplyCB(FL_OBJECT *, long) if (lyxrc->use_tempdir || (IsDirWriteable(path) < 1)){ path = buffer->tmppath; } - PathPush(path); + Path p(path); bool result; if (!lyxrc->print_spool_command.empty() && @@ -3406,7 +3425,6 @@ void PrintApplyCB(FL_OBJECT *, long) } } else result = RunScript(buffer, false, command); - PathPop(); if (!result) WriteAlert(_("Error:"), @@ -3415,7 +3433,7 @@ void PrintApplyCB(FL_OBJECT *, long) } -void PrintOKCB(FL_OBJECT *ob, long data) +extern "C" void PrintOKCB(FL_OBJECT *ob, long data) { PrintCancelCB(ob, data); PrintApplyCB(ob,data); @@ -3424,7 +3442,7 @@ void PrintOKCB(FL_OBJECT *ob, long data) /* callbacks for form form_figure */ -void FigureApplyCB(FL_OBJECT *, long) +extern "C" void FigureApplyCB(FL_OBJECT *, long) { if (!current_view->available()) return; @@ -3495,19 +3513,19 @@ void FigureApplyCB(FL_OBJECT *, long) } -void FigureCancelCB(FL_OBJECT *, long) +extern "C" void FigureCancelCB(FL_OBJECT *, long) { fl_hide_form(fd_form_figure->form_figure); } -void FigureOKCB(FL_OBJECT *ob, long data) +extern "C" void FigureOKCB(FL_OBJECT *ob, long data) { FigureApplyCB(ob,data); FigureCancelCB(ob,data); } -void ScreenApplyCB(FL_OBJECT *, long) +extern "C" void ScreenApplyCB(FL_OBJECT *, long) { lyxrc->roman_font_name = fl_get_input(fd_form_screen->input_roman); lyxrc->sans_font_name = fl_get_input(fd_form_screen->input_sans); @@ -3523,13 +3541,13 @@ void ScreenApplyCB(FL_OBJECT *, long) } -void ScreenCancelCB(FL_OBJECT *, long) +extern "C" void ScreenCancelCB(FL_OBJECT *, long) { fl_hide_form(fd_form_screen->form_screen); } -void ScreenOKCB(FL_OBJECT *ob, long data) +extern "C" void ScreenOKCB(FL_OBJECT *ob, long data) { ScreenCancelCB(ob,data); ScreenApplyCB(ob,data); @@ -3548,7 +3566,7 @@ void LaTeXOptions() fl_raise_form(fd_latex_options->LaTeXOptions); } else { fl_show_form(fd_latex_options->LaTeXOptions, - FL_PLACE_MOUSE | FL_FREE_SIZE, FL_FULLBORDER, + FL_PLACE_MOUSE, FL_FULLBORDER, _("LaTeX Options")); } } @@ -3561,10 +3579,10 @@ void Reconfigure() minibuffer->Set(_("Running configure...")); // Run configure in user lyx directory - PathPush(user_lyxdir); + Path p(user_lyxdir); Systemcalls one(Systemcalls::System, AddName(system_lyxdir,"configure")); - PathPop(); + p.pop(); minibuffer->Set(_("Reloading configuration...")); lyxrc->Read(LibFileSearch(string(), "lyxrc.defaults")); WriteAlert(_("The system has been reconfigured."), @@ -3652,7 +3670,7 @@ struct TocList { static TocList* toclist = 0; -void TocSelectCB(FL_OBJECT *ob, long) +extern "C" void TocSelectCB(FL_OBJECT *ob, long) { if (!current_view->available()) return; @@ -3696,13 +3714,13 @@ void TocSelectCB(FL_OBJECT *ob, long) } -void TocCancelCB(FL_OBJECT *, long) +extern "C" void TocCancelCB(FL_OBJECT *, long) { fl_hide_form(fd_form_toc->form_toc); } -void TocUpdateCB(FL_OBJECT *, long) +extern "C" void TocUpdateCB(FL_OBJECT *, long) { static LyXParagraph* stapar = 0; TocList *tmptoclist = 0; @@ -3808,7 +3826,7 @@ void TocUpdateCB(FL_OBJECT *, long) /* callbacks for form form_ref */ -void RefSelectCB(FL_OBJECT *, long data) +extern "C" void RefSelectCB(FL_OBJECT *, long data) { if (!current_view->available()) return; @@ -3843,7 +3861,7 @@ void RefSelectCB(FL_OBJECT *, long data) } -void RefUpdateCB(FL_OBJECT *, long) +extern "C" void RefUpdateCB(FL_OBJECT *, long) { if (!current_view->available()) { fl_clear_browser(fd_form_ref->browser_ref); @@ -3912,7 +3930,7 @@ void RefUpdateCB(FL_OBJECT *, long) } -void RefHideCB(FL_OBJECT *, long) +extern "C" void RefHideCB(FL_OBJECT *, long) { fl_hide_form(fd_form_ref->form_ref); } @@ -4064,8 +4082,7 @@ void UpdateInsetUpdateList() void addNewlineAndDepth(string &file, int const depth) { file += '\n'; - for (int j=0;j< depth;j++) - file += ' '; + file.append(' ', depth); }