Changeset 142 for Include/basic/prompt.sbp
- Timestamp:
- Mar 9, 2007, 10:15:34 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Include/basic/prompt.sbp
r137 r142 8 8 #require <api_imm.sbp> 9 9 #require <Classes/System/Math.ab> 10 11 Function _PromptSys_GetTextExtentPoint32(hdc As HDC, psz As PCSTR, cb As Long, ByRef Size As SIZE) As Long 12 _PromptSys_GetTextExtentPoint32 = GetTextExtentPoint32A(hdc, psz, cb, Size) 13 End Function 14 15 Function _PromptSys_GetTextExtentPoint32(hdc As HDC, psz As PCWSTR, cb As Long, ByRef Size As SIZE) As Long 16 _PromptSys_GetTextExtentPoint32 = GetTextExtentPoint32W(hdc, psz, cb, Size) 17 End Function 18 19 Function _PromptSys_TextOut(hdc As HDC, x As Long, y As Long, psz As PCSTR, cb As Long) As Long 20 _PromptSys_TextOut = TextOutA(hdc, x, y, psz, cb) 21 End Function 22 23 Function _PromptSys_TextOut(hdc As HDC, x As Long, y As Long, psz As PCWSTR, cb As Long) As Long 24 _PromptSys_TextOut = TextOutW(hdc, x, y, psz, cb) 25 End Function 26 27 Function _PromptSys_ImmGetCompositionString(himc As HIMC, index As DWord, pBuf As PSTR, bufLen As DWord) As Long 28 _PromptSys_ImmGetCompositionString = ImmGetCompositionStringA(himc, index, pBuf, bufLen) 29 End Function 30 31 Function _PromptSys_ImmGetCompositionString(himc As HIMC, index As DWord, pBuf As PWSTR, bufLen As DWord) As Long 32 _PromptSys_ImmGetCompositionString = ImmGetCompositionStringW(himc, index, pBuf, bufLen) 33 End Function 10 34 11 35 Dim _PromptSys_hWnd As HWND … … 22 46 Type _PromptSys_LineInformation 23 47 Length As Long 24 Text As * Char48 Text As *StrChar 25 49 CharInfo As *_PromptSys_CharacterInformation 26 50 End Type … … 29 53 Dim _PromptSys_hFont As HFONT 30 54 Dim _PromptSys_FontSize As SIZE 31 Dim _PromptSys_InputStr[255] As Char55 Dim _PromptSys_InputStr[255] As StrChar 32 56 Dim _PromptSys_InputLen As Long 33 57 Dim _PromptSys_KeyChar As Byte … … 38 62 Dim _PromptSys_SectionOfBufferAccess As CRITICAL_SECTION 39 63 64 Dim _System_OSVersionInfo As OSVERSIONINFO 40 65 41 66 _PromptSys_InputLen = -1 … … 48 73 49 74 _PromptSys_hInitFinish = CreateEvent(0, FALSE, FALSE, 0) 50 CreateThread(0, 0, AddressOf(PromptMain) As LPTHREAD_START_ROUTINE, 0, 0, _PromptSys_dwThreadID) 75 Dim _PromptSys_hThread As HANDLE 76 _PromptSys_hThread = CreateThread(0, 0, AddressOf(PromptMain) As LPTHREAD_START_ROUTINE, 0, 0, _PromptSys_dwThreadID) 77 If _PromptSys_hThread = 0 Then 78 Debug 79 ExitProcess(1) 80 End If 51 81 WaitForSingleObject(_PromptSys_hInitFinish, INFINITE) 52 82 … … 68 98 Next 69 99 _PromptSys_TextLine[100].Length = 0 70 _PromptSys_TextLine[100].Text = _System_calloc(SizeOf ( Char) * 255)100 _PromptSys_TextLine[100].Text = _System_calloc(SizeOf (StrChar) * 255) 71 101 _PromptSys_TextLine[100].CharInfo = _System_calloc(SizeOf (_PromptSys_CharacterInformation) * 255) 72 102 _PromptSys_CurPos.y-- … … 83 113 Dim sz As SIZE 84 114 i3 = _PromptSys_TextLine[i].Length 85 GetTextExtentPoint32(hDC, _PromptSys_TextLine[i].Text, i3, sz)115 _PromptSys_GetTextExtentPoint32(hDC, _PromptSys_TextLine[i].Text, i3, sz) 86 116 87 117 BitBlt(hDC,_ … … 106 136 End If 107 137 With _PromptSys_FontSize 108 TextOut(hDC, currentLineCharInfo[i2].StartPos, i * .cy, VarPtr(_PromptSys_TextLine[i].Text[i2]), tempLen)138 _PromptSys_TextOut(hDC, currentLineCharInfo[i2].StartPos, i * .cy, VarPtr(_PromptSys_TextLine[i].Text[i2]) As *StrChar, tempLen) 109 139 End With 110 140 i2 += tempLen … … 127 157 Dim doubleUnitChar = False As Boolean 128 158 'Addition 129 Dim i2 = 0 As Long, i3 As Long ' : Debug159 Dim i2 = 0 As Long, i3 As Long 130 160 For i2 = 0 To ELM(bufLen) 131 161 If buf[i2] = &h0d Then 'CR \r … … 158 188 charLen = 1 159 189 EndIf 160 GetTextExtentPoint32(hdc, VarPtr(buf.Chars[i2]), charLen, sz)190 _PromptSys_GetTextExtentPoint32(hdc, VarPtr(buf.Chars[i2]) As *StrChar, charLen, sz) 161 191 currentLineCharInfo[.x + 1].StartPos = currentLineCharInfo[.x].StartPos + sz.cx 162 192 /* … … 305 335 TempStr = Ex"\r\n" 306 336 ElseIf wParam = &H16 Then 337 /* 307 338 'Paste Command(Use Clippboard) 308 339 OpenClipboard(hwnd) … … 324 355 GlobalUnlock(hGlobal) 325 356 CloseClipboard() 357 */ 326 358 Else 327 359 _PromptSys_InputStr[_PromptSys_InputLen] = wParam As Byte … … 337 369 End If 338 370 End Sub 371 372 Function _PromptWnd_GetCompositionStringW(himc As HIMC, ByRef rpsz As PWSTR) As Long 373 Dim size = ImmGetCompositionStringW(himc, GCS_RESULTSTR, 0, 0) 'sizeはバイト単位 374 rpsz = _System_malloc(size) As PTSTR 375 If rpsz = 0 Then 376 'Debug 377 Return 0 378 End If 379 Return ImmGetCompositionStringW(himc, GCS_RESULTSTR, rpsz, size) 380 End Function 381 382 Function _PromptWnd_GetCompositionStringA(himc As HIMC, ByRef rpsz As PSTR) As Long 383 Dim size = ImmGetCompositionStringA(himc, GCS_RESULTSTR, 0, 0) 'sizeはバイト単位 384 rpsz = _System_malloc(size) As PTSTR 385 If rpsz = 0 Then 386 'Debug 387 Return 0 388 End If 389 Return ImmGetCompositionStringA(himc, GCS_RESULTSTR, rpsz, size) 390 End Function 339 391 340 392 Function _PromptWnd_OnImeCompostion(hwnd As HWND, wp As WPARAM, lp As LPARAM) As LRESULT … … 345 397 Return 0 346 398 End If 347 Dim size = ImmGetCompositionString(himc, GCS_RESULTSTR, 0, 0) 'sizeはバイト単位 348 Dim str = _System_malloc(size) As PTSTR 349 If str = 0 Then 350 'Debug 351 Return 0 352 End If 353 ImmGetCompositionString(himc, GCS_RESULTSTR, str, size) 399 Dim tempStr As String 400 Dim str As *StrChar 401 #ifdef __STIRNG_IS_NOT_UNICODE 402 Dim size = _PromptWnd_GetCompositionStringA(himc, str) 403 tempStr.Assign(str, size) 404 #else 405 With _System_OSVersionInfo 406 ' GetCompositionStringW is not implimented in Windows 95 407 If .dwMajorVersion = 4 And .dwMinorVersion = 0 And .dwPlatformId = VER_PLATFORM_WIN32_WINDOWS Then 408 Dim strA As PCSTR 409 Dim sizeA = _PromptWnd_GetCompositionStringA(himc, strA) 410 tempStr.AssignFromMultiByte(strA, sizeA) 411 Else 412 Dim size = _PromptWnd_GetCompositionStringW(himc, str) 413 tempStr.Assign(str, size \ SizeOf (WCHAR)) 414 End If 415 End With 416 #endif 354 417 ImmReleaseContext(hwnd, himc) 355 356 memcpy(VarPtr(_PromptSys_InputStr[_PromptSys_InputLen]), str, size)357 _PromptSys_InputLen += size \ SizeOf (Char)358 359 Dim tempStr As String(str, size \ SizeOf (Char))360 418 _System_free(str) 361 419 362 SendMessage(hwnd, WM_KILLFOCUS, 0, 0) 420 memcpy(VarPtr(_PromptSys_InputStr[_PromptSys_InputLen]), tempStr.Chars, SizeOf (StrChar) * tempStr.Length) 421 _PromptSys_InputLen += tempStr.Length 422 423 SendMessage(hwnd, WM_KILLFOCUS, 0, 0) : Debug 363 424 PRINT_ToPrompt(tempStr) 364 425 SendMessage(hwnd, WM_SETFOCUS, 0, 0) … … 371 432 372 433 Function PromptMain(dwData As Long) As Long 434 GetVersionEx(_System_OSVersionInfo) 435 373 436 Dim i As Long 374 375 437 'Allocate 376 438 For i = 0 To 100 377 439 With _PromptSys_TextLine[i] 378 440 .Length = 0 379 .Text = _System_calloc(SizeOf ( Char) * 255)441 .Text = _System_calloc(SizeOf (StrChar) * 255) 380 442 .CharInfo = _System_calloc(SizeOf (_PromptSys_CharacterInformation) * 255) 381 443 End With … … 515 577 '---------------------------------------------- 516 578 Sub INPUT_FromPrompt(ShowStr As String) 517 Dim i As Long ,i2 As Long, i3 As Long579 Dim i As Long, i2 As Long, i3 As Long 518 580 Dim buf As String 519 581
Note:
See TracChangeset
for help on using the changeset viewer.