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 ) ) {