static void displayLine( input_buffer *input ) { char display[MAX_STR]; char *buffer, *dest; int length; int cursor_pos; if( EditFlags.NoInputWindow ) { return; } assert( strlen( input->prompt ) < MAX_STR ); strcpy( display, input->prompt ); length = strlen( display ); dest = &display[length]; buffer = input->buffer + input->left_column; while( *buffer != '\0' && length < input->window.width ) { *dest++ = *buffer++; length += 1; } *dest = '\0'; cursor_pos = input->curr_pos - input->left_column + 1; cursor_pos += strlen( input->prompt ); #ifdef __WIN__ { RECT rect; char *ptr, *c; int len, x; window_id wid; wid = input->window.id; MyHideCaret( wid ); GetClientRect( wid, &rect ); // BlankRectIndirect( input->window.id, input->window.style.background, &rect ); c = input->cache; for( len = 0, ptr = input->buffer; *ptr; ptr++, len++ ) { if( *c != *ptr ) { break; } c++; } x = MyTextExtent( wid, &input->window.style, input->cache, len ); WriteString( wid, x, 0, &input->window.style, display + len ); rect.left = MyTextExtent( wid, &input->window.style, display, strlen( display ) ); BlankRectIndirect( wid, input->window.style.background, &rect ); MyShowCaret( wid ); SetCursorOnLine( input->window.id, cursor_pos, display, &input->window.style ); } #else DisplayLineInWindowWithColor( input->window.id, input->window.line, display, &input->window.style, 0 ); SetGenericWindowCursor( input->window.id, input->window.line, cursor_pos ); #endif } /* displayLine */
/* * displayGenericLines - display all lines in a window */ static vi_rc displayGenericLines( file *f, linenum pagetop, int leftcol, linenum hilite, type_style *style, hilst *hilist, char **vals, int valoff ) { int i, j, k, text_lines; linenum cl = pagetop; fcb *cfcb, *tfcb; line *cline; hilst *ptr; type_style *text, *hot_key; window_info *info; type_style base; char tmp[MAX_STR]; // bool disabled; vi_rc rc; /* * get pointer to first line on page, and window info */ rc = GimmeLinePtr( pagetop, f, &cfcb, &cline ); if( rc != ERR_NO_ERR ) { return( rc ); } base.foreground = WindowAuxInfo( cWin, WIND_INFO_TEXT_COLOR ); base.background = WindowAuxInfo( cWin, WIND_INFO_BACKGROUND_COLOR ); base.font = WindowAuxInfo( cWin, WIND_INFO_TEXT_FONT ); text_lines = WindowAuxInfo( cWin, WIND_INFO_TEXT_LINES ); /* * mark all fcb's as being not in display */ for( tfcb = f->fcbs.head; tfcb != NULL; tfcb = tfcb->next ) { tfcb->on_display = FALSE; } cfcb->on_display = TRUE; /* * run through each line in the window */ ptr = hilist; if( ptr != NULL ) { ptr += pagetop - 1; } for( j = 1; j <= text_lines; j++ ) { if( cline != NULL ) { if( isMenu ) { if( InvokeMenuHook( CurrentMenuNumber, cl ) == -1 ) { // disabled = TRUE; if( cl == hilite ) { info = &activegreyedmenu_info; } else { info = &greyedmenu_info; } } else { // disabled = FALSE; if( cl == hilite ) { info = &activemenu_info; } else { info = &menuw_info; } } text = &info->text; hot_key = &info->hilight; } else { text = &base; if( cl == hilite ) { text = style; } hot_key = text; } /* * now, display what we can of the line on the window */ if( cline->len == 0 ) { DisplayCrossLineInWindow( cWin, j ); goto evil_goto; } else if( cline->len > leftcol ) { if( vals != NULL ) { i = cline->len - leftcol; strncpy( tmp, &(cline->data[leftcol]), EditVars.WindMaxWidth + 5 ); for( k = i; k < valoff; k++ ) { tmp[k] = ' '; } tmp[k] = 0; strcat( tmp, vals[j + pagetop - 2] ); DisplayLineInWindowWithColor( cWin, j, tmp, text, 0 ); } else { DisplayLineInWindowWithColor( cWin, j, cline->data, text, leftcol ); } } else { DisplayLineInWindowWithColor( cWin, j, SingleBlank, text, 0 ); } if( ptr != NULL ) { SetCharInWindowWithColor( cWin, j, 1 + ptr->_offs, ptr->_char, hot_key ); } evil_goto: if( ptr != NULL ) { ptr += 1; } rc = GimmeNextLinePtr( f, &cfcb, &cline ); if( rc != ERR_NO_ERR ) { if( rc == ERR_NO_MORE_LINES ) { continue; } return( rc ); } cl++; cfcb->on_display = TRUE; } else { DisplayLineInWindow( cWin, j, "~" ); } } return( ERR_NO_ERR ); } /* displayGenericLines */