2015-05-17 14:53:26 +00:00
|
|
|
|
Public Class Terminal
|
|
|
|
|
|
2015-05-17 15:47:42 +00:00
|
|
|
|
Public currentdir As String = root
|
2015-05-18 19:46:07 +00:00
|
|
|
|
Public prompttoupdatesave As Boolean = False
|
2015-05-17 14:53:26 +00:00
|
|
|
|
Dim trackpos As Integer = 0
|
|
|
|
|
|
2015-05-23 14:21:24 +00:00
|
|
|
|
Private Sub Terminal_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing
|
|
|
|
|
If BasicWM.Desktop.openterminals > 0 Then BasicWM.Desktop.openterminals -= 1
|
|
|
|
|
End Sub
|
|
|
|
|
|
|
|
|
|
Private Sub Terminal_GotFocus(sender As Object, e As EventArgs) Handles terminaltext.GotFocus
|
|
|
|
|
API.txtterm = Me.terminaltext
|
|
|
|
|
End Sub
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2015-05-17 14:53:26 +00:00
|
|
|
|
Public Sub terminal_Innitiate(sender As Object, e As EventArgs) Handles MyBase.Load
|
|
|
|
|
Me.FormBorderStyle = Windows.Forms.FormBorderStyle.None
|
2015-05-23 14:21:24 +00:00
|
|
|
|
API.txtterm = Me.terminaltext
|
|
|
|
|
If boughtbasicwm = True Then
|
|
|
|
|
pnltop.Show()
|
|
|
|
|
Me.WindowState = FormWindowState.Normal
|
|
|
|
|
Me.Left = (Screen.PrimaryScreen.Bounds.Width - Me.Width) / 2
|
|
|
|
|
Me.Top = (Screen.PrimaryScreen.Bounds.Height - Me.Height) / 2
|
|
|
|
|
Else
|
|
|
|
|
pnltop.Hide()
|
|
|
|
|
Me.WindowState = FormWindowState.Maximized
|
|
|
|
|
End If
|
2015-05-18 19:46:07 +00:00
|
|
|
|
AddLine(username + "@" + osname + " " & currentdir.ToLower.Replace("c:\shiftos", "~") & "$> ")
|
2015-05-17 14:53:26 +00:00
|
|
|
|
SelectBottom()
|
2015-05-18 19:46:07 +00:00
|
|
|
|
If prompttoupdatesave = True Then
|
|
|
|
|
AddLine("ShiftOS has encountered an error loading configuration files. Press any key to reset damaged files.")
|
|
|
|
|
End If
|
2015-05-17 14:53:26 +00:00
|
|
|
|
End Sub
|
|
|
|
|
|
2015-05-22 21:42:21 +00:00
|
|
|
|
|
2015-05-17 14:53:26 +00:00
|
|
|
|
|
2015-05-23 14:21:24 +00:00
|
|
|
|
|
|
|
|
|
|
2015-05-17 14:53:26 +00:00
|
|
|
|
Public Sub Interpret(command As String)
|
|
|
|
|
command = command.ToLower
|
|
|
|
|
If command Like "help" Then
|
|
|
|
|
ShowHelp()
|
2015-05-17 15:47:42 +00:00
|
|
|
|
ElseIf command Like "cd *" Then
|
2015-05-18 19:46:07 +00:00
|
|
|
|
If boughtdirectorysurfing = True Then
|
|
|
|
|
Dim folder As String = command.Replace("cd ", "")
|
2015-05-17 15:47:42 +00:00
|
|
|
|
|
2015-05-18 19:46:07 +00:00
|
|
|
|
If folder = ".." Then
|
|
|
|
|
If currentdir.ToLower = "c:\shiftos" Then
|
|
|
|
|
AddLine("cd: Error! You are at the root of your drive.")
|
|
|
|
|
Else
|
|
|
|
|
currentdir = IO.Directory.GetParent(currentdir).ToString
|
|
|
|
|
End If
|
2015-05-17 15:47:42 +00:00
|
|
|
|
Else
|
2015-05-18 19:46:07 +00:00
|
|
|
|
If IO.Directory.Exists(currentdir + "\" + folder) Then
|
|
|
|
|
currentdir = currentdir & "\" & folder
|
|
|
|
|
ElseIf IO.Directory.Exists(folder) Then
|
|
|
|
|
currentdir = folder
|
|
|
|
|
Else
|
|
|
|
|
AddLine("cd: Directory """ & folder & """ doesn't exist.")
|
|
|
|
|
End If
|
2015-05-17 15:47:42 +00:00
|
|
|
|
End If
|
|
|
|
|
Else
|
2015-05-18 19:46:07 +00:00
|
|
|
|
wrongcommand()
|
2015-05-17 15:47:42 +00:00
|
|
|
|
End If
|
|
|
|
|
ElseIf command = "dir" Or command = "ls" Then
|
2015-05-18 19:46:07 +00:00
|
|
|
|
If boughtdirectorysurfing Then
|
|
|
|
|
AddLine("Type | Name ")
|
|
|
|
|
AddLine("-------+-------------------------------------------")
|
|
|
|
|
For Each Dir As String In IO.Directory.GetDirectories(currentdir)
|
|
|
|
|
Dim dirinf As New IO.DirectoryInfo(Dir)
|
|
|
|
|
AddLine("[DIR] | " & dirinf.Name)
|
|
|
|
|
Next
|
|
|
|
|
For Each file As String In IO.Directory.GetFiles(currentdir)
|
|
|
|
|
Dim filinf As New IO.FileInfo(file)
|
|
|
|
|
AddLine(filinf.Extension & " | " & filinf.Name)
|
|
|
|
|
Next
|
|
|
|
|
Else
|
|
|
|
|
wrongcommand()
|
|
|
|
|
End If
|
2015-05-17 15:47:42 +00:00
|
|
|
|
ElseIf command Like "mkdir *" Then
|
2015-05-18 19:46:07 +00:00
|
|
|
|
If boughtdirectorysurfing = True Then
|
|
|
|
|
Dim foldertomake As String = command.Replace("mkdir ", "")
|
|
|
|
|
If IO.Directory.Exists(currentdir + "\" + foldertomake) Then
|
|
|
|
|
AddLine("Directory already exists!")
|
|
|
|
|
Else
|
|
|
|
|
IO.Directory.CreateDirectory(currentdir + "\" + foldertomake)
|
|
|
|
|
AddLine("mkdir: Directory created successfully.")
|
|
|
|
|
End If
|
2015-05-17 15:47:42 +00:00
|
|
|
|
Else
|
2015-05-18 19:46:07 +00:00
|
|
|
|
wrongcommand()
|
2015-05-17 15:47:42 +00:00
|
|
|
|
End If
|
2015-05-18 19:46:07 +00:00
|
|
|
|
ElseIf command Like "give me * codepoints" Then
|
|
|
|
|
Dim args() As String = command.Split(" ")
|
|
|
|
|
Dim cp As String = args(2)
|
|
|
|
|
AddCP(cp)
|
|
|
|
|
AddLine("Added " & cp & " to your existing ammount of Codepoints.")
|
|
|
|
|
ElseIf command Like "set * *" Then
|
|
|
|
|
Dim args() As String = command.Split(" ")
|
|
|
|
|
Select Case args(1)
|
|
|
|
|
Case "username"
|
|
|
|
|
If boughtcustomusername Then
|
|
|
|
|
username = args(2)
|
|
|
|
|
Else
|
|
|
|
|
wrongcommand()
|
|
|
|
|
End If
|
|
|
|
|
Case "textcolor"
|
|
|
|
|
If boughtterminalsettextcolor Then
|
2015-05-23 14:21:24 +00:00
|
|
|
|
terminaltext.ForeColor = SetColorbasic(args(2))
|
2015-05-18 19:46:07 +00:00
|
|
|
|
End If
|
|
|
|
|
Case Else
|
|
|
|
|
AddLine("set: No valid setting node in configuration file for """ & args(1) & """.")
|
|
|
|
|
End Select
|
2015-05-23 14:21:24 +00:00
|
|
|
|
ElseIf command = "05tray" Then
|
|
|
|
|
AddLine("500 Codepoints have been added.")
|
|
|
|
|
AddCP(500)
|
2015-05-18 19:46:07 +00:00
|
|
|
|
ElseIf command Like "open *" Then
|
|
|
|
|
Dim progtoopen As String = command.Replace("open ", "")
|
2015-05-23 14:21:24 +00:00
|
|
|
|
OpenProgram(progtoopen)
|
|
|
|
|
ElseIf command Like "close *" Then
|
|
|
|
|
Dim progtoclose As String = command.Replace("close ", "")
|
|
|
|
|
If progtoclose = "terminal" Then
|
|
|
|
|
If boughtbasicwm = True Then
|
|
|
|
|
Me.Close()
|
|
|
|
|
Else
|
|
|
|
|
AddLine("close: Cannot close the Terminal!")
|
|
|
|
|
End If
|
2015-05-22 00:33:08 +00:00
|
|
|
|
Else
|
2015-05-23 14:21:24 +00:00
|
|
|
|
closeprogram(progtoclose)
|
|
|
|
|
End If
|
|
|
|
|
ElseIf command Like "shutdown" Then
|
|
|
|
|
savegame()
|
|
|
|
|
Application.Exit()
|
|
|
|
|
ElseIf command Like "math*" Then
|
|
|
|
|
mathquiz = True
|
|
|
|
|
changeinterpreter()
|
|
|
|
|
ElseIf command Like "guess the number" Or command Like "guess" Then
|
|
|
|
|
guessthenumber = True
|
|
|
|
|
changeinterpreter()
|
|
|
|
|
ElseIf command Like "code*" Or command = "code points" Then
|
|
|
|
|
AddLine("You have " & codepoints & " Codepoints.")
|
|
|
|
|
ElseIf command Like "bwm" Then
|
|
|
|
|
If boughtbasicwm = True Then
|
|
|
|
|
BasicWM.Desktop.Show()
|
|
|
|
|
Else
|
|
|
|
|
wrongcommand()
|
|
|
|
|
End If
|
|
|
|
|
ElseIf command = "colors" Then
|
|
|
|
|
showterminalcolors()
|
|
|
|
|
ElseIf command Like "" Then
|
|
|
|
|
'This is here to make it so that the Terminal doesn't say "Wrong Command" if the user doesn't input anything.
|
|
|
|
|
Else
|
|
|
|
|
If IO.File.Exists(currentdir + "\" + command) Then
|
|
|
|
|
openfile(currentdir + "\" + command)
|
|
|
|
|
ElseIf IO.File.Exists(command) Then
|
|
|
|
|
openfile(command)
|
|
|
|
|
Else
|
|
|
|
|
wrongcommand()
|
|
|
|
|
End If
|
2015-05-22 00:33:08 +00:00
|
|
|
|
End If
|
2015-05-17 14:53:26 +00:00
|
|
|
|
End Sub
|
|
|
|
|
|
2015-05-22 00:33:08 +00:00
|
|
|
|
|
2015-05-18 19:46:07 +00:00
|
|
|
|
|
|
|
|
|
|
2015-05-17 14:53:26 +00:00
|
|
|
|
|
2015-05-22 21:42:21 +00:00
|
|
|
|
|
2015-05-17 14:53:26 +00:00
|
|
|
|
|
|
|
|
|
Dim firstuseconversation As Integer = 0
|
|
|
|
|
|
|
|
|
|
Private Sub tmrfirstuse_Tick(sender As Object, e As EventArgs) Handles tmrfirstuse.Tick
|
2015-05-23 14:21:24 +00:00
|
|
|
|
Select Case firstuseconversation
|
|
|
|
|
Case 0
|
|
|
|
|
terminaltext.ReadOnly = True
|
|
|
|
|
AddLine("IP Address 170.245.12.80 is connecting as ""DevX"".")
|
|
|
|
|
Case 1
|
|
|
|
|
AddLine("DevX: It seems my updates have completly installed.")
|
|
|
|
|
Case 2
|
|
|
|
|
AddLine("DevX: Unfortunately, due to your hard drive being formatted, you have lost all your data.")
|
|
|
|
|
Case 3
|
|
|
|
|
AddLine("DevX: However, Don't worry! I've added some pretty cool features to the Terminal to make up for this.")
|
|
|
|
|
Case 4
|
|
|
|
|
AddLine("DevX: I can't tell you much, except for ""Type Help for a list of commands"".")
|
|
|
|
|
Case 5
|
|
|
|
|
AddLine("DevX: I've got to go, but I'll contact you as I develop more updates; and you test the OS.")
|
|
|
|
|
Case 6
|
|
|
|
|
AddLine("User ""DevX"" has disconnected.")
|
|
|
|
|
Case 7
|
|
|
|
|
terminaltext.ResetText()
|
|
|
|
|
AddLine("user@shiftos ~$> ")
|
|
|
|
|
terminaltext.ReadOnly = False
|
|
|
|
|
tmrfirstuse.Stop()
|
|
|
|
|
End Select
|
|
|
|
|
firstuseconversation += 1
|
2015-05-17 14:53:26 +00:00
|
|
|
|
End Sub
|
|
|
|
|
|
2015-05-23 14:21:24 +00:00
|
|
|
|
Private Sub txtterm_KeyDown(sender As Object, e As KeyEventArgs) Handles terminaltext.KeyDown
|
2015-05-18 19:46:07 +00:00
|
|
|
|
If prompttoupdatesave = False Then
|
|
|
|
|
|
|
|
|
|
Select Case e.KeyCode
|
|
|
|
|
Case Keys.ShiftKey
|
2015-05-17 14:53:26 +00:00
|
|
|
|
trackpos = trackpos - 1
|
2015-05-18 19:46:07 +00:00
|
|
|
|
Case Keys.Alt
|
|
|
|
|
trackpos = trackpos - 1
|
|
|
|
|
Case Keys.CapsLock
|
|
|
|
|
trackpos = trackpos - 1
|
|
|
|
|
Case Keys.ControlKey
|
|
|
|
|
trackpos = trackpos - 1
|
|
|
|
|
Case Keys.LWin
|
|
|
|
|
trackpos = trackpos - 1
|
|
|
|
|
Case Keys.RWin
|
|
|
|
|
trackpos = trackpos - 1
|
|
|
|
|
Case Keys.Right
|
2015-05-23 14:21:24 +00:00
|
|
|
|
If terminaltext.SelectionStart = terminaltext.TextLength Then
|
2015-05-18 19:46:07 +00:00
|
|
|
|
trackpos = trackpos - 1
|
|
|
|
|
End If
|
|
|
|
|
Case Keys.Left
|
|
|
|
|
If trackpos < 1 Then
|
|
|
|
|
e.SuppressKeyPress = True
|
|
|
|
|
trackpos = trackpos - 1
|
|
|
|
|
Else
|
|
|
|
|
trackpos = trackpos - 2
|
|
|
|
|
End If
|
|
|
|
|
Case Keys.Up
|
2015-05-17 14:53:26 +00:00
|
|
|
|
e.SuppressKeyPress = True
|
|
|
|
|
trackpos = trackpos - 1
|
2015-05-18 19:46:07 +00:00
|
|
|
|
Case Keys.Down
|
|
|
|
|
e.SuppressKeyPress = True
|
|
|
|
|
trackpos = trackpos - 1
|
|
|
|
|
End Select
|
2015-05-17 14:53:26 +00:00
|
|
|
|
|
2015-05-18 19:46:07 +00:00
|
|
|
|
If e.KeyCode = Keys.Enter Then
|
|
|
|
|
e.SuppressKeyPress = True
|
2015-05-22 21:42:21 +00:00
|
|
|
|
If mathquiz = True Then
|
2015-05-23 14:21:24 +00:00
|
|
|
|
Dim question As String = terminaltext.Lines(terminaltext.Lines.Length - 2)
|
|
|
|
|
Dim answer As String = terminaltext.Lines(terminaltext.Lines.Length - 1).Replace("> ", "")
|
2015-05-22 21:42:21 +00:00
|
|
|
|
If answer = "exit" Then
|
|
|
|
|
mathquiz = False
|
|
|
|
|
AddLine(username + "@" + osname + " " & currentdir.ToLower.Replace("c:\shiftos", "~") & "$> ")
|
|
|
|
|
Else
|
|
|
|
|
Try
|
|
|
|
|
MQInterpret(question, answer)
|
|
|
|
|
Catch ex As Exception
|
|
|
|
|
AddLine("The answer provided isn't a proper number!")
|
|
|
|
|
End Try
|
|
|
|
|
AddLine("> ")
|
|
|
|
|
End If
|
|
|
|
|
ElseIf guessthenumber = True Then
|
2015-05-23 14:21:24 +00:00
|
|
|
|
Dim answer As String = terminaltext.Lines(terminaltext.Lines.Length - 1).Replace("> ", "")
|
2015-05-22 21:42:21 +00:00
|
|
|
|
If answer = "exit" Then
|
|
|
|
|
guessthenumber = False
|
|
|
|
|
AddLine(username + "@" + osname + " " & currentdir.ToLower.Replace("c:\shiftos", "~") & "$> ")
|
|
|
|
|
Else
|
|
|
|
|
Try
|
|
|
|
|
GTNInterpret(answer)
|
|
|
|
|
Catch ex As Exception
|
|
|
|
|
AddLine("The answer provided isn't a proper number.")
|
|
|
|
|
End Try
|
|
|
|
|
AddLine("> ")
|
|
|
|
|
End If
|
2015-05-18 19:46:07 +00:00
|
|
|
|
Else
|
2015-05-23 14:21:24 +00:00
|
|
|
|
Dim command As String = terminaltext.Lines(terminaltext.Lines.Length - 1).Replace(username + "@" + osname + " " & currentdir.ToLower.Replace("c:\shiftos", "~") & "$> ", "").ToLower
|
2015-05-22 21:42:21 +00:00
|
|
|
|
Interpret(command)
|
|
|
|
|
|
|
|
|
|
If mathquiz Or guessthenumber Then
|
|
|
|
|
AddLine("> ")
|
|
|
|
|
Else
|
|
|
|
|
If command = "clear" Then
|
2015-05-23 14:21:24 +00:00
|
|
|
|
terminaltext.Text = username + "@" + osname + " " & currentdir.ToLower.Replace("c:\shiftos", "~") & "$> "
|
|
|
|
|
terminaltext.Select(terminaltext.Text.Length, 0)
|
2015-05-17 14:53:26 +00:00
|
|
|
|
|
2015-05-22 21:42:21 +00:00
|
|
|
|
Else
|
|
|
|
|
AddLine(username + "@" + osname + " " & currentdir.ToLower.Replace("c:\shiftos", "~") & "$> ")
|
2015-05-23 14:21:24 +00:00
|
|
|
|
terminaltext.Select(terminaltext.Text.Length, 0)
|
2015-05-22 21:42:21 +00:00
|
|
|
|
End If
|
|
|
|
|
End If
|
2015-05-23 14:21:24 +00:00
|
|
|
|
End If
|
|
|
|
|
trackpos = 0
|
2015-05-17 14:53:26 +00:00
|
|
|
|
Else
|
2015-05-23 14:21:24 +00:00
|
|
|
|
If e.KeyCode = Keys.Back Then
|
|
|
|
|
Else
|
|
|
|
|
trackpos = trackpos + 1
|
|
|
|
|
End If
|
2015-05-17 14:53:26 +00:00
|
|
|
|
End If
|
|
|
|
|
|
2015-05-18 19:46:07 +00:00
|
|
|
|
If e.KeyCode = Keys.Back Then
|
|
|
|
|
If trackpos < 1 Then
|
2015-05-17 14:53:26 +00:00
|
|
|
|
e.SuppressKeyPress = True
|
2015-05-18 19:46:07 +00:00
|
|
|
|
Else
|
2015-05-23 14:21:24 +00:00
|
|
|
|
If terminaltext.SelectedText.Length < 1 Then
|
2015-05-18 19:46:07 +00:00
|
|
|
|
trackpos = trackpos - 1
|
|
|
|
|
Else
|
|
|
|
|
e.SuppressKeyPress = True
|
|
|
|
|
End If
|
2015-05-17 14:53:26 +00:00
|
|
|
|
End If
|
|
|
|
|
End If
|
|
|
|
|
|
2015-05-18 19:46:07 +00:00
|
|
|
|
SelectBottom()
|
|
|
|
|
Else
|
|
|
|
|
e.SuppressKeyPress = True
|
|
|
|
|
savegame()
|
|
|
|
|
loadgame()
|
|
|
|
|
AddLine("Self-repair complete with no errors.")
|
|
|
|
|
prompttoupdatesave = False
|
|
|
|
|
AddLine(username + "@" + osname + " " & currentdir.ToLower.Replace("c:\shiftos", "~") & "$> ")
|
|
|
|
|
End If
|
2015-05-17 14:53:26 +00:00
|
|
|
|
End Sub
|
2015-05-22 21:42:21 +00:00
|
|
|
|
|
|
|
|
|
|
2015-05-17 14:53:26 +00:00
|
|
|
|
End Class
|