Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

bv_funcs Namespace Reference


Enumerations

enum  DEPTH_CHANGE { INC_DEPTH, DEC_DEPTH }
 what type of depth change to make. More...


Functions

void resizeInsets (BufferView *bv)
bool font2string (LyXFont const &font, bool toggle, string &data)
 Set. More...

bool string2font (string const &data, LyXFont &font, bool &toggle)
 Set. More...

string const freefont2string ()
 Returns the current freefont, encoded as a string to be passed to the frontends. More...

void update_and_apply_freefont (BufferView *bv, string const &data)
 Set the freefont using the contents of. More...

void apply_freefont (BufferView *bv)
 Apply the contents of freefont at the current cursor location. More...

void emph (BufferView *bv)
void bold (BufferView *bv)
void noun (BufferView *bv)
void number (BufferView *bv)
void lang (BufferView *bv, string const &l)
bool changeDepth (BufferView *bv, LyXText *text, DEPTH_CHANGE type, bool test_only)
 Increase or decrease the nesting depth of the selected paragraph(s) if test_only, don't change any depths. More...

void code (BufferView *bv)
void sans (BufferView *bv)
void roman (BufferView *bv)
void styleReset (BufferView *bv)
void underline (BufferView *bv)
void fontSize (BufferView *bv, string const &size)
string const currentState (BufferView *bv)
 Returns the current font and depth as a message. More...

void toggleAndShow (BufferView *bv, LyXFont const &font, bool toggleall)
void replaceSelection (LyXText *lt)
 replace selection with insertion. More...

void tex (BufferView *)


Enumeration Type Documentation

enum bv_funcs::DEPTH_CHANGE
 

what type of depth change to make.

Enumeration values:
INC_DEPTH 
DEC_DEPTH 

Definition at line 48 of file bufferview_funcs.h.

00048                   {
00049         INC_DEPTH,
00050         DEC_DEPTH
00051 };


Function Documentation

void bv_funcs::apply_freefont BufferView   bv
 

Apply the contents of freefont at the current cursor location.

Definition at line 183 of file bufferview_funcs.C.

Referenced by LyXFunc::dispatch.

00184 {
00185         toggleAndShow(bv, freefont, toggleall);
00186         bv->owner()->view_state_changed();
00187         bv->owner()->message(_("Character set"));
00188 }

void bv_funcs::bold BufferView   bv
 

Definition at line 199 of file bufferview_funcs.C.

Referenced by BufferView::Pimpl::dispatch.

00200 {
00201         LyXFont font(LyXFont::ALL_IGNORE);
00202         font.setSeries(LyXFont::BOLD_SERIES);
00203         toggleAndShow(bv, font);
00204 }

bool bv_funcs::changeDepth BufferView  ,
LyXText  ,
DEPTH_CHANGE   ,
bool    test_only
 

Increase or decrease the nesting depth of the selected paragraph(s) if test_only, don't change any depths.

Returns whether something (would have) changed

Definition at line 234 of file bufferview_funcs.C.

Referenced by LyXFunc::dispatch, and LyXFunc::getStatus.

00235 {
00236         if (!bv->available() || !text)
00237             return false;
00238 
00239         if (test_only)
00240                 return text->changeDepth(type, true);
00241 
00242         bv->update(BufferView::SELECT);
00243         bool const changed = text->changeDepth(type, false);
00244         if (text->inset_owner)
00245                 bv->updateInset((Inset *)text->inset_owner);
00246         bv->update(BufferView::SELECT);
00247         return changed;
00248 }

void bv_funcs::code BufferView   bv
 

Definition at line 251 of file bufferview_funcs.C.

Referenced by BufferView::ChangeInsets, kb_keymap::defkey, BufferView::Pimpl::dispatch, BufferView::Pimpl::getInsetByCode, LyXFunc::getStatus, LyXText::gotoInset, Paragraph::insetAllowed, InsetWrap::insetAllowed, InsetText::insetAllowed, InsetTabular::insetAllowed, InsetMinipage::insetAllowed, InsetFootlike::insetAllowed, InsetFloat::insetAllowed, InsetERT::insetAllowed, InsetCollapsable::insetAllowed, InsetFormula::insetAllowed, InsetText::insetUnlock, InsetText::localDispatch, InsetTabular::localDispatch, InsetText::lockInset, mathed_draw_deco, Matrix::Matrix, and Languages::read.

00252 {
00253         LyXFont font(LyXFont::ALL_IGNORE);
00254         font.setFamily(LyXFont::TYPEWRITER_FAMILY); // no good
00255         toggleAndShow(bv, font);
00256 }

