Skip to content

Commit

Permalink
Support square bracket page option
Browse files Browse the repository at this point in the history
  • Loading branch information
epico committed Jan 7, 2025
1 parent 419f189 commit bab868c
Show file tree
Hide file tree
Showing 7 changed files with 74 additions and 1 deletion.
19 changes: 19 additions & 0 deletions src/PYEnglishEditor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,12 @@ EnglishEditor::processKeyEvent (guint keyval, guint keycode, guint modifiers)
m_text.insert (m_cursor, keyval);
m_cursor ++;
}

if (!m_config.squareBracketPage () &&
(IBUS_bracketleft == keyval || IBUS_bracketright == keyval)) {
m_text.insert (m_cursor, keyval);
m_cursor ++;
}
}

/* Deal other staff with updateStateFromInput (). */
Expand Down Expand Up @@ -140,6 +146,12 @@ EnglishEditor::processPageKey (guint keyval)
return TRUE;
}
break;
case IBUS_bracketleft:
if (m_config.squareBracketPage ()) {
pageUp ();
return TRUE;
}
break;
case IBUS_period:
if (m_config.commaPeriodPage ()) {
pageDown ();
Expand All @@ -152,6 +164,13 @@ EnglishEditor::processPageKey (guint keyval)
return TRUE;
}
break;
case IBUS_bracketright:
if (m_config.squareBracketPage ()) {
pageDown ();
return TRUE;
}
break;

case IBUS_Up:
case IBUS_KP_Up:
cursorUp ();
Expand Down
2 changes: 1 addition & 1 deletion src/PYEnglishEditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace PY {

class EnglishDatabase;

static const std::string EnglishSymbols = "`~!@*()+[]{}\\|:\"/<>?";
static const std::string EnglishSymbols = "`~!@*()+{}\\|:\"/<>?";

class EnglishEditor : public Editor {
private:
Expand Down
15 changes: 15 additions & 0 deletions src/PYExtEditor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,14 @@ ExtEditor::processPageKey (guint keyval)
return TRUE;
}
break;
#endif
case IBUS_bracketleft:
if (m_config.squareBracketPage ()) {
pageUp ();
return TRUE;
}
break;
#if 0
//For "2.5" input.
case IBUS_period:
if (m_config.commaPeriodPage ()) {
Expand All @@ -285,6 +293,13 @@ ExtEditor::processPageKey (guint keyval)
return TRUE;
}
break;
case IBUS_bracketright:
if (m_config.squareBracketPage ()) {
pageDown ();
return TRUE;
}
break;

case IBUS_Up:
case IBUS_KP_Up:
cursorUp ();
Expand Down
12 changes: 12 additions & 0 deletions src/PYPPinyinEditor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,12 @@ PinyinEditor::processPunct (guint keyval, guint keycode,
return TRUE;
}
break;
case IBUS_bracketleft:
if (m_config.squareBracketPage ()) {
pageUp ();
return TRUE;
}
break;
case IBUS_period:
if (m_config.commaPeriodPage ()) {
pageDown ();
Expand All @@ -121,6 +127,12 @@ PinyinEditor::processPunct (guint keyval, guint keycode,
return TRUE;
}
break;
case IBUS_bracketright:
if (m_config.squareBracketPage ()) {
pageDown ();
return TRUE;
}
break;
}

if (m_config.autoCommit ()) {
Expand Down
3 changes: 3 additions & 0 deletions src/PYPPinyinEngine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,9 @@ PinyinEngine::processKeyEvent (guint keyval, guint keycode, guint modifiers)
/* For full pinyin, "'" is used. */
(PinyinConfig::instance ().doublePinyin () &&
IBUS_apostrophe == keyval) ||
/* Use square brackets to flip page */
(!PinyinConfig::instance ().squareBracketPage () &&
(IBUS_bracketleft == keyval || IBUS_bracketright == keyval)) ||
/* For double pinyin, ";" is used. */
(!PinyinConfig::instance ().doublePinyin () &&
IBUS_semicolon == keyval)) &&
Expand Down
12 changes: 12 additions & 0 deletions src/PYPSuggestionEditor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,12 @@ SuggestionEditor::processPageKey (guint keyval)
return TRUE;
}
break;
case IBUS_bracketleft:
if (m_config.squareBracketPage ()) {
pageUp ();
return TRUE;
}
break;
case IBUS_period:
if (m_config.commaPeriodPage ()) {
pageDown ();
Expand All @@ -125,6 +131,12 @@ SuggestionEditor::processPageKey (guint keyval)
return TRUE;
}
break;
case IBUS_bracketright:
if (m_config.squareBracketPage ()) {
pageDown ();
return TRUE;
}
break;

case IBUS_Up:
case IBUS_KP_Up:
Expand Down
12 changes: 12 additions & 0 deletions src/PYTableEditor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,12 @@ TableEditor::processPageKey (guint keyval)
return TRUE;
}
break;
case IBUS_bracketleft:
if (m_config.squareBracketPage ()) {
pageUp ();
return TRUE;
}
break;
case IBUS_period:
if (m_config.commaPeriodPage ()) {
pageDown ();
Expand All @@ -147,6 +153,12 @@ TableEditor::processPageKey (guint keyval)
return TRUE;
}
break;
case IBUS_bracketright:
if (m_config.squareBracketPage ()) {
pageDown ();
return TRUE;
}
break;

case IBUS_Up:
case IBUS_KP_Up:
Expand Down

0 comments on commit bab868c

Please sign in to comment.