From: Lars Gullik Bjønnes Date: Sat, 4 Nov 2000 10:00:12 +0000 (+0000) Subject: some formatting changes some simplifications and removal of dead code X-Git-Tag: 1.6.10~21838 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=adaef99e60e28eba8c413a3472cc71e234718af0;p=features.git some formatting changes some simplifications and removal of dead code git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1198 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/ChangeLog b/ChangeLog index 76a64e26c0..dccc44daf8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,24 @@ +2000-11-04 Lars Gullik Bjønnes + + * src/frontends/xforms/FormPreferences.h (operator=): move out of RGB + (operator!): ditto + + * src/frontends/xforms/FormPreferences.C (WriteableFile): simplify + the use of FileInfo + + * src/lyxfunc.C (processKeyEvent): removed + + * src/bufferlist.C (emergencyWrite): removed the out commented + emergency write code. + + * src/Makefile.am (lyx_main.o): add dep for commandtags.h + + * src/LyXView.[Ch]: remove the outcommented raw_callback code + + * many files: change formatting to be a bit more uniform for + if,while,for,switch statements, remove some parantesis not needed. + + 2000-11-03 John Levon * config/kde.m4: make config more robust when KDEDIR is set diff --git a/src/BufferView2.C b/src/BufferView2.C index 5fe3075ef1..606f2044e5 100644 --- a/src/BufferView2.C +++ b/src/BufferView2.C @@ -285,7 +285,7 @@ bool BufferView::gotoLabel(string const & label) for (Buffer::inset_iterator it = buffer()->inset_iterator_begin(); it != buffer()->inset_iterator_end(); ++it) { vector labels = (*it)->getLabelList(); - if ( find(labels.begin(),labels.end(),label) + if (find(labels.begin(),labels.end(),label) != labels.end()) { beforeChange(); text->SetCursor(this, it.getPar(), it.getPos()); diff --git a/src/BufferView_pimpl.C b/src/BufferView_pimpl.C index a896c75edf..a649f64eea 100644 --- a/src/BufferView_pimpl.C +++ b/src/BufferView_pimpl.C @@ -432,12 +432,12 @@ void BufferView::Pimpl::scrollCB(double value) LyXText * vbt = bv_->text; int height = vbt->DefaultHeight(); - if (vbt->cursor.y() < (int)(bv_->text->first + height)) { + if (vbt->cursor.y() < static_cast((bv_->text->first + height))) { vbt->SetCursorFromCoordinates(bv_, 0, bv_->text->first + height); } else if (vbt->cursor.y() > - (int)(bv_->text->first+workarea_->height()-height)) + static_cast((bv_->text->first+workarea_->height()-height))) { vbt->SetCursorFromCoordinates(bv_, 0, bv_->text->first + @@ -1221,11 +1221,11 @@ void BufferView::Pimpl::restorePosition() beforeChange(); - if( fname != buffer_->fileName() ) { + if (fname != buffer_->fileName()) { Buffer * b = bufferlist.exists(fname) ? bufferlist.getBuffer(fname) : bufferlist.loadLyXFile(fname); // don't ask, just load it - if( b != 0 ) buffer(b); + if (b != 0 ) buffer(b); } bv_->text->SetCursorFromCoordinates(bv_, x, y); @@ -1341,7 +1341,7 @@ void BufferView::Pimpl::toggleToggle() void BufferView::Pimpl::center() { beforeChange(); - if (bv_->text->cursor.y() > (int)(workarea_->height() / 2)) { + if (bv_->text->cursor.y() > static_cast((workarea_->height() / 2))) { screen_->Draw(bv_->text, bv_->text->cursor.y() - workarea_->height() / 2); } else { screen_->Draw(bv_->text, 0); diff --git a/src/ColorHandler.C b/src/ColorHandler.C index f3be43ba7d..56835fffe1 100644 --- a/src/ColorHandler.C +++ b/src/ColorHandler.C @@ -105,7 +105,7 @@ GC LyXColorHandler::getGCForeground(LColor::color c) XColor * cmap = new XColor[vi->map_entries]; - for(int i = 0; i < vi->map_entries; ++i) { + for (int i = 0; i < vi->map_entries; ++i) { cmap[i].pixel = i; } XQueryColors(display, colormap, cmap, vi->map_entries); @@ -114,7 +114,7 @@ GC LyXColorHandler::getGCForeground(LColor::color c) int closest_pixel = 0; double closest_distance = 1e20; // we want to minimize this double distance = 0; - for(int t = 0; t < vi->map_entries; ++t) { + for (int t = 0; t < vi->map_entries; ++t) { // The Euclidean distance between two points in // a three-dimensional space, the RGB color-cube, // is used as the distance measurement between two diff --git a/src/CutAndPaste.C b/src/CutAndPaste.C index 6687504150..da51fb0ac6 100644 --- a/src/CutAndPaste.C +++ b/src/CutAndPaste.C @@ -85,7 +85,7 @@ bool CutAndPaste::cutSelection(LyXParagraph * startpar, LyXParagraph ** endpar, #else (startpar == (*endpar)) #endif - ) { + ) { // only within one paragraph buf = new LyXParagraph; LyXParagraph::size_type i = start; @@ -181,7 +181,7 @@ bool CutAndPaste::copySelection(LyXParagraph * startpar, LyXParagraph * endpar, #else (startpar == endpar) #endif - ) { + ) { // only within one paragraph buf = new LyXParagraph; LyXParagraph::size_type i = start; diff --git a/src/DepTable.C b/src/DepTable.C index 8af0420aaf..e493d794aa 100644 --- a/src/DepTable.C +++ b/src/DepTable.C @@ -46,7 +46,7 @@ void DepTable::insert(string const & fi, void DepTable::update() { - for(DepList::iterator itr = deplist.begin(); + for (DepList::iterator itr = deplist.begin(); itr != deplist.end(); ++itr) { unsigned long const one = (*itr).second.second; diff --git a/src/FontInfo.C b/src/FontInfo.C index db2b5b6e9a..a9117e6f94 100644 --- a/src/FontInfo.C +++ b/src/FontInfo.C @@ -128,7 +128,7 @@ void FontInfo::query() strings = new string[matches]; // We have matches. Run them through - for(int i = 0; i < matches; ++i) { + for (int i = 0; i < matches; ++i) { string name(list[i]); sizes[i] = lyx::atoi(token(name, '-', 7)); strings[i] = name; diff --git a/src/LyXView.C b/src/LyXView.C index 292a2581a5..850fa02af1 100644 --- a/src/LyXView.C +++ b/src/LyXView.C @@ -302,12 +302,6 @@ void LyXView::create_form_form_main(int width, int height) } -#if 0 -extern "C" -int C_LyXView_KeyPressMask_raw_callback(FL_FORM * fl, void * xev); -#endif - - void LyXView::init() { // Set the textclass choice @@ -321,12 +315,6 @@ void LyXView::init() autosave_timeout.start(); } -#if 0 - // Install the raw callback for keyboard events - fl_register_raw_callback(form_, - KeyPressMask, - C_LyXView_KeyPressMask_raw_callback); -#endif intl->InitKeyMapper(lyxrc.use_kbmap); } @@ -366,71 +354,6 @@ void LyXView::updateLayoutChoice() } -#if 0 -// This is necessary, since FL_FREE-Objects doesn't get all keypress events -// as FL_KEYBOARD events :-( Matthias 280596 -int LyXView::KeyPressMask_raw_callback(FL_FORM * fl, void * xev) -{ - LyXView * view = static_cast(fl->u_vdata); - int retval = 0; // 0 means XForms should have a look at this event - - XKeyEvent * xke = static_cast(xev); - static Time last_time_pressed = 0; - static Time last_time_released = 0; - static unsigned int last_key_pressed = 0; - static unsigned int last_key_released = 0; - static unsigned int last_state_pressed = 0; - static unsigned int last_state_released = 0; - - // funny. Even though the raw_callback is registered with KeyPressMask, - // also KeyRelease-events are passed through:-( - // [It seems that XForms puts them in pairs... (JMarc)] - if (static_cast(xev)->type == KeyPress - && view->bufferview->focus() - && view->bufferview->active()) - { - last_time_pressed = xke->time; - last_key_pressed = xke->keycode; - last_state_pressed = xke->state; - retval = view->getLyXFunc() - ->processKeyEvent(static_cast(xev)); - } - else if (static_cast(xev)->type == KeyRelease - && view->bufferview->focus() - && view->bufferview->active()) -{ - last_time_released = xke->time; - last_key_released = xke->keycode; - last_state_released = xke->state; - } - - if (last_key_released == last_key_pressed - && last_state_released == last_state_pressed - && last_time_released == last_time_pressed) { - // When the diff between last_time_released and - // last_time_pressed is 0, that sinifies an autoreapeat - // at least on my system. It like some feedback from - // others, especially from user running LyX remote. - lyxerr[Debug::KEY] << "Syncing - purging X events." << endl; - XSync(fl_get_display(), 1); - // This purge make f.ex. scrolling stop imidiatly when - // releaseing the PageDown button. The question is if this - // purging of XEvents can cause any harm...after some testing - // I can see no problems, but I'd like other reports too. - } - return retval; -} - - -// wrapper for the above -extern "C" -int C_LyXView_KeyPressMask_raw_callback(FL_FORM * fl, void * xev) -{ - return LyXView::KeyPressMask_raw_callback(fl, xev); -} -#endif - - // Updates the title of the window with the filename of the current document void LyXView::updateWindowTitle() { diff --git a/src/LyXView.h b/src/LyXView.h index 5ce2b4efff..8017453af5 100644 --- a/src/LyXView.h +++ b/src/LyXView.h @@ -133,10 +133,6 @@ private: /// void invalidateLayoutChoice(); public: -#if 0 - /// - static int KeyPressMask_raw_callback(FL_FORM *, void * xev); -#endif /** This callback is run when a close event is sent from the window manager. */ static int atCloseMainFormCB(FL_FORM *, void *); diff --git a/src/Makefile.am b/src/Makefile.am index 6aa2482969..98747463dd 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -228,7 +228,7 @@ lyx_SOURCES = \ lyx_main.o: lyx_main.C lyx_main.h config.h version.h lyx_gui.h \ lyx_gui_misc.h lyxrc.h support/path.h support/filetools.h \ bufferlist.h debug.h support/FileInfo.h lastfiles.h intl.h \ - lyxserver.h layout.h gettext.h kbmap.h + lyxserver.h layout.h gettext.h kbmap.h commandtags.h $(CXXCOMPILE) -DLYX_DIR=\"$(pkgdatadir)\" \ -DTOP_SRCDIR=\"$(top_srcdir)\" -c $(top_srcdir)/src/lyx_main.C diff --git a/src/MenuBackend.C b/src/MenuBackend.C index 0289bf8928..18d39b90b8 100644 --- a/src/MenuBackend.C +++ b/src/MenuBackend.C @@ -46,7 +46,7 @@ MenuItem::MenuItem(Kind kind, string const & label, string const & command, bool optional) : kind_(kind), label_(label), optional_(optional) { - switch(kind) { + switch (kind) { case Separator: case Documents: case Lastfiles: @@ -122,7 +122,7 @@ Menu & Menu::read(LyXLex & lex) bool optional = false; while (lex.IsOK() && !quit) { - switch(lex.lex()) { + switch (lex.lex()) { case md_optitem: optional = true; // fallback to md_item @@ -351,7 +351,7 @@ void MenuBackend::read(LyXLex & lex) bool menubar = false; while (lex.IsOK() && !quit) { - switch(lex.lex()) { + switch (lex.lex()) { case md_menubar: menubar = true; // fallback to md_menu @@ -436,7 +436,7 @@ void MenuBackend::defaults() add(main_nobuffer); if (lyxerr.debugging(Debug::GUI)) { - for(const_iterator cit = begin(); + for (const_iterator cit = begin(); cit != end() ; ++cit) lyxerr << "Menu name: " << cit->name() << ", Menubar: " << cit->menubar() diff --git a/src/Painter.C b/src/Painter.C index 94943ff957..30675e07c7 100644 --- a/src/Painter.C +++ b/src/Painter.C @@ -319,7 +319,7 @@ PainterBase & Painter::text(int x, int y, char const * s, size_t ls, smallfont.decSize().decSize().setShape(LyXFont::UP_SHAPE); char c; int tmpx = x; - for(size_t i = 0; i < ls; ++i) { + for (size_t i = 0; i < ls; ++i) { c = s[i]; if (islower(static_cast(c))) { c = toupper(c); @@ -359,7 +359,7 @@ PainterBase & Painter::text(int x, int y, XChar2b const * s, int ls, smallfont.decSize().decSize().setShape(LyXFont::UP_SHAPE); static XChar2b c = {0, 0}; int tmpx = x; - for(int i = 0; i < ls; ++i) { + for (int i = 0; i < ls; ++i) { if (s[i].byte1 == 0 && islower(s[i].byte2)) { c.byte2 = toupper(s[i].byte2); lyxfont::XSetFont(display, gc, smallfont); diff --git a/src/Spacing.C b/src/Spacing.C index 6014dea5cb..b80f55ffb1 100644 --- a/src/Spacing.C +++ b/src/Spacing.C @@ -28,7 +28,7 @@ char const * spacing_string[] = {"single", "onehalf", "double", "other"}; float Spacing::getValue() const { - switch(space) { + switch (space) { case Default: // nothing special should happen with this... case Single: return 1.0; case Onehalf: return 1.25; @@ -43,7 +43,7 @@ void Spacing::set(Spacing::Space sp, float val) { space = sp; if (sp == Other) { - switch(int(val * 1000 + 0.5)) { + switch (int(val * 1000 + 0.5)) { case 1000: space = Single; break; case 1250: space = Onehalf; break; case 1667: space = Double; break; @@ -81,7 +81,7 @@ void Spacing::writeFile(ostream & os, bool para) const string const Spacing::writeEnvirBegin() const { - switch(space) { + switch (space) { case Default: break; // do nothing case Single: return "\\begin{singlespace}"; @@ -103,7 +103,7 @@ string const Spacing::writeEnvirBegin() const string const Spacing::writeEnvirEnd() const { - switch(space) { + switch (space) { case Default: break; // do nothing case Single: return "\\end{singlespace}"; diff --git a/src/ToolbarDefaults.C b/src/ToolbarDefaults.C index 9e42b8c67b..c827c598e3 100644 --- a/src/ToolbarDefaults.C +++ b/src/ToolbarDefaults.C @@ -118,7 +118,7 @@ void ToolbarDefaults::read(LyXLex & lex) while (lex.IsOK() && !quit) { - switch(lex.lex()) { + switch (lex.lex()) { case TO_ADD: if (lex.next()) { func = lex.GetString(); diff --git a/src/bmtable.c b/src/bmtable.c index 60fba834d3..b0b6369457 100644 --- a/src/bmtable.c +++ b/src/bmtable.c @@ -298,7 +298,7 @@ void fl_set_bmtable_file(FL_OBJECT * ob, int nx, int ny, char const * filename) unsigned int bw, bh; unsigned char * bdata; - if(XReadBitmapFileData(filename, &bw, &bh, + if (XReadBitmapFileData(filename, &bw, &bh, &bdata, &xh, &yh) == BitmapSuccess) fl_set_bmtable_data(ob, nx, ny, bw, bh, bdata); XFlush(fl_get_display()); diff --git a/src/buffer.C b/src/buffer.C index ff79a73d82..152f7de180 100644 --- a/src/buffer.C +++ b/src/buffer.C @@ -254,7 +254,7 @@ bool Buffer::readLyXformat2(LyXLex & lex, LyXParagraph * par) bool has_token = false; string pretoken; - if(!par) { + if (!par) { par = new LyXParagraph; } else { users->text->BreakParagraph(users); @@ -550,7 +550,7 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, LyXParagraph *& par, if (tmpret != LYX_LAYOUT_DEFAULT) { InsetQuotes::quote_language tmpl = InsetQuotes::EnglishQ; - switch(tmpret) { + switch (tmpret) { case 0: tmpl = InsetQuotes::EnglishQ; break; @@ -574,7 +574,7 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, LyXParagraph *& par, } } else if (token == "\\quotes_times") { lex.nextToken(); - switch(lex.GetInteger()) { + switch (lex.GetInteger()) { case 1: params.quotes_times = InsetQuotes::SingleQ; break; @@ -641,7 +641,7 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, LyXParagraph *& par, params.columns = lex.GetInteger(); } else if (token == "\\papersides") { lex.nextToken(); - switch(lex.GetInteger()) { + switch (lex.GetInteger()) { default: case 1: params.sides = LyXTextClass::OneSide; break; case 2: params.sides = LyXTextClass::TwoSides; break; @@ -921,7 +921,7 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, LyXParagraph *& par, "Inserting as text."); string::const_iterator cit = token.begin(); string::const_iterator end = token.end(); - for(; cit != end; ++cit) { + for (; cit != end; ++cit) { par->InsertChar(pos, (*cit), font); ++pos; } @@ -1389,10 +1389,10 @@ void Buffer::writeFileAscii(string const & fname, int linelen) for (i = 0, actpos = 1; i < par->size(); ++i, ++actpos) { if (!i && !footnoteflag && !noparbreak){ ofs << "\n\n"; - for(j = 0; j < depth; ++j) + for (j = 0; j < depth; ++j) ofs << " "; currlinelen = depth * 2; - switch(ltype) { + switch (ltype) { case 0: /* Standard */ case 4: /* (Sub)Paragraph */ case 5: /* Description */ @@ -1411,7 +1411,7 @@ void Buffer::writeFileAscii(string const & fname, int linelen) break; } if (ltype_depth > depth) { - for(j = ltype_depth - 1; j > depth; --j) + for (j = ltype_depth - 1; j > depth; --j) ofs << " "; currlinelen += (ltype_depth-depth)*2; } @@ -1439,11 +1439,11 @@ void Buffer::writeFileAscii(string const & fname, int linelen) break; case LyXParagraph::META_NEWLINE: ofs << "\n"; - for(j = 0; j < depth; ++j) + for (j = 0; j < depth; ++j) ofs << " "; currlinelen = depth * 2; if (ltype_depth > depth) { - for(j = ltype_depth; + for (j = ltype_depth; j > depth; --j) ofs << " "; currlinelen += (ltype_depth - depth) * 2; @@ -1459,11 +1459,11 @@ void Buffer::writeFileAscii(string const & fname, int linelen) if (currlinelen > linelen - 10 && c == ' ' && i + 2 < par->size()) { ofs << "\n"; - for(j = 0; j < depth; ++j) + for (j = 0; j < depth; ++j) ofs << " "; currlinelen = depth * 2; if (ltype_depth > depth) { - for(j = ltype_depth; + for (j = ltype_depth; j > depth; --j) ofs << " "; currlinelen += (ltype_depth-depth)*2; @@ -1597,10 +1597,10 @@ string const Buffer::asciiParagraph(LyXParagraph const * par, if (!i && !footnoteflag && !noparbreak){ if (linelen > 0) buffer << "\n\n"; - for(char j = 0; j < depth; ++j) + for (char j = 0; j < depth; ++j) buffer << " "; currlinelen = depth * 2; - switch(ltype) { + switch (ltype) { case 0: /* Standard */ case 4: /* (Sub)Paragraph */ case 5: /* Description */ @@ -1625,7 +1625,7 @@ string const Buffer::asciiParagraph(LyXParagraph const * par, break; } if (ltype_depth > depth) { - for(char j = ltype_depth - 1; j > depth; --j) + for (char j = ltype_depth - 1; j > depth; --j) buffer << " "; currlinelen += (ltype_depth-depth)*2; } @@ -1659,12 +1659,12 @@ string const Buffer::asciiParagraph(LyXParagraph const * par, case LyXParagraph::META_NEWLINE: if (linelen > 0) { buffer << "\n"; - for(char j = 0; j < depth; ++j) + for (char j = 0; j < depth; ++j) buffer << " "; } currlinelen = depth * 2; if (ltype_depth > depth) { - for(char j = ltype_depth; + for (char j = ltype_depth; j > depth; --j) buffer << " "; currlinelen += (ltype_depth - depth) * 2; @@ -1681,11 +1681,11 @@ string const Buffer::asciiParagraph(LyXParagraph const * par, (c == ' ') && ((i + 2) < par->size())) { buffer << "\n"; - for(char j = 0; j < depth; ++j) + for (char j = 0; j < depth; ++j) buffer << " "; currlinelen = depth * 2; if (ltype_depth > depth) { - for(char j = ltype_depth; + for (char j = ltype_depth; j > depth; --j) buffer << " "; currlinelen += (ltype_depth-depth)*2; @@ -1856,7 +1856,7 @@ void Buffer::makeLaTeXFile(string const & fname, features.UsedLanguages.insert(default_language); #ifdef DO_USE_DEFAULT_LANGUAGE if (params.language->lang() != "default" || - !features.UsedLanguages.empty() ) { + !features.UsedLanguages.empty()) { #endif use_babel = true; for (LaTeXFeatures::LanguageList::const_iterator cit = @@ -2372,7 +2372,7 @@ void Buffer::makeLinuxDocFile(string const & fname, bool nice, bool body_only) LaTeXFeatures features(params, tclass.numLayouts()); validate(features); - //if(nice) + //if (nice) tex_code_break_column = lyxrc.ascii_linelen; //else //tex_code_break_column = 0; @@ -2389,7 +2389,7 @@ void Buffer::makeLinuxDocFile(string const & fname, bool nice, bool body_only) << params.preamble << sgml_includedfiles << " \n]>\n\n"; } - if(params.options.empty()) + if (params.options.empty()) sgmlOpenTag(ofs, 0, top_element); else { string top = top_element; @@ -2434,11 +2434,11 @@ void Buffer::makeLinuxDocFile(string const & fname, bool nice, bool body_only) // write opening SGML tags switch (style.latextype) { case LATEX_PARAGRAPH: - if(depth == par->depth + if (depth == par->depth && !environment_stack[depth].empty()) { sgmlCloseTag(ofs, depth, environment_stack[depth]); environment_stack[depth].erase(); - if(depth) + if (depth) --depth; else ofs << "

"; @@ -2477,7 +2477,7 @@ void Buffer::makeLinuxDocFile(string const & fname, bool nice, bool body_only) environment_stack[depth].erase(); } if (environment_stack[depth] != style.latexname()) { - if(depth == 0) { + if (depth == 0) { string const temp = "p"; sgmlOpenTag(ofs, depth, temp); } @@ -2485,11 +2485,11 @@ void Buffer::makeLinuxDocFile(string const & fname, bool nice, bool body_only) sgmlOpenTag(ofs, depth, environment_stack[depth]); } - if(style.latextype == LATEX_ENVIRONMENT) break; + if (style.latextype == LATEX_ENVIRONMENT) break; desc_on = (style.labeltype == LABEL_MANUAL); - if(desc_on) + if (desc_on) item_name = "tag"; else item_name = "item"; @@ -2515,7 +2515,7 @@ void Buffer::makeLinuxDocFile(string const & fname, bool nice, bool body_only) ofs << "\n"; // write closing SGML tags - switch(style.latextype) { + switch (style.latextype) { case LATEX_COMMAND: case LATEX_ENVIRONMENT: case LATEX_ITEM_ENVIRONMENT: @@ -2527,10 +2527,10 @@ void Buffer::makeLinuxDocFile(string const & fname, bool nice, bool body_only) } // Close open tags - for(; depth > 0; --depth) + for (; depth > 0; --depth) sgmlCloseTag(ofs, depth, environment_stack[depth]); - if(!environment_stack[depth].empty()) + if (!environment_stack[depth].empty()) sgmlCloseTag(ofs, depth, environment_stack[depth]); if (!body_only) { @@ -2579,7 +2579,7 @@ void Buffer::DocBookHandleCaption(ostream & os, string & inner_tag, SimpleDocBookOnePar(os, extra_par, tpar, desc_on, depth + 2); sgmlCloseTag(os, depth+1, inner_tag); - if(!extra_par.empty()) + if (!extra_par.empty()) os << extra_par; } } @@ -2678,9 +2678,9 @@ void Buffer::DocBookHandleFootnote(ostream & os, LyXParagraph * & par, par = par->next; } os << tmp_par; - if(!inner_tag.empty()) sgmlCloseTag(os, depth + 1, inner_tag); - if(!extra_par.empty()) os << extra_par; - if(!tag.empty()) sgmlCloseTag(os, depth, tag); + if (!inner_tag.empty()) sgmlCloseTag(os, depth + 1, inner_tag); + if (!extra_par.empty()) os << extra_par; + if (!tag.empty()) sgmlCloseTag(os, depth, tag); } #endif @@ -2797,7 +2797,7 @@ void Buffer::SimpleLinuxDocOnePar(ostream & os, LyXParagraph * par, LyXFont const font2 = par->getFont(params, i); if (font1.family() != font2.family()) { - switch(family_type) { + switch (family_type) { case 0: if (font2.family() == LyXFont::TYPEWRITER_FAMILY) { push_tag(os, "tt", stack_num, stack); @@ -2841,7 +2841,7 @@ void Buffer::SimpleLinuxDocOnePar(ostream & os, LyXParagraph * par, // handle italic and slanted fonts if (font1.shape() != font2.shape()) { - switch(shape_type) { + switch (shape_type) { case 0: if (font2.shape() == LyXFont::ITALIC_SHAPE) { push_tag(os, "it", stack_num, stack); @@ -2931,7 +2931,7 @@ void Buffer::SimpleLinuxDocOnePar(ostream & os, LyXParagraph * par, } // resets description flag correctly - switch(desc_on){ + switch (desc_on){ case 1: // not closed... linux_doc_line_break(os, char_line_count, 6); @@ -2986,7 +2986,7 @@ void Buffer::makeDocBookFile(string const & fname, bool nice, bool only_body) LaTeXFeatures features(params, tclass.numLayouts()); validate(features); - //if(nice) + //if (nice) tex_code_break_column = lyxrc.ascii_linelen; //else //tex_code_break_column = 0; @@ -2999,7 +2999,7 @@ void Buffer::makeDocBookFile(string const & fname, bool nice, bool only_body) texrow.reset(); - if(!only_body) { + if (!only_body) { string sgml_includedfiles=features.getIncludedFiles(); ofs << "\n\n"; - if(params.options.empty()) + if (params.options.empty()) sgmlOpenTag(ofs, 0, top_element); else { string top = top_element; @@ -3031,12 +3031,12 @@ void Buffer::makeDocBookFile(string const & fname, bool nice, bool only_body) par->layout); // environment tag closing - for( ; depth > par->depth; --depth) { - if(environment_inner[depth] != "!-- --") { + for (; depth > par->depth; --depth) { + if (environment_inner[depth] != "!-- --") { item_name= "listitem"; sgmlCloseTag(ofs, command_depth + depth, item_name); - if( environment_inner[depth] == "varlistentry") + if (environment_inner[depth] == "varlistentry") sgmlCloseTag(ofs, depth+command_depth, environment_inner[depth]); } @@ -3046,14 +3046,14 @@ void Buffer::makeDocBookFile(string const & fname, bool nice, bool only_body) environment_inner[depth].erase(); } - if(depth == par->depth + if (depth == par->depth && environment_stack[depth] != style.latexname() && !environment_stack[depth].empty()) { - if(environment_inner[depth] != "!-- --") { + if (environment_inner[depth] != "!-- --") { item_name= "listitem"; sgmlCloseTag(ofs, command_depth+depth, item_name); - if( environment_inner[depth] == "varlistentry") + if (environment_inner[depth] == "varlistentry") sgmlCloseTag(ofs, depth + command_depth, environment_inner[depth]); @@ -3067,9 +3067,9 @@ void Buffer::makeDocBookFile(string const & fname, bool nice, bool only_body) } // Write opening SGML tags. - switch(style.latextype) { + switch (style.latextype) { case LATEX_PARAGRAPH: - if(style.latexname() != "dummy") + if (style.latexname() != "dummy") sgmlOpenTag(ofs, depth+command_depth, style.latexname()); break; @@ -3087,18 +3087,18 @@ void Buffer::makeDocBookFile(string const & fname, bool nice, bool only_body) cmd_depth= lyx::atoi(c_depth); - if(command_flag) { - if(cmd_depth= command_base; --j) - if(!command_stack[j].empty()) + if (!command_stack[j].empty()) sgmlCloseTag(ofs, j, command_stack[j]); command_depth= command_base= cmd_depth; - } else if(cmd_depth <= command_depth) { - for(int j = command_depth; + } else if (cmd_depth <= command_depth) { + for (int j = command_depth; j >= cmd_depth; --j) - if(!command_stack[j].empty()) + if (!command_stack[j].empty()) sgmlCloseTag(ofs, j, command_stack[j]); command_depth= cmd_depth; } else @@ -3140,7 +3140,7 @@ void Buffer::makeDocBookFile(string const & fname, bool nice, bool only_body) sgmlOpenTag(ofs, depth + command_depth, environment_stack[depth]); } else { - if(environment_inner[depth] != "!-- --") { + if (environment_inner[depth] != "!-- --") { item_name= "listitem"; sgmlCloseTag(ofs, command_depth + depth, @@ -3152,8 +3152,8 @@ void Buffer::makeDocBookFile(string const & fname, bool nice, bool only_body) } } - if(style.latextype == LATEX_ENVIRONMENT) { - if(!style.latexparam().empty()) + if (style.latextype == LATEX_ENVIRONMENT) { + if (!style.latexparam().empty()) sgmlOpenTag(ofs, depth + command_depth, style.latexparam()); break; @@ -3161,7 +3161,7 @@ void Buffer::makeDocBookFile(string const & fname, bool nice, bool only_body) desc_on = (style.labeltype == LABEL_MANUAL); - if(desc_on) + if (desc_on) environment_inner[depth]= "varlistentry"; else environment_inner[depth]= "listitem"; @@ -3169,7 +3169,7 @@ void Buffer::makeDocBookFile(string const & fname, bool nice, bool only_body) sgmlOpenTag(ofs, depth + 1 + command_depth, environment_inner[depth]); - if(desc_on) { + if (desc_on) { item_name= "term"; sgmlOpenTag(ofs, depth + 1 + command_depth, item_name); @@ -3200,23 +3200,23 @@ void Buffer::makeDocBookFile(string const & fname, bool nice, bool only_body) #endif string end_tag; // write closing SGML tags - switch(style.latextype) { + switch (style.latextype) { case LATEX_COMMAND: end_tag = "title"; sgmlCloseTag(ofs, depth + command_depth, end_tag); break; case LATEX_ENVIRONMENT: - if(!style.latexparam().empty()) + if (!style.latexparam().empty()) sgmlCloseTag(ofs, depth + command_depth, style.latexparam()); break; case LATEX_ITEM_ENVIRONMENT: - if(desc_on == 1) break; + if (desc_on == 1) break; end_tag= "para"; sgmlCloseTag(ofs, depth + 1 + command_depth, end_tag); break; case LATEX_PARAGRAPH: - if(style.latexname() != "dummy") + if (style.latexname() != "dummy") sgmlCloseTag(ofs, depth + command_depth, style.latexname()); break; @@ -3228,13 +3228,13 @@ void Buffer::makeDocBookFile(string const & fname, bool nice, bool only_body) } // Close open tags - for(; depth >= 0; --depth) { - if(!environment_stack[depth].empty()) { - if(environment_inner[depth] != "!-- --") { + for (; depth >= 0; --depth) { + if (!environment_stack[depth].empty()) { + if (environment_inner[depth] != "!-- --") { item_name= "listitem"; sgmlCloseTag(ofs, command_depth + depth, item_name); - if( environment_inner[depth] == "varlistentry") + if (environment_inner[depth] == "varlistentry") sgmlCloseTag(ofs, depth + command_depth, environment_inner[depth]); } @@ -3244,8 +3244,8 @@ void Buffer::makeDocBookFile(string const & fname, bool nice, bool only_body) } } - for(int j = command_depth; j >= command_base; --j) - if(!command_stack[j].empty()) + for (int j = command_depth; j >= command_base; --j) + if (!command_stack[j].empty()) sgmlCloseTag(ofs, j, command_stack[j]); if (!only_body) { @@ -3277,7 +3277,7 @@ void Buffer::SimpleDocBookOnePar(ostream & os, string & extra, LyXFont font1 = main_body > 0 ? style.labelfont : style.font; int char_line_count = depth; - if(!style.free_spacing) + if (!style.free_spacing) for (int j = 0; j < depth; ++j) os << ' '; @@ -3315,9 +3315,9 @@ void Buffer::SimpleDocBookOnePar(ostream & os, string & extra, // and title should come first // desc_on == 4 // - if(desc_on!= 3 || i!= 0) { - if(!tmp_out.empty() && tmp_out[0] == '@') { - if(desc_on == 4) + if (desc_on!= 3 || i!= 0) { + if (!tmp_out.empty() && tmp_out[0] == '@') { + if (desc_on == 4) extra += frontStrip(tmp_out, '@'); else os << frontStrip(tmp_out, '@'); @@ -3360,7 +3360,7 @@ void Buffer::SimpleDocBookOnePar(ostream & os, string & extra, } // resets description flag correctly - switch(desc_on){ + switch (desc_on){ case 1: // not closed... os << ""; @@ -3714,7 +3714,7 @@ void Buffer::resizeInsets(BufferView * bv) { /// then remove all LyXText in text-insets LyXParagraph * par = paragraph; - for(; par; par = par->next) { + for (; par; par = par->next) { par->resizeInsetsLyXText(bv); } } diff --git a/src/bufferlist.C b/src/bufferlist.C index 6de9f42223..fe8dba7576 100644 --- a/src/bufferlist.C +++ b/src/bufferlist.C @@ -109,7 +109,7 @@ bool BufferList::QwriteAll() fname = MakeDisplayPath((*it)->fileName(), 50); bool reask = true; while(reask) { - switch(AskConfirmation(_("Changes in document:"), + switch (AskConfirmation(_("Changes in document:"), fname, _("Save document?"))) { case 1: // Yes @@ -185,7 +185,7 @@ bool BufferList::close(Buffer * buf) fname = MakeDisplayPath(buf->fileName(), 50); bool reask = true; while (reask) { - switch(AskConfirmation(_("Changes in document:"), + switch (AskConfirmation(_("Changes in document:"), fname, _("Save document?"))){ case 1: // Yes @@ -291,50 +291,6 @@ void BufferList::emergencyWrite(Buffer * buf) buf->isUnnamed() ? OnlyFilename(buf->fileName()).c_str() : buf->fileName().c_str()) << endl; - //if (buf->isUnnamed()) - // lyxerr << OnlyFilename(buf->fileName()); - //else - // lyxerr << buf->fileName(); - //lyxerr << _(" as...") << endl; - - // Let's unroll this loop (Lgb) -#if 0 - bool madeit = false; - - for (int i = 0; i < 3 && !madeit; ++i) { - string s; - - // We try to save three places: - // 1) Same place as document. - // 2) In HOME directory. - // 3) In "/tmp" directory. - if (i == 0) { - if (buf->isUnnamed()) - continue; - s = buf->fileName(); - } else if (i == 1) { - s = AddName(GetEnvPath("HOME"), buf->fileName()); - } else { - // MakeAbsPath to prepend the current - // drive letter on OS/2 - s = AddName(MakeAbsPath("/tmp/"), buf->fileName()); - } - s += ".emergency"; - - lyxerr << " " << i + 1 << ") " << s << endl; - - if (buf->writeFile(s, true)) { - buf->markLyxClean(); - lyxerr << _(" Save seems successful. Phew.") << endl; - madeit = true; - } else if (i != 2) { - lyxerr << _(" Save failed! Trying...") << endl; - } else { - lyxerr << _(" Save failed! Bummer. Document is lost.") - << endl; - } - } -#else // We try to save three places: // 1) Same place as document. Unless it is an unnamed doc. @@ -375,7 +331,6 @@ void BufferList::emergencyWrite(Buffer * buf) return; } lyxerr << _(" Save failed! Bummer. Document is lost.") << endl; -#endif } diff --git a/src/bufferparams.C b/src/bufferparams.C index c3418377fc..ae15380f54 100644 --- a/src/bufferparams.C +++ b/src/bufferparams.C @@ -57,7 +57,7 @@ BufferParams::BufferParams() sides = LyXTextClass::OneSide; columns = 1; pagestyle = "default"; - for(int iter = 0; iter < 4; ++iter) { + for (int iter = 0; iter < 4; ++iter) { user_defined_bullets[iter] = temp_bullets[iter] = ITEMIZE_DEFAULTS[iter]; } @@ -139,7 +139,7 @@ void BufferParams::writeFile(ostream & os) const << "\n\\defskip " << defskip.asLyXCommand() << "\n\\quotes_language " << string_quotes_language[quotes_language] << '\n'; - switch(quotes_times) { + switch (quotes_times) { // An output operator for insetquotes would be nice case InsetQuotes::SingleQ: os << "\\quotes_times 1\n"; break; diff --git a/src/combox.C b/src/combox.C index bee3d12504..b472f8628d 100644 --- a/src/combox.C +++ b/src/combox.C @@ -160,7 +160,7 @@ void Combox::add(int x, int y, int w, int hmin, int hmax) { FL_OBJECT * obj; - switch(type) { + switch (type) { case FL_COMBOX_DROPLIST: { button = obj = fl_add_button(FL_NORMAL_BUTTON, diff --git a/src/commandtags.h b/src/commandtags.h index c84d89f270..adffe4c210 100644 --- a/src/commandtags.h +++ b/src/commandtags.h @@ -58,8 +58,8 @@ enum kb_action { LFUN_ROMAN, LFUN_NOUN, LFUN_RIGHT, - LFUN_LEFT, - LFUN_UP, // 40 + LFUN_LEFT, // 40 + LFUN_UP, LFUN_DOWN, LFUN_PRIOR, LFUN_NEXT, @@ -68,8 +68,8 @@ enum kb_action { LFUN_TAB, LFUN_SHIFT_TAB, // Jug 20000522 LFUN_WORDRIGHT, - LFUN_WORDLEFT, - LFUN_BEGINNINGBUF, // 50 + LFUN_WORDLEFT, // 50 + LFUN_BEGINNINGBUF, LFUN_ENDBUF, LFUN_RIGHTSEL, LFUN_LEFTSEL, @@ -78,8 +78,8 @@ enum kb_action { LFUN_PRIORSEL, LFUN_NEXTSEL, LFUN_HOMESEL, - LFUN_ENDSEL, - LFUN_WORDRIGHTSEL, // 60 + LFUN_ENDSEL, // 60 + LFUN_WORDRIGHTSEL, LFUN_WORDLEFTSEL, LFUN_BEGINNINGBUFSEL, LFUN_ENDBUFSEL, @@ -88,8 +88,8 @@ enum kb_action { LFUN_DELETE, LFUN_BACKSPACE, LFUN_BREAKLINE, - LFUN_BREAKPARAGRAPH, - LFUN_BREAKPARAGRAPHKEEPLAYOUT, // 70 + LFUN_BREAKPARAGRAPH, // 70 + LFUN_BREAKPARAGRAPHKEEPLAYOUT, LFUN_QUOTE, LFUN_CIRCUMFLEX, LFUN_GRAVE, @@ -98,8 +98,8 @@ enum kb_action { LFUN_CEDILLA, LFUN_MACRON, LFUN_UNDERBAR, - LFUN_UNDERDOT, - LFUN_CIRCLE, // 80 + LFUN_UNDERDOT, // 80 + LFUN_CIRCLE, LFUN_TIE, LFUN_BREVE, LFUN_CARON, @@ -108,8 +108,8 @@ enum kb_action { LFUN_UMLAUT, LFUN_DOT, LFUN_OGONEK, - LFUN_VECTOR, // Alejandro 040696 - LFUN_SELFINSERT, // 90 + LFUN_VECTOR, // Alejandro 040696 // 90 + LFUN_SELFINSERT, LFUN_GETBUFNAME, LFUN_GETXY, LFUN_SETXY, @@ -118,8 +118,8 @@ enum kb_action { LFUN_GETLAYOUT, LFUN_GETFONT, LFUN_GETLATEX, - LFUN_GETNAME, - LFUN_NOTIFY, // 100 + LFUN_GETNAME, // 100 + LFUN_NOTIFY, LFUN_GOTOFILEROW, // Edmar 12/23/98 LFUN_INSERT_NOTE, LFUN_KMAP_OFF, @@ -128,8 +128,8 @@ enum kb_action { LFUN_KMAP_TOGGLE, LFUN_INSERT_MATH, LFUN_INSERT_MATRIX, - LFUN_GREEK, - LFUN_MATH_LIMITS, // 110 + LFUN_GREEK, // 110 + LFUN_MATH_LIMITS, LFUN_GREEK_TOGGLE, LFUN_MATH_DELIM, // Alejandro 180696 LFUN_MATH_DISPLAY, // was INSERT_EQUATION Alejandro 180696 @@ -138,8 +138,8 @@ enum kb_action { LFUN_MATH_NONUMBER, // Alejandro 180696 LFUN_MATH_SIZE, // Alejandro 150896 LFUN_MATH_MACRO, // ale970510 - LFUN_MATH_MACROARG, // ale970510 - LFUN_MATH_PANEL, // 120 + LFUN_MATH_MACROARG, // ale970510 // 120 + LFUN_MATH_PANEL, LFUN_FIGURE, LFUN_MELT, LFUN_DELETE_WORD_FORWARD, @@ -148,8 +148,8 @@ enum kb_action { LFUN_MARK_OFF, LFUN_MARK_ON, LFUN_LAYOUT, - LFUN_LAYOUTNO, // Lgb 97-06-10 - LFUN_LAYOUT_CHARACTER, // 130 + LFUN_LAYOUTNO, // Lgb 97-06-10 // 130 + LFUN_LAYOUT_CHARACTER, LFUN_LAYOUT_PARAGRAPH, LFUN_LAYOUT_DOCUMENT, LFUN_LAYOUT_PREAMBLE, @@ -158,8 +158,8 @@ enum kb_action { LFUN_CODE, LFUN_SANS, LFUN_DEFAULT, - LFUN_UNDERLINE, - LFUN_FONT_SIZE, // 140 + LFUN_UNDERLINE, // 140 + LFUN_FONT_SIZE, LFUN_FONT_STATE, LFUN_UPCASE_WORD, LFUN_LOWCASE_WORD, @@ -168,8 +168,8 @@ enum kb_action { LFUN_REF_INSERT, LFUN_PUSH_TOOLBAR, LFUN_ADD_TO_TOOLBAR, - LFUN_DEPTH_MIN, // RVDK_PATCH_5 - LFUN_DEPTH_PLUS, // 150 // RVDK_PATCH_5 + LFUN_DEPTH_MIN, // 150 // RVDK_PATCH_5 + LFUN_DEPTH_PLUS, // RVDK_PATCH_5 LFUN_MENU_OPEN_BY_NAME, // RVDK_PATCH_5 LFUN_SPELLCHECK, // RVDK_PATCH_5 LFUN_CANCEL, // RVDK_PATCH_5 @@ -178,8 +178,8 @@ enum kb_action { LFUN_FILE_INSERT, LFUN_FILE_INSERT_ASCII, // CFO-G 1997-11-19 LFUN_FILE_NEW, - LFUN_FILE_OPEN, - LFUN_UP_PARAGRAPH, // 160 // Asger 1996-10-01 + LFUN_FILE_OPEN, // 160 + LFUN_UP_PARAGRAPH, // Asger 1996-10-01 LFUN_UP_PARAGRAPHSEL, // Asger 1996-10-01 LFUN_DOWN_PARAGRAPH, // Asger 1996-10-01 LFUN_DOWN_PARAGRAPHSEL, // Asger 1996-10-01 diff --git a/src/frontends/xforms/FormBase.h b/src/frontends/xforms/FormBase.h index 3eca8ca3ed..6ac0321f99 100644 --- a/src/frontends/xforms/FormBase.h +++ b/src/frontends/xforms/FormBase.h @@ -70,7 +70,7 @@ protected: // methods /** Filter the inputs on callback from xforms Return true if inputs are valid. */ - virtual bool input( FL_OBJECT *, long ) { + virtual bool input( FL_OBJECT *, long) { return true; } /// Apply from dialog (modify or create inset) diff --git a/src/frontends/xforms/FormCitation.C b/src/frontends/xforms/FormCitation.C index d0dff54ef8..8cdcfac7e6 100644 --- a/src/frontends/xforms/FormCitation.C +++ b/src/frontends/xforms/FormCitation.C @@ -52,7 +52,7 @@ FormCitation::~FormCitation() FL_FORM * FormCitation::form() const { - if ( dialog_ ) return dialog_->form; + if (dialog_ ) return dialog_->form; return 0; } @@ -99,7 +99,7 @@ void FormCitation::update() vector > blist = lv_->buffer()->getBibkeyList(); - for( unsigned int i = 0; i < blist.size(); ++i ) { + for (unsigned int i = 0; i < blist.size(); ++i) { bibkeys.push_back(blist[i].first); bibkeysInfo.push_back(blist[i].second); } @@ -108,7 +108,7 @@ void FormCitation::update() citekeys.clear(); string tmp, keys( params.getContents() ); keys = frontStrip( split(keys, tmp, ',') ); - while( !tmp.empty() ) { + while (!tmp.empty()) { citekeys.push_back( tmp ); keys = frontStrip( split(keys, tmp, ',') ); } @@ -140,7 +140,7 @@ void FormCitation::updateBrowser( FL_OBJECT * browser, { fl_clear_browser( browser ); - for( unsigned int i = 0; i < keys.size(); ++i ) + for (unsigned int i = 0; i < keys.size(); ++i ) fl_add_browser_line( browser, keys[i].c_str()); } @@ -166,7 +166,7 @@ void FormCitation::setBibButtons( State status ) const void FormCitation::setCiteButtons( State status ) const { - switch( status ) { + switch (status) { case ON: { fl_activate_object( dialog_->delBtn ); @@ -174,7 +174,7 @@ void FormCitation::setCiteButtons( State status ) const int sel = fl_get_browser( dialog_->citeBrsr ); - if ( sel != 1 ) { + if (sel != 1) { fl_activate_object( dialog_->upBtn ); fl_set_object_lcol( dialog_->upBtn, FL_BLACK ); } else { @@ -182,7 +182,7 @@ void FormCitation::setCiteButtons( State status ) const fl_set_object_lcol( dialog_->upBtn, FL_INACTIVE ); } - if ( sel != fl_get_browser_maxline(dialog_->citeBrsr)) { + if (sel != fl_get_browser_maxline(dialog_->citeBrsr)) { fl_activate_object( dialog_->downBtn ); fl_set_object_lcol( dialog_->downBtn, FL_BLACK ); } else { @@ -233,11 +233,11 @@ void FormCitation::setSize( int hbrsr, bool bibPresent ) const static int const hok = dialog_->button_ok->h; int hform = dh1 + hbrsr + dh1; - if ( bibPresent ) hform += hinfo + dh1; - if ( natbib ) hform += hstyle + dh1 + htext + dh2; + if (bibPresent ) hform += hinfo + dh1; + if (natbib ) hform += hstyle + dh1 + htext + dh2; hform += htext + dh1 + hok + dh2; - if ( hform != minh_ ) { + if (hform != minh_) { minh_ = hform; fl_set_form_size( dialog_->form, minw_, minh_ ); } else @@ -264,7 +264,7 @@ void FormCitation::setSize( int hbrsr, bool bibPresent ) const y = dh1 + hbrsr + dh1; // in position for next element - if ( bibPresent ) { + if (bibPresent) { x = dialog_->infoBrsr->x; fl_set_object_position( dialog_->infoBrsr, x, y ); fl_show_object( dialog_->infoBrsr ); @@ -272,7 +272,7 @@ void FormCitation::setSize( int hbrsr, bool bibPresent ) const } else fl_hide_object( dialog_->infoBrsr ); - if ( natbib ) { + if (natbib) { x = dialog_->style->x; fl_set_object_position( dialog_->style, x, y ); fl_show_object( dialog_->style ); @@ -309,13 +309,13 @@ bool FormCitation::input( FL_OBJECT *, long data ) bool activate = false; State cb = static_cast( data ); - switch( cb ) { + switch (cb) { case BIBBRSR: { fl_deselect_browser( dialog_->citeBrsr ); unsigned int sel = fl_get_browser( dialog_->bibBrsr ); - if ( sel < 1 || sel > bibkeys.size() ) break; + if (sel < 1 || sel > bibkeys.size() ) break; // Put into infoBrsr the additional info associated with // the selected bibBrsr key @@ -327,14 +327,14 @@ bool FormCitation::input( FL_OBJECT *, long data ) vector::iterator it = find( citekeys.begin(), citekeys.end(), bibkeys[sel-1] ); - if ( it != citekeys.end() ) { + if (it != citekeys.end()) { int n = static_cast( it - citekeys.begin() ); fl_select_browser_line( dialog_->citeBrsr, n+1 ); fl_set_browser_topline( dialog_->citeBrsr, n+1 ); } - if ( !lv_->buffer()->isReadonly() ) { - if ( it != citekeys.end() ) { + if (!lv_->buffer()->isReadonly()) { + if (it != citekeys.end()) { setBibButtons( OFF ); setCiteButtons( ON ); } else { @@ -347,9 +347,9 @@ bool FormCitation::input( FL_OBJECT *, long data ) case CITEBRSR: { unsigned int sel = fl_get_browser( dialog_->citeBrsr ); - if ( sel < 1 || sel > citekeys.size() ) break; + if (sel < 1 || sel > citekeys.size() ) break; - if ( !lv_->buffer()->isReadonly() ) { + if (!lv_->buffer()->isReadonly()) { setBibButtons( OFF ); setCiteButtons( ON ); } @@ -373,10 +373,10 @@ bool FormCitation::input( FL_OBJECT *, long data ) break; case ADD: { - if ( lv_->buffer()->isReadonly() ) break; + if (lv_->buffer()->isReadonly() ) break; unsigned int sel = fl_get_browser( dialog_->bibBrsr ); - if ( sel < 1 || sel > bibkeys.size() ) break; + if (sel < 1 || sel > bibkeys.size() ) break; // Add the selected bibBrsr key to citeBrsr fl_addto_browser( dialog_->citeBrsr, @@ -393,10 +393,10 @@ bool FormCitation::input( FL_OBJECT *, long data ) break; case DELETE: { - if ( lv_->buffer()->isReadonly() ) break; + if (lv_->buffer()->isReadonly() ) break; unsigned int sel = fl_get_browser( dialog_->citeBrsr ); - if ( sel < 1 || sel > citekeys.size() ) break; + if (sel < 1 || sel > citekeys.size() ) break; // Remove the selected key from citeBrsr fl_delete_browser_line( dialog_->citeBrsr, sel ) ; @@ -409,10 +409,10 @@ bool FormCitation::input( FL_OBJECT *, long data ) break; case UP: { - if ( lv_->buffer()->isReadonly() ) break; + if (lv_->buffer()->isReadonly() ) break; unsigned int sel = fl_get_browser( dialog_->citeBrsr ); - if ( sel < 2 || sel > citekeys.size() ) break; + if (sel < 2 || sel > citekeys.size() ) break; // Move the selected key up one line vector::iterator it = citekeys.begin() + sel-1; @@ -430,10 +430,10 @@ bool FormCitation::input( FL_OBJECT *, long data ) break; case DOWN: { - if ( lv_->buffer()->isReadonly() ) break; + if (lv_->buffer()->isReadonly() ) break; unsigned int sel = fl_get_browser( dialog_->citeBrsr ); - if ( sel < 1 || sel > citekeys.size()-1 ) break; + if (sel < 1 || sel > citekeys.size()-1 ) break; // Move the selected key down one line vector::iterator it = citekeys.begin() + sel-1; @@ -461,7 +461,7 @@ void FormCitation::apply() if (lv_->buffer()->isReadonly()) return; string contents; - for(unsigned int i = 0; i < citekeys.size(); ++i) { + for (unsigned int i = 0; i < citekeys.size(); ++i) { if (i > 0) contents += ", "; contents += citekeys[i]; } diff --git a/src/frontends/xforms/FormCopyright.C b/src/frontends/xforms/FormCopyright.C index 0cef3ce770..b215e73efc 100644 --- a/src/frontends/xforms/FormCopyright.C +++ b/src/frontends/xforms/FormCopyright.C @@ -34,7 +34,7 @@ FormCopyright::~FormCopyright() FL_FORM * FormCopyright::form() const { - if ( dialog_ ) return dialog_->form; + if (dialog_ ) return dialog_->form; return 0; } diff --git a/src/frontends/xforms/FormDocument.C b/src/frontends/xforms/FormDocument.C index 2c47d4c7e7..e05395849d 100644 --- a/src/frontends/xforms/FormDocument.C +++ b/src/frontends/xforms/FormDocument.C @@ -209,7 +209,7 @@ void FormDocument::build() #ifdef DO_USE_DEFAULT_LANGUAGE combo_language->addto("default"); #endif - for(Languages::const_iterator cit = languages.begin(); + for (Languages::const_iterator cit = languages.begin(); cit != languages.end(); ++cit) { combo_language->addto((*cit).second.lang()); } @@ -324,7 +324,7 @@ bool FormDocument::input( FL_OBJECT * ob, long data ) { State cb = static_cast( data ); - switch( cb ) { + switch (cb) { case CHECKCHOICECLASS: CheckChoiceClass(ob, 0); break; @@ -355,7 +355,7 @@ bool FormDocument::input( FL_OBJECT * ob, long data ) break; } - switch( data ) { + switch (data) { case INPUT: case CHECKCHOICECLASS: case CHOICEBULLETSIZE: @@ -476,7 +476,7 @@ bool FormDocument::class_apply() params.sides = LyXTextClass::OneSide; Spacing tmpSpacing = params.spacing; - switch(fl_get_choice(class_->choice_doc_spacing)) { + switch (fl_get_choice(class_->choice_doc_spacing)) { case 1: lyxerr[Debug::INFO] << "Spacing: SINGLE\n"; params.spacing.set(Spacing::Single); @@ -536,7 +536,7 @@ bool FormDocument::language_apply() InsetQuotes::quote_language lga = InsetQuotes::EnglishQ; bool redo = false; - switch(fl_get_choice(language_->choice_quotes_language) - 1) { + switch (fl_get_choice(language_->choice_quotes_language) - 1) { case 0: lga = InsetQuotes::EnglishQ; break; @@ -952,13 +952,13 @@ void FormDocument::BulletDepth(FL_OBJECT * ob, State cb) BufferParams & param = lv_->buffer()->params; int data = 0; - if( cb == BULLETDEPTH1 ) + if (cb == BULLETDEPTH1 ) data = 0; - else if ( cb == BULLETDEPTH2 ) + else if (cb == BULLETDEPTH2 ) data = 1; - else if ( cb == BULLETDEPTH3 ) + else if (cb == BULLETDEPTH3 ) data = 2; - else if ( cb == BULLETDEPTH4 ) + else if (cb == BULLETDEPTH4 ) data = 3; switch (fl_get_button_numb(ob)) { @@ -981,17 +981,17 @@ void FormDocument::BulletPanel(FL_OBJECT * /*ob*/, State cb) /* by the user. (eg. standard.xpm, psnfss1.xpm etc...) */ int data = 0; - if( cb == BULLETPANEL1 ) + if (cb == BULLETPANEL1 ) data = 0; - else if ( cb == BULLETPANEL2 ) + else if (cb == BULLETPANEL2 ) data = 1; - else if ( cb == BULLETPANEL3 ) + else if (cb == BULLETPANEL3 ) data = 2; - else if ( cb == BULLETPANEL4 ) + else if (cb == BULLETPANEL4 ) data = 3; - else if ( cb == BULLETPANEL5 ) + else if (cb == BULLETPANEL5 ) data = 4; - else if ( cb == BULLETPANEL6 ) + else if (cb == BULLETPANEL6 ) data = 5; if (data != current_bullet_panel) { diff --git a/src/frontends/xforms/FormError.C b/src/frontends/xforms/FormError.C index bdc2110f90..b481b29d3a 100644 --- a/src/frontends/xforms/FormError.C +++ b/src/frontends/xforms/FormError.C @@ -39,7 +39,7 @@ FormError::~FormError() FL_FORM * FormError::form() const { - if ( dialog_ ) return dialog_->form; + if (dialog_ ) return dialog_->form; return 0; } diff --git a/src/frontends/xforms/FormGraphics.C b/src/frontends/xforms/FormGraphics.C index 49cb50d87d..c5d8083139 100644 --- a/src/frontends/xforms/FormGraphics.C +++ b/src/frontends/xforms/FormGraphics.C @@ -147,7 +147,7 @@ void FormGraphics::build() FL_FORM * FormGraphics::form() const { - if ( dialog_ ) return dialog_->form; + if (dialog_ ) return dialog_->form; return 0; } @@ -279,7 +279,7 @@ bool FormGraphics::input(FL_OBJECT *, long data ) bool inputOK = true; - switch( cb ) { + switch (cb) { case CHECKINPUT: inputOK = checkInput(); break; diff --git a/src/frontends/xforms/FormIndex.C b/src/frontends/xforms/FormIndex.C index 45bcebe8dc..fffc92d742 100644 --- a/src/frontends/xforms/FormIndex.C +++ b/src/frontends/xforms/FormIndex.C @@ -44,7 +44,7 @@ FormIndex::~FormIndex() FL_FORM * FormIndex::form() const { - if ( dialog_ ) return dialog_->form; + if (dialog_ ) return dialog_->form; return 0; } @@ -73,7 +73,7 @@ void FormIndex::update() { fl_set_input(dialog_->key, params.getContents().c_str()); - if ( lv_->buffer()->isReadonly() ) { + if (lv_->buffer()->isReadonly()) { fl_deactivate_object( dialog_->key ); fl_deactivate_object( dialog_->ok ); fl_set_object_lcol( dialog_->ok, FL_INACTIVE ); diff --git a/src/frontends/xforms/FormParagraph.C b/src/frontends/xforms/FormParagraph.C index 0f9beea210..67f49a8d43 100644 --- a/src/frontends/xforms/FormParagraph.C +++ b/src/frontends/xforms/FormParagraph.C @@ -469,7 +469,7 @@ void FormParagraph::extra_update() par->pextra_width.c_str()); fl_set_input(extra_->input_pextra_widthp, par->pextra_widthp.c_str()); - switch(par->pextra_alignment) { + switch (par->pextra_alignment) { case LyXParagraph::MINIPAGE_ALIGN_TOP: fl_set_button(extra_->radio_pextra_top, 1); break; diff --git a/src/frontends/xforms/FormPreferences.C b/src/frontends/xforms/FormPreferences.C index 6ac1214523..b7b3b5e13b 100644 --- a/src/frontends/xforms/FormPreferences.C +++ b/src/frontends/xforms/FormPreferences.C @@ -46,7 +46,7 @@ extern Languages languages; typedef pair X11Colour; static vector colourDB; -static string const colourFile = "/usr/lib/X11/rgb.txt"; +static string const colourFile("/usr/lib/X11/rgb.txt"); FormPreferences::FormPreferences(LyXView * lv, Dialogs * d) @@ -260,29 +260,29 @@ void FormPreferences::feedback( FL_OBJECT * ob ) { string str; - if( ob->form->fdui == colours_ ) { + if (ob->form->fdui == colours_) { str = feedbackColours( ob ); - } else if( ob->form->fdui == converters_ ) { + } else if (ob->form->fdui == converters_) { str = feedbackConverters( ob ); - } else if( ob->form->fdui == formats_ ) { + } else if (ob->form->fdui == formats_) { str = feedbackFormats( ob ); - } else if( ob->form->fdui == inputs_misc_ ) { + } else if (ob->form->fdui == inputs_misc_) { str = feedbackInputsMisc( ob ); - } else if( ob->form->fdui == interface_ ) { + } else if (ob->form->fdui == interface_) { str = feedbackInterface( ob ); - } else if( ob->form->fdui == language_ ) { + } else if (ob->form->fdui == language_) { str = feedbackLanguage( ob ); - } else if( ob->form->fdui == lnf_misc_ ) { + } else if (ob->form->fdui == lnf_misc_) { str = feedbackLnFmisc( ob ); - } else if( ob->form->fdui == outputs_misc_ ) { + } else if (ob->form->fdui == outputs_misc_) { str = feedbackOutputsMisc( ob ); - } else if( ob->form->fdui == paths_ ) { + } else if (ob->form->fdui == paths_) { str = feedbackPaths( ob ); - } else if( ob->form->fdui == printer_ ) { + } else if (ob->form->fdui == printer_) { str = feedbackPrinter( ob ); - } else if( ob->form->fdui == screen_fonts_ ) { + } else if (ob->form->fdui == screen_fonts_) { str = feedbackScreenFonts( ob ); - } else if( ob->form->fdui == spellchecker_ ) { + } else if (ob->form->fdui == spellchecker_) { str = feedbackSpellChecker( ob ); } @@ -302,20 +302,20 @@ bool FormPreferences::input(FL_OBJECT * ob, long) // some totally ridiculous value somewhere. Change activate to suit. // comments before each test describe what is _valid_ - if( ob->form->fdui == colours_ ) { - if( ! inputColours( ob ) ) + if (ob->form->fdui == colours_) { + if (! inputColours( ob ) ) activate = false; - } else if( ob->form->fdui == language_ ) { - if( ! inputLanguage( ob ) ) + } else if (ob->form->fdui == language_) { + if (! inputLanguage( ob ) ) activate = false; - } else if( ob->form->fdui == paths_ ) { - if( ! inputPaths( ob ) ) + } else if (ob->form->fdui == paths_) { + if (! inputPaths( ob ) ) activate = false; - } else if( ob->form->fdui == screen_fonts_ ) { - if( ! inputScreenFonts() ) + } else if (ob->form->fdui == screen_fonts_) { + if (! inputScreenFonts() ) activate = false; - } else if( ob->form->fdui == spellchecker_ ) { - if( ! inputSpellChecker( ob ) ) + } else if (ob->form->fdui == spellchecker_) { + if (! inputSpellChecker( ob ) ) activate = false; } @@ -373,7 +373,7 @@ void FormPreferences::buildColours() fl_set_input_return(colours_->input_name, FL_RETURN_END_CHANGED); - if( ColoursLoadBrowser(colourFile) ) + if (ColoursLoadBrowser(colourFile) ) fl_set_input(colours_->input_name, colourFile.c_str()); else fl_set_input(colours_->input_name, N_("No file found")); @@ -384,7 +384,7 @@ void FormPreferences::buildColours() } -string FormPreferences::feedbackColours( FL_OBJECT const * const ) const +string const FormPreferences::feedbackColours( FL_OBJECT const * const ) const { return string(); } @@ -394,22 +394,22 @@ bool FormPreferences::inputColours( FL_OBJECT const * const ob ) { bool activate = true; - if( ob == colours_->browser_x11 ) { + if (ob == colours_->browser_x11) { int i = fl_get_browser(colours_->browser_x11); - if( i > 0) { + if (i > 0) { ColoursUpdateBrowser(i-1); } - } else if( ob == colours_->valslider_red + } else if (ob == colours_->valslider_red || ob == colours_->valslider_green - || ob == colours_->valslider_blue ) { + || ob == colours_->valslider_blue) { ColoursUpdateRGB(); - } else if( ob == colours_->input_name) { + } else if (ob == colours_->input_name) { string file = fl_get_input(colours_->input_name); - if( ColoursLoadBrowser(file) ) + if (ColoursLoadBrowser(file) ) fl_set_input(colours_->input_name, file.c_str()); - else if( ColoursLoadBrowser(colourFile) ) + else if (ColoursLoadBrowser(colourFile) ) fl_set_input(colours_->input_name, colourFile.c_str()); else fl_set_input(colours_->input_name, N_("No file found")); @@ -419,7 +419,7 @@ bool FormPreferences::inputColours( FL_OBJECT const * const ob ) } -bool FormPreferences::ColoursLoadBrowser( string const & filename ) +bool FormPreferences::ColoursLoadBrowser(string const & filename) { LyXLex lex(0, 0); @@ -432,38 +432,38 @@ bool FormPreferences::ColoursLoadBrowser( string const & filename ) vector cols; vector names; - while( 1 ) { + while (true) { getline( is, line ); - if( line.empty() ) + if (line.empty() ) break; - if( line[0] != '!' ) { + if (line[0] != '!') { RGB col; string name; istringstream iss(line); iss >> col.r >> col.g >> col.b; - while( iss.good() ) { + while (iss.good()) { string next; iss >> next; - if( !name.empty() ) name += " "; + if (!name.empty() ) name += " "; name += next; } // remove redundant entries on the fly bool add = cols.empty(); - if( !add ) { + if (!add) { vector::const_iterator it = find( cols.begin(), cols.end(), col ); add = (it == cols.end()); } - if ( add ) { + if (add) { name = lowercase( name ); - if( name == "gray0" ) name = "black"; - if( name == "gray100" ) name = "white"; + if (name == "gray0" ) name = "black"; + if (name == "gray100" ) name = "white"; - if( name == "black" || name == "white" ) { + if (name == "black" || name == "white") { cols.insert(cols.begin(), col); names.insert(names.begin(), name); } else { @@ -475,8 +475,8 @@ bool FormPreferences::ColoursLoadBrowser( string const & filename ) } vector::iterator sit = names.begin(); - for( vector::const_iterator iit = cols.begin(); - iit != cols.end(); ++iit, ++sit ) { + for (vector::const_iterator iit = cols.begin(); + iit != cols.end(); ++iit, ++sit) { colourDB.push_back( X11Colour(*sit, *iit) ); } @@ -484,8 +484,8 @@ bool FormPreferences::ColoursLoadBrowser( string const & filename ) fl_freeze_form(colours_->form); fl_clear_browser( colbr ); - for( vector::const_iterator cit = colourDB.begin(); - cit != colourDB.end(); ++cit ) { + for (vector::const_iterator cit = colourDB.begin(); + cit != colourDB.end(); ++cit) { string name = (*cit).first; //RGB col = (*cit).second; //name += " (" + tostr(col.r) + ", " + tostr(col.g) + @@ -502,13 +502,13 @@ bool FormPreferences::ColoursLoadBrowser( string const & filename ) } -int FormPreferences::ColoursSearchEntry(RGB const & col ) const +int FormPreferences::ColoursSearchEntry(RGB const & col) const { int mindiff = 0x7fffffff; vector::const_iterator mincit = colourDB.begin(); - for( vector::const_iterator cit = colourDB.begin(); - cit != colourDB.end(); ++cit ) { + for (vector::const_iterator cit = colourDB.begin(); + cit != colourDB.end(); ++cit) { RGB colDB = (*cit).second; RGB diff; diff.r = col.r - colDB.r; @@ -519,7 +519,7 @@ int FormPreferences::ColoursSearchEntry(RGB const & col ) const 3 * (diff.g * diff.g) + (diff.b * diff.b)); - if( mindiff > d ) { + if (mindiff > d) { mindiff = d; mincit = cit; } @@ -560,7 +560,7 @@ void FormPreferences::ColoursUpdateRGB() int i = ColoursSearchEntry( col ); // change topline only if necessary // int top = fl_get_browser_topline(colours_->browser_x11); - // if(i < top || i > (top+15)) + // if (i < top || i > (top+15)) fl_set_browser_topline(colours_->browser_x11, i-5); fl_select_browser_line(colours_->browser_x11, i + 1); @@ -569,13 +569,11 @@ void FormPreferences::ColoursUpdateRGB() void FormPreferences::updateColours() -{ -} +{} void FormPreferences::applyConverters() const -{ -} +{} void FormPreferences::buildConverters() @@ -585,20 +583,19 @@ void FormPreferences::buildConverters() } -string FormPreferences::feedbackConverters( FL_OBJECT const * const ) const +string const +FormPreferences::feedbackConverters( FL_OBJECT const * const ) const { return string(); } void FormPreferences::updateConverters() -{ -} +{} void FormPreferences::applyFormats() const -{ -} +{} void FormPreferences::buildFormats() @@ -614,7 +611,7 @@ void FormPreferences::buildFormats() } -string FormPreferences::feedbackFormats( FL_OBJECT const * const ) const +string const FormPreferences::feedbackFormats( FL_OBJECT const * const ) const { string str; @@ -629,13 +626,13 @@ bool FormPreferences::inputFormats( FL_OBJECT const * const ) void FormPreferences::updateFormats() -{ -} +{} void FormPreferences::applyInputsMisc() const { - lyxrc.date_insert_format = fl_get_input(inputs_misc_->input_date_format); + lyxrc.date_insert_format = + fl_get_input(inputs_misc_->input_date_format); } @@ -655,11 +652,12 @@ void FormPreferences::buildInputsMisc() } -string FormPreferences::feedbackInputsMisc( FL_OBJECT const * const ob ) const +string const +FormPreferences::feedbackInputsMisc(FL_OBJECT const * const ob) const { string str; - if( ob == inputs_misc_->input_date_format ) + if (ob == inputs_misc_->input_date_format ) str = lyxrc.getDescription( LyXRC::RC_DATE_INSERT_FORMAT ); return str; @@ -720,22 +718,22 @@ void FormPreferences::buildInterface() } - -string FormPreferences::feedbackInterface( FL_OBJECT const * const ob ) const +string const +FormPreferences::feedbackInterface( FL_OBJECT const * const ob ) const { string str; - if( ob == interface_->input_popup_font ) + if (ob == interface_->input_popup_font ) str = lyxrc.getDescription( LyXRC::RC_SCREEN_FONT_POPUP ); - else if ( ob == interface_->input_menu_font ) + else if (ob == interface_->input_menu_font ) str = lyxrc.getDescription( LyXRC::RC_SCREEN_FONT_MENU ); - else if ( ob == interface_->input_popup_encoding ) + else if (ob == interface_->input_popup_encoding ) str = lyxrc.getDescription( LyXRC::RC_SCREEN_FONT_ENCODING_MENU ); - else if ( ob == interface_->input_bind_file ) + else if (ob == interface_->input_bind_file ) str = lyxrc.getDescription( LyXRC::RC_BINDFILE ); - else if ( ob == interface_->input_ui_file ) + else if (ob == interface_->input_ui_file ) str = lyxrc.getDescription( LyXRC::RC_UIFILE ); - else if ( ob == interface_->check_override_x_dead_keys ) + else if (ob == interface_->check_override_x_dead_keys ) str = lyxrc.getDescription( LyXRC::RC_OVERRIDE_X_DEADKEYS ); return str; @@ -766,7 +764,7 @@ void FormPreferences::applyLanguage() const int button = fl_get_button(language_->check_use_kbmap); lyxrc.use_kbmap = static_cast(button); - if( button ) { + if (button) { lyxrc.primary_kbmap = combo_kbmap_1->getline(); lyxrc.secondary_kbmap = combo_kbmap_2->getline(); } @@ -853,31 +851,32 @@ void FormPreferences::buildLanguage() } -string FormPreferences::feedbackLanguage( FL_OBJECT const * const ob ) const +string const +FormPreferences::feedbackLanguage(FL_OBJECT const * const ob) const { string str; - if( reinterpret_cast(ob) == combo_default_lang ) + if (reinterpret_cast(ob) == combo_default_lang ) str = lyxrc.getDescription( LyXRC::RC_DEFAULT_LANGUAGE ); - else if( ob == language_->check_use_kbmap ) + else if (ob == language_->check_use_kbmap ) str = lyxrc.getDescription( LyXRC::RC_KBMAP ); - else if( reinterpret_cast(ob) == combo_kbmap_1) + else if (reinterpret_cast(ob) == combo_kbmap_1) str = lyxrc.getDescription( LyXRC::RC_KBMAP_PRIMARY ); - else if( reinterpret_cast(ob) == combo_kbmap_2 ) + else if (reinterpret_cast(ob) == combo_kbmap_2 ) str = lyxrc.getDescription( LyXRC::RC_KBMAP_SECONDARY ); - else if( ob == language_->check_rtl_support ) + else if (ob == language_->check_rtl_support ) str = lyxrc.getDescription( LyXRC::RC_RTL_SUPPORT ); - else if( ob == language_->check_auto_begin ) + else if (ob == language_->check_auto_begin ) str = lyxrc.getDescription( LyXRC::RC_LANGUAGE_AUTO_BEGIN ); - else if( ob == language_->check_auto_end ) + else if (ob == language_->check_auto_end ) str = lyxrc.getDescription( LyXRC::RC_LANGUAGE_AUTO_END ); - else if( ob == language_->check_mark_foreign ) + else if (ob == language_->check_mark_foreign ) str = lyxrc.getDescription( LyXRC::RC_MARK_FOREIGN_LANGUAGE ); - else if( ob == language_->input_package ) + else if (ob == language_->input_package ) str = lyxrc.getDescription( LyXRC::RC_LANGUAGE_PACKAGE ); - else if( ob == language_->input_command_begin ) + else if (ob == language_->input_command_begin ) str = lyxrc.getDescription( LyXRC::RC_LANGUAGE_COMMAND_BEGIN ); - else if( ob == language_->input_command_end ) + else if (ob == language_->input_command_end ) str = lyxrc.getDescription( LyXRC::RC_LANGUAGE_COMMAND_END ); return str; @@ -888,8 +887,8 @@ bool FormPreferences::inputLanguage( FL_OBJECT const * const ob ) { bool activate = true; - if( !ob || ob == language_->check_use_kbmap ) { - if( fl_get_button(language_->check_use_kbmap) ) { + if (!ob || ob == language_->check_use_kbmap) { + if (fl_get_button(language_->check_use_kbmap)) { combo_kbmap_1->activate(); combo_kbmap_2->activate(); } else { @@ -909,7 +908,7 @@ void FormPreferences::updateLanguage() combo_default_lang->select_text( lyxrc.default_language ); - if( lyxrc.use_kbmap ) { + if (lyxrc.use_kbmap) { combo_kbmap_1->select_text( lyxrc.primary_kbmap ); combo_kbmap_2->select_text( lyxrc.secondary_kbmap ); } else { @@ -938,7 +937,7 @@ void FormPreferences::updateLanguage() void FormPreferences::LanguagesAdd( Combox & combo ) const { - for(Languages::const_iterator cit = languages.begin(); + for (Languages::const_iterator cit = languages.begin(); cit != languages.end(); cit++) { combo.addto((*cit).second.lang()); } @@ -988,30 +987,31 @@ void FormPreferences::buildLnFmisc() } -string FormPreferences::feedbackLnFmisc( FL_OBJECT const * const ob ) const +string const FormPreferences::feedbackLnFmisc(FL_OBJECT const * const ob) const { string str; - if( ob == lnf_misc_->check_banner ) + if (ob == lnf_misc_->check_banner ) str = lyxrc.getDescription( LyXRC::RC_SHOW_BANNER ); - else if( ob == lnf_misc_->check_auto_region_delete ) + else if (ob == lnf_misc_->check_auto_region_delete ) str = lyxrc.getDescription( LyXRC::RC_AUTOREGIONDELETE ); - else if( ob == lnf_misc_->check_exit_confirm ) + else if (ob == lnf_misc_->check_exit_confirm ) str = lyxrc.getDescription( LyXRC::RC_EXIT_CONFIRMATION ); - else if( ob == lnf_misc_->check_display_shortcuts ) + else if (ob == lnf_misc_->check_display_shortcuts ) str = lyxrc.getDescription( LyXRC::RC_DISPLAY_SHORTCUTS ); - else if( ob == lnf_misc_->check_ask_new_file ) + else if (ob == lnf_misc_->check_ask_new_file ) str = lyxrc.getDescription( LyXRC::RC_NEW_ASK_FILENAME ); - else if( ob == lnf_misc_->check_cursor_follows_scrollbar ) + else if (ob == lnf_misc_->check_cursor_follows_scrollbar ) str = lyxrc.getDescription( LyXRC::RC_CURSOR_FOLLOWS_SCROLLBAR ); - else if( ob == lnf_misc_->counter_autosave ) + else if (ob == lnf_misc_->counter_autosave ) str = lyxrc.getDescription( LyXRC::RC_AUTOSAVE ); - else if( ob == lnf_misc_->counter_wm_jump ) + else if (ob == lnf_misc_->counter_wm_jump ) str = lyxrc.getDescription( LyXRC::RC_WHEEL_JUMP ); return str; } + void FormPreferences::updateLnFmisc() { fl_set_button(lnf_misc_->check_banner, @@ -1076,19 +1076,20 @@ void FormPreferences::buildOutputsMisc() } -string FormPreferences::feedbackOutputsMisc(FL_OBJECT const * const ob ) const +string const +FormPreferences::feedbackOutputsMisc(FL_OBJECT const * const ob) const { string str; - if( ob == outputs_misc_->counter_line_len ) + if (ob == outputs_misc_->counter_line_len ) str = lyxrc.getDescription( LyXRC::RC_ASCII_LINELEN ); - else if( ob == outputs_misc_->input_tex_encoding ) + else if (ob == outputs_misc_->input_tex_encoding ) str = lyxrc.getDescription( LyXRC::RC_FONT_ENCODING ); - else if( ob == outputs_misc_->input_ascii_roff ) + else if (ob == outputs_misc_->input_ascii_roff ) str = lyxrc.getDescription( LyXRC::RC_ASCIIROFF_COMMAND ); - else if( ob == outputs_misc_->input_checktex ) + else if (ob == outputs_misc_->input_checktex ) str = lyxrc.getDescription( LyXRC::RC_CHKTEX_COMMAND ); - else if( ob == outputs_misc_->choice_default_papersize ) + else if (ob == outputs_misc_->choice_default_papersize ) str = lyxrc.getDescription( LyXRC::RC_DEFAULT_PAPERSIZE ); return str; @@ -1117,14 +1118,14 @@ void FormPreferences::applyPaths() int button = fl_get_button(paths_->check_use_temp_dir); string str = fl_get_input(paths_->input_temp_dir); - if( !button ) str.erase(); + if (!button ) str.erase(); lyxrc.use_tempdir = button; lyxrc.tempdir_path = str; button = fl_get_button(paths_->check_last_files); str = fl_get_input(paths_->input_lastfiles); - if( !button ) str.erase(); + if (!button ) str.erase(); lyxrc.check_lastfiles = button; lyxrc.lastfiles = str; @@ -1133,7 +1134,7 @@ void FormPreferences::applyPaths() button = fl_get_button(paths_->check_make_backups); str = fl_get_input(paths_->input_backup_path); - if( !button ) str.erase(); + if (!button ) str.erase(); lyxrc.make_backup = button; lyxrc.backupdir_path = str; @@ -1195,29 +1196,29 @@ void FormPreferences::buildPaths() } -string FormPreferences::feedbackPaths( FL_OBJECT const * const ob ) const +string const FormPreferences::feedbackPaths( FL_OBJECT const * const ob ) const { string str; - if( ob == paths_->input_default_path ) + if (ob == paths_->input_default_path ) str = lyxrc.getDescription( LyXRC::RC_DOCUMENTPATH ); - else if ( ob == paths_->input_template_path ) + else if (ob == paths_->input_template_path ) str = lyxrc.getDescription( LyXRC::RC_TEMPLATEPATH ); - else if ( ob == paths_->check_use_temp_dir ) + else if (ob == paths_->check_use_temp_dir ) str = lyxrc.getDescription( LyXRC::RC_USETEMPDIR ); - else if ( ob == paths_->input_temp_dir ) + else if (ob == paths_->input_temp_dir ) str = lyxrc.getDescription( LyXRC::RC_TEMPDIRPATH ); - else if ( ob == paths_->check_last_files ) + else if (ob == paths_->check_last_files ) str = lyxrc.getDescription( LyXRC::RC_CHECKLASTFILES ); - else if ( ob == paths_->input_lastfiles ) + else if (ob == paths_->input_lastfiles ) str = lyxrc.getDescription( LyXRC::RC_LASTFILES ); - else if ( ob == paths_->counter_lastfiles ) + else if (ob == paths_->counter_lastfiles ) str = lyxrc.getDescription( LyXRC::RC_NUMLASTFILES ); - else if ( ob == paths_->check_make_backups ) + else if (ob == paths_->check_make_backups ) str = lyxrc.getDescription( LyXRC::RC_MAKE_BACKUP ); - else if ( ob == paths_->input_backup_path ) + else if (ob == paths_->input_backup_path ) str = lyxrc.getDescription( LyXRC::RC_BACKUPDIR_PATH ); - else if ( ob == paths_->input_serverpipe ) + else if (ob == paths_->input_serverpipe ) str = lyxrc.getDescription( LyXRC::RC_SERVERPIPE ); return str; @@ -1228,8 +1229,8 @@ bool FormPreferences::inputPaths( FL_OBJECT const * const ob ) { bool activate = true; - if( !ob || ob == paths_->check_use_temp_dir ) { - if( fl_get_button(paths_->check_use_temp_dir) ) { + if (!ob || ob == paths_->check_use_temp_dir) { + if (fl_get_button(paths_->check_use_temp_dir)) { fl_activate_object(paths_->input_temp_dir); fl_set_object_lcol(paths_->input_temp_dir, FL_BLACK); @@ -1240,8 +1241,8 @@ bool FormPreferences::inputPaths( FL_OBJECT const * const ob ) } } - if( !ob || ob == paths_->check_last_files ) { - if( fl_get_button(paths_->check_last_files) ) { + if (!ob || ob == paths_->check_last_files) { + if (fl_get_button(paths_->check_last_files)) { fl_activate_object(paths_->input_lastfiles); fl_set_object_lcol(paths_->input_lastfiles, FL_BLACK); @@ -1252,8 +1253,8 @@ bool FormPreferences::inputPaths( FL_OBJECT const * const ob ) } } - if( !ob || ob == paths_->check_make_backups ) { - if( fl_get_button(paths_->check_make_backups) ) { + if (!ob || ob == paths_->check_make_backups) { + if (fl_get_button(paths_->check_make_backups)) { fl_activate_object(paths_->input_backup_path); fl_set_object_lcol(paths_->input_backup_path, FL_BLACK); @@ -1264,48 +1265,48 @@ bool FormPreferences::inputPaths( FL_OBJECT const * const ob ) } } - if( !ob || ob == paths_->input_default_path ) { + if (!ob || ob == paths_->input_default_path) { string name = fl_get_input(paths_->input_default_path); - if( !WriteableDir(name) ) + if (!WriteableDir(name) ) return false; } - if( !ob || ob == paths_->input_template_path ) { + if (!ob || ob == paths_->input_template_path) { string name = fl_get_input(paths_->input_template_path); - if( !ReadableDir(name) ) + if (!ReadableDir(name) ) return false; } - if( !ob || ob == paths_->input_temp_dir ) { + if (!ob || ob == paths_->input_temp_dir) { string name = fl_get_input(paths_->input_temp_dir); - if( fl_get_button(paths_->check_make_backups) + if (fl_get_button(paths_->check_make_backups) && !name.empty() && !WriteableDir(name) ) return false; } - if( !ob || ob == paths_->input_backup_path ) { + if (!ob || ob == paths_->input_backup_path) { string name = fl_get_input(paths_->input_backup_path); - if( fl_get_button(paths_->check_make_backups) + if (fl_get_button(paths_->check_make_backups) && !name.empty() && !WriteableDir(name) ) return false; } - if( !ob || ob == paths_->input_lastfiles ) { + if (!ob || ob == paths_->input_lastfiles) { string name = fl_get_input(paths_->input_lastfiles); - if( fl_get_button(paths_->check_last_files) + if (fl_get_button(paths_->check_last_files) && !name.empty() && !WriteableFile(name) ) return false; } - if( !ob || ob == paths_->input_serverpipe ) { + if (!ob || ob == paths_->input_serverpipe) { string name = fl_get_input(paths_->input_serverpipe); - if( !name.empty() ) { - if( !WriteableFile(name, ".in") ) + if (!name.empty()) { + if (!WriteableFile(name, ".in")) return false; - if( !WriteableFile(name, ".out") ) + if (!WriteableFile(name, ".out")) return false; } } @@ -1321,22 +1322,22 @@ void FormPreferences::updatePaths() fl_set_input(paths_->input_template_path, lyxrc.template_path.c_str()); - string str = string(); - if( lyxrc.make_backup ) str = lyxrc.backupdir_path; + string str; + if (lyxrc.make_backup) str = lyxrc.backupdir_path; fl_set_button(paths_->check_make_backups, lyxrc.make_backup); fl_set_input(paths_->input_backup_path, str.c_str()); str.erase(); - if( lyxrc.use_tempdir ) str = lyxrc.tempdir_path; + if (lyxrc.use_tempdir) str = lyxrc.tempdir_path; fl_set_button(paths_->check_use_temp_dir, lyxrc.use_tempdir); fl_set_input(paths_->input_temp_dir, str.c_str()); str.erase(); - if( lyxrc.check_lastfiles ) str = lyxrc.lastfiles; + if (lyxrc.check_lastfiles) str = lyxrc.lastfiles; fl_set_button(paths_->check_last_files, lyxrc.check_lastfiles); @@ -1380,45 +1381,45 @@ void FormPreferences::applyPrinter() const } -string FormPreferences::feedbackPrinter( FL_OBJECT const * const ob ) const +string const FormPreferences::feedbackPrinter(FL_OBJECT const * const ob) const { string str; - if( ob == printer_->input_command ) + if (ob == printer_->input_command ) str = lyxrc.getDescription( LyXRC::RC_PRINT_COMMAND ); - else if( ob == printer_->check_adapt_output ) + else if (ob == printer_->check_adapt_output ) str = lyxrc.getDescription( LyXRC::RC_PRINT_ADAPTOUTPUT ); - else if( ob == printer_->input_to_printer ) + else if (ob == printer_->input_to_printer ) str = lyxrc.getDescription( LyXRC::RC_PRINTTOPRINTER ); - else if( ob == printer_->input_to_file ) + else if (ob == printer_->input_to_file ) str = lyxrc.getDescription( LyXRC::RC_PRINTTOFILE ); - else if( ob == printer_->input_file_extension ) + else if (ob == printer_->input_file_extension ) str = lyxrc.getDescription( LyXRC::RC_PRINTFILEEXTENSION ); - else if( ob == printer_->input_extra_options ) + else if (ob == printer_->input_extra_options ) str = lyxrc.getDescription( LyXRC::RC_PRINTEXSTRAOPTIONS ); - else if( ob == printer_->input_spool_command ) + else if (ob == printer_->input_spool_command ) str = lyxrc.getDescription( LyXRC::RC_PRINTSPOOL_COMMAND ); - else if( ob == printer_->input_spool_prefix ) + else if (ob == printer_->input_spool_prefix ) str = lyxrc.getDescription( LyXRC::RC_PRINTSPOOL_PRINTERPREFIX ); - else if( ob == printer_->input_name ) + else if (ob == printer_->input_name ) str = lyxrc.getDescription( LyXRC::RC_PRINTER ); - else if( ob == printer_->input_even_pages ) + else if (ob == printer_->input_even_pages ) str = lyxrc.getDescription( LyXRC::RC_PRINTEVENPAGEFLAG ); - else if( ob == printer_->input_odd_pages ) + else if (ob == printer_->input_odd_pages ) str = lyxrc.getDescription( LyXRC::RC_PRINTODDPAGEFLAG ); - else if( ob == printer_->input_page_range ) + else if (ob == printer_->input_page_range ) str = lyxrc.getDescription( LyXRC::RC_PRINTPAGERANGEFLAG ); - else if( ob == printer_->input_reverse ) + else if (ob == printer_->input_reverse ) str = lyxrc.getDescription( LyXRC::RC_PRINTREVERSEFLAG ); - else if( ob == printer_->input_landscape ) + else if (ob == printer_->input_landscape ) str = lyxrc.getDescription( LyXRC::RC_PRINTLANDSCAPEFLAG ); - else if( ob == printer_->input_copies ) + else if (ob == printer_->input_copies ) str = lyxrc.getDescription( LyXRC::RC_PRINTCOLLCOPIESFLAG ); - else if( ob == printer_->input_collated ) + else if (ob == printer_->input_collated ) str = lyxrc.getDescription( LyXRC::RC_PRINTCOPIESFLAG ); - else if( ob == printer_->input_paper_type ) + else if (ob == printer_->input_paper_type ) str = lyxrc.getDescription( LyXRC::RC_PRINTPAPERFLAG ); - else if( ob == printer_->input_paper_size ) + else if (ob == printer_->input_paper_size ) str = lyxrc.getDescription( LyXRC::RC_PRINTPAPERDIMENSIONFLAG ); return str; @@ -1519,38 +1520,38 @@ void FormPreferences::applyScreenFonts() const bool changed = false; string str = fl_get_input(screen_fonts_->input_roman); - if( lyxrc.roman_font_name != str ) { + if (lyxrc.roman_font_name != str) { changed = true; lyxrc.roman_font_name = str; } str = fl_get_input(screen_fonts_->input_sans); - if( lyxrc.sans_font_name != str ) { + if (lyxrc.sans_font_name != str) { changed = true; lyxrc.sans_font_name = str; } str = fl_get_input(screen_fonts_->input_typewriter); - if( lyxrc.typewriter_font_name != str ) { + if (lyxrc.typewriter_font_name != str) { changed = true; lyxrc.typewriter_font_name = str; } str = fl_get_input(screen_fonts_->input_screen_encoding); - if( lyxrc.font_norm != str ) { + if (lyxrc.font_norm != str) { changed = true; lyxrc.font_norm = str; } bool button = fl_get_button(screen_fonts_->check_scalable); - if( lyxrc.use_scalable_fonts != button ) { + if (lyxrc.use_scalable_fonts != button) { changed = true; lyxrc.use_scalable_fonts = button; } unsigned int ivalue = static_cast (fl_get_counter_value(screen_fonts_->counter_zoom)); - if( lyxrc.zoom != ivalue) { + if (lyxrc.zoom != ivalue) { changed = true; lyxrc.zoom = ivalue; } @@ -1563,66 +1564,66 @@ void FormPreferences::applyScreenFonts() const } double dvalue = strToDbl(fl_get_input(screen_fonts_->input_tiny)); - if( lyxrc.font_sizes[LyXFont::SIZE_TINY] != dvalue ) { + if (lyxrc.font_sizes[LyXFont::SIZE_TINY] != dvalue) { changed = true; lyxrc.font_sizes[LyXFont::SIZE_TINY] = dvalue; } dvalue = strToDbl(fl_get_input(screen_fonts_->input_script)); - if( lyxrc.font_sizes[LyXFont::SIZE_SCRIPT] != dvalue ) { + if (lyxrc.font_sizes[LyXFont::SIZE_SCRIPT] != dvalue) { changed = true; lyxrc.font_sizes[LyXFont::SIZE_SCRIPT] = dvalue; } dvalue = strToDbl(fl_get_input(screen_fonts_->input_footnote)); - if( lyxrc.font_sizes[LyXFont::SIZE_FOOTNOTE] != dvalue ) { + if (lyxrc.font_sizes[LyXFont::SIZE_FOOTNOTE] != dvalue) { changed = true; lyxrc.font_sizes[LyXFont::SIZE_FOOTNOTE] = dvalue; } dvalue = strToDbl(fl_get_input(screen_fonts_->input_small)); - if( lyxrc.font_sizes[LyXFont::SIZE_SMALL] != dvalue ) { + if (lyxrc.font_sizes[LyXFont::SIZE_SMALL] != dvalue) { changed = true; lyxrc.font_sizes[LyXFont::SIZE_SMALL] = dvalue; } dvalue = strToDbl(fl_get_input(screen_fonts_->input_normal)); - if( lyxrc.font_sizes[LyXFont::SIZE_NORMAL] != dvalue ) { + if (lyxrc.font_sizes[LyXFont::SIZE_NORMAL] != dvalue) { changed = true; lyxrc.font_sizes[LyXFont::SIZE_NORMAL] = dvalue; } dvalue = strToDbl(fl_get_input(screen_fonts_->input_large)); - if( lyxrc.font_sizes[LyXFont::SIZE_LARGE] != dvalue ) { + if (lyxrc.font_sizes[LyXFont::SIZE_LARGE] != dvalue) { changed = true; lyxrc.font_sizes[LyXFont::SIZE_LARGE] = dvalue; } dvalue = strToDbl(fl_get_input(screen_fonts_->input_larger)); - if( lyxrc.font_sizes[LyXFont::SIZE_LARGER] != dvalue ) { + if (lyxrc.font_sizes[LyXFont::SIZE_LARGER] != dvalue) { changed = true; lyxrc.font_sizes[LyXFont::SIZE_LARGER] = dvalue; } dvalue = strToDbl(fl_get_input(screen_fonts_->input_largest)); - if( lyxrc.font_sizes[LyXFont::SIZE_LARGEST] != dvalue ) { + if (lyxrc.font_sizes[LyXFont::SIZE_LARGEST] != dvalue) { changed = true; lyxrc.font_sizes[LyXFont::SIZE_LARGEST] = dvalue; } dvalue = strToDbl(fl_get_input(screen_fonts_->input_huge)); - if( lyxrc.font_sizes[LyXFont::SIZE_HUGE] != dvalue ) { + if (lyxrc.font_sizes[LyXFont::SIZE_HUGE] != dvalue) { changed = true; lyxrc.font_sizes[LyXFont::SIZE_HUGE] = dvalue; } dvalue = strToDbl(fl_get_input(screen_fonts_->input_huger)); - if( lyxrc.font_sizes[LyXFont::SIZE_HUGER] != dvalue ) { + if (lyxrc.font_sizes[LyXFont::SIZE_HUGER] != dvalue) { changed = true; lyxrc.font_sizes[LyXFont::SIZE_HUGER] = dvalue; } - if( changed ) { + if (changed) { // Now update the buffers // Can anything below here affect the redraw process? lv_->getLyXFunc()->Dispatch(LFUN_SCREEN_FONT_UPDATE); @@ -1699,25 +1700,26 @@ void FormPreferences::buildScreenFonts() } -string FormPreferences::feedbackScreenFonts(FL_OBJECT const * const ob ) const +string const +FormPreferences::feedbackScreenFonts(FL_OBJECT const * const ob ) const { string str; - if( ob == screen_fonts_->input_roman ) + if (ob == screen_fonts_->input_roman ) str = lyxrc.getDescription( LyXRC::RC_SCREEN_FONT_ROMAN ); - else if( ob == screen_fonts_->input_sans ) + else if (ob == screen_fonts_->input_sans ) str = lyxrc.getDescription( LyXRC::RC_SCREEN_FONT_SANS ); - else if( ob == screen_fonts_->input_typewriter ) + else if (ob == screen_fonts_->input_typewriter ) str = lyxrc.getDescription( LyXRC::RC_SCREEN_FONT_TYPEWRITER ); - else if( ob == screen_fonts_->check_scalable ) + else if (ob == screen_fonts_->check_scalable ) str = lyxrc.getDescription( LyXRC::RC_SCREEN_FONT_SCALABLE ); - else if( ob == screen_fonts_->input_screen_encoding ) + else if (ob == screen_fonts_->input_screen_encoding ) str = lyxrc.getDescription( LyXRC::RC_SCREEN_FONT_ENCODING ); - else if( ob == screen_fonts_->counter_zoom ) + else if (ob == screen_fonts_->counter_zoom ) str = lyxrc.getDescription( LyXRC::RC_SCREEN_ZOOM ); - else if( ob == screen_fonts_->counter_dpi ) + else if (ob == screen_fonts_->counter_dpi ) str = lyxrc.getDescription( LyXRC::RC_SCREEN_DPI ); - else if( ob == screen_fonts_->input_tiny + else if (ob == screen_fonts_->input_tiny || ob == screen_fonts_->input_script || ob == screen_fonts_->input_footnote || ob == screen_fonts_->input_small @@ -1778,7 +1780,7 @@ bool FormPreferences::inputScreenFonts() str = N_("WARNING! Fonts must be input in the order tiny > script>\nfootnote > small > normal > large > larger > largest > huge > huger."); } - if( !activate ) { + if (!activate) { fl_set_object_label(dialog_->text_warning, str.c_str()); fl_set_object_lsize(dialog_->text_warning, FL_SMALL_SIZE); } @@ -1828,7 +1830,7 @@ void FormPreferences::applySpellChecker() { string choice = "none"; - switch(fl_get_choice(spellchecker_->choice_spell_command)) { + switch (fl_get_choice(spellchecker_->choice_spell_command)) { case 1: choice = "none"; break; @@ -1844,7 +1846,7 @@ void FormPreferences::applySpellChecker() lyxrc.isp_command = choice; // If spell checker == "none", all other input set to off. - if( fl_get_choice(spellchecker_->choice_spell_command) == 1 ) { + if (fl_get_choice(spellchecker_->choice_spell_command) == 1) { lyxrc.isp_use_alt_lang = false; lyxrc.isp_alt_lang.erase(); @@ -1859,24 +1861,24 @@ void FormPreferences::applySpellChecker() } else { int button = fl_get_button(spellchecker_->check_alt_lang); choice = fl_get_input(spellchecker_->input_alt_lang); - if( button && choice.empty() ) button = 0; - if( !button ) choice.erase(); + if (button && choice.empty() ) button = 0; + if (!button ) choice.erase(); lyxrc.isp_use_alt_lang = static_cast(button); lyxrc.isp_alt_lang = choice; button = fl_get_button(spellchecker_->check_escape_chars); choice = fl_get_input(spellchecker_->input_escape_chars); - if( button && choice.empty() ) button = 0; - if( !button ) choice.erase(); + if (button && choice.empty() ) button = 0; + if (!button ) choice.erase(); lyxrc.isp_use_esc_chars = static_cast(button); lyxrc.isp_esc_chars = choice; button = fl_get_button(spellchecker_->check_personal_dict); choice = fl_get_input(spellchecker_->input_personal_dict); - if( button && choice.empty() ) button = 0; - if( !button ) choice.erase(); + if (button && choice.empty() ) button = 0; + if (!button ) choice.erase(); lyxrc.isp_use_pers_dict = static_cast(button); lyxrc.isp_pers_dict = choice; @@ -1929,27 +1931,28 @@ void FormPreferences::buildSpellchecker() } -string FormPreferences::feedbackSpellChecker( FL_OBJECT const * const ob ) const +string const +FormPreferences::feedbackSpellChecker(FL_OBJECT const * const ob) const { string str; - if( ob == spellchecker_->choice_spell_command ) + if (ob == spellchecker_->choice_spell_command ) str = lyxrc.getDescription( LyXRC::RC_SPELL_COMMAND ); - else if( ob == spellchecker_->check_alt_lang ) + else if (ob == spellchecker_->check_alt_lang ) str = lyxrc.getDescription( LyXRC::RC_USE_ALT_LANG ); - else if( ob == spellchecker_->input_alt_lang ) + else if (ob == spellchecker_->input_alt_lang ) str = lyxrc.getDescription( LyXRC::RC_ALT_LANG ); - else if( ob == spellchecker_->check_escape_chars ) + else if (ob == spellchecker_->check_escape_chars ) str = lyxrc.getDescription( LyXRC::RC_USE_ESC_CHARS ); - else if( ob == spellchecker_->input_escape_chars ) + else if (ob == spellchecker_->input_escape_chars ) str = lyxrc.getDescription( LyXRC::RC_ESC_CHARS ); - else if( ob == spellchecker_->check_personal_dict ) + else if (ob == spellchecker_->check_personal_dict ) str = lyxrc.getDescription( LyXRC::RC_USE_PERS_DICT ); - else if( ob == spellchecker_->input_personal_dict ) + else if (ob == spellchecker_->input_personal_dict ) str = lyxrc.getDescription( LyXRC::RC_PERS_DICT ); - else if( ob == spellchecker_->check_compound_words ) + else if (ob == spellchecker_->check_compound_words ) str = lyxrc.getDescription( LyXRC::RC_ACCEPT_COMPOUND ); - else if( ob == spellchecker_->check_input_enc ) + else if (ob == spellchecker_->check_input_enc ) str = lyxrc.getDescription( LyXRC::RC_USE_INP_ENC ); return str; @@ -1961,8 +1964,8 @@ bool FormPreferences::inputSpellChecker( FL_OBJECT const * const ob ) // Allow/dissallow input // If spell checker == "none", disable all input. - if( !ob || ob == spellchecker_->choice_spell_command ) { - if( fl_get_choice(spellchecker_->choice_spell_command) == 1 ) { + if (!ob || ob == spellchecker_->choice_spell_command) { + if (fl_get_choice(spellchecker_->choice_spell_command) == 1) { fl_deactivate_object( spellchecker_->check_alt_lang ); fl_deactivate_object( spellchecker_->input_alt_lang ); fl_deactivate_object( spellchecker_->check_escape_chars ); @@ -1981,8 +1984,8 @@ bool FormPreferences::inputSpellChecker( FL_OBJECT const * const ob ) } } - if( !ob || ob == spellchecker_->check_alt_lang ) { - if( fl_get_button(spellchecker_->check_alt_lang) ) { + if (!ob || ob == spellchecker_->check_alt_lang) { + if (fl_get_button(spellchecker_->check_alt_lang)) { fl_activate_object(spellchecker_->input_alt_lang); fl_set_object_lcol(spellchecker_->input_alt_lang, FL_BLACK); @@ -1993,8 +1996,8 @@ bool FormPreferences::inputSpellChecker( FL_OBJECT const * const ob ) } } - if( !ob || ob == spellchecker_->check_escape_chars ) { - if( fl_get_button(spellchecker_->check_escape_chars) ) { + if (!ob || ob == spellchecker_->check_escape_chars) { + if (fl_get_button(spellchecker_->check_escape_chars)) { fl_activate_object(spellchecker_->input_escape_chars); fl_set_object_lcol(spellchecker_->input_escape_chars, FL_BLACK); @@ -2005,8 +2008,8 @@ bool FormPreferences::inputSpellChecker( FL_OBJECT const * const ob ) } } - if( !ob || ob == spellchecker_->check_personal_dict ) { - if( fl_get_button(spellchecker_->check_personal_dict) ) { + if (!ob || ob == spellchecker_->check_personal_dict) { + if (fl_get_button(spellchecker_->check_personal_dict)) { fl_activate_object(spellchecker_->input_personal_dict); fl_set_object_lcol(spellchecker_->input_personal_dict, FL_BLACK); @@ -2024,30 +2027,30 @@ bool FormPreferences::inputSpellChecker( FL_OBJECT const * const ob ) void FormPreferences::updateSpellChecker() { int choice = 1; - if( lyxrc.isp_command == "none" ) + if (lyxrc.isp_command == "none" ) choice = 1; - else if( lyxrc.isp_command == "ispell" ) + else if (lyxrc.isp_command == "ispell" ) choice = 2; - else if( lyxrc.isp_command == "aspell" ) + else if (lyxrc.isp_command == "aspell" ) choice = 3; fl_set_choice(spellchecker_->choice_spell_command, choice); string str = string(); - if( lyxrc.isp_use_alt_lang ) str = lyxrc.isp_alt_lang; + if (lyxrc.isp_use_alt_lang ) str = lyxrc.isp_alt_lang; fl_set_button(spellchecker_->check_alt_lang, lyxrc.isp_use_alt_lang); fl_set_input(spellchecker_->input_alt_lang, str.c_str()); str.erase(); - if( lyxrc.isp_use_esc_chars ) str = lyxrc.isp_esc_chars; + if (lyxrc.isp_use_esc_chars ) str = lyxrc.isp_esc_chars; fl_set_button(spellchecker_->check_escape_chars, lyxrc.isp_use_esc_chars); fl_set_input(spellchecker_->input_escape_chars, str.c_str()); str.erase(); - if( lyxrc.isp_use_pers_dict ) str = lyxrc.isp_pers_dict; + if (lyxrc.isp_use_pers_dict ) str = lyxrc.isp_pers_dict; fl_set_button(spellchecker_->check_personal_dict, lyxrc.isp_use_pers_dict); @@ -2069,23 +2072,23 @@ bool FormPreferences::WriteableDir( string const & name ) const bool success = true; string str; - if( !AbsolutePath(name) ) { + if (!AbsolutePath(name)) { success = false; str = N_("WARNING! The absolute path is required."); } - FileInfo tp(name); - if( success && !tp.isDir() ) { + FileInfo const tp(name); + if (success && !tp.isDir()) { success = false; str = N_("WARNING! Directory does not exist."); } - if( success && !tp.writable() ) { + if (success && !tp.writable()) { success = false; str = N_("WARNING! Cannot write to this directory."); } - if( !success ) { + if (!success) { fl_set_object_label(dialog_->text_warning, str.c_str()); fl_set_object_lsize(dialog_->text_warning, FL_SMALL_SIZE); } @@ -2099,23 +2102,23 @@ bool FormPreferences::ReadableDir( string const & name ) const bool success = true; string str; - if( !AbsolutePath(name) ) { + if (!AbsolutePath(name)) { success = false; str = N_("WARNING! The absolute path is required."); } - FileInfo tp(name); - if( success && !tp.isDir() ) { + FileInfo const tp(name); + if (success && !tp.isDir()) { success = false; str = N_("WARNING! Directory does not exist."); } - if( success && !tp.readable() ) { + if (success && !tp.readable()) { success = false; str = N_("WARNING! Cannot read this directory."); } - if( !success ) { + if (!success) { fl_set_object_label(dialog_->text_warning, str.c_str()); fl_set_object_lsize(dialog_->text_warning, FL_SMALL_SIZE); } @@ -2124,7 +2127,8 @@ bool FormPreferences::ReadableDir( string const & name ) const } -bool FormPreferences::WriteableFile( string const & name, string const & suffix ) const +bool FormPreferences::WriteableFile(string const & name, + string const & suffix) const { // A writeable file is either: // * An existing file to which we have write access, or @@ -2134,49 +2138,58 @@ bool FormPreferences::WriteableFile( string const & name, string const & suffix bool success = true; string str; - if( name.empty() ) { + if (name.empty()) { success = false; str = N_("WARNING! No file input."); } - string dir = OnlyPath(name); - if( success && !AbsolutePath(dir) ) { + string const dir = OnlyPath(name); + if (success && !AbsolutePath(dir)) { success = false; str = N_("WARNING! The absolute path is required."); } + // This is not a nice way to use FileInfo (Lgb) +#if 0 FileInfo d; + { FileInfo d1(dir); FileInfo d2(name); - if( d2.isDir() ) + if (d2.isDir() ) d = d2; else d = d1; } - - if( success && !d.isDir()) { +#else + // This should be equivalent (Lgb) + FileInfo d(name); + if (!d.isDir()) { + d.newFile(dir); + } +#endif + if (success && !d.isDir()) { success = false; str = N_("WARNING! Directory does not exist."); } - if( success && !d.writable() ) { + if (success && !d.writable()) { success = false; str = N_("WARNING! Cannot write to this directory."); } FileInfo f(name+suffix); - if( success && (dir == name || f.isDir()) ) { + if (success && (dir == name || f.isDir())) { success = false; str = N_("WARNING! A file is required, not a directory."); } - if( success && (f.exist() && !f.writable()) ) { + if (success && (f.exist() && !f.writable())) { success = false; str = N_("WARNING! Cannot write to this file."); } - if( !success ) { + if (!success) { fl_set_object_label(dialog_->text_warning, str.c_str()); fl_set_object_lsize(dialog_->text_warning, FL_SMALL_SIZE); } @@ -2197,6 +2210,7 @@ void FormPreferences::ComboLanguageCB(int, void * v, Combox * combox) // C functions for the timer callback used to give the user feedback C_GENERICCB(FormPreferences, FeedbackCB) + void FormPreferences::FeedbackCB(FL_OBJECT * ob, long) { FormPreferences * pre = @@ -2204,13 +2218,15 @@ void FormPreferences::FeedbackCB(FL_OBJECT * ob, long) pre->feedback( pre->feedbackObj ); } -extern "C" int C_FormPreferencesFeedbackPost(FL_OBJECT * ob, int event, - FL_Coord, FL_Coord, int, void *) + +extern "C" +int C_FormPreferencesFeedbackPost(FL_OBJECT * ob, int event, + FL_Coord, FL_Coord, int, void *) { // can occur when form is being deleted. This seems an easier fix than // a call "fl_set_object_posthandler(ob, 0)" for each and every object // in the destructor. - if( !ob->form ) return 0; + if (!ob->form ) return 0; FormPreferences * pre = static_cast(ob->form->u_vdata); @@ -2220,10 +2236,10 @@ extern "C" int C_FormPreferencesFeedbackPost(FL_OBJECT * ob, int event, // post_handler for feedback messages -void FormPreferences::feedbackPost(FL_OBJECT *ob, int event) +void FormPreferences::feedbackPost(FL_OBJECT * ob, int event) { // We do not test for empty help here, since this can never happen - if(event == FL_ENTER){ + if (event == FL_ENTER){ // Used as a placeholder for ob, so that we don't have to // a horrible reinterpret_cast to long and pass it as an // argument in fl_set_object_callback. @@ -2233,7 +2249,7 @@ void FormPreferences::feedbackPost(FL_OBJECT *ob, int event) 0); fl_set_timer(dialog_->timer_feedback, 0.5); } - else if(event != FL_MOTION){ + else if (event != FL_MOTION){ fl_set_timer(dialog_->timer_feedback, 0); feedbackObj = 0; fl_set_object_label(dialog_->text_warning, ""); @@ -2241,7 +2257,7 @@ void FormPreferences::feedbackPost(FL_OBJECT *ob, int event) } -void FormPreferences::setPostHandler( FL_OBJECT * ob ) const +void FormPreferences::setPostHandler(FL_OBJECT * ob) const { fl_set_object_posthandler(ob, C_FormPreferencesFeedbackPost); } diff --git a/src/frontends/xforms/FormPreferences.h b/src/frontends/xforms/FormPreferences.h index 99e50a30cf..8abec739bd 100644 --- a/src/frontends/xforms/FormPreferences.h +++ b/src/frontends/xforms/FormPreferences.h @@ -64,10 +64,6 @@ public: int b; RGB() : r(0), g(0), b(0) {} RGB(int red, int green, int blue) : r(red), g(green), b(blue) {} - bool operator==(RGB const & o) const - { return( r == o.r && g == o.g && b == o.b ); } - bool operator!=(RGB const & o) const - { return( r != o.r || g != o.g || b != o.b ); } }; private: @@ -148,29 +144,29 @@ private: */ /// - string feedbackColours(FL_OBJECT const * const) const; + string const feedbackColours(FL_OBJECT const * const) const; /// - string feedbackConverters(FL_OBJECT const * const) const; + string const feedbackConverters(FL_OBJECT const * const) const; /// - string feedbackFormats( FL_OBJECT const * const ) const; + string const feedbackFormats( FL_OBJECT const * const ) const; /// - string feedbackInputsMisc(FL_OBJECT const * const) const; + string const feedbackInputsMisc(FL_OBJECT const * const) const; /// - string feedbackInterface(FL_OBJECT const * const) const; + string const feedbackInterface(FL_OBJECT const * const) const; /// - string feedbackLanguage(FL_OBJECT const * const) const; + string const feedbackLanguage(FL_OBJECT const * const) const; /// - string feedbackLnFmisc(FL_OBJECT const * const) const; + string const feedbackLnFmisc(FL_OBJECT const * const) const; /// - string feedbackOutputsMisc(FL_OBJECT const * const) const; + string const feedbackOutputsMisc(FL_OBJECT const * const) const; /// - string feedbackPaths(FL_OBJECT const * const) const; + string const feedbackPaths(FL_OBJECT const * const) const; /// - string feedbackPrinter(FL_OBJECT const * const) const; + string const feedbackPrinter(FL_OBJECT const * const) const; /// - string feedbackScreenFonts(FL_OBJECT const * const) const; + string const feedbackScreenFonts(FL_OBJECT const * const) const; /// - string feedbackSpellChecker(FL_OBJECT const * const) const; + string const feedbackSpellChecker(FL_OBJECT const * const) const; /** Folder specific input functions. Not all folders require one. */ @@ -282,10 +278,10 @@ private: /// Spellchecker, language stuff, etc FD_form_outer_tab * usage_tab_; /// - FD_form_converters * converters_; - /// FD_form_colours * colours_; /// + FD_form_converters * converters_; + /// FD_form_formats * formats_; /// FD_form_inputs_misc * inputs_misc_; @@ -315,4 +311,20 @@ private: FL_OBJECT * feedbackObj; }; + +inline +bool operator==(FormPreferences::RGB const & c1, + FormPreferences::RGB const & c2) +{ + return (c1.r == c2.r && c1.g == c2.g && c1.b == c2.b); +} + + +inline +bool operator!=(FormPreferences::RGB const & c1, + FormPreferences::RGB const & c2) +{ + return !(c1 == c2); +} + #endif diff --git a/src/frontends/xforms/FormRef.C b/src/frontends/xforms/FormRef.C index fafb1475ec..09ac1375a5 100644 --- a/src/frontends/xforms/FormRef.C +++ b/src/frontends/xforms/FormRef.C @@ -52,7 +52,7 @@ FormRef::~FormRef() FL_FORM * FormRef::form() const { - if ( dialog_ ) return dialog_->form; + if (dialog_ ) return dialog_->form; return 0; } @@ -84,7 +84,7 @@ void FormRef::build() minw_sb = minw_; // Name is irrelevant to LaTeX documents - if ( lv_->buffer()->isLatex() ) { + if (lv_->buffer()->isLatex()) { fl_deactivate_object( dialog_->name ); fl_set_object_lcol( dialog_->name, FL_INACTIVE ); } @@ -111,7 +111,7 @@ void FormRef::update() fl_set_object_label(dialog_->button_go, _("Goto reference")); refs.clear(); - if ( inset_ == 0 ) { + if (inset_ == 0) { refs = lv_->buffer()->getLabelList(); updateBrowser( refs ); showBrowser(); @@ -124,15 +124,15 @@ void FormRef::update() void FormRef::updateBrowser( vector keys ) const { - if ( fl_get_button( dialog_->sort ) ) + if (fl_get_button( dialog_->sort ) ) sort( keys.begin(), keys.end() ); fl_clear_browser( dialog_->browser ); - for( vector::const_iterator it = keys.begin(); + for (vector::const_iterator it = keys.begin(); it != keys.end(); ++it ) fl_add_browser_line( dialog_->browser, (*it).c_str()); - if ( keys.empty() ) { + if (keys.empty()) { fl_add_browser_line( dialog_->browser, _("*** No labels found in document ***")); @@ -203,7 +203,7 @@ void FormRef::setSize( int w, int dx ) const static int x6 = dialog_->button_cancel->x; static int y6 = dialog_->button_cancel->y; - if ( form()->w != w ) { + if (form()->w != w) { minw_ = w; fl_set_form_size( form(), minw_, minh_ ); } else @@ -218,7 +218,7 @@ void FormRef::setSize( int w, int dx ) const // These two must be reset apparently // Name is irrelevant to LaTeX documents - if ( lv_->buffer()->isLatex() ) { + if (lv_->buffer()->isLatex()) { fl_deactivate_object( dialog_->name ); fl_set_object_lcol( dialog_->name, FL_INACTIVE ); } @@ -259,12 +259,12 @@ void FormRef::apply() bool FormRef::input( FL_OBJECT *, long data ) { bool activate( true ); - switch( data ) { + switch (data) { // goto reference / go back case 1: { toggle = static_cast(toggle + 1); - if ( toggle == GOFIRST ) toggle = GOREF; + if (toggle == GOFIRST ) toggle = GOREF; switch (toggle) { case GOREF: @@ -294,7 +294,7 @@ bool FormRef::input( FL_OBJECT *, long data ) case 2: { unsigned int sel = fl_get_browser( dialog_->browser ); - if ( sel < 1 || sel > refs.size() ) break; + if (sel < 1 || sel > refs.size() ) break; string s = fl_get_browser_line( dialog_->browser, sel ); fl_set_input( dialog_->ref, s.c_str()); @@ -326,8 +326,8 @@ bool FormRef::input( FL_OBJECT *, long data ) { Type type = static_cast( fl_get_choice(dialog_->type) - 1 ); - if ( params.getCmdName() == getName( type ) - && inset_ ) { + if (params.getCmdName() == getName( type ) + && inset_) { activate = false; } } @@ -344,16 +344,16 @@ FormRef::Type FormRef::getType() const { Type type; - if ( params.getCmdName() == "ref" ) + if (params.getCmdName() == "ref" ) type = REF; - else if ( params.getCmdName() == "pageref" ) + else if (params.getCmdName() == "pageref" ) type = PAGEREF; - else if ( params.getCmdName() == "vref" ) + else if (params.getCmdName() == "vref" ) type = VREF; - else if ( params.getCmdName() == "vpageref" ) + else if (params.getCmdName() == "vpageref" ) type = VPAGEREF; else @@ -367,7 +367,7 @@ string FormRef::getName( Type type ) const { string name; - switch( type ) { + switch (type) { case REF: name = "ref"; break; diff --git a/src/frontends/xforms/FormTabular.C b/src/frontends/xforms/FormTabular.C index 4c7806d7e1..56d12593f5 100644 --- a/src/frontends/xforms/FormTabular.C +++ b/src/frontends/xforms/FormTabular.C @@ -48,7 +48,7 @@ FormTabular::~FormTabular() FL_FORM * FormTabular::form() const { - if ( dialog_ ) return dialog_->form; + if (dialog_ ) return dialog_->form; return 0; } diff --git a/src/frontends/xforms/FormTabularCreate.C b/src/frontends/xforms/FormTabularCreate.C index 80f189ad0f..3789fb21af 100644 --- a/src/frontends/xforms/FormTabularCreate.C +++ b/src/frontends/xforms/FormTabularCreate.C @@ -44,7 +44,7 @@ FormTabularCreate::~FormTabularCreate() FL_FORM * FormTabularCreate::form() const { - if ( dialog_ ) return dialog_->form; + if (dialog_ ) return dialog_->form; return 0; } diff --git a/src/frontends/xforms/FormToc.C b/src/frontends/xforms/FormToc.C index 40ca12b595..d9d22d728a 100644 --- a/src/frontends/xforms/FormToc.C +++ b/src/frontends/xforms/FormToc.C @@ -51,7 +51,7 @@ FormToc::~FormToc() FL_FORM * FormToc::form() const { - if ( dialog_ ) return dialog_->form; + if (dialog_ ) return dialog_->form; return 0; } @@ -82,13 +82,13 @@ void FormToc::update() { Buffer::TocType type; - if ( params.getCmdName() == "tableofcontents" ) + if (params.getCmdName() == "tableofcontents" ) type = Buffer::TOC_TOC; - else if ( params.getCmdName() == "listofalgorithms" ) + else if (params.getCmdName() == "listofalgorithms" ) type = Buffer::TOC_LOA; - else if ( params.getCmdName() == "listoffigures" ) + else if (params.getCmdName() == "listoffigures" ) type = Buffer::TOC_LOF; else diff --git a/src/frontends/xforms/FormUrl.C b/src/frontends/xforms/FormUrl.C index fc0ac2b40a..9078536b71 100644 --- a/src/frontends/xforms/FormUrl.C +++ b/src/frontends/xforms/FormUrl.C @@ -44,7 +44,7 @@ FormUrl::~FormUrl() FL_FORM * FormUrl::form() const { - if ( dialog_ ) return dialog_->form; + if (dialog_ ) return dialog_->form; return 0; } @@ -74,12 +74,12 @@ void FormUrl::update() fl_set_input(dialog_->url, params.getContents().c_str()); fl_set_input(dialog_->name, params.getOptions().c_str()); - if ( params.getCmdName() == "url" ) + if (params.getCmdName() == "url" ) fl_set_button(dialog_->radio_html, 0); else fl_set_button(dialog_->radio_html, 1); - if ( lv_->buffer()->isReadonly() ) { + if (lv_->buffer()->isReadonly()) { fl_deactivate_object( dialog_->url ); fl_deactivate_object( dialog_->name ); fl_deactivate_object( dialog_->radio_html ); diff --git a/src/frontends/xforms/Menubar_pimpl.C b/src/frontends/xforms/Menubar_pimpl.C index 483af3bbad..07fc2cabbf 100644 --- a/src/frontends/xforms/Menubar_pimpl.C +++ b/src/frontends/xforms/Menubar_pimpl.C @@ -64,7 +64,7 @@ int string_width(string const & str) Menubar::Pimpl::Pimpl(LyXView * view, MenuBackend const & mb) : owner_(view), menubackend_(&mb), current_group_(0) { - for(MenuBackend::const_iterator menu = menubackend_->begin(); + for (MenuBackend::const_iterator menu = menubackend_->begin(); menu != menubackend_->end() ; ++menu) { if (menu->menubar()) { FL_OBJECT * group = fl_bgn_group(); @@ -169,7 +169,7 @@ void Menubar::Pimpl::set(string const & menu_name) void Menubar::Pimpl::openByName(string const & name) { - for(ButtonList::const_iterator cit = buttonlist_.begin(); + for (ButtonList::const_iterator cit = buttonlist_.begin(); cit != buttonlist_.end(); ++cit) { if ((*cit)->item_->submenu() == name) { MenuCallback((*cit)->obj_, 1); @@ -510,7 +510,7 @@ int Menubar::Pimpl::create_submenu(Window win, LyXView * view, MenuItem const & item = (*i); string & extra_label = *it; - switch(item.kind()) { + switch (item.kind()) { case MenuItem::Command: { LyXFunc::func_status flag = view->getLyXFunc()->getStatus(item.action()); diff --git a/src/frontends/xforms/Toolbar_pimpl.C b/src/frontends/xforms/Toolbar_pimpl.C index d9a72639bc..db5c7d0a0b 100644 --- a/src/frontends/xforms/Toolbar_pimpl.C +++ b/src/frontends/xforms/Toolbar_pimpl.C @@ -120,13 +120,13 @@ int BubblePost(FL_OBJECT *ob, int event, FL_OBJECT * bubble_timer = reinterpret_cast(ob->u_cdata); // We do not test for empty help here, since this can never happen - if(event == FL_ENTER){ + if (event == FL_ENTER){ fl_set_object_callback(bubble_timer, C_Toolbar_BubbleTimerCB, reinterpret_cast(ob)); fl_set_timer(bubble_timer, 1); } - else if(event != FL_MOTION){ + else if (event != FL_MOTION){ fl_set_timer(bubble_timer, 0); fl_hide_oneliner(); } @@ -252,7 +252,7 @@ void ToolbarCB(FL_OBJECT * ob, long ac) LyXView * owner = static_cast(ob->u_vdata); string res = owner->getLyXFunc()->Dispatch(int(ac)); - if(!res.empty()) + if (!res.empty()) lyxerr[Debug::GUI] << "ToolbarCB: Function returned: " << res << endl; } @@ -349,7 +349,7 @@ void Toolbar::Pimpl::set(bool doingmain) ToolbarList::iterator item = toollist.begin(); ToolbarList::iterator end = toollist.end(); for (; item != end; ++item) { - switch(item->action){ + switch (item->action){ case ToolbarDefaults::SEPARATOR: xpos += sepspace; break; diff --git a/src/frontends/xforms/form_citation.C b/src/frontends/xforms/form_citation.C index eac60cccf5..fea160b037 100644 --- a/src/frontends/xforms/form_citation.C +++ b/src/frontends/xforms/form_citation.C @@ -12,7 +12,7 @@ FD_form_citation::~FD_form_citation() { - if( form->visible ) fl_hide_form( form ); + if (form->visible ) fl_hide_form( form ); fl_free_form( form ); } diff --git a/src/frontends/xforms/form_copyright.C b/src/frontends/xforms/form_copyright.C index 6604843a4b..edefc2543e 100644 --- a/src/frontends/xforms/form_copyright.C +++ b/src/frontends/xforms/form_copyright.C @@ -12,7 +12,7 @@ FD_form_copyright::~FD_form_copyright() { - if( form->visible ) fl_hide_form( form ); + if (form->visible ) fl_hide_form( form ); fl_free_form( form ); } diff --git a/src/frontends/xforms/form_document.C b/src/frontends/xforms/form_document.C index 3a00bb8386..9600aeeee5 100644 --- a/src/frontends/xforms/form_document.C +++ b/src/frontends/xforms/form_document.C @@ -14,7 +14,7 @@ FD_form_tabbed_document::~FD_form_tabbed_document() { - if( form->visible ) fl_hide_form( form ); + if (form->visible ) fl_hide_form( form ); fl_free_form( form ); } @@ -56,7 +56,7 @@ FD_form_tabbed_document * FormDocument::build_tabbed_document() FD_form_doc_paper::~FD_form_doc_paper() { - if( form->visible ) fl_hide_form( form ); + if (form->visible ) fl_hide_form( form ); fl_free_form( form ); } @@ -177,7 +177,7 @@ FD_form_doc_paper * FormDocument::build_doc_paper() FD_form_doc_class::~FD_form_doc_class() { - if( form->visible ) fl_hide_form( form ); + if (form->visible ) fl_hide_form( form ); fl_free_form( form ); } @@ -286,7 +286,7 @@ FD_form_doc_class * FormDocument::build_doc_class() FD_form_doc_language::~FD_form_doc_language() { - if( form->visible ) fl_hide_form( form ); + if (form->visible ) fl_hide_form( form ); fl_free_form( form ); } @@ -336,7 +336,7 @@ FD_form_doc_language * FormDocument::build_doc_language() FD_form_doc_options::~FD_form_doc_options() { - if( form->visible ) fl_hide_form( form ); + if (form->visible ) fl_hide_form( form ); fl_free_form( form ); } @@ -380,7 +380,7 @@ FD_form_doc_options * FormDocument::build_doc_options() FD_form_doc_bullet::~FD_form_doc_bullet() { - if( form->visible ) fl_hide_form( form ); + if (form->visible ) fl_hide_form( form ); fl_free_form( form ); } diff --git a/src/frontends/xforms/form_error.C b/src/frontends/xforms/form_error.C index e503369cad..0262f3a111 100644 --- a/src/frontends/xforms/form_error.C +++ b/src/frontends/xforms/form_error.C @@ -12,7 +12,7 @@ FD_form_error::~FD_form_error() { - if( form->visible ) fl_hide_form( form ); + if (form->visible ) fl_hide_form( form ); fl_free_form( form ); } diff --git a/src/frontends/xforms/form_graphics.C b/src/frontends/xforms/form_graphics.C index c78a6f83b4..be0354509d 100644 --- a/src/frontends/xforms/form_graphics.C +++ b/src/frontends/xforms/form_graphics.C @@ -12,7 +12,7 @@ FD_form_graphics::~FD_form_graphics() { - if( form->visible ) fl_hide_form( form ); + if (form->visible ) fl_hide_form( form ); fl_free_form( form ); } diff --git a/src/frontends/xforms/form_index.C b/src/frontends/xforms/form_index.C index 729e5a981f..fbecb35f83 100644 --- a/src/frontends/xforms/form_index.C +++ b/src/frontends/xforms/form_index.C @@ -12,7 +12,7 @@ FD_form_index::~FD_form_index() { - if( form->visible ) fl_hide_form( form ); + if (form->visible ) fl_hide_form( form ); fl_free_form( form ); } diff --git a/src/frontends/xforms/form_paragraph.C b/src/frontends/xforms/form_paragraph.C index 04a3113e1f..361d3fd3e6 100644 --- a/src/frontends/xforms/form_paragraph.C +++ b/src/frontends/xforms/form_paragraph.C @@ -12,7 +12,7 @@ FD_form_paragraph_general::~FD_form_paragraph_general() { - if( form->visible ) fl_hide_form( form ); + if (form->visible ) fl_hide_form( form ); fl_free_form( form ); } @@ -136,7 +136,7 @@ FD_form_paragraph_general * FormParagraph::build_paragraph_general() FD_form_paragraph_extra::~FD_form_paragraph_extra() { - if( form->visible ) fl_hide_form( form ); + if (form->visible ) fl_hide_form( form ); fl_free_form( form ); } @@ -225,7 +225,7 @@ FD_form_paragraph_extra * FormParagraph::build_paragraph_extra() FD_form_tabbed_paragraph::~FD_form_tabbed_paragraph() { - if( form->visible ) fl_hide_form( form ); + if (form->visible ) fl_hide_form( form ); fl_free_form( form ); } diff --git a/src/frontends/xforms/form_preferences.C b/src/frontends/xforms/form_preferences.C index a411712c55..cd2225d6a6 100644 --- a/src/frontends/xforms/form_preferences.C +++ b/src/frontends/xforms/form_preferences.C @@ -12,7 +12,7 @@ FD_form_preferences::~FD_form_preferences() { - if( form->visible ) fl_hide_form( form ); + if (form->visible ) fl_hide_form( form ); fl_free_form( form ); } @@ -57,7 +57,7 @@ FD_form_preferences * FormPreferences::build_preferences() FD_form_outer_tab::~FD_form_outer_tab() { - if( form->visible ) fl_hide_form( form ); + if (form->visible ) fl_hide_form( form ); fl_free_form( form ); } @@ -83,7 +83,7 @@ FD_form_outer_tab * FormPreferences::build_outer_tab() FD_form_screen_fonts::~FD_form_screen_fonts() { - if( form->visible ) fl_hide_form( form ); + if (form->visible ) fl_hide_form( form ); fl_free_form( form ); } @@ -171,7 +171,7 @@ FD_form_screen_fonts * FormPreferences::build_screen_fonts() FD_form_outputs_misc::~FD_form_outputs_misc() { - if( form->visible ) fl_hide_form( form ); + if (form->visible ) fl_hide_form( form ); fl_free_form( form ); } @@ -223,7 +223,7 @@ FD_form_outputs_misc * FormPreferences::build_outputs_misc() FD_form_spellchecker::~FD_form_spellchecker() { - if( form->visible ) fl_hide_form( form ); + if (form->visible ) fl_hide_form( form ); fl_free_form( form ); } @@ -287,7 +287,7 @@ FD_form_spellchecker * FormPreferences::build_spellchecker() FD_form_inputs_misc::~FD_form_inputs_misc() { - if( form->visible ) fl_hide_form( form ); + if (form->visible ) fl_hide_form( form ); fl_free_form( form ); } @@ -314,7 +314,7 @@ FD_form_inputs_misc * FormPreferences::build_inputs_misc() FD_form_language::~FD_form_language() { - if( form->visible ) fl_hide_form( form ); + if (form->visible ) fl_hide_form( form ); fl_free_form( form ); } @@ -386,7 +386,7 @@ FD_form_language * FormPreferences::build_language() FD_form_colours::~FD_form_colours() { - if( form->visible ) fl_hide_form( form ); + if (form->visible ) fl_hide_form( form ); fl_free_form( form ); } @@ -449,7 +449,7 @@ FD_form_colours * FormPreferences::build_colours() FD_form_converters::~FD_form_converters() { - if( form->visible ) fl_hide_form( form ); + if (form->visible ) fl_hide_form( form ); fl_free_form( form ); } @@ -497,7 +497,7 @@ FD_form_converters * FormPreferences::build_converters() FD_form_formats::~FD_form_formats() { - if( form->visible ) fl_hide_form( form ); + if (form->visible ) fl_hide_form( form ); fl_free_form( form ); } @@ -549,7 +549,7 @@ FD_form_formats * FormPreferences::build_formats() FD_form_lnf_misc::~FD_form_lnf_misc() { - if( form->visible ) fl_hide_form( form ); + if (form->visible ) fl_hide_form( form ); fl_free_form( form ); } @@ -617,7 +617,7 @@ FD_form_lnf_misc * FormPreferences::build_lnf_misc() FD_form_interface::~FD_form_interface() { - if( form->visible ) fl_hide_form( form ); + if (form->visible ) fl_hide_form( form ); fl_free_form( form ); } @@ -666,7 +666,7 @@ FD_form_interface * FormPreferences::build_interface() FD_form_printer::~FD_form_printer() { - if( form->visible ) fl_hide_form( form ); + if (form->visible ) fl_hide_form( form ); fl_free_form( form ); } @@ -745,7 +745,7 @@ FD_form_printer * FormPreferences::build_printer() FD_form_paths::~FD_form_paths() { - if( form->visible ) fl_hide_form( form ); + if (form->visible ) fl_hide_form( form ); fl_free_form( form ); } diff --git a/src/frontends/xforms/form_print.C b/src/frontends/xforms/form_print.C index 6078fee5ac..4d22c85c22 100644 --- a/src/frontends/xforms/form_print.C +++ b/src/frontends/xforms/form_print.C @@ -12,7 +12,7 @@ FD_form_print::~FD_form_print() { - if( form->visible ) fl_hide_form( form ); + if (form->visible ) fl_hide_form( form ); fl_free_form( form ); } diff --git a/src/frontends/xforms/form_ref.C b/src/frontends/xforms/form_ref.C index 932494f934..ceade206bc 100644 --- a/src/frontends/xforms/form_ref.C +++ b/src/frontends/xforms/form_ref.C @@ -12,7 +12,7 @@ FD_form_ref::~FD_form_ref() { - if( form->visible ) fl_hide_form( form ); + if (form->visible ) fl_hide_form( form ); fl_free_form( form ); } diff --git a/src/frontends/xforms/form_tabular.C b/src/frontends/xforms/form_tabular.C index d2239f39e7..bab9f9c9b3 100644 --- a/src/frontends/xforms/form_tabular.C +++ b/src/frontends/xforms/form_tabular.C @@ -12,7 +12,7 @@ FD_form_tabular::~FD_form_tabular() { - if( form->visible ) fl_hide_form( form ); + if (form->visible ) fl_hide_form( form ); fl_free_form( form ); } @@ -51,7 +51,7 @@ FD_form_tabular * FormTabular::build_tabular() FD_form_tabular_options::~FD_form_tabular_options() { - if( form->visible ) fl_hide_form( form ); + if (form->visible ) fl_hide_form( form ); fl_free_form( form ); } @@ -106,7 +106,7 @@ FD_form_tabular_options * FormTabular::build_tabular_options() FD_form_column_options::~FD_form_column_options() { - if( form->visible ) fl_hide_form( form ); + if (form->visible ) fl_hide_form( form ); fl_free_form( form ); } @@ -196,7 +196,7 @@ FD_form_column_options * FormTabular::build_column_options() FD_form_cell_options::~FD_form_cell_options() { - if( form->visible ) fl_hide_form( form ); + if (form->visible ) fl_hide_form( form ); fl_free_form( form ); } @@ -293,7 +293,7 @@ FD_form_cell_options * FormTabular::build_cell_options() FD_form_longtable_options::~FD_form_longtable_options() { - if( form->visible ) fl_hide_form( form ); + if (form->visible ) fl_hide_form( form ); fl_free_form( form ); } diff --git a/src/frontends/xforms/form_tabular_create.C b/src/frontends/xforms/form_tabular_create.C index 2f94d7bebb..02fe6fd134 100644 --- a/src/frontends/xforms/form_tabular_create.C +++ b/src/frontends/xforms/form_tabular_create.C @@ -12,7 +12,7 @@ FD_form_tabular_create::~FD_form_tabular_create() { - if( form->visible ) fl_hide_form( form ); + if (form->visible ) fl_hide_form( form ); fl_free_form( form ); } diff --git a/src/frontends/xforms/form_toc.C b/src/frontends/xforms/form_toc.C index 40e1247de6..92edb0dcbe 100644 --- a/src/frontends/xforms/form_toc.C +++ b/src/frontends/xforms/form_toc.C @@ -12,7 +12,7 @@ FD_form_toc::~FD_form_toc() { - if( form->visible ) fl_hide_form( form ); + if (form->visible ) fl_hide_form( form ); fl_free_form( form ); } diff --git a/src/frontends/xforms/form_url.C b/src/frontends/xforms/form_url.C index b35d9c4a70..e142d9f4f3 100644 --- a/src/frontends/xforms/form_url.C +++ b/src/frontends/xforms/form_url.C @@ -12,7 +12,7 @@ FD_form_url::~FD_form_url() { - if( form->visible ) fl_hide_form( form ); + if (form->visible ) fl_hide_form( form ); fl_free_form( form ); } diff --git a/src/frontends/xforms/input_validators.c b/src/frontends/xforms/input_validators.c index d3c2aafba8..5acafa6fec 100644 --- a/src/frontends/xforms/input_validators.c +++ b/src/frontends/xforms/input_validators.c @@ -81,16 +81,16 @@ void fl_print_range_filter(FL_OBJECT * ob, pages = split (pages, piece, ',') ; piece = strip(piece) ; piece = frontStrip(piece) ; - if ( !stringOnlyContains (piece, "0123456789-") ) { + if (!stringOnlyContains (piece, "0123456789-")) { WriteAlert(_("ERROR! Unable to print!"), _("Check 'range of pages'!")); return; } if (piece.find('-') == string::npos) { // not found pageflag += lyxrc.print_pagerange_flag + piece + '-' + piece + ' ' ; - } else if (suffixIs(piece, "-") ) { // missing last page + } else if (suffixIs(piece, "-")) { // missing last page pageflag += lyxrc.print_pagerange_flag + piece + "1000 "; - } else if (prefixIs(piece, "-") ) { // missing first page + } else if (prefixIs(piece, "-")) { // missing first page pageflag += lyxrc.print_pagerange_flag + '1' + piece + ' ' ; } else { pageflag += lyxrc.print_pagerange_flag + piece + ' ' ; diff --git a/src/frontends/xforms/xform_helpers.C b/src/frontends/xforms/xform_helpers.C index 2fcc60514f..b3ed35d27a 100644 --- a/src/frontends/xforms/xform_helpers.C +++ b/src/frontends/xforms/xform_helpers.C @@ -18,14 +18,14 @@ using std::vector; string formatted( string const & sin, int w, int size, int style ) { string sout; - if( sin.empty() ) return sout; + if (sin.empty() ) return sout; // break sin up into a vector of individual words vector sentence; string word; - for( string::const_iterator sit = sin.begin(); - sit != sin.end(); ++sit ) { - if( (*sit) == ' ' || (*sit) == '\n') { + for (string::const_iterator sit = sin.begin(); + sit != sin.end(); ++sit) { + if ((*sit) == ' ' || (*sit) == '\n') { sentence.push_back(word); word.erase(); } else { @@ -33,17 +33,17 @@ string formatted( string const & sin, int w, int size, int style ) } } // Flush remaining contents of word - if( !word.empty() ) sentence.push_back(word); + if (!word.empty() ) sentence.push_back(word); string line, l1; - for( vector::const_iterator vit = sentence.begin(); - vit != sentence.end(); ++vit ) { - if( !l1.empty() ) l1 += ' '; + for (vector::const_iterator vit = sentence.begin(); + vit != sentence.end(); ++vit) { + if (!l1.empty() ) l1 += ' '; l1 += (*vit); int length = fl_get_string_width(style, size, l1.c_str(), int(l1.length())); - if( length >= w ) { - if( !sout.empty() ) sout += '\n'; + if (length >= w) { + if (!sout.empty() ) sout += '\n'; sout += line; l1 = (*vit); } @@ -51,8 +51,8 @@ string formatted( string const & sin, int w, int size, int style ) line = l1; } // Flush remaining contents of line - if( !line.empty() ) { - if( !sout.empty() ) sout += '\n'; + if (!line.empty()) { + if (!sout.empty() ) sout += '\n'; sout += line; } diff --git a/src/insets/ExternalTemplate.C b/src/insets/ExternalTemplate.C index 906cd9ad79..ffcdd43305 100644 --- a/src/insets/ExternalTemplate.C +++ b/src/insets/ExternalTemplate.C @@ -153,7 +153,7 @@ void ExternalTemplateManager::readTemplates(string const & path) } while (lex.IsOK()) { - switch(lex.lex()) { + switch (lex.lex()) { case TM_TEMPLATE: { lex.next(); string temp = lex.GetString(); @@ -273,7 +273,7 @@ void ExternalTemplate::FormatTemplate::readFormat(LyXLex & lex) pushpophelper pph(lex, formattags, FO_END); while (lex.IsOK()) { - switch(lex.lex()) { + switch (lex.lex()) { case FO_PRODUCT: lex.next(true); product = lex.GetString(); diff --git a/src/insets/figinset.C b/src/insets/figinset.C index 60d10c5f3d..a82b9deb1b 100644 --- a/src/insets/figinset.C +++ b/src/insets/figinset.C @@ -168,7 +168,7 @@ int GhostscriptMsg(FL_OBJECT *, Window, int, int, { XClientMessageEvent * e = reinterpret_cast(ev); - if(lyxerr.debugging()) { + if (lyxerr.debugging()) { lyxerr << "ClientMessage, win:[xx] gs:[" << e->data.l[0] << "] pm:[" << e->data.l[1] << "]" << endl; } @@ -322,7 +322,7 @@ void AllocColors(int num) if (i) XFreeColors(fl_get_display(), fl_state[fl_get_vclass()].colormap, gs_pixels, i, 0); - if(lyxerr.debugging()) { + if (lyxerr.debugging()) { lyxerr << "Cannot allocate color cube " << num << endl;; } @@ -772,7 +772,7 @@ void getbitmap(figdata * p) static void makeupdatelist(figdata * p) { - for(figures_type::iterator it = figures.begin(); + for (figures_type::iterator it = figures.begin(); it != figures.end(); ++it) if ((*it)->data == p) { if (lyxerr.debugging()) { @@ -1158,7 +1158,7 @@ int InsetFig::DocBook(Buffer const *, ostream & os) const string buf1 = OnlyPath(owner->fileName()); string figurename = MakeRelPath(fname, buf1); - if(suffixIs(figurename, ".eps")) + if (suffixIs(figurename, ".eps")) figurename.erase(figurename.length() - 4); os << "@"; @@ -1199,7 +1199,7 @@ void InsetFig::Edit(BufferView * bv, int, int, unsigned int) // We should have RO-versions of the form instead. // The actual prevention of altering a readonly doc // is done in CallbackFig() - if(bv->buffer()->isReadonly()) + if (bv->buffer()->isReadonly()) WarnReadonly(bv->buffer()->fileName()); if (!form) { @@ -1703,7 +1703,7 @@ void InsetFig::CallbackFig(long arg) break; case 7: /* apply */ case 8: /* ok (apply and close) */ - if(!current_view->buffer()->isReadonly()) { + if (!current_view->buffer()->isReadonly()) { wtype = twtype; htype = thtype; xwid = atof(fl_get_input(form->Width)); @@ -1744,7 +1744,7 @@ void InsetFig::CallbackFig(long arg) break; } //if not readonly // The user has already been informed about RO in ::Edit - if(arg == 7) // if 'Apply' + if (arg == 7) // if 'Apply' break; // fall through case 9: /* cancel = restore and close */ @@ -1888,7 +1888,7 @@ void InsetFig::RestoreForm() } else fl_set_input(form->EpsFile, ""); fl_set_input(form->Subcaption, subcaption.c_str()); - if(current_view->buffer()->isReadonly()) + if (current_view->buffer()->isReadonly()) DisableFigurePanel(form); TempRegenerate(); diff --git a/src/insets/insetbib.C b/src/insets/insetbib.C index 1ea8b95d3f..32f8b7ae6e 100644 --- a/src/insets/insetbib.C +++ b/src/insets/insetbib.C @@ -84,7 +84,7 @@ InsetBibKey::InsetBibKey(InsetCommandParams const & p) InsetBibKey::~InsetBibKey() { - if(bibitem_form && bibitem_form->bibitem_form + if (bibitem_form && bibitem_form->bibitem_form && bibitem_form->bibitem_form->visible && bibitem_form->bibitem_form->u_vdata == &holder) fl_hide_form(bibitem_form->bibitem_form); @@ -106,7 +106,7 @@ void InsetBibKey::callback( FD_bibitem_form * form, long data ) // Do NOT change this to // holder.view->buffer() as this code is used by both // InsetBibKey and InsetBibtex! Ughhhhhhh!!!! - if(!current_view->buffer()->isReadonly()) { + if (!current_view->buffer()->isReadonly()) { setContents(fl_get_input(form->key)); setOptions(fl_get_input(form->label)); // shouldn't mark the buffer dirty unless @@ -176,7 +176,7 @@ string const InsetBibKey::getScreenLabel() const */ void InsetBibKey::Edit(BufferView * bv, int, int, unsigned int) { - if(bv->buffer()->isReadonly()) + if (bv->buffer()->isReadonly()) WarnReadonly(bv->buffer()->fileName()); if (!bibitem_form) { @@ -213,7 +213,7 @@ InsetBibtex::InsetBibtex(InsetCommandParams const & p) InsetBibtex::~InsetBibtex() { - if(bibitem_form && bibitem_form->bibitem_form + if (bibitem_form && bibitem_form->bibitem_form && bibitem_form->bibitem_form->visible && bibitem_form->bibitem_form->u_vdata == &holder) fl_hide_form(bibitem_form->bibitem_form); @@ -283,7 +283,7 @@ vector > const InsetBibtex::getKeys(Buffer const * buffer) string linebuf0; while (getline(ifs, linebuf0)) { string linebuf = frontStrip(strip(linebuf0)); - if( linebuf.empty() ) continue; + if (linebuf.empty() ) continue; if (prefixIs(linebuf, "@")) { linebuf = subst(linebuf, '{', '('); linebuf = split(linebuf, tmp, '('); @@ -296,7 +296,7 @@ vector > const InsetBibtex::getKeys(Buffer const * buffer) keys.push_back(pair(tmp,string())); } } - } else if( !keys.empty() ) { + } else if (!keys.empty()) { keys.back().second += linebuf + "\n"; } } diff --git a/src/insets/insetcite.C b/src/insets/insetcite.C index eea8607b70..7f70ba44d4 100644 --- a/src/insets/insetcite.C +++ b/src/insets/insetcite.C @@ -40,7 +40,7 @@ string const InsetCitation::getScreenLabel() const keys = frontStrip(split(keys, key, ',')); string::size_type size = label.size() + 2 + key.size(); - if( size >= maxSize ) { + if (size >= maxSize) { label += ", ..."; break; } diff --git a/src/insets/insetcommand.C b/src/insets/insetcommand.C index e7ad117674..b3ff8cbba3 100644 --- a/src/insets/insetcommand.C +++ b/src/insets/insetcommand.C @@ -44,7 +44,7 @@ string const InsetCommandParams::getAsString() const void InsetCommandParams::setFromString( string const & b ) { string::size_type idx = b.find("|++|"); - if( idx == string::npos ) { + if (idx == string::npos) { cmdname = ""; options = ""; contents = ""; @@ -55,7 +55,7 @@ void InsetCommandParams::setFromString( string const & b ) string tmp = b.substr(idx+4); idx = tmp.find("|++|"); - if( idx == string::npos ) { + if (idx == string::npos) { options = tmp; } else { options = tmp.substr(0, idx); diff --git a/src/insets/insetcommand.h b/src/insets/insetcommand.h index 2e75be5bbe..0dd010df7e 100644 --- a/src/insets/insetcommand.h +++ b/src/insets/insetcommand.h @@ -58,7 +58,7 @@ public: /// string const & getContents() const { return contents; } /// - void setCmdName( string const & n ) { cmdname = n; } + void setCmdName( string const & n) { cmdname = n; } /// void setOptions(string const & o) { options = o; } /// diff --git a/src/insets/insetinclude.C b/src/insets/insetinclude.C index 8153c087cc..718032141d 100644 --- a/src/insets/insetinclude.C +++ b/src/insets/insetinclude.C @@ -138,7 +138,7 @@ void include_cb(FL_OBJECT *, long arg) } case 1: - if(!current_view->buffer()->isReadonly()) { + if (!current_view->buffer()->isReadonly()) { inset->setContents(fl_get_input(form->input)); // don't typeset inset->setNoLoad(fl_get_button(form->flag1)); @@ -160,7 +160,7 @@ void include_cb(FL_OBJECT *, long arg) fl_hide_form(form->include); break; case 5: - if(!current_view->buffer()->isReadonly()) { + if (!current_view->buffer()->isReadonly()) { inset->setContents(fl_get_input(form->input)); inset->setNoLoad(fl_get_button(form->flag1)); if (fl_get_button(form->flag2)) @@ -247,7 +247,7 @@ Inset * InsetInclude::Clone(Buffer const & buffer) const void InsetInclude::Edit(BufferView * bv, int, int, unsigned int) { - if(bv->buffer()->isReadonly()) + if (bv->buffer()->isReadonly()) WarnReadonly(bv->buffer()->fileName()); if (!form) { @@ -440,7 +440,7 @@ int InsetInclude::Linuxdoc(Buffer const * buffer, ostream & os) const } else writefile = getFileName(); - if(IsLyXFilename(getFileName())) + if (IsLyXFilename(getFileName())) writefile = ChangeExtension(writefile, ".sgml"); lyxerr[Debug::LATEX] << "incfile:" << incfile << endl; @@ -476,7 +476,7 @@ int InsetInclude::DocBook(Buffer const * buffer, ostream & os) const writefile = AddName(buffer->tmppath, incfile); } else writefile = getFileName(); - if(IsLyXFilename(getFileName())) + if (IsLyXFilename(getFileName())) writefile = ChangeExtension(writefile, ".sgml"); lyxerr[Debug::LATEX] << "incfile:" << incfile << endl; @@ -507,7 +507,7 @@ void InsetInclude::Validate(LaTeXFeatures & features) const // Use the relative path. writefile = incfile; - if(IsLyXFilename(getFileName())) + if (IsLyXFilename(getFileName())) writefile = ChangeExtension(writefile, ".sgml"); features.IncludedFiles[include_label] = writefile; diff --git a/src/insets/insetinfo.C b/src/insets/insetinfo.C index f0d355a13f..66c7712191 100644 --- a/src/insets/insetinfo.C +++ b/src/insets/insetinfo.C @@ -173,7 +173,7 @@ void InsetInfo::CloseInfoCB(FL_OBJECT * ob, long) InsetInfo * inset = static_cast(ob->u_vdata); string tmp = fl_get_input(inset->strobj); Buffer * buffer = current_view->buffer(); - if(tmp != inset->contents && !(buffer->isReadonly()) ) { + if (tmp != inset->contents && !(buffer->isReadonly())) { buffer->markDirty(); inset->contents = tmp; } @@ -203,7 +203,7 @@ void InsetInfo::Edit(BufferView *bv, int, int, unsigned int) { static int ow = -1, oh; - if(bv->buffer()->isReadonly()) + if (bv->buffer()->isReadonly()) WarnReadonly(bv->buffer()->fileName()); if (!form) { diff --git a/src/insets/insetlatexaccent.C b/src/insets/insetlatexaccent.C index 77619a2d76..2fc222f235 100644 --- a/src/insets/insetlatexaccent.C +++ b/src/insets/insetlatexaccent.C @@ -191,7 +191,7 @@ void InsetLatexAccent::checkContents() // special clause for \i{}, \j{} \l{} and \L{} if ((modtype == DOT_LESS_I || modtype == DOT_LESS_J || modtype == lSLASH || modtype == LSLASH) - && contents[3] == '}' ) { + && contents[3] == '}') { switch (modtype) { case DOT_LESS_I: ic = 'i'; break; case DOT_LESS_J: ic = 'j'; break; @@ -225,13 +225,13 @@ void InsetLatexAccent::checkContents() remdot = true; else return; - } else if ( (ic == 'i'|| ic == 'j') && contents[4] == '}') { + } else if ((ic == 'i'|| ic == 'j') && contents[4] == '}') { // Do a rewrite: \{i} --> \{\i} string temp = contents; temp.erase(3, string::npos); temp += '\\'; temp += char(ic); - for(string::size_type j = 4; + for (string::size_type j = 4; j < contents.length(); ++j) temp+= contents[j]; contents= temp; diff --git a/src/insets/insetparent.C b/src/insets/insetparent.C index 3c6a7f2975..128ee44b04 100644 --- a/src/insets/insetparent.C +++ b/src/insets/insetparent.C @@ -32,7 +32,7 @@ using std::ostream; InsetParent::InsetParent(InsetCommandParams const & p, Buffer const & bf) : InsetCommand(p) { - string fn = p.getContents(); + string const fn = p.getContents(); setContents(MakeAbsPath(fn, OnlyPath(bf.fileName()))); } diff --git a/src/insets/insetquotes.C b/src/insets/insetquotes.C index b66a7e0cef..41f4be19d5 100644 --- a/src/insets/insetquotes.C +++ b/src/insets/insetquotes.C @@ -78,7 +78,7 @@ InsetQuotes::InsetQuotes(char c, BufferParams const & params) : language(params.quotes_language), times(params.quotes_times) { // Decide whether left or right - switch(c) { + switch (c) { case ' ': case '(': case '{': case '[': case '-': case ':': case LyXParagraph::META_HFILL: case LyXParagraph::META_NEWLINE: @@ -272,7 +272,7 @@ int InsetQuotes::Linuxdoc(Buffer const *, ostream & os) const int InsetQuotes::DocBook(Buffer const *, ostream & os) const { - if(times == InsetQuotes::DoubleQ) { + if (times == InsetQuotes::DoubleQ) { if (side == InsetQuotes::LeftQ) os << "“"; else diff --git a/src/insets/insetref.C b/src/insets/insetref.C index ff995a8a9f..b936e53ad9 100644 --- a/src/insets/insetref.C +++ b/src/insets/insetref.C @@ -23,10 +23,10 @@ InsetRef::InsetRef(InsetCommandParams const & p, Buffer const & buf) void InsetRef::Edit(BufferView * bv, int, int, unsigned int button) { // Eventually trigger dialog with button 3 not 1 - if( button == 3 ) + if (button == 3 ) bv->owner()->getLyXFunc()-> Dispatch(LFUN_REF_GOTO, getContents()); - else if( button == 1 ) + else if (button == 1 ) bv->owner()->getDialogs()->showRef( this ); } @@ -47,7 +47,7 @@ string const InsetRef::getScreenLabel() const temp += getContents(); - if(!isLatex + if (!isLatex && !getOptions().empty()) { temp += "||"; temp += getOptions(); @@ -59,7 +59,7 @@ string const InsetRef::getScreenLabel() const int InsetRef::Latex(Buffer const *, ostream & os, bool /*fragile*/, bool /*fs*/) const { - if(getOptions().empty()) + if (getOptions().empty()) os << escape(getCommand()); else { InsetCommandParams p( getCmdName(), getContents(), "" ); @@ -117,6 +117,6 @@ void InsetRef::Validate(LaTeXFeatures & features) const { if (getCmdName() == "vref" || getCmdName() == "vpageref") features.varioref = true; - else if(getCmdName() == "prettyref") + else if (getCmdName() == "prettyref") features.prettyref = true; } diff --git a/src/insets/insettabular.C b/src/insets/insettabular.C index b16366a71e..f97392473b 100644 --- a/src/insets/insettabular.C +++ b/src/insets/insettabular.C @@ -252,11 +252,11 @@ void InsetTabular::draw(BufferView * bv, LyXFont const & font, int baseline, bool dodraw; x += ADD_TO_TABULAR_WIDTH; if (cleared) { - for(i = 0; i < tabular->rows(); ++i) { + for (i = 0; i < tabular->rows(); ++i) { nx = int(x); dodraw = ((baseline + tabular->GetDescentOfRow(i)) > 0) && (baseline - tabular->GetAscentOfRow(i))columns(); ++j) { + for (j = 0; j < tabular->columns(); ++j) { if (tabular->IsPartOfMultiColumn(i, j)) continue; cx = nx + tabular->GetBeginningOfTextInCell(cell); @@ -276,8 +276,8 @@ void InsetTabular::draw(BufferView * bv, LyXFont const & font, int baseline, } } else if (need_update == CELL) { nx = int(x); - for(i = 0; (cell < actcell) && (i < tabular->rows()); ++i) { - for(j = 0; (cell < actcell) && (j < tabular->columns()); ++j) { + for (i = 0; (cell < actcell) && (i < tabular->rows()); ++i) { + for (j = 0; (cell < actcell) && (j < tabular->columns()); ++j) { if (tabular->IsPartOfMultiColumn(i, j)) continue; nx += tabular->GetWidthOfColumn(cell); @@ -402,7 +402,7 @@ void InsetTabular::update(BufferView * bv, LyXFont const & font, bool reinit) // inset_x = cursor.x() - top_x + tabular->GetBeginningOfTextInCell(actcell); // inset_y = cursor.y(); } - switch(need_update) { + switch (need_update) { case INIT: case FULL: case CELL: @@ -964,9 +964,9 @@ bool InsetTabular::calculate_dimensions_of_cells(BufferView * bv, InsetText * inset; bool changed = false; - for(int i = 0; i < tabular->rows(); ++i) { + for (int i = 0; i < tabular->rows(); ++i) { maxAsc = maxDesc = 0; - for(int j= 0; j < tabular->columns(); ++j) { + for (int j= 0; j < tabular->columns(); ++j) { if (tabular->IsPartOfMultiColumn(i,j)) continue; ++cell; @@ -1062,7 +1062,7 @@ void InsetTabular::setPos(BufferView * bv, int x, int y) const tabular->GetAdditionalWidth(actcell); #warning Jürgen, can you rewrite this to _not_ use the sequencing operator. (Lgb) #if 0 - for(; !tabular->IsLastCellInRow(actcell) && (lx < x); + for (; !tabular->IsLastCellInRow(actcell) && (lx < x); ++actcell,lx += tabular->GetWidthOfColumn(actcell) + tabular->GetAdditionalWidth(actcell - 1)); #else @@ -1089,10 +1089,10 @@ int InsetTabular::getCellXPos(int cell) const { int c = cell; - for(; !tabular->IsFirstCellInRow(c); --c) + for (; !tabular->IsFirstCellInRow(c); --c) ; int lx = tabular->GetWidthOfColumn(cell); - for(; c < cell; ++c) { + for (; c < cell; ++c) { lx += tabular->GetWidthOfColumn(c); } return (lx - tabular->GetWidthOfColumn(cell) + top_x); @@ -1108,7 +1108,7 @@ void InsetTabular::resetPos(BufferView * bv) const int cell = 0; actrow = 0; cursor.y(0); - for(; (cell < actcell) && !tabular->IsLastRow(cell); ++cell) { + for (; (cell < actcell) && !tabular->IsLastRow(cell); ++cell) { if (tabular->IsLastCellInRow(cell)) { cursor.y(cursor.y() + tabular->GetDescentOfRow(actrow) + tabular->GetAscentOfRow(actrow + 1) + @@ -1239,7 +1239,7 @@ bool InsetTabular::TabularFeatures(BufferView * bv, string const & what) LyXTabular::Feature action = LyXTabular::LAST_ACTION; int i = 0; - for(; tabularFeatures[i].action != LyXTabular::LAST_ACTION; ++i) { + for (; tabularFeatures[i].action != LyXTabular::LAST_ACTION; ++i) { string const tmp = tabularFeatures[i].feature; if (tmp == what.substr(0, tmp.length())) { @@ -1400,8 +1400,8 @@ void InsetTabular::TabularFeatures(BufferView * bv, flag = false; case LyXTabular::TOGGLE_LINE_TOP: lineSet = !tabular->TopLine(actcell, flag); - for(i=sel_row_start; i<=sel_row_end; ++i) - for(j=sel_col_start; j<=sel_col_end; ++j) + for (i=sel_row_start; i<=sel_row_end; ++i) + for (j=sel_col_start; j<=sel_col_end; ++j) tabular->SetTopLine(tabular->GetCellNumber(i,j),lineSet, flag); UpdateLocal(bv, INIT, true); break; @@ -1410,8 +1410,8 @@ void InsetTabular::TabularFeatures(BufferView * bv, flag = false; case LyXTabular::TOGGLE_LINE_BOTTOM: lineSet = !tabular->BottomLine(actcell, flag); - for(i=sel_row_start; i<=sel_row_end; ++i) - for(j=sel_col_start; j<=sel_col_end; ++j) + for (i=sel_row_start; i<=sel_row_end; ++i) + for (j=sel_col_start; j<=sel_col_end; ++j) tabular->SetBottomLine(tabular->GetCellNumber(i,j),lineSet, flag); UpdateLocal(bv, INIT, true); @@ -1421,8 +1421,8 @@ void InsetTabular::TabularFeatures(BufferView * bv, flag = false; case LyXTabular::TOGGLE_LINE_LEFT: lineSet = !tabular->LeftLine(actcell, flag); - for(i=sel_row_start; i<=sel_row_end; ++i) - for(j=sel_col_start; j<=sel_col_end; ++j) + for (i=sel_row_start; i<=sel_row_end; ++i) + for (j=sel_col_start; j<=sel_col_end; ++j) tabular->SetLeftLine(tabular->GetCellNumber(i,j),lineSet, flag); UpdateLocal(bv, INIT, true); @@ -1432,8 +1432,8 @@ void InsetTabular::TabularFeatures(BufferView * bv, flag = false; case LyXTabular::TOGGLE_LINE_RIGHT: lineSet = !tabular->RightLine(actcell, flag); - for(i=sel_row_start; i<=sel_row_end; ++i) - for(j=sel_col_start; j<=sel_col_end; ++j) + for (i=sel_row_start; i<=sel_row_end; ++i) + for (j=sel_col_start; j<=sel_col_end; ++j) tabular->SetRightLine(tabular->GetCellNumber(i,j),lineSet, flag); UpdateLocal(bv, INIT, true); @@ -1445,8 +1445,8 @@ void InsetTabular::TabularFeatures(BufferView * bv, case LyXTabular::ALIGN_LEFT: case LyXTabular::ALIGN_RIGHT: case LyXTabular::ALIGN_CENTER: - for(i = sel_row_start; i <= sel_row_end; ++i) - for(j = sel_col_start; j <= sel_col_end; ++j) + for (i = sel_row_start; i <= sel_row_end; ++i) + for (j = sel_col_start; j <= sel_col_end; ++j) tabular->SetAlignment(tabular->GetCellNumber(i, j), setAlign, flag); if (hasSelection()) @@ -1461,8 +1461,8 @@ void InsetTabular::TabularFeatures(BufferView * bv, case LyXTabular::VALIGN_TOP: case LyXTabular::VALIGN_BOTTOM: case LyXTabular::VALIGN_CENTER: - for(i = sel_row_start; i <= sel_row_end; ++i) - for(j = sel_col_start; j <= sel_col_end; ++j) + for (i = sel_row_start; i <= sel_row_end; ++i) + for (j = sel_col_start; j <= sel_col_end; ++j) tabular->SetVAlignment(tabular->GetCellNumber(i, j), setVAlign, flag); if (hasSelection()) @@ -1513,8 +1513,8 @@ void InsetTabular::TabularFeatures(BufferView * bv, case LyXTabular::SET_ALL_LINES: setLines = 1; case LyXTabular::UNSET_ALL_LINES: - for(i=sel_row_start; i<=sel_row_end; ++i) - for(j=sel_col_start; j<=sel_col_end; ++j) + for (i=sel_row_start; i<=sel_row_end; ++i) + for (j=sel_col_start; j<=sel_col_end; ++j) tabular->SetAllLines(tabular->GetCellNumber(i,j), setLines); UpdateLocal(bv, INIT, true); break; @@ -1533,13 +1533,13 @@ void InsetTabular::TabularFeatures(BufferView * bv, tabular->SetRotateTabular(false); break; case LyXTabular::SET_ROTATE_CELL: - for(i=sel_row_start; i<=sel_row_end; ++i) - for(j=sel_col_start; j<=sel_col_end; ++j) + for (i=sel_row_start; i<=sel_row_end; ++i) + for (j=sel_col_start; j<=sel_col_end; ++j) tabular->SetRotateCell(tabular->GetCellNumber(i,j),true); break; case LyXTabular::UNSET_ROTATE_CELL: - for(i = sel_row_start; i <= sel_row_end; ++i) - for(j = sel_col_start; j <= sel_col_end; ++j) + for (i = sel_row_start; i <= sel_row_end; ++i) + for (j = sel_col_start; j <= sel_col_end; ++j) tabular->SetRotateCell(tabular->GetCellNumber(i, j), false); break; case LyXTabular::SET_USEBOX: @@ -1547,8 +1547,8 @@ void InsetTabular::TabularFeatures(BufferView * bv, LyXTabular::BoxType val = LyXTabular::BoxType(strToInt(value)); if (val == tabular->GetUsebox(actcell)) val = LyXTabular::BOX_NONE; - for(i = sel_row_start; i <= sel_row_end; ++i) - for(j = sel_col_start; j <= sel_col_end; ++j) + for (i = sel_row_start; i <= sel_row_end; ++i) + for (j = sel_col_start; j <= sel_col_end; ++j) tabular->SetUsebox(tabular->GetCellNumber(i, j), val); break; } @@ -1604,16 +1604,16 @@ bool InsetTabular::ActivateCellInset(BufferView * bv, int x, int y, int button, bool InsetTabular::InsetHit(BufferView * bv, int x, int ) const { InsetText * inset = tabular->GetCellInset(actcell); - int x1 = x + top_x; + int const x1 = x + top_x; if (!cellstart(cursor.pos())) { - return (((x + top_x) < cursor.x()) && - ((x + top_x) > (cursor.x() - inset->width(bv, - LyXFont(LyXFont::ALL_SANE))))); + return ((x + top_x) < cursor.x() && + (x + top_x) > (cursor.x() - inset->width(bv, + LyXFont(LyXFont::ALL_SANE)))); } else { - int x2 = cursor.x() + tabular->GetBeginningOfTextInCell(actcell); - return ((x1 > x2) && - (x1 < (x2 + inset->width(bv, LyXFont(LyXFont::ALL_SANE))))); + int const x2 = cursor.x() + tabular->GetBeginningOfTextInCell(actcell); + return (x1 > x2 && + x1 < (x2 + inset->width(bv, LyXFont(LyXFont::ALL_SANE)))); } } @@ -1635,7 +1635,7 @@ int InsetTabular::getMaxWidth(Painter & pain, { int const n = tabular->GetNumberOfCells(); int cell = 0; - for(; cell < n; ++cell) { + for (; cell < n; ++cell) { if (tabular->GetCellInset(cell) == inset) break; } @@ -1689,7 +1689,7 @@ LyXFunc::func_status InsetTabular::getStatus(string const & what) const LyXFunc::func_status status = LyXFunc::OK; int i = 0; - for(; tabularFeatures[i].action != LyXTabular::LAST_ACTION; ++i) { + for (; tabularFeatures[i].action != LyXTabular::LAST_ACTION; ++i) { string const tmp = tabularFeatures[i].feature; if (tmp == what.substr(0, tmp.length())) { //if (!strncmp(tabularFeatures[i].feature.c_str(), what.c_str(), @@ -1934,14 +1934,14 @@ bool InsetTabular::copySelection(BufferView * bv) paste_tabular = new LyXTabular(this, *tabular); // rows, columns); int i; - for(i=0; i < sel_row_start; ++i) + for (i=0; i < sel_row_start; ++i) paste_tabular->DeleteRow(0); while(paste_tabular->rows() > rows) paste_tabular->DeleteRow(rows); paste_tabular->SetTopLine(0, true, true); paste_tabular->SetBottomLine(paste_tabular->GetFirstCellInRow(rows-1), true, true); - for(i=0; i < sel_col_start; ++i) + for (i=0; i < sel_col_start; ++i) paste_tabular->DeleteColumn(0); while(paste_tabular->columns() > columns) paste_tabular->DeleteColumn(columns); @@ -1959,7 +1959,7 @@ bool InsetTabular::pasteSelection(BufferView * bv) { if (!paste_tabular) return false; - for(int j=0, i=actcell; jGetNumberOfCells(); ++j,++i) { + for (int j=0, i=actcell; jGetNumberOfCells(); ++j,++i) { while (paste_tabular->row_of_cell(j) > tabular->row_of_cell(i)-actrow) ++i; if (tabular->GetNumberOfCells() <= i) @@ -2006,8 +2006,8 @@ bool InsetTabular::cutSelection() //sel_cell_end = tmp; swap(sel_cell_start, sel_cell_end); } - for(int i = sel_row_start; i <= sel_row_end; ++i) { - for(int j = sel_col_start; j <= sel_col_end; ++j) { + for (int i = sel_row_start; i <= sel_row_end; ++i) { + for (int j = sel_col_start; j <= sel_col_end; ++j) { tabular->GetCellInset(tabular->GetCellNumber(i, j))->clear(); } } diff --git a/src/insets/insettext.C b/src/insets/insettext.C index 6f17fbac6f..0d76778bce 100644 --- a/src/insets/insettext.C +++ b/src/insets/insettext.C @@ -114,7 +114,7 @@ InsetText::~InsetText() { // delete all instances of LyXText before deleting the paragraps used // by it. - for(Cache::const_iterator cit = cache.begin(); cit != cache.end(); ++cit) + for (Cache::const_iterator cit = cache.begin(); cit != cache.end(); ++cit) delete (*cit).second; LyXParagraph * p = par->next; delete par; @@ -130,7 +130,7 @@ void InsetText::clear() { // delete all instances of LyXText before deleting the paragraps used // by it. - for(Cache::const_iterator cit = cache.begin(); cit != cache.end(); ++cit) + for (Cache::const_iterator cit = cache.begin(); cit != cache.end(); ++cit) delete (*cit).second; LyXParagraph * p = par->next; delete par; @@ -177,7 +177,7 @@ void InsetText::Read(Buffer const * buf, LyXLex & lex) // delete all instances of LyXText before deleting the paragraps used // by it. - for(Cache::const_iterator cit = cache.begin(); cit != cache.end(); ++cit) + for (Cache::const_iterator cit = cache.begin(); cit != cache.end(); ++cit) delete (*cit).second; LyXParagraph * p = par->next; @@ -644,7 +644,7 @@ void InsetText::InsetButtonPress(BufferView * bv, int x, int y, int button) paste_internally = true; } TEXT(bv)->SetCursorFromCoordinates(bv, x-drawTextXOffset, - y+insetAscent); + y + insetAscent); TEXT(bv)->sel_cursor = TEXT(bv)->cursor; UpdateLocal(bv, CURSOR, false); bv->owner()->setLayout(cpar(bv)->GetLayout()); @@ -742,7 +742,7 @@ InsetText::LocalDispatch(BufferView * bv, UpdateLocal(bv, CURSOR_PAR, false); return result; } else if (result == FINISHED) { - switch(action) { + switch (action) { case -1: case LFUN_RIGHT: moveRight(bv, false); @@ -1390,7 +1390,7 @@ void InsetText::SetParagraphData(LyXParagraph *p) { // delete all instances of LyXText before deleting the paragraps used // by it. - for(Cache::const_iterator cit = cache.begin(); cit != cache.end(); ++cit) + for (Cache::const_iterator cit = cache.begin(); cit != cache.end(); ++cit) delete (*cit).second; LyXParagraph * np; @@ -1509,7 +1509,7 @@ void InsetText::deleteLyXText(BufferView * bv, bool recursive) const if (recursive) { /// then remove all LyXText in text-insets LyXParagraph * p = par; - for(;p;p = p->next) { + for (;p;p = p->next) { p->deleteInsetsLyXText(bv); } } @@ -1572,7 +1572,7 @@ void InsetText::resizeLyXText(BufferView * bv) const /// then resize all LyXText in text-insets inset_x = cx(bv) - top_x + drawTextXOffset; inset_y = cy(bv) + drawTextYOffset; - for(LyXParagraph * p = par; p; p = p->next) { + for (LyXParagraph * p = par; p; p = p->next) { p->resizeInsetsLyXText(bv); } } @@ -1582,8 +1582,8 @@ void InsetText::resizeLyXText(BufferView * bv) const void InsetText::removeNewlines() { - for(LyXParagraph * p = par; p; p = p->next) { - for(int i = 0; i < p->Last(); ++i) { + for (LyXParagraph * p = par; p; p = p->next) { + for (int i = 0; i < p->Last(); ++i) { if (p->GetChar(i) == LyXParagraph::META_NEWLINE) p->Erase(i); } diff --git a/src/insets/insettoc.C b/src/insets/insettoc.C index 6657beb0f6..27f94452fd 100644 --- a/src/insets/insettoc.C +++ b/src/insets/insettoc.C @@ -17,11 +17,11 @@ using std::ostream; string const InsetTOC::getScreenLabel() const { string cmdname( getCmdName() ); - if( cmdname == "tableofcontents" ) + if (cmdname == "tableofcontents" ) return _("Table of Contents"); - else if( cmdname == "listofalgorithms" ) + else if (cmdname == "listofalgorithms" ) return _("List of Algorithms"); - else if( cmdname == "listoffigures" ) + else if (cmdname == "listoffigures" ) return _("List of Figures"); else return _("List of Tables"); @@ -31,11 +31,11 @@ string const InsetTOC::getScreenLabel() const Inset::Code InsetTOC::LyxCode() const { string cmdname( getCmdName() ); - if( cmdname == "tableofcontents" ) + if (cmdname == "tableofcontents" ) return Inset::TOC_CODE; - else if( cmdname == "listofalgorithms" ) + else if (cmdname == "listofalgorithms" ) return Inset::LOA_CODE; - else if( cmdname == "listoffigures" ) + else if (cmdname == "listoffigures" ) return Inset::LOF_CODE; else return Inset::LOT_CODE; @@ -50,7 +50,7 @@ void InsetTOC::Edit(BufferView * bv, int, int, unsigned int) int InsetTOC::Linuxdoc(Buffer const *, ostream & os) const { - if( getCmdName() == "tableofcontents" ) + if (getCmdName() == "tableofcontents" ) os << ""; return 0; } @@ -58,7 +58,7 @@ int InsetTOC::Linuxdoc(Buffer const *, ostream & os) const int InsetTOC::DocBook(Buffer const *, ostream & os) const { - if( getCmdName() == "tableofcontents" ) + if (getCmdName() == "tableofcontents" ) os << ""; return 0; } diff --git a/src/insets/inseturl.C b/src/insets/inseturl.C index 3f6cb00412..b95bc270af 100644 --- a/src/insets/inseturl.C +++ b/src/insets/inseturl.C @@ -28,12 +28,12 @@ void InsetUrl::Edit(BufferView * bv, int, int, unsigned int) string const InsetUrl::getScreenLabel() const { string temp; - if( getCmdName() == "url" ) + if (getCmdName() == "url" ) temp = _("Url: "); else temp = _("HtmlUrl: "); - if(!getOptions().empty()) + if (!getOptions().empty()) temp += getOptions(); else temp += getContents(); diff --git a/src/kbmap.C b/src/kbmap.C index bbdc5e5d77..389416e3e4 100644 --- a/src/kbmap.C +++ b/src/kbmap.C @@ -167,7 +167,7 @@ void kb_keymap::print(string & buf) const int kb_keymap::defkey(kb_sequence * seq, int action, int idx /*= 0*/) { unsigned int code = seq->sequence[idx]; - if(code == NoSymbol) return -1; + if (code == NoSymbol) return -1; unsigned int modmsk = seq->modifiers[idx]; @@ -185,7 +185,7 @@ int kb_keymap::defkey(kb_sequence * seq, int action, int idx /*= 0*/) << buf << "' is overriding old binding..." << endl; - if((*it).table) { + if ((*it).table) { delete (*it).table; (*it).table = 0; } diff --git a/src/kbsequence.C b/src/kbsequence.C index d5bdd3c3c1..26e13d412d 100644 --- a/src/kbsequence.C +++ b/src/kbsequence.C @@ -61,24 +61,24 @@ void printKeysym(unsigned int key, unsigned int mod, string & buf); int kb_sequence::addkey(unsigned int key, unsigned int mod, unsigned int nmod /*= 0*/) { - if(length < 0) length = 0; + if (length < 0) length = 0; - if(length + 1 >= size) { + if (length + 1 >= size) { unsigned int * nseq = new unsigned int[size + KB_PREALLOC]; size += KB_PREALLOC; memcpy(nseq, sequence, length * sizeof(unsigned int)); - if(sequence != staticseq) delete sequence; + if (sequence != staticseq) delete sequence; sequence = nseq; nseq = new unsigned int[size]; memcpy(nseq, modifiers, length * sizeof(unsigned int)); - if(modifiers != staticmod) delete modifiers; + if (modifiers != staticmod) delete modifiers; modifiers = nseq; } modifiers[length] = mod + (nmod << 16); sequence[length++] = key; - if(curmap) + if (curmap) return curmap->lookup(key, mod, this); return -1; @@ -98,16 +98,16 @@ int kb_sequence::addkey(unsigned int key, int kb_sequence::parse(string const & s) { - if(s.empty()) return 1; + if (s.empty()) return 1; string::size_type i = 0; unsigned int mod = 0, nmod = 0; while (i < s.length()) { - if(s[i] && (s[i]) <= ' ') ++i; - if(i >= s.length()) break; + if (s[i] && (s[i]) <= ' ') ++i; + if (i >= s.length()) break; - if(s[i + 1] == '-') { // is implicit that s[i] == true - switch(s[i]) { + if (s[i + 1] == '-') { // is implicit that s[i] == true + switch (s[i]) { case 's': case 'S': mod |= ShiftMask; i += 2; @@ -123,8 +123,8 @@ int kb_sequence::parse(string const & s) default: return i + 1; } - } else if(s[i] == '~' && s[i + 1] && s[i + 2] == '-') { - switch(s[i + 1]) { + } else if (s[i] == '~' && s[i + 1] && s[i + 2] == '-') { + switch (s[i + 1]) { case 's': case 'S': nmod |= ShiftMask; i += 3; @@ -143,11 +143,11 @@ int kb_sequence::parse(string const & s) } else { string tbuf; string::size_type j = i; - for(; j < s.length() && s[j] > ' '; ++j) + for (; j < s.length() && s[j] > ' '; ++j) tbuf += s[j]; // (!!!check bounds :-) KeySym key = XStringToKeysym(tbuf.c_str()); - if(key == NoSymbol) { + if (key == NoSymbol) { lyxerr[Debug::KBMAP] << "kbmap.C: No such keysym: " << tbuf << endl; @@ -179,15 +179,15 @@ int kb_sequence::print(string & buf, bool when_defined) const KeySym key; unsigned int mod; int l = length; - if ( l < 0 && !when_defined ) l = -l; + if (l < 0 && !when_defined ) l = -l; - for(int i = 0; i < l; ++i) { + for (int i = 0; i < l; ++i) { key = sequence[i]; mod = modifiers[i] & 0xffff; printKeysym(key, mod, buf); // RVDK_PATCH_5 - if(i + 1 < l) { // append a blank + if (i + 1 < l) { // append a blank buf += ' '; } } @@ -243,8 +243,8 @@ void kb_sequence::delseq() unsigned int kb_sequence::getsym() const { int l = length; - if(l == 0) return NoSymbol; - if(l < 0) l = -l; + if (l == 0) return NoSymbol; + if (l < 0) l = -l; return sequence[l - 1]; } @@ -261,7 +261,7 @@ char kb_sequence::getiso() const { int c = getsym(); - if(c > 0xff) + if (c > 0xff) return '\0'; return c; } diff --git a/src/layout.C b/src/layout.C index bad3b27411..8652f06d8e 100644 --- a/src/layout.C +++ b/src/layout.C @@ -188,7 +188,7 @@ bool LyXLayout::Read (LyXLex & lexrc, LyXTextClass const & tclass) while (!finished && lexrc.IsOK() && !error) { int le = lexrc.lex(); // See comment in lyxrc.C. - switch(le) { + switch (le) { case LyXLex::LEX_FEOF: continue; @@ -198,7 +198,7 @@ bool LyXLayout::Read (LyXLex & lexrc, LyXTextClass const & tclass) continue; default: break; } - switch(static_cast(le)) { + switch (static_cast(le)) { case LT_END: // end of structure finished = true; break; @@ -429,7 +429,7 @@ void LyXLayout::readAlign(LyXLex & lexrc) return; default: break; }; - switch(static_cast(le)) { + switch (static_cast(le)) { case AT_BLOCK: align = LYX_ALIGN_BLOCK; break; @@ -610,7 +610,7 @@ void LyXLayout::readEndLabelType(LyXLex & lexrc) pushpophelper pph(lexrc, endlabelTypeTags, END_LABEL_ENUM_LAST-END_LABEL_ENUM_FIRST+1); int le = lexrc.lex(); - switch(le) { + switch (le) { case LyXLex::LEX_UNDEF: lexrc.printError("Unknown labeltype tag `$$Token'"); break; @@ -641,7 +641,7 @@ void LyXLayout::readMargin(LyXLex & lexrc) pushpophelper pph(lexrc, marginTags, MARGIN_RIGHT_ADDRESS_BOX); int le = lexrc.lex(); - switch(le) { + switch (le) { case LyXLex::LEX_UNDEF: lexrc.printError("Unknown margin type tag `$$Token'"); return; @@ -710,13 +710,13 @@ void LyXLayout::readSpacing(LyXLex & lexrc) pushpophelper pph(lexrc, spacingTags, ST_OTHER); int le = lexrc.lex(); - switch(le) { + switch (le) { case LyXLex::LEX_UNDEF: lexrc.printError("Unknown spacing token `$$Token'"); return; default: break; } - switch(static_cast(le)) { + switch (static_cast(le)) { case ST_SPACING_SINGLE: spacing.set(Spacing::Single); break; @@ -835,7 +835,7 @@ bool LyXTextClass::Read(string const & filename, bool merge) // parsing while (lexrc.IsOK() && !error) { int le = lexrc.lex(); - switch(le) { + switch (le) { case LyXLex::LEX_FEOF: continue; @@ -845,7 +845,7 @@ bool LyXTextClass::Read(string const & filename, bool merge) continue; default: break; } - switch(static_cast(le)) { + switch (static_cast(le)) { case TC_OUTPUTTYPE: // output type definition readOutputType(lexrc); break; @@ -901,7 +901,7 @@ bool LyXTextClass::Read(string const & filename, bool merge) case TC_SIDES: if (lexrc.next()) { - switch(lexrc.GetInteger()) { + switch (lexrc.GetInteger()) { case 1: sides_ = OneSide; break; case 2: sides_ = TwoSides; break; default: @@ -1003,7 +1003,7 @@ void LyXTextClass::readOutputType(LyXLex & lexrc) pushpophelper pph(lexrc, outputTypeTags, LITERATE); int le = lexrc.lex(); - switch(le) { + switch (le) { case LyXLex::LEX_UNDEF: lexrc.printError("Unknown output type `$$Token'"); return; @@ -1053,7 +1053,7 @@ void LyXTextClass::readMaxCounter(LyXLex & lexrc) pushpophelper pph(lexrc, maxCounterTags, MC_COUNTER_ENUMIV); int le = lexrc.lex(); - switch(le) { + switch (le) { case LyXLex::LEX_UNDEF: lexrc.printError("Unknown MaxCounter tag `$$Token'"); return; @@ -1237,7 +1237,7 @@ LyXTextClassList::NumberOfLayout(LyXTextClassList::size_type textclass, string const & name) const { classlist[textclass].load(); - for(unsigned int i = 0; i < classlist[textclass].numLayouts(); ++i) { + for (unsigned int i = 0; i < classlist[textclass].numLayouts(); ++i) { if (classlist[textclass][i].name() == name) return make_pair(true, i); } diff --git a/src/lyx_cb.C b/src/lyx_cb.C index 9787b712a6..440abb97c6 100644 --- a/src/lyx_cb.C +++ b/src/lyx_cb.C @@ -657,7 +657,7 @@ LyXFont const UserFreeFont(BufferParams const & params) LyXFont font(LyXFont::ALL_IGNORE); int pos = fl_get_choice(fd_form_character->choice_family); - switch(pos) { + switch (pos) { case 1: font.setFamily(LyXFont::IGNORE_FAMILY); break; case 2: font.setFamily(LyXFont::ROMAN_FAMILY); break; case 3: font.setFamily(LyXFont::SANS_FAMILY); break; @@ -666,7 +666,7 @@ LyXFont const UserFreeFont(BufferParams const & params) } pos = fl_get_choice(fd_form_character->choice_series); - switch(pos) { + switch (pos) { case 1: font.setSeries(LyXFont::IGNORE_SERIES); break; case 2: font.setSeries(LyXFont::MEDIUM_SERIES); break; case 3: font.setSeries(LyXFont::BOLD_SERIES); break; @@ -674,7 +674,7 @@ LyXFont const UserFreeFont(BufferParams const & params) } pos = fl_get_choice(fd_form_character->choice_shape); - switch(pos) { + switch (pos) { case 1: font.setShape(LyXFont::IGNORE_SHAPE); break; case 2: font.setShape(LyXFont::UP_SHAPE); break; case 3: font.setShape(LyXFont::ITALIC_SHAPE); break; @@ -684,7 +684,7 @@ LyXFont const UserFreeFont(BufferParams const & params) } pos = fl_get_choice(fd_form_character->choice_size); - switch(pos) { + switch (pos) { case 1: font.setSize(LyXFont::IGNORE_SIZE); break; case 2: font.setSize(LyXFont::SIZE_TINY); break; case 3: font.setSize(LyXFont::SIZE_SCRIPT); break; @@ -702,7 +702,7 @@ LyXFont const UserFreeFont(BufferParams const & params) } pos = fl_get_choice(fd_form_character->choice_bar); - switch(pos) { + switch (pos) { case 1: font.setEmph(LyXFont::IGNORE); font.setUnderbar(LyXFont::IGNORE); font.setNoun(LyXFont::IGNORE); @@ -720,7 +720,7 @@ LyXFont const UserFreeFont(BufferParams const & params) } pos = fl_get_choice(fd_form_character->choice_color); - switch(pos) { + switch (pos) { case 1: font.setColor(LColor::ignore); break; case 2: font.setColor(LColor::none); break; case 3: font.setColor(LColor::black); break; @@ -835,7 +835,7 @@ void FigureApplyCB(FL_OBJECT *, long) return; Buffer * buffer = current_view->buffer(); - if(buffer->isReadonly()) // paranoia + if (buffer->isReadonly()) // paranoia return; current_view->owner()->getMiniBuffer()->Set(_("Inserting figure...")); diff --git a/src/lyx_gui.C b/src/lyx_gui.C index 87a41cceb8..cd81b5ee20 100644 --- a/src/lyx_gui.C +++ b/src/lyx_gui.C @@ -131,14 +131,14 @@ LyXGUI::LyXGUI(LyX * owner, int * argc, char * argv[], bool GUI) if (height < 400) height = 400; // If width is not set by geometry, check it against monitor width - if ( !(geometryBitmask & 4) ) { + if (!(geometryBitmask & 4)) { Screen * scr = ScreenOfDisplay(fl_get_display(), fl_screen); //DefaultScreen(fl_get_display()); if (WidthOfScreen(scr) - 8 < width) width = WidthOfScreen(scr) - 8; } // If height is not set by geometry, check it against monitor height - if ( !(geometryBitmask & 8) ) { + if (!(geometryBitmask & 8)) { Screen * scr = ScreenOfDisplay(fl_get_display(), fl_screen); //DefaultScreen(fl_get_display()); if (HeightOfScreen(scr) - 24 < height) height = HeightOfScreen(scr) - 24; @@ -340,7 +340,7 @@ void LyXGUI::create_forms() // build up the combox entries combo_language2->addline(_("No change")); combo_language2->addline(_("Reset")); - for(Languages::const_iterator cit = languages.begin(); + for (Languages::const_iterator cit = languages.begin(); cit != languages.end(); ++cit) { #ifdef DO_USE_DEFAULT_LANGUAGE if ((*cit).second.lang() != "default") diff --git a/src/lyx_main.C b/src/lyx_main.C index 045e8cc72a..324f2000c6 100644 --- a/src/lyx_main.C +++ b/src/lyx_main.C @@ -637,7 +637,7 @@ void LyX::ReadUIFile(string const & name) lex.printTable(lyxerr); while (lex.IsOK()) { - switch(lex.lex()) { + switch (lex.lex()) { case ui_menuset: menubackend.read(lex); break; @@ -717,7 +717,7 @@ bool LyX::easyParse(int * argc, char * argv[]) { bool gui = true; int removeargs = 0; // used when options are read - for(int i = 1; i < *argc; ++i) { + for (int i = 1; i < *argc; ++i) { string arg = argv[i]; // Check for -dbg int @@ -857,7 +857,7 @@ void error_handler(int err_sig) bufferlist.emergencyWriteAll(); lyxerr << "Bye." << endl; - if(err_sig!= SIGHUP && + if (err_sig!= SIGHUP && (!GetEnv("LYXDEBUG").empty() || err_sig == SIGSEGV)) lyx::abort(); exit(0); diff --git a/src/lyxfont.C b/src/lyxfont.C index 86d7939f17..fa54c547b5 100644 --- a/src/lyxfont.C +++ b/src/lyxfont.C @@ -192,7 +192,7 @@ LyXFont & LyXFont::decSize() /// Increases font size by one LyXFont & LyXFont::incSize() { - switch(size()) { + switch (size()) { case SIZE_HUGER: break; case SIZE_HUGE: setSize(SIZE_HUGER); break; case SIZE_LARGEST: setSize(SIZE_HUGE); break; @@ -245,7 +245,7 @@ LyXFont::FONT_MISC_STATE LyXFont::setMisc(FONT_MISC_STATE newfont, void LyXFont::update(LyXFont const & newfont, Language const * document_language, bool toggleall) { - if(newfont.family() == family() && toggleall) + if (newfont.family() == family() && toggleall) setFamily(INHERIT_FAMILY); // toggle 'back' else if (newfont.family() != IGNORE_FAMILY) setFamily(newfont.family()); @@ -268,7 +268,7 @@ void LyXFont::update(LyXFont const & newfont, break; } - if(newfont.shape() == shape() && toggleall) + if (newfont.shape() == shape() && toggleall) setShape(INHERIT_SHAPE); // toggle 'back' else if (newfont.shape() != IGNORE_SHAPE) setShape(newfont.shape()); diff --git a/src/lyxfr1.C b/src/lyxfr1.C index ca5e9aa51a..76a99e9cca 100644 --- a/src/lyxfr1.C +++ b/src/lyxfr1.C @@ -120,7 +120,7 @@ void LyXFindReplace::SearchReplaceCB() // in order to avoid endless loop :-( if (SF.SearchString().length() == 0 || (SF.SearchString().length() == 1 - && SF.SearchString()[0] == ' ') ) { + && SF.SearchString()[0] == ' ')) { WriteAlert(_("Sorry!"), _("You cannot replace a single space, " "nor an empty character.")); return; @@ -157,7 +157,7 @@ void LyXFindReplace::SearchReplaceAllCB() // in order to avoid endless loop :-( if (SF.SearchString().length() == 0 || (SF.SearchString().length() == 1 - && SF.SearchString()[0] == ' ') ) { + && SF.SearchString()[0] == ' ')) { WriteAlert(_("Sorry!"), _("You cannot replace a single space, " "nor an empty character.")); return; @@ -186,7 +186,7 @@ void LyXFindReplace::SearchReplaceAllCB() ++replace_count; } } while (SearchCB(true)); - if( replace_count == 0 ) { + if (replace_count == 0) { LyXBell(); bv->owner()->getMiniBuffer()->Set( _("String not found!")); diff --git a/src/lyxfunc.C b/src/lyxfunc.C index 9a64088e7f..893dc3b652 100644 --- a/src/lyxfunc.C +++ b/src/lyxfunc.C @@ -24,9 +24,6 @@ #endif #include "version.h" -#if 0 -#include "lyxlookup.h" -#endif #include "kbmap.h" #include "lyxfunc.h" #include "bufferlist.h" @@ -217,7 +214,7 @@ int LyXFunc::processKeySym(KeySym keysym, unsigned int state) // implementations? (Lgb) // This code snippet makes lyx ignore some keys. Perhaps // all of them should be explictly mentioned? - if((keysym >= XK_Shift_L && keysym <= XK_Hyper_R) + if ((keysym >= XK_Shift_L && keysym <= XK_Hyper_R) || keysym == XK_Mode_switch || keysym == 0x0) return 0; @@ -232,7 +229,7 @@ int LyXFunc::processKeySym(KeySym keysym, unsigned int state) // When not cancel or meta-fake, do the normal lookup. // Note how the meta_fake Mod1 bit is OR-ed in and reset afterwards. // Mostly, meta_fake_bit = 0. RVDK_PATCH_5. - if ( (action != LFUN_CANCEL) && (action != LFUN_META_FAKE) ) { + if ((action != LFUN_CANCEL) && (action != LFUN_META_FAKE)) { // remove Caps Lock and Mod2 as a modifiers action = keyseq.addkey(keysym, @@ -258,7 +255,7 @@ int LyXFunc::processKeySym(KeySym keysym, unsigned int state) // why not return already here if action == -1 and // num_bytes == 0? (Lgb) - if(keyseq.length > 1 || keyseq.length < -1) { + if (keyseq.length > 1 || keyseq.length < -1) { string buf; keyseq.print(buf); owner->getMiniBuffer()->Set(buf); @@ -296,141 +293,6 @@ int LyXFunc::processKeySym(KeySym keysym, unsigned int state) } -#if 0 -int LyXFunc::processKeyEvent(XEvent * ev) -{ - char s_r[10]; - KeySym keysym_return = 0; - string argument; - XKeyEvent * keyevent = &ev->xkey; - int num_bytes = LyXLookupString(ev, s_r, 10, &keysym_return); - s_r[num_bytes] = '\0'; - - if (lyxerr.debugging(Debug::KEY)) { - char * tmp = XKeysymToString(keysym_return); - string stm = (tmp ? tmp : ""); - lyxerr << "KeySym is " - << stm - << "[" - << keysym_return << "]" - << " and num_bytes is " - << num_bytes - << " the string returned is \"" - << s_r << '\"' - << endl; - } - // Do nothing if we have nothing (JMarc) - if (num_bytes == 0 && keysym_return == NoSymbol) { - lyxerr[Debug::KEY] << "Empty kbd action (probably composing)" - << endl; - return 0; - } - - // this function should be used always [asierra060396] - UpdatableInset * tli = owner->view()->theLockingInset(); - if (owner->view()->available() && tli && (keysym_return==XK_Escape)) { - if (tli == tli->GetLockingInset()) { - owner->view()->unlockInset(tli); - owner->view()->text->CursorRight(owner->view()); - moveCursorUpdate(false); - owner->showState(); - } else { - tli->UnlockInsetInInset(owner->view(), - tli->GetLockingInset(),true); - } - return 0; - } - - // Can we be sure that this will work for all X-Windows - // implementations? (Lgb) - // This code snippet makes lyx ignore some keys. Perhaps - // all of them should be explictly mentioned? - if((keysym_return >= XK_Shift_L && keysym_return <= XK_Hyper_R) - || keysym_return == XK_Mode_switch || keysym_return == 0x0) - return 0; - - // Do a one-deep top-level lookup for - // cancel and meta-fake keys. RVDK_PATCH_5 - cancel_meta_seq.reset(); - - int action = cancel_meta_seq.addkey(keysym_return, keyevent->state - &(ShiftMask|ControlMask - |Mod1Mask)); - - // When not cancel or meta-fake, do the normal lookup. - // Note how the meta_fake Mod1 bit is OR-ed in and reset afterwards. - // Mostly, meta_fake_bit = 0. RVDK_PATCH_5. - if ( (action != LFUN_CANCEL) && (action != LFUN_META_FAKE) ) { - - // remove Caps Lock and Mod2 as a modifiers - action = keyseq.addkey(keysym_return, - (keyevent->state | meta_fake_bit) - &(ShiftMask|ControlMask - |Mod1Mask)); - } - // Dont remove this unless you know what you are doing. - meta_fake_bit = 0; - - if (action == 0) action = LFUN_PREFIX; - - if (lyxerr.debugging(Debug::KEY)) { - string buf; - keyseq.print(buf); - lyxerr << "Key [" - << action << "][" - << buf << "]" - << "[" - << num_bytes << "]" - << endl; - } - - // already here we know if it any point in going further - // why not return already here if action == -1 and - // num_bytes == 0? (Lgb) - - if(keyseq.length > 1 || keyseq.length < -1) { - string buf; - keyseq.print(buf); - owner->getMiniBuffer()->Set(buf); - } - - if (action == -1) { - if (keyseq.length < -1) { // unknown key sequence... - string buf; - LyXBell(); - keyseq.print(buf); - owner->getMiniBuffer()->Set(_("Unknown sequence:"), buf); - return 0; - } - - char isochar = keyseq.getiso(); - if (!(keyevent->state&ControlMask) && - !(keyevent->state&Mod1Mask) && - (isochar && keysym_return < 0xF000)) { - argument += isochar; - } - if (argument.empty()) { - lyxerr.debug() << "Empty argument!" << endl; - // This can`t possibly be of any use - // so we`ll skip the dispatch. - return 0; - } - } - else - if (action == LFUN_SELFINSERT) { - argument = s_r[0]; - } - - bool tmp_sc = show_sc; - show_sc = false; - Dispatch(action, argument); - show_sc = tmp_sc; - - return 0; -} -#endif - - LyXFunc::func_status LyXFunc::getStatus(int ac) const { kb_action action; @@ -613,6 +475,9 @@ string const LyXFunc::Dispatch(string const & s) string const LyXFunc::Dispatch(int ac, string const & do_not_use_this_arg) { + lyxerr[Debug::ACTION] << "LyXFunc::Dispatch: action[" << ac + <<"] arg[" << do_not_use_this_arg << "]" << endl; + string argument; kb_action action; LyXText * text = 0; @@ -743,7 +608,7 @@ string const LyXFunc::Dispatch(int ac, return string(); else { setMessage(N_("Text mode")); - switch(action) { + switch (action) { case LFUN_UNKNOWN_ACTION: case LFUN_BREAKPARAGRAPH: case LFUN_BREAKLINE: @@ -783,7 +648,7 @@ string const LyXFunc::Dispatch(int ac, if (!text) text = owner->view()->text; - switch(action) { + switch (action) { // --- Misc ------------------------------------------- case LFUN_WORDFINDFORWARD : case LFUN_WORDFINDBACKWARD : { @@ -813,7 +678,7 @@ string const LyXFunc::Dispatch(int ac, owner->view()->text->ClearSelection(); // Move cursor so that successive C-s 's will not stand in place. - if( action == LFUN_WORDFINDFORWARD ) + if (action == LFUN_WORDFINDFORWARD ) owner->view()->text->CursorRightOneWord(owner->view()); owner->view()->text->FinishUndo(); moveCursorUpdate(false); @@ -849,7 +714,7 @@ string const LyXFunc::Dispatch(int ac, case LFUN_CANCEL: // RVDK_PATCH_5 keyseq.reset(); meta_fake_bit = 0; - if(owner->view()->available()) + if (owner->view()->available()) // cancel any selection Dispatch(LFUN_MARK_OFF); setMessage(N_("Cancel")); @@ -971,11 +836,11 @@ string const LyXFunc::Dispatch(int ac, { InsetCommandParams p; - if( action == LFUN_TOCVIEW ) + if (action == LFUN_TOCVIEW ) p.setCmdName( "tableofcontents" ); - else if( action == LFUN_LOAVIEW ) + else if (action == LFUN_LOAVIEW ) p.setCmdName( "listofalgorithms" ); - else if( action == LFUN_LOFVIEW ) + else if (action == LFUN_LOFVIEW ) p.setCmdName( "listoffigures" ); else p.setCmdName( "listoftables" ); @@ -991,17 +856,17 @@ string const LyXFunc::Dispatch(int ac, { InsetCommandParams p; - if( action == LFUN_TOC_INSERT ) + if (action == LFUN_TOC_INSERT ) p.setCmdName( "tableofcontents" ); - else if( action == LFUN_LOA_INSERT ) + else if (action == LFUN_LOA_INSERT ) p.setCmdName( "listofalgorithms" ); - else if( action == LFUN_LOF_INSERT ) + else if (action == LFUN_LOF_INSERT ) p.setCmdName( "listoffigures" ); else p.setCmdName( "listoftables" ); Inset * inset = new InsetTOC( p ); - if( !owner->view()->insertInset( inset, "Standard", true ) ) + if (!owner->view()->insertInset( inset, "Standard", true ) ) delete inset; break; } @@ -1165,7 +1030,7 @@ string const LyXFunc::Dispatch(int ac, && owner->view()->text->cursor.par()->footnoteflag != LyXParagraph::NO_FOOTNOTE) { // only melt footnotes with FOOTMELT, not margins etc - if(owner->view()->text->cursor.par()->footnotekind == LyXParagraph::FOOTNOTE) + if (owner->view()->text->cursor.par()->footnotekind == LyXParagraph::FOOTNOTE) Melt(owner->view()); } else @@ -1179,7 +1044,7 @@ string const LyXFunc::Dispatch(int ac, && owner->view()->text->cursor.par()->footnoteflag != LyXParagraph::NO_FOOTNOTE) { // only melt margins - if(owner->view()->text->cursor.par()->footnotekind == LyXParagraph::MARGIN) + if (owner->view()->text->cursor.par()->footnotekind == LyXParagraph::MARGIN) Melt(owner->view()); } else Margin(owner->view()); @@ -1567,7 +1432,7 @@ string const LyXFunc::Dispatch(int ac, { LyXText * tmptext = owner->view()->text; bool is_rtl = tmptext->cursor.par()->isRightToLeftPar(owner->buffer()->params); - if(!tmptext->mark_set) + if (!tmptext->mark_set) owner->view()->beforeChange(); owner->view()->update(BufferView::SELECT|BufferView::FITCUR); if (is_rtl) @@ -1596,7 +1461,7 @@ string const LyXFunc::Dispatch(int ac, // it simpler? (Lgb) LyXText * txt = owner->view()->text; bool is_rtl = txt->cursor.par()->isRightToLeftPar(owner->buffer()->params); - if(!txt->mark_set) owner->view()->beforeChange(); + if (!txt->mark_set) owner->view()->beforeChange(); owner->view()->update(BufferView::SELECT|BufferView::FITCUR); LyXCursor cur = txt->cursor; if (!is_rtl) @@ -1631,7 +1496,7 @@ string const LyXFunc::Dispatch(int ac, break; case LFUN_UP: - if(!owner->view()->text->mark_set) owner->view()->beforeChange(); + if (!owner->view()->text->mark_set) owner->view()->beforeChange(); owner->view()->update(BufferView::UPDATE); owner->view()->text->CursorUp(owner->view()); owner->view()->text->FinishUndo(); @@ -1640,7 +1505,7 @@ string const LyXFunc::Dispatch(int ac, break; case LFUN_DOWN: - if(!owner->view()->text->mark_set) + if (!owner->view()->text->mark_set) owner->view()->beforeChange(); owner->view()->update(BufferView::UPDATE); owner->view()->text->CursorDown(owner->view()); @@ -1650,7 +1515,7 @@ string const LyXFunc::Dispatch(int ac, break; case LFUN_UP_PARAGRAPH: - if(!owner->view()->text->mark_set) + if (!owner->view()->text->mark_set) owner->view()->beforeChange(); owner->view()->update(BufferView::UPDATE); owner->view()->text->CursorUpParagraph(owner->view()); @@ -1660,7 +1525,7 @@ string const LyXFunc::Dispatch(int ac, break; case LFUN_DOWN_PARAGRAPH: - if(!owner->view()->text->mark_set) + if (!owner->view()->text->mark_set) owner->view()->beforeChange(); owner->view()->update(BufferView::UPDATE); owner->view()->text->CursorDownParagraph(owner->view()); @@ -1670,7 +1535,7 @@ string const LyXFunc::Dispatch(int ac, break; case LFUN_PRIOR: - if(!text->mark_set) + if (!text->mark_set) owner->view()->beforeChange(); owner->view()->update(BufferView::UPDATE); owner->view()->cursorPrevious(text); @@ -1683,7 +1548,7 @@ string const LyXFunc::Dispatch(int ac, break; case LFUN_NEXT: - if(!text->mark_set) + if (!text->mark_set) owner->view()->beforeChange(); owner->view()->update(BufferView::UPDATE); owner->view()->cursorNext(text); @@ -1696,7 +1561,7 @@ string const LyXFunc::Dispatch(int ac, break; case LFUN_HOME: - if(!owner->view()->text->mark_set) + if (!owner->view()->text->mark_set) owner->view()->beforeChange(); owner->view()->update(BufferView::SELECT|BufferView::FITCUR); owner->view()->text->CursorHome(owner->view()); @@ -1706,7 +1571,7 @@ string const LyXFunc::Dispatch(int ac, break; case LFUN_END: - if(!owner->view()->text->mark_set) + if (!owner->view()->text->mark_set) owner->view()->beforeChange(); owner->view()->update(BufferView::SELECT|BufferView::FITCUR); owner->view()->text->CursorEnd(owner->view()); @@ -1717,7 +1582,7 @@ string const LyXFunc::Dispatch(int ac, case LFUN_SHIFT_TAB: case LFUN_TAB: - if(!owner->view()->text->mark_set) + if (!owner->view()->text->mark_set) owner->view()->beforeChange(); owner->view()->update(BufferView::SELECT|BufferView::FITCUR); owner->view()->text->CursorTab(owner->view()); @@ -1727,7 +1592,7 @@ string const LyXFunc::Dispatch(int ac, break; case LFUN_WORDRIGHT: - if(!text->mark_set) + if (!text->mark_set) owner->view()->beforeChange(); owner->view()->update(BufferView::SELECT|BufferView::FITCUR); if (text->cursor.par()->isRightToLeftPar(owner->buffer()->params)) @@ -1742,7 +1607,7 @@ string const LyXFunc::Dispatch(int ac, break; case LFUN_WORDLEFT: - if(!text->mark_set) + if (!text->mark_set) owner->view()->beforeChange(); owner->view()->update(BufferView::SELECT|BufferView::FITCUR); if (text->cursor.par()->isRightToLeftPar(owner->buffer()->params)) @@ -1757,7 +1622,7 @@ string const LyXFunc::Dispatch(int ac, break; case LFUN_BEGINNINGBUF: - if(!owner->view()->text->mark_set) + if (!owner->view()->text->mark_set) owner->view()->beforeChange(); owner->view()->update(BufferView::SELECT|BufferView::FITCUR); owner->view()->text->CursorTop(owner->view()); @@ -1767,7 +1632,7 @@ string const LyXFunc::Dispatch(int ac, break; case LFUN_ENDBUF: - if(!owner->view()->text->mark_set) + if (!owner->view()->text->mark_set) owner->view()->beforeChange(); owner->view()->update(BufferView::SELECT|BufferView::FITCUR); owner->view()->text->CursorBottom(owner->view()); @@ -1933,7 +1798,7 @@ string const LyXFunc::Dispatch(int ac, break; case LFUN_SETMARK: - if(text->mark_set) { + if (text->mark_set) { owner->view()->beforeChange(); owner->view()->update(BufferView::SELECT|BufferView::FITCUR); setMessage(N_("Mark removed")); @@ -2385,7 +2250,7 @@ string const LyXFunc::Dispatch(int ac, { LyXParagraph::size_type pos = owner->view()->text->cursor.pos(); - if(pos < owner->view()->text->cursor.par()->size()) + if (pos < owner->view()->text->cursor.par()->size()) //dispatch_buffer = owner->view()->text-> // cursor.par()->text[pos]; dispatch_buffer = @@ -2419,9 +2284,9 @@ string const LyXFunc::Dispatch(int ac, case LFUN_GETFONT: { LyXFont & font = owner->view()->text->current_font; - if(font.shape() == LyXFont::ITALIC_SHAPE) + if (font.shape() == LyXFont::ITALIC_SHAPE) dispatch_buffer = 'E'; - else if(font.shape() == LyXFont::SMALLCAPS_SHAPE) + else if (font.shape() == LyXFont::SMALLCAPS_SHAPE) dispatch_buffer = 'N'; else dispatch_buffer = '0'; @@ -2432,7 +2297,7 @@ string const LyXFunc::Dispatch(int ac, case LFUN_GETLATEX: { LyXFont & font = owner->view()->text->current_font; - if(font.latex() == LyXFont::ON) + if (font.latex() == LyXFont::ON) dispatch_buffer = 'L'; else dispatch_buffer = '0'; @@ -2755,13 +2620,13 @@ string const LyXFunc::Dispatch(int ac, { InsetCommandParams p( "index" ); - if( argument.empty() ) { + if (argument.empty()) { // Get the word immediately preceding the cursor LyXParagraph::size_type curpos = owner->view()->text->cursor.pos() - 1; string curstring; - if( curpos >= 0 ) + if (curpos >= 0 ) curstring = owner->view()->text ->cursor.par()->GetWord(curpos); @@ -2793,7 +2658,7 @@ string const LyXFunc::Dispatch(int ac, LyXParagraph::size_type curpos = owner->view()->text->cursor.pos() - 1; // Can't do that at the beginning of a paragraph - if( curpos < 0 ) break; + if (curpos < 0 ) break; string curstring( owner->view()->text ->cursor.par()->GetWord(curpos) ); @@ -3013,7 +2878,7 @@ string const LyXFunc::Dispatch(int ac, case LFUN_UNKNOWN_ACTION: { - if(!owner->buffer()) { + if (!owner->buffer()) { LyXBell(); setErrorMessage(N_("No document open")); break; @@ -3033,7 +2898,7 @@ string const LyXFunc::Dispatch(int ac, * "auto_region_delete", which defaults to * true (on). */ - if ( lyxrc.auto_region_delete ) { + if (lyxrc.auto_region_delete) { if (owner->view()->text->selection){ owner->view()->text->CutSelection(owner->view(), false); owner->view()->update(BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE); @@ -3144,7 +3009,7 @@ void LyXFunc::MenuNew(bool fromTemplate) // Check if the document already is open if (bufferlist.exists(s)) { - switch(AskConfirmation(_("Document is already open:"), + switch (AskConfirmation(_("Document is already open:"), MakeDisplayPath(s, 50), _("Do you want to close that document now?\n" "('No' will just switch to the open version)"))) @@ -3307,7 +3172,7 @@ void LyXFunc::doImport(string const & argument) // Check if the document already is open if (bufferlist.exists(lyxfile)) { - switch(AskConfirmation(_("Document is already open:"), + switch (AskConfirmation(_("Document is already open:"), MakeDisplayPath(lyxfile, 50), _("Do you want to close that document now?\n" "('No' will just switch to the open version)"))) diff --git a/src/lyxfunc.h b/src/lyxfunc.h index cfca897c92..ae7a8683ec 100644 --- a/src/lyxfunc.h +++ b/src/lyxfunc.h @@ -49,13 +49,9 @@ public: /// Same again but for xtl buffers. Still looking for better idea. bool Dispatch(int action, auto_mem_buffer &); -#if 0 - /// A keyboard event is processed to execute a lyx action. - int processKeyEvent(XEvent * ev); -#else /// int processKeySym(KeySym k, unsigned int state); -#endif + /// func_status getStatus(int ac) const; diff --git a/src/lyxlex_pimpl.C b/src/lyxlex_pimpl.C index 1f8309193d..2dcd2c054c 100644 --- a/src/lyxlex_pimpl.C +++ b/src/lyxlex_pimpl.C @@ -53,7 +53,7 @@ void LyXLex::Pimpl::printError(string const & message) const void LyXLex::Pimpl::printTable(ostream & os) { os << "\nNumber of tags: " << no_items << '\n'; - for(int i= 0; i < no_items; ++i) + for (int i= 0; i < no_items; ++i) os << "table[" << i << "]: tag: `" << table[i].tag << "' code:" << table[i].code << '\n'; diff --git a/src/lyxlookup.C b/src/lyxlookup.C index aecd62b019..0b48540116 100644 --- a/src/lyxlookup.C +++ b/src/lyxlookup.C @@ -180,7 +180,7 @@ int LyXLookupString(XEvent * event, result = XmbLookupString(xic, &event->xkey, buffer_return, bytes_buffer, keysym_return, &status_return); - switch(status_return) { + switch (status_return) { case XBufferOverflow: lyxerr[Debug::KEY] << "XBufferOverflow" << endl; break; diff --git a/src/lyxrc.C b/src/lyxrc.C index 8f420b8f76..36ba4f501c 100644 --- a/src/lyxrc.C +++ b/src/lyxrc.C @@ -285,7 +285,7 @@ int LyXRC::read(string const & filename) // compiler. int le = lexrc.lex(); - switch(le) { + switch (le) { case LyXLex::LEX_UNDEF: lexrc.printError("Unknown tag `$$Token'"); continue; @@ -849,7 +849,7 @@ int LyXRC::read(string const & filename) break; case RC_NEW_ASK_FILENAME: - if ( lexrc.next()) + if (lexrc.next()) new_ask_filename = lexrc.GetBool(); break; case RC_CONVERTER: { @@ -888,7 +888,7 @@ int LyXRC::read(string const & filename) break; } case RC_DEFAULT_LANGUAGE: - if ( lexrc.next()) + if (lexrc.next()) default_language = lexrc.GetString(); break; @@ -938,7 +938,7 @@ void LyXRC::output(ostream & os) const // The nice thing is that we will get a warning from the compiler // if we forget an element. LyXRCTags tag = RC_LAST; - switch(tag) { + switch (tag) { case RC_LAST: case RC_INPUT: // input/include files are not done here @@ -1495,7 +1495,7 @@ string LyXRC::getDescription(LyXRCTags tag) { string str; - switch( tag ) { + switch (tag) { case RC_FONT_ENCODING: str = N_("The font encoding used for the LaTeX2e fontenc package. T1 is highly recommended for non-English languages."); break; diff --git a/src/lyxserver.C b/src/lyxserver.C index 1760a0f618..eb9483dc02 100644 --- a/src/lyxserver.C +++ b/src/lyxserver.C @@ -72,7 +72,7 @@ using std::endl; // provide an empty mkfifo() if we do not have one. This disables the // lyxserver. #ifndef HAVE_MKFIFO -int mkfifo(char const * __path, mode_t __mode ) { +int mkfifo(char const * __path, mode_t __mode) { return 0; } #endif @@ -240,7 +240,7 @@ void LyXComm::closeConnection() { return; } - if(infd > -1) { + if (infd > -1) { fl_remove_io_callback(infd, FL_READ, C_LyXComm_callback); string tmp = pipename + ".in"; @@ -264,7 +264,7 @@ void LyXComm::closeConnection() { }; #endif } - if(outfd > -1) { + if (outfd > -1) { string tmp = pipename + ".out"; #ifdef __EMX__ rc = DosDisConnectNPipe(outfd); @@ -309,7 +309,7 @@ void LyXComm::callback(int fd, void *v) // the single = is intended here. while((status = read(fd, charbuf, CMDBUFLEN-1))) {// break and return in loop - if(status > 0) // got something + if (status > 0) // got something { charbuf[status]= '\0'; // turn it into a c string lsbuf += strip(charbuf, '\r'); @@ -325,22 +325,22 @@ void LyXComm::callback(int fd, void *v) << "LyXComm: status:" << status << ", lsbuf:" << lsbuf << ", cmd:" << cmd << endl; - if(!cmd.empty()) + if (!cmd.empty()) c->clientcb(c->client, cmd); //\n or not \n? } } - if(errno == EAGAIN) + if (errno == EAGAIN) { // EAGAIN is not really an error , it means we're // only reading too fast for the writing process on // the other end of the pipe. errno = 0; return; // up to libforms select-loop (*crunch*) } - if(errno != 0 ) + if (errno != 0 ) { lyxerr << "LyXComm: " << strerror(errno) << endl; - if(!lsbuf.empty()) + if (!lsbuf.empty()) { lyxerr << "LyxComm: truncated command: " << lsbuf << endl; @@ -434,7 +434,7 @@ void LyXServer::callback(LyXServer * serv, string const & msg) if (strncmp(p, "LYXSRV:", 7) == 0) { server_only = true; - } else if(0!= strncmp(p, "LYXCMD:", 7)) { + } else if (0!= strncmp(p, "LYXCMD:", 7)) { lyxerr << "LyXServer: Unknown request" << endl; return; } @@ -444,8 +444,8 @@ void LyXServer::callback(LyXServer * serv, string const & msg) string client; while(*p && *p != ':') client += char(*p++); - if(*p == ':') ++p; - if(!*p) return; + if (*p == ':') ++p; + if (!*p) return; // --- 3. get function name --- string cmd; @@ -454,10 +454,10 @@ void LyXServer::callback(LyXServer * serv, string const & msg) // --- 4. parse the argument --- string arg; - if(!server_only && *p == ':' && *(++p)) { + if (!server_only && *p == ':' && *(++p)) { while(*p && *p != '\n') arg += char(*p++); - if(*p) ++p; + if (*p) ++p; } lyxerr[Debug::LYXSERVER] @@ -473,7 +473,7 @@ void LyXServer::callback(LyXServer * serv, string const & msg) // we are listening. if (cmd == "hello") { // One more client - if(serv->numclients == MAX_CLIENTS){ //paranoid check + if (serv->numclients == MAX_CLIENTS){ //paranoid check lyxerr[Debug::LYXSERVER] << "LyXServer: too many clients..." << endl; diff --git a/src/mathed/formula.C b/src/mathed/formula.C index 3b56a6ce2b..674de866f1 100644 --- a/src/mathed/formula.C +++ b/src/mathed/formula.C @@ -1011,7 +1011,7 @@ InsetFormula::LocalDispatch(BufferView * bv, if (lf[1]) { l = in_word_set(lf, strlen(lf)); // Long words will cause l == 0; so check. - if(l) ilf = l->id; + if (l) ilf = l->id; } else if (vdelim.find(lf[0]) != string::npos) ilf = lf[0]; @@ -1022,7 +1022,7 @@ InsetFormula::LocalDispatch(BufferView * bv, else if (rg[1]) { l = in_word_set(rg, strlen(rg)); - if(l) irg = l->id; + if (l) irg = l->id; } else if (vdelim.find(rg[0]) != string::npos) irg = rg[0]; @@ -1274,7 +1274,7 @@ void mathedValidate(LaTeXFeatures & features, MathParInset * par) while (it.OK() && !(features.binom && features.boldsymbol)) { if (it.IsInset()) { - if(it.IsActive()) { + if (it.IsActive()) { MathParInset * p = it.GetActiveInset(); if (!features.binom && p->GetType() == LM_OT_MACRO && p->GetName() == "binom") { diff --git a/src/mathed/math_iter.C b/src/mathed/math_iter.C index a6ef6eaedf..cf72b48bd5 100644 --- a/src/mathed/math_iter.C +++ b/src/mathed/math_iter.C @@ -43,7 +43,7 @@ void my_memcpy( void * ps_in, const void * pt_in, size_t n ) char * ps = static_cast(ps_in); char const * pt = static_cast(pt_in); /* - for(size_t i = n; i--;) + for (size_t i = n; i--;) *ps++ = *pt++; */ while (n--) *ps++ = *pt++; diff --git a/src/mathed/math_symbols.C b/src/mathed/math_symbols.C index f36000774d..8d35d24bd6 100644 --- a/src/mathed/math_symbols.C +++ b/src/mathed/math_symbols.C @@ -235,12 +235,12 @@ int peek_event(FL_FORM * /*form*/, void *xev) if (BitmapMenu::active == 0) return 0; - if(static_cast(xev)->type == ButtonPress) + if (static_cast(xev)->type == ButtonPress) { BitmapMenu::active->Hide(); return 1; } - if(static_cast(xev)->type == KeyPress) + if (static_cast(xev)->type == KeyPress) { char c[5]; KeySym keysym; diff --git a/src/mathed/math_write.C b/src/mathed/math_write.C index f70873edbb..56e03464b5 100644 --- a/src/mathed/math_write.C +++ b/src/mathed/math_write.C @@ -239,7 +239,7 @@ void MathParInset::Write(ostream & os, bool fragile) os << '}'; data.Next(); } else - switch(cx) { + switch (cx) { case LM_TC_TAB: { os << " & "; diff --git a/src/paragraph.C b/src/paragraph.C index 2fd52c60b4..d3e63a193b 100644 --- a/src/paragraph.C +++ b/src/paragraph.C @@ -1805,7 +1805,7 @@ int LyXParagraph::GetEndLabel(BufferParams const & bparams) const if (endlabeltype != END_LABEL_NO_LABEL) { LyXParagraph const * last = this; #ifndef NEW_INSETS - if( footnoteflag == NO_FOOTNOTE) + if (footnoteflag == NO_FOOTNOTE) last = LastPhysicalPar(); else if (next->footnoteflag == NO_FOOTNOTE) return endlabeltype; @@ -2315,7 +2315,7 @@ LyXParagraph * LyXParagraph::TeXOnePar(Buffer const * buf, ? GetFontSettings(bparams, size()-1).isRightToLeft() : language->RightToLeft(); - if ( (p = NextAfterFootnote()) != 0 && + if ((p = NextAfterFootnote()) != 0 && p->size() > 0 && p->GetFontSettings(bparams, 0).isRightToLeft() != is_rtl) is_rtl = getParLanguage(bparams)->RightToLeft(); @@ -2922,7 +2922,7 @@ void LyXParagraph::SimpleTeXSpecialChars(Buffer const * buf, } // Otherwise, we use what LaTeX // provides us. - switch(c) { + switch (c) { case '<': os << "\\textless{}"; column += 10; @@ -3169,7 +3169,7 @@ LyXParagraph * LyXParagraph::TeXEnvironment(Buffer const * buf, texrow.newline(); } os << "\\begin{minipage}"; - switch(pextra_alignment) { + switch (pextra_alignment) { case MINIPAGE_ALIGN_TOP: os << "[t]"; break; @@ -3308,7 +3308,7 @@ LyXParagraph * LyXParagraph::TeXEnvironment(Buffer const * buf, texrow.newline(); } os << "\\begin{minipage}"; - switch(par->pextra_alignment) { + switch (par->pextra_alignment) { case MINIPAGE_ALIGN_TOP: os << "[t]"; break; @@ -3842,7 +3842,7 @@ bool LyXParagraph::IsLetter(LyXParagraph::size_type pos) const if (IsLetterChar(c)) return true; // '\0' is not a letter, allthough every string contains "" (below) - if( c == '\0') + if (c == '\0') return false; // We want to pass the ' and escape chars to ispell string extra = lyxrc.isp_esc_chars + '\''; @@ -3892,7 +3892,7 @@ bool LyXParagraph::isRightToLeftPar(BufferParams const & bparams) const void LyXParagraph::ChangeLanguage(BufferParams const & bparams, Language const * from, Language const * to) { - for(size_type i = 0; i < size(); ++i) { + for (size_type i = 0; i < size(); ++i) { LyXFont font = GetFontSettings(bparams, i); if (font.language() == from) { font.setLanguage(to); diff --git a/src/screen.C b/src/screen.C index 8d7b8e9095..438d48c2c7 100644 --- a/src/screen.C +++ b/src/screen.C @@ -126,9 +126,8 @@ void LyXScreen::DrawOneRow(LyXText * text, Row * row, int y_text, { int y = y_text - text->first + y_offset; - if (((y+row->height()) > 0) && - ((y-row->height()) <= (int)owner.height())) - { + if (((y + row->height()) > 0) && + ((y - row->height()) <= static_cast(owner.height()))) { // ok there is something visible LyXText::text_status st = text->status; do { @@ -221,16 +220,16 @@ bool LyXScreen::FitManualCursor(LyXText * text, { int newtop = text->first; - if (y + desc - text->first >= (int)owner.height()) + if (y + desc - text->first >= static_cast(owner.height())) newtop = y - 3 * owner.height() / 4; // the scroll region must be so big!! - else if (y - asc < (int)text->first + else if (y - asc < static_cast(text->first) && text->first > 0) { newtop = y - owner.height() / 4; } newtop = max(newtop, 0); // can newtop ever be < 0? (Lgb) - if (newtop != (int)text->first) { + if (newtop != static_cast(text->first)) { Draw(text, newtop); text->first = newtop; return true; @@ -243,7 +242,7 @@ void LyXScreen::ShowManualCursor(LyXText const * text, int x, int y, int asc, int desc, Cursor_Shape shape) { int y1 = max(y - text->first - asc, 0); - int y2 = min(y - text->first + desc, (int)owner.height()); + int y2 = min(y - text->first + desc, static_cast(owner.height())); // Secure against very strange situations y2 = max(y2, y1); @@ -253,11 +252,11 @@ void LyXScreen::ShowManualCursor(LyXText const * text, int x, int y, cursor_pixmap = 0; } - if ((y2 > 0) && (y1 < int(owner.height()))) { + if (y2 > 0 && y1 < int(owner.height())) { cursor_pixmap_h = y2 - y1 + 1; cursor_pixmap_y = y1; - switch(shape) { + switch (shape) { case BAR_SHAPE: cursor_pixmap_w = 1; cursor_pixmap_x = x; @@ -294,7 +293,7 @@ void LyXScreen::ShowManualCursor(LyXText const * text, int x, int y, y1 + owner.ypos(), x + owner.xpos(), y2 + owner.ypos()); - switch(shape) { + switch (shape) { case BAR_SHAPE: break; case L_SHAPE: @@ -358,7 +357,7 @@ unsigned int LyXScreen::TopCursorVisible(LyXText const * text) else newtop = text->cursor.y() - 3 * owner.height() / 4; /* the scroll region must be so big!! */ - } else if ((int)(text->cursor.y() - text->cursor.row()->baseline()) < + } else if (static_cast((text->cursor.y()) - text->cursor.row()->baseline()) < text->first && text->first > 0) { if (text->cursor.row()->height() < owner.height() @@ -391,7 +390,7 @@ bool LyXScreen::FitCursor(LyXText * text) void LyXScreen::Update(LyXText * text, int y_offset, int x_offset) { - switch(text->status) { + switch (text->status) { case LyXText::NEED_MORE_REFRESH: { int y = max(int(text->refresh_y - text->first), 0); @@ -425,14 +424,15 @@ void LyXScreen::ToggleSelection(LyXText * text, bool kill_selection, // only if there is a selection if (!text->selection) return; - int bottom = min(max((int)(text->sel_end_cursor.y() + int bottom = min(max(static_cast(text->sel_end_cursor.y() - text->sel_end_cursor.row()->baseline() - + text->sel_end_cursor.row()->height()), text->first), - (int)(text->first + owner.height())); - int top = min(max((int)(text->sel_start_cursor.y() - + + text->sel_end_cursor.row()->height()), + text->first), + static_cast(text->first + owner.height())); + int top = min(max(static_cast(text->sel_start_cursor.y() - text->sel_start_cursor.row()->baseline()), text->first), - (int)(text->first + owner.height())); + static_cast(text->first + owner.height())); if (kill_selection) text->selection = 0; @@ -456,8 +456,10 @@ void LyXScreen::ToggleToggle(LyXText * text, int y_offset, int x_offset) - text->toggle_end_cursor.row()->baseline() + text->toggle_end_cursor.row()->height(); - bottom = min(max(bottom, text->first), (int)(text->first + owner.height())); - top = min(max(top, text->first), (int)(text->first + owner.height())); + bottom = min(max(bottom, text->first), + static_cast(text->first + owner.height())); + top = min(max(top, text->first), + static_cast(text->first + owner.height())); DrawFromTo(text, top - text->first, bottom - text->first, y_offset, x_offset); diff --git a/src/spellchecker.C b/src/spellchecker.C index fa208ce363..53492cefbe 100644 --- a/src/spellchecker.C +++ b/src/spellchecker.C @@ -301,7 +301,7 @@ void init_spell_checker(BufferParams const & params, string const & lang) isp_pid = -1; - if(pipe(pipein) == -1 || pipe(pipeout) == -1) { + if (pipe(pipein) == -1 || pipe(pipeout) == -1) { lyxerr << "LyX: Can't create pipe for spellchecker!" << endl; goto END; } @@ -324,13 +324,13 @@ void init_spell_checker(BufferParams const & params, string const & lang) isp_pid = fork(); - if(isp_pid == -1) { + if (isp_pid == -1) { lyxerr << "LyX: Can't create child process for spellchecker!" << endl; goto END; } - if(isp_pid == 0) { + if (isp_pid == 0) { /* child process */ dup2(pipein[0], STDIN_FILENO); dup2(pipeout[1], STDOUT_FILENO); @@ -584,7 +584,7 @@ void sc_accept_word(string const & word) static inline void sc_store_replacement(string const & mis, string const & cor) { - if(actual_spell_checker == ASC_ASPELL) { + if (actual_spell_checker == ASC_ASPELL) { ::fputs("$$ra ", out); ::fputs(mis.c_str(), out); ::fputc(',', out); @@ -840,7 +840,7 @@ bool RunSpellChecker(BufferView * bv) // Update slider if and only if value has changed newvalue = int(100.0*newval); - if(newvalue!= oldval) { + if (newvalue!= oldval) { oldval = newvalue; fl_set_slider_value(fd_form_spell_check->slider, oldval); } @@ -946,7 +946,7 @@ bool RunSpellChecker(BufferView * bv) } } - if(sc_still_alive()) { + if (sc_still_alive()) { close_spell_checker(); string word_msg(tostr(word_count)); if (word_count != 1) { diff --git a/src/support/FileInfo.C b/src/support/FileInfo.C index 944652b9e1..aade9e243a 100644 --- a/src/support/FileInfo.C +++ b/src/support/FileInfo.C @@ -373,7 +373,7 @@ bool FileInfo::isSocket() const // should not be in FileInfo -bool FileInfo::access(int p) +bool FileInfo::access(int p) const { // if we don't have a filename we fail if (fname.empty()) return false; diff --git a/src/support/FileInfo.h b/src/support/FileInfo.h index 93bbadc8fb..d52034feff 100644 --- a/src/support/FileInfo.h +++ b/src/support/FileInfo.h @@ -21,12 +21,12 @@ #include #include #include - +#include #include "LString.h" /** Use objects of this class to get information about files. */ -class FileInfo { +class FileInfo : public noncopyable { public: /// FileInfo(); @@ -101,15 +101,15 @@ public: eperm = F_OK }; /// Test whether the current user has a given set of permissions - bool access(int p); + bool access(int p) const; /// Is the file writable for the current user? - bool writable() { return access(FileInfo::wperm); } + bool writable() const { return access(FileInfo::wperm); } /// Is the file readable for the current user? - bool readable() { return access(FileInfo::rperm); } + bool readable() const { return access(FileInfo::rperm); } /// Is the file executable for the current user? - bool executable() { return access(FileInfo::xperm); } + bool executable() const { return access(FileInfo::xperm); } /// Does the file exist? - bool exist() { return access(FileInfo::eperm); } + bool exist() const { return access(FileInfo::eperm); } /// bool isLink() const; /// diff --git a/src/support/filetools.C b/src/support/filetools.C index 748c210dbb..c1052a180a 100644 --- a/src/support/filetools.C +++ b/src/support/filetools.C @@ -546,7 +546,7 @@ string const MakeAbsPath(string const & RelPath, string const & BasePath) // checks for already absolute path if (AbsolutePath(RelPath)) #ifdef __EMX__ - if(RelPath[0]!= '/' && RelPath[0]!= '\\') + if (RelPath[0]!= '/' && RelPath[0]!= '\\') #endif return RelPath; diff --git a/src/support/lstrings.C b/src/support/lstrings.C index 270af081b9..547d0790aa 100644 --- a/src/support/lstrings.C +++ b/src/support/lstrings.C @@ -88,7 +88,7 @@ bool isStrInt(string const & str) if (tmpstr.empty()) return false; string::const_iterator cit = tmpstr.begin(); - if ( (*cit) == '-') ++cit; + if ((*cit) == '-') ++cit; string::const_iterator end = tmpstr.end(); for (; cit != end; ++cit) { if (!isdigit((*cit))) return false; @@ -121,7 +121,7 @@ bool isStrDbl(string const & str) string::const_iterator cit = tmpstr.begin(); bool found_dot(false); - if ( (*cit) == '-') ++cit; + if ((*cit) == '-') ++cit; string::const_iterator end = tmpstr.end(); for (; cit != end; ++cit) { if (!isdigit((*cit)) @@ -427,7 +427,7 @@ string const subst(string const & a, char oldchar, char newchar) string tmp(a); string::iterator lit = tmp.begin(); string::iterator end = tmp.end(); - for(; lit != end; ++lit) + for (; lit != end; ++lit) if ((*lit) == oldchar) (*lit) = newchar; return tmp; diff --git a/src/support/lyxstring.C b/src/support/lyxstring.C index 4e7438d69f..7bd6d90f2f 100644 --- a/src/support/lyxstring.C +++ b/src/support/lyxstring.C @@ -1055,7 +1055,7 @@ lyxstring::size_type lyxstring::find_first_of(value_type const * ptr, if (!n) return npos; for (size_type t = i; t < rep->sz; ++t) { - if(memchr(ptr, rep->s[t], n) != 0) return t; + if (memchr(ptr, rep->s[t], n) != 0) return t; } return npos; } @@ -1109,7 +1109,7 @@ lyxstring::size_type lyxstring::find_last_of(value_type const * ptr, size_type ii = min(rep->sz - 1, i); for (int t = ii; t >= 0; --t) { - if(memchr(ptr, rep->s[t], n) != 0) return t; + if (memchr(ptr, rep->s[t], n) != 0) return t; } return npos; } @@ -1165,7 +1165,7 @@ lyxstring::size_type lyxstring::find_first_not_of(value_type const * ptr, if (!n) return (i < rep->sz) ? i : npos; for (size_type t = i; t < rep->sz; ++t) { - if(memchr(ptr, rep->s[t], n) == 0) return t; + if (memchr(ptr, rep->s[t], n) == 0) return t; } return npos; } @@ -1222,7 +1222,7 @@ lyxstring::size_type lyxstring::find_last_not_of(value_type const * ptr, size_type ii = min(rep->sz - 1, i); for (int t = ii; t >= 0; --t) { - if(memchr(ptr, rep->s[t], n) == 0) return t; + if (memchr(ptr, rep->s[t], n) == 0) return t; } return npos; } diff --git a/src/support/snprintf.c b/src/support/snprintf.c index 56d09ba754..f486cc6c77 100644 --- a/src/support/snprintf.c +++ b/src/support/snprintf.c @@ -691,7 +691,7 @@ int portable_vsnprintf(char *str, size_t str_m, const char *fmt, va_list ap) { /* Actually it uses 0x prefix even for a zero value. */ && long_arg != 0 #endif - ) { tmp[str_arg_l++] = '0'; tmp[str_arg_l++] = 'x'; } + ) { tmp[str_arg_l++] = '0'; tmp[str_arg_l++] = 'x'; } #endif } zero_padding_insertion_ind = str_arg_l; @@ -703,7 +703,7 @@ int portable_vsnprintf(char *str, size_t str_m, const char *fmt, va_list ap) { * converting a zero value with a precision of zero is a null string. * Actually it returns all zeroes. */ #endif - ) { /* converted to null string */ } + ) { /* converted to null string */ } else { char f[5]; int f_l = 0; f[f_l++] = '%'; @@ -736,7 +736,7 @@ int portable_vsnprintf(char *str, size_t str_m, const char *fmt, va_list ap) { && !(zero_padding_insertion_ind < str_arg_l && tmp[zero_padding_insertion_ind] == '0') #endif - ) { /* assure leading zero for alternative-form octal numbers */ + ) { /* assure leading zero for alternative-form octal numbers */ if (!precision_specified || precision < num_of_digits+1) { precision = num_of_digits+1; precision_specified = 1; } } diff --git a/src/tabular.C b/src/tabular.C index cacf627991..9e64f3a33e 100644 --- a/src/tabular.C +++ b/src/tabular.C @@ -135,8 +135,8 @@ LyXTabular * LyXTabular::Clone(InsetTabular * inset) LyXTabular * result = new LyXTabular(inset, *this); // don't know if this is good but I need to Clone also // the text-insets here, this is for the Undo-facility! - for(int i = 0; i < rows_; ++i) { - for(int j = 0; j < columns_; ++j) { + for (int i = 0; i < rows_; ++i) { + for (int j = 0; j < columns_; ++j) { result->cell_info[i][j].inset = cell_info[i][j].inset; result->cell_info[i][j].inset.setOwner(inset); } @@ -201,13 +201,13 @@ void LyXTabular::AppendRow(int cell) cell_vvector c_info = cell_vvector(rows_, cell_vector(columns_, cellstruct())); - for(int i = 0; i <= row; ++i) { - for(int j = 0; j < columns_; ++j) { + for (int i = 0; i <= row; ++i) { + for (int j = 0; j < columns_; ++j) { c_info[i][j] = cell_info[i][j]; } } - for(int i = row + 1; i < rows_; ++i) { - for(int j = 0; j < columns_; ++j) { + for (int i = row + 1; i < rows_; ++i) { + for (int j = 0; j < columns_; ++j) { c_info[i][j] = cell_info[i-1][j]; } } @@ -307,10 +307,7 @@ void LyXTabular::Reinit() void LyXTabular::set_row_column_number_info(bool oldformat) { - //int c = 0; - //int column = 0; numberofcells = -1; - //int row = 0; for (int row = 0; row < rows_; ++row) { for (int column = 0; column= numberofcells) + if (cell >= numberofcells) return false; if (!onlycolumn && IsMultiColumn(cell)) @@ -586,7 +583,7 @@ void LyXTabular::recalculateMulticolCells(int cell, int new_width) int i = column1; for (; i <= column2; ++i) cell_info[row][i].width_of_cell = 0; - for(i = cell + 1; (i < numberofcells) && (!IsMultiColumn(i)); ++i) + for (i = cell + 1; (i < numberofcells) && (!IsMultiColumn(i)); ++i) ; if (i < numberofcells) recalculateMulticolCells(i, GetWidthOfCell(i) - (2 * WIDTH_OF_LINE)); @@ -616,13 +613,13 @@ bool LyXTabular::SetWidthOfCell(int cell, int new_width) } if (tmp) { int i = 0; - for(; iSetAutoBreakRows(flag); @@ -960,7 +957,7 @@ string const write_attribute(string const & name, string const & value) string const write_attribute(string const & name, bool value) { - string str = " " + name + "=\"" + tostr((int)value) + "\""; + string str = " " + name + "=\"" + tostr(static_cast(value)) + "\""; return str; } #endif @@ -1175,7 +1172,7 @@ void LyXTabular::Read(Buffer const * buf, LyXLex & lex) getTokenValue(line, "endfoot", endfoot); getTokenValue(line, "endlastfoot", endlastfoot); - for(int i = 0; i < rows_; ++i) { + for (int i = 0; i < rows_; ++i) { l_getline(is, line); if (!prefixIs(line, " got" << @@ -1433,7 +1430,7 @@ void LyXTabular::OldFormatRead(LyXLex & lex, string const & fl) InsetText * inset = GetCellInset(cell); int row; - for(int i = 0; i < par->Last(); ++i) { + for (int i = 0; i < par->Last(); ++i) { if (par->IsNewline(i)) { ++cell; if (cell > GetNumberOfCells()) { @@ -1947,7 +1944,7 @@ int LyXTabular::GetHeightOfTabular() const { int height = 0; - for(int row = 0; row < rows_; ++row) + for (int row = 0; row < rows_; ++row) height += GetAscentOfRow(row) + GetDescentOfRow(row) + GetAdditionalHeight(GetCellNumber(row, 0)); return height; @@ -2038,7 +2035,7 @@ int LyXTabular::TeXCellPreamble(ostream & os, int cell) const if (LeftLine(cell)) os << '|'; if (!GetPWidth(cell).empty()) { - switch(GetVAlignment(cell)) { + switch (GetVAlignment(cell)) { case LYX_VALIGN_TOP: os << "p"; break; @@ -2073,7 +2070,7 @@ int LyXTabular::TeXCellPreamble(ostream & os, int cell) const } if (GetUsebox(cell) == BOX_PARBOX) { os << "\\parbox["; - switch(GetVAlignment(cell)) { + switch (GetVAlignment(cell)) { case LYX_VALIGN_TOP: os << "t"; break; @@ -2087,7 +2084,7 @@ int LyXTabular::TeXCellPreamble(ostream & os, int cell) const os << "]{" << GetPWidth(cell) << "}{"; } else if (GetUsebox(cell) == BOX_MINIPAGE) { os << "\\begin{minipage}["; - switch(GetVAlignment(cell)) { + switch (GetVAlignment(cell)) { case LYX_VALIGN_TOP: os << "t"; break; @@ -2151,7 +2148,7 @@ int LyXTabular::Latex(Buffer const * buf, if (!column_info[i].align_special.empty()) { os << column_info[i].align_special; } else if (!column_info[i].p_width.empty()) { - switch(column_info[i].valignment) { + switch (column_info[i].valignment) { case LYX_VALIGN_TOP: os << "p"; break; @@ -2189,7 +2186,7 @@ int LyXTabular::Latex(Buffer const * buf, //+--------------------------------------------------------------------- //int bret; - for(int i = 0; i < rows_; ++i) { + for (int i = 0; i < rows_; ++i) { ret += TeXTopHLine(os, i); int bret = ret; if (IsLongTabular()) { @@ -2215,7 +2212,7 @@ int LyXTabular::Latex(Buffer const * buf, ret += TeXBottomHLine(os, i-1); ret += TeXTopHLine(os, i); } - for(int j = 0; j < columns_; ++j) { + for (int j = 0; j < columns_; ++j) { if (IsPartOfMultiColumn(i,j)) continue; ret += TeXCellPreamble(os, cell); @@ -2307,14 +2304,14 @@ int LyXTabular::DocBook(Buffer const * buf, ostream & os) const int cell = 0; os << "\n"; - for(int i = 0; i < rows_; ++i) { + for (int i = 0; i < rows_; ++i) { os << "\n"; - for(int j = 0; j < columns_; ++j) { + for (int j = 0; j < columns_; ++j) { if (IsPartOfMultiColumn(i, j)) continue; os << " clen(columns_); // first all non (real) multicolumn cells! - for(int j = 0; j < columns_; ++j) { + for (int j = 0; j < columns_; ++j) { clen[j] = 0; - for(int i = 0; i < rows_; ++i) { + for (int i = 0; i < rows_; ++i) { int cell = GetCellNumber(i, j); if (IsMultiColumn(cell, true)) continue; @@ -2558,8 +2550,8 @@ int LyXTabular::Ascii(Buffer const * buf, ostream & os) const } } // then all (real) multicolumn cells! - for(int j = 0; j < columns_; ++j) { - for(int i = 0; i < rows_; ++i) { + for (int j = 0; j < columns_; ++j) { + for (int i = 0; i < rows_; ++i) { int cell = GetCellNumber(i, j); if (!IsMultiColumn(cell, true) || IsPartOfMultiColumn(i, j)) continue; @@ -2574,9 +2566,9 @@ int LyXTabular::Ascii(Buffer const * buf, ostream & os) const } } int cell = 0; - for(int i = 0; i < rows_; ++i) { + for (int i = 0; i < rows_; ++i) { AsciiTopHLine(os, i, clen); - for(int j = 0; j < columns_; ++j) { + for (int j = 0; j < columns_; ++j) { if (IsPartOfMultiColumn(i,j)) continue; ret += AsciiPrintCell(buf, os, cell, i, j, clen); @@ -2601,7 +2593,7 @@ void LyXTabular::Validate(LaTeXFeatures & features) const features.longtable = true; if (NeedRotating()) features.rotating = true; - for(int cell = 0; cell < numberofcells; ++cell) { + for (int cell = 0; cell < numberofcells; ++cell) { if (GetVAlignment(cell) != LYX_VALIGN_TOP) features.array = true; GetCellInset(cell)->Validate(features); @@ -2613,8 +2605,8 @@ LyXTabular::BoxType LyXTabular::UseParbox(int cell) const { LyXParagraph * par = GetCellInset(cell)->par; - for(; par; par = par->next) { - for(int i = 0; i < par->Last(); ++i) { + for (; par; par = par->next) { + for (int i = 0; i < par->Last(); ++i) { if (par->GetChar(i) == LyXParagraph::META_NEWLINE) return BOX_PARBOX; } diff --git a/src/texrow.C b/src/texrow.C index 8a1f5b7f4f..01c60fc96e 100644 --- a/src/texrow.C +++ b/src/texrow.C @@ -82,7 +82,7 @@ bool TexRow::getIdFromRow(int row, int & id, int & pos) const // same id (and where the pos is larger) // to avoid putting errorinsets at the // same pos. - for(; kit != end; ++kit) { + for (; kit != end; ++kit) { if (&(*kit) != &(*cit) && (*kit).id() == (*cit).id() && (*kit).pos() >= (*cit).pos()) @@ -108,7 +108,7 @@ void TexRow::increasePos(int id, int pos) const { RowList::iterator kit = rowlist.begin(); RowList::iterator end = rowlist.end(); - for(; kit != end; ++kit) { + for (; kit != end; ++kit) { if (id == (*kit).id() && pos < (*kit).pos()) { (*kit).pos((*kit).pos() + 1); diff --git a/src/text.C b/src/text.C index e7383aa369..e0dd58339b 100644 --- a/src/text.C +++ b/src/text.C @@ -1027,8 +1027,8 @@ LyXText::NextBreakPoint(BufferView * bview, Row const * row, int width) const // non-display if (par->GetInset(i)->display() && (layout.isCommand() || - ((layout.labeltype == LABEL_MANUAL) && - (i < BeginningOfMainBody(bview->buffer(), par))))) { + (layout.labeltype == LABEL_MANUAL + && i < BeginningOfMainBody(bview->buffer(), par)))) { // display istn't allowd par->GetInset(i)->display(false); x += SingleWidth(bview, par, i, c); @@ -1633,7 +1633,7 @@ void LyXText::BreakAgain(BufferView * bview, Row * row) const LyXParagraph::size_type z = NextBreakPoint(bview, row, workWidth(bview)); Row * tmprow = row; - if (z < row->par()->Last() ) { + if (z < row->par()->Last()) { if (!row->next() || (row->next() && row->next()->par() != row->par())) { // insert a new row ++z; @@ -1677,7 +1677,7 @@ void LyXText::BreakAgainOneRow(BufferView * bview, Row * row) LyXParagraph::size_type z = NextBreakPoint(bview, row, workWidth(bview)); Row * tmprow = row; - if (z < row->par()->Last() ) { + if (z < row->par()->Last()) { if (!row->next() || (row->next() && row->next()->par() != row->par())) { /* insert a new row */ @@ -1923,7 +1923,7 @@ void LyXText::InsertChar(BufferView * bview, char c) (cursor.pos() == 1 || cursor.par()->IsSeparator(cursor.pos() - 2) || cursor.par()->IsNewline(cursor.pos() - 2) ) - ) { + ) { SetCharFont(bview->buffer(), cursor.par(), cursor.pos() - 1, @@ -2040,7 +2040,7 @@ void LyXText::InsertChar(BufferView * bview, char c) LyXParagraph::size_type z = NextBreakPoint(bview, row->previous(), workWidth(bview)); - if ( z >= row->pos()) { + if (z >= row->pos()) { row->pos(z + 1); // set the dimensions of the row above @@ -2083,7 +2083,7 @@ void LyXText::InsertChar(BufferView * bview, char c) * will set fill to -1. Otherwise * we would not get a rebreak! */ row->fill(Fill(bview, row, workWidth(bview))); - if (row->fill() < 0 ) { + if (row->fill() < 0) { refresh_y = y; refresh_row = row; refresh_x = cursor.x(); @@ -2295,7 +2295,7 @@ void LyXText::CursorRightOneWord(BufferView * bview) const int steps = 0; // Skip through initial nonword stuff. - while ( tmpcursor.pos() < tmpcursor.par()->Last() && + while (tmpcursor.pos() < tmpcursor.par()->Last() && ! tmpcursor.par()->IsWord( tmpcursor.pos() ) ) { // printf("Current pos1 %d", tmpcursor.pos()) ; @@ -2303,7 +2303,7 @@ void LyXText::CursorRightOneWord(BufferView * bview) const ++steps; } // Advance through word. - while ( tmpcursor.pos() < tmpcursor.par()->Last() && + while (tmpcursor.pos() < tmpcursor.par()->Last() && tmpcursor.par()->IsWord( tmpcursor.pos() ) ) { // printf("Current pos2 %d", tmpcursor.pos()) ; @@ -2376,17 +2376,17 @@ void LyXText::CursorLeftOneWord(BufferView * bview) const void LyXText::SelectWord(BufferView * bview) { // Move cursor to the beginning, when not already there. - if ( cursor.pos() - && !cursor.par()->IsSeparator(cursor.pos()-1) - && !cursor.par()->IsKomma(cursor.pos()-1) ) + if (cursor.pos() + && !cursor.par()->IsSeparator(cursor.pos()-1) + && !cursor.par()->IsKomma(cursor.pos()-1) ) CursorLeftOneWord(bview); // set the sel cursor sel_cursor = cursor; - while ( cursor.pos() < cursor.par()->Last() - && !cursor.par()->IsSeparator(cursor.pos()) - && !cursor.par()->IsKomma(cursor.pos()) ) + while (cursor.pos() < cursor.par()->Last() + && !cursor.par()->IsSeparator(cursor.pos()) + && !cursor.par()->IsKomma(cursor.pos()) ) cursor.pos(cursor.pos() + 1); SetCursor(bview, cursor.par(), cursor.pos() ); @@ -2406,7 +2406,7 @@ bool LyXText::SelectWordWhenUnderCursor(BufferView * bview) && !cursor.par()->IsSeparator(cursor.pos()) && !cursor.par()->IsKomma(cursor.pos()) && !cursor.par()->IsSeparator(cursor.pos() -1) - && !cursor.par()->IsKomma(cursor.pos() -1) ) { + && !cursor.par()->IsKomma(cursor.pos() -1)) { SelectWord(bview); return true; } @@ -2900,7 +2900,7 @@ void LyXText::Backspace(BufferView * bview) if (row->previous() && row->previous()->par() == row->par()) { z = NextBreakPoint(bview, row->previous(), workWidth(bview)); - if ( z >= row->pos()) { + if (z >= row->pos()) { row->pos(z + 1); Row * tmprow = row->previous(); @@ -3015,7 +3015,9 @@ void LyXText::GetVisibleRow(BufferView * bview, int y_offset, int x_offset, /* returns a printed row */ Painter & pain = bview->painter(); - bool is_rtl = row_ptr->par()->isRightToLeftPar(bview->buffer()->params); + bool const is_rtl = + row_ptr->par()->isRightToLeftPar(bview->buffer()->params); + LyXParagraph::size_type last = RowLastPrintable(row_ptr); LyXParagraph::size_type vpos, pos; @@ -3048,9 +3050,9 @@ void LyXText::GetVisibleRow(BufferView * bview, int y_offset, int x_offset, bool clear_area = true; Inset * inset = 0; - if (!bview->screen()->forceClear() && (last == row_ptr->pos()) && - (row_ptr->par()->GetChar(row_ptr->pos()) == LyXParagraph::META_INSET) && - (inset = row_ptr->par()->GetInset(row_ptr->pos()))) { + if (!bview->screen()->forceClear() && last == row_ptr->pos() + && row_ptr->par()->GetChar(row_ptr->pos()) == LyXParagraph::META_INSET + && (inset = row_ptr->par()->GetInset(row_ptr->pos()))) { clear_area = inset->doClearArea(); } // we don't need to clear it's already done!!! @@ -3128,7 +3130,7 @@ void LyXText::GetVisibleRow(BufferView * bview, int y_offset, int x_offset, row_ptr->height(), LColor::selection); } - } else if ( sel_start_cursor.row() != row_ptr && + } else if (sel_start_cursor.row() != row_ptr && sel_end_cursor.row() != row_ptr && y > sel_start_cursor.y() && y < sel_end_cursor.y()) { @@ -3138,7 +3140,7 @@ void LyXText::GetVisibleRow(BufferView * bview, int y_offset, int x_offset, } else if (sel_start_cursor.row() == row_ptr || sel_end_cursor.row() == row_ptr) { float tmpx = x; - if ( (sel_start_cursor.row() != row_ptr && !is_rtl) || + if ((sel_start_cursor.row() != row_ptr && !is_rtl) || (sel_end_cursor.row() != row_ptr && is_rtl)) pain.fillRectangle(x_offset, y_offset, int(tmpx), @@ -3173,7 +3175,7 @@ void LyXText::GetVisibleRow(BufferView * bview, int y_offset, int x_offset, } else tmpx += SingleWidth(bview, row_ptr->par(), pos); - if ( (sel_start_cursor.row() != row_ptr || + if ((sel_start_cursor.row() != row_ptr || sel_start_cursor.pos() <= pos) && (sel_end_cursor.row() != row_ptr || pos < sel_end_cursor.pos()) ) @@ -3184,7 +3186,7 @@ void LyXText::GetVisibleRow(BufferView * bview, int y_offset, int x_offset, LColor::selection); } - if ( (sel_start_cursor.row() != row_ptr && is_rtl) || + if ((sel_start_cursor.row() != row_ptr && is_rtl) || (sel_end_cursor.row() != row_ptr && !is_rtl) ) pain.fillRectangle(x_offset + int(tmpx), y_offset, @@ -3587,11 +3589,11 @@ void LyXText::GetVisibleRow(BufferView * bview, int y_offset, int x_offset, #endif if ( #ifndef NEW_INSETS - (row_ptr->par()->ParFromPos(last + 1) == par) + row_ptr->par()->ParFromPos(last + 1) == par #else - (row_ptr->par() == par) + row_ptr->par() == par #endif - && (!row_ptr->next() || (row_ptr->next()->par() != row_ptr->par()))) + && (!row_ptr->next() || row_ptr->next()->par() != row_ptr->par())) { /* think about the margins */ if (!row_ptr->next() && bv_owner) diff --git a/src/text2.C b/src/text2.C index d7047c5c30..9564e41c7f 100644 --- a/src/text2.C +++ b/src/text2.C @@ -1721,7 +1721,7 @@ void LyXText::SetCounter(Buffer const * buf, LyXParagraph * par) const // entry in the marginnote and the enclosing // environment is an enum/item then correct for the // LaTeX behaviour (ARRae) - if(par->footnoteflag == LyXParagraph::OPEN_FOOTNOTE + if (par->footnoteflag == LyXParagraph::OPEN_FOOTNOTE && par->footnotekind == LyXParagraph::MARGIN && par->Previous() && par->Previous()->footnoteflag != LyXParagraph::OPEN_FOOTNOTE @@ -2663,7 +2663,7 @@ void LyXText::CheckParagraph(BufferView * bview, LyXParagraph * par, // is there a break one row above if (row->previous() && row->previous()->par() == row->par()) { z = NextBreakPoint(bview, row->previous(), workWidth(bview)); - if ( z >= row->pos()) { + if (z >= row->pos()) { // set the dimensions of the row above y -= row->previous()->height(); refresh_y = y; @@ -3094,7 +3094,7 @@ void LyXText::DeleteEmptyParagraphMechanism(BufferView * bview, LyXCursor tmpcursor; if (old_cursor.par() != cursor.par()) { - if ( (old_cursor.par()->Last() == 0 + if ((old_cursor.par()->Last() == 0 || (old_cursor.par()->Last() == 1 && old_cursor.par()->IsLineSeparator(0))) #ifndef NEW_INSETS diff --git a/src/trans.C b/src/trans.C index 98b6c45c0d..b2d6543d45 100644 --- a/src/trans.C +++ b/src/trans.C @@ -48,7 +48,7 @@ string const DefaultTrans::process(char c, TransManager & k) Trans::Trans() { - for(int i = 0; i < TEX_MAX_ACCENT + 1; ++i) + for (int i = 0; i < TEX_MAX_ACCENT + 1; ++i) kmod_list_[i] = 0; } @@ -87,11 +87,11 @@ void Trans::FreeException(Trans::keyexc & exclist) void Trans::FreeKeymap() { - for(int i = 0; i < 256; ++i) + for (int i = 0; i < 256; ++i) if (!keymap_[i].empty()) { keymap_[i].erase(); } - for(int i = 0; i < TEX_MAX_ACCENT + 1; ++i) + for (int i = 0; i < TEX_MAX_ACCENT + 1; ++i) if (kmod_list_[i]) { FreeException(kmod_list_[i]->exception_list); delete kmod_list_[i]; @@ -150,18 +150,7 @@ void Trans::AddDeadkey(tex_accent accent, string const & keys, kmod_list_[accent]->allowed = allowed; } - for(string::size_type i = 0; i < keys.length(); ++i) { -#if 0 - string * temp = - &keymap_[static_cast(keys[i])]; -#warning this is not really clean we should find a cleaner way (Jug) - *temp = "xx"; /* this is needed for the being sure that - the below assignment is not assigned to - a nullpointer (if size of string = 0) - */ - (*temp)[0] = 0; - (*temp)[1] = accent; -#else + for (string::size_type i = 0; i < keys.length(); ++i) { string & temp = keymap_[static_cast(keys[i])]; if (!temp.empty()) @@ -172,7 +161,6 @@ void Trans::AddDeadkey(tex_accent accent, string const & keys, // Lgb temp += char(0); temp += char(accent); -#endif } kmod_list_[accent]->exception_list = 0; } @@ -183,7 +171,7 @@ int Trans::Load(LyXLex & lex) bool error = false; while (lex.IsOK() && !error) { - switch(lex.lex()) { + switch (lex.lex()) { case KMOD: { if (lyxerr.debugging(Debug::KBMAP)) @@ -198,7 +186,7 @@ int Trans::Load(LyXLex & lex) string keys = lex.GetString(); if (lex.next(true)) { - if ( lyxerr.debugging(Debug::KBMAP)) + if (lyxerr.debugging(Debug::KBMAP)) lyxerr << "accent\t`" << lex.text() << "'" << endl; } else @@ -250,7 +238,7 @@ int Trans::Load(LyXLex & lex) // Find what key accent_2 is on - should // check about accent_1 also int key = 0; - for(; key < 256; ++key) { + for (; key < 256; ++key) { if (!keymap_[key].empty() && keymap_[key][0] == 0 && keymap_[key][1] == accent_2) @@ -404,7 +392,7 @@ tex_accent getkeymod(string const & p) << "].name = `" << lyx_accent_table[i].name << "'" << endl; - if ( lyx_accent_table[i].name + if (lyx_accent_table[i].name && contains(p, lyx_accent_table[i].name)) { lyxerr[Debug::KBMAP] << "Found it!" << endl; return static_cast(i); diff --git a/src/vspace.C b/src/vspace.C index e065ab83ce..25d5d5ef51 100644 --- a/src/vspace.C +++ b/src/vspace.C @@ -168,7 +168,7 @@ bool isValidGlueLength (string const & data, LyXGlueLength * result) // To make isValidGlueLength recognize negative values as // the first number this little hack is needed: short val_sign = 1; // positive as default - switch(buffer[0]) { + switch (buffer[0]) { case '-': lyx_advance(buffer, 1); val_sign = -1; @@ -232,7 +232,7 @@ bool isValidLength(string const & data, LyXLength * result) // To make isValidLength recognize negative values // this little hack is needed: short val_sign = 1; // positive as default - switch(buffer[0]) { + switch (buffer[0]) { case '-': lyx_advance(buffer, 1); val_sign = -1;