void vm_horizline(char x1, char x2, char row, char attr, char ch) { char cell[2]; cell[0] = ch; cell[1] = attr; VioWrtNCell((PBYTE) &cell, (USHORT) (x2 - x1 + 1), (USHORT) (row - 1), (USHORT) (x1 - 1), 0); }
void erase_display() { curcell[1] = defscr.pv_colours[VSCcolour]; curcell[0] = ' '; VioWrtNCell((PBYTE) curcell, Rows * Columns, 0, 0, 0); }
/*--------------------------------------------------------------------------* * clear_eol * * * *--------------------------------------------------------------------------*/ void clear_eol(int row, int col, struct window_parms *wp) { int rc, acol, arow; acol = wp->left_col + col; arow = wp->top_row + row; if (rc = VioWrtNCell(wp->clearcell, wp->display_cols - col, arow, acol, (HVIO)0)) printf("Failed clearing EOL (%d, %d) rc = %d\n", arow, acol, rc); }
VOID ClearScreen(THREAD *pstThd) { VIOCELL Cell; VIOPS *pVio = &pstThd->stVio; BYTE byBackground; BYTE byForeground; byBackground = ClrTable[pVio->wBackground].PSClr; byForeground = ClrTable[pVio->wForeground].PSClr; /* ** Set foreground and background colors in ANSI, so that the ** VioWrtTTY function will pick up the correct colors. */ chAnsi[ANSI_FORE] = QueryAnsiClr(byForeground); chAnsi[ANSI_BACK] = QueryAnsiClr(byBackground); VioSetAnsi (ANSI_ON,pVio->hpsVio); VioWrtTTY( (PCH)chAnsi,sizeof(chAnsi),pVio->hpsVio); if (!pstThd->stCfg.bEnableAnsi) VioSetAnsi (ANSI_OFF,pVio->hpsVio); /* ** Set Presentation Space to a known state - full of spaces. */ Cell.vc = ' '; Cell.ExtAttr = Cell.Spare = 0; Cell.Attr = (byBackground << 4) | byForeground; VioWrtNCell((PBYTE)&Cell,pVio->usPsWidth * pVio->usPsDepth,0,0,pVio->hpsVio); VioSetOrg(0,0,pVio->hpsVio); VioSetCurPos(0,0,pVio->hpsVio); /* ** Zero the scroll bars. */ WinSendMsg(WinWindowFromID(pstThd->hwndFrame,FID_VERTSCROLL), SBM_SETPOS, MPFROMSHORT(0), MPFROMSHORT(0)); WinSendMsg(WinWindowFromID(pstThd->hwndFrame,FID_HORZSCROLL), SBM_SETPOS, MPFROMSHORT(0), MPFROMSHORT(0)); WinSendMsg(WinWindowFromID(pstThd->hwndFrame,FID_VERTSCROLL), SBM_SETTHUMBSIZE, MPFROM2SHORT(pVio->usWndWidth,pVio->usPsWidth), (MPARAM)NULL); WinSendMsg(WinWindowFromID(pstThd->hwndFrame,FID_HORZSCROLL), SBM_SETTHUMBSIZE, MPFROM2SHORT(pVio->usWndDepth,pVio->usPsDepth), (MPARAM)NULL); }
void vm_paintclearbox(char x1, char y1, char x2, char y2, char attr) { char y, cell[2]; cell[0] = ' '; cell[1] = attr; for (y = y1; y <= y2; y++) { VioWrtNCell((PBYTE) &cell, (USHORT) (x2 - x1 + 1), (USHORT) (y - 1), (USHORT) (x1 - 1), 0); } }
void outchar(int c) { curcell [0] = c; VioWrtNCell((PBYTE) curcell, 1, virt_row, virt_col, 0); if (++virt_col >= Columns) { virt_col -= Columns; if (++virt_row >= Rows) virt_row = Rows - 1; } }
static void vio_CE (VCOLOR color) { CHAR cell[2]; if (c_col < o_ttycolumns) { cell[0] = ' '; cell[1] = color; VioWrtNCell (cell, o_ttycolumns - c_col, c_row, c_col, 0); } }
void UIAPI uioncursor( void ) /****************************/ { CHAR CharCellPair[2]; VIOCURSORINFO vioCursor; VioGetCurType( &vioCursor, 0 ); if( UIData->cursor_type == C_INSERT ) { vioCursor.yStart = vioCursor.cEnd / 2; } else { vioCursor.yStart = (vioCursor.cEnd * 7) / 8; } vioCursor.cx = 1; vioCursor.attr = 1; VioSetCurType(&vioCursor, 0); /* set cursor position */ VioSetCurPos( UIData->cursor_row, UIData->cursor_col, 0); if( UIData->cursor_attr != -2 ) { /* get current character and attribute */ VioGetCurPos( &r, &c, 0 ); length = sizeof(CharCellPair); VioReadCellStr(&CharCellPair[0], &length, UIData->cursor_row, UIData->cursor_col, 0); /* write out the character and the new attribute */ CharCellPair[1] = UIData->cursor_attr; VioWrtNCell((PBYTE)&CharCellPair[0], 24, UIData->cursor_row, UIData->cursor_col, 0); } UIData->cursor_on = true; }
void vm_horizline(char x1, char x2, char row, char attr, char ch) { if (_osmode == DOS_MODE) { char x; for (x = x1; x <= x2; x++) { vm_xputch(x, row, attr, ch); } } else { char cell[2]; cell[0] = ch; cell[1] = attr; VioWrtNCell((PBYTE) &cell, (USHORT) (x2 - x1 + 1), (USHORT) (row - 1), (USHORT) (x1 - 1), 0); } }
void vm_paintclearbox(char x1, char y1, char x2, char y2, char attr) { if (_osmode == DOS_MODE) { char x, y; for (y = y1; y <= y2; y++) { for (x = x1; x <= x2; x++) { vm_xputch(x, y, attr, ' '); } } } else { char y, cell[2]; cell[0] = ' '; cell[1] = attr; for (y = y1; y <= y2; y++) { VioWrtNCell((PBYTE) &cell, (USHORT) (x2 - x1 + 1), (USHORT) (y - 1), (USHORT) (x1 - 1), 0); } } }
int ConSetBox(int X, int Y, int W, int H, TCell Cell) { int I; int MX, MY; int MouseHidden = 0; unsigned char *p = (unsigned char *)&Cell; if (MouseVisible) ConQueryMousePos(&MX, &MY); for (I = 0; I < H; I++) { if (MouseVisible) if (Y + I == MY) if ((MX >= X) && (MX < X + W)) { DrawMouse(0); MouseHidden = 1; } VioWrtNCell((PCH)p, (USHORT)(W), (USHORT)(Y + I), (USHORT)X, 0); if (MouseHidden) { DrawMouse(1); MouseHidden = 0; } } return 0; }
USHORT __pascal VIOWRTNCELL(const PBYTE Cell, const USHORT Count, const USHORT Row, const USHORT Column, const HVIO Handle) { return VioWrtNCell(Cell, Count, Row, Column, Handle); }
int EnterLine (char *buf,ULONG len,USHORT y,char *filename, char **choices,int numc,int start) { ULONG pos = 0,c,nm,numchars = 0,tpos,wl; APIRET rc; int key,attr = ((7 << 4) << 8) | ' ',ret = 0; BOOL okay = TRUE,insert = TRUE,lasttab = FALSE; char *sav,*k = NULL,*p; static char keybuf[1026]; USHORT t; FILEFINDBUF3 fb3; HDIR hdir = HDIR_CREATE; wl = 0; sav = malloc(vio.col * 2); if(!sav) { DosBeep(50,100); *buf = 0; return -1; } ThreadMsg(" "); t = vio.col * 2; VioReadCellStr(sav,&t,y,0,0); VioWrtNCell((char *)&attr,vio.col,y,0,0); ShowCursor(FALSE); VioSetCurPos(y,0,0); for(c = 0;c < len - 1;c++) { /* find end of default string */ if(!buf[c]) break; } pos = c; for(;c < len - 1;c++) /* space-pad remainder of buf */ buf[c] = ' '; while(okay) { /* assure buffer is null terminated (cluck, cluck) */ buf[len - 1] = 0; /* assure pos hasn't gone past our limit */ if(pos > len - 1) pos = len - 1; /* set left side of entry field */ if(pos < wl) wl = pos; if(pos >= wl + vio.col) wl = (pos - vio.col) + 1; /* set cursor position */ VioSetCurPos(y,pos - wl,0); /* display buf */ tpos = min(vio.col,len - wl); /* max length of displayable text */ VioWrtCharStr(buf + wl,tpos,y,0,0); /* show text */ if(tpos < vio.col) /* space-pad? */ VioWrtNChar(" ",vio.col - tpos,y,tpos,0); if(k && *k) /* "macros" waiting to be entered? */ key = *k++; /* yep, skip keyboard input */ else { /* nope, go to the keyboard */ k = NULL; /* clear macro pointer */ key = get_ch(-1); } switch(key) { case 256: /* shiftstate changed -- ignore */ break; case '\r': /* accept input */ okay = FALSE; break; case 45 | 256: case 61 | 256: case '\x1b': /* Escape -- exit editor */ memset(buf,' ',len - 1); buf[len - 1] = 0; okay = FALSE; ret = -1; break; case '\b': if(pos) { pos--; memmove(buf + pos,buf + (pos + 1),len - (pos + 1)); buf[len - 2] = ' '; } lasttab = FALSE; break; case 25: /* ctrl+y -- clear input */ VioWrtNCell((char *)&attr,vio.col,y,0,0); memset(buf,' ',len - 1); buf[len - 1] = 0; wl = pos = 0; lasttab = FALSE; break; case 59 | 256: /* F1 -- insert directory */ k = directory; lasttab = FALSE; break; case 60 | 256: /* F2 -- insert filename */ if(filename) k = filename; lasttab = FALSE; break; case 62 | 256: /* F4 -- insert target */ k = target; lasttab = FALSE; break; case 15: /* shift+tab */ if(hdir != (HDIR)HDIR_CREATE) { DosFindClose(hdir); hdir = HDIR_CREATE; lasttab = FALSE; } /* intentional fallthru */ case 9: /* tab -- auto-complete */ if(!pos || pos >= len - 1) break; if(lasttab && numchars) { lasttab = FALSE; for(tpos = 0;tpos < numchars;tpos++) keybuf[tpos] = '\b'; keybuf[tpos++] = '\01'; keybuf[tpos] = 0; numchars = 0; k = keybuf; break; } else { if(hdir != (HDIR)HDIR_CREATE) DosFindClose(hdir); hdir = HDIR_CREATE; } /* intentional fallthru */ case 1: /* cheat! */ k = NULL; if(!pos || pos >= len - 1) break; tpos = pos - 1; while(tpos && buf[tpos] != ' ') tpos--; if(buf[tpos] == ' ') tpos++; strcpy(keybuf,buf + tpos); tpos = 0; while(keybuf[tpos] && keybuf[tpos] != ' ') tpos++; keybuf[tpos] = 0; lstrip(rstrip(keybuf)); if(*keybuf) { strcat(keybuf,"*"); nm = 1; if(hdir == (HDIR)HDIR_CREATE) rc = DosFindFirst(keybuf, &hdir, FILE_NORMAL | FILE_HIDDEN | FILE_SYSTEM | FILE_DIRECTORY | FILE_ARCHIVED | FILE_READONLY, &fb3, sizeof(fb3), &nm, FIL_STANDARD); else rc = DosFindNext(hdir,&fb3,sizeof(fb3),&nm); if(!rc) { while((fb3.attrFile & FILE_DIRECTORY) && (*fb3.achName == '.' && (!fb3.achName[1] || (fb3.achName[1] == '.' && !fb3.achName[2])))) { nm = 1; if(DosFindNext(hdir,&fb3,sizeof(fb3),&nm)) { DosFindClose(hdir); hdir = HDIR_CREATE; *fb3.achName = 0; break; } } if(*fb3.achName) { keybuf[strlen(keybuf) - 1] = 0; p = strchr(keybuf,'\\'); if(p) p++; else p = keybuf; tpos = 0; while(*p && fb3.achName[tpos] && toupper(*p) == toupper(fb3.achName[tpos])) { p++; tpos++; } if(fb3.achName[tpos]) { strcpy(keybuf,fb3.achName + tpos); numchars = strlen(keybuf); lasttab = TRUE; k = keybuf; } else if(hdir != (HDIR)HDIR_CREATE) { DosFindClose(hdir); hdir = HDIR_CREATE; } } } else if(hdir != (HDIR)HDIR_CREATE) { DosBeep(50,50); DosFindClose(hdir); hdir = HDIR_CREATE; } } break; case 83 | 256: /* delete */ memmove(buf + pos,buf + (pos + 1),len - (pos + 1)); buf[len - 2] = ' '; lasttab = FALSE; break; case 82 | 256: /* insert */ insert = (insert) ? FALSE : TRUE; break; case 71 | 256: /* home */ wl = pos = 0; lasttab = FALSE; break; case 79 | 256: /* end */ pos = len - 2; while(pos && buf[pos] == ' ') pos--; if(pos && buf[pos] != ' ') pos++; lasttab = FALSE; break; case 75 | 256: /* left */ if(pos) pos--; lasttab = FALSE; break; case 77 | 256: /* right */ if(pos < len - 1) pos++; lasttab = FALSE; break; case 72 | 256: /* up */ lasttab = FALSE; if(choices) { if(choices[start]) { VioWrtNCell((char *)&attr,vio.col,y,0,0); memset(buf,' ',len - 1); buf[len - 1] = 0; wl = pos = 0; k = choices[start]; start++; while(start < numc && !choices[start]) start++; if(start > (numc - 1)) start = 0; if(!choices[start]) { while(start < numc && !choices[start]) start++; } if(start > (numc - 1)) start = 0; } } break; case 80 | 256: /* down */ lasttab = FALSE; if(choices) { if(choices[start]) { VioWrtNCell((char *)&attr,vio.col,y,0,0); memset(buf,' ',len - 1); buf[len - 1] = 0; wl = pos = 0; k = choices[start]; start--; while(start >= 0 && !choices[start]) start--; if(start < 0) start = numc - 1; if(!choices[start]) { while(start >= 0 && !choices[start]) start--; } if(start < 0) start = numc - 1; } } break; case 115 | 256: /* ctrl+left */ while(pos && buf[pos] == ' ') pos--; while(pos && buf[pos] != ' ') pos--; lasttab = FALSE; break; case 116 | 256: /* ctrl + right */ while(pos < len - 1 && buf[pos] == ' ') pos++; while(pos < len - 1 && buf[pos] != ' ') pos++; lasttab = FALSE; break; default: if(pos < len - 1 && !(key & 256) && !iscntrl(key)) { if(insert) { if(pos < len - 2) { memmove(buf + (pos + 1),buf + pos,len - (pos + 2)); buf[len - 2] = ' '; } buf[pos] = (char)key; } else buf[pos] = (char)key; pos++; } else if(pos >= len - 1) DosBeep(250,25); break; } } if(hdir != (HDIR)HDIR_CREATE) DosFindClose(hdir); ShowCursor(TRUE); VioWrtCellStr(sav,vio.col * 2,y,0,0); free(sav); SetupConsole(); ThreadMsg(NULL); buf[len - 1] = 0; lstrip(rstrip(buf)); return (ret) ? ret : strlen(buf); }
void erase_line() { curcell [0] = ' '; VioWrtNCell((PBYTE) curcell, Columns - virt_col, virt_row, virt_col, 0); }
int SimpleInput (char *title,char *text,ULONG beep,ULONG dur,ULONG wait, int *responses) { char *buf; int xlen,key = 0,x; USHORT len = (vio.col * 7) * 2,start,mlen,cell; char sattr = 8; BOOL okay = TRUE; if(!title) title = ""; if(!text) return key; xlen = min(max(strlen(title),strlen(text)),vio.col - 6); mlen = xlen + 6; start = (vio.col - xlen) / 2; buf = malloc(len); if(buf) { /* save screen under */ VioReadCellStr(buf,&len,(vio.row / 2) - 2,0,0); /* draw borders */ /* first, bright white left and top */ cell = ((((7 | 8) << 4) | 7) << 8) | ' '; VioWrtNCell((char *)&cell,mlen,(vio.row / 2) - 2,start,0); VioWrtNCell((char *)&cell,1,(vio.row / 2) - 1,start,0); VioWrtNCell((char *)&cell,1,(vio.row / 2),start,0); VioWrtNCell((char *)&cell,1,(vio.row / 2) + 1,start,0); VioWrtNCell((char *)&cell,1,(vio.row / 2) + 2,start,0); VioWrtNCell((char *)&cell,1,(vio.row / 2) + 3,start,0); /* now dark grey right and bottom */ cell = (((8 << 4) | 7) << 8) | ' '; VioWrtNCell((char *)&cell,1,(vio.row / 2) - 1,start + (mlen - 1),0); VioWrtNCell((char *)&cell,1,(vio.row / 2),start + (mlen - 1),0); VioWrtNCell((char *)&cell,1,(vio.row / 2) + 1,start + (mlen - 1),0); VioWrtNCell((char *)&cell,1,(vio.row / 2) + 2,start + (mlen - 1),0); VioWrtNCell((char *)&cell,mlen - 1,(vio.row / 2) + 3,start + 1,0); /* fill title area with light grey foreground, red background */ cell = (((7 << 4) | 4) << 8) | ' '; VioWrtNCell((char *)&cell,mlen - 2,(vio.row / 2) - 1,start + 1,0); /* fill text area with light grey foreground, black background */ cell = (((7 << 4) | 0) << 8) | ' '; VioWrtNCell((char *)&cell,mlen - 4,(vio.row / 2) + 1,start + 2,0); /* make interior border -- first white on light grey */ cell = (((7 << 4) | (7 | 8)) << 8) | 'Ú'; VioWrtNCell((char *)&cell,1,(vio.row / 2),start + 1,0); cell = (((7 << 4) | (7 | 8)) << 8) | '¿'; VioWrtNCell((char *)&cell,1,(vio.row / 2),start + (mlen - 2),0); cell = (((7 << 4) | (7 | 8)) << 8) | 'Ä'; VioWrtNCell((char *)&cell,mlen - 4,(vio.row / 2),start + 2,0); cell = (((7 << 4) | (7 | 8)) << 8) | '³'; VioWrtNCell((char *)&cell,1,(vio.row / 2) + 1,start + 1,0); cell = (((7 << 4) | (7 | 8)) << 8) | 'À'; VioWrtNCell((char *)&cell,1,(vio.row / 2) + 2,start + 1,0); /* now dark grey on light grey */ cell = (((7 << 4) | 8) << 8) | 'Ä'; VioWrtNCell((char *)&cell,mlen - 4,(vio.row / 2) + 2,start + 2,0); cell = (((7 << 4) | 8) << 8) | 'Ù'; VioWrtNCell((char *)&cell,1,(vio.row / 2) + 2,start + (mlen - 2),0); cell = (((7 << 4) | 8) << 8) | '³'; VioWrtNCell((char *)&cell,1,(vio.row / 2) + 1,start + (mlen - 2),0); /* insert title */ VioWrtCharStr(title, min(xlen,strlen(title)), (vio.row / 2) - 1, (start + (mlen / 2)) - (min(xlen,strlen(title)) / 2), 0); /* insert text */ VioWrtCharStr(text, min(xlen,strlen(text)), (vio.row / 2) + 1, (start + (mlen / 2)) - (min(xlen,strlen(text)) / 2), 0); /* draw shadow */ VioWrtNAttr(&sattr,1,(vio.row / 2) - 1,start + mlen,0); VioWrtNAttr(&sattr,1,(vio.row / 2),start + mlen,0); VioWrtNAttr(&sattr,1,(vio.row / 2) + 1,start + mlen,0); VioWrtNAttr(&sattr,1,(vio.row / 2) + 2,start + mlen,0); VioWrtNAttr(&sattr,1,(vio.row / 2) + 3,start + mlen,0); VioWrtNAttr(&sattr,mlen,(vio.row / 2) + 4,start + 1,0); VioSetCurPos((vio.row / 2) + 1,start + (mlen - 3),0); if(responses) ShowCursor(FALSE); if(beep) DosBeep(beep,dur); if(!responses) DosSleep(wait); else { KbdFlushBuffer(0); while(okay) { key = get_ch(-1); if(!*responses) break; for(x = 0;responses[x];x++) { if(key == responses[x]) { okay = FALSE; break; } } } } ShowCursor(TRUE); VioWrtCellStr(buf,len,(vio.row / 2) - 2,0,0); free(buf); KbdFlushBuffer(0); ThreadMsg(NULL); } return key; }
void ShowFullWindow (char *title) { int attr = ((7 << 4) << 8) | ' '; USHORT line; /* display empty "window" */ VioScrollUp(3,0,vio.row - 5,vio.col - 1,-1,(char *)&attr,0); attr = (((7 << 4) | 4) << 8) | ' '; VioWrtNCell((char *)&attr,vio.col,2,0,0); attr = (((7 << 4) | (7 | 8)) << 8) | 'Ä'; VioWrtNCell((char *)&attr,vio.col - 4,3,1,0); attr = (((7 << 4) | 8) << 8) | 'Ä'; VioWrtNCell((char *)&attr,vio.col - 4,vio.row - 6,1,0); attr = (((7 << 4) | (7 | 8)) << 8) | 'Ú'; VioWrtNCell((char *)&attr,1,3,1,0); attr = (((7 << 4) | (7 | 8)) << 8) | '¿'; VioWrtNCell((char *)&attr,1,3,vio.col - 3,0); attr = (((7 << 4) | (7 | 8)) << 8) | 'À'; VioWrtNCell((char *)&attr,1,vio.row - 6,1,0); attr = (((7 << 4) | 8) << 8) | 'Ù'; VioWrtNCell((char *)&attr,1,vio.row - 6,vio.col - 3,0); attr = (((7 << 4) | (7 | 8)) << 8) | '³'; for(line = 4;line < vio.row - 6;line++) VioWrtNCell((char *)&attr,1,line,1,0); attr = (((7 << 4) | 8) << 8) | '³'; for(line = 4;line < vio.row - 6;line++) VioWrtNCell((char *)&attr,1,line,vio.col - 3,0); attr = ' '; VioWrtNCell((char *)&attr,vio.col - 1,vio.row - 4,1,0); for(line = 3;line < vio.row - 4;line++) VioWrtNCell((char *)&attr,1,line,vio.col - 1,0); attr = ((8 << 4) << 8) | ' '; VioWrtNCell((char *)&attr,1,2,vio.col - 1,0); VioWrtNCell((char *)&attr,1,vio.row - 4,0,0); /* display title */ VioWrtCharStr(title,min(strlen(title),vio.col - 2),2, ((vio.col - 2) - min(strlen(title),vio.col - 2)) / 2,0); }