string const bv_funcs::currentState BufferView   bv
 

Returns the current font and depth as a message.

Definition at line 299 of file bufferview_funcs.C.

Referenced by BufferView::Pimpl::dispatch, ControlCommandBuffer::getCurrentState, and LyXFunc::view_status_message.

00300 {
00301         if (!bv->available())
00302                 return string();
00303 
00304         if (mathcursor)
00305                 return mathcursor->info();
00306 
00307         ostringstream state;
00308 
00309         LyXText * text = bv->getLyXText();
00310         Buffer * buffer = bv->buffer();
00311         LyXCursor const & c(text->cursor);
00312 
00313         bool const show_change = buffer->params.tracking_changes
00314                 && c.pos() != c.par()->size()
00315                 && c.par()->lookupChange(c.pos()) != Change::UNCHANGED;
00316 
00317         if (show_change) {
00318                 Change change(c.par()->lookupChangeFull(c.pos()));
00319                 Author const & a(bv->buffer()->authors().get(change.author));
00320                 state << _("Change: ") << a.name();
00321                 if (!a.email().empty()) {
00322                         state << " (" << a.email() << ")";
00323                 }
00324                 if (change.changetime)
00325                         state << _(" at ") << ctime(&change.changetime);
00326                 state << " : ";
00327         }
00328 
00329         // I think we should only show changes from the default
00330         // font. (Asger)
00331         LyXFont font = text->real_current_font;
00332         LyXFont const & defaultfont =
00333                 buffer->params.getLyXTextClass().defaultfont();
00334         font.reduce(defaultfont);
00335 
00336         // avoid _(...) re-entrance problem
00337         string const s = font.stateText(&buffer->params);
00338         state << bformat(_("Font: %1$s"), s);
00339 
00340         // state << bformat(_("Font: %1$s"), font.stateText(&buffer->params));
00341 
00342         // The paragraph depth
00343         int depth = text->getDepth();
00344         if (depth > 0)
00345                 state << bformat(_(", Depth: %1$s"), tostr(depth));
00346 
00347         // The paragraph spacing, but only if different from
00348         // buffer spacing.
00349         if (!text->cursor.par()->params().spacing().isDefault()) {
00350                 Spacing::Space cur_space =
00351                         text->cursor.par()->params().spacing().getSpace();
00352                 state << _(", Spacing: ");
00353 
00354                 switch (cur_space) {
00355                 case Spacing::Single:
00356                         state << _("Single");
00357                         break;
00358                 case Spacing::Onehalf:
00359                         state << _("OneHalf");
00360                         break;
00361                 case Spacing::Double:
00362                         state << _("Double");
00363                         break;
00364                 case Spacing::Other:
00365                         state << _("Other (")
00366                               << text->cursor.par()->params().spacing().getValue()
00367                               << ')';
00368                         break;
00369                 case Spacing::Default:
00370                         // should never happen, do nothing
00371                         break;
00372                 }
00373         }
00374 #ifdef DEVEL_VERSION
00375         state << _(", Paragraph: ") << text->cursor.par()->id();
00376         state << "  Inset: " <<
00377                 (text->cursor.par()->inInset() ? text->cursor.par()->inInset()->id() : -1);
00378 #endif
00379         return STRCONV(state.str());
00380 }

void bv_funcs::emph BufferView   bv
 

Definition at line 191 of file bufferview_funcs.C.

Referenced by BufferView::Pimpl::dispatch.

00192 {
00193         LyXFont font(LyXFont::ALL_IGNORE);
00194         font.setEmph(LyXFont::TOGGLE);
00195         toggleAndShow(bv, font);
00196 }

bool bv_funcs::font2string LyXFont const &    font,
bool    toggle,
string &    data
 

Set.

Parameters:
data  using
font  and
toggle.  If successful, returns true.

Definition at line 65 of file bufferview_funcs.C.

Referenced by ControlCharacter::dispatchParams.

00066 {
00067         string lang = "ignore";
00068         if (font.language())
00069                 lang = font.language()->lang();
00070 
00071         ostringstream os;
00072         os << "family " << font.family() << '\n'
00073            << "series " << font.series() << '\n'
00074            << "shape " << font.shape() << '\n'
00075            << "size " << font.size() << '\n'
00076            << "emph " << font.emph() << '\n'
00077            << "underbar " << font.underbar() << '\n'
00078            << "noun " << font.noun() << '\n'
00079            << "number " << font.number() << '\n'
00080            << "color " << font.color() << '\n'
00081            << "language " << lang << '\n'
00082            << "toggleall " << tostr(toggle);
00083         data = STRCONV(os.str());
00084         return true;
00085 }

