int WatchIconProc(WINDOW wnd, MESSAGE msg, PARAM p1, PARAM p2) { int rtn; switch (msg) { case CREATE_WINDOW: rtn = DefaultWndProc(wnd, msg, p1, p2); SendMessage(wnd, CAPTURE_MOUSE, 0, 0); SendMessage(wnd, HIDE_MOUSE, 0, 0); SendMessage(wnd, CAPTURE_KEYBOARD, 0, 0); return rtn; case PAINT: SetStandardColor(wnd); writeline(wnd, " À ", 1, 1, FALSE); return TRUE; case BORDER: rtn = DefaultWndProc(wnd, msg, p1, p2); writeline(wnd, "Í", 2, 0, FALSE); return rtn; case MOUSE_MOVED: SendMessage(wnd, HIDE_WINDOW, 0, 0); SendMessage(wnd, MOVE, p1, p2); SendMessage(wnd, SHOW_WINDOW, 0, 0); return TRUE; case CLOSE_WINDOW: SendMessage(wnd, RELEASE_MOUSE, 0, 0); SendMessage(wnd, RELEASE_KEYBOARD, 0, 0); SendMessage(wnd, SHOW_MOUSE, 0, 0); break; default: break; } return DefaultWndProc(wnd, msg, p1, p2); }
int WatchIconProc(WINDOW wnd, MESSAGE msg, PARAM p1, PARAM p2) { int rtn, i; static int tick = 0; static char *hands[] = { " À ", " Ú ", " ¿ ", " Ù " }; switch (msg) { case CREATE_WINDOW: tick = 0; rtn = DefaultWndProc(wnd, msg, p1, p2); SendMessage(wnd, CAPTURE_MOUSE, 0, 0); SendMessage(wnd, HIDE_MOUSE, 0, 0); SendMessage(wnd, CAPTURE_KEYBOARD, 0, 0); SendMessage(wnd, CAPTURE_CLOCK, 0, 0); return rtn; case CLOCKTICK: ++tick; tick &= 3; SendMessage(wnd->PrevClock, msg, p1, p2); /* (fall through and paint) */ case PAINT: SetStandardColor(wnd); writeline(wnd, hands[tick], 1, 1, FALSE); return TRUE; case BORDER: rtn = DefaultWndProc(wnd, msg, p1, p2); writeline(wnd, "Í", 2, 0, FALSE); return rtn; case MOUSE_MOVED: SendMessage(wnd, HIDE_WINDOW, 0, 0); SendMessage(wnd, MOVE, p1, p2); SendMessage(wnd, SHOW_WINDOW, 0, 0); return TRUE; case CLOSE_WINDOW: SendMessage(wnd, RELEASE_CLOCK, 0, 0); SendMessage(wnd, RELEASE_MOUSE, 0, 0); SendMessage(wnd, RELEASE_KEYBOARD, 0, 0); SendMessage(wnd, SHOW_MOUSE, 0, 0); break; default: break; } return DefaultWndProc(wnd, msg, p1, p2); }
/* ---------- PAINT Message ---------- */ static void PaintMsg(WINDOW wnd) { if (Selecting) return; if (wnd == inFocus) SendMessage(GetParent(wnd), ADDSTATUS, 0, 0); SetStandardColor(wnd); wputs(wnd, GetText(wnd), 0, 0); if (ActiveMenuBar->ActiveSelection != -1 && (wnd == inFocus || mwnd != NULL)) { char *sel, *cp; int offset, offset1; sel = DFmalloc(200); offset=menu[ActiveMenuBar->ActiveSelection].x1; offset1=menu[ActiveMenuBar->ActiveSelection].x2; GetText(wnd)[offset1] = '\0'; SetReverseColor(wnd); memset(sel, '\0', 200); strcpy(sel, GetText(wnd)+offset); cp = strchr(sel, CHANGECOLOR); if (cp != NULL) *(cp + 2) = background | 0x80; wputs(wnd, sel, offset-ActiveMenuBar->ActiveSelection*4, 0); GetText(wnd)[offset1] = ' '; if (mwnd == NULL && wnd == inFocus) { char *st = ActiveMenu [ActiveMenuBar->ActiveSelection].StatusText; if (st != NULL) SendMessage(GetParent(wnd), ADDSTATUS, (PARAM)st, 0); } free(sel); } }
/* --------- All displayable typed keys ------------- */ static void KeyTyped(WINDOW wnd, int c) { char *currchar = CurrChar; if ((c != '\n' && c < ' ') || (c & 0x1000)) /* ---- not recognized by editor --- */ return; if (!isMultiLine(wnd) && TextBlockMarked(wnd)) { SendMessage(wnd, CLEARTEXT, 0, 0); currchar = CurrChar; } /* ---- test typing at end of text ---- */ if (currchar == wnd->text+wnd->MaxTextLength) { /* ---- typing at the end of maximum buffer ---- */ beep(); return; } if (*currchar == '\0') { /* --- insert a newline at end of text --- */ *currchar = '\n'; *(currchar+1) = '\0'; BuildTextPointers(wnd); } /* --- displayable char or newline --- */ if (c == '\n' || wnd->InsertMode || *currchar == '\n') { /* ------ inserting the keyed character ------ */ if (wnd->text[wnd->textlen-1] != '\0') { /* --- the current text buffer is full --- */ if (wnd->textlen == wnd->MaxTextLength) { /* --- text buffer is at maximum size --- */ beep(); return; } /* ---- increase the text buffer size ---- */ wnd->textlen += GROWLENGTH; /* --- but not above maximum size --- */ if (wnd->textlen > wnd->MaxTextLength) wnd->textlen = wnd->MaxTextLength; wnd->text = DFrealloc(wnd->text, wnd->textlen+2); wnd->text[wnd->textlen-1] = '\0'; currchar = CurrChar; } memmove(currchar+1, currchar, strlen(currchar)+1); ModTextPointers(wnd, wnd->CurrLine+1, 1); if (isMultiLine(wnd) && wnd->wlines > 1) wnd->textwidth = max(wnd->textwidth, (int) (TextLine(wnd, wnd->CurrLine+1)- TextLine(wnd, wnd->CurrLine))); else wnd->textwidth = max(wnd->textwidth, strlen(wnd->text)); WriteTextLine(wnd, NULL, wnd->wtop+wnd->WndRow, FALSE); } /* ----- put the char in the buffer ----- */ *currchar = c; wnd->TextChanged = TRUE; if (c == '\n') { wnd->wleft = 0; BuildTextPointers(wnd); End(wnd); Forward(wnd); SendMessage(wnd, PAINT, 0, 0); return; } /* ---------- test end of window --------- */ if (WndCol == ClientWidth(wnd)-1) { if (!isMultiLine(wnd)) { if (!(currchar == wnd->text+wnd->MaxTextLength-2)) SendMessage(wnd, HORIZSCROLL, TRUE, 0); } else { char *cp = currchar; while (*cp != ' ' && cp != TextLine(wnd, wnd->CurrLine)) --cp; if (cp == TextLine(wnd, wnd->CurrLine) || !wnd->WordWrapMode) SendMessage(wnd, HORIZSCROLL, TRUE, 0); else { int dif = 0; if (c != ' ') { dif = (int) (currchar - cp); wnd->CurrCol -= dif; SendMessage(wnd, KEYBOARD, DEL, 0); --dif; } SendMessage(wnd, KEYBOARD, '\n', 0); currchar = CurrChar; wnd->CurrCol = dif; if (c == ' ') return; } } } /* ------ display the character ------ */ SetStandardColor(wnd); PutWindowChar(wnd, c, WndCol, wnd->WndRow); /* ----- advance the pointers ------ */ wnd->CurrCol++; }
static void DisplayAsciitab(WINDOW wnd) { int x, y, i, ch; char content[80]; SetStandardColor(wnd); memset(content, ' ', 80); PutWindowLine(wnd, " + 0 1 2 3 4 5 6 7 8 9 A B C D E F ", 0, 0); ch = 0; for (y = 0; y < 16; y++) { i = 0; content[i++] = ' '; content[i++] = (y < 10) ? ('0' + y) : ('A' + (y-10)); content[i++] = '0'; content[i++] = ' '; for (x = 0; x < 16; x++) { if (ascii_highlight == ch) { content[i++] = CHANGECOLOR; /* next chars must be 8x 8x */ content[i++] = SelectForeground(wnd)+0x80; content[i++] = SelectBackground(wnd)+0x80; } /* SelectBackground(wnd)+0x80 thechar ' ' RESETCOLOR now... */ content[i++] = ch; /* see video.h wputs limitations! */ if ((!content[i-1]) #if 0 /* video.c treats this as non-escape char in THIS context */ || (content[i-1] == CHANGECOLOR) #endif || (content[i-1] == RESETCOLOR) #ifdef TAB_TOGGLING /* also used in editor.c and video.c */ || (content[i-1] == ('\t' | 0x80)) || (content[i-1] == ('\f' | 0x80)) #endif ) content[i-1] = '*'; if (ascii_highlight == ch) content[i++] = RESETCOLOR; content[i++] = ' '; ch++; } /* x loop */ #if ASCIIWIDTH > 40 content[i++] = (y < 10) ? ('0' + y) : ('A' + (y-10)); content[i++] = '0'; content[i++] = ' '; #endif content[i++] = 0; PutWindowLine(wnd, content, 0, y+1); } /* y loop */ content[0] = 0; i = ascii_highlight; if ((!i) #if 0 /* video.c treats this as non-escape char in THIS context */ || (i == CHANGECOLOR) #endif || (i == RESETCOLOR) #ifdef TAB_TOGGLING || (i == ('\t' | 0x80)) || (i == ('\f' | 0x80)) #endif ) i = '*'; sprintf(content," Character: Alt-%d (0x%02x) (\\%03o) '%c' ", ascii_highlight, ascii_highlight, ascii_highlight, (char)i); PutWindowLine(wnd, content, 0, 17); }