#\bind "C-k" "font-noun" # 'k' for capitals
\bind "C-u" "font-underline"
\bind "C-S-P" "font-typewriter" # 'P' for Program
+\bind "C-S-O" "font-strikeout"
\bind "C-m" "math-mode"
\bind "C-S-M" "math-display"
document.body[i:k+1] = subst
i = i + 1
+def revert_strikeout(document):
+ " Reverts \\strike character style "
+ while True:
+ i = find_token(document.body, '\\strikeout', 0)
+ if i == -1:
+ return
+ del document.body[i]
+
##
# Conversion hub
[351, []],
[352, [convert_splitindex]],
[353, []],
- [354, []]
+ [354, []],
+ [355, []]
]
-revert = [[353, [revert_printindexall]],
+revert = [[354, [revert_strikeout]],
+ [353, [revert_printindexall]],
[352, [revert_subindex]],
[351, [revert_splitindex]],
[350, [revert_backgroundcolor]],
// Do not remove the comment below, so we get merge conflict in
// independent branches. Instead add your own.
-int const LYX_FORMAT = 354; // jspitzm: support for \print[sub]index*
+int const LYX_FORMAT = 355; // sanda: support for \\sout
typedef map<string, bool> DepClean;
typedef map<docstring, pair<InsetLabel const *, Buffer::References> > RefCache;
if (f.underbar() != FONT_INHERIT)
os << bformat(_("Underline %1$s, "),
_(GUIMiscNames[f.underbar()]));
+ if (f.strikeout() != FONT_INHERIT)
+ os << bformat(_("Strikeout %1$s, "),
+ _(GUIMiscNames[f.strikeout()]));
if (f.noun() != FONT_INHERIT)
os << bformat(_("Noun %1$s, "),
_(GUIMiscNames[f.noun()]));
if (ttok == "no_bar") {
f.setUnderbar(FONT_OFF);
+ } else if (ttok == "no_strikeout") {
+ f.setStrikeout(FONT_OFF);
} else if (ttok == "no_emph") {
f.setEmph(FONT_OFF);
} else if (ttok == "no_noun") {
f.setEmph(FONT_ON);
} else if (ttok == "underbar") {
f.setUnderbar(FONT_ON);
+ } else if (ttok == "strikeout") {
+ f.setStrikeout(FONT_ON);
} else if (ttok == "noun") {
f.setNoun(FONT_ON);
} else {
break;
}
}
+ if (orgfont.fontInfo().strikeout() != bits_.strikeout()) {
+ os << "\\strikeout " << LyXMiscNames[bits_.strikeout()] << "\n";
+ }
if (orgfont.fontInfo().noun() != bits_.noun()) {
os << "\\noun " << LyXMiscNames[bits_.noun()] << "\n";
}
count += 10;
env = true; //We have opened a new environment
}
+ if (f.strikeout() == FONT_ON) {
+ os << "\\sout{";
+ count += 6;
+ env = true; //We have opened a new environment
+ }
// \noun{} is a LyX special macro
if (f.noun() == FONT_ON) {
os << "\\noun{";
++count;
env = true; // Size change need not bother about closing env.
}
+ if (f.strikeout() == FONT_ON) {
+ os << '}';
+ ++count;
+ env = true; // Size change need not bother about closing env.
+ }
if (f.noun() == FONT_ON) {
os << '}';
++count;
<< "size " << bits_.size() << '\n'
<< "emph " << bits_.emph() << '\n'
<< "underbar " << bits_.underbar() << '\n'
+ << "strikeout " << bits_.strikeout() << '\n'
<< "noun " << bits_.noun() << '\n'
<< "number " << bits_.number() << '\n'
<< "color " << bits_.color() << '\n'
bits_.setSize(FontSize(next));
} else if (token == "emph" || token == "underbar" ||
- token == "noun" || token == "number") {
+ token == "noun" || token == "number" ||
+ token == "strikeout") {
int const next = lex.getInteger();
FontState const misc = FontState(next);
bits_.setEmph(misc);
else if (token == "underbar")
bits_.setUnderbar(misc);
+ else if (token == "strikeout")
+ bits_.setStrikeout(misc);
else if (token == "noun")
bits_.setNoun(misc);
else if (token == "number")
features.require("noun");
LYXERR(Debug::LATEX, "Noun enabled. Font: " << to_utf8(stateText(0)));
}
+ if (bits_.strikeout() == FONT_ON) {
+ LYXERR(Debug::LATEX, "font.strikeout: " << bits_.strikeout());
+ features.require("ulem");
+ LYXERR(Debug::LATEX, "Strikeout enabled. Font: " << to_utf8(stateText(0)));
+ }
switch (bits_.color()) {
case Color_none:
case Color_inherit:
//<< " background " << f.background()
<< " emph " << f.emph()
<< " underbar " << f.underbar()
+ << " strikeout " << f.strikeout()
<< " noun " << f.noun()
<< " number " << f.number();
}
FONT_OFF,
FONT_OFF,
FONT_OFF,
+ FONT_OFF,
FONT_OFF);
FontInfo const inherit_font(
FONT_INHERIT,
FONT_INHERIT,
FONT_INHERIT,
+ FONT_INHERIT,
FONT_OFF);
FontInfo const ignore_font(
FONT_IGNORE,
FONT_IGNORE,
FONT_IGNORE,
+ FONT_IGNORE,
FONT_IGNORE);
emph_ = FONT_INHERIT;
if (underbar_ == tmplt.underbar_)
underbar_ = FONT_INHERIT;
+ if (strikeout_ == tmplt.strikeout_)
+ strikeout_ = FONT_INHERIT;
if (noun_ == tmplt.noun_)
noun_ = FONT_INHERIT;
if (color_ == tmplt.color_)
if (underbar_ == FONT_INHERIT)
underbar_ = tmplt.underbar_;
+ if (strikeout_ == FONT_INHERIT)
+ strikeout_ = tmplt.strikeout_;
+
if (noun_ == FONT_INHERIT)
noun_ = tmplt.noun_;
setEmph(setMisc(newfont.emph_, emph_));
setUnderbar(setMisc(newfont.underbar_, underbar_));
+ setStrikeout(setMisc(newfont.strikeout_, strikeout_));
setNoun(setMisc(newfont.noun_, noun_));
setNumber(setMisc(newfont.number_, number_));
return (family_ != INHERIT_FAMILY && series_ != INHERIT_SERIES
&& shape_ != INHERIT_SHAPE && size_ != FONT_SIZE_INHERIT
&& emph_ != FONT_INHERIT && underbar_ != FONT_INHERIT
- && noun_ != FONT_INHERIT
+ && strikeout_ != FONT_INHERIT && noun_ != FONT_INHERIT
&& color_ != Color_inherit
&& background_ != Color_inherit);
}
ColorCode background,
FontState emph,
FontState underbar,
+ FontState strikeout,
FontState noun,
FontState number)
: family_(family), series_(series), shape_(shape), size_(size),
color_(color), background_(background), paint_color_(), emph_(emph),
- underbar_(underbar), noun_(noun), number_(number)
+ underbar_(underbar), strikeout_(strikeout), noun_(noun), number_(number)
{}
/// Decreases font size by one
void setEmph(FontState e) { emph_ = e; }
FontState underbar() const { return underbar_; }
void setUnderbar(FontState u) { underbar_ = u; }
+ FontState strikeout() const { return strikeout_; }
+ void setStrikeout(FontState s) { strikeout_ = s; }
FontState noun() const { return noun_; }
void setNoun(FontState n) { noun_ = n; }
FontState number() const { return number_; }
///
FontState underbar_;
///
+ FontState strikeout_;
+ ///
FontState noun_;
///
FontState number_;
&& lhs.background_ == rhs.background_
&& lhs.emph_ == rhs.emph_
&& lhs.underbar_ == rhs.underbar_
+ && lhs.strikeout_ == rhs.strikeout_
&& lhs.noun_ == rhs.noun_
&& lhs.number_ == rhs.number_;
}
LFUN_FONT_DEFAULT,
// 125
LFUN_FONT_UNDERLINE,
+ LFUN_FONT_STRIKEOUT,
LFUN_FONT_SIZE,
LFUN_FONT_STATE,
LFUN_WORD_UPCASE,
- LFUN_WORD_LOWCASE,
// 130
+ LFUN_WORD_LOWCASE,
LFUN_WORD_CAPITALIZE,
- LFUN_LABEL_INSERT,
LFUN_DEPTH_DECREMENT,
LFUN_DEPTH_INCREMENT,
LFUN_MENU_OPEN, // used in bindings as of 20060905
LFUN_MATH_BIGDELIM,
LFUN_MATH_FONT_STYLE,
LFUN_SECTION_SELECT, // vfr, 20090503
-
+ LFUN_LABEL_INSERT,
LFUN_LASTACTION // end of the table
};
* \endvar
*/
{ LFUN_FONT_UNDERLINE, "font-underline", Noop, Layout },
+/*!
+ * \var lyx::FuncCode lyx::LFUN_FONT_STRIKEOUT
+ * \li Action: Toggles strikeout (strike-through) in the font (selection-wise).
+ * \li Syntax: font-strikeout
+ * \li Origin: sanda, 3 May 2009
+ * \endvar
+ */
+ { LFUN_FONT_STRIKEOUT, "font-strikeout", Noop, Layout },
/*!
* \var lyx::FuncCode lyx::LFUN_FONT_EMPH
* \li Action: Toggles the emphasis font style (selection-wise).
else
lex.printError("Unknown bar font flag "
"`$$Token'");
+ } else if (token == "\\strikeout") {
+ lex.next();
+ font.fontInfo().setStrikeout(font.setLyXMisc(lex.getString()));
} else if (token == "\\noun") {
lex.next();
font.fontInfo().setNoun(font.setLyXMisc(lex.getString()));
break;
}
+ case LFUN_FONT_STRIKEOUT: {
+ Font font(ignore_font, ignore_language);
+ font.fontInfo().setStrikeout(FONT_TOGGLE);
+ toggleAndShow(cur, this, font);
+ break;
+ }
case LFUN_FONT_UNDERLINE: {
Font font(ignore_font, ignore_language);
font.fontInfo().setUnderbar(FONT_TOGGLE);
case LFUN_MATH_SUPERSCRIPT:
case LFUN_FONT_DEFAULT:
case LFUN_FONT_UNDERLINE:
+ case LFUN_FONT_STRIKEOUT:
case LFUN_FONT_SIZE:
case LFUN_LANGUAGE:
case LFUN_TEXTSTYLE_APPLY:
bars << BarPair(qt_("No change"), IGNORE);
bars << BarPair(qt_("Emph"), EMPH_TOGGLE);
bars << BarPair(qt_("Underbar"), UNDERBAR_TOGGLE);
+ bars << BarPair(qt_("Strikeout"), STRIKEOUT_TOGGLE);
bars << BarPair(qt_("Noun"), NOUN_TOGGLE);
bars << BarPair(qt_("Reset"), INHERIT);
return bars;
if (fi.underbar() == FONT_TOGGLE)
return UNDERBAR_TOGGLE;
+ if (fi.strikeout() == FONT_TOGGLE)
+ return STRIKEOUT_TOGGLE;
+
if (fi.noun() == FONT_TOGGLE)
return NOUN_TOGGLE;
case IGNORE:
fi.setEmph(FONT_IGNORE);
fi.setUnderbar(FONT_IGNORE);
+ fi.setStrikeout(FONT_IGNORE);
fi.setNoun(FONT_IGNORE);
break;
fi.setUnderbar(FONT_TOGGLE);
break;
+ case STRIKEOUT_TOGGLE:
+ fi.setStrikeout(FONT_TOGGLE);
+ break;
+
case NOUN_TOGGLE:
fi.setNoun(FONT_TOGGLE);
break;
case INHERIT:
fi.setEmph(FONT_INHERIT);
fi.setUnderbar(FONT_INHERIT);
+ fi.setStrikeout(FONT_INHERIT);
fi.setNoun(FONT_INHERIT);
break;
}
///
NOUN_TOGGLE,
///
+ STRIKEOUT_TOGGLE,
+ ///
INHERIT
};
textwidth = smallCapsText(x, y, str, f);
if (f.underbar() == FONT_ON)
underline(f, x, y, textwidth);
+ if (f.strikeout() == FONT_ON)
+ strikeoutLine(f, x, y, textwidth);
return textwidth;
}
textwidth = fm.width(s);
if (f.underbar() == FONT_ON)
underline(f, x, y, textwidth);
+ if (f.strikeout() == FONT_ON)
+ strikeoutLine(f, x, y, textwidth);
if (!isDrawingEnabled())
return textwidth;
}
+void GuiPainter::strikeoutLine(FontInfo const & f, int x, int y, int width)
+{
+ FontMetrics const & fm = theFontMetrics(f);
+
+ int const middle = max((fm.maxHeight() / 4), 1);
+ int const height = middle/3;
+
+ if (height < 2)
+ line(x, y - middle, x + width, y - middle, f.realColor());
+ else
+ fillRectangle(x, y - middle, width, height, f.realColor());
+}
+
+
void GuiPainter::dashedUnderline(FontInfo const & f, int x, int y, int width)
{
FontMetrics const & fm = theFontMetrics(f);
/// check the font, and if set, draw an dashed underline
void dashedUnderline(FontInfo const & f,
int x, int y, int width);
+ /// check the font, and if set, draw an strike-through line
+ void strikeoutLine(FontInfo const & f,
+ int x, int y, int width);
/// draw a bevelled button border
void buttonFrame(int x, int y, int w, int h);
case LFUN_FONT_SIZE:
case LFUN_FONT_STATE:
case LFUN_FONT_UNDERLINE:
+ case LFUN_FONT_STRIKEOUT:
case LFUN_FOOTNOTE_INSERT:
case LFUN_HYPERLINK_INSERT:
case LFUN_INDEX_INSERT:
case LFUN_TEXTSTYLE_UPDATE:
case LFUN_FONT_SIZE:
case LFUN_FONT_UNDERLINE:
+ case LFUN_FONT_STRIKEOUT:
case LFUN_LANGUAGE:
case LFUN_WORD_CAPITALIZE:
case LFUN_WORD_UPCASE: