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