void bv_funcs::fontSize BufferView   bv,
string const &    size
 

Definition at line 290 of file bufferview_funcs.C.

Referenced by BufferView::Pimpl::dispatch.

00291 {
00292         LyXFont font(LyXFont::ALL_IGNORE);
00293         font.setLyXSize(size);
00294         toggleAndShow(bv, font);
00295 }

string const bv_funcs::freefont2string  
 

Returns the current freefont, encoded as a string to be passed to the frontends.

Definition at line 162 of file bufferview_funcs.C.

Referenced by LyXFunc::dispatch.

00163 {
00164         string data;
00165         if (font2string(freefont, toggleall, data))
00166                 return data;
00167         return string();
00168 }

void bv_funcs::lang BufferView   bv,
string const &    l
 

Definition at line 222 of file bufferview_funcs.C.

Referenced by BufferView::Pimpl::dispatch, MathHullInset::doExtern, getSpeller, ISpell::ISpell, LaunchIspell::LaunchIspell, LyXFont::LyXFont, pipeThroughExtern, Languages::read, readParToken, LyXText::setCurrentFont, and LaTeXFeatures::useLanguage.

00223 {
00224         LyXFont font(LyXFont::ALL_IGNORE);
00225         Language const * lang = languages.getLanguage(l);
00226         if (!lang)
00227                 return;
00228 
00229         font.setLanguage(lang);
00230         toggleAndShow(bv, font);
00231 }

void bv_funcs::noun BufferView   bv
 

Definition at line 207 of file bufferview_funcs.C.

Referenced by BufferView::Pimpl::dispatch.

00208 {
00209         LyXFont font(LyXFont::ALL_IGNORE);
00210         font.setNoun(LyXFont::TOGGLE);
00211         toggleAndShow(bv, font);
00212 }

void bv_funcs::number BufferView   bv
 

Definition at line 215 of file bufferview_funcs.C.

00216 {
00217         LyXFont font(LyXFont::ALL_IGNORE);
00218         font.setNumber(LyXFont::TOGGLE);
00219         toggleAndShow(bv, font);
00220 }

void bv_funcs::replaceSelection LyXText   lt
 

replace selection with insertion.

Definition at line 419 of file bufferview_funcs.C.

Referenced by LyXText::dispatch, InsetText::localDispatch, and specialChar.

00420 {
00421         if (lt->selection.set()) {
00422                 lt->update();
00423                 lt->cutSelection(true, false);
00424                 lt->update();
00425         }
00426 }

void bv_funcs::resizeInsets BufferView   bv
 

Definition at line 54 of file bufferview_funcs.C.

Referenced by BufferView::Pimpl::resizeCurrentBuffer, and BufferView::Pimpl::workAreaResize.

00055 {
00056         ParagraphList & paragraphs = bv->buffer()->paragraphs;
00058         std::for_each(paragraphs.begin(), paragraphs.end(),
00059                       boost::bind(&Paragraph::resizeInsetsLyXText, _1, bv));
00060 }

void bv_funcs::roman BufferView   bv
 

Definition at line 267 of file bufferview_funcs.C.

Referenced by BufferView::Pimpl::dispatch, and romanCounter.

00268 {
00269         LyXFont font(LyXFont::ALL_IGNORE);
00270         font.setFamily(LyXFont::ROMAN_FAMILY);
00271         toggleAndShow(bv, font);
00272 }

void bv_funcs::sans BufferView   bv
 

Definition at line 259 of file bufferview_funcs.C.

Referenced by BufferView::Pimpl::dispatch.

00260 {
00261         LyXFont font(LyXFont::ALL_IGNORE);
00262         font.setFamily(LyXFont::SANS_FAMILY);
00263         toggleAndShow(bv, font);
00264 }

bool bv_funcs::string2font string const &    data,
LyXFont   font,
bool &    toggle
 

Set.

Parameters:
font  and
toggle  using
data.  If successful, returns true.

Definition at line 90 of file bufferview_funcs.C.

