VOID TDendwin() { char outbuf[TDBUFSIZE]; if (!TDisopen) { return; } #if !defined(PMFEWIN3) && !defined(NT_GENERIC) TEput('\r'); TEput('\n'); #endif TDobptr = outbuf; TDoutbuf = outbuf; TDoutcount = TDBUFSIZE; _puts(VE); _puts(TE); _echoit = TRUE; _rawmode = FALSE; _pfast = FALSE; _puts(EA); /* clean display attributes up */ if (LD) { _puts(LE); } if (KY) { _puts(KE); /* get out of keypad mode */ } /* ** Terminal exit string to allow users to ** reset terminal to whatever state they want. */ _puts(ES); IITDrstsize(); TEwrite(TDoutbuf, (i4)(TDBUFSIZE - TDoutcount)); TEflush(); TEclose(); TDisopen = FALSE; if (curscr) { /* code for STANDOUT taken out since ** STANDOUT should never be set now, ** I hope. (dkh) */ _endwin = TRUE; } }
/* ** fix_cursor ** ** Description: ** routine to restore cursor to previous position after ** something have been hard written to the terminal */ STATUS fix_cursor() { STATUS ret_val = OK ; char *cgp = NULL ; #ifdef NT_GENERIC COORD coordinate; coordinate.X = lx; coordinate.Y = ly; SetConsoleCursorPosition(hTEconsole, coordinate); #else cgp = TDtgoto(CM, lx, ly); TEwrite(cgp,STlength(cgp)); TEflush(); #endif return (ret_val); }
STATUS disp_diff(STATUS acmmt,i4 canons) { STATUS ioerr ; STATUS up_canon = FAIL ; char cmmtfile [50] ; char canon_upd = '\0' ; char junk ; char menu_ans ; bool conditional_exp ; /* initialize diff window */ conditional_exp = FALSE; #ifndef NT_GENERIC TEwrite(CL,STlength(CL)); TEflush(); #endif diffW = TDnewwin(MAIN_ROWS,MAIN_COLS,FIRST_MAIN_ROW,FIRST_MAIN_COL); diffstW = TDnewwin(STATUS_ROWS,STATUS_COLS,FIRST_STAT_ROW,FIRST_MAIN_COL); TDrefresh(diffstW); TDrefresh(diffW); screenLine = 0; old_page = 0; bottom_page = 0; myPages = NULL; ioerr = OK; STprintf(cmmtfile,ERx("ct%s.stf"),SEPpidstr); diffPtr = sepDiffer->_fptr; /* ** display diff */ page_down(0); if (updateMode) up_canon = OK; for (;;) { if (updateMode) { if (editCAns == '\0') disp_prompt(DIFF_MENU_M,&menu_ans,DIFF_MENU_AM); else menu_ans = 'e'; } else disp_prompt(DIFF_MENU,&menu_ans,DIFF_MENU_A); switch (menu_ans) { case 'A': case 'a': ioerr = FAIL; break; case 'P': case 'p': page_up(); break; case 'N': case 'n': page_down(0); break; case 'C': case 'c': if (acmmt == FAIL && !updateMode) disp_prompt(ERx("no comments attached to this command"), &junk,NULL); else { edit_file(cmmtfile); TDtouchwin(diffW); TDrefresh(diffW); } break; case 'E': case 'e': if (up_canon == OK) { if (editCAns == '\0') { disp_prompt(UPD_CANON,&canon_upd,UPD_CANON_A); } else { canon_upd = editCAns; menu_ans = 'q'; } if (canon_upd == 'M' || canon_upd == 'A' || canon_upd == 'm' || canon_upd == 'a' ) conditional_exp = ask_for_conditional(diffstW, editCAns); up_canon = FAIL; } break; } if (menu_ans == 'Q' || menu_ans == 'q' || menu_ans == 'A' || menu_ans == 'a' || menu_ans == 'D' || menu_ans == 'd') { disp_prompt(NULLSTR,NULL,NULL); SEPdisconnect = (menu_ans == 'A' || menu_ans == 'a' || menu_ans == 'D' || menu_ans == 'd'); break; } } /* ** update test */ if (updateMode) { LOCATION cmmtloc; short count; /* add comments */ LOfroms(FILENAME & PATH,cmmtfile,&cmmtloc); if (SEP_LOexists(&cmmtloc)) { append_line(OPEN_COMMENT,1); append_file(cmmtfile); append_line(CLOSE_COMMENT,1); LOdelete(&cmmtloc); } /* add canons */ switch (canon_upd) { case 'I': case 'i': append_line(OPEN_CANON,1); append_line(SKIP_SYMBOL,1); append_line(CLOSE_CANON,1); break; case 'M': case 'm': SEPrewind(sepResults, FALSE); if (conditional_exp == TRUE) { append_line(OPEN_CANON,0); append_line(conditional_prompt,1); } else append_line(OPEN_CANON,1); append_sepfile(sepResults); append_line(CLOSE_CANON,1); append_sepfile(sepGCanons); break; case 'O': case 'o': SEPrewind(sepResults, FALSE); append_line(OPEN_CANON,1); append_sepfile(sepResults); append_line(CLOSE_CANON,1); break; case '\0': case 'E': case 'e': append_sepfile(sepGCanons); break; case 'A': case 'a': append_sepfile(sepGCanons); SEPrewind(sepResults, FALSE); if (conditional_exp == TRUE) { append_line(OPEN_CANON,0); append_line(conditional_prompt,1); } else append_line(OPEN_CANON,1); append_sepfile(sepResults); append_line(CLOSE_CANON,1); break; } } MEtfree(SEP_ME_TAG_PAGES); TDdelwin(diffW); TDdelwin(diffstW); return(ioerr); }
STATUS disp_prompt(char *buffer,char *achar,char *range) { STATUS ret_val = OK ; char caracter ; char *legal = NULL ; char termBuffer [255] ; #ifdef NT_GENERIC COORD coordinate; int numchars, i; char tempchar [80]; #endif if (achar == NULL) { #ifndef NT_GENERIC STprintf(termBuffer,ERx("%s%s%s%s%s"),REG_CHAR,ATTR_OFF, PROMPT_POS,DEL_EOL,buffer); TEwrite(termBuffer,STlength(termBuffer)); TEflush(); #else SetConsoleActiveScreenBuffer(hTEconsole); coordinate.X=0; coordinate.Y=22; SetConsoleCursorPosition(hTEconsole, coordinate); WriteConsole(hTEconsole, buffer, strlen(buffer), &numchars, NULL); coordinate.X=strlen(buffer); coordinate.Y=22; SetConsoleCursorPosition(hTEconsole, coordinate); strcpy (tempchar, " "); for (i=2; i<=(80-strlen(buffer)); i++) strcat (tempchar, " "); WriteConsole(hTEconsole, tempchar, strlen(tempchar), &numchars, NULL); #endif } else { #ifndef NT_GENERIC STprintf(termBuffer,ERx("%s%s%s%s%s[ %s ]%s "),REG_CHAR,ATTR_OFF, PROMPT_POS,DEL_EOL,REV_VIDEO,buffer,ATTR_OFF); TEwrite(termBuffer,STlength(termBuffer)); TEflush(); #else SetConsoleActiveScreenBuffer(hTEconsole); coordinate.X=0; coordinate.Y=22; SetConsoleCursorPosition(hTEconsole, coordinate); SetConsoleTextAttribute(hTEconsole, FOREGROUND_BLUE|BACKGROUND_RED|BACKGROUND_GREEN|BACKGROUND_BLUE|BACKGROUND_INTENSITY); STpolycat(3, ERx("[ "), buffer, ERx(" ]"), &termBuffer); WriteConsole(hTEconsole, termBuffer, strlen(termBuffer), &numchars, NULL); coordinate.X=strlen(termBuffer); coordinate.Y=22; SetConsoleCursorPosition(hTEconsole, coordinate); strcpy (tempchar, " "); for (i=2; i<=(80-strlen(termBuffer)); i++) strcat (tempchar, " "); SetConsoleTextAttribute(hTEconsole, FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE|FOREGROUND_INTENSITY|BACKGROUND_BLUE); WriteConsole(hTEconsole, tempchar, strlen(tempchar), &numchars, NULL); #endif TEinflush(); for (;;) { EXinterrupt(EX_OFF); #ifdef VMS sys$setast(0); #endif caracter = TEget(0); EXinterrupt(EX_ON); #ifdef VMS sys$setast(1); #endif if (range == NULL || (legal = STindex(range,&caracter,0)) != NULL) break; else { TEput(BELL); TEflush(); } } *achar = caracter; } return (ret_val); }