mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 10:00:33 +00:00
Allow users to specify toolbar icons for commands with a backslash. This is in the same style as the replacements made for math-insert commands.
See the user's list: http://thread.gmane.org/gmane.editors.lyx.general/52712 git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@27979 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
afe522b1f6
commit
dd64c572c2
@ -18,6 +18,8 @@
|
|||||||
|
|
||||||
""" Convert files to the file format generated by lyx 2.0"""
|
""" Convert files to the file format generated by lyx 2.0"""
|
||||||
|
|
||||||
|
import re
|
||||||
|
|
||||||
from parser_tools import find_token, find_end_of, find_tokens, get_value, get_value_string
|
from parser_tools import find_token, find_end_of, find_tokens, get_value, get_value_string
|
||||||
|
|
||||||
####################################################################
|
####################################################################
|
||||||
@ -46,15 +48,62 @@ def revert_swiss(document):
|
|||||||
document.body[j] = document.body[j].replace("\\lang german-ch", "\\lang ngerman")
|
document.body[j] = document.body[j].replace("\\lang german-ch", "\\lang ngerman")
|
||||||
j = j + 1
|
j = j + 1
|
||||||
|
|
||||||
|
def revert_tabularvalign(document):
|
||||||
|
"Revert the tabular valign option"
|
||||||
|
i = 0
|
||||||
|
while True:
|
||||||
|
i = find_token(document.body, "\\begin_inset Tabular", i)
|
||||||
|
if i == -1:
|
||||||
|
return
|
||||||
|
j = find_end_of_inset(document.body, i)
|
||||||
|
if j == -1:
|
||||||
|
document.warning("Malformed LyX document: Could not find end of tabular.")
|
||||||
|
i = j
|
||||||
|
continue
|
||||||
|
|
||||||
|
k = find_token(document.body, "<features tabularvalignment=", i)
|
||||||
|
if k == -1:
|
||||||
|
i = j
|
||||||
|
continue
|
||||||
|
|
||||||
|
# which valignment is specified?
|
||||||
|
tabularvalignment_re = re.compile(r'<features tabularvalignment="(top|bottom)">')
|
||||||
|
m = tabularvalignment_re.match(document.body[k])
|
||||||
|
if not m:
|
||||||
|
i = j
|
||||||
|
continue
|
||||||
|
|
||||||
|
tabularvalignment = m.group(1)
|
||||||
|
|
||||||
|
subst = ['\\end_layout', '\\end_inset']
|
||||||
|
document.body[j+1:j+1] = subst # just inserts those lines
|
||||||
|
subst = ['\\begin_inset Box Frameless',
|
||||||
|
'position "' + tabularvalignment[0] +'"',
|
||||||
|
'hor_pos "c"',
|
||||||
|
'has_inner_box 1',
|
||||||
|
'inner_pos "c"',
|
||||||
|
'use_parbox 0',
|
||||||
|
'width "0col%"',
|
||||||
|
'special "none"',
|
||||||
|
'height "1in"',
|
||||||
|
'height_special "totalheight"',
|
||||||
|
'status open',
|
||||||
|
'',
|
||||||
|
'\\begin_layout Plain Layout']
|
||||||
|
document.body[i:i] = subst # this just inserts the array at i
|
||||||
|
i += len(subst) + 2 # adjust i to save a few cycles
|
||||||
|
|
||||||
##
|
##
|
||||||
# Conversion hub
|
# Conversion hub
|
||||||
#
|
#
|
||||||
|
|
||||||
supported_versions = ["2.2.0","2.0"]
|
supported_versions = ["2.0.0","2.0"]
|
||||||
convert = [[346, []]
|
convert = [[346, []],
|
||||||
|
[347, []]
|
||||||
]
|
]
|
||||||
|
|
||||||
revert = [[345, [revert_swiss]]
|
revert = [[346, [revert_tabularvalign]],
|
||||||
|
[345, [revert_swiss]]
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
@ -166,6 +166,9 @@ Menuset
|
|||||||
Item "Left Line|L" "tabular-feature toggle-line-left"
|
Item "Left Line|L" "tabular-feature toggle-line-left"
|
||||||
Item "Right Line|R" "tabular-feature toggle-line-right"
|
Item "Right Line|R" "tabular-feature toggle-line-right"
|
||||||
Separator
|
Separator
|
||||||
|
Item "Top|p" "tabular-feature tabular-valign-top"
|
||||||
|
Item "Middle|M" "tabular-feature tabular-valign-middle"
|
||||||
|
Item "Bottom|o" "tabular-feature tabular-valign-bottom"
|
||||||
End
|
End
|
||||||
|
|
||||||
Menu "edit_tabular_features"
|
Menu "edit_tabular_features"
|
||||||
|
@ -118,7 +118,7 @@ namespace {
|
|||||||
|
|
||||||
// Do not remove the comment below, so we get merge conflict in
|
// Do not remove the comment below, so we get merge conflict in
|
||||||
// independent branches. Instead add your own.
|
// independent branches. Instead add your own.
|
||||||
int const LYX_FORMAT = 346; // jspitzm: Swiss German
|
int const LYX_FORMAT = 347; // vfr: add tabular valign opion
|
||||||
|
|
||||||
typedef map<string, bool> DepClean;
|
typedef map<string, bool> DepClean;
|
||||||
typedef map<docstring, pair<InsetLabel const *, Buffer::References> > RefCache;
|
typedef map<docstring, pair<InsetLabel const *, Buffer::References> > RefCache;
|
||||||
|
@ -1894,7 +1894,8 @@ void LyXAction::init()
|
|||||||
unset-lthead|set-ltfirsthead|unset-ltfirsthead|set-ltfoot|unset-ltfoot|
|
unset-lthead|set-ltfirsthead|unset-ltfirsthead|set-ltfoot|unset-ltfoot|
|
||||||
set-ltlastfoot|unset-ltlastfoot|set-ltnewpage|toggle-ltcaption|
|
set-ltlastfoot|unset-ltlastfoot|set-ltnewpage|toggle-ltcaption|
|
||||||
set-special-column|set-special-multi|set-booktabs|unset-booktabs|
|
set-special-column|set-special-multi|set-booktabs|unset-booktabs|
|
||||||
set-top-space|set-bottom-space|set-interline-space|set-border-lines \n
|
set-top-space|set-bottom-space|set-interline-space|set-border-lines|
|
||||||
|
tabular-valign-top|tabular-valign-middle|tabular-valign-bottom \n
|
||||||
<ARG>: additional argument for some commands, use debug mode to explore its values.
|
<ARG>: additional argument for some commands, use debug mode to explore its values.
|
||||||
* \li Origin: Jug, 28 Jul 2000
|
* \li Origin: Jug, 28 Jul 2000
|
||||||
* \endvar
|
* \endvar
|
||||||
|
@ -160,6 +160,9 @@ TabularFeature tabularFeature[] =
|
|||||||
{ Tabular::SET_BOTTOM_SPACE, "set-bottom-space" },
|
{ Tabular::SET_BOTTOM_SPACE, "set-bottom-space" },
|
||||||
{ Tabular::SET_INTERLINE_SPACE, "set-interline-space" },
|
{ Tabular::SET_INTERLINE_SPACE, "set-interline-space" },
|
||||||
{ Tabular::SET_BORDER_LINES, "set-border-lines" },
|
{ Tabular::SET_BORDER_LINES, "set-border-lines" },
|
||||||
|
{ Tabular::TABULAR_VALIGN_TOP, "tabular-valign-top"},
|
||||||
|
{ Tabular::TABULAR_VALIGN_MIDDLE, "tabular-valign-middle"},
|
||||||
|
{ Tabular::TABULAR_VALIGN_BOTTOM, "tabular-valign-bottom"},
|
||||||
{ Tabular::LAST_ACTION, "" }
|
{ Tabular::LAST_ACTION, "" }
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -595,6 +598,7 @@ void Tabular::init(Buffer & buf, row_type rows_arg,
|
|||||||
cell_info.reserve(100);
|
cell_info.reserve(100);
|
||||||
updateIndexes();
|
updateIndexes();
|
||||||
is_long_tabular = false;
|
is_long_tabular = false;
|
||||||
|
tabular_valignment = LYX_VALIGN_MIDDLE;
|
||||||
rotate = false;
|
rotate = false;
|
||||||
use_booktabs = false;
|
use_booktabs = false;
|
||||||
size_t row_count = row_info.size();
|
size_t row_count = row_info.size();
|
||||||
@ -1286,6 +1290,7 @@ void Tabular::write(ostream & os) const
|
|||||||
<< write_attribute("rotate", rotate)
|
<< write_attribute("rotate", rotate)
|
||||||
<< write_attribute("booktabs", use_booktabs)
|
<< write_attribute("booktabs", use_booktabs)
|
||||||
<< write_attribute("islongtable", is_long_tabular)
|
<< write_attribute("islongtable", is_long_tabular)
|
||||||
|
<< write_attribute("tabularvalignment", tabular_valignment)
|
||||||
<< write_attribute("firstHeadTopDL", endfirsthead.topDL)
|
<< write_attribute("firstHeadTopDL", endfirsthead.topDL)
|
||||||
<< write_attribute("firstHeadBottomDL", endfirsthead.bottomDL)
|
<< write_attribute("firstHeadBottomDL", endfirsthead.bottomDL)
|
||||||
<< write_attribute("firstHeadEmpty", endfirsthead.empty)
|
<< write_attribute("firstHeadEmpty", endfirsthead.empty)
|
||||||
@ -1384,6 +1389,7 @@ void Tabular::read(Lexer & lex)
|
|||||||
getTokenValue(line, "rotate", rotate);
|
getTokenValue(line, "rotate", rotate);
|
||||||
getTokenValue(line, "booktabs", use_booktabs);
|
getTokenValue(line, "booktabs", use_booktabs);
|
||||||
getTokenValue(line, "islongtable", is_long_tabular);
|
getTokenValue(line, "islongtable", is_long_tabular);
|
||||||
|
getTokenValue(line, "tabularvalignment", tabular_valignment);
|
||||||
getTokenValue(line, "firstHeadTopDL", endfirsthead.topDL);
|
getTokenValue(line, "firstHeadTopDL", endfirsthead.topDL);
|
||||||
getTokenValue(line, "firstHeadBottomDL", endfirsthead.bottomDL);
|
getTokenValue(line, "firstHeadBottomDL", endfirsthead.bottomDL);
|
||||||
getTokenValue(line, "firstHeadEmpty", endfirsthead.empty);
|
getTokenValue(line, "firstHeadEmpty", endfirsthead.empty);
|
||||||
@ -2286,9 +2292,22 @@ int Tabular::latex(odocstream & os, OutputParams const & runparams) const
|
|||||||
++ret;
|
++ret;
|
||||||
}
|
}
|
||||||
if (is_long_tabular)
|
if (is_long_tabular)
|
||||||
os << "\\begin{longtable}{";
|
os << "\\begin{longtable}";
|
||||||
else
|
else
|
||||||
os << "\\begin{tabular}{";
|
os << "\\begin{tabular}";
|
||||||
|
|
||||||
|
switch (tabular_valignment) {
|
||||||
|
case LYX_VALIGN_TOP:
|
||||||
|
os << "[t]";
|
||||||
|
break;
|
||||||
|
case LYX_VALIGN_BOTTOM:
|
||||||
|
os << "[b]";
|
||||||
|
break;
|
||||||
|
case LYX_VALIGN_MIDDLE:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
os << "{";
|
||||||
|
|
||||||
for (col_type i = 0; i < column_info.size(); ++i) {
|
for (col_type i = 0; i < column_info.size(); ++i) {
|
||||||
if (columnLeftLine(i))
|
if (columnLeftLine(i))
|
||||||
@ -3813,6 +3832,19 @@ bool InsetTabular::getStatus(Cursor & cur, FuncRequest const & cmd,
|
|||||||
status.setOnOff(tabular.rotate);
|
status.setOnOff(tabular.rotate);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case Tabular::TABULAR_VALIGN_TOP:
|
||||||
|
status.setOnOff(tabular.tabular_valignment
|
||||||
|
== Tabular::LYX_VALIGN_TOP);
|
||||||
|
break;
|
||||||
|
case Tabular::TABULAR_VALIGN_MIDDLE:
|
||||||
|
status.setOnOff(tabular.tabular_valignment
|
||||||
|
== Tabular::LYX_VALIGN_MIDDLE);
|
||||||
|
break;
|
||||||
|
case Tabular::TABULAR_VALIGN_BOTTOM:
|
||||||
|
status.setOnOff(tabular.tabular_valignment
|
||||||
|
== Tabular::LYX_VALIGN_BOTTOM);
|
||||||
|
break;
|
||||||
|
|
||||||
case Tabular::UNSET_ROTATE_TABULAR:
|
case Tabular::UNSET_ROTATE_TABULAR:
|
||||||
status.setOnOff(!tabular.rotate);
|
status.setOnOff(!tabular.rotate);
|
||||||
break;
|
break;
|
||||||
@ -4560,6 +4592,18 @@ void InsetTabular::tabularFeatures(Cursor & cur,
|
|||||||
tabular.rotate = !tabular.rotate;
|
tabular.rotate = !tabular.rotate;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case Tabular::TABULAR_VALIGN_TOP:
|
||||||
|
tabular.tabular_valignment = Tabular::LYX_VALIGN_TOP;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Tabular::TABULAR_VALIGN_MIDDLE:
|
||||||
|
tabular.tabular_valignment = Tabular::LYX_VALIGN_MIDDLE;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Tabular::TABULAR_VALIGN_BOTTOM:
|
||||||
|
tabular.tabular_valignment = Tabular::LYX_VALIGN_BOTTOM;
|
||||||
|
break;
|
||||||
|
|
||||||
case Tabular::SET_ROTATE_CELL:
|
case Tabular::SET_ROTATE_CELL:
|
||||||
for (row_type i = sel_row_start; i <= sel_row_end; ++i)
|
for (row_type i = sel_row_start; i <= sel_row_end; ++i)
|
||||||
for (col_type j = sel_col_start; j <= sel_col_end; ++j)
|
for (col_type j = sel_col_start; j <= sel_col_end; ++j)
|
||||||
|
@ -178,6 +178,12 @@ public:
|
|||||||
///
|
///
|
||||||
SET_BORDER_LINES,
|
SET_BORDER_LINES,
|
||||||
///
|
///
|
||||||
|
TABULAR_VALIGN_TOP,
|
||||||
|
///
|
||||||
|
TABULAR_VALIGN_MIDDLE,
|
||||||
|
///
|
||||||
|
TABULAR_VALIGN_BOTTOM,
|
||||||
|
///
|
||||||
LAST_ACTION
|
LAST_ACTION
|
||||||
};
|
};
|
||||||
///
|
///
|
||||||
@ -557,6 +563,8 @@ public:
|
|||||||
bool use_booktabs;
|
bool use_booktabs;
|
||||||
///
|
///
|
||||||
bool rotate;
|
bool rotate;
|
||||||
|
///
|
||||||
|
VAlignment tabular_valignment;
|
||||||
//
|
//
|
||||||
// for long tabulars
|
// for long tabulars
|
||||||
//
|
//
|
||||||
|
Loading…
Reference in New Issue
Block a user