From e620c4fc30b6bfbe4173ba908c2166e8b5e574d2 Mon Sep 17 00:00:00 2001 From: Correl Roush Date: Thu, 28 Feb 2008 22:30:41 +0000 Subject: [PATCH] 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 --- ncurses/ncurses.php | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/ncurses/ncurses.php b/ncurses/ncurses.php index 2cc6e27..9c5ab3a 100644 --- a/ncurses/ncurses.php +++ b/ncurses/ncurses.php @@ -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 ) ) {