/* ** create_comment () */ STATUS create_comment () { STATUS ret_val ; FILE *tmpf = NULL ; if ((ret_val = bld_cmtName(msg)) != OK) { disp_line(msg, 0, 0); } else { if (SIfopen(cmtLoc, ERx("a"), SI_TXT, TERM_LINE, &tmpf) == OK) { SIclose(tmpf); } edit_file(cmtName); fix_cursor(); TDclear(curscr); TDtouchwin(mainW); TDrefresh(mainW); } return (ret_val); } /* end of create_comment */
VOID put_d_message(char *aMessage) { TDerase(diffstW); SEPprintw(diffstW, PROMPT_ROW, PROMPT_COL, aMessage); TDrefresh(diffstW); }
VOID get_d_answer(char *question,char *ansbuff) { TDerase(diffstW); SEPprintw(diffstW, PROMPT_ROW, PROMPT_COL, question); getstr(diffstW, ansbuff, FALSE); TDerase(diffstW); TDrefresh(diffstW); }
VOID put_message(WINDOW *wndow,char *aMessage) { if (!batchMode) { TDerase(wndow); SEPprintw(wndow, PROMPT_ROW, PROMPT_COL, aMessage); TDrefresh(wndow); } }
void TDjcrestart() { reg WINDOW *screen = curscr; i4 ox; i4 oy; TDrestore(TE_FORMS, TRUE); ox = screen->_curx; oy = screen->_cury; TDrefresh(screen); screen->_cury = oy; screen->_curx = ox; }
STATUS edit_file(char *fname) { STATUS ret_val = OK ; char locbuf [MAX_LOC] ; LOCATION loc ; WINDOW *comments = NULL ; if (fname != NULL && *fname != '\0') { comments = TDnewwin(24,80,0,0); TDrefresh(comments); STcopy(fname, locbuf); LOfroms(PATH & FILENAME, locbuf, &loc); TErestore(TE_NORMAL); UTedit(real_editor, &loc); TErestore(TE_FORMS); TDdelwin(comments); } return (ret_val); } /* edit_file */
VOID disp_d_line(char *lineptr,int row,int column) { if (row) { SEPprintw(diffW, row, column, lineptr); screenLine = row + 1; } else { if (screenLine >= FIRST_MAIN_ROW && screenLine <= LAST_MAIN_ROW) { SEPprintw(diffW, screenLine++, FIRST_MAIN_COL, lineptr); } else { TDscroll(diffW); SEPprintw(diffW, LAST_MAIN_ROW, FIRST_MAIN_COL, lineptr); } } TDrefresh(diffW); }
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); }
VOID get_string(WINDOW *wndow,char *question,char *ansbuff) { char *prompt = NULL ; char tempBuffer [TERM_LINE] ; char *cp = ansbuff ; char *cptr = NULL ; i4 clen ; register i4 i ; prompt = SEP_MEalloc(SEP_ME_TAG_NODEL, STlength(question)+5, TRUE, (STATUS *) NULL); STprintf(prompt, ERx("%s "), question); put_message(wndow, prompt); getstr(wndow, tempBuffer, FALSE); /* check if continuation character was entered */ cptr = SEP_CMlastchar(tempBuffer,0); if (CMcmpcase(cptr,cont_char) == 0) { *cptr = EOS; STcopy(tempBuffer,cp); clen = SEP_CMstlen(tempBuffer,0); for (i=0; i<clen; i++) CMnext(cp); TDerase(wndow); STprintf(tempBuffer, ERx("%s%s"), prompt, ansbuff); SEPprintw(wndow, PROMPT_ROW - 1, PROMPT_COL, tempBuffer); STprintf(prompt, ERx("%s%s"), question, cont_char); SEPprintw(wndow, PROMPT_ROW, PROMPT_COL, prompt); TDrefresh(wndow); getstr(wndow,tempBuffer,FALSE); /* check if continuation character was entered */ cptr = SEP_CMlastchar(tempBuffer,0); if (CMcmpcase(cptr,cont_char) == 0) { i4 temp; *cptr = EOS; STprintf(prompt, ERx("%s %s"), question, tempBuffer); SEPprintw(wndow, PROMPT_ROW, PROMPT_COL, prompt); STcopy(tempBuffer, cp); STprintf(prompt, ERx("%s%s"), question, cont_char); SEPprintw(wndow, PROMPT_ROW + 1, PROMPT_COL, prompt); /* ** ugly fix to prevent the screen from scrolling when ** typing to the last line of the screen. It will hopefully ** be changed in the future for a more elegant solution */ temp = LINES; LINES++; TDrefresh(wndow); getstr(wndow, tempBuffer, FALSE); disp_prompt((char *)NULLSTR, (char *)NULL, (char *)NULL); LINES = temp; } } MEfree(prompt); STcopy(tempBuffer, cp); TDerase(wndow); TDrefresh(wndow); }