pager: don't scroll down for non-log
+ some code moved around in TextEditor
This commit is contained in:
parent
a18ef9939a
commit
4613a14a9f
2 changed files with 45 additions and 37 deletions
|
@ -114,12 +114,16 @@ sub _editor($title, $origdata, $readonly = 0) {
|
|||
-wrapping => 0,
|
||||
-hscrollbar => 0,
|
||||
-vscrollbar => 0,
|
||||
-pos => ($readonly ? length($origdata) : 0),
|
||||
-pos => ($readonly == 2 ? length($origdata) : 0),
|
||||
#-readonly => !!$readonly # does not support -pos
|
||||
);
|
||||
|
||||
my $return;
|
||||
|
||||
if ($readonly) {
|
||||
$editor->readonly(1); # must be before bindings
|
||||
$editor->set_binding(sub { $cui->mainloopExit }, "q") if $readonly;
|
||||
} else {
|
||||
my @keys = (
|
||||
[ Curses::KEY_HOME() => 'cursor-scrlinestart' ],
|
||||
[ Curses::KEY_END() => 'cursor-scrlineend' ],
|
||||
|
@ -153,9 +157,8 @@ sub _editor($title, $origdata, $readonly = 0) {
|
|||
} ],
|
||||
);
|
||||
|
||||
$editor->readonly(1) if $readonly; # must be before bindings
|
||||
$editor->set_binding(reverse @$_) for @keys;
|
||||
$editor->set_binding(sub { $cui->mainloopExit }, "q") if $readonly;
|
||||
}
|
||||
$editor->focus();
|
||||
|
||||
$cui->mainloop;
|
||||
|
@ -187,4 +190,9 @@ sub pager($title, $data) {
|
|||
_editor($title, $data, 1);
|
||||
}
|
||||
|
||||
sub logpager($title, $data) {
|
||||
_require();
|
||||
_editor($title, $data, 2);
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
|
@ -66,7 +66,7 @@ sub log_for($self, $cart, $input, @) {
|
|||
my @lines = _grep($user);
|
||||
|
||||
require RevBank::TextEditor;
|
||||
RevBank::TextEditor::pager("RevBank log for $user", join("", @lines, "(end)"));
|
||||
RevBank::TextEditor::logpager("RevBank log for $user", join("", @lines, "(end)"));
|
||||
return ACCEPT;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue