Skip to content

Commit

Permalink
Handle zoom shortcut keys better (#447)
Browse files Browse the repository at this point in the history
  • Loading branch information
gfrenoy committed Apr 4, 2020
1 parent bf2ef99 commit 815edcd
Showing 1 changed file with 35 additions and 15 deletions.
50 changes: 35 additions & 15 deletions lib/PACTerminal.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1126,6 +1126,11 @@ sub _setupCallbacks {
$self->_showInfoTab();
return 1;
}

# Test Zooming actions
if ($self->_zoomHandler($keyval)) {
return 1;
}
}
# <Ctrl>
elsif ($ctrl && (! $$self{_CFG}{environments}{$$self{_UUID}}{'terminal options'}{'disable CTRL key bindings'})) {
Expand All @@ -1148,21 +1153,7 @@ sub _setupCallbacks {
}

# Test Zooming actions
my $zoom = 0;
my $scale = $$self{_GUI}{_VTE}->get_font_scale();

if ($keyval eq 'plus' || $keyval eq 'KP_Add') {
$zoom = 1;
$scale += 0.1;
} elsif ($keyval eq 'minus' || $keyval eq 'KP_Subtract') {
$zoom = 1;
$scale -= 0.1;
} elsif ($keyval eq '0' || $keyval eq 'KP_0') {
$zoom = 1;
$scale = 1;
}
if ($zoom) {
$$self{_GUI}{_VTE}->set_font_scale($scale);
if ($self->_zoomHandler($keyval)) {
return 1;
}
}
Expand Down Expand Up @@ -4241,6 +4232,31 @@ sub _showEmbedMessages {
$$self{_GUI}{_BTNLOG}->set_label('Hide _messages');
}

sub _zoomHandler {
my $self = shift;
my $keyval = shift;

my $zoom = 0;
my $scale = $$self{_GUI}{_VTE}->get_font_scale();

if ($keyval eq 'plus' || $keyval eq 'KP_Add') {
$zoom = 1;
$scale += 0.1;
} elsif ($keyval eq 'minus' || $keyval eq 'KP_Subtract') {
$zoom = 1;
$scale -= 0.1;
} elsif ($keyval eq '0' || $keyval eq 'KP_0') {
$zoom = 1;
$scale = 1;
}
if ($zoom) {
$$self{_GUI}{_VTE}->set_font_scale($scale);
return 1;
}

return 0;
}

# END: Private functions definitions
###################################################################

Expand Down Expand Up @@ -4531,6 +4547,10 @@ For an embed connection, hide the console displaying the messages concerning the
For an embed connection, show the console displaying the messages concerning the connection.
=head2 sub _zoomHandler
On a keypress, check if zoom factor of the terminal should be changed.
=head2 sub _hasKeePassField
Returns true (1) if this terminal has a least on field whose value is kept into a KeePass database file
Expand Down

0 comments on commit 815edcd

Please sign in to comment.