Prettied up the ncurses table view, optimized its screen updates. Mantis: 2691
git-svn-id: file:///srv/svn/scanner/trunk@15 a0501263-5b7a-4423-a8ba-1edf086583e7
This commit is contained in:
parent
9c988e61ba
commit
e620c4fc30
1 changed files with 23 additions and 2 deletions
|
@ -299,9 +299,10 @@ class NcTableView extends NcWindow {
|
|||
}
|
||||
$this->attribute_on( NCURSES_A_UNDERLINE );
|
||||
$this->attribute_on( NCURSES_A_BOLD );
|
||||
$this->write_fixed( 0, 0, implode( ' | ', $cols ) );
|
||||
$this->write_fixed( 0, 0, implode( ' ', $cols ), 0, false );
|
||||
$this->attribute_off( NCURSES_A_UNDERLINE );
|
||||
$this->attribute_off( NCURSES_A_BOLD );
|
||||
|
||||
$max_items = ( $this->height - 2 );
|
||||
$offset = ( $selected > $max_items ) ? $selected - $max_items : 0;
|
||||
foreach( $rows as $id => $row ) {
|
||||
|
@ -317,9 +318,29 @@ class NcTableView extends NcWindow {
|
|||
if( $selected == $id ) {
|
||||
$this->attribute_on( NCURSES_A_REVERSE );
|
||||
}
|
||||
$this->write_fixed( $id - $offset + 1, 0, implode( ' | ', $row ) );
|
||||
$this->write_fixed( $id - $offset + 1, 0, implode( ' | ', $row ), 0, false );
|
||||
$this->attribute_off( NCURSES_A_REVERSE );
|
||||
}
|
||||
$x = 0;
|
||||
foreach( array_values( $column_widths ) as $id => $width ) {
|
||||
$x += $width + ( $id == 0 ? 1 : 3 );
|
||||
// Every Column
|
||||
ncurses_wmove( $this->window, 1, $x );
|
||||
ncurses_wvline( $this->window, NCURSES_ACS_VLINE, $this->height - 1 );
|
||||
// Header Row
|
||||
ncurses_wmove( $this->window, 0, $x );
|
||||
$this->attribute_on( NCURSES_A_UNDERLINE );
|
||||
ncurses_wvline( $this->window, NCURSES_ACS_VLINE, 1 );
|
||||
$this->attribute_off( NCURSES_A_UNDERLINE );
|
||||
// Highlighted Row
|
||||
ncurses_wmove( $this->window, $selected - $offset + 1, $x );
|
||||
$this->attribute_on( NCURSES_A_REVERSE );
|
||||
ncurses_wvline( $this->window, NCURSES_ACS_VLINE, 1 );
|
||||
$this->attribute_off( NCURSES_A_REVERSE );
|
||||
}
|
||||
// Finally, update
|
||||
ncurses_wrefresh( $this->window );
|
||||
ncurses_doupdate();
|
||||
}
|
||||
function load( $records ) {
|
||||
if( !is_array( $records ) ) {
|
||||
|
|
Loading…
Reference in a new issue