mirror of
https://gitlab.com/sortix/sortix.git
synced 2023-02-13 20:55:38 -05:00
Fix pager(1) bugs.
This commit is contained in:
parent
77129524eb
commit
d472818380
1 changed files with 21 additions and 18 deletions
|
@ -272,6 +272,7 @@ static void pager_push_wchar(struct pager* pager, wchar_t wc)
|
||||||
|
|
||||||
if ( pager->incoming_control_state == CONTROL_STATE_CSI )
|
if ( pager->incoming_control_state == CONTROL_STATE_CSI )
|
||||||
{
|
{
|
||||||
|
pager->incoming_control_state = CONTROL_STATE_NONE;
|
||||||
if ( wc == '[' )
|
if ( wc == '[' )
|
||||||
pager->incoming_control_state = CONTROL_STATE_COMMAND;
|
pager->incoming_control_state = CONTROL_STATE_COMMAND;
|
||||||
}
|
}
|
||||||
|
@ -318,7 +319,6 @@ static void pager_push_wchar(struct pager* pager, wchar_t wc)
|
||||||
size_t left = pager->out_fd_winsize.ws_col - pager->incoming_line_width;
|
size_t left = pager->out_fd_winsize.ws_col - pager->incoming_line_width;
|
||||||
if ( left < (size_t) width )
|
if ( left < (size_t) width )
|
||||||
line = pager_next_line(pager);
|
line = pager_next_line(pager);
|
||||||
else
|
|
||||||
pager->incoming_line_width += width;
|
pager->incoming_line_width += width;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -402,7 +402,7 @@ static void pager_control_sequence_finish(struct pager* pager, wchar_t wc)
|
||||||
pager_control_sequence_push(pager, wc);
|
pager_control_sequence_push(pager, wc);
|
||||||
if ( pager->control_state == CONTROL_STATE_NONE )
|
if ( pager->control_state == CONTROL_STATE_NONE )
|
||||||
return;
|
return;
|
||||||
if ( wc == 'm' )
|
if ( wc == L'm' )
|
||||||
{
|
{
|
||||||
pager->input_set_color = true;
|
pager->input_set_color = true;
|
||||||
return pager_control_sequence_accept(pager);
|
return pager_control_sequence_accept(pager);
|
||||||
|
@ -502,12 +502,12 @@ static void pager_simple_fd(struct pager* pager, int fd, const char* fdpath)
|
||||||
|
|
||||||
static bool pager_can_page(struct pager* pager)
|
static bool pager_can_page(struct pager* pager)
|
||||||
{
|
{
|
||||||
if ( pager->lines_used <= pager->current_line )
|
if ( pager->current_line + 1 == pager->lines_used )
|
||||||
return false;
|
{
|
||||||
struct line* line = &pager->lines[pager->current_line];
|
struct line* line = &pager->lines[pager->current_line];
|
||||||
if ( line->content_used <= pager->current_line_offset )
|
return pager->current_line_offset < line->content_used;
|
||||||
return false;
|
}
|
||||||
return true;
|
return pager->current_line + 1 < pager->lines_used;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void pager_page(struct pager* pager)
|
static void pager_page(struct pager* pager)
|
||||||
|
@ -555,17 +555,20 @@ static void pager_push_fd(struct pager* pager, int fd, const char* fdpath)
|
||||||
bool eof = false;
|
bool eof = false;
|
||||||
while ( !pager->quiting )
|
while ( !pager->quiting )
|
||||||
{
|
{
|
||||||
if ( !pager->skipping_to_end && pager->allowed_lines == 0 )
|
if ( !pager->skipping_to_end )
|
||||||
|
{
|
||||||
|
if ( pager->allowed_lines == 0 )
|
||||||
{
|
{
|
||||||
pager->allowance_ever_exhausted = true;
|
pager->allowance_ever_exhausted = true;
|
||||||
pager_prompt(pager, false);
|
pager_prompt(pager, false);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if ( !pager->skipping_to_end && pager_can_page(pager) )
|
if ( pager_can_page(pager) )
|
||||||
{
|
{
|
||||||
pager_page(pager);
|
pager_page(pager);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if ( eof )
|
if ( eof )
|
||||||
break;
|
break;
|
||||||
if ( !pager_read_fd(pager, fd, fdpath) )
|
if ( !pager_read_fd(pager, fd, fdpath) )
|
||||||
|
|
Loading…
Reference in a new issue