My Linux Terminal code is here (It's still very buggy and lacks many features.. you can contribute to it if you want):
Code: Select all
; Application: MiniShell [prerelease v0.001] by merihevonen
; Description: Simple Linux Terminal written in PureBasic
; Enumerations
Enumeration
 #MainWindow
EndEnumeration
Enumeration
 #ExecuteButton
 #InputGadget
 #ShellGadget
EndEnumeration
; Application
OpenWindow(#MainWindow, 0, 0, 480, 320, "MiniShell", #PB_Window_ScreenCentered|#PB_Window_SizeGadget)
CreateGadgetList(WindowID(#MainWindow))
 ButtonGadget(#ExecuteButton, WindowWidth(#MainWindow)-105, 5, 100, 25, "Execute")
 StringGadget(#InputGadget, 5, 5, WindowWidth(#MainWindow)-115, 25, "")
 EditorGadget(#ShellGadget, 5, 35, WindowWidth(#MainWindow)-10, WindowHeight(#MainWindow)-40, #PB_Editor_ReadOnly)
SetGadgetText(#ShellGadget, "[MiniShell]: ")
; Loop
Quit=0
Repeat
 Select WaitWindowEvent()
  Case #PB_Event_CloseWindow
   Quit=1
  Case #PB_Event_Gadget
   Select EventGadget()
    Case #ExecuteButton
     Command$=GetGadgetText(#InputGadget)
     If FindString(Command$, " ", 0)<>0
      CommandPos=FindString(Command$, " ", 0)-1
      ACommand$=Trim(Left(Command$, CommandPos))
      BCommand$=Trim(Mid(Command$, CommandPos+2, Len(Command$)-CommandPos))
     Else
      ACommand$=Command$
      BCommand$=""
     EndIf
     SetGadgetText(#ShellGadget, GetGadgetText(#ShellGadget)+Command$+#LF$)
     If ACommand$<>""
      hCmd=RunProgram(ACommand$, BCommand$, "", #PB_Program_Read|#PB_Program_Open)
      While ProgramRunning(hCmd)
        ProgramOutput$+ReadProgramString(hCmd)+#LF$
      Wend
      SetGadgetText(#ShellGadget, GetGadgetText(#ShellGadget)+ProgramOutput$)
      ProgramOutput$=""
      SetGadgetText(#ShellGadget, GetGadgetText(#ShellGadget)+"[MiniShell]: ")
     EndIf
   EndSelect
 EndSelect
Until Quit



