Skip to content

Commit

Permalink
Merge pull request #1702 from contour-terminal/fix/control_numbers
Browse files Browse the repository at this point in the history
Add control codes for Control+(5,6,7,8) input
  • Loading branch information
Yaraslaut authored Jan 5, 2025
2 parents 5ce620b + 9a4e40a commit 98f81b6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions metainfo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@
<li>Ensure inserting new tabs happens right next to the currently active tab (#1695)</li>
<li>Adds `MoveTabToLeft` and `MoveTabToRight` actions to move tabs around (#1695)</li>
<li>Adds `MoveTabTo` action to move tabs to a specific position (#1695)</li>
<li>Adds handling of control codes for Ctrl+5|6|7|8 (#1701)</li>
<li>Adds CenterCursor (`zz`) vi motion</li>
</ul>
</description>
Expand Down
16 changes: 16 additions & 0 deletions src/vtbackend/InputGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,22 @@ bool StandardKeyboardInputGenerator::generateChar(char32_t characterEvent,
return true;
}

// handle Control + 5, 6, 7
if (modifiers == Modifier::Control && crispy::ascending('5', chr, '7'))
{
// part of the control characters
// 5 6 7 corresponds to 1D 1E 1F
append(static_cast<char>(24 + characterEvent - '0'));
return true;
}

// handle Control + 8 which is DEL
if (modifiers == Modifier::Control && chr == '8')
{
append('\x7F');
return true;
}

if (modifiers == Modifier::Control && characterEvent >= '[' && characterEvent <= '_')
{
append(static_cast<char>(chr - 'A' + 1)); // remaining C0 characters 0x1B .. 0x1F
Expand Down

0 comments on commit 98f81b6

Please sign in to comment.