Leaked source code of windows server 2003
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.

229 lines
7.3 KiB

  1. /* File: D:\WACKER\tdll\term.hh (Created: 07-Dec-1993)
  2. *
  3. * Copyright 1994 by Hilgraeve Inc. -- Monroe, MI
  4. * All rights reserved
  5. *
  6. * $Revision: 3 $
  7. * $Date: 3/26/02 8:41a $
  8. */
  9. /* --- Macros --- */
  10. #define MAX_EMUCOLORS 16
  11. #define BEZEL_SIZE 13
  12. #define OUTDENT 3
  13. // MARK_XOR and MARK_ABS used to tell MarkText() to mark text in terminal
  14. // window image buffer.
  15. #define MARK_XOR 1
  16. #define MARK_ABS 2
  17. /* --- Private Messages --- */
  18. #define WM_TERM_SCRLMARK WM_USER+0x200
  19. #define WM_TERM_KLUDGE_FONT WM_USER+0x201
  20. /* --- Data Structures --- */
  21. typedef struct stTerm *HHTERM;
  22. struct stTerm
  23. {
  24. ECHAR **fplpstrTxt; // Text buffer
  25. PSTATTR *fppstAttr; // array of pointers to attribute structs.
  26. BYTE abBlink[MAX_EMUROWS]; // array of chars used to check blinking
  27. int iTopline; // top line of text buffer.
  28. int iRows, // number of rows
  29. iCols; // number of columns
  30. HBRUSH hbrushBackScrl, // color of backscroll region.
  31. hbrushDivider, // color of divider bar.
  32. hbrushTerminal, // emulator's clear attribute.
  33. hbrushHighlight, // highlight brush
  34. hbrushBackHatch, // backscroll hatched brush
  35. hbrushTermHatch; // terminal hatched brush
  36. COLORREF crBackScrl, // RGB background color of backscroll.
  37. crBackScrlTxt, // RGB text color of backscroll.
  38. crTerm; // RGB terminal background (clear attr).
  39. HPEN hBlackPen, // Pen used to draw bezel border
  40. hWhitePen, // Pen used to draw bezel highlight
  41. hDkGrayPen, // Pen used to draw bezel face
  42. hLtGrayPen; // Pen used to draw bezel shadow
  43. HWND hwnd, // terminal window handle.
  44. hwndSession; // session window handle.
  45. HSESSION hSession; // session handle.
  46. HFONT hFont, // terminal font
  47. hDblHiFont, // double high
  48. hDblWiFont, // double wide
  49. hDblHiWiFont; // double high wide
  50. HFONT hSymFont, // symbol terminal font
  51. hSymDblHiFont, // symbol double high
  52. hSymDblWiFont, // symbol double wide
  53. hSymDblHiWiFont; // symbol double high wide
  54. LOGFONT lf, // terminal logfont structure
  55. lfSys, // logfont read from system file
  56. lfHold; // for kludge font
  57. int xChar, // width of font
  58. yChar, // height of font
  59. cx, // width of client area
  60. cy, // height of client area
  61. iTermHite, // terminal height expressed as rows
  62. iEvenFont; // Flag indicating we have an even pixeled font
  63. int iBlink, // state of blink (-1=on,0=disabled,1=off)
  64. fBlink, // true if blinking host cursor set
  65. fFocus, // true if we have the focus
  66. fBump, // used to position vertical thumb
  67. fCapture, // mouse captured
  68. fHstCurOn, // host cursor
  69. fSelectByWord, // selecting text by word
  70. fScrolled, // scrolling routines set this.
  71. iBtnOne, // what a dbl clk button one does
  72. fLclCurOn, // marking cursor
  73. fCursorsLinked, // cursors are the same
  74. fCursorTracking, // terminal view tracks to cursor
  75. fMarkingLock, // true if we've marked text
  76. fExtSelect, // true if extended text selection on
  77. fBackscrlLock, // true if only backscroll visible
  78. fItalic; // true if font is italic
  79. unsigned uBlinkRate; // blink rate set on handle creation
  80. const COLORREF *pacrEmuColors; // pointer array to emulator colors
  81. int iVScrlMin, // scrollbar control variables
  82. iVScrlMax,
  83. iVScrlPos,
  84. iHScrlMin,
  85. iHScrlMax,
  86. iHScrlPos;
  87. int xBezel, // size of bezel in pixels
  88. xIndent, // amount in pixels to indent from bezel
  89. yBrushOrg; // brush orign used for hatchbrush
  90. POINT ptHstCur, // host cursor coordinates
  91. ptLclCur, // local (marking) cursor coordinates
  92. ptBeg, // beginning of marked region
  93. ptEnd; // end of marked region
  94. int iCurType; // Type of cursor defined in emu\emu.h
  95. int iHstCurSiz; // Vertical size of host cursor
  96. HTIMER hCursorTimer, // timer for blinking terminal cursor
  97. hMarkingTimer; // used for scroll marking
  98. HUPDATE hUpdate; // copy of info from termGetUpdate()
  99. TCHAR underscores[MAX_EMUCOLS]; // used to do underlining
  100. /* --- Stuff from Client-side backscroll handle ---*/
  101. ECHAR **fplpstrBkTxt; // bckscrl text buffer
  102. int iPhysicalBkRows, // # of physical rows used by the buffer
  103. iMaxPhysicalBkRows, // Max size of buffer based on font.
  104. iNextBkLn, // next line to receive text in buffer
  105. iBkLines; // used in TP_WM_SIZE()
  106. };
  107. /* --- Function prototypes --- */
  108. /* --- termproc.c --- */
  109. LRESULT CALLBACK TermProc(HWND hwnd, UINT uMsg, WPARAM wPar, LPARAM lPar);
  110. void TP_WM_SIZE(const HWND hwnd,
  111. const unsigned fwSizeType,
  112. const int iWidth,
  113. const int iHite);
  114. /* --- termhdl.c --- */
  115. HHTERM CreateTerminalHdl(const HWND hwndTerm);
  116. void DestroyTerminalHdl(const HHTERM hhTerm);
  117. BOOL termSysColorChng(const HHTERM hhTerm);
  118. void termSetClrAttr(const HHTERM hhTerm);
  119. BOOL termSetFont(const HHTERM hhTerm, const PLOGFONT plf);
  120. HFONT termMakeFont(const HHTERM hhTerm, const BOOL fUnderline,
  121. const BOOL fHigh, const BOOL fWide, const BOOL fSymbol);
  122. /* --- termcpy.c --- */
  123. int strlentrunc(const ECHAR *pach, const int iLen);
  124. /* --- termmos.c --- */
  125. void TP_WM_LBTNDN(const HWND hwnd, const unsigned uFlags, const int xPos, const int yPos);
  126. void TP_WM_MOUSEMOVE(const HWND hwnd, const unsigned uFlags, const int xPos, const int yPos);
  127. void TP_WM_LBTNUP(const HWND hwnd, const unsigned uFlags, const int xPos, const int yPos);
  128. void TP_WM_LBTNDBLCLK(const HWND hwnd, const unsigned uFlags, const int xPos, const int yPos);
  129. /* --- termcur.c --- */
  130. void ShowCursors(const HHTERM hhTerm);
  131. void HideCursors(const HHTERM hhTerm);
  132. void PaintHostCursor(const HHTERM hhTerm, const BOOL fOn, const HDC hdc);
  133. void PaintLocalCursor(const HHTERM hhTerm, const BOOL fOn, const HDC hdc);
  134. void CALLBACK CursorTimerProc(void *pvhwnd, long ltime);
  135. void LinkCursors(const HHTERM hhTerm);
  136. void SetLclCurPos(const HHTERM hhTerm, const LPPOINT lpptCur);
  137. void MoveSelectionCursor(const HHTERM hhTerm,
  138. const HWND hwnd,
  139. int x,
  140. int y,
  141. BOOL fMarking);
  142. /* --- termutil.c --- */
  143. BOOL termTranslateKey(const HHTERM hhTerm, const HWND hwnd, const KEY_T Key);
  144. void BlinkText(const HHTERM hhTerm);
  145. void termQuerySnapRect(const HHTERM hhTerm, LPRECT prc);
  146. void UnmarkText(const HHTERM hhTerm);
  147. void MarkTextAll(HHTERM hhTerm);
  148. void TestForMarkingLock(const HHTERM hhTerm);
  149. void CALLBACK MarkingTimerProc(void *pvhWnd, long lTime);
  150. void MarkText(const HHTERM hhTerm,
  151. const LPPOINT ptBeg,
  152. const LPPOINT ptEnd,
  153. const BOOL fMark,
  154. const int sMarkingMethod);
  155. BOOL PointInSelectionRange(const PPOINT ppt,
  156. const PPOINT pptBeg,
  157. const PPOINT pptEnd,
  158. const int iCols);
  159. #define VP_NO_ADJUSTMENT 0
  160. #define VP_ADJUST_RIGHT 1
  161. #define VP_ADJUST_LEFT 2
  162. BOOL termValidatePosition(const HHTERM hhTerm,
  163. const int nAdjustmentMode,
  164. POINT *pLocation);
  165. /* --- termupd.c --- */
  166. void termGetUpdate(const HHTERM hhTerm, const int fRedraw);
  167. void termGetBkLines(const HHTERM hhTerm, const int iScrlInc, int yBeg, int sType);
  168. void termFillBk(const HHTERM hhTerm, const int iScrlPos);
  169. /* --- termpnt.c --- */
  170. void termPaint(const HHTERM hhTerm, const HWND hwnd);