00091 {
00092         istringstream is(STRCONV(data));
00093         LyXLex lex(0,0);
00094         lex.setStream(is);
00095 
00096         int nset = 0;
00097         while (lex.isOK()) {
00098                 string token;
00099                 if (lex.next())
00100                         token = lex.getString();
00101 
00102                 if (token.empty() || !lex.next())
00103                         break;
00104 
00105                 if (token == "family") {
00106                         int const next = lex.getInteger();
00107                         font.setFamily(LyXFont::FONT_FAMILY(next));
00108 
00109                 } else if (token == "series") {
00110                         int const next = lex.getInteger();
00111                         font.setSeries(LyXFont::FONT_SERIES(next));
00112 
00113                 } else if (token == "shape") {
00114                         int const next = lex.getInteger();
00115                         font.setShape(LyXFont::FONT_SHAPE(next));
00116 
00117                 } else if (token == "size") {
00118                         int const next = lex.getInteger();
00119                         font.setSize(LyXFont::FONT_SIZE(next));
00120 
00121                 } else if (token == "emph" || token == "underbar" ||
00122                            token == "noun" || token == "number") {
00123 
00124                         int const next = lex.getInteger();
00125                         LyXFont::FONT_MISC_STATE const misc =
00126                                 LyXFont::FONT_MISC_STATE(next);
00127 
00128                         if (token == "emph")
00129                             font.setEmph(misc);
00130                         else if (token == "underbar")
00131                                 font.setUnderbar(misc);
00132                         else if (token == "noun")
00133                                 font.setNoun(misc);
00134                         else if (token == "number")
00135                                 font.setNumber(misc);
00136 
00137                 } else if (token == "color") {
00138                         int const next = lex.getInteger();
00139                         font.setColor(LColor::color(next));
00140 
00141                 } else if (token == "language") {
00142                         string const next = lex.getString();
00143                         if (next == "ignore")
00144                                 font.setLanguage(ignore_language);
00145                         else
00146                                 font.setLanguage(languages.getLanguage(next));
00147 
00148                 } else if (token == "toggleall") {
00149                         toggle = lex.getBool();
00150 
00151                 } else {
00152                         // Unrecognised token
00153                         break;
00154                 }
00155 
00156                 ++nset;
00157         }
00158         return (nset > 0);
00159 }

void bv_funcs::styleReset BufferView   bv
 

Definition at line 275 of file bufferview_funcs.C.

Referenced by BufferView::Pimpl::dispatch.

00276 {
00277         LyXFont font(LyXFont::ALL_INHERIT, ignore_language);
00278         toggleAndShow(bv, font);
00279 }

void tex BufferView  
 

void bv_funcs::toggleAndShow BufferView   bv,
LyXFont const &    font,
bool    toggleall = true
 

Definition at line 386 of file bufferview_funcs.C.

00387 {
00388         if (!bv->available())
00389                 return;
00390 
00391         if (bv->theLockingInset()) {
00392                 bv->theLockingInset()->setFont(bv, font, toggleall);
00393                 return;
00394         }
00395 
00396         LyXText * text = bv->getLyXText();
00397         // FIXME: can this happen ??
00398         if (!text)
00399                 return;
00400 
00401         bv->update(text, BufferView::SELECT);
00402         text->toggleFree(font, toggleall);
00403         bv->update(text, BufferView::SELECT);
00404 
00405         if (font.language() != ignore_language ||
00406             font.number() != LyXFont::IGNORE) {
00407                 LyXCursor & cursor = text->cursor;
00408                 text->computeBidiTables(bv->buffer(), text->cursorRow());
00409                 if (cursor.boundary() !=
00410                     text->isBoundary(bv->buffer(), *cursor.par(), cursor.pos(),
00411                                      text->real_current_font))
00412                         text->setCursor(cursor.par(), cursor.pos(),
00413                                         false, !cursor.boundary());
00414         }
00415 }

void bv_funcs::underline BufferView   bv
 

Definition at line 282 of file bufferview_funcs.C.

Referenced by BufferView::Pimpl::dispatch.

00283 {
00284         LyXFont font(LyXFont::ALL_IGNORE);
00285         font.setUnderbar(LyXFont::TOGGLE);
00286         toggleAndShow(bv, font);
00287 }

void bv_funcs::update_and_apply_freefont BufferView   bv,
string const &    data
 

Set the freefont using the contents of.

Parameters:
data  dispatched from the frontends and apply it at the current cursor location.

Definition at line 171 of file bufferview_funcs.C.

Referenced by LyXFunc::dispatch.

00172 {
00173         LyXFont font;
00174         bool toggle;
00175         if (string2font(data, font, toggle)) {
00176                 freefont = font;
00177                 toggleall = toggle;
00178                 apply_freefont(bv);
00179         }
00180 }


Generated on Fri Jul 18 01:19:06 2003 for lyx by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002