[1] | 1 | 'prompt.sbp
|
---|
| 2 |
|
---|
| 3 |
|
---|
| 4 | #ifndef _INC_PROMPT
|
---|
| 5 | #define _INC_PROMPT
|
---|
| 6 |
|
---|
| 7 |
|
---|
| 8 | #include <api_imm.sbp>
|
---|
| 9 |
|
---|
| 10 | Dim _PromptSys_hWnd As HWND
|
---|
| 11 | Dim _PromptSys_dwThreadID As DWord
|
---|
[90] | 12 | Dim _PromptSys_bInitFinish As BOOL
|
---|
[1] | 13 |
|
---|
| 14 | 'text
|
---|
[121] | 15 | Dim _PromptSys_LogFont As LOGFONTA 'LOGFONT
|
---|
[1] | 16 | Dim _PromptSys_hFont As HFONT
|
---|
| 17 | Dim _PromptSys_FontSize As SIZE
|
---|
[110] | 18 | Dim _PromptSys_InputStr[255] As Char
|
---|
[1] | 19 | Dim _PromptSys_InputLen As Long
|
---|
| 20 | Dim _PromptSys_KeyChar As Byte
|
---|
| 21 | Dim _PromptSys_CurPos As POINTAPI
|
---|
[110] | 22 | Dim _PromptSys_Buffer[100] As *Char
|
---|
[121] | 23 | Dim _PromptSys_TextColor[100] As *COLORREF
|
---|
| 24 | Dim _PromptSys_BackColor[100] As *COLORREF
|
---|
| 25 | Dim _PromptSys_NowTextColor As COLORREF
|
---|
| 26 | Dim _PromptSys_NowBackColor As COLORREF
|
---|
[1] | 27 | Dim _PromptSys_SectionOfBufferAccess As CRITICAL_SECTION
|
---|
| 28 |
|
---|
| 29 |
|
---|
| 30 | _PromptSys_InputLen=-1
|
---|
| 31 |
|
---|
| 32 | 'graphic
|
---|
| 33 | Dim _PromptSys_hBitmap As HBITMAP
|
---|
| 34 | Dim _PromptSys_hMemDC As HDC
|
---|
| 35 | Dim _PromptSys_ScreenSize As SIZE
|
---|
| 36 | Dim _PromptSys_GlobalPos As POINTAPI
|
---|
| 37 |
|
---|
| 38 |
|
---|
| 39 | _PromptSys_bInitFinish=0
|
---|
[121] | 40 | CreateThread( _
|
---|
[1] | 41 | 0,
|
---|
| 42 | 0,
|
---|
| 43 | AddressOf(PromptMain) As LPTHREAD_START_ROUTINE,
|
---|
| 44 | 0 As VoidPtr,
|
---|
| 45 | 0,
|
---|
| 46 | _PromptSys_dwThreadID)
|
---|
| 47 | Do
|
---|
| 48 | Sleep(20)
|
---|
| 49 | Loop Until _PromptSys_bInitFinish
|
---|
| 50 |
|
---|
| 51 | Sub DrawPromptBuffer(hDC As HDC, StartLine As Long, EndLine As Long)
|
---|
| 52 | Dim i As Long, i2 As Long, i3 As Long
|
---|
| 53 | Dim sz As SIZE
|
---|
[110] | 54 | Dim temporary[2] As Char
|
---|
[1] | 55 |
|
---|
[121] | 56 | Dim hOldFont = SelectObject(hDC, _PromptSys_hFont) As HFONT
|
---|
[1] | 57 |
|
---|
| 58 | 'Scroll
|
---|
| 59 | Dim rc As RECT
|
---|
[121] | 60 | GetClientRect(_PromptSys_hWnd, rc)
|
---|
[1] | 61 | While (_PromptSys_CurPos.y+1)*_PromptSys_FontSize.cy>rc.bottom and _PromptSys_CurPos.y>0
|
---|
[121] | 62 | _System_free(_PromptSys_Buffer[0])
|
---|
| 63 | _System_free(_PromptSys_TextColor[0])
|
---|
| 64 | _System_free(_PromptSys_BackColor[0])
|
---|
[1] | 65 | For i=0 To 100-1
|
---|
[121] | 66 | _PromptSys_Buffer[i] = _PromptSys_Buffer[i+1]
|
---|
| 67 | _PromptSys_TextColor[i] = _PromptSys_TextColor[i+1]
|
---|
| 68 | _PromptSys_BackColor[i] = _PromptSys_BackColor[i+1]
|
---|
[1] | 69 | Next
|
---|
[121] | 70 | _PromptSys_Buffer[100] = _System_calloc(SizeOf (Char) * 255)
|
---|
| 71 | _PromptSys_TextColor[100] = _System_calloc(SizeOf(COLORREF) * 255)
|
---|
| 72 | _PromptSys_BackColor[100] = _System_calloc(SizeOf(COLORREF) * 255)
|
---|
[1] | 73 |
|
---|
[90] | 74 | _PromptSys_CurPos.y--
|
---|
[1] | 75 |
|
---|
| 76 | 'Redraw
|
---|
| 77 | StartLine=-1
|
---|
| 78 | Wend
|
---|
| 79 |
|
---|
| 80 | i=0
|
---|
| 81 | While i*_PromptSys_FontSize.cy<rc.bottom and i<=100
|
---|
| 82 | If StartLine=-1 or (StartLine<=i and i<=EndLine) Then
|
---|
[121] | 83 | i3 = lstrlen(_PromptSys_Buffer[i])
|
---|
| 84 | GetTextExtentPoint32(hDC, _PromptSys_Buffer[i], i3, sz)
|
---|
| 85 |
|
---|
[1] | 86 | BitBlt(hDC,_
|
---|
| 87 | sz.cx, i*_PromptSys_FontSize.cy, _
|
---|
| 88 | rc.right, _PromptSys_FontSize.cy, _
|
---|
| 89 | _PromptSys_hMemDC,sz.cx,i*_PromptSys_FontSize.cy,SRCCOPY)
|
---|
| 90 |
|
---|
[121] | 91 | For i2 = 0 To i3-1
|
---|
| 92 | SetTextColor(hDC, _PromptSys_TextColor[i][i2])
|
---|
| 93 | If _PromptSys_BackColor[i][i2] = -1 Then
|
---|
| 94 | SetBkMode(hDC, TRANSPARENT)
|
---|
[1] | 95 | Else
|
---|
[121] | 96 | SetBkMode(hDC, OPAQUE)
|
---|
| 97 | SetBkColor(hDC, _PromptSys_BackColor[i][i2])
|
---|
[1] | 98 | End If
|
---|
| 99 |
|
---|
[121] | 100 | Dim tempLen As Long
|
---|
[1] | 101 | temporary[0]=_PromptSys_Buffer[i][i2]
|
---|
[119] | 102 | #ifdef UNICODE
|
---|
| 103 | If _System_IsSurrogatePair(_PromptSys_Buffer[i][i2], _PromptSys_Buffer[i][i2+1]) Then
|
---|
| 104 | #else
|
---|
[1] | 105 | If IsDBCSLeadByte(temporary[0]) Then
|
---|
[119] | 106 | #endif
|
---|
[121] | 107 | temporary[1] = _PromptSys_Buffer[i][i2+1]
|
---|
| 108 | temporary[2] = 0
|
---|
[119] | 109 | i2++
|
---|
[121] | 110 | tempLen = 2
|
---|
[1] | 111 | Else
|
---|
[121] | 112 | temporary[1] = 0
|
---|
| 113 | tempLen = 1
|
---|
[1] | 114 | End If
|
---|
[121] | 115 | With _PromptSys_FontSize
|
---|
| 116 | TextOut(hDC, i2 * .cx, i * .cy, temporary, tempLen)
|
---|
| 117 | End With
|
---|
[1] | 118 | Next
|
---|
| 119 | End If
|
---|
| 120 |
|
---|
[90] | 121 | i++
|
---|
[1] | 122 | Wend
|
---|
| 123 |
|
---|
[121] | 124 | SelectObject(hDC, hOldFont)
|
---|
[1] | 125 | End Sub
|
---|
| 126 |
|
---|
| 127 | Sub PRINT_ToPrompt(buf As String)
|
---|
| 128 | EnterCriticalSection(_PromptSys_SectionOfBufferAccess)
|
---|
[121] | 129 | With _PromptSys_CurPos
|
---|
[1] | 130 | Dim StartLine As Long
|
---|
[121] | 131 | StartLine = .y
|
---|
[1] | 132 | 'Addition
|
---|
[121] | 133 | Dim i2 = 0 As Long, i3 As Long
|
---|
[1] | 134 | Do
|
---|
[121] | 135 | If buf[i2] = 9 Then 'tab
|
---|
| 136 | i3 = 8 - (.x And 7) '(.x mod 8)
|
---|
| 137 | Dim j As Long
|
---|
| 138 | Dim p = VarPtr(_PromptSys_Buffer[.y][.x]) As *Char
|
---|
| 139 | ' FillMemory(_PromptSys_Buffer[.y]+.x, i3, Asc(" "))
|
---|
| 140 | For j = 0 To ELM(i3)
|
---|
| 141 | p[j] = &h20 'Asc(" ")
|
---|
| 142 | Next
|
---|
[90] | 143 | i2++
|
---|
[121] | 144 | .x += i3
|
---|
[1] | 145 | Continue
|
---|
| 146 | End If
|
---|
| 147 |
|
---|
[121] | 148 | If buf[i2] = 13 and buf[i2+1] = 10 Then '\r\n
|
---|
[90] | 149 | i2 += 2
|
---|
[121] | 150 | .y++
|
---|
| 151 | .x = 0
|
---|
[1] | 152 | Continue
|
---|
| 153 | End If
|
---|
| 154 |
|
---|
[121] | 155 | If buf[i2] = 0 Then Exit Do
|
---|
| 156 | _PromptSys_Buffer[.y][.x] = buf[i2]
|
---|
| 157 | _PromptSys_TextColor[.y][.x] = _PromptSys_NowTextColor
|
---|
| 158 | _PromptSys_BackColor[.y][.x] = _PromptSys_NowBackColor
|
---|
[1] | 159 |
|
---|
[90] | 160 | i2++
|
---|
[121] | 161 | .x++
|
---|
[1] | 162 | Loop
|
---|
| 163 | 'Draw the text buffer added
|
---|
[121] | 164 | Dim hDC = GetDC(_PromptSys_hWnd)
|
---|
| 165 | DrawPromptBuffer(hDC, StartLine, .y)
|
---|
| 166 | ReleaseDC(_PromptSys_hWnd, hDC)
|
---|
| 167 | End With
|
---|
[1] | 168 | LeaveCriticalSection(_PromptSys_SectionOfBufferAccess)
|
---|
| 169 | End Sub
|
---|
| 170 |
|
---|
| 171 | Function PromptProc(hWnd As HWND, message As DWord, wParam As WPARAM, lParam As LPARAM) As LRESULT
|
---|
| 172 | Dim hIMC As HIMC
|
---|
| 173 | Dim hDC As HDC
|
---|
| 174 | Dim ps As PAINTSTRUCT
|
---|
| 175 | Dim TempStr As String
|
---|
| 176 | Dim CompForm As COMPOSITIONFORM
|
---|
| 177 |
|
---|
| 178 | Select Case message
|
---|
| 179 | Case WM_CREATE
|
---|
[121] | 180 | hDC = GetDC(hWnd)
|
---|
| 181 | With _PromptSys_ScreenSize
|
---|
| 182 | _PromptSys_hBitmap = CreateCompatibleBitmap(hDC, .cx, .cy)
|
---|
| 183 | End With
|
---|
| 184 | _PromptSys_hMemDC = CreateCompatibleDC(hDC)
|
---|
| 185 | SelectObject(_PromptSys_hMemDC, _PromptSys_hBitmap)
|
---|
[1] | 186 |
|
---|
| 187 | 'Initialize for Win9x
|
---|
[121] | 188 | Dim hOldBrush = SelectObject(_PromptSys_hMemDC, GetStockObject(BLACK_BRUSH)) As HBRUSH
|
---|
| 189 | With _PromptSys_ScreenSize
|
---|
| 190 | PatBlt(_PromptSys_hMemDC, 0, 0, .cx, .cy, PATCOPY)
|
---|
| 191 | End With
|
---|
| 192 | SelectObject(_PromptSys_hMemDC, hOldBrush)
|
---|
[1] | 193 |
|
---|
| 194 | Dim tm As TEXTMETRIC
|
---|
[121] | 195 | Dim hOldFont=SelectObject(_PromptSys_hMemDC, _PromptSys_hFont) As HFONT
|
---|
| 196 | GetTextExtentPoint32(_PromptSys_hMemDC, Ex" " As PCTSTR, 1, _PromptSys_FontSize)
|
---|
| 197 | GetTextMetrics(_PromptSys_hMemDC, tm)
|
---|
| 198 | SelectObject(_PromptSys_hMemDC, hOldFont)
|
---|
| 199 | _PromptSys_FontSize.cy = tm.tmHeight
|
---|
[1] | 200 |
|
---|
| 201 | ReleaseDC(hWnd,hDC)
|
---|
| 202 | Case WM_PAINT
|
---|
[121] | 203 | hDC = BeginPaint(hWnd,ps)
|
---|
| 204 | With _PromptSys_ScreenSize
|
---|
| 205 | BitBlt(hDC, 0, 0, .cx, .cy, _PromptSys_hMemDC, 0, 0, SRCCOPY)
|
---|
| 206 | End With
|
---|
| 207 | DrawPromptBuffer(hDC, -1, 0)
|
---|
| 208 | EndPaint(hWnd, ps)
|
---|
[1] | 209 |
|
---|
[121] | 210 | _PromptSys_bInitFinish = TRUE
|
---|
[1] | 211 | Case WM_SETFOCUS
|
---|
| 212 | If _PromptSys_InputLen<>-1 Then
|
---|
[121] | 213 | hIMC = ImmGetContext(hWnd)
|
---|
[1] | 214 | If hIMC Then
|
---|
[121] | 215 | With CompForm
|
---|
| 216 | .dwStyle = CFS_POINT
|
---|
| 217 | .ptCurrentPos.x = _PromptSys_CurPos.x*_PromptSys_FontSize.cx
|
---|
| 218 | .ptCurrentPos.y = _PromptSys_CurPos.y*_PromptSys_FontSize.cy
|
---|
| 219 | End With
|
---|
| 220 | ImmSetCompositionWindow(hIMC, CompForm)
|
---|
| 221 | ImmSetCompositionFontA(hIMC, _PromptSys_LogFont)
|
---|
[1] | 222 | End If
|
---|
[121] | 223 | ImmReleaseContext(hWnd, hIMC)
|
---|
[1] | 224 |
|
---|
| 225 | CreateCaret(hWnd,NULL,9,6)
|
---|
| 226 | SetCaretPos(_PromptSys_CurPos.x*_PromptSys_FontSize.cx, _
|
---|
| 227 | (_PromptSys_CurPos.y+1)*_PromptSys_FontSize.cy-7)
|
---|
| 228 | ShowCaret(hWnd)
|
---|
| 229 | End If
|
---|
| 230 | Case WM_KILLFOCUS
|
---|
| 231 | HideCaret(hWnd)
|
---|
| 232 | DestroyCaret()
|
---|
| 233 | Case WM_KEYDOWN
|
---|
| 234 | If _PromptSys_InputLen=-1 Then
|
---|
| 235 | _PromptSys_KeyChar=wParam As Byte
|
---|
| 236 | End If
|
---|
| 237 | Case WM_CHAR
|
---|
[121] | 238 | If _PromptSys_InputLen <> -1 Then
|
---|
| 239 | If wParam = VK_BACK Then
|
---|
[1] | 240 | If _PromptSys_InputLen Then
|
---|
[121] | 241 | _PromptSys_InputLen--
|
---|
| 242 | _PromptSys_InputStr[_PromptSys_InputLen] = 0
|
---|
[1] | 243 |
|
---|
[121] | 244 | _PromptSys_CurPos.x--
|
---|
| 245 | _PromptSys_Buffer[_PromptSys_CurPos.y][_PromptSys_CurPos.x] = 0
|
---|
[1] | 246 | End If
|
---|
[121] | 247 | ElseIf wParam = VK_RETURN Then
|
---|
| 248 | _PromptSys_InputStr[_PromptSys_InputLen] = 0
|
---|
| 249 | _PromptSys_InputLen = -1
|
---|
| 250 | TempStr = Ex"\r\n"
|
---|
| 251 | ElseIf wParam = &H16 Then
|
---|
[1] | 252 | 'Paste Command(Use Clippboard)
|
---|
| 253 | OpenClipboard(hWnd)
|
---|
[121] | 254 | Dim hGlobal = GetClipboardData(CF_TEXT) As HGLOBAL
|
---|
| 255 | If hGlobal = 0 Then Return 0
|
---|
| 256 | Dim pTemp = GlobalLock(hGlobal) As PCSTR
|
---|
| 257 | #ifdef UNICODE 'A版ウィンドウプロシージャ用
|
---|
[119] | 258 | Dim tempSizeW = MultiByteToWideChar(CP_ACP, 0, pTemp, -1, 0, 0) + 1
|
---|
[121] | 259 | TempStr = ZeroString(tempSizeW)
|
---|
[119] | 260 | MultiByteToWideChar(CP_ACP, 0, pTemp, -1, StrPtr(TempStr), tempSizeW)
|
---|
| 261 | #else
|
---|
[121] | 262 | TempStr = ZeroString(lstrlen(pTemp) + 1)
|
---|
| 263 | lstrcpy(StrPtr(TempStr), pTemp)
|
---|
[119] | 264 | #endif
|
---|
[121] | 265 | memcpy(VarPtr(_PromptSys_InputStr[_PromptSys_InputLen]), TempStr.Chars, SizeOf (Char) * TempStr.Length)
|
---|
| 266 | _PromptSys_InputLen += TempStr.Length
|
---|
[1] | 267 |
|
---|
| 268 | GlobalUnlock(hGlobal)
|
---|
| 269 | CloseClipboard()
|
---|
| 270 | Else
|
---|
[121] | 271 | _PromptSys_InputStr[_PromptSys_InputLen] = wParam As Byte
|
---|
[110] | 272 | _PromptSys_InputLen++
|
---|
[1] | 273 |
|
---|
[121] | 274 | TempStr.ReSize(1)
|
---|
| 275 | TempStr[0] = wParam As Char
|
---|
[1] | 276 | End If
|
---|
| 277 |
|
---|
[121] | 278 | SendMessage(hWnd, WM_KILLFOCUS, 0, 0)
|
---|
[1] | 279 | PRINT_ToPrompt(TempStr)
|
---|
[121] | 280 | SendMessage(hWnd, WM_SETFOCUS, 0, 0)
|
---|
[1] | 281 | End If
|
---|
| 282 | Case WM_DESTROY
|
---|
| 283 | DeleteDC(_PromptSys_hMemDC)
|
---|
| 284 | DeleteObject(_PromptSys_hBitmap)
|
---|
| 285 |
|
---|
| 286 | PostQuitMessage(0)
|
---|
| 287 | Case Else
|
---|
| 288 | PromptProc=DefWindowProc(hWnd,message,wParam,lParam)
|
---|
| 289 | Exit Function
|
---|
| 290 | End Select
|
---|
| 291 | PromptProc=0
|
---|
| 292 | End Function
|
---|
| 293 |
|
---|
| 294 | Function PromptMain(dwData As Long) As Long
|
---|
| 295 | Dim i As Long
|
---|
| 296 |
|
---|
| 297 | 'Allocate
|
---|
| 298 | For i=0 To 100
|
---|
[121] | 299 | _PromptSys_Buffer[i] = _System_calloc(SizeOf (Char) * 255)
|
---|
| 300 | _PromptSys_TextColor[i] = _System_calloc(SizeOf(COLORREF) * 255)
|
---|
| 301 | _PromptSys_BackColor[i] = _System_calloc(SizeOf(COLORREF) * 255)
|
---|
[1] | 302 | Next
|
---|
| 303 |
|
---|
| 304 | 'Current Colors initialize
|
---|
| 305 | _PromptSys_NowTextColor=RGB(255,255,255)
|
---|
| 306 | _PromptSys_NowBackColor=RGB(0,0,0)
|
---|
| 307 |
|
---|
| 308 | 'Setup
|
---|
| 309 | _PromptSys_ScreenSize.cx=GetSystemMetrics(SM_CXSCREEN)
|
---|
| 310 | _PromptSys_ScreenSize.cy=GetSystemMetrics(SM_CYSCREEN)
|
---|
| 311 |
|
---|
| 312 | 'LogFont initialize
|
---|
[121] | 313 | With _PromptSys_LogFont
|
---|
| 314 | .lfHeight = -16
|
---|
| 315 | .lfWidth = 0
|
---|
| 316 | .lfEscapement = 0
|
---|
| 317 | .lfOrientation = 0
|
---|
| 318 | .lfWeight = 0
|
---|
| 319 | .lfItalic = 0
|
---|
| 320 | .lfUnderline = 0
|
---|
| 321 | .lfStrikeOut = 0
|
---|
| 322 | .lfCharSet = SHIFTJIS_CHARSET
|
---|
| 323 | .lfOutPrecision = OUT_DEFAULT_PRECIS
|
---|
| 324 | .lfClipPrecision = CLIP_DEFAULT_PRECIS
|
---|
| 325 | .lfQuality = DEFAULT_QUALITY
|
---|
| 326 | .lfPitchAndFamily = FIXED_PITCH
|
---|
| 327 | lstrcpy(.lfFaceName, "MS 明朝")
|
---|
| 328 | End With
|
---|
[1] | 329 |
|
---|
[121] | 330 | _PromptSys_hFont = CreateFontIndirect(ByVal VarPtr(_PromptSys_LogFont))
|
---|
[1] | 331 |
|
---|
| 332 | 'Critical Section
|
---|
| 333 | InitializeCriticalSection(_PromptSys_SectionOfBufferAccess)
|
---|
| 334 |
|
---|
| 335 | 'Regist Prompt Class
|
---|
| 336 | Dim wcl As WNDCLASSEX
|
---|
| 337 | FillMemory(VarPtr(wcl),Len(wcl),0)
|
---|
| 338 | wcl.cbSize=Len(wcl)
|
---|
| 339 | wcl.hInstance=GetModuleHandle(0)
|
---|
| 340 | wcl.style=CS_HREDRAW or CS_VREDRAW or CS_DBLCLKS
|
---|
| 341 | wcl.hIcon=LoadIcon(NULL,MAKEINTRESOURCE(IDI_APPLICATION))
|
---|
| 342 | wcl.hIconSm=LoadIcon(NULL,MAKEINTRESOURCE(IDI_WINLOGO))
|
---|
| 343 | wcl.hCursor=LoadCursor(NULL,MAKEINTRESOURCE(IDC_ARROW))
|
---|
| 344 | wcl.lpszClassName="PROMPT"
|
---|
| 345 | wcl.lpfnWndProc=AddressOf(PromptProc)
|
---|
| 346 | wcl.hbrBackground=GetStockObject(BLACK_BRUSH)
|
---|
[121] | 347 | Dim atom = RegisterClassEx(wcl)
|
---|
[1] | 348 |
|
---|
| 349 | 'Create Prompt Window
|
---|
[121] | 350 | _PromptSys_hWnd=CreateWindowEx(WS_EX_CLIENTEDGE,atom As ULONG_PTR As PCSTR,"BASIC PROMPT",WS_OVERLAPPEDWINDOW,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,0,0,GetModuleHandle(0),0)
|
---|
[1] | 351 | ShowWindow(_PromptSys_hWnd,SW_SHOW)
|
---|
[119] | 352 | UpdateWindow(_PromptSys_hWnd)
|
---|
[1] | 353 |
|
---|
| 354 | Dim msg As MSG, iResult As Long
|
---|
| 355 | Do
|
---|
| 356 | iResult=GetMessage(msg,0,0,0)
|
---|
| 357 | If iResult=0 or iResult=-1 Then Exit Do
|
---|
| 358 | TranslateMessage(msg)
|
---|
| 359 | DispatchMessage(msg)
|
---|
| 360 | Loop
|
---|
| 361 |
|
---|
[121] | 362 | '強制的に終了する
|
---|
| 363 | ExitProcess(0)
|
---|
| 364 |
|
---|
[1] | 365 | EnterCriticalSection(_PromptSys_SectionOfBufferAccess)
|
---|
[121] | 366 |
|
---|
| 367 | For i=0 to 100
|
---|
| 368 | _System_free(_PromptSys_Buffer[i])
|
---|
| 369 | _System_free(_PromptSys_TextColor[i])
|
---|
| 370 | _System_free(_PromptSys_BackColor[i])
|
---|
| 371 | Next
|
---|
[17] | 372 |
|
---|
[1] | 373 | LeaveCriticalSection(_PromptSys_SectionOfBufferAccess)
|
---|
| 374 |
|
---|
| 375 | DeleteCriticalSection(_PromptSys_SectionOfBufferAccess)
|
---|
| 376 |
|
---|
| 377 | ExitProcess(0)
|
---|
| 378 | End Function
|
---|
| 379 |
|
---|
| 380 |
|
---|
| 381 | '----------------------
|
---|
| 382 | ' Prompt text Commands
|
---|
| 383 | '----------------------
|
---|
| 384 |
|
---|
| 385 | Macro CLS()(num As Long)
|
---|
| 386 | Dim i As Long
|
---|
| 387 | Dim hOldBrush As HBRUSH
|
---|
| 388 |
|
---|
| 389 | 'When parameter was omitted, num is set to 1
|
---|
| 390 | If num=0 Then num=1
|
---|
| 391 |
|
---|
| 392 | If num=1 or num=3 Then
|
---|
| 393 | 'Clear the text screen
|
---|
| 394 | For i=0 To 100
|
---|
| 395 | FillMemory(_PromptSys_Buffer[i],255,0)
|
---|
| 396 | Next
|
---|
| 397 | _PromptSys_CurPos.x=0
|
---|
| 398 | _PromptSys_CurPos.y=0
|
---|
| 399 | End If
|
---|
| 400 |
|
---|
| 401 | If num=2 or num=3 Then
|
---|
| 402 | 'Clear the graphics screen
|
---|
| 403 | hOldBrush=SelectObject(_PromptSys_hMemDC,GetStockObject(BLACK_BRUSH))
|
---|
| 404 | PatBlt(_PromptSys_hMemDC,0,0,_PromptSys_ScreenSize.cx,_PromptSys_ScreenSize.cy,PATCOPY)
|
---|
| 405 | SelectObject(_PromptSys_hMemDC,hOldBrush)
|
---|
| 406 | End If
|
---|
| 407 |
|
---|
| 408 | 'Redraw
|
---|
| 409 | InvalidateRect(_PromptSys_hWnd,ByVal 0,0)
|
---|
| 410 | End Macro
|
---|
| 411 |
|
---|
| 412 | Macro COLOR(TextColorCode As Long)(BackColorCode As Long)
|
---|
| 413 | _PromptSys_NowTextColor=GetBasicColor(TextColorCode)
|
---|
| 414 | If BackColorCode=-1 Then
|
---|
| 415 | _PromptSys_NowBackColor=-1
|
---|
| 416 | Else
|
---|
| 417 | _PromptSys_NowBackColor=GetBasicColor(BackColorCode)
|
---|
| 418 | End If
|
---|
| 419 | End Macro
|
---|
| 420 |
|
---|
| 421 | '---------- Defined in "command.sbp" ----------
|
---|
| 422 | 'Dim _System_InputDataPtr[_System_MAX_PARMSNUM] As VoidPtr
|
---|
| 423 | 'Dim _System_InputDataType[_System_MAX_PARMSNUM] As DWord
|
---|
| 424 | '----------------------------------------------
|
---|
| 425 | Sub INPUT_FromPrompt(ShowStr As String)
|
---|
| 426 | Dim i As Long ,i2 As Long, i3 As Long
|
---|
| 427 | Dim buf As String
|
---|
| 428 |
|
---|
| 429 | *InputReStart
|
---|
| 430 |
|
---|
| 431 | PRINT_ToPrompt(ShowStr)
|
---|
| 432 |
|
---|
| 433 | 'Input by keyboard
|
---|
| 434 | _PromptSys_InputLen=0
|
---|
| 435 | SendMessage(_PromptSys_hWnd,WM_SETFOCUS,0,0)
|
---|
| 436 | While _PromptSys_InputLen<>-1
|
---|
| 437 | Sleep(10)
|
---|
| 438 | Wend
|
---|
| 439 | SendMessage(_PromptSys_hWnd,WM_KILLFOCUS,0,0)
|
---|
| 440 |
|
---|
| 441 | 'Set value to variable
|
---|
[121] | 442 | i = 0
|
---|
| 443 | i2 = 0
|
---|
| 444 | buf = ZeroString(lstrlen(_PromptSys_InputStr))
|
---|
[1] | 445 | While 1
|
---|
[121] | 446 | i3 = 0
|
---|
[1] | 447 | While 1
|
---|
[121] | 448 | If _PromptSys_InputStr[i2] = &h2c Then
|
---|
| 449 | buf.Chars[i3] = 0
|
---|
[1] | 450 | Exit While
|
---|
| 451 | End If
|
---|
| 452 |
|
---|
[121] | 453 | buf.Chars[i3] = _PromptSys_InputStr[i2]
|
---|
[1] | 454 |
|
---|
[121] | 455 | If _PromptSys_InputStr[i2] = 0 Then Exit While
|
---|
[1] | 456 |
|
---|
[90] | 457 | i2++
|
---|
| 458 | i3++
|
---|
[1] | 459 | Wend
|
---|
| 460 |
|
---|
[121] | 461 | _System_Input_SetArgument(_System_InputDataPtr[i], _System_InputDataType[i], buf, i3)
|
---|
[1] | 462 |
|
---|
[90] | 463 | i++
|
---|
[121] | 464 | If _System_InputDataPtr[i]=0 and _PromptSys_InputStr[i2]=&h2c Then 'Asc(",")
|
---|
[1] | 465 | PRINT_ToPrompt(Ex"入力データの個数が多すぎます\r\n")
|
---|
| 466 | Goto *InputReStart
|
---|
| 467 | ElseIf _PromptSys_InputStr[i2]=0 Then
|
---|
| 468 | If _System_InputDataPtr[i]<>0 Then
|
---|
| 469 | PRINT_ToPrompt(Ex"入力データの個数が足りません\r\n")
|
---|
| 470 | Goto *InputReStart
|
---|
| 471 | Else
|
---|
| 472 | Exit While
|
---|
| 473 | End If
|
---|
| 474 | End If
|
---|
| 475 |
|
---|
[121] | 476 | i2++
|
---|
[1] | 477 | Wend
|
---|
| 478 | End Sub
|
---|
| 479 |
|
---|
| 480 | Sub PRINTUSING_ToPrompt(UsingStr As String)
|
---|
| 481 | PRINT_ToPrompt(_System_GetUsingFormat(UsingStr))
|
---|
| 482 | End Sub
|
---|
| 483 |
|
---|
| 484 | Macro LOCATE(x As Long, y As Long)
|
---|
| 485 | Dim i As Long, i2 As Long
|
---|
| 486 |
|
---|
| 487 | If x<0 Then x=0
|
---|
| 488 | If y<0 Then y=0
|
---|
| 489 | If y>100 Then y=100
|
---|
| 490 |
|
---|
| 491 | _PromptSys_CurPos.x=x
|
---|
| 492 | _PromptSys_CurPos.y=y
|
---|
| 493 |
|
---|
| 494 | i=0
|
---|
| 495 | While _PromptSys_Buffer[y][i]
|
---|
[90] | 496 | i++
|
---|
[1] | 497 | Wend
|
---|
| 498 |
|
---|
| 499 | If i<x Then
|
---|
| 500 | FillMemory(_PromptSys_Buffer[y]+i,x-i,Asc(" "))
|
---|
| 501 | For i2=i To x-1
|
---|
| 502 | _PromptSys_BackColor[y][i2]=-1
|
---|
| 503 | Next
|
---|
| 504 | End If
|
---|
| 505 | End Macro
|
---|
| 506 |
|
---|
| 507 |
|
---|
| 508 | '-------------------
|
---|
| 509 | ' Graphics Commands
|
---|
| 510 | '-------------------
|
---|
| 511 |
|
---|
| 512 | Macro CIRCLE(x As Long , y As Long, radius As Long)(ColorCode As Long, StartPos As Double, EndPos As Double, Aspect As Double, bFill As Long, BrushColor As Long)
|
---|
| 513 | '呼び出し方法は以下のようになります(コンパイラがパラメータの並びを最適化します)
|
---|
| 514 | 'Circle (x, y), radius [, color] [, start] [, end] [, aspect] [, f] [, color2]
|
---|
| 515 |
|
---|
[121] | 516 | Dim hBrush As HBRUSH
|
---|
[1] | 517 | Dim radi2 As Long
|
---|
| 518 | Dim sw As Long
|
---|
| 519 | Dim i1 As Long, i2 As Long, i3 As Long, i4 As Long
|
---|
| 520 |
|
---|
[121] | 521 | Dim hPen = CreatePen(PS_SOLID,1,GetBasicColor(ColorCode))
|
---|
[1] | 522 | If bFill Then
|
---|
| 523 | hBrush=CreateSolidBrush(GetBasicColor(BrushColor))
|
---|
| 524 | Else
|
---|
| 525 | hBrush=GetStockObject(NULL_BRUSH)
|
---|
| 526 | End If
|
---|
| 527 |
|
---|
[121] | 528 | Dim hDC=GetDC(_PromptSys_hWnd)
|
---|
[1] | 529 | SelectObject(hDC,hPen)
|
---|
| 530 | SelectObject(hDC,hBrush)
|
---|
[121] | 531 | Dim hOldPen=SelectObject(_PromptSys_hMemDC,hPen)
|
---|
| 532 | Dim hOldBrush=SelectObject(_PromptSys_hMemDC,hBrush)
|
---|
[1] | 533 |
|
---|
| 534 | If Aspect<1 Then
|
---|
[89] | 535 | radi2=(CDbl(radius)*Aspect) As Long
|
---|
[1] | 536 | Else
|
---|
| 537 | radi2=radius
|
---|
[89] | 538 | radius=(CDbl(radius)/Aspect) As Long
|
---|
[1] | 539 | End If
|
---|
| 540 |
|
---|
| 541 | If StartPos=0 And EndPos=0 Then
|
---|
| 542 | Ellipse(hDC,x-radius,y-radi2,x+radius,y+radi2)
|
---|
| 543 | Ellipse(_PromptSys_hMemDC,x-radius,y-radi2,x+radius,y+radi2)
|
---|
| 544 | Else
|
---|
[90] | 545 | StartPos *=StartPos
|
---|
| 546 | EndPos *=EndPos
|
---|
[1] | 547 |
|
---|
| 548 | If StartPos<0 Or EndPos<0 Then
|
---|
| 549 | sw=1
|
---|
| 550 | Else
|
---|
| 551 | sw=0
|
---|
| 552 | End If
|
---|
| 553 |
|
---|
[90] | 554 | StartPos = Abs(StartPos)
|
---|
| 555 | EndPos = Abs(EndPos)
|
---|
[1] | 556 |
|
---|
| 557 | If StartPos<=78.5 Then
|
---|
| 558 | i1=78
|
---|
| 559 | i2=Int(StartPos)
|
---|
| 560 | ElseIf StartPos<=235.5 Then
|
---|
[90] | 561 | StartPos -= 78.5
|
---|
[1] | 562 | i1=78-Int(StartPos)
|
---|
| 563 | i2=78
|
---|
| 564 | ElseIf StartPos<=392.5 Then
|
---|
[90] | 565 | StartPos -= 235.5
|
---|
[1] | 566 | i1=-78
|
---|
| 567 | i2=78-Int(StartPos)
|
---|
| 568 | ElseIf StartPos<=549.5 Then
|
---|
[90] | 569 | StartPos -= 392.5
|
---|
[1] | 570 | i1=-78+Int(StartPos)
|
---|
| 571 | i2=-78
|
---|
| 572 | ElseIf StartPos<=628 Then
|
---|
[90] | 573 | StartPos -= 549.5
|
---|
[1] | 574 | i1=78
|
---|
| 575 | i2=-78+Int(StartPos)
|
---|
| 576 | End If
|
---|
| 577 |
|
---|
| 578 | If EndPos<=78.5 Then
|
---|
| 579 | i3=78
|
---|
| 580 | i4=Int(EndPos)
|
---|
| 581 | ElseIf EndPos<=235.5 Then
|
---|
[90] | 582 | EndPos -= 78.5
|
---|
[1] | 583 | i3=78-Int(EndPos)
|
---|
| 584 | i4=78
|
---|
| 585 | ElseIf EndPos<=392.5 Then
|
---|
[90] | 586 | EndPos -= 235.5
|
---|
[1] | 587 | i3=-78
|
---|
| 588 | i4=78-Int(EndPos)
|
---|
| 589 | ElseIf EndPos<=549.5 Then
|
---|
[90] | 590 | EndPos -= 392.5
|
---|
[1] | 591 | i3=-78+Int(EndPos)
|
---|
| 592 | i4=-78
|
---|
| 593 | ElseIf EndPos<=628 Then
|
---|
[90] | 594 | EndPos -= 549.5
|
---|
[1] | 595 | i3=78
|
---|
| 596 | i4=-78+Int(EndPos)
|
---|
| 597 | End If
|
---|
| 598 |
|
---|
| 599 | If sw Then
|
---|
| 600 | Pie(hDC,x-radius,y-radi2,x+radius,y+radi2, x+i1,y-i2,x+i3,y-i4)
|
---|
| 601 | Pie(_PromptSys_hMemDC,x-radius,y-radi2,x+radius,y+radi2, x+i1,y-i2,x+i3,y-i4)
|
---|
| 602 | Else
|
---|
| 603 | Arc(hDC,x-radius,y-radi2,x+radius,y+radi2, x+i1,y-i2,x+i3,y-i4)
|
---|
| 604 | Arc(_PromptSys_hMemDC,x-radius,y-radi2,x+radius,y+radi2, x+i1,y-i2,x+i3,y-i4)
|
---|
| 605 | End If
|
---|
| 606 | End If
|
---|
| 607 |
|
---|
| 608 | ReleaseDC(_PromptSys_hWnd,hDC)
|
---|
| 609 | SelectObject(_PromptSys_hMemDC,hOldPen)
|
---|
| 610 | SelectObject(_PromptSys_hMemDC,hOldBrush)
|
---|
| 611 | DeleteObject(hPen)
|
---|
| 612 | If bFill Then DeleteObject(hBrush)
|
---|
| 613 | End Macro
|
---|
| 614 |
|
---|
| 615 | Macro LINE(sx As Long, sy As Long, bStep As Long, ex As Long, ey As Long)(ColorCode As Long, fType As Long, BrushColor As Long)
|
---|
| 616 | '呼び出し方法は以下のようになります(コンパイラがパラメータの並びを最適化します)
|
---|
| 617 | 'Line (sx,sy)-[STEP](ex,ey),[ColorCode],[B/Bf],[BrushColor]
|
---|
| 618 | Dim temp As Long
|
---|
| 619 |
|
---|
| 620 | If sx=&H80000000 And sy=&H80000000 Then
|
---|
| 621 | sx=_PromptSys_GlobalPos.x
|
---|
| 622 | sy=_PromptSys_GlobalPos.y
|
---|
| 623 | End If
|
---|
| 624 |
|
---|
| 625 | If bStep Then
|
---|
[90] | 626 | ex += sx
|
---|
| 627 | ey += sy
|
---|
[1] | 628 | Else
|
---|
| 629 | If fType Then
|
---|
| 630 | 'ラインの場合(四角形でない場合)
|
---|
| 631 | If sx>ex Then
|
---|
| 632 | temp=ex
|
---|
| 633 | ex=sx
|
---|
| 634 | sx=temp
|
---|
| 635 | End If
|
---|
| 636 | If sy>ey Then
|
---|
| 637 | temp=ey
|
---|
| 638 | ey=sy
|
---|
| 639 | sy=temp
|
---|
| 640 | End If
|
---|
| 641 | End If
|
---|
| 642 | End If
|
---|
| 643 |
|
---|
[121] | 644 | Dim hDC = GetDC(_PromptSys_hWnd)
|
---|
| 645 | Dim hPen = CreatePen(PS_SOLID, 1, GetBasicColor(ColorCode))
|
---|
| 646 | Dim hBrush As HBRUSH
|
---|
[1] | 647 | If fType=2 Then
|
---|
| 648 | hBrush=CreateSolidBrush(GetBasicColor(BrushColor))
|
---|
| 649 | Else
|
---|
| 650 | hBrush=GetStockObject(NULL_BRUSH)
|
---|
| 651 | End If
|
---|
| 652 |
|
---|
| 653 | SelectObject(hDC,hPen)
|
---|
| 654 | SelectObject(hDC,hBrush)
|
---|
[121] | 655 | Dim hOldPen = SelectObject(_PromptSys_hMemDC,hPen)
|
---|
| 656 | Dim hOldBrush = SelectObject(_PromptSys_hMemDC,hBrush)
|
---|
[1] | 657 |
|
---|
| 658 | Select Case fType
|
---|
| 659 | Case 0
|
---|
| 660 | 'line
|
---|
| 661 | MoveToEx(_PromptSys_hMemDC,sx,sy,ByVal NULL)
|
---|
| 662 | LineTo(_PromptSys_hMemDC,ex,ey)
|
---|
| 663 | SetPixel(_PromptSys_hMemDC,ex,ey,GetBasicColor(ColorCode))
|
---|
| 664 | MoveToEx(hDC,sx,sy,ByVal NULL)
|
---|
| 665 | LineTo(hDC,ex,ey)
|
---|
| 666 | SetPixel(hDC,ex,ey,GetBasicColor(ColorCode))
|
---|
| 667 | Case Else
|
---|
| 668 | 'Rectangle
|
---|
| 669 | Rectangle(hDC,sx,sy,ex+1,ey+1)
|
---|
| 670 | Rectangle(_PromptSys_hMemDC,sx,sy,ex+1,ey+1)
|
---|
| 671 | End Select
|
---|
| 672 |
|
---|
| 673 | ReleaseDC(_PromptSys_hWnd,hDC)
|
---|
| 674 | SelectObject(_PromptSys_hMemDC,hOldPen)
|
---|
| 675 | SelectObject(_PromptSys_hMemDC,hOldBrush)
|
---|
| 676 | DeleteObject(hPen)
|
---|
| 677 | If fType=2 Then DeleteObject(hBrush)
|
---|
| 678 |
|
---|
| 679 | _PromptSys_GlobalPos.x=ex
|
---|
| 680 | _PromptSys_GlobalPos.y=ey
|
---|
| 681 | End Macro
|
---|
| 682 |
|
---|
| 683 | Macro PSET(x As Long, y As Long)(ColorCode As Long)
|
---|
| 684 | '呼び出し方法は以下のようになります(コンパイラがパラメータの並びを最適化します)
|
---|
| 685 | 'PSet (x,y),ColorCode
|
---|
| 686 |
|
---|
[121] | 687 | Dim hDC=GetDC(_PromptSys_hWnd)
|
---|
[1] | 688 | SetPixel(hDC,x,y,GetBasicColor(ColorCode))
|
---|
| 689 | SetPixel(_PromptSys_hMemDC,x,y,GetBasicColor(ColorCode))
|
---|
| 690 | ReleaseDC(_PromptSys_hWnd,hDC)
|
---|
| 691 |
|
---|
| 692 | _PromptSys_GlobalPos.x=x
|
---|
| 693 | _PromptSys_GlobalPos.y=y
|
---|
| 694 | End Macro
|
---|
| 695 |
|
---|
| 696 | Macro PAINT(x As Long, y As Long, BrushColor As Long)(ByVal LineColor As Long)
|
---|
| 697 | '呼び出し方法は以下のようになります(コンパイラがパラメータの並びを最適化します)
|
---|
| 698 | 'Paint (x,y),BrushColor,LineColor
|
---|
| 699 |
|
---|
[89] | 700 | Dim hDC As HDC
|
---|
| 701 | Dim hBrush As HBRUSH, hOldBrush As VoidPtr
|
---|
| 702 |
|
---|
[1] | 703 | hBrush=CreateSolidBrush(GetBasicColor(BrushColor))
|
---|
| 704 |
|
---|
| 705 | hDC=GetDC(_PromptSys_hWnd)
|
---|
| 706 | SelectObject(hDC,hBrush)
|
---|
| 707 | hOldBrush=SelectObject(_PromptSys_hMemDC,hBrush)
|
---|
| 708 |
|
---|
| 709 | ExtFloodFill(hDC,x,y,GetBasicColor(LineColor),FLOODFILLBORDER)
|
---|
| 710 | ExtFloodFill(_PromptSys_hMemDC,x,y,GetBasicColor(LineColor),FLOODFILLBORDER)
|
---|
| 711 |
|
---|
| 712 | ReleaseDC(_PromptSys_hWnd,hDC)
|
---|
| 713 | SelectObject(_PromptSys_hMemDC,hOldBrush)
|
---|
| 714 | DeleteObject(hBrush)
|
---|
| 715 | End Macro
|
---|
| 716 |
|
---|
| 717 |
|
---|
| 718 | '-----------
|
---|
| 719 | ' Functions
|
---|
| 720 | '-----------
|
---|
| 721 |
|
---|
| 722 | Function Inkey$() As String
|
---|
| 723 | If _PromptSys_KeyChar=0 Then
|
---|
| 724 | Inkey$=""
|
---|
| 725 | Else
|
---|
| 726 | Inkey$=Chr$(_PromptSys_KeyChar)
|
---|
| 727 | End If
|
---|
| 728 | _PromptSys_KeyChar=0
|
---|
| 729 | End Function
|
---|
| 730 |
|
---|
| 731 | Function Input$(length As Long) As String
|
---|
| 732 | Dim i As Long
|
---|
| 733 |
|
---|
| 734 | If length<=0 Then
|
---|
| 735 | Input$=""
|
---|
| 736 | Exit Function
|
---|
| 737 | End If
|
---|
| 738 |
|
---|
| 739 | i=0
|
---|
| 740 | While 1
|
---|
| 741 | If _PromptSys_KeyChar Then
|
---|
| 742 | Input$=Input$+Chr$(_PromptSys_KeyChar)
|
---|
| 743 | _PromptSys_KeyChar=0
|
---|
[90] | 744 | i++
|
---|
[1] | 745 | If i>=length Then
|
---|
| 746 | Exit While
|
---|
| 747 | End If
|
---|
| 748 | End If
|
---|
| 749 | Sleep(1)
|
---|
| 750 | Wend
|
---|
| 751 | End Function
|
---|
| 752 |
|
---|
| 753 |
|
---|
[89] | 754 | #endif '_INC_PROMPT
|
---|