📄 fconsole.class
字号:
' Gambas class filePRIVATE $hProcess AS ProcessPRIVATE $sText AS StringSTATIC PUBLIC SUB Main() DIM hForm AS Form hForm = NEW FConsole hForm.Show ENDPUBLIC SUB _new() EXEC [ "bash", "--noediting" ] FOR READ WRITE AS $hProcess txtCommand.SetFocusENDPUBLIC SUB Form_Close() $hProcess.KillENDPUBLIC SUB Form_Resize() txtCommand.Move(0, ME.ClientH - txtCommand.H, ME.ClientW, txtCommand.H) txtConsole.Move(0, 0, ME.ClientW, txtCommand.Y) ENDPUBLIC SUB Process_Read() DIM sStr AS String ' Never do that! 'LINE INPUT #LAST, sStr ' Do that instead: READ #LAST, sStr, -256 $sText = $sText & sStr UpdateConsoleENDPUBLIC SUB Process_Error(sStr AS String) $sText = $sText & sStr UpdateConsole ENDPRIVATE SUB UpdateConsole() DIM iPos AS Integer DIM sStr AS String DO iPos = Instr($sText, "\n") IF iPos = 0 THEN RETURN sStr = Normalize(Left$($sText, iPos)) $sText = Mid$($sText, iPos + 1) txtConsole.Pos = txtConsole.Length txtConsole.Insert(sStr) LOOP ENDPUBLIC SUB Process_Kill() 'hProcess = NULL TRY ME.Close ENDPUBLIC SUB txtCommand_Activate() DIM sLig AS String sLig = txtCommand.Text & gb.NewLine txtConsole.Insert("# " & sLig) txtCommand.Clear sLig = Conv$(sLig, Desktop.Charset, System.Charset) PRINT #$hProcess, sLig; ENDSTATIC PRIVATE FUNCTION Normalize(sStr AS String) AS String DIM sNorm AS String DIM iInd AS Integer DIM iCar AS Integer DIM bEsc AS Boolean FOR iInd = 1 TO Len(sStr) iCar = Asc(sStr, iInd) IF iCar = 27 THEN bEsc = TRUE CONTINUE ENDIF IF bEsc THEN IF iCar < 32 THEN bEsc = FALSE CONTINUE ENDIF IF iCar < 32 AND iCar <> 10 THEN iCar = 32 sNorm = sNorm & Chr$(iCar) NEXT RETURN Conv$(sNorm, System.Charset, Desktop.Charset) END
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -