mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 13:18:28 +00:00
Allow to switch buffer languages via the menu.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@33366 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
bded680ff8
commit
a61eeb1fb2
@ -315,6 +315,7 @@ Menuset
|
|||||||
Item "Apply Last Text Style|A" "textstyle-apply"
|
Item "Apply Last Text Style|A" "textstyle-apply"
|
||||||
Submenu "Text Style|S" "edit_textstyles"
|
Submenu "Text Style|S" "edit_textstyles"
|
||||||
Item "Paragraph Settings...|P" "layout-paragraph"
|
Item "Paragraph Settings...|P" "layout-paragraph"
|
||||||
|
LanguageSelector
|
||||||
Separator
|
Separator
|
||||||
Item "Fullscreen Mode" "ui-toggle fullscreen"
|
Item "Fullscreen Mode" "ui-toggle fullscreen"
|
||||||
End
|
End
|
||||||
|
@ -111,6 +111,7 @@ Menuset
|
|||||||
Item "Move Paragraph Down|v" "paragraph-move-down"
|
Item "Move Paragraph Down|v" "paragraph-move-down"
|
||||||
Separator
|
Separator
|
||||||
Submenu "Text Style|S" "edit_textstyles"
|
Submenu "Text Style|S" "edit_textstyles"
|
||||||
|
LanguageSelector
|
||||||
Item "Paragraph Settings...|P" "layout-paragraph"
|
Item "Paragraph Settings...|P" "layout-paragraph"
|
||||||
Separator
|
Separator
|
||||||
# Mathed b0rkage means these don't work properly
|
# Mathed b0rkage means these don't work properly
|
||||||
@ -125,7 +126,7 @@ Menuset
|
|||||||
# obvious what the context is for the others)
|
# obvious what the context is for the others)
|
||||||
OptItem "Increase List Depth|I" "depth-increment"
|
OptItem "Increase List Depth|I" "depth-increment"
|
||||||
OptItem "Decrease List Depth|D" "depth-decrement"
|
OptItem "Decrease List Depth|D" "depth-decrement"
|
||||||
OptItem "Dissolve Inset|l" "inset-dissolve"
|
OptItem "Dissolve Inset" "inset-dissolve"
|
||||||
OptItem "TeX Code Settings...|C" "inset-settings ert"
|
OptItem "TeX Code Settings...|C" "inset-settings ert"
|
||||||
# 'a' shortcut to match Insert entry, shouldn't clash with Table Settings
|
# 'a' shortcut to match Insert entry, shouldn't clash with Table Settings
|
||||||
OptItem "Float Settings...|a" "inset-settings float"
|
OptItem "Float Settings...|a" "inset-settings float"
|
||||||
|
@ -2172,6 +2172,27 @@ bool Buffer::isMultiLingual() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
std::set<Language const *> Buffer::getLanguages() const
|
||||||
|
{
|
||||||
|
std::set<Language const *> languages;
|
||||||
|
getLanguages(languages);
|
||||||
|
return languages;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Buffer::getLanguages(std::set<Language const *> & languages) const
|
||||||
|
{
|
||||||
|
ParConstIterator end = par_iterator_end();
|
||||||
|
for (ParConstIterator it = par_iterator_begin(); it != end; ++it)
|
||||||
|
it->getLanguages(languages);
|
||||||
|
// also children
|
||||||
|
std::vector<Buffer *> clist = getChildren();
|
||||||
|
for (vector<Buffer *>::const_iterator cit = clist.begin();
|
||||||
|
cit != clist.end(); ++cit)
|
||||||
|
(*cit)->getLanguages(languages);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
DocIterator Buffer::getParFromID(int const id) const
|
DocIterator Buffer::getParFromID(int const id) const
|
||||||
{
|
{
|
||||||
Buffer * buf = const_cast<Buffer *>(this);
|
Buffer * buf = const_cast<Buffer *>(this);
|
||||||
|
@ -375,6 +375,8 @@ public:
|
|||||||
|
|
||||||
///
|
///
|
||||||
bool isMultiLingual() const;
|
bool isMultiLingual() const;
|
||||||
|
///
|
||||||
|
std::set<Language const *> getLanguages() const;
|
||||||
|
|
||||||
///
|
///
|
||||||
BufferParams & params();
|
BufferParams & params();
|
||||||
@ -572,6 +574,8 @@ private:
|
|||||||
*/
|
*/
|
||||||
ReadStatus readFile(Lexer &, support::FileName const & filename,
|
ReadStatus readFile(Lexer &, support::FileName const & filename,
|
||||||
bool fromString = false);
|
bool fromString = false);
|
||||||
|
///
|
||||||
|
void getLanguages(std::set<Language const *> &) const;
|
||||||
|
|
||||||
/// Use the Pimpl idiom to hide the internals.
|
/// Use the Pimpl idiom to hide the internals.
|
||||||
class Impl;
|
class Impl;
|
||||||
|
@ -2616,6 +2616,20 @@ bool Paragraph::isMultiLingual(BufferParams const & bparams) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Paragraph::getLanguages(std::set<Language const *> & languages) const
|
||||||
|
{
|
||||||
|
FontList::const_iterator cit = d->fontlist_.begin();
|
||||||
|
FontList::const_iterator end = d->fontlist_.end();
|
||||||
|
|
||||||
|
for (; cit != end; ++cit) {
|
||||||
|
Language const * lang = cit->font().language();
|
||||||
|
if (lang != ignore_language &&
|
||||||
|
lang != latex_language)
|
||||||
|
languages.insert(lang);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
docstring Paragraph::asString(int options) const
|
docstring Paragraph::asString(int options) const
|
||||||
{
|
{
|
||||||
return asString(0, size(), options);
|
return asString(0, size(), options);
|
||||||
|
@ -23,6 +23,8 @@
|
|||||||
#include "support/strfwd.h"
|
#include "support/strfwd.h"
|
||||||
#include "support/types.h"
|
#include "support/types.h"
|
||||||
|
|
||||||
|
#include <set>
|
||||||
|
|
||||||
namespace lyx {
|
namespace lyx {
|
||||||
|
|
||||||
class AuthorList;
|
class AuthorList;
|
||||||
@ -117,6 +119,8 @@ public:
|
|||||||
Language const * from, Language const * to);
|
Language const * from, Language const * to);
|
||||||
///
|
///
|
||||||
bool isMultiLingual(BufferParams const &) const;
|
bool isMultiLingual(BufferParams const &) const;
|
||||||
|
///
|
||||||
|
void getLanguages(std::set<Language const *> &) const;
|
||||||
|
|
||||||
/// Convert the paragraph to a string.
|
/// Convert the paragraph to a string.
|
||||||
/// \param AsStringParameter options. This can contain any combination of
|
/// \param AsStringParameter options. This can contain any combination of
|
||||||
|
@ -2560,6 +2560,7 @@ bool Text::getStatus(Cursor & cur, FuncRequest const & cmd,
|
|||||||
|
|
||||||
case LFUN_LANGUAGE:
|
case LFUN_LANGUAGE:
|
||||||
enable = !cur.inset().getLayout().isPassThru();
|
enable = !cur.inset().getLayout().isPassThru();
|
||||||
|
flag.setOnOff(to_utf8(cmd.argument()) == cur.real_current_font.language()->lang());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LFUN_BREAK_PARAGRAPH:
|
case LFUN_BREAK_PARAGRAPH:
|
||||||
|
@ -38,6 +38,7 @@
|
|||||||
#include "FuncStatus.h"
|
#include "FuncStatus.h"
|
||||||
#include "IndicesList.h"
|
#include "IndicesList.h"
|
||||||
#include "KeyMap.h"
|
#include "KeyMap.h"
|
||||||
|
#include "Language.h"
|
||||||
#include "Lexer.h"
|
#include "Lexer.h"
|
||||||
#include "LyXAction.h"
|
#include "LyXAction.h"
|
||||||
#include "LyX.h" // for lastfiles
|
#include "LyX.h" // for lastfiles
|
||||||
@ -164,7 +165,9 @@ public:
|
|||||||
/** Available graphics groups */
|
/** Available graphics groups */
|
||||||
GraphicsGroups,
|
GraphicsGroups,
|
||||||
/// Words suggested by the spellchecker.
|
/// Words suggested by the spellchecker.
|
||||||
SpellingSuggestions
|
SpellingSuggestions,
|
||||||
|
/** Used Languages */
|
||||||
|
LanguageSelector
|
||||||
};
|
};
|
||||||
|
|
||||||
explicit MenuItem(Kind kind) : kind_(kind), optional_(false) {}
|
explicit MenuItem(Kind kind) : kind_(kind), optional_(false) {}
|
||||||
@ -322,6 +325,7 @@ public:
|
|||||||
void expandCiteStyles(BufferView const *);
|
void expandCiteStyles(BufferView const *);
|
||||||
void expandGraphicsGroups(BufferView const *);
|
void expandGraphicsGroups(BufferView const *);
|
||||||
void expandSpellingSuggestions(BufferView const *);
|
void expandSpellingSuggestions(BufferView const *);
|
||||||
|
void expandLanguageSelector(Buffer const * buf);
|
||||||
///
|
///
|
||||||
ItemList items_;
|
ItemList items_;
|
||||||
///
|
///
|
||||||
@ -428,7 +432,8 @@ void MenuDefinition::read(Lexer & lex)
|
|||||||
md_pasterecent,
|
md_pasterecent,
|
||||||
md_toolbars,
|
md_toolbars,
|
||||||
md_graphicsgroups,
|
md_graphicsgroups,
|
||||||
md_spellingsuggestions
|
md_spellingsuggestions,
|
||||||
|
md_languageselector
|
||||||
};
|
};
|
||||||
|
|
||||||
LexerKeyword menutags[] = {
|
LexerKeyword menutags[] = {
|
||||||
@ -450,6 +455,7 @@ void MenuDefinition::read(Lexer & lex)
|
|||||||
{ "indiceslists", md_indiceslists },
|
{ "indiceslists", md_indiceslists },
|
||||||
{ "indiceslistscontext", md_indiceslistscontext },
|
{ "indiceslistscontext", md_indiceslistscontext },
|
||||||
{ "item", md_item },
|
{ "item", md_item },
|
||||||
|
{ "languageselector", md_languageselector },
|
||||||
{ "lastfiles", md_lastfiles },
|
{ "lastfiles", md_lastfiles },
|
||||||
{ "optitem", md_optitem },
|
{ "optitem", md_optitem },
|
||||||
{ "optsubmenu", md_optsubmenu },
|
{ "optsubmenu", md_optsubmenu },
|
||||||
@ -568,6 +574,10 @@ void MenuDefinition::read(Lexer & lex)
|
|||||||
add(MenuItem(MenuItem::SpellingSuggestions));
|
add(MenuItem(MenuItem::SpellingSuggestions));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case md_languageselector:
|
||||||
|
add(MenuItem(MenuItem::LanguageSelector));
|
||||||
|
break;
|
||||||
|
|
||||||
case md_indices:
|
case md_indices:
|
||||||
add(MenuItem(MenuItem::Indices));
|
add(MenuItem(MenuItem::Indices));
|
||||||
break;
|
break;
|
||||||
@ -754,6 +764,36 @@ void MenuDefinition::expandSpellingSuggestions(BufferView const * bv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void MenuDefinition::expandLanguageSelector(Buffer const * buf)
|
||||||
|
{
|
||||||
|
if (!buf)
|
||||||
|
return;
|
||||||
|
|
||||||
|
std::set<Language const *> languages =
|
||||||
|
buf->masterBuffer()->getLanguages();
|
||||||
|
|
||||||
|
if (languages.size() < 2) {
|
||||||
|
add(MenuItem(MenuItem::Command, qt_("Language ...|L"),
|
||||||
|
FuncRequest(LFUN_DIALOG_SHOW, "character")));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
MenuItem item(MenuItem::Submenu, qt_("Language|L"));
|
||||||
|
item.setSubmenu(MenuDefinition(qt_("Language")));
|
||||||
|
std::set<Language const *>::const_iterator const begin = languages.begin();
|
||||||
|
for (std::set<Language const *>::const_iterator cit = begin;
|
||||||
|
cit != languages.end(); ++cit) {
|
||||||
|
MenuItem w(MenuItem::Command, qt_((*cit)->display()),
|
||||||
|
FuncRequest(LFUN_LANGUAGE, (*cit)->lang()));
|
||||||
|
item.submenu().addWithStatusCheck(w);
|
||||||
|
}
|
||||||
|
item.submenu().add(MenuItem(MenuItem::Separator));
|
||||||
|
item.submenu().add(MenuItem(MenuItem::Command, qt_("More Languages ..."),
|
||||||
|
FuncRequest(LFUN_DIALOG_SHOW, "character")));
|
||||||
|
add(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void MenuDefinition::expandLastfiles()
|
void MenuDefinition::expandLastfiles()
|
||||||
{
|
{
|
||||||
LastFilesSection::LastFiles const & lf = theSession().lastFiles().lastFiles();
|
LastFilesSection::LastFiles const & lf = theSession().lastFiles().lastFiles();
|
||||||
@ -1652,6 +1692,10 @@ void Menus::Impl::expand(MenuDefinition const & frommenu,
|
|||||||
tomenu.expandSpellingSuggestions(bv);
|
tomenu.expandSpellingSuggestions(bv);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case MenuItem::LanguageSelector:
|
||||||
|
tomenu.expandLanguageSelector(buf);
|
||||||
|
break;
|
||||||
|
|
||||||
case MenuItem::Submenu: {
|
case MenuItem::Submenu: {
|
||||||
MenuItem item(*cit);
|
MenuItem item(*cit);
|
||||||
item.setSubmenu(MenuDefinition(cit->submenuname()));
|
item.setSubmenu(MenuDefinition(cit->submenuname()));
|
||||||
|
Loading…
Reference in New Issue
Block a user