Ignore:
Timestamp:
Feb 23, 2008, 5:37:00 PM (16 years ago)
Author:
イグトランス (egtra)
Message:

UTF8Encoding(仮)の追加

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Include/basic/prompt.sbp

    r288 r411  
    44#ifndef _INC_PROMPT
    55#define _INC_PROMPT
    6 
    7 #require <api_imm.sbp>
    8 #require <Classes/System/Math.ab>
    9 #require <Classes/System/Environment.ab>
    106
    117Namespace ActiveBasic
     
    2319Function _PromptSys_TextOut(hdc As HDC, x As Long, y As Long, psz As PCSTR, cb As Long) As Long
    2420    _PromptSys_TextOut = TextOutA(hdc, x, y, psz, cb)
     21    If _PromptSys_TextOut = 0 Then Debug
    2522End Function
    2623
     
    6562Dim _PromptSys_SectionOfBufferAccess As CRITICAL_SECTION
    6663
    67 Dim _System_OSVersionInfo As OSVERSIONINFO
    68 
    6964
    7065'graphic
     
    8681Sub DrawPromptBuffer(hDC As HDC, StartLine As Long, EndLine As Long)
    8782    Dim i As Long, i2 As Long, i3 As Long
     83    Dim ret As Long
    8884
    8985    Dim hOldFont = SelectObject(hDC, _PromptSys_hFont) As HFONT
     
    118114            _PromptSys_GetTextExtentPoint32(hDC, _PromptSys_TextLine[i].Text, i3, sz)
    119115
    120             BitBlt(hDC,_
    121                 sz.cx, i * _PromptSys_FontSize.cy, _
    122                 rc.right, _PromptSys_FontSize.cy, _
    123                 _PromptSys_hMemDC, sz.cx, i * _PromptSys_FontSize.cy, SRCCOPY)
     116'           BitBlt(hDC,_
     117'               sz.cx, i * _PromptSys_FontSize.cy, _
     118'               rc.right, _PromptSys_FontSize.cy, _
     119'               _PromptSys_hMemDC, sz.cx, i * _PromptSys_FontSize.cy, SRCCOPY)
    124120
    125121            While i2 < i3
     
    128124                    SetBkMode(hDC, TRANSPARENT)
    129125                Else
    130                     SetBkMode(hDC, OPAQUE)
    131                     SetBkColor(hDC, currentLineCharInfo[i2].BackColor)
     126                    Debug
     127                    ret = SetBkMode(hDC, OPAQUE)
     128                    ret = SetBkColor(hDC, currentLineCharInfo[i2].BackColor)
    132129                End If
    133130
     
    152149
    153150Sub PRINT_ToPrompt(buf As String)
     151    OutputDebugString(ToTCStr(Ex"PRINT_ToPrompt " + buf + Ex"\r\n"))
    154152    EnterCriticalSection(_PromptSys_SectionOfBufferAccess)
     153    If buf = "あ" Then Debug
    155154    With _PromptSys_CurPos
    156155        Dim hdc = GetDC(_PromptSys_hWnd)
    157156        Dim hOldFont = SelectObject(hdc, _PromptSys_hFont)
    158         Dim StartLine As Long : StartLine = .y
     157        Dim StartLine = .y As Long
    159158        Dim bufLen = buf.Length
    160159        Dim doubleUnitChar = False As Boolean
     
    194193                        _PromptSys_GetTextExtentPoint32(hdc, VarPtr(p[i2]) As *StrChar, charLen, sz)
    195194                        currentLineCharInfo[.x + 1].StartPos = currentLineCharInfo[.x].StartPos + sz.cx
    196 /*
    197                         Dim buf[1023] As Char
    198                         wsprintf(buf, Ex"%d %d\r\n", currentLineCharInfo[.x + 1].StartPos, currentLineCharInfo[.x].StartPos + sz.cx)
    199                         OutputDebugString(buf)
    200 */
    201195                    End If
    202196                End If
     
    207201
    208202        'Draw the text buffer added
    209         DrawPromptBuffer(hdc, StartLine, .y)
     203        'DrawPromptBuffer(hdc, StartLine, .y)
     204        InvalidateRect(_PromptSys_hWnd, ByVal 0, TRUE)
     205        UpdateWindow(_PromptSys_hWnd)
    210206        SelectObject(hdc, hOldFont)
    211207        ReleaseDC(_PromptSys_hWnd, hdc)
     
    262258        .cy = tm.tmHeight
    263259    End With
     260
     261    '_PromptSys_hFont initialize
     262    Dim lf As LOGFONT
     263    With lf
     264        .lfHeight = -MulDiv(12, GetDeviceCaps(hdc, LOGPIXELSY), 72)
     265        .lfWidth = 0
     266        .lfEscapement = 0
     267        .lfOrientation = 0
     268        .lfWeight = 0
     269        .lfItalic = 0
     270        .lfUnderline = 0
     271        .lfStrikeOut = 0
     272        .lfCharSet = SHIFTJIS_CHARSET
     273        .lfOutPrecision = OUT_DEFAULT_PRECIS
     274        .lfClipPrecision = CLIP_DEFAULT_PRECIS
     275        .lfQuality = DEFAULT_QUALITY
     276        .lfPitchAndFamily = FIXED_PITCH
     277        lstrcpy(.lfFaceName, ToTCStr("MS 明朝"))
     278    End With
     279
     280    _PromptSys_hFont = CreateFontIndirect(lf)
    264281
    265282    ReleaseDC(hwnd, hdc)
     
    378395Function _PromptWnd_GetCompositionStringW(himc As HIMC, ByRef rpsz As PWSTR) As Long
    379396    Dim size = ImmGetCompositionStringW(himc, GCS_RESULTSTR, 0, 0) 'sizeはバイト単位
    380     rpsz = _System_malloc(size) As PWSTR
     397    rpsz = GC_malloc(size) As PWSTR
    381398    If rpsz = 0 Then
    382399        'Debug
     
    388405Function _PromptWnd_GetCompositionStringA(himc As HIMC, ByRef rpsz As PSTR) As Long
    389406    Dim size = ImmGetCompositionStringA(himc, GCS_RESULTSTR, 0, 0) 'sizeはバイト単位
    390     rpsz = _System_malloc(size) As PSTR
     407    rpsz = GC_malloc(size) As PSTR
    391408    If rpsz = 0 Then
    392409        'Debug
     
    423440#endif
    424441        ImmReleaseContext(hwnd, himc)
    425         _System_free(str)
    426442
    427443        ActiveBasic.Strings.ChrCopy(VarPtr(_PromptSys_InputStr[_PromptSys_InputLen]), tempStr.StrPtr, tempStr.Length As SIZE_T)
     
    439455
    440456Function PromptMain(dwData As Long) As Long
    441     GetVersionEx(_System_OSVersionInfo)
    442 
    443457    Dim i As Long
    444458    'Allocate
     
    460474        .cy = GetSystemMetrics(SM_CYSCREEN)
    461475    End With
    462 
    463     '_PromptSys_hFont initialize
    464     Dim lf As LOGFONT
    465     With lf
    466         .lfHeight = -16
    467         .lfWidth = 0
    468         .lfEscapement = 0
    469         .lfOrientation = 0
    470         .lfWeight = 0
    471         .lfItalic = 0
    472         .lfUnderline = 0
    473         .lfStrikeOut = 0
    474         .lfCharSet = SHIFTJIS_CHARSET
    475         .lfOutPrecision = OUT_DEFAULT_PRECIS
    476         .lfClipPrecision = CLIP_DEFAULT_PRECIS
    477         .lfQuality = DEFAULT_QUALITY
    478         .lfPitchAndFamily = FIXED_PITCH
    479         lstrcpy(.lfFaceName, ToTCStr("MS 明朝"))
    480     End With
    481 
    482     _PromptSys_hFont = CreateFontIndirect(lf)
    483476
    484477    'Critical Section
     
    604597            Goto *InputReStart
    605598        End If
    606         _System_Input_SetArgument(_System_InputDataPtr[i], _System_InputDataType[i], broken[i].ToString)
     599        _System_Input_SetArgument(_System_InputDataPtr[i], _System_InputDataType[i], broken[i])
    607600    Next
    608601
     
    624617    Dim i = _PromptSys_TextLine[y].Length
    625618    If i < x Then
    626         _System_FillChar(VarPtr(_PromptSys_TextLine[y].Text[i]), x - i, &h20 As StrChar) 'Asc(" ")
     619        ActiveBasic.Strings.ChrFill(VarPtr(_PromptSys_TextLine[y].Text[i]), x - i, &h20 As StrChar) 'Asc(" ")
    627620        Dim i2 As Long
    628621        For i2 = i To ELM(x)
     
    664657        Ellipse(_PromptSys_hMemDC,x-radius,y-radi2,x+radius,y+radi2)
    665658    Else
    666         Dim sw As Long
     659        Dim sw As Boolean
    667660        StartPos *=StartPos
    668661        EndPos *=EndPos
    669662
    670663        If StartPos<0 Or EndPos<0 Then
    671             sw=1
     664            sw = True
    672665        Else
    673             sw=0
     666            sw = False
    674667        End If
    675668
Note: See TracChangeset for help on using the changeset viewer.