From: Lars Gullik Bjønnes Date: Wed, 12 Apr 2000 14:20:08 +0000 (+0000) Subject: small fixes, silence debug msgs, move some functions X-Git-Tag: 1.6.10~22303 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=c93e59102c8f44477d98c962a09b8d40f87cd418;p=features.git small fixes, silence debug msgs, move some functions git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@650 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/ChangeLog b/ChangeLog index b2e312891b..d5d7195af4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2000-04-12 Lars Gullik Bjønnes + + * src/lyxfunc.C (Dispatch): make PARAGRAPH_SPACING compile with + strstream too. + + * src/bufferview_funcs.[Ch]: two new files, moved several of the + methods from lyx_cb.here. + + * src/lyx_cb.C: in addition to the above; removed input_prohibited + it was not used. + 2000-04-11 Lars Gullik Bjønnes * src/lyx_cb.[Ch]: made several functions take a BufferView* arg diff --git a/src/BufferView_pimpl.C b/src/BufferView_pimpl.C index 8571e7e66f..8ca4cc9a05 100644 --- a/src/BufferView_pimpl.C +++ b/src/BufferView_pimpl.C @@ -17,7 +17,7 @@ #include "lyxfunc.h" #include "minibuffer.h" #include "font.h" -#include "lyx_cb.h" +#include "bufferview_funcs.h" #include "TextCache.h" #include "bufferlist.h" #include "insets/insetbib.h" @@ -29,8 +29,11 @@ using std::pair; using std::endl; +/* the selection possible is needed, that only motion events are + * used, where the bottom press event was on the drawing area too */ +bool selection_possible = false; + extern BufferList bufferlist; -extern bool selection_possible; extern char ascii_type; extern void sigchldhandler(pid_t pid, int * status); diff --git a/src/LyXSendto.C b/src/LyXSendto.C index defc086bd2..0ef41824f1 100644 --- a/src/LyXSendto.C +++ b/src/LyXSendto.C @@ -11,7 +11,8 @@ #include "lyx_gui_misc.h" #include "support/syscall.h" #include "gettext.h" -#include "lyx_cb.h" +//#include "lyx_cb.h" +#include "bufferview_funcs.h" extern FD_form_sendto * fd_form_sendto; extern BufferView * current_view; diff --git a/src/Makefile.am b/src/Makefile.am index b098b89a2b..e7aed06698 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -75,6 +75,8 @@ lyx_SOURCES = \ bufferlist.h \ bufferparams.C \ bufferparams.h \ + bufferview_funcs.C \ + bufferview_funcs.h \ bullet_forms.C \ bullet_forms.h \ bullet_forms_cb.C \ diff --git a/src/buffer.C b/src/buffer.C index 98b052e1c6..0962a9a8d8 100644 --- a/src/buffer.C +++ b/src/buffer.C @@ -44,7 +44,8 @@ #include "lyxlex.h" #include "tex-strings.h" #include "layout.h" -#include "lyx_cb.h" +//#include "lyx_cb.h" +#include "bufferview_funcs.h" #include "minibuffer.h" #include "lyxfont.h" #include "version.h" @@ -118,8 +119,6 @@ static const float LYX_FORMAT = 2.16; extern int tex_code_break_column; -extern void FreeUpdateTimer(); - Buffer::Buffer(string const & file, bool ronly) { diff --git a/src/bufferlist.C b/src/bufferlist.C index c812f584e8..6fc5fbad24 100644 --- a/src/bufferlist.C +++ b/src/bufferlist.C @@ -31,6 +31,7 @@ #include "lyxrc.h" #include "lyxtext.h" #include "lyx_cb.h" +#include "bufferview_funcs.h" #include "gettext.h" #include "LyXView.h" #include "vc-backend.h" diff --git a/src/insets/figinset.C b/src/insets/figinset.C index ac649e70ff..454d9d5463 100644 --- a/src/insets/figinset.C +++ b/src/insets/figinset.C @@ -58,7 +58,8 @@ #include "support/lyxlib.h" #include "Painter.h" #include "font.h" -#include "lyx_cb.h" +//#include "lyx_cb.h" +#include "bufferview_funcs.h" using std::ostream; using std::istream; diff --git a/src/lyx_cb.C b/src/lyx_cb.C index 3bc8c6d426..f3e35bfe5b 100644 --- a/src/lyx_cb.C +++ b/src/lyx_cb.C @@ -15,45 +15,35 @@ #include #include "LString.h" -#include "support/lstrings.h" -#include "lyx_main.h" #include FORMS_H_LOCATION #include "lyx.h" #include "layout_forms.h" #include "bullet_forms.h" #include "print_form.h" #include "form1.h" -#include "spellchecker.h" -#include "version.h" +#include "lyx_main.h" #include "lyx_cb.h" -#include "credits.h" #include "insets/insetref.h" -#include "insets/insetquotes.h" #include "insets/insetlabel.h" #include "insets/figinset.h" #include "lyxfunc.h" -#include "latexoptions.h" -#include "lyxfont.h" #include "minibuffer.h" #include "combox.h" #include "bufferlist.h" -#include "support/filetools.h" -#include "support/path.h" #include "filedlg.h" #include "lyx_gui_misc.h" #include "LyXView.h" +#include "BufferView.h" #include "lastfiles.h" +#include "bufferview_funcs.h" #include "support/FileInfo.h" -#include "debug.h" #include "support/syscall.h" -#include "support/lyxlib.h" +#include "support/filetools.h" +#include "support/path.h" #include "lyxserver.h" #include "FontLoader.h" #include "lyxrc.h" #include "lyxtext.h" -#include "gettext.h" -#include "layout.h" -#include "language.h" #include "CutAndPaste.h" using std::ifstream; @@ -100,15 +90,6 @@ char ascii_type; /* for selection notify callbacks */ bool scrolling = false; -char updatetimer = 0; - -/* whether the work area should get callbacks */ -bool input_prohibited = false; - -/* the selection possible is needed, that only motion events are -* used, where the bottom press event was on the drawing area too */ -bool selection_possible = false; - // This is used to make the dreaded font toggle problem hopefully go // away. Definitely not the best solution, but I think it sorta works. bool toggleall = true; @@ -196,82 +177,12 @@ void ShowMessage(Buffer * buf, } } -// How should this actually work? Should it prohibit input in all BufferViews, -// or just in the current one? If "just the current one", then it should be -// placed in BufferView. If "all BufferViews" then LyXGUI (I think) should -// run "ProhibitInput" on all LyXViews which will run prohibitInput on all -// BufferViews. Or is it perhaps just the (input in) BufferViews in the -// current LyxView that should be prohibited (Lgb) (This applies to -// "AllowInput" as well.) -void ProhibitInput(BufferView * bv) -{ - input_prohibited = true; - bv->hideCursor(); - - static Cursor cursor; - static bool cursor_undefined = true; - - if (cursor_undefined){ - cursor = XCreateFontCursor(fl_display, XC_watch); - XFlush(fl_display); - cursor_undefined = false; - } - - /* set the cursor to the watch for all forms and the canvas */ - XDefineCursor(fl_display, bv->owner()->getForm()->window, - cursor); - if (fd_form_paragraph->form_paragraph->visible) - XDefineCursor(fl_display, - fd_form_paragraph->form_paragraph->window, - cursor); - if (fd_form_character->form_character->visible) - XDefineCursor(fl_display, - fd_form_character->form_character->window, - cursor); - - XFlush(fl_display); - fl_deactivate_all_forms(); -} - - -// Should find a way to move this into BufferView.C -void SetXtermCursor(Window win) -{ - static Cursor cursor; - static bool cursor_undefined = true; - if (cursor_undefined){ - cursor = XCreateFontCursor(fl_display, XC_xterm); - XFlush(fl_display); - cursor_undefined = false; - } - XDefineCursor(fl_display, win, cursor); - XFlush(fl_display); -} - -void AllowInput(BufferView * bv) -{ - input_prohibited = false; - - /* reset the cursor from the watch for all forms and the canvas */ - - XUndefineCursor(fl_display, bv->owner()->getForm()->window); - if (fd_form_paragraph->form_paragraph->visible) - XUndefineCursor(fl_display, - fd_form_paragraph->form_paragraph->window); - if (fd_form_character->form_character->visible) - XUndefineCursor(fl_display, - fd_form_character->form_character->window); - - // What to do about this? (Lgb) - if (bv->belowMouse()) - SetXtermCursor(bv->owner()->getForm()->window); - - XFlush(fl_display); - fl_activate_all_forms(); -} +// only called from this file, LyXView and LyXFunc +char updatetimer = 0; +// only called from BufferView_pimpl and LyXFunc void FreeUpdateTimer() { /* a real free timer would be better but I don't know @@ -280,6 +191,7 @@ void FreeUpdateTimer() } +// Only called from LyXFunc void SetUpdateTimer(float time) { fl_set_timer(current_view->owner()->getMainForm()->timer_update, time); @@ -806,6 +718,7 @@ bool AskOverwrite(Buffer * buffer, string const & s) return true; } + void MenuMakeLaTeX(Buffer * buffer) { // Why care about this? @@ -927,6 +840,7 @@ void MenuPrint(Buffer * buffer) } } + void MenuMakeHTML(Buffer * buffer) { // First, create LaTeX file @@ -956,6 +870,7 @@ void MenuMakeHTML(Buffer * buffer) } + void MenuMakeHTML_LinuxDoc(Buffer * buffer) { // First, create LinuxDoc file @@ -1007,6 +922,7 @@ void MenuMakeHTML_DocBook(Buffer * buffer) } + void MenuExport(Buffer * buffer, string const & extyp) { // latex @@ -1327,19 +1243,6 @@ void MenuPasteSelection(char at) } -// candidate for move to BufferView -void Foot(BufferView * bv) -{ - if (!bv->available()) - return; - - bv->owner()->getMiniBuffer() - ->Set(_("Inserting Footnote...")); - bv->hideCursor(); - bv->update(-2); - bv->text->InsertFootnoteEnvironment(LyXParagraph::FOOTNOTE); - bv->update(1); -} // candidate for move to LyXView @@ -2072,246 +1975,6 @@ void MenuLayoutSave() } -/* -------> These CB's use ToggleFree() as the (one and only?) font-changer. - They also show the current font state. */ - -static -void ToggleAndShow(BufferView *, LyXFont const &); - - -void FontSize(BufferView * bv, string const & size) -{ - LyXFont font(LyXFont::ALL_IGNORE); - font.setGUISize(size); - ToggleAndShow(bv, font); -} - - -void Emph(BufferView * bv) -{ - LyXFont font(LyXFont::ALL_IGNORE); - font.setEmph(LyXFont::TOGGLE); - ToggleAndShow(bv, font); -} - - -void Noun(BufferView * bv) -{ - LyXFont font(LyXFont::ALL_IGNORE); - font.setNoun(LyXFont::TOGGLE); - ToggleAndShow(bv, font); -} - - -void Bold(BufferView * bv) -{ - LyXFont font(LyXFont::ALL_IGNORE); - font.setSeries(LyXFont::BOLD_SERIES); - ToggleAndShow(bv, font); -} - - -void Underline(BufferView * bv) -{ - LyXFont font(LyXFont::ALL_IGNORE); - font.setUnderbar(LyXFont::TOGGLE); - ToggleAndShow(bv, font); -} - - -void Code(BufferView * bv) -{ - LyXFont font(LyXFont::ALL_IGNORE); - font.setFamily(LyXFont::TYPEWRITER_FAMILY); // no good - ToggleAndShow(bv, font); -} - - -void Sans(BufferView * bv) -{ - LyXFont font(LyXFont::ALL_IGNORE); - font.setFamily(LyXFont::SANS_FAMILY); - ToggleAndShow(bv, font); -} - - -void Roman(BufferView * bv) -{ - LyXFont font(LyXFont::ALL_IGNORE); - font.setFamily(LyXFont::ROMAN_FAMILY); - ToggleAndShow(bv, font); -} - - -void Tex(BufferView * bv) -{ - LyXFont font(LyXFont::ALL_IGNORE); - font.setLatex (LyXFont::TOGGLE); - ToggleAndShow(bv, font); -} - -void Lang(BufferView * bv, string const & l) -{ - LyXFont font(LyXFont::ALL_IGNORE); - Languages::iterator lit = languages.find(l); - if (lit != languages.end()) { - font.setLanguage(&(*lit).second); - ToggleAndShow(bv, font); - } else - WriteAlert(_("Error! unknown language"),l); -} - - -void StyleReset(BufferView * bv) -{ - LyXFont font(LyXFont::ALL_INHERIT, ignore_language); - ToggleAndShow(bv, font); -} - - -/* -------> Returns the current font and depth by printing a message. In the - * future perhaps we could try to implement a callback to the button-bar. - * That is, `light' the bold button when the font is currently bold, etc. - */ -string CurrentState(BufferView * bv) -{ - string state; - if (bv->available()) { - // I think we should only show changes from the default - // font. (Asger) - Buffer * buffer = bv->buffer(); - LyXFont font = bv->text->real_current_font; - LyXFont defaultfont = textclasslist.TextClass(buffer-> - params.textclass).defaultfont(); - font.reduce(defaultfont); - state = _("Font: ") + font.stateText(); - // The paragraph depth - int depth = bv->text->GetDepth(); - if (depth > 0) - state += string(_(", Depth: ")) + tostr(depth); - // The paragraph spacing, but only if different from - // buffer spacing. - if (!bv->text->cursor.par->spacing.isDefault()) { - Spacing::Space cur_space = - bv->text->cursor.par->spacing.getSpace(); - state += _(", Spacing: "); - switch (cur_space) { - case Spacing::Single: - state += _("Single"); - break; - case Spacing::Onehalf: - state += _("Onehalf"); - break; - case Spacing::Double: - state += _("Double"); - break; - case Spacing::Other: - state += _("Other ("); - state += tostr(bv->text->cursor.par->spacing.getValue()); - state += ")"; - break; - case Spacing::Default: - // should never happen, do nothing - break; - } - } - } - return state; -} - - - -// candidate for move to BufferView -/* -------> Does the actual toggle job of the XxxCB() calls above. - * Also shows the current font state. - */ -static -void ToggleAndShow(BufferView * bv, LyXFont const & font) -{ - if (bv->available()) { - bv->hideCursor(); - bv->update(-2); - if (bv->the_locking_inset) - bv->the_locking_inset->SetFont(bv, font, toggleall); - else - bv->text->ToggleFree(font, toggleall); - bv->update(1); - } -} - - -// candidate for move to BufferView -void Margin(BufferView * bv) -{ - if (bv->available()) { - bv->owner()->getMiniBuffer()->Set(_("Inserting margin note...")); - bv->hideCursor(); - bv->update(-2); - bv->text->InsertFootnoteEnvironment(LyXParagraph::MARGIN); - bv->update(1); - } -} - - -void Figure() -{ - if (fd_form_figure->form_figure->visible) { - fl_raise_form(fd_form_figure->form_figure); - } else { - fl_show_form(fd_form_figure->form_figure, - FL_PLACE_MOUSE, FL_FULLBORDER, - _("Insert Figure")); - } -} - - -void Table() -{ - 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_FULLBORDER, - _("Insert Table")); - } -} - - -// candidate for move to BufferView -void Melt(BufferView * bv) -{ - if (!bv->available()) return; - - bv->owner()->getMiniBuffer()->Set(_("Melt")); - bv->hideCursor(); - bv->beforeChange(); - bv->update(-2); - bv->text->MeltFootnoteEnvironment(); - bv->update(1); -} - - -// candidate for move to BufferView -// Change environment depth. -// if decInc >= 0, increment depth -// if decInc < 0, decrement depth -void changeDepth(BufferView * bv, int decInc) -{ - if (!bv->available()) return; - - bv->hideCursor(); - bv->update(-2); - if (decInc >= 0) - bv->text->IncDepth(); - else - bv->text->DecDepth(); - bv->update(1); - bv->owner()->getMiniBuffer() - ->Set(_("Changed environment depth" - " (in possible range, maybe not)")); -} - - // 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() @@ -2400,10 +2063,6 @@ LyXFont UserFreeFont() } -void Free(BufferView * bv) -{ - ToggleAndShow(bv, UserFreeFont()); -} /* callbacks for form form_title */ @@ -3253,6 +2912,30 @@ extern "C" void PrintOKCB(FL_OBJECT * ob, long data) } +void Figure() +{ + if (fd_form_figure->form_figure->visible) { + fl_raise_form(fd_form_figure->form_figure); + } else { + fl_show_form(fd_form_figure->form_figure, + FL_PLACE_MOUSE, FL_FULLBORDER, + _("Insert Figure")); + } +} + + +void Table() +{ + 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_FULLBORDER, + _("Insert Table")); + } +} + + /* callbacks for form form_figure */ extern "C" void FigureApplyCB(FL_OBJECT *, long) { diff --git a/src/lyx_cb.h b/src/lyx_cb.h index 4518af219a..295c80d4db 100644 --- a/src/lyx_cb.h +++ b/src/lyx_cb.h @@ -2,62 +2,14 @@ #ifndef LYX_CB_H #define LYX_CB_H -#include FORMS_H_LOCATION - -#include "LString.h" - -class Inset; -class BufferView; - /// extern bool quitting; +extern bool toggleall; // When still false after reading lyxrc, warn user //about failing \bind_file command. RVDK_PATCH_5 extern bool BindFileSet; - -/// -extern void Foot(BufferView *); -/// -extern void Emph(BufferView *); -/// -extern void Bold(BufferView *); -/// -extern void Noun(BufferView *); -/// -extern void Margin(BufferView *); -/// -extern void Figure(); -/// -extern void Lang(BufferView *, string const &); -/// -extern void Table(); -/// -extern void Melt(BufferView *); -/// -extern void Tex(BufferView *); -/// -extern void changeDepth(BufferView *, int); -/// -extern void Free(BufferView *); -/// -extern void ProhibitInput(BufferView *); -/// -extern void AllowInput(BufferView *); -/// -extern void Code(BufferView *); -/// -extern void Sans(BufferView *); -/// -extern void Roman(BufferView *); -/// -extern void StyleReset(BufferView *); -/// -extern void Underline(BufferView *); -/// -extern void FontSize(BufferView *, string const &); -/// -extern string CurrentState(BufferView *); +extern LyXFont UserFreeFont(); #endif diff --git a/src/lyx_gui_misc.C b/src/lyx_gui_misc.C index 34da9d32d5..4cca2189b7 100644 --- a/src/lyx_gui_misc.C +++ b/src/lyx_gui_misc.C @@ -31,6 +31,7 @@ #include "sp_form.h" #include "insets/insetindex.h" #include "LyXView.h" +#include "bufferview_funcs.h" using std::pair; using std::make_pair; diff --git a/src/lyxfont.C b/src/lyxfont.C index 563e3bb8c5..6cd7f8f816 100644 --- a/src/lyxfont.C +++ b/src/lyxfont.C @@ -412,7 +412,7 @@ string LyXFont::stateText() const //if (buf.empty()) // ost << _("Default"); unsigned int opos = ost.tellp(); - lyxerr << "Opos: " << opos << endl; + //lyxerr << "Opos: " << opos << endl; if (opos == 0) ost << _("Default") << ", "; ost << _("Language: ") << _(language()->display.c_str()); diff --git a/src/lyxfunc.C b/src/lyxfunc.C index 66c4179746..f6c3a19ac2 100644 --- a/src/lyxfunc.C +++ b/src/lyxfunc.C @@ -78,6 +78,7 @@ using std::istringstream; #include "WorkArea.h" #include "lyxfr1.h" #include "menus.h" +#include "bufferview_funcs.h" using std::pair; using std::endl; @@ -1956,14 +1957,19 @@ string LyXFunc::Dispatch(int ac, cur_value = par->spacing.getValue(); } - lyxerr << "all spacing arguments: " << argument << endl; +#ifdef HAVE_SSTREAM istringstream istr(argument); +#else + istrstream istr(argument.c_str()); +#endif string tmp; istr >> tmp; - lyxerr << "spacing = " << tmp << endl; Spacing::Space new_spacing = cur_spacing; float new_value = cur_value; - if (tmp == "single") { + if (tmp.empty()) { + lyxerr << "Missing argument to `paragraph-spacing'" + << endl; + } else if (tmp == "single") { new_spacing = Spacing::Single; } else if (tmp == "onehalf") { new_spacing = Spacing::Onehalf; diff --git a/src/menus.C b/src/menus.C index e75268ddcf..951627bdfb 100644 --- a/src/menus.C +++ b/src/menus.C @@ -45,6 +45,7 @@ #include "gettext.h" #include "layout.h" #include "lyx_cb.h" +#include "bufferview_funcs.h" using std::vector; using std::endl; diff --git a/src/paragraph.C b/src/paragraph.C index 5825ed1d96..7e869d7872 100644 --- a/src/paragraph.C +++ b/src/paragraph.C @@ -520,8 +520,8 @@ LyXParagraph::~LyXParagraph() // ale970302 delete bibkey; // - lyxerr << "LyXParagraph::paragraph_id = " - << LyXParagraph::paragraph_id << endl; + //lyxerr << "LyXParagraph::paragraph_id = " + // << LyXParagraph::paragraph_id << endl; } diff --git a/src/text.C b/src/text.C index e9a8a818fe..b80439d71a 100644 --- a/src/text.C +++ b/src/text.C @@ -1273,7 +1273,7 @@ void LyXText::SetHeightOfRow(Row * row_ptr) const } else { spacing_val = bparams->spacing.getValue(); } - lyxerr << "spacing_val = " << spacing_val << endl; + //lyxerr << "spacing_val = " << spacing_val << endl; int maxasc = int(lyxfont::maxAscent(font) * layout.spacing.getValue() *