diff options
Diffstat (limited to 'shiftos_next/Terminal.vb')
| -rw-r--r-- | shiftos_next/Terminal.vb | 248 |
1 files changed, 105 insertions, 143 deletions
diff --git a/shiftos_next/Terminal.vb b/shiftos_next/Terminal.vb index a4d5304..50df6bc 100644 --- a/shiftos_next/Terminal.vb +++ b/shiftos_next/Terminal.vb @@ -4,10 +4,28 @@ Public prompttoupdatesave As Boolean = False Dim trackpos As Integer = 0 + 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 + + + Public Sub terminal_Innitiate(sender As Object, e As EventArgs) Handles MyBase.Load Me.FormBorderStyle = Windows.Forms.FormBorderStyle.None - Me.WindowState = FormWindowState.Maximized - loadgame() + 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 AddLine(username + "@" + osname + " " & currentdir.ToLower.Replace("c:\shiftos", "~") & "$> ") SelectBottom() If prompttoupdatesave = True Then @@ -17,6 +35,8 @@ + + Public Sub Interpret(command As String) command = command.ToLower If command Like "help" Then @@ -86,116 +106,58 @@ End If Case "textcolor" If boughtterminalsettextcolor Then - Select Case args(2) - Case "black" - AddLine("Error! Black and black don't go too well...") - Case "white" - txtterm.ForeColor = Color.White - Case "gray" - If boughtgray Then - txtterm.ForeColor = Color.Gray - Else - AddLine("Error! Unsupported color.") - End If - Case "red" - If boughtred Then - txtterm.ForeColor = Color.Red - Else - AddLine("Error! Unsupported color.") - End If - Case "green" - If boughtgreen Then - txtterm.ForeColor = Color.Green - Else - AddLine("Error! Unsupported color.") - End If - Case "blue" - If boughtblue Then - txtterm.ForeColor = Color.Blue - Else - AddLine("Error! Unsupported color.") - End If - Case "yellow" - If boughtyellow Then - txtterm.ForeColor = Color.Yellow - Else - AddLine("Error! Unsupported color.") - End If - Case "orange" - If boughtorange Then - txtterm.ForeColor = Color.Orange - Else - AddLine("Error! Unsupported color.") - End If - Case "pink" - If boughtpink Then - txtterm.ForeColor = Color.Pink - Else - AddLine("Error! Unsupported color.") - End If - Case "purple" - If boughtpurple Then - txtterm.ForeColor = Color.Purple - Else - AddLine("Error! Unsupported color.") - End If - Case "brown" - If boughtbrown Then - txtterm.ForeColor = Color.Brown - Else - AddLine("Error! Unsupported color.") - End If - Case Else - AddLine("Error! Unsupported color, check 'colors' for a list of supported colors.") - End Select + terminaltext.ForeColor = SetColorbasic(args(2)) End If Case Else AddLine("set: No valid setting node in configuration file for """ & args(1) & """.") End Select + ElseIf command = "05tray" Then + AddLine("500 Codepoints have been added.") + AddCP(500) ElseIf command Like "open *" Then Dim progtoopen As String = command.Replace("open ", "") - Select Case progtoopen - Case "shiftorium", "packages", "pacman", "code shop" - shiftorium_cmd.Show() - Case "files", "fileskimmer", "file skimmer", "fs", "file browser" - If boughtfileskimmer = True Then - file_skimmer.Show() - Else - AddLine("open: Invalid program """ & progtoopen & """.") - End If - Case "textpad", "text", "notepad" - If boughttextpad = True Then - TextPad.Show() - Else - AddLine("open: Invalid program """ & progtoopen & """.") - End If - Case Else - AddLine("open: Invalid program """ & progtoopen & """.") - End Select - ElseIf command Like "shutdown" Then - savegame() - Me.Close() - 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 = "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) + 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 Else - wrongcommand() + 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 End If - End If End Sub @@ -207,32 +169,32 @@ Dim firstuseconversation As Integer = 0 Private Sub tmrfirstuse_Tick(sender As Object, e As EventArgs) Handles tmrfirstuse.Tick - Select Case firstuseconversation - Case 0 - txtterm.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 - txtterm.ResetText() - AddLine("user@shiftos ~$> ") - txtterm.ReadOnly = False - tmrfirstuse.Stop() - End Select - firstuseconversation += 1 + 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 End Sub - Private Sub txtterm_KeyDown(sender As Object, e As KeyEventArgs) Handles txtterm.KeyDown + Private Sub txtterm_KeyDown(sender As Object, e As KeyEventArgs) Handles terminaltext.KeyDown If prompttoupdatesave = False Then Select Case e.KeyCode @@ -249,7 +211,7 @@ Case Keys.RWin trackpos = trackpos - 1 Case Keys.Right - If txtterm.SelectionStart = txtterm.TextLength Then + If terminaltext.SelectionStart = terminaltext.TextLength Then trackpos = trackpos - 1 End If Case Keys.Left @@ -270,8 +232,8 @@ If e.KeyCode = Keys.Enter Then e.SuppressKeyPress = True If mathquiz = True Then - Dim question As String = txtterm.Lines(txtterm.Lines.Length - 2) - Dim answer As String = txtterm.Lines(txtterm.Lines.Length - 1).Replace("> ", "") + Dim question As String = terminaltext.Lines(terminaltext.Lines.Length - 2) + Dim answer As String = terminaltext.Lines(terminaltext.Lines.Length - 1).Replace("> ", "") If answer = "exit" Then mathquiz = False AddLine(username + "@" + osname + " " & currentdir.ToLower.Replace("c:\shiftos", "~") & "$> ") @@ -284,7 +246,7 @@ AddLine("> ") End If ElseIf guessthenumber = True Then - Dim answer As String = txtterm.Lines(txtterm.Lines.Length - 1).Replace("> ", "") + Dim answer As String = terminaltext.Lines(terminaltext.Lines.Length - 1).Replace("> ", "") If answer = "exit" Then guessthenumber = False AddLine(username + "@" + osname + " " & currentdir.ToLower.Replace("c:\shiftos", "~") & "$> ") @@ -297,35 +259,35 @@ AddLine("> ") End If Else - Dim command As String = txtterm.Lines(txtterm.Lines.Length - 1).Replace(username + "@" + osname + " " & currentdir.ToLower.Replace("c:\shiftos", "~") & "$> ", "").ToLower + Dim command As String = terminaltext.Lines(terminaltext.Lines.Length - 1).Replace(username + "@" + osname + " " & currentdir.ToLower.Replace("c:\shiftos", "~") & "$> ", "").ToLower Interpret(command) If mathquiz Or guessthenumber Then AddLine("> ") Else If command = "clear" Then - txtterm.Text = username + "@" + osname + " " & currentdir.ToLower.Replace("c:\shiftos", "~") & "$> " - txtterm.Select(txtterm.Text.Length, 0) + terminaltext.Text = username + "@" + osname + " " & currentdir.ToLower.Replace("c:\shiftos", "~") & "$> " + terminaltext.Select(terminaltext.Text.Length, 0) Else AddLine(username + "@" + osname + " " & currentdir.ToLower.Replace("c:\shiftos", "~") & "$> ") - txtterm.Select(txtterm.Text.Length, 0) + terminaltext.Select(terminaltext.Text.Length, 0) End If End If - End If - trackpos = 0 + End If + trackpos = 0 Else - If e.KeyCode = Keys.Back Then - Else - trackpos = trackpos + 1 - End If + If e.KeyCode = Keys.Back Then + Else + trackpos = trackpos + 1 + End If End If If e.KeyCode = Keys.Back Then If trackpos < 1 Then e.SuppressKeyPress = True Else - If txtterm.SelectedText.Length < 1 Then + If terminaltext.SelectedText.Length < 1 Then trackpos = trackpos - 1 Else e.SuppressKeyPress = True |
