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.

268 lines
7.7 KiB

  1. /*===========================================================================*/
  2. /* Copyright (c) 1987 - 1988, Future Soft Engineering, Inc. */
  3. /* Houston, Texas */
  4. /*===========================================================================*/
  5. #define NOLSTRING TRUE /* jtf win3 mod */
  6. #include <windows.h>
  7. #include "port1632.h"
  8. #include "dcrc.h"
  9. #include "dynacomm.h"
  10. /*---------------------------------------------------------------------------*/
  11. /* updateTermScrollBars() - [mbb] */
  12. /*---------------------------------------------------------------------------*/
  13. VOID updateTermScrollBars(BOOL bScroll)
  14. {
  15. INT saveScrollRange, offset;
  16. saveScrollRange = nScrollRange.y;
  17. if((offset = maxScreenLine - visScreenLine) < 0)
  18. offset = 0;
  19. if((nScrollRange.y = savTopLine + offset) < 0)
  20. nScrollRange.y = 0;
  21. if(((nScrollPos.y > 0) && (nScrollPos.y == saveScrollRange)) || (nScrollPos.y > nScrollRange.y))
  22. nScrollPos.y = nScrollRange.y;
  23. if(!trmParams.fHideTermVSB)
  24. {
  25. SetScrollRange(hTermWnd, SB_VERT, 0, (nScrollRange.y > 0) ? nScrollRange.y : 1, FALSE);
  26. if (GetScrollPos(hTermWnd, SB_VERT) != nScrollPos.y) /* jtf 3.14 */
  27. SetScrollPos(hTermWnd, SB_VERT, nScrollPos.y, TRUE);
  28. }
  29. else
  30. SetScrollRange(hTermWnd, SB_VERT, 0, 0, TRUE);
  31. if(!trmParams.fHideTermHSB)
  32. {
  33. SetScrollRange(hTermWnd, SB_HORZ, 0, (nScrollRange.x > 0) ? nScrollRange.x : 1, FALSE);
  34. if (GetScrollPos(hTermWnd, SB_HORZ) != nScrollPos.x) /* jtf 3.14 */
  35. SetScrollPos(hTermWnd, SB_HORZ, nScrollPos.x, TRUE);
  36. }
  37. else
  38. SetScrollRange(hTermWnd, SB_HORZ, 0, 0, TRUE);
  39. if(bScroll)
  40. scrollBits();
  41. }
  42. /*---------------------------------------------------------------------------*/
  43. /* scrollTermWindow() - [mbb] */
  44. /*---------------------------------------------------------------------------*/
  45. proc scrollTermWindow(INT dh, INT dv)
  46. {
  47. ScrollWindow(hTermWnd, -dh*chrWidth, -dv*chrHeight, (LPRECT) &hTE.viewRect,
  48. (LPRECT) &hTE.viewRect);
  49. }
  50. /*---------------------------------------------------------------------------*/
  51. /* scrollTermLine() - [mbb] */
  52. /*---------------------------------------------------------------------------*/
  53. proc scrollTermLine(INT newLine, INT dh, INT dv)
  54. {
  55. RECT r;
  56. getPort();
  57. hTE.active = 0;
  58. if(dv > 0)
  59. r.top = hTE.viewRect.bottom - stdChrHeight;
  60. else
  61. r.top = 0;
  62. r.left = hTE.viewRect.left;
  63. r.bottom = r.top + stdChrHeight;
  64. r.right = hTE.viewRect.right;
  65. scrollTermWindow(dh, dv);
  66. ValidateRect(hTermWnd, (LPRECT) &r);
  67. reDrawTermLine(newLine, 0, maxChars);
  68. clipRect(&r);
  69. termActivate(&hTE);
  70. releasePort();
  71. }
  72. /*---------------------------------------------------------------------------*/
  73. /* scrollBits() - Move text on term. screen + some IT house keeping. [mbb] */
  74. /*---------------------------------------------------------------------------*/
  75. VOID scrollBits()
  76. {
  77. INT oldTopLine;
  78. INT oldLeftCol;
  79. INT dh, dv;
  80. INT offset;
  81. INT lin;
  82. oldLeftCol = curLeftCol;
  83. oldTopLine = curTopLine;
  84. curLeftCol = nScrollPos.x;
  85. curTopLine = nScrollPos.y;
  86. dh = curLeftCol - oldLeftCol;
  87. dv = curTopLine - oldTopLine;
  88. hideTermCursor();
  89. if(dh != 0)
  90. {
  91. scrollTermWindow(dh, dv);
  92. UpdateWindow(hTermWnd);
  93. }
  94. else if(dv == 1)
  95. scrollTermLine(curTopLine-savTopLine+visScreenLine, dh, dv);
  96. else if(dv == -1)
  97. scrollTermLine(curTopLine-savTopLine, dh, dv);
  98. else if(dv != 0)
  99. {
  100. termDeactivate(&hTE);
  101. reDrawTermScreen(0, visScreenLine+1, curTopLine - savTopLine); /* mbbx 2.00: jtf disp2... */
  102. termActivate(&hTE);
  103. }
  104. showTermCursor();
  105. if((curTopLine + visScreenLine) > (savTopLine + maxScreenLine)) /* mbbx 2.00.06: jtf disp2... */
  106. cleanRect(maxScreenLine+1, (visScreenLine + curTopLine) - (savTopLine + maxScreenLine));
  107. }
  108. /*---------------------------------------------------------------------------*/
  109. /* scrollUp() - */
  110. /*---------------------------------------------------------------------------*/
  111. VOID scrollUp(INT nBar, INT partCode, INT deltaLines)
  112. {
  113. LONG *pScrollPos;
  114. if(partCode == SB_LINEUP)
  115. {
  116. pScrollPos = ((nBar == SB_VERT) ? &nScrollPos.y : &nScrollPos.x);
  117. if(*pScrollPos > 0)
  118. {
  119. *pScrollPos -= deltaLines;
  120. updateTermScrollBars(TRUE);
  121. }
  122. }
  123. }
  124. /*---------------------------------------------------------------------------*/
  125. /* scrollDown() - */
  126. /*---------------------------------------------------------------------------*/
  127. VOID scrollDown(INT nBar, INT partCode, INT deltaLines)
  128. {
  129. LONG *pScrollRange, *pScrollPos;
  130. if(partCode == SB_LINEDOWN)
  131. {
  132. if(nBar == SB_VERT)
  133. {
  134. pScrollRange = &nScrollRange.y;
  135. pScrollPos = &nScrollPos.y;
  136. }
  137. else
  138. {
  139. pScrollRange = &nScrollRange.x;
  140. pScrollPos = &nScrollPos.x;
  141. }
  142. if(*pScrollPos < *pScrollRange)
  143. {
  144. *pScrollPos += deltaLines;
  145. updateTermScrollBars(TRUE);
  146. }
  147. }
  148. }
  149. /*---------------------------------------------------------------------------*/
  150. /* pageScroll() - */
  151. /*---------------------------------------------------------------------------*/
  152. VOID pageScroll(INT which)
  153. {
  154. if(which == SB_PAGEUP)
  155. {
  156. if((nScrollPos.y -= (visScreenLine + 1)) < 0)
  157. nScrollPos.y = 0;
  158. }
  159. else
  160. {
  161. if((nScrollPos.y += (visScreenLine + 1)) > nScrollRange.y)
  162. nScrollPos.y = nScrollRange.y;
  163. }
  164. updateTermScrollBars(TRUE);
  165. termCleanUp();
  166. }
  167. /*---------------------------------------------------------------------------*/
  168. /* hPageScroll() - */
  169. /*---------------------------------------------------------------------------*/
  170. VOID hPageScroll(INT which)
  171. {
  172. nScrollPos.x = ((which == SB_PAGEUP) ? 0 : nScrollRange.x);
  173. updateTermScrollBars(TRUE);
  174. termCleanUp(); /* mbbx 1.04: per jtfx */
  175. }
  176. /*---------------------------------------------------------------------------*/
  177. /* trackScroll() - [scf] */
  178. /*---------------------------------------------------------------------------*/
  179. VOID trackScroll(INT nBar, INT partCode)
  180. {
  181. LONG *pScrollRange, *pScrollPos;
  182. INT amount;
  183. if(nBar == SB_VERT)
  184. {
  185. pScrollRange = &nScrollRange.y;
  186. pScrollPos = &nScrollPos.y;
  187. }
  188. else
  189. {
  190. pScrollRange = &nScrollRange.x;
  191. pScrollPos = &nScrollPos.x;
  192. }
  193. amount = (((partCode == SB_LINEUP) || (partCode == SB_PAGEUP)) ? -1 : 1);
  194. if(((amount == -1) && (*pScrollPos > 0)) || ((amount == 1) && (*pScrollPos < *pScrollRange)))
  195. {
  196. if((partCode == SB_PAGEUP) || (partCode == SB_PAGEDOWN))
  197. {
  198. if(nBar == SB_VERT)
  199. {
  200. if(amount == -1)
  201. {
  202. if((*pScrollPos -= ((hTE.viewRect.bottom - hTE.viewRect.top) / chrHeight)) < 0)
  203. *pScrollPos = 0;
  204. }
  205. else
  206. {
  207. if((*pScrollPos += ((hTE.viewRect.bottom - hTE.viewRect.top) / chrHeight)) > *pScrollRange)
  208. *pScrollPos = *pScrollRange;
  209. }
  210. }
  211. else
  212. *pScrollPos += ((amount == -1) ? 0 : *pScrollRange);
  213. }
  214. else
  215. *pScrollPos += amount;
  216. updateTermScrollBars(FALSE);
  217. }
  218. }