/* * WPrintfLine - printf text on a window line */ vi_rc WPrintfLine( window_id w, int line, char *str, ... ) { va_list al; char tmp[MAX_STR]; va_start( al, str ); MyVSprintf( tmp, str, al ); va_end( al ); tmp[EditVars.WindMaxWidth - 1] = 0; return( DisplayLineInWindow( w, line, tmp ) ); } /* WPrintfLine */
/* * StatusLine - display a line in the status window */ static void StatusLine( int line, char *str, int format ) { int len, width, blanks, i, j; type_style *style; len = strlen( str ); width = WindowAuxInfo( status_window_id, WIND_INFO_TEXT_COLS ); style = &statusw_info.text_style; switch( format ) { case FMT_RIGHT: blanks = 0; if( width > len ) { blanks = width - len; } break; case FMT_CENTRE: blanks = 0; if( width > len ) { blanks = (width - len) / 2; } break; default: DisplayLineInWindow( status_window_id, line, str ); return; } i = 1; while( i <= blanks ) { SetCharInWindowWithColor( status_window_id, line, i, ' ', style ); i++; } j = 0; while( j < len && i <= width ) { SetCharInWindowWithColor( status_window_id, line, i, str[j], style ); j += 1; i += 1; } while( i <= width ) { SetCharInWindowWithColor( status_window_id, line, i, ' ', style ); i++; } } /* StatusLine */
/* * Message2 - display message on line 2 */ void Message2( char *str, ... ) { va_list al; char tmp[MAX_STR]; if( !EditFlags.EchoOn || MessageWindow == NO_WINDOW ) { return; } va_start( al, str ); MyVSprintf( tmp,str, al ); va_end( al ); tmp[EditVars.WindMaxWidth - 1] = 0; if( !EditFlags.LineDisplay ) { DisplayLineInWindow( MessageWindow, 2, tmp ); } else { MyPrintf( "%s\n", tmp ); } } /* Message2 */
/* * Message2 - display message on line 2 */ void Message2( const char *str, ... ) { va_list al; char tmp[MAX_STR]; if( !EditFlags.EchoOn || BAD_ID( message_window_id ) ) { return; } va_start( al, str ); MyVSprintf( tmp,str, al ); va_end( al ); tmp[EditVars.WindMaxWidth - 1] = '\0'; if( !EditFlags.LineDisplay ) { DisplayLineInWindow( message_window_id, 2, tmp ); } else { MyPrintf( "%s\n", tmp ); } } /* Message2 */
/* * ResizeWindow - give a window a new size */ vi_rc ResizeWindow( window_id wn, int x1, int y1, int x2, int y2, int scrflag ) { wind *tmp, *w; int bt, k; // char *txt, *tptr; // char *ot; // int i, j; w = AccessWindow( wn ); if( !ValidDimension( x1, y1, x2, y2, w->has_border ) ) { ReleaseWindow( w ); return( ERR_WIND_INVALID ); } tmp = AllocWindow( x1, y1, x2, y2, w->has_border, w->border_color1, w->border_color2, w->text_color, w->background_color ); tmp->id = wn; tmp->has_gadgets = w->has_gadgets; // txt = MemAlloc( w->width + 1 ); // tptr = txt; RestoreOverlap( wn, scrflag ); Windows[wn] = tmp; tmp->accessed = TRUE; ResetOverlap( tmp ); MarkOverlap( wn ); /* * display the new text */ k = 1; bt = (int) w->has_border; ClearWindow( wn ); if( w->title != NULL ) { WindowTitle( wn, w->title ); } else { DrawBorder( wn ); } #if 0 for( j = bt; j < w->height - bt; j++ ) { ot = &(w->text[(j * w->width) * sizeof( char_info )]); for( i = bt; i < w->width - bt; i++ ) { *txt++ = ot[i * sizeof( char_info )]; } *txt = 0; DisplayLineInWindow( wn, k++, tptr ); txt = tptr; } #else DCResize( CurrentInfo ); DCDisplayAllLines(); DCUpdate(); #endif FreeWindow( w ); ReleaseWindow( tmp ); return( ERR_NO_ERR ); } /* ResizeWindow */
/* * 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 */
/* * fileGrep - search a single dir and build list of files */ static void fileGrep( char *dir, char **list, int *clist, window_id wn ) { char fn[FILENAME_MAX], data[FILENAME_MAX], ts[FILENAME_MAX]; char path[FILENAME_MAX]; char drive[_MAX_DRIVE], directory[_MAX_DIR], name[_MAX_FNAME]; char ext[_MAX_EXT]; int i; #if defined( __WIN__ ) && defined( __NT__ ) LVITEM lvi; #endif vi_rc rc; /* * get file path prefix */ _splitpath( dir, drive, directory, name, ext ); strcpy( path, drive ); strcat( path, directory ); // _makepath( path, drive, directory, NULL,NULL ); /* * run through each entry and search it; building a list of matches */ rc = GetSortDir( dir, FALSE ); if( rc != ERR_NO_ERR ) { return; } for( i = 0; i < DirFileCount; i++ ) { if( !(DirFiles[i]->attr & _A_SUBDIR ) ) { strcpy( fn, path ); strcat( fn, DirFiles[i]->name ); #ifdef __WIN__ EditFlags.BreakPressed = SetGrepDialogFile( fn ); #else DisplayLineInWindow( wn, 1, fn ); #endif if( EditFlags.BreakPressed ) { return; } if( isFgrep ) { rc = fSearch( fn, ts ); } else { rc = eSearch( fn, ts ); } if( rc == FGREP_FOUND_STRING ) { ExpandTabsInABuffer( ts, strlen( ts ), data, MAX_DISP ); strcpy( ts, data ); MySprintf( data, "%X \"%s\"", fn, ts ); #ifdef __WIN__ /* * for windows - the handle passed in is the list box * and the entire string is added to it but only the file * name is added to the list */ #ifdef __NT__ if( IsCommCtrlLoaded() ) { lvi.mask = LVIF_TEXT; lvi.iItem = SendMessage( wn, LVM_GETITEMCOUNT, 0, 0L ); lvi.iSubItem = 0; lvi.pszText = fn; SendMessage( wn, LVM_INSERTITEM, 0, (LPARAM)&lvi ); lvi.iSubItem = 1; lvi.pszText = ts; SendMessage( wn, LVM_SETITEM, 0, (LPARAM)&lvi ); } else { #endif SendMessage( wn, LB_ADDSTRING, 0, (LPARAM)data ); MySprintf( data, "%X", fn ); #ifdef __NT__ } #endif #endif AddString( &(list[*clist]), data ); (*clist)++; } else if( rc != ERR_NO_ERR ) { return; } } } } /* fileGrep */