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.

455 lines
7.8 KiB

  1. /*++
  2. Copyright (c) 1985 - 1999, Microsoft Corporation
  3. Module Name:
  4. dbcs.h
  5. Abstract:
  6. Author:
  7. Revision History:
  8. --*/
  9. #define UNICODE_DBCS_PADDING 0xffff
  10. #define DEFAULT_FONTSIZE 256
  11. #define DEFAULT_EUDCSIZE 1
  12. #define VDM_EUDC_FONT_SIZE_X 16
  13. #define VDM_EUDC_FONT_SIZE_Y 16
  14. #define USACP 1252
  15. #define KOREAN_CP 949
  16. #define JAPAN_CP 932
  17. #if defined(FE_SB)
  18. #define MIN_SCRBUF_WIDTH 12 // for suport display IME status
  19. #define MIN_SCRBUF_HEIGHT 2 // for suport display IME status
  20. #define MIN_WINDOW_HEIGHT 1
  21. #endif
  22. #if defined(i386)
  23. extern ULONG gdwMachineId;
  24. #endif
  25. extern ULONG DefaultFontIndex;
  26. extern COORD DefaultFontSize;
  27. extern BYTE DefaultFontFamily;
  28. typedef struct _MODE_FONT_PAIR {
  29. DWORD Mode;
  30. #define FS_MODE_TEXT 0x0001
  31. #define FS_MODE_GRAPHICS 0x0002
  32. #define FS_MODE_FIND 0x8000
  33. #define FS_TEXT (FS_MODE_FIND+FS_MODE_TEXT)
  34. #define FS_GRAPHICS (FS_MODE_FIND+FS_MODE_GRAPHICS)
  35. COORD ScreenSize;
  36. COORD Resolution;
  37. COORD FontSize;
  38. } MODE_FONT_PAIR, *PMODE_FONT_PAIR;
  39. typedef struct _FS_CODEPAGE {
  40. SINGLE_LIST_ENTRY List;
  41. UINT CodePage;
  42. } FS_CODEPAGE, *PFS_CODEPAGE;
  43. extern PUSHORT RegInitialPalette;
  44. extern PUCHAR RegColorBuffer;
  45. extern PUCHAR RegColorBufferNoTranslate;
  46. extern DWORD NUMBER_OF_MODE_FONT_PAIRS;
  47. extern PMODE_FONT_PAIR RegModeFontPairs;
  48. extern SINGLE_LIST_ENTRY gRegFullScreenCodePage; // This list contain FS_CODEPAGE data.
  49. typedef struct tagSTRINGBITMAP
  50. {
  51. UINT uiWidth;
  52. UINT uiHeight;
  53. BYTE ajBits[1];
  54. } STRINGBITMAP, *LPSTRINGBITMAP;
  55. UINT
  56. GetStringBitmapW(
  57. HDC hdc,
  58. LPWSTR pwc,
  59. UINT cwc,
  60. UINT cbData,
  61. BYTE *pSB
  62. );
  63. //
  64. // dbcs.c
  65. //
  66. #if defined(FE_IME)
  67. #if defined(i386)
  68. NTSTATUS
  69. ImeWmFullScreen(
  70. IN BOOL Foreground,
  71. IN PCONSOLE_INFORMATION Console,
  72. IN PSCREEN_INFORMATION ScreenInfo
  73. );
  74. #endif // i386
  75. NTSTATUS
  76. GetImeKeyState(
  77. IN PCONSOLE_INFORMATION Console,
  78. IN PDWORD pdwConversion
  79. );
  80. NTSTATUS
  81. SetImeKeyState(
  82. IN PCONSOLE_INFORMATION Console,
  83. IN DWORD fdwConversion
  84. );
  85. NTSTATUS
  86. SetImeCodePage(
  87. IN PCONSOLE_INFORMATION Console
  88. );
  89. NTSTATUS
  90. SetImeOutputCodePage(
  91. IN PCONSOLE_INFORMATION Console,
  92. IN PSCREEN_INFORMATION ScreenInfo,
  93. IN DWORD CodePage
  94. );
  95. #endif // FE_IME
  96. VOID
  97. SetLineChar(
  98. IN PSCREEN_INFORMATION ScreenInfo
  99. );
  100. BOOL
  101. CheckBisectStringA(
  102. IN DWORD CodePage,
  103. IN PCHAR Buffer,
  104. IN DWORD NumBytes,
  105. IN LPCPINFO lpCPInfo
  106. );
  107. VOID
  108. BisectWrite(
  109. IN SHORT StringLength,
  110. IN COORD TargetPoint,
  111. IN PSCREEN_INFORMATION ScreenInfo
  112. );
  113. VOID
  114. BisectClipbrd(
  115. IN SHORT StringLength,
  116. IN COORD TargetPoint,
  117. IN PSCREEN_INFORMATION ScreenInfo,
  118. OUT PSMALL_RECT SmallRect
  119. );
  120. VOID
  121. BisectWriteAttr(
  122. IN SHORT StringLength,
  123. IN COORD TargetPoint,
  124. IN PSCREEN_INFORMATION ScreenInfo
  125. );
  126. DWORD
  127. RemoveDbcsMark(
  128. IN PWCHAR Dst,
  129. IN PWCHAR Src,
  130. IN DWORD NumBytes,
  131. IN PCHAR SrcA,
  132. IN BOOL OS2OemFormat
  133. );
  134. DWORD
  135. RemoveDbcsMarkCell(
  136. IN PCHAR_INFO Dst,
  137. IN PCHAR_INFO Src,
  138. IN DWORD NumBytes
  139. );
  140. DWORD
  141. RemoveDbcsMarkAll(
  142. IN PSCREEN_INFORMATION ScreenInfo,
  143. IN PROW Row,
  144. IN PSHORT LeftChar,
  145. IN PRECT TextRect,
  146. IN int *TextLeft,
  147. IN PWCHAR Buffer,
  148. IN SHORT NumberOfChars
  149. );
  150. BOOL
  151. IsDBCSLeadByteConsole(
  152. IN BYTE AsciiChar,
  153. IN LPCPINFO lpCPInfo
  154. );
  155. NTSTATUS
  156. AdjustFont(
  157. IN PCONSOLE_INFORMATION Console,
  158. IN UINT CodePage
  159. );
  160. NTSTATUS
  161. ConvertToCodePage(
  162. IN PCONSOLE_INFORMATION Console,
  163. IN UINT PrevCodePage
  164. );
  165. NTSTATUS
  166. ConvertOutputOemToNonOemUnicode(
  167. IN OUT LPWSTR Source,
  168. IN OUT PBYTE KAttrRows,
  169. IN int SourceLength, // in chars
  170. IN UINT Codepage
  171. );
  172. VOID
  173. TextOutEverything(
  174. IN PCONSOLE_INFORMATION Console,
  175. IN PSCREEN_INFORMATION ScreenInfo,
  176. IN SHORT LeftWindowPos,
  177. IN OUT PSHORT RightWindowPos,
  178. IN OUT PSHORT CountOfAttr,
  179. IN SHORT CountOfAttrOriginal,
  180. IN OUT PBOOL DoubleColorDBCS,
  181. IN BOOL LocalEUDCFlag,
  182. IN PROW Row,
  183. IN PATTR_PAIR Attr,
  184. IN SHORT LeftTextPos,
  185. IN SHORT RightTextPos,
  186. IN int WindowRectLeft,
  187. IN RECT WindowRect,
  188. IN SHORT NumberOfChars
  189. );
  190. VOID
  191. TextOutCommonLVB(
  192. IN PCONSOLE_INFORMATION Console,
  193. IN WORD Attributes,
  194. IN RECT CommonLVBRect
  195. );
  196. NTSTATUS
  197. MakeAltRasterFont(
  198. UINT CodePage,
  199. COORD DefaultFontSize,
  200. COORD *AltFontSize,
  201. BYTE *AltFontFamily,
  202. ULONG *AltFontIndex,
  203. LPWSTR AltFaceName
  204. );
  205. NTSTATUS
  206. InitializeDbcsMisc(
  207. VOID
  208. );
  209. #if defined(i386)
  210. NTSTATUS
  211. RealUnicodeToNEC_OS2_Unicode(
  212. IN OUT LPWSTR Source,
  213. IN int SourceLength // in chars
  214. );
  215. BOOL
  216. InitializeNEC_OS2_CP(
  217. VOID
  218. );
  219. #endif
  220. BYTE
  221. CodePageToCharSet(
  222. UINT CodePage
  223. );
  224. BOOL
  225. IsAvailableFarEastCodePage(
  226. UINT CodePage
  227. );
  228. LPTTFONTLIST
  229. SearchTTFont(
  230. LPWSTR pwszFace,
  231. BOOL fCodePage,
  232. UINT CodePage
  233. );
  234. BOOL
  235. IsAvailableTTFont(
  236. LPWSTR pwszFace
  237. );
  238. BOOL
  239. IsAvailableTTFontCP(
  240. LPWSTR pwszFace,
  241. UINT CodePage
  242. );
  243. LPWSTR
  244. GetAltFaceName(
  245. LPWSTR pwszFace
  246. );
  247. BOOL
  248. IsAvailableFsCodePage(
  249. UINT CodePage
  250. );
  251. #if defined(FE_IME)
  252. VOID
  253. ProcessCreateConsoleIME(
  254. IN LPMSG lpMsg,
  255. DWORD dwConsoleThreadId
  256. );
  257. NTSTATUS
  258. InitConsoleIMEStuff(
  259. HDESK hDesktop,
  260. DWORD dwConsoleThreadId,
  261. PCONSOLE_INFORMATION Console
  262. );
  263. NTSTATUS
  264. WaitConsoleIMEStuff(
  265. HDESK hDesktop,
  266. HANDLE hThread
  267. );
  268. NTSTATUS
  269. ConSrvRegisterConsoleIME(
  270. PCSR_PROCESS Process,
  271. HDESK hDesktop,
  272. HWINSTA hWinSta,
  273. HWND hWndConsoleIME,
  274. DWORD dwConsoleIMEThreadId,
  275. DWORD dwAction,
  276. DWORD *dwConsoleThreadId
  277. );
  278. VOID
  279. RemoveConsoleIME(
  280. PCSR_PROCESS Process,
  281. DWORD dwConsoleIMEThreadId
  282. );
  283. NTSTATUS
  284. ConsoleImeMessagePumpWorker(
  285. PCONSOLE_INFORMATION Console,
  286. UINT Message,
  287. WPARAM wParam,
  288. LPARAM lParam,
  289. LRESULT* lplResult);
  290. NTSTATUS
  291. ConsoleImeMessagePump(
  292. PCONSOLE_INFORMATION Console,
  293. UINT Message,
  294. WPARAM wParam,
  295. LPARAM lParam
  296. );
  297. #endif // FE_IME
  298. BOOL
  299. RegisterKeisenOfTTFont(
  300. IN PSCREEN_INFORMATION ScreenInfo
  301. );
  302. ULONG
  303. TranslateUnicodeToOem(
  304. IN PCONSOLE_INFORMATION Console,
  305. IN PWCHAR UnicodeBuffer,
  306. IN ULONG UnicodeCharCount,
  307. OUT PCHAR AnsiBuffer,
  308. IN ULONG AnsiByteCount,
  309. OUT PINPUT_RECORD DbcsLeadInpRec
  310. );
  311. DWORD
  312. ImmConversionToConsole(
  313. DWORD fdwConversion
  314. );
  315. DWORD
  316. ImmConversionFromConsole(
  317. DWORD dwNlsMode
  318. );
  319. //#define DBG_KAZUM
  320. //#define DBG_KATTR
  321. #if defined(DBG) && defined(DBG_KATTR)
  322. VOID
  323. BeginKAttrCheck(
  324. IN PSCREEN_INFORMATION ScreenInfo
  325. );
  326. #endif
  327. //
  328. // output.c
  329. //
  330. BOOL
  331. CreateDbcsScreenBuffer(
  332. IN PCONSOLE_INFORMATION Console,
  333. IN COORD dwScreenBufferSize,
  334. OUT PDBCS_SCREEN_BUFFER DbcsScreenBuffer
  335. );
  336. BOOL
  337. DeleteDbcsScreenBuffer(
  338. IN PDBCS_SCREEN_BUFFER DbcsScreenBuffer
  339. );
  340. BOOL
  341. ReCreateDbcsScreenBuffer(
  342. IN PCONSOLE_INFORMATION Console,
  343. IN UINT OldCodePage
  344. );
  345. BOOL
  346. FE_PolyTextOutCandidate(
  347. IN PSCREEN_INFORMATION ScreenInfo,
  348. IN PSMALL_RECT Region
  349. );
  350. VOID
  351. FE_ConsolePolyTextOut(
  352. IN PSCREEN_INFORMATION ScreenInfo,
  353. IN PSMALL_RECT Region
  354. );
  355. //
  356. // private.c
  357. //
  358. NTSTATUS
  359. SetRAMFontCodePage(
  360. IN PSCREEN_INFORMATION ScreenInfo
  361. );
  362. NTSTATUS
  363. SetRAMFont(
  364. IN PSCREEN_INFORMATION ScreenInfo,
  365. IN PCHAR_INFO ScreenBufPtr,
  366. IN DWORD Length
  367. );