X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Flyx_cb.C;h=a6f8f60d18a07e90f0d132621b2723a24f6540e2;hb=a69e7a45780e94f4330a91facfe35126c678e34e;hp=c0d847f62779ffd5aa1ff51251a268a183778e66;hpb=6bba977f42b0cde753ac2ffd26f3f9c6b32ba0b6;p=lyx.git diff --git a/src/lyx_cb.C b/src/lyx_cb.C index c0d847f627..a6f8f60d18 100644 --- a/src/lyx_cb.C +++ b/src/lyx_cb.C @@ -40,11 +40,9 @@ #include "support/filetools.h" #include "support/path.h" #include "lyxserver.h" -#include "FontLoader.h" #include "lyxrc.h" #include "lyxtext.h" #include "CutAndPaste.h" -#include "TextCache.h" using std::ifstream; using std::copy; @@ -70,10 +68,6 @@ extern FD_form_quotes * fd_form_quotes; extern FD_form_preamble * fd_form_preamble; extern FD_form_table * fd_form_table; extern FD_form_figure * fd_form_figure; -extern FD_form_screen * fd_form_screen; -extern FD_form_toc * fd_form_toc; -extern FD_form_ref * fd_form_ref; -extern FD_LaTeXOptions * fd_latex_options; extern FD_form_bullet * fd_form_bullet; extern BufferView * current_view; // called too many times in this file... @@ -160,8 +154,8 @@ void ToggleLockedInsetCursor(long x, long y, int asc, int desc); int RunLinuxDoc(BufferView *, int, string const &); int RunDocBook(int, string const &); -void MenuWrite(Buffer * buf); -void MenuWriteAs(Buffer * buffer); +bool MenuWrite(Buffer * buf); +bool MenuWriteAs(Buffer * buffer); void MenuReload(Buffer * buf); void MenuLayoutSave(); @@ -190,7 +184,7 @@ void ShowMessage(Buffer * buf, // // should be moved to lyxfunc.C -void MenuWrite(Buffer * buffer) +bool MenuWrite(Buffer * buffer) { XFlush(fl_display); if (!buffer->save()) { @@ -199,17 +193,19 @@ void MenuWrite(Buffer * buffer) if (AskQuestion(_("Save failed. Rename and try again?"), MakeDisplayPath(s, 50), _("(If not, document is not saved.)"))) { - MenuWriteAs(buffer); + return MenuWriteAs(buffer); } + return false; } else { lastfiles->newFile(buffer->fileName()); } + return true; } // should be moved to BufferView.C // Half of this func should be in LyXView, the rest in BufferView. -void MenuWriteAs(Buffer * buffer) +bool MenuWriteAs(Buffer * buffer) { // Why do we require BufferView::text to be able to write a // document? I see no point in that. (Lgb) @@ -226,14 +222,21 @@ void MenuWriteAs(Buffer * buffer) if (!IsLyXFilename(fname)) fname += ".lyx"; - fname = fileDlg.Select(_("Enter Filename to Save Document as"), - OnlyPath(fname), - "*.lyx", - OnlyFilename(fname)); + if (buffer->isUnnamed()) { + fname = fileDlg.Select(_("Enter Filename to Save Document as"), + "", + "*.lyx", + ""); + } else { + fname = fileDlg.Select(_("Enter Filename to Save Document as"), + OnlyPath(fname), + "*.lyx", + OnlyFilename(fname)); + } AllowInput(current_view); if (fname.empty()) { - return; + return false; } // Make sure the absolute filename ends with appropriate suffix string s = MakeAbsPath(fname); @@ -245,7 +248,7 @@ void MenuWriteAs(Buffer * buffer) if (!AskQuestion(_("Same name as document already has:"), MakeDisplayPath(s, 50), _("Save anyway?"))) - return; + return false; // Falls through to name change and save } // No, but do we have another file with this name open? @@ -263,24 +266,36 @@ void MenuWriteAs(Buffer * buffer) ShowMessage(buffer, _("Document renamed to '"), MakeDisplayPath(s), _("', but not saved...")); } - return; + return false; } // Check whether the file exists else { FileInfo myfile(s); if (myfile.isOK() && !AskQuestion(_("Document already exists:"), MakeDisplayPath(s, 50), _("Replace file?"))) - return; + return false; } // Ok, change the name of the buffer buffer->fileName(s); buffer->markDirty(); + bool unnamed = buffer->isUnnamed(); + buffer->setUnnamed(false); // And save // Small bug: If the save fails, we have irreversible changed the name // of the document. - MenuWrite(buffer); -} + // Hope this is fixed this way! (Jug) + if (!MenuWrite(buffer)) { + buffer->fileName(oldname); + buffer->setUnnamed(unnamed); + ShowMessage(buffer, _("Document could not be saved!"), + _("Holding the old name."), MakeDisplayPath(oldname)); + return false; + } + // now remove the oldname autosave file if existant! + removeAutosaveFile(oldname); + return true; +} int MenuRunLaTeX(Buffer * buffer) @@ -384,11 +399,11 @@ int MakeLaTeXOutput(Buffer * buffer) if (lyxrc.use_tempdir || (IsDirWriteable(path) < 1)) { path = buffer->tmppath; } - //if (!buffer->isDviClean()) { - Path p(path); - ret = MenuRunLaTeX(buffer); - //} - return ret; + + Path p(path); + ret = MenuRunLaTeX(buffer); + + return ret; } @@ -720,7 +735,6 @@ void MenuMakeLaTeX(Buffer * buffer) buffer->makeLaTeXFile(s, string(), true); ShowMessage(buffer, _("Nice LaTeX file saved as"), MakeDisplayPath(s)); - buffer->markDviDirty(); } } @@ -744,7 +758,7 @@ void MenuMakeLinuxDoc(Buffer * buffer) ShowMessage(buffer, _("Building LinuxDoc SGML file `"), MakeDisplayPath(s),"'..."); - buffer->makeLinuxDocFile(s, 65); + buffer->makeLinuxDocFile(s, true); buffer->redraw(); ShowMessage(buffer, _("LinuxDoc SGML file save as"), MakeDisplayPath(s)); @@ -771,7 +785,7 @@ void MenuMakeDocBook(Buffer * buffer) ShowMessage(buffer, _("Building DocBook SGML file `"), MakeDisplayPath(s), "'..."); - buffer->makeDocBookFile(s, 65); + buffer->makeDocBookFile(s, true); buffer->redraw(); ShowMessage(buffer, _("DocBook SGML file save as"), MakeDisplayPath(s)); @@ -927,15 +941,12 @@ void MenuExport(Buffer * buffer, string const & extyp) } // HTML else if (extyp == "html") { - MenuMakeHTML(buffer); - } - // HTML from linuxdoc - else if (extyp == "html-linuxdoc") { - MenuMakeHTML_LinuxDoc(buffer); - } - // HTML from docbook - else if (extyp == "html-docbook") { - MenuMakeHTML_DocBook(buffer); + if (buffer->isLinuxDoc()) + MenuMakeHTML_LinuxDoc(buffer); + else if (buffer->isDocBook()) + MenuMakeHTML_DocBook(buffer); + else + MenuMakeHTML(buffer); } else { ShowMessage(buffer, _("Unknown export type: ") + extyp); @@ -976,8 +987,7 @@ void AutoSave(BufferView * bv) if (!bv->available()) return; - if (bv->buffer()->isBakClean() - || bv->buffer()->isReadonly()) { + if (bv->buffer()->isBakClean() || bv->buffer()->isReadonly()) { // We don't save now, but we'll try again later bv->owner()->resetAutosaveTimer(); return; @@ -1104,10 +1114,19 @@ void InsertAsciiFile(BufferView * bv, string const & f, bool asParagraph) ifs.unsetf(ios::skipws); istream_iterator ii(ifs); istream_iterator end; +#if !defined(USE_INCLUDED_STRING) && !defined(STD_STRING_IS_GOOD) + // We use this until the compilers get better... + vector tmp; + copy(ii, end, back_inserter(tmp)); + string tmpstr(tmp.begin(), tmp.end()); +#else + // This is what we want to use and what we will use once the + // compilers get good enough. //string tmpstr(ii, end); // yet a reason for using std::string // alternate approach to get the file into a string: string tmpstr; copy(ii, end, back_inserter(tmpstr)); +#endif // insert the string current_view->hideCursor(); @@ -1121,26 +1140,6 @@ void InsertAsciiFile(BufferView * bv, 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); - } else { - 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); - } -} - - void MenuInsertLabel(char const * arg) { string label = arg; @@ -1153,34 +1152,14 @@ void MenuInsertLabel(char const * arg) } } if (!label.empty()) { - InsetLabel * new_inset = new InsetLabel; - new_inset->setContents(label); - current_view->insertInset(new_inset); + InsetCommandParams p( "label", label ); + InsetLabel * inset = new InsetLabel( p ); + current_view->insertInset( inset ); } AllowInput(current_view); } -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); - } else { - 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); - } -} - - // candidate for move to LyXView // This is only used in toolbar.C void LayoutsCB(int sel, void *) @@ -1213,7 +1192,7 @@ int RunLinuxDoc(BufferView * bv, int flag, string const & filename) if (!bv->available()) return 0; - bv->buffer()->makeLinuxDocFile(name, 0); + bv->buffer()->makeLinuxDocFile(name, false); // CHECK remove this once we have a proper geometry class @@ -1244,8 +1223,7 @@ int RunLinuxDoc(BufferView * bv, int flag, string const & filename) s2 = lyxrc.linuxdoc_to_latex_command + ' ' + add_flags + " -o dvi " + ' ' + name; if (one.startscript(Systemcalls::System, s2)) { errorcode = 1; - } else - bv->buffer()->markDviClean(); + } break; default: /* unknown output */ break; @@ -1275,7 +1253,7 @@ int RunDocBook(int flag, string const & filename) if (!current_view->available()) return 0; - current_view->buffer()->makeDocBookFile(name, 0); + current_view->buffer()->makeDocBookFile(name, false); // Shall this code go or should it stay? (Lgb) // This code is a placeholder for future implementation. (Jose') @@ -1297,8 +1275,7 @@ int RunDocBook(int flag, string const & filename) string s2 = lyxrc.docbook_to_dvi_command + ' ' + name; if (one.startscript(Systemcalls::System, s2)) { errorcode = 1; - } else - current_view->buffer()->markDviClean(); + } } break; default: /* unknown output */ @@ -1408,18 +1385,23 @@ bool UpdateLayoutParagraph() } Buffer * buf = current_view->buffer(); + LyXText * text = 0; + if (current_view->the_locking_inset) + text = current_view->the_locking_inset->getLyXText(current_view); + if (!text) + text = current_view->text; fl_set_input(fd_form_paragraph->input_labelwidth, - current_view->text->cursor.par()->GetLabelWidthString().c_str()); + text->cursor.par()->GetLabelWidthString().c_str()); fl_set_button(fd_form_paragraph->radio_align_right, 0); fl_set_button(fd_form_paragraph->radio_align_left, 0); fl_set_button(fd_form_paragraph->radio_align_center, 0); fl_set_button(fd_form_paragraph->radio_align_block, 0); - int align = current_view->text->cursor.par()->GetAlign(); + int align = text->cursor.par()->GetAlign(); if (align == LYX_ALIGN_LAYOUT) align = textclasslist.Style(buf->params.textclass, - current_view->text->cursor.par()->GetLayout()).align; + text->cursor.par()->GetLayout()).align; switch (align) { case LYX_ALIGN_RIGHT: @@ -1435,20 +1417,41 @@ bool UpdateLayoutParagraph() fl_set_button(fd_form_paragraph->radio_align_block, 1); break; } - + +#ifndef NEW_INSETS fl_set_button(fd_form_paragraph->check_lines_top, - current_view->text->cursor.par()->FirstPhysicalPar()->line_top); + text->cursor.par()->FirstPhysicalPar()->line_top); + fl_set_button(fd_form_paragraph->check_lines_bottom, - current_view->text->cursor.par()->FirstPhysicalPar()->line_bottom); + text->cursor.par()->FirstPhysicalPar()->line_bottom); + fl_set_button(fd_form_paragraph->check_pagebreaks_top, - current_view->text->cursor.par()->FirstPhysicalPar()->pagebreak_top); + text->cursor.par()->FirstPhysicalPar()->pagebreak_top); + fl_set_button(fd_form_paragraph->check_pagebreaks_bottom, - current_view->text->cursor.par()->FirstPhysicalPar()->pagebreak_bottom); + text->cursor.par()->FirstPhysicalPar()->pagebreak_bottom); fl_set_button(fd_form_paragraph->check_noindent, - current_view->text->cursor.par()->FirstPhysicalPar()->noindent); + text->cursor.par()->FirstPhysicalPar()->noindent); +#else + fl_set_button(fd_form_paragraph->check_lines_top, + text->cursor.par()->line_top); + fl_set_button(fd_form_paragraph->check_lines_bottom, + text->cursor.par()->line_bottom); + fl_set_button(fd_form_paragraph->check_pagebreaks_top, + text->cursor.par()->pagebreak_top); + fl_set_button(fd_form_paragraph->check_pagebreaks_bottom, + text->cursor.par()->pagebreak_bottom); + fl_set_button(fd_form_paragraph->check_noindent, + text->cursor.par()->noindent); +#endif fl_set_input (fd_form_paragraph->input_space_above, ""); - - switch (current_view->text->cursor.par()->FirstPhysicalPar()->added_space_top.kind()) { + +#ifndef NEW_INSETS + switch (text->cursor.par()->FirstPhysicalPar()->added_space_top.kind()) { +#else + switch (text->cursor.par()->added_space_top.kind()) { +#endif + case VSpace::NONE: fl_set_choice (fd_form_paragraph->choice_space_above, 1); break; @@ -1468,15 +1471,27 @@ bool UpdateLayoutParagraph() fl_set_choice (fd_form_paragraph->choice_space_above, 6); break; case VSpace::LENGTH: - fl_set_choice (fd_form_paragraph->choice_space_above, 7); + fl_set_choice (fd_form_paragraph->choice_space_above, 7); +#ifndef NEW_INSETS + fl_set_input (fd_form_paragraph->input_space_above, + text->cursor.par()->FirstPhysicalPar()->added_space_top.length().asString().c_str()); +#else fl_set_input (fd_form_paragraph->input_space_above, - current_view->text->cursor.par()->FirstPhysicalPar()->added_space_top.length().asString().c_str()); + text->cursor.par()->added_space_top.length().asString().c_str()); +#endif break; } +#ifndef NEW_INSETS + fl_set_button (fd_form_paragraph->check_space_above, + text->cursor.par()->FirstPhysicalPar()->added_space_top.keep()); + fl_set_input (fd_form_paragraph->input_space_below, ""); + switch (text->cursor.par()->FirstPhysicalPar()->added_space_bottom.kind()) { +#else fl_set_button (fd_form_paragraph->check_space_above, - current_view->text->cursor.par()->FirstPhysicalPar()->added_space_top.keep()); + text->cursor.par()->added_space_top.keep()); fl_set_input (fd_form_paragraph->input_space_below, ""); - switch (current_view->text->cursor.par()->FirstPhysicalPar()->added_space_bottom.kind()) { + switch (text->cursor.par()->added_space_bottom.kind()) { +#endif case VSpace::NONE: fl_set_choice (fd_form_paragraph->choice_space_below, 1); @@ -1503,17 +1518,28 @@ bool UpdateLayoutParagraph() break; case VSpace::LENGTH: fl_set_choice (fd_form_paragraph->choice_space_below, - 7); + 7); +#ifndef NEW_INSETS fl_set_input (fd_form_paragraph->input_space_below, - current_view->text->cursor.par()->FirstPhysicalPar()->added_space_bottom.length().asString().c_str()); + text->cursor.par()->FirstPhysicalPar()->added_space_bottom.length().asString().c_str()); break; } fl_set_button (fd_form_paragraph->check_space_below, - current_view->text->cursor.par()->FirstPhysicalPar()->added_space_bottom.keep()); + text->cursor.par()->FirstPhysicalPar()->added_space_bottom.keep()); fl_set_button(fd_form_paragraph->check_noindent, - current_view->text->cursor.par()->FirstPhysicalPar()->noindent); + text->cursor.par()->FirstPhysicalPar()->noindent); +#else + fl_set_input (fd_form_paragraph->input_space_below, + text->cursor.par()->added_space_bottom.length().asString().c_str()); + break; + } + fl_set_button (fd_form_paragraph->check_space_below, + text->cursor.par()->added_space_bottom.keep()); + fl_set_button(fd_form_paragraph->check_noindent, + text->cursor.par()->noindent); +#endif if (current_view->buffer()->isReadonly()) { DisableParagraphLayout(); } else { @@ -1913,7 +1939,7 @@ void MenuLayoutSave() // This is both GUI and LyXFont dependent. Don't know where to put it. (Asger) // Well, it's mostly GUI dependent, so I guess it will stay here. (Asger) -LyXFont UserFreeFont() +LyXFont UserFreeFont(BufferParams const & params) { LyXFont font(LyXFont::ALL_IGNORE); @@ -1995,20 +2021,18 @@ LyXFont UserFreeFont() case 11: font.setColor(LColor::inherit); break; } - string language = combo_language2->getline(); - Languages::iterator lit = languages.find(language); - if (lit != languages.end()) - font.setLanguage(&(*lit).second); - else - font.setLanguage(ignore_language); - + int choice = combo_language2->get(); + if (choice == 1) + font.setLanguage(ignore_language); + else if (choice == 2) + font.setLanguage(params.language_info); + else + font.setLanguage(&languages[combo_language2->getline()]); return font; } - - /* callbacks for form form_title */ extern "C" void TimerCB(FL_OBJECT *, long) { @@ -2136,16 +2160,21 @@ extern "C" void ParagraphApplyCB(FL_OBJECT *, long) labelwidthstring = fl_get_input(fd_form_paragraph->input_labelwidth); noindent = fl_get_button(fd_form_paragraph->check_noindent); - current_view->text->SetParagraph(current_view, - line_top, - line_bottom, - pagebreak_top, - pagebreak_bottom, - space_top, - space_bottom, - align, - labelwidthstring, - noindent); + LyXText * text = 0; + if (current_view->the_locking_inset) + text = current_view->the_locking_inset->getLyXText(current_view); + if (!text) + text = current_view->text; + text->SetParagraph(current_view, + line_top, + line_bottom, + pagebreak_top, + pagebreak_bottom, + space_top, + space_bottom, + align, + labelwidthstring, + noindent); current_view->update(BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE); current_view->owner()->getMiniBuffer()->Set(_("Paragraph layout set")); } @@ -2171,7 +2200,7 @@ extern "C" void CharacterApplyCB(FL_OBJECT *, long) // we set toggleall locally here, since it should be true for // all other uses of ToggleAndShow() (JMarc) toggleall = fl_get_button(fd_form_character->check_toggle_all); - ToggleAndShow(current_view, UserFreeFont()); + ToggleAndShow(current_view, UserFreeFont(current_view->buffer()->params)); current_view->setState(); toggleall = true; } @@ -2576,11 +2605,13 @@ extern "C" void PreambleOKCB(FL_OBJECT * ob, long data) /* callbacks for form form_table */ -extern "C" void TableApplyCB(FL_OBJECT *, long) +extern "C" +void TableApplyCB(FL_OBJECT *, long) { if (!current_view->available()) return; - + +#ifndef NEW_TABULAR // check for tables in tables if (current_view->text->cursor.par()->table){ WriteAlert(_("Impossible Operation!"), @@ -2588,7 +2619,7 @@ extern "C" void TableApplyCB(FL_OBJECT *, long) _("Sorry.")); return; } - +#endif current_view->owner()->getMiniBuffer()->Set(_("Inserting table...")); int ysize = int(fl_get_slider_value(fd_form_table->slider_columns) + 0.5); @@ -2616,8 +2647,10 @@ extern "C" void TableApplyCB(FL_OBJECT *, long) //if (!fl_get_button(fd_form_table->check_latex)){ // insert the new wysiwy table current_view->text->SetLayout(current_view, 0); // standard layout +#ifndef NEW_INSETS if (current_view->text->cursor.par()->footnoteflag == LyXParagraph::NO_FOOTNOTE) { +#endif current_view->text ->SetParagraph(current_view, 0, 0, 0, 0, @@ -2630,6 +2663,7 @@ extern "C" void TableApplyCB(FL_OBJECT *, long) LYX_ALIGN_CENTER, string(), 0); +#ifndef NEW_INSETS } else { current_view->text ->SetParagraph(current_view, 0, 0, @@ -2640,16 +2674,17 @@ extern "C" void TableApplyCB(FL_OBJECT *, long) string(), 0); } - +#endif +#ifndef NEW_TABULAR current_view->text->cursor.par()->table = new LyXTable(xsize, ysize); - +#endif Language const * lang = current_view->text->cursor.par()->getParLanguage(current_view->buffer()->params); LyXFont font(LyXFont::ALL_INHERIT, lang); for (int i = 0; i < xsize * ysize - 1; ++i) { - current_view->text->cursor.par()->InsertChar(0, LyXParagraph::META_NEWLINE); - current_view->text->cursor.par()->SetFont(0, font); + current_view->text->cursor.par() + ->InsertChar(0, LyXParagraph::META_NEWLINE, font); } current_view->text->RedoParagraph(current_view); @@ -2661,13 +2696,15 @@ extern "C" void TableApplyCB(FL_OBJECT *, long) } -extern "C" void TableCancelCB(FL_OBJECT *, long) +extern "C" +void TableCancelCB(FL_OBJECT *, long) { fl_hide_form(fd_form_table->form_table); } -extern "C" void TableOKCB(FL_OBJECT * ob, long data) +extern "C" +void TableOKCB(FL_OBJECT * ob, long data) { TableApplyCB(ob, data); TableCancelCB(ob, data); @@ -2699,7 +2736,8 @@ void Table() /* callbacks for form form_figure */ -extern "C" void FigureApplyCB(FL_OBJECT *, long) +extern "C" +void FigureApplyCB(FL_OBJECT *, long) { if (!current_view->available()) return; @@ -2710,7 +2748,10 @@ extern "C" void FigureApplyCB(FL_OBJECT *, long) current_view->owner()->getMiniBuffer()->Set(_("Inserting figure...")); if (fl_get_button(fd_form_figure->radio_inline) - || current_view->text->cursor.par()->table) { +#ifndef NEW_TABULAR + || current_view->text->cursor.par()->table +#endif + ) { InsetFig * new_inset = new InsetFig(100, 20, buffer); current_view->insertInset(new_inset); current_view->owner()->getMiniBuffer()->Set(_("Figure inserted")); @@ -2737,9 +2778,11 @@ extern "C" void FigureApplyCB(FL_OBJECT *, long) // The standard layout should always be numer 0; current_view->text->SetLayout(current_view, 0); - + +#ifndef NEW_INSETS if (current_view->text->cursor.par()->footnoteflag == LyXParagraph::NO_FOOTNOTE) { +#endif current_view->text-> SetParagraph(current_view, 0, 0, 0, 0, @@ -2749,6 +2792,7 @@ extern "C" void FigureApplyCB(FL_OBJECT *, long) buffer->params.spacing.getValue(), LyXLength::CM), LYX_ALIGN_CENTER, string(), 0); +#ifndef NEW_INSETS } else { current_view->text->SetParagraph(current_view, 0, 0, 0, 0, @@ -2758,6 +2802,7 @@ extern "C" void FigureApplyCB(FL_OBJECT *, long) string(), 0); } +#endif current_view->update(BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE); @@ -2784,60 +2829,6 @@ extern "C" void FigureOKCB(FL_OBJECT * ob, long data) } -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); - lyxrc.typewriter_font_name = fl_get_input(fd_form_screen->input_typewriter); - lyxrc.font_norm = fl_get_input(fd_form_screen->input_font_norm); - lyxrc.zoom = atoi(fl_get_input(fd_form_screen->intinput_size)); - fontloader.update(); - - // Of course we should only to the resize and the textcahce.clear - // if values really changed...but not very important right now. (Lgb) - - // All buffers will need resize - bufferlist.resize(); - // We also need to empty the textcache so that - // the buffer will be formatted correctly after - // a zoom change. - textcache.clear(); - - current_view->owner()->getMiniBuffer()->Set(_("Screen options set")); -} - - -extern "C" void ScreenCancelCB(FL_OBJECT *, long) -{ - fl_hide_form(fd_form_screen->form_screen); -} - - -extern "C" void ScreenOKCB(FL_OBJECT * ob, long data) -{ - ScreenCancelCB(ob, data); - ScreenApplyCB(ob, data); -} - - -void LaTeXOptions(BufferView * bv) -{ - if (!bv->available()) - return; - - fl_set_button(fd_latex_options->accents, - int(bv->buffer()->params.allowAccents)); - - if (fd_latex_options->LaTeXOptions->visible) { - fl_raise_form(fd_latex_options->LaTeXOptions); - } else { - fl_show_form(fd_latex_options->LaTeXOptions, - FL_PLACE_MOUSE, FL_FULLBORDER, - _("LaTeX Options")); - } -} - - // This function runs "configure" and then rereads lyx.defaults to // reconfigure the automatic settings. void Reconfigure(BufferView * bv) @@ -2855,240 +2846,3 @@ void Reconfigure(BufferView * bv) _("You need to restart LyX to make use of any"), _("updated document class specifications.")); } - - -// -// Table of Contents -// - -static vector toclist; - - -extern "C" void TocSelectCB(FL_OBJECT * ob, long) -{ - if (!current_view->available()) - return; - - TocUpdateCB(0, 0); - unsigned int choice = fl_get_browser(ob); - if (0 < choice && choice - 1 < toclist.size()) { - current_view->beforeChange(); - current_view->text->SetCursor(current_view, toclist[choice-1].par, 0); - current_view->text->sel_cursor = - current_view->text->cursor; - current_view->update(BufferView::SELECT|BufferView::FITCUR); - } else { - WriteAlert(_("Error"), - _("Couldn't find this label"), - _("in current document.")); - } -} - - -extern "C" void TocCancelCB(FL_OBJECT *, long) -{ - fl_hide_form(fd_form_toc->form_toc); -} - - -extern "C" -void TocUpdateCB(FL_OBJECT *, long) -{ - if (!current_view->available()) { - toclist.clear(); - fl_clear_browser(fd_form_toc->browser_toc); - fl_add_browser_line(fd_form_toc->browser_toc, - _("*** No Document ***")); - return; - } - - vector > tmp = - current_view->buffer()->getTocList(); - int type = fl_get_choice(fd_form_toc->toctype)-1; - //if (toclist == tmp[type]) - // return; - if (toclist.size() == tmp[type].size()) { - // Check if all elements are the same. - unsigned int i = 0; - for (; i < toclist.size(); ++i) { - if (toclist[i] != tmp[type][i]) - break; - } - if (i >= toclist.size()) return; - } - - toclist = tmp[type]; - - static Buffer * buffer = 0; - int topline = 0; - int line = 0; - if (buffer == current_view->buffer()) { - topline = fl_get_browser_topline(fd_form_toc->browser_toc); - line = fl_get_browser(fd_form_toc->browser_toc); - } else - buffer = current_view->buffer(); - - fl_clear_browser(fd_form_toc->browser_toc); - fl_hide_object(fd_form_toc->browser_toc); - - for (vector::const_iterator it = toclist.begin(); - it != toclist.end(); ++it) - fl_add_browser_line(fd_form_toc->browser_toc, - (string(4*(*it).depth,' ')+ - (*it).str).c_str()); - - fl_set_browser_topline(fd_form_toc->browser_toc, topline); - fl_select_browser_line(fd_form_toc->browser_toc, line); - fl_show_object(fd_form_toc->browser_toc); -} - - -/* callbacks for form form_ref */ -extern "C" void RefSelectCB(FL_OBJECT *, long data) -{ - if (!current_view->available()) - return; - - string s = - fl_get_browser_line(fd_form_ref->browser_ref, - fl_get_browser(fd_form_ref->browser_ref)); - string u = frontStrip(strip(fl_get_input(fd_form_ref->ref_name))); - - if (s.empty()) - return; - - if (data == 5) { - current_view->owner()->getLyXFunc()->Dispatch(LFUN_REFGOTO, s.c_str()); - if (!current_view->NoSavedPositions()) { - fl_activate_object(fd_form_ref->back); - fl_set_object_lcol(fd_form_ref->back, FL_BLACK); - } - return; - } else if (data >= 6) { - current_view->owner()->getLyXFunc()->Dispatch(LFUN_REFBACK); - if (current_view->NoSavedPositions()) { - fl_deactivate_object(fd_form_ref->back); - fl_set_object_lcol(fd_form_ref->back, FL_INACTIVE); - } - return; - } - - static string const commands[5] - = { "\\ref", "\\pageref", "\\vref", "\\vpageref", - "\\prettyref"}; - string t = commands[data]; - - if (current_view->buffer()->isSGML()) - t += "[" + u + "]" + "{" + s + "}"; - else - t += "{" + s + "}"; - - Inset * new_inset = - new InsetRef(t, current_view->buffer()); - current_view->insertInset(new_inset); -} - - -extern "C" void RefUpdateCB(FL_OBJECT *, long) -{ - if (!current_view->available()) { - fl_clear_browser(fd_form_ref->browser_ref); - return; - } - - FL_OBJECT * brow = fd_form_ref->browser_ref; - - // Get the current line, in order to restore it later - char const * const btmp = fl_get_browser_line(brow, - fl_get_browser(brow)); - string currentstr = btmp ? btmp : ""; - - fl_clear_browser(brow); - fl_hide_object(brow); - - vector refs = current_view->buffer()->getLabelList(); - if (fl_get_button(fd_form_ref->sort)) - sort(refs.begin(),refs.end()); - for (vector::const_iterator it = refs.begin(); - it != refs.end(); ++it) - fl_add_browser_line(brow, (*it).c_str()); - - int topline = 1; - int total_lines = fl_get_browser_maxline(brow); - for (int i = 1; i <= total_lines ; ++i) { - if (fl_get_browser_line(brow, i) == currentstr) { - topline = i; - break; - } - } - fl_set_browser_topline(brow, topline); - - bool empty = refs.empty(); - bool sgml = current_view->buffer()->isSGML(); - bool readonly = current_view->buffer()->isReadonly(); - - if (current_view->NoSavedPositions()) { - fl_deactivate_object(fd_form_ref->back); - fl_set_object_lcol(fd_form_ref->back, FL_INACTIVE); - } else { - fl_activate_object(fd_form_ref->back); - fl_set_object_lcol(fd_form_ref->back, FL_BLACK); - } - - if (empty) { - fl_add_browser_line(brow, - _("*** No labels found in document ***")); - fl_deactivate_object(brow); - fl_deactivate_object(fd_form_ref->gotoref); - fl_set_object_lcol(fd_form_ref->gotoref, FL_INACTIVE); - } else { - fl_select_browser_line(brow, topline); - fl_activate_object(brow); - fl_activate_object(fd_form_ref->gotoref); - fl_set_object_lcol(fd_form_ref->gotoref, FL_BLACK); - } - - if (empty || readonly) { - fl_deactivate_object(fd_form_ref->ref); - fl_set_object_lcol(fd_form_ref->ref, FL_INACTIVE); - fl_deactivate_object(fd_form_ref->pageref); - fl_set_object_lcol(fd_form_ref->pageref, FL_INACTIVE); - } else { - fl_activate_object(fd_form_ref->ref); - fl_set_object_lcol(fd_form_ref->ref, FL_BLACK); - fl_activate_object(fd_form_ref->pageref); - fl_set_object_lcol(fd_form_ref->pageref, FL_BLACK); - } - - if (empty || readonly || sgml) { - fl_deactivate_object(fd_form_ref->vref); - fl_set_object_lcol(fd_form_ref->vref, FL_INACTIVE); - fl_deactivate_object(fd_form_ref->vpageref); - fl_set_object_lcol(fd_form_ref->vpageref, FL_INACTIVE); - fl_deactivate_object(fd_form_ref->prettyref); - fl_set_object_lcol(fd_form_ref->prettyref, FL_INACTIVE); - } else { - fl_activate_object(fd_form_ref->vref); - fl_set_object_lcol(fd_form_ref->vref, FL_BLACK); - fl_activate_object(fd_form_ref->vpageref); - fl_set_object_lcol(fd_form_ref->vpageref, FL_BLACK); - fl_activate_object(fd_form_ref->prettyref); - fl_set_object_lcol(fd_form_ref->prettyref, FL_BLACK); - } - - if (sgml) { - fl_activate_object(fd_form_ref->ref_name); - fl_set_object_lcol(fd_form_ref->ref_name, FL_BLACK); - } else { - fl_deactivate_object(fd_form_ref->ref_name); - fl_set_object_lcol(fd_form_ref->ref_name, FL_INACTIVE); - } - - fl_show_object(brow); -} - - -extern "C" void RefHideCB(FL_OBJECT *, long) -{ - fl_hide_form(fd_form_ref->form_ref); -}