Skip to content

Commit

Permalink
Support Compatibility display style
Browse files Browse the repository at this point in the history
  • Loading branch information
epico committed Jan 28, 2021
1 parent 39c7da6 commit 330ba5b
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 10 deletions.
3 changes: 2 additions & 1 deletion src/PYConfig.h
Expand Up @@ -35,7 +35,8 @@ namespace PY {

typedef enum {
DISPLAY_STYLE_TRADITIONAL,
DISPLAY_STYLE_COMPACT
DISPLAY_STYLE_COMPACT,
DISPLAY_STYLE_COMPATIBILITY
} DisplayStyle;

enum CloudInputSource{
Expand Down
9 changes: 6 additions & 3 deletions src/PYPBopomofoEditor.cc
Expand Up @@ -345,7 +345,8 @@ BopomofoEditor::commit (const gchar *str)
void
BopomofoEditor::updatePreeditText ()
{
if (DISPLAY_STYLE_COMPACT == m_config.displayStyle ())
if (DISPLAY_STYLE_COMPACT == m_config.displayStyle () ||
DISPLAY_STYLE_COMPATIBILITY == m_config.displayStyle ())
return;

guint num = 0;
Expand Down Expand Up @@ -405,7 +406,8 @@ void
BopomofoEditor::updateAuxiliaryText (void)
{
if (G_UNLIKELY (m_text.empty ())) {
if (DISPLAY_STYLE_TRADITIONAL == m_config.displayStyle ())
if (DISPLAY_STYLE_TRADITIONAL == m_config.displayStyle () ||
DISPLAY_STYLE_COMPATIBILITY == m_config.displayStyle ())
hideAuxiliaryText ();
if (DISPLAY_STYLE_COMPACT == m_config.displayStyle ())
hidePreeditText ();
Expand All @@ -424,7 +426,8 @@ BopomofoEditor::updateAuxiliaryText (void)
m_buffer << p;

StaticText text (m_buffer);
if (DISPLAY_STYLE_TRADITIONAL == m_config.displayStyle ())
if (DISPLAY_STYLE_TRADITIONAL == m_config.displayStyle () ||
DISPLAY_STYLE_COMPATIBILITY == m_config.displayStyle ())
Editor::updateAuxiliaryText (text, TRUE);
if (DISPLAY_STYLE_COMPACT == m_config.displayStyle ())
Editor::updatePreeditText (text, 0, TRUE);
Expand Down
3 changes: 2 additions & 1 deletion src/PYPConfig.cc
Expand Up @@ -193,7 +193,8 @@ static const struct{
DisplayStyle display_style;
} display_style_options [] = {
{0, DISPLAY_STYLE_TRADITIONAL},
{1, DISPLAY_STYLE_COMPACT}
{1, DISPLAY_STYLE_COMPACT},
{2, DISPLAY_STYLE_COMPATIBILITY}
};

static const struct{
Expand Down
6 changes: 4 additions & 2 deletions src/PYPDoublePinyinEditor.cc
Expand Up @@ -124,7 +124,8 @@ void
DoublePinyinEditor::updateAuxiliaryText (void)
{
if (G_UNLIKELY (m_text.empty ())) {
if (DISPLAY_STYLE_TRADITIONAL == m_config.displayStyle ())
if (DISPLAY_STYLE_TRADITIONAL == m_config.displayStyle () ||
DISPLAY_STYLE_COMPATIBILITY == m_config.displayStyle ())
hideAuxiliaryText ();
if (DISPLAY_STYLE_COMPACT == m_config.displayStyle ())
hidePreeditText ();
Expand All @@ -143,7 +144,8 @@ DoublePinyinEditor::updateAuxiliaryText (void)
m_buffer << p;

StaticText text (m_buffer);
if (DISPLAY_STYLE_TRADITIONAL == m_config.displayStyle ())
if (DISPLAY_STYLE_TRADITIONAL == m_config.displayStyle () ||
DISPLAY_STYLE_COMPATIBILITY == m_config.displayStyle ())
Editor::updateAuxiliaryText (text, TRUE);
if (DISPLAY_STYLE_COMPACT == m_config.displayStyle ())
Editor::updatePreeditText (text, 0, TRUE);
Expand Down
6 changes: 4 additions & 2 deletions src/PYPFullPinyinEditor.cc
Expand Up @@ -91,7 +91,8 @@ void
FullPinyinEditor::updateAuxiliaryText (void)
{
if (G_UNLIKELY (m_text.empty ())) {
if (DISPLAY_STYLE_TRADITIONAL == m_config.displayStyle ())
if (DISPLAY_STYLE_TRADITIONAL == m_config.displayStyle () ||
DISPLAY_STYLE_COMPATIBILITY == m_config.displayStyle ())
hideAuxiliaryText ();
if (DISPLAY_STYLE_COMPACT == m_config.displayStyle ())
hidePreeditText ();
Expand All @@ -110,7 +111,8 @@ FullPinyinEditor::updateAuxiliaryText (void)
m_buffer << p;

StaticText text (m_buffer);
if (DISPLAY_STYLE_TRADITIONAL == m_config.displayStyle ())
if (DISPLAY_STYLE_TRADITIONAL == m_config.displayStyle () ||
DISPLAY_STYLE_COMPATIBILITY == m_config.displayStyle ())
Editor::updateAuxiliaryText (text, TRUE);
if (DISPLAY_STYLE_COMPACT == m_config.displayStyle ())
Editor::updatePreeditText (text, 0, TRUE);
Expand Down
3 changes: 2 additions & 1 deletion src/PYPPinyinEditor.cc
Expand Up @@ -227,7 +227,8 @@ PinyinEditor::commit (const gchar *str)
void
PinyinEditor::updatePreeditText ()
{
if (DISPLAY_STYLE_COMPACT == m_config.displayStyle ())
if (DISPLAY_STYLE_COMPACT == m_config.displayStyle () ||
DISPLAY_STYLE_COMPATIBILITY == m_config.displayStyle ())
return;

guint num = 0;
Expand Down

0 comments on commit 330ba5b

Please sign in to comment.