mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-25 10:58:52 +00:00
Add LFUN_WORD_TOGGLECASE (word-togglecase)
The new function word-togglecase is a companion of word-upcase and word-lowcase: it toggles each character between lowcase and upcase, which is useful when one FORGOT THE cAPS lOCK KEY. Add bindings (except for emacs) and a menu entry.
This commit is contained in:
parent
3d2ffc5b53
commit
afc524da3f
@ -13,9 +13,13 @@
|
|||||||
|
|
||||||
!!!The following new LyX functions have been introduced in 2.5:
|
!!!The following new LyX functions have been introduced in 2.5:
|
||||||
|
|
||||||
|
- The new function word-togglecase is a companion of word-upcase and
|
||||||
|
word-lowcase: it toggles each character between lowcase and upcase,
|
||||||
|
which is useful when one FORGOT THE cAPS lOCK KEY.
|
||||||
|
|
||||||
!!!The following LyX functions have been changed in 2.5:
|
!!!The following LyX functions have been changed in 2.5:
|
||||||
|
|
||||||
- The funcion window_new does not take an optional <GEOMETRY>
|
- The funcion window-new does not take an optional <GEOMETRY>
|
||||||
parameter anymore. This only worked in windows and existed for
|
parameter anymore. This only worked in windows and existed for
|
||||||
internal reasons.
|
internal reasons.
|
||||||
|
|
||||||
|
@ -154,6 +154,7 @@ Format 5
|
|||||||
|
|
||||||
\bind "M-z Down" "word-lowcase"
|
\bind "M-z Down" "word-lowcase"
|
||||||
\bind "M-z Up" "word-upcase"
|
\bind "M-z Up" "word-upcase"
|
||||||
|
\bind "M-z Left" "word-togglecase"
|
||||||
\bind "M-z Right" "word-capitalize"
|
\bind "M-z Right" "word-capitalize"
|
||||||
|
|
||||||
\bind "M-z space" "font-default"
|
\bind "M-z space" "font-default"
|
||||||
|
@ -155,6 +155,7 @@ Format 5
|
|||||||
|
|
||||||
\bind "M-c Down" "word-lowcase"
|
\bind "M-c Down" "word-lowcase"
|
||||||
\bind "M-c Up" "word-upcase"
|
\bind "M-c Up" "word-upcase"
|
||||||
|
\bind "M-c Left" "word-togglecase"
|
||||||
\bind "M-c Right" "word-capitalize"
|
\bind "M-c Right" "word-capitalize"
|
||||||
|
|
||||||
\bind "M-c space" "font-default"
|
\bind "M-c space" "font-default"
|
||||||
|
@ -190,6 +190,7 @@ Menuset
|
|||||||
Item "Capitalize|p" "word-capitalize"
|
Item "Capitalize|p" "word-capitalize"
|
||||||
Item "Uppercase|U" "word-upcase"
|
Item "Uppercase|U" "word-upcase"
|
||||||
Item "Lowercase|L" "word-lowcase"
|
Item "Lowercase|L" "word-lowcase"
|
||||||
|
Item "Toggle Case|T" "word-togglecase"
|
||||||
End
|
End
|
||||||
|
|
||||||
Menu "edit_textstyles"
|
Menu "edit_textstyles"
|
||||||
|
@ -512,6 +512,7 @@ enum FuncCode
|
|||||||
LFUN_REFERENCE_INSERT, // spitz, 20240728
|
LFUN_REFERENCE_INSERT, // spitz, 20240728
|
||||||
// 400
|
// 400
|
||||||
LFUN_REFERENCE_TO_PARAGRAPH, // spitz, 20240728
|
LFUN_REFERENCE_TO_PARAGRAPH, // spitz, 20240728
|
||||||
|
LFUN_WORD_TOGGLECASE, // lasgouttes 20241014
|
||||||
LFUN_LASTACTION // end of the table
|
LFUN_LASTACTION // end of the table
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -4654,6 +4654,17 @@ void LyXAction::init()
|
|||||||
*/
|
*/
|
||||||
{ LFUN_WORD_SELECT, "word-select", ReadOnly, Edit },
|
{ LFUN_WORD_SELECT, "word-select", ReadOnly, Edit },
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \var lyx::FuncCode lyx::LFUN_WORD_TOGGLECASE
|
||||||
|
* \li Action: Invert the case of the words in the selection or word at cursor position.
|
||||||
|
* \li Syntax: word-togglecase [<SEL_TYPE>]
|
||||||
|
* \li Params: <SEL_TYPE>: if this is equal to "partial", then the
|
||||||
|
* default word starts at cursor position (emacs-style).
|
||||||
|
* Otherwise, the whole word is considered.
|
||||||
|
* \endvar
|
||||||
|
*/
|
||||||
|
{ LFUN_WORD_TOGGLECASE, "word-togglecase", Noop, Edit },
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \var lyx::FuncCode lyx::LFUN_WORD_UPCASE
|
* \var lyx::FuncCode lyx::LFUN_WORD_UPCASE
|
||||||
* \li Action: Change the words in the selection or word at cursor position
|
* \li Action: Change the words in the selection or word at cursor position
|
||||||
|
@ -4789,18 +4789,23 @@ void Paragraph::changeCase(BufferParams const & bparams, pos_type pos,
|
|||||||
// ignore insets and don't play with deleted text!
|
// ignore insets and don't play with deleted text!
|
||||||
if (oldChar != META_INSET && !isDeleted(pos)) {
|
if (oldChar != META_INSET && !isDeleted(pos)) {
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case text_lowercase:
|
case text_lowercase:
|
||||||
newChar = lowercase(oldChar);
|
newChar = lowercase(oldChar);
|
||||||
break;
|
break;
|
||||||
case text_capitalization:
|
case text_capitalization:
|
||||||
if (capitalize) {
|
if (capitalize) {
|
||||||
newChar = uppercase(oldChar);
|
newChar = uppercase(oldChar);
|
||||||
capitalize = false;
|
capitalize = false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case text_uppercase:
|
case text_uppercase:
|
||||||
|
newChar = uppercase(oldChar);
|
||||||
|
break;
|
||||||
|
case text_togglecase:
|
||||||
|
if (isUpperCase(oldChar))
|
||||||
|
newChar = lowercase(oldChar);
|
||||||
|
else if (isLowerCase(oldChar))
|
||||||
newChar = uppercase(oldChar);
|
newChar = uppercase(oldChar);
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -110,11 +110,13 @@ public:
|
|||||||
///
|
///
|
||||||
enum TextCase {
|
enum TextCase {
|
||||||
///
|
///
|
||||||
text_lowercase = 0,
|
text_lowercase,
|
||||||
///
|
///
|
||||||
text_capitalization = 1,
|
text_capitalization,
|
||||||
///
|
///
|
||||||
text_uppercase = 2
|
text_uppercase,
|
||||||
|
///
|
||||||
|
text_togglecase
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -4946,6 +4946,10 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
|
|||||||
changeCase(cur, text_capitalization, cmd.getArg(0) == "partial");
|
changeCase(cur, text_capitalization, cmd.getArg(0) == "partial");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case LFUN_WORD_TOGGLECASE:
|
||||||
|
changeCase(cur, text_togglecase, cmd.getArg(0) == "partial");
|
||||||
|
break;
|
||||||
|
|
||||||
case LFUN_CHARS_TRANSPOSE:
|
case LFUN_CHARS_TRANSPOSE:
|
||||||
charsTranspose(cur);
|
charsTranspose(cur);
|
||||||
break;
|
break;
|
||||||
@ -7159,6 +7163,7 @@ bool Text::getStatus(Cursor & cur, FuncRequest const & cmd,
|
|||||||
case LFUN_WORD_UPCASE:
|
case LFUN_WORD_UPCASE:
|
||||||
case LFUN_WORD_LOWCASE:
|
case LFUN_WORD_LOWCASE:
|
||||||
case LFUN_WORD_CAPITALIZE:
|
case LFUN_WORD_CAPITALIZE:
|
||||||
|
case LFUN_WORD_TOGGLECASE:
|
||||||
case LFUN_CHARS_TRANSPOSE:
|
case LFUN_CHARS_TRANSPOSE:
|
||||||
case LFUN_SERVER_GET_XY:
|
case LFUN_SERVER_GET_XY:
|
||||||
case LFUN_SERVER_SET_XY:
|
case LFUN_SERVER_SET_XY:
|
||||||
|
Loading…
Reference in New Issue
Block a user