mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-25 10:58:52 +00:00
Make Word Wrap property confiurable by language
It is now possible to specify in the lib/language file whether screen rows can be broken anywhere (CJK languages) or only at work boundary. Set WordWrap to false for the CJK languages (notice that japanese-cjk had been forgotten before). Moreover, remove a test for separators in row element that was not really helpful. Fixes part of ticket #10299.
This commit is contained in:
parent
58734edff6
commit
bf88ad495c
@ -17,6 +17,7 @@
|
||||
# FontEncoding <font encoding|font encoding|...>
|
||||
# InternalEncoding <true|false>
|
||||
# RTL <true|false>
|
||||
# WordWrap <true|false>
|
||||
# LangCode <language_code>
|
||||
# LangVariety <language_variety>
|
||||
# PreBabelPreamble
|
||||
@ -100,6 +101,9 @@
|
||||
# If True, LyX takes care for characters/macros that do not exist in
|
||||
# some font encodings ("<", ">", "|" and straight quote).
|
||||
# It is not required for standard encodings like T2A. See bug #5091.
|
||||
# * WordWrap is only used for on-screen display: when is is true (the default), rows are broken
|
||||
# at word boundary; otherwise, they can be ended at arbitrary position. This
|
||||
# setting is useful for CJK languages.
|
||||
# * LangCode is also used for spellchecking and thesaurus, where the
|
||||
# dictionaries are named accordingly. Thus, check this when introducing/
|
||||
# changing language codes (especially aspell, thesaurus).
|
||||
@ -501,6 +505,7 @@ Language chinese-simplified
|
||||
HasGuiSupport true
|
||||
Encoding euc-cn
|
||||
QuoteStyle english
|
||||
WordWrap false
|
||||
LangCode zh_CN
|
||||
DateFormats "yyyy年M月d日|yyyy-M-d|yy-M-d"
|
||||
Requires CJK
|
||||
@ -512,6 +517,7 @@ Language chinese-traditional
|
||||
HasGuiSupport true
|
||||
QuoteStyle cjk
|
||||
Encoding utf8-cjk
|
||||
WordWrap false
|
||||
LangCode zh_TW
|
||||
DateFormats "yyyy年M月d日|yyyy年M月d日|yy年M月d日"
|
||||
Requires CJK
|
||||
@ -909,6 +915,7 @@ Language japanese
|
||||
HasGuiSupport true
|
||||
BabelName japanese
|
||||
Encoding jis-platex
|
||||
WordWrap false
|
||||
LangCode ja_JP
|
||||
Requires japanese
|
||||
FontEncoding ASCII
|
||||
@ -920,7 +927,8 @@ End
|
||||
Language japanese-cjk
|
||||
GuiName "Japanese (CJK)"
|
||||
Encoding euc-jp
|
||||
DateFormats "yyyy年M月d日|yyyy/MM/dd|yy/MM/dd"
|
||||
DateFormats "yyyy年M月d日|yyyy/MM/dd|yy/MM/dd"
|
||||
WordWrap false
|
||||
LangCode ja_JP
|
||||
Requires CJK
|
||||
QuoteStyle cjk
|
||||
@ -960,6 +968,7 @@ Language korean
|
||||
Encoding euc-kr
|
||||
QuoteStyle cjkangle
|
||||
DateFormats "yyyy년 M월 d일|yyyy. M. d.|yy. M. d."
|
||||
WordWrap false
|
||||
LangCode ko_KR
|
||||
Requires CJK
|
||||
End
|
||||
|
@ -131,7 +131,8 @@ bool Language::readLanguage(Lexer & lex)
|
||||
LA_PROVIDES,
|
||||
LA_REQUIRES,
|
||||
LA_QUOTESTYLE,
|
||||
LA_RTL
|
||||
LA_RTL,
|
||||
LA_WORDWRAP
|
||||
};
|
||||
|
||||
// Keep these sorted alphabetically!
|
||||
@ -153,7 +154,8 @@ bool Language::readLanguage(Lexer & lex)
|
||||
{ "provides", LA_PROVIDES },
|
||||
{ "quotestyle", LA_QUOTESTYLE },
|
||||
{ "requires", LA_REQUIRES },
|
||||
{ "rtl", LA_RTL }
|
||||
{ "rtl", LA_RTL },
|
||||
{"wordwrap", LA_WORDWRAP }
|
||||
};
|
||||
|
||||
bool error = false;
|
||||
@ -240,6 +242,9 @@ bool Language::readLanguage(Lexer & lex)
|
||||
case LA_RTL:
|
||||
lex >> rightToLeft_;
|
||||
break;
|
||||
case LA_WORDWRAP:
|
||||
lex >> word_wrap_;
|
||||
break;
|
||||
}
|
||||
}
|
||||
lex.popTable();
|
||||
|
@ -36,7 +36,7 @@ class Language {
|
||||
public:
|
||||
///
|
||||
Language() : rightToLeft_(false), encoding_(0), internal_enc_(false),
|
||||
has_gui_support_(false) {}
|
||||
has_gui_support_(false), word_wrap_(true) {}
|
||||
/// LyX language name
|
||||
std::string const lang() const { return lang_; }
|
||||
/// Babel language name
|
||||
@ -59,6 +59,8 @@ public:
|
||||
std::string const display() const { return display_; }
|
||||
/// is this a RTL language?
|
||||
bool rightToLeft() const { return rightToLeft_; }
|
||||
/// shall text be wrapped at word boundary ?
|
||||
bool wordWrap() const { return word_wrap_; }
|
||||
/**
|
||||
* Translate a string from the layout files that appears in the output.
|
||||
* It takes the translations from lib/layouttranslations instead of
|
||||
@ -142,6 +144,8 @@ private:
|
||||
///
|
||||
bool has_gui_support_;
|
||||
///
|
||||
bool word_wrap_;
|
||||
///
|
||||
TranslationMap layoutTranslations_;
|
||||
};
|
||||
|
||||
|
13
src/Row.cpp
13
src/Row.cpp
@ -492,13 +492,10 @@ bool Row::shortenIfNeeded(pos_type const keep, int const w, int const next_width
|
||||
* FIXME: hardcoding languages is bad. Put this information in
|
||||
* `languages' file.
|
||||
*/
|
||||
string const lang = brk.font.language()->lang();
|
||||
bool force = lang == "chinese-simplified"
|
||||
|| lang == "chinese-traditional"
|
||||
|| lang == "japanese"
|
||||
|| lang == "korean";
|
||||
// FIXME: is it important to check for separators?
|
||||
if ((!force && brk.countSeparators() == 0) || brk.pos < keep)
|
||||
bool const word_wrap = brk.font.language()->wordWrap();
|
||||
// When there is text before the body part (think description
|
||||
// environment), do not try to break.
|
||||
if (brk.pos < keep)
|
||||
continue;
|
||||
/* We have found a suitable separable element. This is the common case.
|
||||
* Try to break it cleanly (at word boundary) at a length that is both
|
||||
@ -506,7 +503,7 @@ bool Row::shortenIfNeeded(pos_type const keep, int const w, int const next_width
|
||||
* - shorter than the natural width of the element, in order to enforce
|
||||
* break-up.
|
||||
*/
|
||||
if (brk.breakAt(min(w - wid_brk, brk.dim.wid - 2), force)) {
|
||||
if (brk.breakAt(min(w - wid_brk, brk.dim.wid - 2), !word_wrap)) {
|
||||
/* if this element originally did not cause a row overflow
|
||||
* in itself, and the remainder of the row would still be
|
||||
* too large after breaking, then we will have issues in
|
||||
|
Loading…
Reference in New Issue
Block a user