void MYMENU_ViewSplitView() { static int splitview = 0; if ( splitview == 0 ) { // get the cell where to split int start_row = 0; int start_col = 0; int end_row, end_col; get_selection( &start_row, &start_col, &end_row, &end_col ); // get x/y pos int xx = current_view()->edge[ VIEW_LEFT ] + col_zero_width; int yy = current_view()->edge[ VIEW_TOP ] + row_zero_height; int p; for ( p = current_view()->col_head; p < start_col; ++p ) xx += col_width_of( p ) * ratio; for ( p = current_view()->row_head; p < start_row; ++p ) yy += row_height_of( p ) * ratio; // NOTE: always shift a bit to let the user select the last row/col if ( xx != current_view()->edge[ VIEW_LEFT ] + col_zero_width ) { split_view( xx + 1, -1 ); splitview = 1; } if ( yy != current_view()->edge[ VIEW_TOP ] + row_zero_height ) { split_view( -1, yy + 1 ); splitview = 1; } } else { restore_view(); splitview = 0; } update_selection_rect(); update_table_view(); }
/* long-running function to get input */ char *get_input(char *prefix) { view_t *view=current_view(); /* write the prefix */ mvaddstr(view->height,0,prefix); doupdate(); refresh(); /* read input */ char *buffer=(char *)malloc(MAX_INPUT_SIZE); int c=getch(),i=0; while(c!='\n' && c!='\r') { if(c==CTRL('D')) return 0; /* no input */ /* add the character to the screen */ addch(c); doupdate(); /* and flush */ refresh(); /* add to our internal buffer */ buffer[i++]=c; if(i==MAX_INPUT_SIZE) return 0; /* FIXME throw actual error */ c=getch(); } return buffer; }