diff --git a/rosapps/dflat32/applicat.c b/rosapps/dflat32/applicat.c index 270cf06d618..89649d9c90e 100644 --- a/rosapps/dflat32/applicat.c +++ b/rosapps/dflat32/applicat.c @@ -2,7 +2,6 @@ #include "dflat.h" -static int ScreenHeight; static BOOL DisplayModified = FALSE; DFWINDOW ApplicationWindow; @@ -50,9 +49,9 @@ static char Menus[9][26] = /* --------------- CREATE_WINDOW Message -------------- */ static int CreateWindowMsg(DFWINDOW wnd) { - int rtn; + int rtn; + ApplicationWindow = wnd; - ScreenHeight = SCREENHEIGHT; #ifdef INCLUDE_WINDOWOPTIONS if (cfg.Border) SetCheckBox(&Display, ID_BORDER); @@ -386,7 +385,8 @@ static void CreateStatusBar(DFWINDOW wnd) /* -------- return the name of a document window ------- */ static char *WindowName(DFWINDOW wnd) { - if (GetTitle(wnd) == NULL) { + if (GetTitle(wnd) == NULL) + { if (GetClass(wnd) == DIALOG) return ((DBOX *)(wnd->extension))->HelpName; else @@ -518,7 +518,8 @@ static void MoreWindows(DFWINDOW wnd) static void ChooseWindow(DFWINDOW wnd, int WindowNo) { DFWINDOW cwnd = FirstWindow(wnd); - while (cwnd != NULL) { + while (cwnd != NULL) + { if (GetClass(cwnd) != MENUBAR && GetClass(cwnd) != STATUSBAR) if (WindowNo-- == 0) diff --git a/rosapps/dflat32/calendar.c b/rosapps/dflat32/calendar.c index 99a33bffbd5..13dea84c007 100644 --- a/rosapps/dflat32/calendar.c +++ b/rosapps/dflat32/calendar.c @@ -1,8 +1,6 @@ /* ------------- calendar.c ------------- */ #include "dflat.h" -#ifndef TURBOC - #define CALHEIGHT 17 #define CALWIDTH 33 @@ -13,9 +11,31 @@ static DFWINDOW Cwnd; static void FixDate(void) { - /* ---- adjust Feb for leap year ---- */ - DyMo[1] = (ttm.tm_year % 4) ? 28 : 29; - ttm.tm_mday = min(ttm.tm_mday, DyMo[ttm.tm_mon]); + /* ---- adjust Feb for leap year ---- */ + if (ttm.tm_year % 4 == 0) + { + if (ttm.tm_year % 100 == 0) + { + if (ttm.tm_year % 400 == 0) + { + DyMo[1] = 29; + } + else + { + DyMo[1] = 28; + } + } + else + { + DyMo[1] = 29; + } + } + else + { + DyMo[1] = 28; + } + + ttm.tm_mday = min(ttm.tm_mday, DyMo[ttm.tm_mon]); } /* ---- build calendar dates array ---- */ @@ -162,4 +182,4 @@ void Calendar(DFWINDOW pwnd) DfSendMessage(Cwnd, SETFOCUS, TRUE, 0); } -#endif +/* EOF */ diff --git a/rosapps/dflat32/console.c b/rosapps/dflat32/console.c index a604300fea7..9c638d1092e 100644 --- a/rosapps/dflat32/console.c +++ b/rosapps/dflat32/console.c @@ -18,16 +18,31 @@ static int altconvert[] = { }; #endif -static int cursorpos[MAXSAVES]; -static int cursorshape[MAXSAVES]; -static int cs; +static COORD cursorpos[MAXSAVES]; +static CONSOLE_CURSOR_INFO cursorinfo[MAXSAVES]; +static int cs = 0; void SwapCursorStack(void) { - if (cs > 1) { - swap(cursorpos[cs-2], cursorpos[cs-1]); - swap(cursorshape[cs-2], cursorshape[cs-1]); + if (cs > 1) + { + COORD coord; + CONSOLE_CURSOR_INFO csi; + + coord = cursorpos[cs-2]; + cursorpos[cs-2] = cursorpos[cs-1]; + cursorpos[cs-1] = coord; + + memcpy (&csi, + &cursorinfo[cs-2], + sizeof(CONSOLE_CURSOR_INFO)); + memcpy (&cursorinfo[cs-2], + &cursorinfo[cs-1], + sizeof(CONSOLE_CURSOR_INFO)); + memcpy (&cursorinfo[cs-1], + &csi, + sizeof(CONSOLE_CURSOR_INFO)); } } @@ -53,6 +68,7 @@ void GetKey (PINPUT_RECORD lpBuffer) /* ---------- read the keyboard shift status --------- */ + int getshift(void) { // regs.h.ah = 2; @@ -82,20 +98,8 @@ void cursor(int x, int y) SetConsoleCursorPosition (GetStdHandle (STD_OUTPUT_HANDLE), coPos); } -/* ------ get cursor shape and position ------ */ -static void getcursor(void) -{ -/* - videomode(); - regs.h.ah = READCURSOR; - regs.x.bx = video_page; - int86(VIDEO, ®s, ®s); -*/ - /* FIXME */ -} /* ------- get the current cursor position ------- */ - void curr_cursor(int *x, int *y) //VOID GetCursorXY (PSHORT x, PSHORT y) { @@ -111,70 +115,85 @@ void curr_cursor(int *x, int *y) /* ------ save the current cursor configuration ------ */ void savecursor(void) { -/* - if (cs < MAXSAVES) { - getcursor(); - cursorshape[cs] = regs.x.cx; - cursorpos[cs] = regs.x.dx; - cs++; - } -*/ + if (cs < MAXSAVES) + { + CONSOLE_SCREEN_BUFFER_INFO csbi; + + GetConsoleScreenBufferInfo (GetStdHandle (STD_OUTPUT_HANDLE), &csbi); + cursorpos[cs].X = csbi.dwCursorPosition.X; + cursorpos[cs].Y = csbi.dwCursorPosition.Y; + + GetConsoleCursorInfo (GetStdHandle (STD_OUTPUT_HANDLE), + &(cursorinfo[cs])); + + cs++; + } } /* ---- restore the saved cursor configuration ---- */ void restorecursor(void) { -/* - if (cs) { - --cs; - videomode(); - regs.x.dx = cursorpos[cs]; - regs.h.ah = SETCURSOR; - regs.x.bx = video_page; - int86(VIDEO, ®s, ®s); - set_cursor_type(cursorshape[cs]); - } -*/ + if (cs) + { + --cs; + SetConsoleCursorPosition (GetStdHandle (STD_OUTPUT_HANDLE), + cursorpos[cs]); + SetConsoleCursorInfo (GetStdHandle (STD_OUTPUT_HANDLE), + &(cursorinfo[cs])); + } } /* ------ make a normal cursor ------ */ void normalcursor(void) { -// set_cursor_type(0x0607); + CONSOLE_CURSOR_INFO csi; + + csi.bVisible = TRUE; + csi.dwSize = 5; + SetConsoleCursorInfo (GetStdHandle (STD_OUTPUT_HANDLE), + &csi); } /* ------ hide the cursor ------ */ void hidecursor(void) { -/* - getcursor(); - regs.h.ch |= HIDECURSOR; - regs.h.ah = SETCURSORTYPE; - int86(VIDEO, ®s, ®s); -*/ + CONSOLE_CURSOR_INFO csi; + + GetConsoleCursorInfo (GetStdHandle (STD_OUTPUT_HANDLE), + &csi); + csi.bVisible = FALSE; + SetConsoleCursorInfo (GetStdHandle (STD_OUTPUT_HANDLE), + &csi); } /* ------ unhide the cursor ------ */ void unhidecursor(void) { -/* - getcursor(); - regs.h.ch &= ~HIDECURSOR; - regs.h.ah = SETCURSORTYPE; - int86(VIDEO, ®s, ®s); -*/ + CONSOLE_CURSOR_INFO csi; + + GetConsoleCursorInfo (GetStdHandle (STD_OUTPUT_HANDLE), + &csi); + csi.bVisible = TRUE; + SetConsoleCursorInfo (GetStdHandle (STD_OUTPUT_HANDLE), + &csi); } -/* ---- use BIOS to set the cursor type ---- */ -void set_cursor_type(unsigned t) +/* set the cursor size (in percent) */ +void set_cursor_size (unsigned t) { -/* - videomode(); - regs.h.ah = SETCURSORTYPE; - regs.x.bx = video_page; - regs.x.cx = t; - int86(VIDEO, ®s, ®s); -*/ + CONSOLE_CURSOR_INFO csi; + + GetConsoleCursorInfo (GetStdHandle (STD_OUTPUT_HANDLE), + &csi); + + if (t < 2) + csi.dwSize = 2; + else if (t > 90) + csi.dwSize = 90; + else + csi.dwSize = t; + SetConsoleCursorInfo (GetStdHandle (STD_OUTPUT_HANDLE), + &csi); } diff --git a/rosapps/dflat32/dflat.h b/rosapps/dflat32/dflat.h index fd391a19094..0d3ec41a9f6 100644 --- a/rosapps/dflat32/dflat.h +++ b/rosapps/dflat32/dflat.h @@ -269,10 +269,10 @@ extern BOOL ClipString; #define DOWNSCROLLBOX (unsigned char) '\x1f' #define LEFTSCROLLBOX (unsigned char) '\x11' #define RIGHTSCROLLBOX (unsigned char) '\x10' -#define SCROLLBARCHAR (unsigned char) 176 +#define SCROLLBARCHAR (unsigned char) 176 #define SCROLLBOXCHAR (unsigned char) 178 /* ------------------ menu characters --------------------- */ -#define CHECKMARK (unsigned char) (SCREENHEIGHT==25?251:4) +#define CHECKMARK (unsigned char) '\x04' //(SCREENHEIGHT==25?251:4) #define CASCADEPOINTER (unsigned char) '\x10' /* ----------------- title bar characters ----------------- */ #define CONTROLBOXCHAR (unsigned char) '\xf0' @@ -285,12 +285,16 @@ extern BOOL ClipString; #define CHANGECOLOR (unsigned char) 174 /* prefix to change colors */ #define RESETCOLOR (unsigned char) 175 /* reset colors to default */ #define LISTSELECTOR 4 /* selected list box entry */ + /* --------- message prototypes ----------- */ -BOOL init_messages(void); +BOOL DfInitialize (void); +void DfTerminate (void); void DfPostMessage (DFWINDOW, DFMESSAGE, PARAM, PARAM); int DfSendMessage (DFWINDOW, DFMESSAGE, PARAM, PARAM); BOOL DfDispatchMessage (void); void handshake(void); +SHORT DfGetScreenHeight (void); +SHORT DfGetScreenWidth (void); /* ---- standard window message processing prototypes ----- */ int ApplicationProc(DFWINDOW, DFMESSAGE, PARAM, PARAM); @@ -317,6 +321,7 @@ int ErrorBoxProc(DFWINDOW, DFMESSAGE, PARAM, PARAM); int YesNoBoxProc(DFWINDOW, DFMESSAGE, PARAM, PARAM); int StatusBarProc(DFWINDOW, DFMESSAGE, PARAM, PARAM); int WatchIconProc(DFWINDOW, DFMESSAGE, PARAM, PARAM); + /* ------------- normal box prototypes ------------- */ void SetStandardColor(DFWINDOW); void SetReverseColor(DFWINDOW); diff --git a/rosapps/dflat32/edit.c b/rosapps/dflat32/edit.c index 4ae2d5de475..e8cbab8e018 100644 --- a/rosapps/dflat32/edit.c +++ b/rosapps/dflat32/edit.c @@ -36,8 +36,10 @@ int main (int argc, char *argv[]) { DFWINDOW wnd; FILE *fp; - if (!init_messages()) + + if (DfInitialize () == FALSE) return 1; + Argv = argv; LoadConfig (); // if (!LoadConfig()) @@ -75,6 +77,8 @@ int main (int argc, char *argv[]) while (DfDispatchMessage ()) ; + DfTerminate (); + return 0; } diff --git a/rosapps/dflat32/helpbox.c b/rosapps/dflat32/helpbox.c index 571193e61a8..196f47cc248 100644 --- a/rosapps/dflat32/helpbox.c +++ b/rosapps/dflat32/helpbox.c @@ -14,7 +14,7 @@ char *ClassNames[] = { NULL }; -#define MAXHEIGHT (SCREENHEIGHT-10) +#define MAXHEIGHT (DfGetScreenHeight()-10) /* --------- linked list of help text collections -------- */ struct helps { @@ -691,18 +691,18 @@ static void BestFit(DFWINDOW wnd, DIALOGWINDOW *dwnd) /* --- compute above overlap ---- */ above = OverLap(dwnd->h, GetTop(wnd)); /* --- compute below overlap ---- */ - below = OverLap(GetBottom(wnd), SCREENHEIGHT-dwnd->h); + below = OverLap(GetBottom(wnd), DfGetScreenHeight()-dwnd->h); /* --- compute right overlap ---- */ - right = OverLap(GetRight(wnd), SCREENWIDTH-dwnd->w); + right = OverLap(GetRight(wnd), DfGetScreenWidth()-dwnd->w); /* --- compute left overlap ---- */ left = OverLap(dwnd->w, GetLeft(wnd)); if (above < below) dwnd->y = max(0, GetTop(wnd)-dwnd->h-2); else - dwnd->y = min(SCREENHEIGHT-dwnd->h, GetBottom(wnd)+2); + dwnd->y = min(DfGetScreenHeight()-dwnd->h, GetBottom(wnd)+2); if (right < left) - dwnd->x = min(GetRight(wnd)+2, SCREENWIDTH-dwnd->w); + dwnd->x = min(GetRight(wnd)+2, DfGetScreenWidth()-dwnd->w); else dwnd->x = max(0, GetLeft(wnd)-dwnd->w-2); diff --git a/rosapps/dflat32/lists.c b/rosapps/dflat32/lists.c index f907293ff61..c67987a03ca 100644 --- a/rosapps/dflat32/lists.c +++ b/rosapps/dflat32/lists.c @@ -82,19 +82,22 @@ void ReFocus(DFWINDOW wnd) /* ---- remove a window from the linked list ---- */ void RemoveWindow(DFWINDOW wnd) { - if (wnd != NULL) { + if (wnd != NULL) + { DFWINDOW pwnd = GetParent(wnd); - if (PrevWindow(wnd) != NULL) - NextWindow(PrevWindow(wnd)) = NextWindow(wnd); - if (NextWindow(wnd) != NULL) - PrevWindow(NextWindow(wnd)) = PrevWindow(wnd); - if (pwnd != NULL) { - if (wnd == FirstWindow(pwnd)) - FirstWindow(pwnd) = NextWindow(wnd); - if (wnd == LastWindow(pwnd)) - LastWindow(pwnd) = PrevWindow(wnd); + + if (PrevWindow(wnd) != NULL) + NextWindow(PrevWindow(wnd)) = NextWindow(wnd); + if (NextWindow(wnd) != NULL) + PrevWindow(NextWindow(wnd)) = PrevWindow(wnd); + if (pwnd != NULL) + { + if (wnd == FirstWindow(pwnd)) + FirstWindow(pwnd) = NextWindow(wnd); + if (wnd == LastWindow(pwnd)) + LastWindow(pwnd) = PrevWindow(wnd); } - } + } } /* ---- append a window to the linked list ---- */ @@ -105,14 +108,6 @@ void AppendWindow(DFWINDOW wnd) DFWINDOW pwnd = GetParent(wnd); if (pwnd != NULL) { -/* - if (FirstWindow(pwnd) == NULL) - FirstWindow(pwnd) = wnd; - if (LastWindow(pwnd) != NULL) - NextWindow(LastWindow(pwnd)) = wnd; - PrevWindow(wnd) = LastWindow(pwnd); - LastWindow(pwnd) = wnd; -*/ if (FirstWindow(pwnd) == NULL) { FirstWindow(pwnd) = wnd; @@ -130,8 +125,10 @@ void AppendWindow(DFWINDOW wnd) } } -/* ----- if document windows and statusbar or menubar get the focus, - pass it on ------- */ +/* + * if document windows and statusbar or menubar get the focus, + * pass it on + */ void SkipApplicationControls(void) { BOOL EmptyAppl = FALSE; diff --git a/rosapps/dflat32/makefile b/rosapps/dflat32/makefile index 6391be09e58..5189d99c933 100644 --- a/rosapps/dflat32/makefile +++ b/rosapps/dflat32/makefile @@ -49,7 +49,7 @@ else endif -WITH_DEBUGGING=yes +#WITH_DEBUGGING=yes include ../rules.mak diff --git a/rosapps/dflat32/menubar.c b/rosapps/dflat32/menubar.c index 09649db074d..a67b1f367ff 100644 --- a/rosapps/dflat32/menubar.c +++ b/rosapps/dflat32/menubar.c @@ -405,22 +405,26 @@ int MenuBarProc(DFWINDOW wnd, DFMESSAGE msg, PARAM p1, PARAM p2) /* ------------- reset the MENUBAR -------------- */ static void reset_menubar(DFWINDOW wnd) { - GetText(wnd) = DFrealloc(GetText(wnd), SCREENWIDTH+5); - memset(GetText(wnd), ' ', SCREENWIDTH); + GetText(wnd) = DFrealloc(GetText(wnd), DfGetScreenWidth()+5); + memset(GetText(wnd), ' ', DfGetScreenWidth()); *(GetText(wnd)+WindowWidth(wnd)) = '\0'; } static DFWINDOW GetDocFocus(void) { DFWINDOW wnd = ApplicationWindow; - if (wnd != NULL) { + if (wnd != NULL) + { wnd = LastWindow(wnd); - while (wnd != NULL && (GetClass(wnd) == MENUBAR || - GetClass(wnd) == STATUSBAR)) + while (wnd != NULL && + (GetClass(wnd) == MENUBAR || + GetClass(wnd) == STATUSBAR)) wnd = PrevWindow(wnd); if (wnd != NULL) + { while (wnd->childfocus != NULL) wnd = wnd->childfocus; + } } return wnd ? wnd : ApplicationWindow; } diff --git a/rosapps/dflat32/message.c b/rosapps/dflat32/message.c index e3d865c953b..89b65bf34f2 100644 --- a/rosapps/dflat32/message.c +++ b/rosapps/dflat32/message.c @@ -1,6 +1,7 @@ /* --------- message.c ---------- */ #include "dflat.h" +#include "system.h" static int handshaking = 0; @@ -56,9 +57,21 @@ static void StopMsg(void) unhidecursor(); } -/* ------------ initialize the message system --------- */ -BOOL init_messages (VOID) +SHORT DfGetScreenHeight (void) { + return sScreenHeight; +} + +SHORT DfGetScreenWidth (void) +{ + return sScreenWidth; +} + +/* ------------ initialize the message system --------- */ +BOOL DfInitialize (VOID) +{ + CONSOLE_SCREEN_BUFFER_INFO csbi; + AllocTesting = TRUE; if (setjmp(AllocError) != 0) { @@ -66,9 +79,17 @@ BOOL init_messages (VOID) return FALSE; } + /* get input and output handles */ + hInput = GetStdHandle (STD_INPUT_HANDLE); + hOutput = GetStdHandle (STD_OUTPUT_HANDLE); + + /* get screen size */ + GetConsoleScreenBufferInfo (hOutput, &csbi); + sScreenHeight = (csbi.srWindow.Bottom - csbi.srWindow.Top) + 1; + sScreenWidth = (csbi.srWindow.Right - csbi.srWindow.Left) + 1; + /* enable mouse events */ - SetConsoleMode (GetStdHandle (STD_INPUT_HANDLE), - ENABLE_MOUSE_INPUT); + SetConsoleMode (hInput, ENABLE_MOUSE_INPUT); savecursor(); hidecursor(); @@ -88,6 +109,12 @@ BOOL init_messages (VOID) return TRUE; } + +void DfTerminate (void) +{ + +} + /* ----- post an event and parameters to event queue ---- */ static void PostEvent(DFMESSAGE event, int p1, int p2) { @@ -163,19 +190,23 @@ static void collect_events(void) { sk |= CTRLKEY; } + if (ir.Event.KeyEvent.dwControlKeyState & SHIFT_PRESSED) + { + sk |= LEFTSHIFT + RIGHTSHIFT; + } -#if 0 if (sk != OldShiftKeys) { OldShiftKeys = sk; /* the shift status changed */ PostEvent(SHIFT_CHANGED, sk, 0); +#if 0 if (sk & ALTKEY) AltDown = TRUE; else AltDown = FALSE; - } #endif + } if (ir.Event.KeyEvent.uChar.AsciiChar == 0) { @@ -213,6 +244,14 @@ static void collect_events(void) c = FWD; break; + case VK_INSERT: + c = INS; + break; + + case VK_DELETE: + c = DEL; + break; + case VK_HOME: c = HOME; break; @@ -234,7 +273,14 @@ static void collect_events(void) } } else - c = ir.Event.KeyEvent.uChar.AsciiChar; + { + /* special handling of SHIFT+TAB */ + if (ir.Event.KeyEvent.uChar.AsciiChar == VK_TAB && + (ir.Event.KeyEvent.dwControlKeyState & SHIFT_PRESSED)) + c = SHIFT_HT; + else + c = ir.Event.KeyEvent.uChar.AsciiChar; + } PostEvent (KEYBOARD, c, sk); } @@ -282,66 +328,9 @@ static void collect_events(void) } } } - - -#if 0 - /* --------- keyboard events ---------- */ - if ((sk = getshift()) != ShiftKeys) - { - ShiftKeys = sk; - /* ---- the shift status changed ---- */ - PostEvent(SHIFT_CHANGED, sk, 0); - if (sk & ALTKEY) - AltDown = TRUE; - } - - /* ---- build keyboard events for key combinations that - BIOS doesn't report --------- */ - if (sk & ALTKEY) { - if (keyportvalue == 14) { - AltDown = FALSE; - PostEvent(KEYBOARD, ALT_BS, sk); - } - if (keyportvalue == 83) { - AltDown = FALSE; - PostEvent(KEYBOARD, ALT_DEL, sk); - } - } - - if (sk & CTRLKEY) - { - AltDown = FALSE; - if (keyportvalue == 82) { - PostEvent(KEYBOARD, CTRL_INS, sk); - } - } - /* ----------- test for keystroke ------- */ - if (keyhit()) { - static int cvt[] = {SHIFT_INS,END,DN,PGDN,BS,'5', - FWD,HOME,UP,PGUP}; - INPUT_RECORD ir; - int c; - - GetKey(&ir); - c = ir.Event.KeyEvent.uChar.AsciiChar; - - AltDown = FALSE; - /* -------- convert numeric pad keys ------- */ - if (sk & (LEFTSHIFT | RIGHTSHIFT)) - { - if (c >= '0' && c <= '9') - c = cvt[c-'0']; - else if (c == '.' || c == DEL) - c = SHIFT_DEL; - else if (c == INS) - c = SHIFT_INS; - } - /* ------ post the keyboard event ------ */ - PostEvent(KEYBOARD, c, sk); - } -#endif } + /* ----- post a message and parameters to msg queue ---- */ void DfPostMessage(DFWINDOW wnd, DFMESSAGE msg, PARAM p1, PARAM p2) { @@ -476,9 +465,9 @@ int DfSendMessage(DFWINDOW wnd, DFMESSAGE msg, PARAM p1, PARAM p2) break; case SHOW_CURSOR: if (p1) - set_cursor_type(0x0106); + set_cursor_size(100); else - set_cursor_type(0x0607); + set_cursor_size(5); unhidecursor(); break; diff --git a/rosapps/dflat32/msgbox.c b/rosapps/dflat32/msgbox.c index 8e46766ee92..3683b6f93e9 100644 --- a/rosapps/dflat32/msgbox.c +++ b/rosapps/dflat32/msgbox.c @@ -188,23 +188,29 @@ DFWINDOW MomentaryMessage(char *msg) int MsgHeight(char *msg) { - int h = 1; - while ((msg = strchr(msg, '\n')) != NULL) { - h++; - msg++; - } - return min(h, SCREENHEIGHT-10); + int h = 1; + + while ((msg = strchr(msg, '\n')) != NULL) + { + h++; + msg++; + } + + return min(h, DfGetScreenHeight ()-10); } int MsgWidth(char *msg) { - int w = 0; - char *cp = msg; - while ((cp = strchr(msg, '\n')) != NULL) { - w = max(w, (int) (cp-msg)); - msg = cp+1; - } - return min(max((int)strlen(msg), (int)w), SCREENWIDTH-10); + int w = 0; + char *cp = msg; + + while ((cp = strchr(msg, '\n')) != NULL) + { + w = max(w, (int) (cp-msg)); + msg = cp+1; + } + + return min(max((int)strlen(msg), (int)w), DfGetScreenWidth()-10); } /* EOF */ \ No newline at end of file diff --git a/rosapps/dflat32/normal.c b/rosapps/dflat32/normal.c index bf5f423e143..32740ba48b1 100644 --- a/rosapps/dflat32/normal.c +++ b/rosapps/dflat32/normal.c @@ -99,11 +99,11 @@ static BOOL KeyboardMsg(DFWINDOW wnd, PARAM p1, PARAM p2) --y; break; case DN: - if (y < SCREENHEIGHT-1) + if (y < DfGetScreenHeight()-1) y++; break; case FWD: - if (x < SCREENWIDTH-1) + if (x < DfGetScreenWidth()-1) x++; break; case BS: @@ -389,8 +389,8 @@ static BOOL MouseMovedMsg(DFWINDOW wnd, PARAM p1, PARAM p2) { if (WindowMoving) { int leftmost = 0, topmost = 0, - bottommost = SCREENHEIGHT-2, - rightmost = SCREENWIDTH-2; + bottommost = DfGetScreenHeight()-2, + rightmost = DfGetScreenWidth()-2; int x = (int) p1 - diff; int y = (int) p2; if (GetParent(wnd) != NULL && @@ -430,8 +430,8 @@ static void MaximizeMsg(DFWINDOW wnd) DFRECT rc = {0, 0, 0, 0}; DFRECT holdrc; holdrc = wnd->RestoredRC; - rc.rt = SCREENWIDTH-1; - rc.bt = SCREENHEIGHT-1; + rc.rt = DfGetScreenWidth()-1; + rc.bt = DfGetScreenHeight()-1; if (GetParent(wnd)) rc = ClientRect(GetParent(wnd)); wnd->oldcondition = wnd->condition; @@ -721,10 +721,10 @@ static DFRECT PositionIcon(DFWINDOW wnd) { DFWINDOW pwnd = GetParent(wnd); DFRECT rc; - RectLeft(rc) = SCREENWIDTH-ICONWIDTH; - RectTop(rc) = SCREENHEIGHT-ICONHEIGHT; - RectRight(rc) = SCREENWIDTH-1; - RectBottom(rc) = SCREENHEIGHT-1; + RectLeft(rc) = DfGetScreenWidth()-ICONWIDTH; + RectTop(rc) = DfGetScreenHeight()-ICONHEIGHT; + RectRight(rc) = DfGetScreenWidth()-1; + RectBottom(rc) = DfGetScreenHeight()-1; if (pwnd != NULL) { DFRECT prc = WindowRect(pwnd); DFWINDOW cwnd = FirstWindow(pwnd); @@ -789,8 +789,8 @@ static void sizeborder(DFWINDOW wnd, int rt, int bt) { int leftmost = GetLeft(wnd)+10; int topmost = GetTop(wnd)+3; - int bottommost = SCREENHEIGHT-1; - int rightmost = SCREENWIDTH-1; + int bottommost = DfGetScreenHeight()-1; + int rightmost = DfGetScreenWidth()-1; if (GetParent(wnd)) { bottommost = min(bottommost, GetClientBottom(GetParent(wnd))); @@ -824,9 +824,9 @@ static DFRECT adjShadow(DFWINDOW wnd) DFRECT rc; rc = wnd->rc; if (TestAttribute(wnd, SHADOW)) { - if (RectRight(rc) < SCREENWIDTH-1) - RectRight(rc)++; - if (RectBottom(rc) < SCREENHEIGHT-1) + if (RectRight(rc) < DfGetScreenWidth()-1) + RectRight(rc)++; + if (RectBottom(rc) < DfGetScreenHeight()-1) RectBottom(rc)++; } return rc; diff --git a/rosapps/dflat32/popdown.c b/rosapps/dflat32/popdown.c index 4362369d1b2..b24726fadda 100644 --- a/rosapps/dflat32/popdown.c +++ b/rosapps/dflat32/popdown.c @@ -8,31 +8,38 @@ static int py = -1; /* ------------ CREATE_WINDOW Message ------------- */ static int CreateWindowMsg(DFWINDOW wnd) { - int rtn, adj; - ClearAttribute(wnd, HASTITLEBAR | - VSCROLLBAR | - MOVEABLE | - SIZEABLE | - HSCROLLBAR); + int rtn, adj; + + ClearAttribute (wnd, + HASTITLEBAR | + VSCROLLBAR | + MOVEABLE | + SIZEABLE | + HSCROLLBAR); + /* ------ adjust to keep popdown on screen ----- */ - adj = SCREENHEIGHT-1-wnd->rc.bt; - if (adj < 0) { + adj = DfGetScreenHeight()-1-wnd->rc.bt; + if (adj < 0) + { wnd->rc.tp += adj; wnd->rc.bt += adj; } - adj = SCREENWIDTH-1-wnd->rc.rt; - if (adj < 0) { + adj = DfGetScreenWidth()-1-wnd->rc.rt; + if (adj < 0) + { wnd->rc.lf += adj; wnd->rc.rt += adj; } - rtn = BaseWndProc(POPDOWNMENU, wnd, CREATE_WINDOW, 0, 0); - DfSendMessage(wnd, CAPTURE_MOUSE, 0, 0); - DfSendMessage(wnd, CAPTURE_KEYBOARD, 0, 0); - DfSendMessage(NULL, SAVE_CURSOR, 0, 0); - DfSendMessage(NULL, HIDE_CURSOR, 0, 0); + + rtn = BaseWndProc(POPDOWNMENU, wnd, CREATE_WINDOW, 0, 0); + DfSendMessage(wnd, CAPTURE_MOUSE, 0, 0); + DfSendMessage(wnd, CAPTURE_KEYBOARD, 0, 0); + DfSendMessage(NULL, SAVE_CURSOR, 0, 0); + DfSendMessage(NULL, HIDE_CURSOR, 0, 0); wnd->oldFocus = inFocus; inFocus = wnd; - return rtn; + + return rtn; } /* --------- LEFT_BUTTON Message --------- */ diff --git a/rosapps/dflat32/readme.txt b/rosapps/dflat32/readme.txt index 42773f8bcbf..de96a406607 100644 --- a/rosapps/dflat32/readme.txt +++ b/rosapps/dflat32/readme.txt @@ -18,7 +18,7 @@ Things that have to be fixed (incomplete list): collisions (e.g. CreateWindow() --> DfCreateWindow()) - fix short dos filename buffers - add code to register external window classes - - implement recognition of current console screen size + - implement recognition of current console screen size (done) - fix remaining bugs - update documentation diff --git a/rosapps/dflat32/rect.c b/rosapps/dflat32/rect.c index d58d4ba7fe4..15edfe721bf 100644 --- a/rosapps/dflat32/rect.c +++ b/rosapps/dflat32/rect.c @@ -66,8 +66,8 @@ DFRECT ClientRect(void *wnd) { RectLeft(rc) = 1; // GetClientLeft((DFWINDOW)wnd); RectTop(rc) = 2; // GetClientTop((DFWINDOW)wnd); - RectRight(rc) = SCREENWIDTH - 2; // GetClientRight((DFWINDOW)wnd); - RectBottom(rc) = SCREENHEIGHT - 2; // GetClientBottom((DFWINDOW)wnd); + RectRight(rc) = DfGetScreenWidth () - 2; // GetClientRight((DFWINDOW)wnd); + RectBottom(rc) = DfGetScreenHeight () - 2; // GetClientBottom((DFWINDOW)wnd); return rc; } @@ -95,8 +95,8 @@ DFRECT ClipRectangle(void *wnd, DFRECT rc) { DFRECT sr; RectLeft(sr) = RectTop(sr) = 0; - RectRight(sr) = SCREENWIDTH-1; - RectBottom(sr) = SCREENHEIGHT-1; + RectRight(sr) = DfGetScreenWidth()-1; + RectBottom(sr) = DfGetScreenHeight()-1; if (!TestAttribute((DFWINDOW)wnd, NOCLIP)) while ((wnd = GetParent((DFWINDOW)wnd)) != NULL) rc = subRectangle(rc, ClientRect(wnd)); diff --git a/rosapps/dflat32/sysmenu.c b/rosapps/dflat32/sysmenu.c index a3e897b15dd..00e4aafc968 100644 --- a/rosapps/dflat32/sysmenu.c +++ b/rosapps/dflat32/sysmenu.c @@ -53,10 +53,10 @@ void BuildSystemMenu(DFWINDOW wnd) ht = MenuHeight(SystemMenu.PullDown[0].Selections); wd = MenuWidth(SystemMenu.PullDown[0].Selections); - if (lf+wd > SCREENWIDTH-1) - lf = (SCREENWIDTH-1) - wd; - if (tp+ht > SCREENHEIGHT-2) - tp = (SCREENHEIGHT-2) - ht; + if (lf+wd > DfGetScreenWidth()-1) + lf = (DfGetScreenWidth()-1) - wd; + if (tp+ht > DfGetScreenHeight()-2) + tp = (DfGetScreenHeight()-2) - ht; SystemMenuWnd = DfCreateWindow(POPDOWNMENU, NULL, lf,tp,ht,wd,NULL,wnd,SystemMenuProc, 0); diff --git a/rosapps/dflat32/system.h b/rosapps/dflat32/system.h index 944dc7c3a19..42136c1b242 100644 --- a/rosapps/dflat32/system.h +++ b/rosapps/dflat32/system.h @@ -16,8 +16,15 @@ #define ZEROFLAG 0x40 #define MAXSAVES 50 -#define SCREENWIDTH (80) -#define SCREENHEIGHT (25) +//#define SCREENWIDTH (80) +//#define SCREENHEIGHT (25) + +HANDLE hInput; +HANDLE hOutput; + +SHORT sScreenHeight; +SHORT sScreenWidth; + /* ---------- keyboard prototypes -------- */ int AltConvert(int); @@ -34,7 +41,7 @@ void unhidecursor(void); void savecursor(void); void restorecursor(void); void normalcursor(void); -void set_cursor_type(unsigned t); +void set_cursor_size(unsigned t); void videomode(void); void SwapCursorStack(void); diff --git a/rosapps/dflat32/textbox.c b/rosapps/dflat32/textbox.c index cc5fb7d553e..6e13bb17926 100644 --- a/rosapps/dflat32/textbox.c +++ b/rosapps/dflat32/textbox.c @@ -381,7 +381,7 @@ static void PaintMsg(DFWINDOW wnd, PARAM p1, PARAM p2) ClipString++; /* ----- blank line for padding ----- */ - memset(blankline, ' ', SCREENWIDTH); + memset(blankline, ' ', DfGetScreenWidth()); blankline[RectRight(rcc)+1] = '\0'; /* ------- each line within rectangle ------ */ diff --git a/rosapps/dflat32/video.c b/rosapps/dflat32/video.c index 74385c986e1..51398402919 100644 --- a/rosapps/dflat32/video.c +++ b/rosapps/dflat32/video.c @@ -81,7 +81,7 @@ void PutVideoChar(int x, int y, int ch) COORD pos; DWORD dwWritten; - if (x < SCREENWIDTH && y < SCREENHEIGHT) + if (x < sScreenWidth && y < sScreenHeight) { pos.X = x; pos.Y = y; @@ -141,7 +141,7 @@ BOOL CharInView(DFWINDOW wnd, int x, int y) } nwnd = NextWindow(nwnd); } - return (x1 < SCREENWIDTH && y1 < SCREENHEIGHT); + return (x1 < sScreenWidth && y1 < sScreenHeight); } /* -------- write a character to a window ------- */ @@ -180,7 +180,7 @@ void wputs(DFWINDOW wnd, void *s, int x, int y) int x2 = x1; int y1 = GetTop(wnd)+y; - if (x1 < SCREENWIDTH && y1 < SCREENHEIGHT && isVisible(wnd)) + if (x1 < sScreenWidth && y1 < sScreenHeight && isVisible(wnd)) { char ln[200]; WORD attr[200]; @@ -223,8 +223,8 @@ void wputs(DFWINDOW wnd, void *s, int x, int y) foreground = fg; background = bg; len = (int)(cp-ln); - if (x1+len > SCREENWIDTH) - len = SCREENWIDTH-x1; + if (x1+len > sScreenWidth) + len = sScreenWidth-x1; if (!ClipString && !TestAttribute(wnd, NOCLIP)) { diff --git a/rosapps/dflat32/window.c b/rosapps/dflat32/window.c index 63d4bc0c70d..8fa334d4ac1 100644 --- a/rosapps/dflat32/window.c +++ b/rosapps/dflat32/window.c @@ -24,16 +24,16 @@ DFWINDOW DfCreateWindow( int base; /* ----- height, width = -1: fill the screen ------- */ if (height == -1) - height = SCREENHEIGHT; + height = sScreenHeight; if (width == -1) - width = SCREENWIDTH; + width = sScreenWidth; /* ----- coordinates -1, -1 = center the window ---- */ if (left == -1) - wnd->rc.lf = (SCREENWIDTH-width)/2; + wnd->rc.lf = (sScreenWidth-width)/2; else wnd->rc.lf = left; if (top == -1) - wnd->rc.tp = (SCREENHEIGHT-height)/2; + wnd->rc.tp = (sScreenHeight-height)/2; else wnd->rc.tp = top; wnd->attrib = attrib; @@ -498,7 +498,9 @@ void PutWindowChar(DFWINDOW wnd, char c, int x, int y) void PutWindowLine(DFWINDOW wnd, void *s, int x, int y) { - int saved = FALSE, sv; + int saved = FALSE; + int sv = 0; + if (x < ClientWidth(wnd) && y < ClientHeight(wnd)) { char *en = (char *)s+ClientWidth(wnd)-x;