@@ 85,9 85,12 @@ fn run(conf: *config, in: io::handle) (void | vt::error) = {
};
vt::disablecur(term)?;
+ const (rows, cols) = vt::getsize(term)?;
let state = state {
term = term,
conf = conf,
+ rows = rows,
+ cols = cols,
info = vt::newpen(void, void, vt::style::INVERT),
ellipsis = vt::newpen(vt::color::BLACK, vt::color::WHITE),
binary = vt::newpen(
@@ 98,7 101,7 @@ fn run(conf: *config, in: io::handle) (void | vt::error) = {
in = in,
...
};
- drawlines(&state)?;
+ drawlines(&state, state.rows - 1)?;
if (state.eof && state.conf.onescreen && state.lines[0] == 0) {
return;
};
@@ 130,6 133,16 @@ fn run(conf: *config, in: io::handle) (void | vt::error) = {
action_top(&state)?;
case 'G' =>
action_bottom(&state)?;
+ case 'd' =>
+ if (ev.mods == modflag::CTRL) {
+ clearstatus(&state)?;
+ drawlines(&state, (state.rows - 1) / 2)?;
+ };
+ case 'u' =>
+ if (ev.mods == modflag::CTRL) {
+ scrollup(&state, (state.rows - 1) / 2)?;
+ clearstatus(&state)?;
+ };
case =>
yield;
};
@@ 150,12 163,12 @@ fn run(conf: *config, in: io::handle) (void | vt::error) = {
};
};
-fn drawlines(state: *state) (void | vt::error) = {
- const (rows, cols) = vt::getsize(state.term)?;
- state.rows = rows;
- state.cols = cols;
-
- for (let i = 0u; i < rows - 1 && !state.eof; i += 1) {
+fn drawlines(state: *state, nlines: uint) (void | vt::error) = {
+ let max = state.rows - 1;
+ if (max > nlines) {
+ max = nlines;
+ };
+ for (let i = 0u; i < max && !state.eof; i += 1) {
drawline(state)?;
};
@@ 246,7 259,7 @@ fn scrollup(state: *state, lines: uint) (void | vt::error) = {
state.eof = false;
delete(state.lines[lineno..]);
vt::clear(state.term)?;
- drawlines(state)?;
+ drawlines(state, state.rows - 1)?;
};
fn action_down(state: *state) (void | vt::error) = {
@@ 261,7 274,7 @@ fn action_up(state: *state) (void | vt::error) = {
fn action_pgdown(state: *state) (void | vt::error) = {
clearstatus(state)?;
- drawlines(state)?;
+ drawlines(state, state.rows - 1)?;
};
fn action_pgup(state: *state) (void | vt::error) = {
@@ 273,7 286,7 @@ fn action_top(state: *state) (void | vt::error) = {
state.eof = false;
delete(state.lines[..]);
vt::clear(state.term)?;
- drawlines(state)?;
+ drawlines(state, state.rows - 1)?;
};
fn action_bottom(state: *state) (void | vt::error) = {