mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 18:08:10 +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|...>
|
# FontEncoding <font encoding|font encoding|...>
|
||||||
# InternalEncoding <true|false>
|
# InternalEncoding <true|false>
|
||||||
# RTL <true|false>
|
# RTL <true|false>
|
||||||
|
# WordWrap <true|false>
|
||||||
# LangCode <language_code>
|
# LangCode <language_code>
|
||||||
# LangVariety <language_variety>
|
# LangVariety <language_variety>
|
||||||
# PreBabelPreamble
|
# PreBabelPreamble
|
||||||
@ -100,6 +101,9 @@
|
|||||||
# If True, LyX takes care for characters/macros that do not exist in
|
# If True, LyX takes care for characters/macros that do not exist in
|
||||||
# some font encodings ("<", ">", "|" and straight quote).
|
# some font encodings ("<", ">", "|" and straight quote).
|
||||||
# It is not required for standard encodings like T2A. See bug #5091.
|
# 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
|
# * LangCode is also used for spellchecking and thesaurus, where the
|
||||||
# dictionaries are named accordingly. Thus, check this when introducing/
|
# dictionaries are named accordingly. Thus, check this when introducing/
|
||||||
# changing language codes (especially aspell, thesaurus).
|
# changing language codes (especially aspell, thesaurus).
|
||||||
@ -501,6 +505,7 @@ Language chinese-simplified
|
|||||||
HasGuiSupport true
|
HasGuiSupport true
|
||||||
Encoding euc-cn
|
Encoding euc-cn
|
||||||
QuoteStyle english
|
QuoteStyle english
|
||||||
|
WordWrap false
|
||||||
LangCode zh_CN
|
LangCode zh_CN
|
||||||
DateFormats "yyyy年M月d日|yyyy-M-d|yy-M-d"
|
DateFormats "yyyy年M月d日|yyyy-M-d|yy-M-d"
|
||||||
Requires CJK
|
Requires CJK
|
||||||
@ -512,6 +517,7 @@ Language chinese-traditional
|
|||||||
HasGuiSupport true
|
HasGuiSupport true
|
||||||
QuoteStyle cjk
|
QuoteStyle cjk
|
||||||
Encoding utf8-cjk
|
Encoding utf8-cjk
|
||||||
|
WordWrap false
|
||||||
LangCode zh_TW
|
LangCode zh_TW
|
||||||
DateFormats "yyyy年M月d日|yyyy年M月d日|yy年M月d日"
|
DateFormats "yyyy年M月d日|yyyy年M月d日|yy年M月d日"
|
||||||
Requires CJK
|
Requires CJK
|
||||||
@ -909,6 +915,7 @@ Language japanese
|
|||||||
HasGuiSupport true
|
HasGuiSupport true
|
||||||
BabelName japanese
|
BabelName japanese
|
||||||
Encoding jis-platex
|
Encoding jis-platex
|
||||||
|
WordWrap false
|
||||||
LangCode ja_JP
|
LangCode ja_JP
|
||||||
Requires japanese
|
Requires japanese
|
||||||
FontEncoding ASCII
|
FontEncoding ASCII
|
||||||
@ -920,7 +927,8 @@ End
|
|||||||
Language japanese-cjk
|
Language japanese-cjk
|
||||||
GuiName "Japanese (CJK)"
|
GuiName "Japanese (CJK)"
|
||||||
Encoding euc-jp
|
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
|
LangCode ja_JP
|
||||||
Requires CJK
|
Requires CJK
|
||||||
QuoteStyle cjk
|
QuoteStyle cjk
|
||||||
@ -960,6 +968,7 @@ Language korean
|
|||||||
Encoding euc-kr
|
Encoding euc-kr
|
||||||
QuoteStyle cjkangle
|
QuoteStyle cjkangle
|
||||||
DateFormats "yyyy년 M월 d일|yyyy. M. d.|yy. M. d."
|
DateFormats "yyyy년 M월 d일|yyyy. M. d.|yy. M. d."
|
||||||
|
WordWrap false
|
||||||
LangCode ko_KR
|
LangCode ko_KR
|
||||||
Requires CJK
|
Requires CJK
|
||||||
End
|
End
|
||||||
|
@ -131,7 +131,8 @@ bool Language::readLanguage(Lexer & lex)
|
|||||||
LA_PROVIDES,
|
LA_PROVIDES,
|
||||||
LA_REQUIRES,
|
LA_REQUIRES,
|
||||||
LA_QUOTESTYLE,
|
LA_QUOTESTYLE,
|
||||||
LA_RTL
|
LA_RTL,
|
||||||
|
LA_WORDWRAP
|
||||||
};
|
};
|
||||||
|
|
||||||
// Keep these sorted alphabetically!
|
// Keep these sorted alphabetically!
|
||||||
@ -153,7 +154,8 @@ bool Language::readLanguage(Lexer & lex)
|
|||||||
{ "provides", LA_PROVIDES },
|
{ "provides", LA_PROVIDES },
|
||||||
{ "quotestyle", LA_QUOTESTYLE },
|
{ "quotestyle", LA_QUOTESTYLE },
|
||||||
{ "requires", LA_REQUIRES },
|
{ "requires", LA_REQUIRES },
|
||||||
{ "rtl", LA_RTL }
|
{ "rtl", LA_RTL },
|
||||||
|
{"wordwrap", LA_WORDWRAP }
|
||||||
};
|
};
|
||||||
|
|
||||||
bool error = false;
|
bool error = false;
|
||||||
@ -240,6 +242,9 @@ bool Language::readLanguage(Lexer & lex)
|
|||||||
case LA_RTL:
|
case LA_RTL:
|
||||||
lex >> rightToLeft_;
|
lex >> rightToLeft_;
|
||||||
break;
|
break;
|
||||||
|
case LA_WORDWRAP:
|
||||||
|
lex >> word_wrap_;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
lex.popTable();
|
lex.popTable();
|
||||||
|
@ -36,7 +36,7 @@ class Language {
|
|||||||
public:
|
public:
|
||||||
///
|
///
|
||||||
Language() : rightToLeft_(false), encoding_(0), internal_enc_(false),
|
Language() : rightToLeft_(false), encoding_(0), internal_enc_(false),
|
||||||
has_gui_support_(false) {}
|
has_gui_support_(false), word_wrap_(true) {}
|
||||||
/// LyX language name
|
/// LyX language name
|
||||||
std::string const lang() const { return lang_; }
|
std::string const lang() const { return lang_; }
|
||||||
/// Babel language name
|
/// Babel language name
|
||||||
@ -59,6 +59,8 @@ public:
|
|||||||
std::string const display() const { return display_; }
|
std::string const display() const { return display_; }
|
||||||
/// is this a RTL language?
|
/// is this a RTL language?
|
||||||
bool rightToLeft() const { return rightToLeft_; }
|
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.
|
* Translate a string from the layout files that appears in the output.
|
||||||
* It takes the translations from lib/layouttranslations instead of
|
* It takes the translations from lib/layouttranslations instead of
|
||||||
@ -142,6 +144,8 @@ private:
|
|||||||
///
|
///
|
||||||
bool has_gui_support_;
|
bool has_gui_support_;
|
||||||
///
|
///
|
||||||
|
bool word_wrap_;
|
||||||
|
///
|
||||||
TranslationMap layoutTranslations_;
|
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
|
* FIXME: hardcoding languages is bad. Put this information in
|
||||||
* `languages' file.
|
* `languages' file.
|
||||||
*/
|
*/
|
||||||
string const lang = brk.font.language()->lang();
|
bool const word_wrap = brk.font.language()->wordWrap();
|
||||||
bool force = lang == "chinese-simplified"
|
// When there is text before the body part (think description
|
||||||
|| lang == "chinese-traditional"
|
// environment), do not try to break.
|
||||||
|| lang == "japanese"
|
if (brk.pos < keep)
|
||||||
|| lang == "korean";
|
|
||||||
// FIXME: is it important to check for separators?
|
|
||||||
if ((!force && brk.countSeparators() == 0) || brk.pos < keep)
|
|
||||||
continue;
|
continue;
|
||||||
/* We have found a suitable separable element. This is the common case.
|
/* 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
|
* 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
|
* - shorter than the natural width of the element, in order to enforce
|
||||||
* break-up.
|
* 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
|
/* if this element originally did not cause a row overflow
|
||||||
* in itself, and the remainder of the row would still be
|
* in itself, and the remainder of the row would still be
|
||||||
* too large after breaking, then we will have issues in
|
* too large after breaking, then we will have issues in
|
||||||
|
Loading…
Reference in New Issue
Block a user