Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

186 lines
5.9 KiB

  1. //
  2. // borrowed for temprorary softpc console support
  3. //
  4. /*++ BUILD Version: 0001
  5. *
  6. * x86 v1.0
  7. *
  8. * XWINCON.H
  9. * Windows support functions for console windows
  10. *
  11. * History
  12. * Created 27-Dec-90 by Jeff Parsons
  13. *
  14. * COPYRIGHT NOTICE
  15. * This source file may not be distributed, modified or incorporated into
  16. * another product without prior approval from the author, Jeff Parsons.
  17. * This file may be copied to designated servers and machines authorized to
  18. * access those servers, but that does not imply any form of approval.
  19. */
  20. typedef unsigned int UINT; // ints preferred
  21. typedef int INT; // ints preferred
  22. typedef CHAR *NPSZ;
  23. typedef INT (FAR PASCAL *INTPROC)(HWND, UINT, UINT, LONG);
  24. #define DEF_CCHIN 16 // default input buffer size
  25. #define DEF_CCHXOUT 80 // default output buffer width
  26. #define DEF_CCHYOUT 25 // default output buffer height
  27. #define CON_SCROLL_LOCK 0x0010 // console has SCROLL-LOCK set
  28. #define CON_NUM_LOCK 0x0020 // console has NUM-LOCK set
  29. #define CON_CAPS_LOCK 0x0040 // console has CAPS-LOCK set
  30. #define CON_LEDS_MASK 0x0070 //
  31. #define CON_FOCUS 0x0100 // console has focus
  32. #ifndef VK_OEM_SCROLL
  33. #define VK_OEM_SCROLL 0x91 // left out of windows.h for some reason...
  34. #endif
  35. #define INVALIDATE_SCROLL 2
  36. #define IDM_DBBRK 100
  37. #define IDM_ABOUT 101
  38. #define CLR_BLACK 0x00000000
  39. #define CLR_RED 0x007F0000
  40. #define CLR_GREEN 0x00007F00
  41. #define CLR_BROWN 0x007F7F00
  42. #define CLR_BLUE 0x0000007F
  43. #define CLR_MAGENTA 0x007F007F
  44. #define CLR_CYAN 0x00007F7F
  45. #define CLR_LT_GRAY 0x00BFBFBF
  46. #define CLR_DK_GRAY 0x007F7F7F
  47. #define CLR_BR_RED 0x00FF0000
  48. #define CLR_BR_GREEN 0x0000FF00
  49. #define CLR_YELLOW 0x00FFFF00
  50. #define CLR_BR_BLUE 0x000000FF
  51. #define CLR_BR_MAGENTA 0x00FF00FF
  52. #define CLR_BR_CYAN 0x0000FFFF
  53. #define CLR_WHITE 0x00FFFFFF
  54. #define OPT_FONT 0x0004 // use small OEM font if available (/s)
  55. #define OPT_DOUBLE 0x0020 // use 50-line debug window w/small font (/50)
  56. #define OPT_CAPS 0x0002 // map ctrl keys to caps-lock (/c)
  57. #define OPT_TERMINAL 0x0010 // redirect all window output to terminal (/t)
  58. #define OPT_FLUSH 0x0100 // flush prefetch after every jump (/f)
  59. #define OPT_NOXLATE 0x0200 // disable built-in translations (/n)
  60. #define OPT_DEBUG 0x0008 // shadow all log output on debug terminal (/d)
  61. #define OPT_GO 0x0001 // do an initial "go" (/g)
  62. #define CTRL_A 1 // used by gets to repeat last line
  63. #define CTRL_C 3 // break in debug window
  64. #define CTRL_Q 17 // flow control
  65. #define CTRL_S 19 // flow control
  66. #define BELL 7 //
  67. #define BS 8 // backspace
  68. #define TAB 9 //
  69. #define LF 10 // linefeed
  70. #define CR 13 // return
  71. #define ESCAPE 27 //
  72. #define SIGNAL_EMULATE 1
  73. #define ERR_NONE 0x0
  74. #define TRUE_IF_WIN32 1
  75. /* Per-window information
  76. */
  77. #ifdef WIN_16
  78. #define GETPCONSOLE(hwnd) (PCONSOLE)GetWindowWord(hwnd,0)
  79. #define SETPCONSOLE(hwnd,p) (PCONSOLE)SetWindowWord(hwnd,0,(INT)p)
  80. #endif
  81. #ifdef WIN_32
  82. #define GETPCONSOLE(hwnd) (PCONSOLE)GetWindowLong(hwnd,0)
  83. #define SETPCONSOLE(hwnd,p) (PCONSOLE)SetWindowLong(hwnd,0,(LONG)p)
  84. #endif
  85. #ifdef PM
  86. #define GETPCONSOLE(hwnd) (PCONSOLE)WinQueryWindowUShort(hwnd,0)
  87. #define SETPCONSOLE(hwnd,p) (PCONSOLE)WinSetWindowUShort(hwnd,0,(USHORT)p)
  88. #endif
  89. #define GETICARET(pcon) (pcon->chyCaret*pcon->cchxOut+pcon->chxCaret)
  90. #define GETPCARET(pcon) (pcon->pchOut+GETICARET(pcon))
  91. #define GETXCARET(pcon) (pcon->chxCaret*pcon->cxChar)
  92. #ifdef WIN
  93. #define GETYCARET(pcon) (pcon->chyCaret*pcon->cyChar)
  94. #else
  95. #define GETYCARET(pcon) (pcon->cyOut - pcon->chyCaret*pcon->cyChar)
  96. #endif
  97. #define GETILINE(pcon,chy) ((chy)*pcon->cchxOut)
  98. #define GETPLINE(pcon,chy) (pcon->pchOut+GETILINE(pcon,chy))
  99. #define GETICHAR(pcon,chx,chy) ((chy)*pcon->cchxOut+(chx))
  100. #define GETPCHAR(pcon,chx,chy) (pcon->pchOut+GETICHAR(pcon,chx,chy))
  101. #define GETXCHAR(pcon,chx) (pcon->cxChar*(chx))
  102. #ifdef WIN
  103. #define GETYCHAR(pcon,chy) (pcon->cyChar*(chy))
  104. #else
  105. #define GETYCHAR(pcon,chy) (pcon->cyOut - pcon->cyChar*(chy))
  106. #endif
  107. #define WORDOF(i,n) (((PWORD)&(i))[n])
  108. #define LOW(l) WORDOF(l,0)
  109. #define NPVOID(p) ((VOID *)(p))
  110. typedef struct key_s {
  111. INT iKey;
  112. LONG lKeyType;
  113. } KEY, *PKEY;
  114. typedef struct console_s {
  115. INT flCon; // console flags (see CON_*)
  116. PKEY pkIn; // pointer to input buffer
  117. HANDLE hkEvent; // handle to key event
  118. INT ikHead; // input head (where to store next key)
  119. INT ikTail; // input tail (where to retrieve next key)
  120. INT ikMax; // maximum input index
  121. HFONT hFont; // font identifier
  122. INT cxChar; // character width, in pixels
  123. INT cyChar; // character height, in pixels
  124. INT cxOut; // buffer width, in pixels
  125. INT cyOut; // buffer height, in pixels
  126. INT cchxOut; // buffer width, in chars
  127. INT cchyOut; // buffer height, in chars
  128. UINT cbOut; // buffer size, in bytes
  129. PCHAR pchOut; // pointer to output buffer
  130. INT chxCaret; // caret x location, in char coordinates
  131. INT chyCaret; // caret y location, in char coordinates
  132. } CONSOLE, *PCONSOLE;
  133. /* Function prototypes
  134. */
  135. PCONSOLE initconsole(HWND hwnd, INT cchIn, INT cchxOut, INT cchyOut, INT iFont);
  136. VOID freeconsole(HWND hwnd);
  137. VOID clearconsole(HWND hwnd);
  138. VOID invalidateconsole(HWND hwnd, PRECT prc, BOOL fUpdate);
  139. INT wprint(HWND hwnd, NPSZ psz, INT n);
  140. INT wgetch(HWND hwnd);
  141. BOOL wkbhit(HWND hwnd);
  142. VOID wyield(HANDLE);
  143. INT wputch(HWND hwnd, INT i);
  144. VOID setcaret(HWND hwnd, INT x, INT y);
  145. VOID getcaret(HWND hwnd, PINT px, PINT py);
  146. VOID writechar(HWND hwnd, CHAR ch, INT n);
  147. VOID scrollrect(HWND hwndGuest, PRECT prc, INT n);
  148. extern HWND hwndGuest;
  149. extern HANDLE hHostInstance;
  150. extern INT flOptions; // command-line options (see OPT_*)
  151. extern INT flSignals; // signal flags (see SIGNAL_*)
  152. LONG FAR PASCAL VDMWndProc(HWND hwnd, UINT wMsg, UINT uParam, LONG lParam);
  153. BOOL FAR PASCAL VDMAbout(HWND hDlg, UINT wMsg, UINT uParam, LONG lParam);
  154. VOID processmessages(HWND hwnd);
  155. INT getkbdleds(VOID);
  156. VOID setkbdleds(INT flCon);
  157. VOID mapkbdkeys(PCONSOLE pcon, UINT iParam, BOOL fDown);