}
-void BufferView::setCursorLanguage(std::string const & code)
-{
- Language const * lang = languages.getFromCode(code, buffer_.getLanguages());
- if (lang) {
- d->cursor_.current_font.setLanguage(lang);
- d->cursor_.real_current_font.setLanguage(lang);
- } else
- LYXERR0("setCursorLanguage: unknown language code " << code);
-}
-
-
bool BufferView::singleParUpdate()
{
Text & buftext = buffer_.text();
/// sets cursor.
/// This is used when handling LFUN_MOUSE_PRESS.
bool mouseSetCursor(Cursor & cur, bool select = false);
- /// Set the cursor language from language code.
- /* Considers first exact math with the codes used in the document,
- * then approximate match among the same list, and finally exact
- * or partial match with the whole list of languages.
- */
- void setCursorLanguage(std::string const & code);
/// sets the selection.
/* When \c backwards == false, set anchor
#include "DispatchResult.h"
#include "FuncCode.h"
#include "FuncRequest.h"
+#include "Language.h"
#include "Layout.h"
#include "LyXAction.h"
#include "LyXRC.h"
#include "mathed/MathFactory.h"
#include "mathed/InsetMathMacro.h"
+#include "frontends/Application.h"
+
#include <sstream>
#include <limits>
#include <map>
}
+void Cursor::setLanguageFromInput()
+{
+ string const & code = theApp()->inputLanguageCode();
+ Language const * lang = languages.getFromCode(code, buffer()->getLanguages());
+ if (lang) {
+ current_font.setLanguage(lang);
+ real_current_font.setLanguage(lang);
+ } else
+ LYXERR0("setLanguageFromCode: unknown language code " << code);
+}
+
+
void Cursor::setCurrentFont()
{
CursorSlice const & cs = innerTextSlice();
current_font = par.getFontSettings(bufparams, cpos);
real_current_font = tm.displayFont(cpit, cpos);
+ // set language to input language
+ setLanguageFromInput();
+
// special case for paragraph end
if (cs.pos() == lastpos()
&& tm.isRTLBoundary(cpit, cs.pos())
/// get the resut of the last dispatch
DispatchResult const & result() const;
- ///
+ /// Set the cursor language from current input method language
+ /* Considers first exact math with the codes used in the document,
+ * then approximate match among the same list, and finally exact
+ * or partial match with the whole list of languages.
+ */
+ void setLanguageFromInput();
+ /// Set the current font of the cursor from its location.
void setCurrentFont();
/**
if ((code.size() == 2) && (langcode.size() > 2)
&& (code + '_' == langcode.substr(0, 3)))
return ApproximateMatch;
- if (code.substr(0,2) == langcode.substr(0,2))
+ if (code.substr(0,2) == langcode.substr(0,2))
return VeryApproximateMatch;
return NoMatch;
}
QLocale loc = inputMethod()->locale();
#endif
//LYXERR0("input lang = " << fromqstr(loc.name()));
- return fromqstr(loc.name());
+ return loc.name() == "C" ? "en_US" : fromqstr(loc.name());
}
{
//LYXERR0("Change language to " << inputLanguage()->lang());
if (currentView() && currentView()->currentBufferView())
- currentView()->currentBufferView()->setCursorLanguage(inputLanguageCode());
+ currentView()->currentBufferView()->cursor().setLanguageFromInput();
}
case QEvent::KeyboardLayoutChange:
//LYXERR0("keyboard change");
if (currentView() && currentView()->currentBufferView())
- currentView()->currentBufferView()->setCursorLanguage(inputLanguageCode());
+ currentView()->currentBufferView()->cursor().setLanguageFromInput();
e->accept();
return true;
#endif