2022-11-02 17:28:19 -04:00
|
|
|
|
Imports System.IO
|
|
|
|
|
|
2022-11-13 03:15:05 -05:00
|
|
|
|
Public Class Console
|
2022-11-16 22:56:11 -05:00
|
|
|
|
Public TrackPos As Integer 'Tracking the position of the caret in order to not bypass the user@hostname string
|
|
|
|
|
Public DefaultPrompt As String 'Default prompt to display in ShiftOS, usually it's user@hostname
|
|
|
|
|
Public BadCommand As Boolean 'Detect if it's a bad command or not
|
|
|
|
|
Public DisplayStory As Integer 'Keep record for displaying the DevX's or other's monologue
|
|
|
|
|
Public StoryToTell As String 'Which chapter that you're going to be in
|
|
|
|
|
Public ChangeInterpreter As Boolean = False 'Default interpreter is Terminal, if it's changed to True, there'll be other program used by Console
|
|
|
|
|
Public CurrentInterpreter As String = "terminal" 'Shows what program is using Console
|
|
|
|
|
Public CurrentDirectory As String 'Current Directory for ShiftOS Explorer
|
|
|
|
|
Public Pseudodir As String 'Pseudo-directory for ShiftFS
|
|
|
|
|
Public StayAtChapter As Boolean = False 'If this set to true, then intro for chapters are mostly going to be in
|
|
|
|
|
Public ToolBarUse As Boolean = False 'Either any program is using ToolBar or not
|
|
|
|
|
Public ReleaseCursor As Boolean = False 'Release cursor from TrackPos
|
|
|
|
|
Public ShOSKey As String 'DOSKEY tracking string for ShiftOS
|
2022-11-01 18:57:27 -04:00
|
|
|
|
|
2022-11-13 03:15:05 -05:00
|
|
|
|
Private Sub Console_Load(sender As Object, e As EventArgs) Handles MyBase.Load
|
2022-11-15 20:28:22 -05:00
|
|
|
|
Console_Full()
|
2022-11-04 19:27:35 -04:00
|
|
|
|
Cursor.Hide()
|
2022-11-04 02:12:41 -04:00
|
|
|
|
InitializeTerminal()
|
|
|
|
|
End Sub
|
|
|
|
|
|
|
|
|
|
Public Sub InitializeTerminal()
|
2022-11-06 04:22:35 -05:00
|
|
|
|
Strings.OnceInfo(1) = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\ShiftOS\ShiftFS"
|
2022-11-06 03:20:38 -05:00
|
|
|
|
Strings.OnceInfo(4) = "!"
|
2022-11-08 01:02:02 -05:00
|
|
|
|
Strings.OnceInfo(7) = Width
|
|
|
|
|
Strings.OnceInfo(8) = Height
|
2022-11-01 18:57:27 -04:00
|
|
|
|
If Strings.IsFree = True Then
|
|
|
|
|
Strings.ComputerInfo(0) = "shiftos"
|
|
|
|
|
Strings.ComputerInfo(1) = "user"
|
2022-11-04 02:12:41 -04:00
|
|
|
|
CheckFeature()
|
2022-11-13 03:15:05 -05:00
|
|
|
|
Terminal_PrintPrompt()
|
|
|
|
|
Terminal_AssignPrompt()
|
2022-11-01 21:52:31 -04:00
|
|
|
|
Else
|
2022-11-05 20:21:26 -04:00
|
|
|
|
If StayAtChapter = True Then
|
2022-11-06 06:45:00 -05:00
|
|
|
|
LoadGame()
|
2022-11-04 02:12:41 -04:00
|
|
|
|
CheckFeature()
|
2022-11-13 03:15:05 -05:00
|
|
|
|
Terminal_PrintPrompt()
|
|
|
|
|
Terminal_AssignPrompt()
|
2022-11-05 20:21:26 -04:00
|
|
|
|
Else
|
|
|
|
|
If Strings.ComputerInfo(3) = "0" Then
|
|
|
|
|
TextBox1.ReadOnly = True
|
|
|
|
|
StayAtChapter = True
|
|
|
|
|
StoryOnlyTimer.Start()
|
|
|
|
|
Else
|
2022-11-06 06:45:00 -05:00
|
|
|
|
LoadGame()
|
2022-11-05 20:21:26 -04:00
|
|
|
|
CheckFeature()
|
2022-11-13 03:15:05 -05:00
|
|
|
|
Terminal_PrintPrompt()
|
|
|
|
|
Terminal_AssignPrompt()
|
2022-11-05 20:21:26 -04:00
|
|
|
|
End If
|
2022-11-02 17:28:19 -04:00
|
|
|
|
End If
|
2022-11-01 18:57:27 -04:00
|
|
|
|
End If
|
2022-11-06 03:20:38 -05:00
|
|
|
|
CurrentDirectory = Strings.OnceInfo(1)
|
|
|
|
|
Pseudodir = CurrentDirectory.Replace(Strings.OnceInfo(1), "!\")
|
2022-11-13 03:15:05 -05:00
|
|
|
|
TextRebind()
|
2022-11-01 18:57:27 -04:00
|
|
|
|
End Sub
|
|
|
|
|
|
2022-11-04 02:12:41 -04:00
|
|
|
|
Public Sub CheckFeature()
|
|
|
|
|
If Strings.AvailableFeature(4) = "1" Then
|
2022-11-06 06:45:00 -05:00
|
|
|
|
If ToolBarUse = True Then
|
|
|
|
|
If Strings.OnceInfo(2) = "True" Then
|
|
|
|
|
InfoBarTimer.Start()
|
|
|
|
|
TextBox1.Dock = DockStyle.None
|
|
|
|
|
ToolBar.Visible = True
|
|
|
|
|
ToolBar.SendToBack()
|
|
|
|
|
InfoBar.Visible = True
|
|
|
|
|
InfoBar.SendToBack()
|
|
|
|
|
TextBox1.Dock = DockStyle.Fill
|
|
|
|
|
Else
|
|
|
|
|
TextBox1.Dock = DockStyle.None
|
|
|
|
|
InfoBar.Visible = False
|
|
|
|
|
ToolBar.Visible = True
|
|
|
|
|
ToolBar.SendToBack()
|
|
|
|
|
TextBox1.Dock = DockStyle.Fill
|
|
|
|
|
End If
|
2022-11-06 02:24:53 -05:00
|
|
|
|
Else
|
2022-11-06 06:45:00 -05:00
|
|
|
|
If Strings.OnceInfo(2) = "True" Then
|
|
|
|
|
InfoBarTimer.Start()
|
|
|
|
|
TextBox1.Dock = DockStyle.None
|
|
|
|
|
InfoBar.Visible = True
|
|
|
|
|
InfoBar.SendToBack()
|
|
|
|
|
ToolBar.Visible = False
|
|
|
|
|
TextBox1.Dock = DockStyle.Fill
|
|
|
|
|
Else
|
|
|
|
|
TextBox1.Dock = DockStyle.None
|
|
|
|
|
InfoBar.Visible = False
|
|
|
|
|
ToolBar.Visible = False
|
|
|
|
|
TextBox1.Dock = DockStyle.Fill
|
|
|
|
|
End If
|
2022-11-06 02:24:53 -05:00
|
|
|
|
End If
|
2022-11-04 02:12:41 -04:00
|
|
|
|
Else
|
|
|
|
|
TextBox1.Dock = DockStyle.None
|
|
|
|
|
InfoBar.Visible = False
|
|
|
|
|
TextBox1.Dock = DockStyle.Fill
|
|
|
|
|
End If
|
|
|
|
|
End Sub
|
|
|
|
|
|
2022-11-07 02:16:34 -05:00
|
|
|
|
Private Sub txtterm_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyDown
|
2022-11-13 03:15:05 -05:00
|
|
|
|
KeyInput = e.KeyData
|
2022-11-16 23:44:01 -05:00
|
|
|
|
InputKey = e.KeyData
|
|
|
|
|
ShortcutHandle()
|
2022-11-06 06:45:00 -05:00
|
|
|
|
If ReleaseCursor = True Then
|
|
|
|
|
|
|
|
|
|
Else
|
2022-11-07 02:16:34 -05:00
|
|
|
|
Select Case e.KeyData
|
|
|
|
|
Case Keys.Enter
|
|
|
|
|
e.SuppressKeyPress = True
|
|
|
|
|
If TextBox1.ReadOnly = True Then
|
2022-11-06 06:45:00 -05:00
|
|
|
|
|
2022-11-07 02:16:34 -05:00
|
|
|
|
Else
|
2022-11-13 03:15:05 -05:00
|
|
|
|
Terminal_ReadCommand()
|
2022-11-07 22:22:01 -05:00
|
|
|
|
If Strings.AvailableFeature(18) = 1 Then
|
|
|
|
|
ShOSKey_InputCommand(command)
|
|
|
|
|
End If
|
2022-11-07 02:16:34 -05:00
|
|
|
|
If ChangeInterpreter = True Then
|
|
|
|
|
DoChildCommand()
|
2022-11-13 03:15:05 -05:00
|
|
|
|
Terminal_PrintPrompt()
|
2022-11-07 02:16:34 -05:00
|
|
|
|
TextRebind()
|
2022-11-06 06:45:00 -05:00
|
|
|
|
Else
|
2022-11-14 08:09:29 -05:00
|
|
|
|
Terminal_DoCommand()
|
2022-11-13 03:15:05 -05:00
|
|
|
|
Terminal_PrintPrompt()
|
2022-11-07 02:16:34 -05:00
|
|
|
|
TextRebind()
|
2022-11-06 06:45:00 -05:00
|
|
|
|
End If
|
2022-11-07 02:16:34 -05:00
|
|
|
|
End If
|
|
|
|
|
TrackPos = 0
|
2022-11-13 22:25:13 -05:00
|
|
|
|
Case Keys.ShiftKey, Keys.LShiftKey, Keys.RShiftKey, Keys.Alt, Keys.ControlKey, Keys.LWin, Keys.RWin
|
2022-11-07 02:16:34 -05:00
|
|
|
|
e.SuppressKeyPress = True
|
2022-11-13 22:25:13 -05:00
|
|
|
|
TrackPos = TrackPos
|
2022-11-07 02:16:34 -05:00
|
|
|
|
Case Keys.Back
|
|
|
|
|
If TrackPos <= 0 Then
|
2022-11-06 06:45:00 -05:00
|
|
|
|
e.SuppressKeyPress = True
|
|
|
|
|
Else
|
2022-11-07 02:16:34 -05:00
|
|
|
|
TrackPos = TrackPos - 1
|
|
|
|
|
'If TextBox1.SelectedText.Length < 1 Then
|
|
|
|
|
' TrackPos = TrackPos - 1
|
|
|
|
|
'Else
|
|
|
|
|
' e.SuppressKeyPress = True
|
|
|
|
|
'End If
|
2022-11-06 06:45:00 -05:00
|
|
|
|
End If
|
2022-11-07 02:16:34 -05:00
|
|
|
|
Case Keys.Right
|
|
|
|
|
If TextBox1.SelectionStart = TextBox1.TextLength Then
|
2022-11-06 06:45:00 -05:00
|
|
|
|
Else
|
|
|
|
|
TrackPos = TrackPos + 1
|
|
|
|
|
End If
|
2022-11-07 02:16:34 -05:00
|
|
|
|
'If TrackPos <= 0 Then
|
|
|
|
|
' Dim CommandChar As String
|
|
|
|
|
' CommandChar = TextBox1.Lines(TextBox1.Lines.Length - 1)
|
|
|
|
|
' CommandChar = CommandChar.Replace(DefaultPrompt, "")
|
|
|
|
|
' TrackPos = CommandChar.Length - 1
|
|
|
|
|
' TextBox1.Select(TextBox1.TextLength, 0)
|
|
|
|
|
' TextBox1.ScrollToCaret()
|
|
|
|
|
'End If
|
|
|
|
|
Case Keys.Left
|
|
|
|
|
If TextBox1.SelectionStart = 0 Then
|
2022-11-06 06:45:00 -05:00
|
|
|
|
e.SuppressKeyPress = True
|
|
|
|
|
Else
|
2022-11-07 02:16:34 -05:00
|
|
|
|
TrackPos = TrackPos - 1
|
2022-11-06 06:45:00 -05:00
|
|
|
|
End If
|
2022-11-07 02:16:34 -05:00
|
|
|
|
If TrackPos <= 0 Then
|
|
|
|
|
Dim CommandChar As String
|
|
|
|
|
CommandChar = TextBox1.Lines(TextBox1.Lines.Length - 1)
|
|
|
|
|
CommandChar = CommandChar.Replace(DefaultPrompt, "")
|
|
|
|
|
TrackPos = CommandChar.Length - 1
|
|
|
|
|
TextBox1.Select(TextBox1.TextLength, 0)
|
|
|
|
|
TextBox1.ScrollToCaret()
|
|
|
|
|
End If
|
|
|
|
|
'If TrackPos < 1 Then
|
|
|
|
|
' e.SuppressKeyPress = True
|
|
|
|
|
' TrackPos = TrackPos - 1
|
|
|
|
|
'Else
|
|
|
|
|
' TrackPos = TrackPos - 2
|
|
|
|
|
'End If
|
|
|
|
|
Case Keys.Up
|
|
|
|
|
e.SuppressKeyPress = True
|
2022-11-07 22:22:01 -05:00
|
|
|
|
If Strings.AvailableFeature(18) = 1 Then
|
|
|
|
|
ShOSKey_Display()
|
|
|
|
|
TextRebind()
|
|
|
|
|
End If
|
2022-11-07 02:16:34 -05:00
|
|
|
|
Case Keys.Down
|
|
|
|
|
e.SuppressKeyPress = True
|
2022-11-07 22:22:01 -05:00
|
|
|
|
If Strings.AvailableFeature(18) = 1 Then
|
|
|
|
|
ShOSKey_Display()
|
|
|
|
|
TextRebind()
|
|
|
|
|
End If
|
2022-11-07 02:16:34 -05:00
|
|
|
|
Case Else
|
|
|
|
|
TrackPos = TrackPos + 1
|
|
|
|
|
End Select
|
2022-11-06 06:45:00 -05:00
|
|
|
|
End If
|
2022-11-07 02:16:34 -05:00
|
|
|
|
'If e.KeyCode = Keys.Enter Then
|
|
|
|
|
' 'If command = "clear" Then
|
|
|
|
|
' ' txtterm.Text = txtterm.Text + ShiftOSDesktop.username & "@" & ShiftOSDesktop.osname & " $> "
|
|
|
|
|
' ' txtterm.Select(txtterm.Text.Length, 0)
|
|
|
|
|
|
|
|
|
|
' 'Else
|
|
|
|
|
' ' txtterm.Text = txtterm.Text + Environment.NewLine & ShiftOSDesktop.username & "@" & ShiftOSDesktop.osname & " $> "
|
|
|
|
|
' ' txtterm.Select(txtterm.Text.Length, 0)
|
|
|
|
|
' 'End If
|
|
|
|
|
'Else
|
|
|
|
|
' 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 TextBox1.SelectedText.Length < 1 Then
|
|
|
|
|
' ' TrackPos = TrackPos - 1
|
|
|
|
|
' ' Else
|
|
|
|
|
' ' e.SuppressKeyPress = True
|
|
|
|
|
' ' End If
|
|
|
|
|
' 'End If
|
|
|
|
|
'End If
|
2022-11-01 18:57:27 -04:00
|
|
|
|
End Sub
|
|
|
|
|
|
|
|
|
|
Private Sub TextBox1_Click(sender As Object, e As EventArgs) Handles TextBox1.Click, TextBox1.MouseDoubleClick
|
2022-11-13 03:15:05 -05:00
|
|
|
|
TextRebind()
|
2022-11-01 18:57:27 -04:00
|
|
|
|
End Sub
|
2022-11-02 17:28:19 -04:00
|
|
|
|
|
|
|
|
|
Private Sub StoryOnlyTimer_Tick(sender As Object, e As EventArgs) Handles StoryOnlyTimer.Tick
|
2022-11-16 22:56:11 -05:00
|
|
|
|
StoryLineIntro(DisplayStory)
|
2022-11-02 17:28:19 -04:00
|
|
|
|
DisplayStory = DisplayStory + 1
|
|
|
|
|
End Sub
|
2022-11-04 02:12:41 -04:00
|
|
|
|
|
|
|
|
|
Private Sub InfoBarTimer_Tick(sender As Object, e As EventArgs) Handles InfoBarTimer.Tick
|
|
|
|
|
InfoBar.Text = "|"
|
|
|
|
|
If Strings.AvailableFeature(5) = "1" Then
|
|
|
|
|
InfoBar.Text = InfoBar.Text & " " & Math.Floor(Date.Now.Subtract(Date.Today).TotalSeconds) & " |"
|
|
|
|
|
ElseIf Strings.AvailableFeature(5) = "3" Then
|
|
|
|
|
If Strings.AvailableFeature(6) = "1" Then
|
|
|
|
|
InfoBar.Text = InfoBar.Text & " " & Math.Floor(Date.Now.Subtract(Date.Today).TotalMinutes) & " |"
|
|
|
|
|
ElseIf Strings.AvailableFeature(6) = "3" Then
|
|
|
|
|
If Strings.AvailableFeature(7) = "1" Then
|
|
|
|
|
InfoBar.Text = InfoBar.Text & " " & Math.Floor(Date.Now.Subtract(Date.Today).TotalHours) & " |"
|
2022-11-05 20:21:26 -04:00
|
|
|
|
ElseIf Strings.AvailableFeature(7) = "3" Then
|
|
|
|
|
If Strings.AvailableFeature(12) = "1" Then
|
|
|
|
|
If Date.Now.Hour < 12 Then
|
|
|
|
|
InfoBar.Text = InfoBar.Text & Environment.NewLine & " " & TimeOfDay.Hour & " AM |"
|
|
|
|
|
Else
|
|
|
|
|
InfoBar.Text = InfoBar.Text & Environment.NewLine & " " & TimeOfDay.Hour - 12 & " PM |"
|
|
|
|
|
End If
|
2022-11-13 03:15:05 -05:00
|
|
|
|
ElseIf Strings.AvailableFeature(12) = "3" Then
|
|
|
|
|
If Strings.AvailableFeature(23) = "1" Then
|
|
|
|
|
InfoBar.Text = InfoBar.Text & Environment.NewLine & " " & TimeOfDay.Hour & ":" & TimeOfDay.Minute & " |"
|
|
|
|
|
End If
|
2022-11-05 20:21:26 -04:00
|
|
|
|
End If
|
2022-11-04 02:12:41 -04:00
|
|
|
|
End If
|
|
|
|
|
End If
|
|
|
|
|
End If
|
2022-11-13 22:25:13 -05:00
|
|
|
|
If Strings.AvailableFeature(24) = 1 Then
|
|
|
|
|
InfoBar.Text = InfoBar.Text & " " & Date.Now.DayOfYear & " |"
|
|
|
|
|
ElseIf Strings.AvailableFeature(24) = 3 Then
|
|
|
|
|
If Strings.AvailableFeature(25) = 1 Then
|
|
|
|
|
Dim WeekOfYear As String = Date.Now.DayOfYear / 7
|
|
|
|
|
InfoBar.Text = InfoBar.Text & " " & WeekOfYear.Substring(0, 2) & " |"
|
|
|
|
|
ElseIf Strings.AvailableFeature(25) = 3 Then
|
|
|
|
|
If Strings.AvailableFeature(26) = 1 Then
|
|
|
|
|
InfoBar.Text = InfoBar.Text & " " & Date.Now.Month & " |"
|
|
|
|
|
ElseIf Strings.AvailableFeature(26) = 3 Then
|
|
|
|
|
If Strings.AvailableFeature(27) = 1 Then
|
|
|
|
|
InfoBar.Text = InfoBar.Text & " " & Date.Now.Year & " |"
|
|
|
|
|
ElseIf Strings.AvailableFeature(27) = 3 Then
|
|
|
|
|
If Strings.AvailableFeature(28) = 1 Then
|
|
|
|
|
InfoBar.Text = InfoBar.Text & " " & Date.Now.Day & "/" & Date.Now.Month & " |"
|
|
|
|
|
ElseIf Strings.AvailableFeature(28) = 3 Then
|
|
|
|
|
If Strings.AvailableFeature(29) = 1 Then
|
|
|
|
|
InfoBar.Text = InfoBar.Text & " " & Date.Now.Day & "/" & Date.Now.Month & "/" & Date.Now.Year & " |"
|
|
|
|
|
End If
|
|
|
|
|
End If
|
|
|
|
|
End If
|
|
|
|
|
End If
|
|
|
|
|
End If
|
|
|
|
|
End If
|
|
|
|
|
If Strings.OnceInfo(0) = "Yes" Then
|
2022-11-04 02:12:41 -04:00
|
|
|
|
InfoBar.Text = InfoBar.Text & " root |"
|
|
|
|
|
Else
|
|
|
|
|
InfoBar.Text = InfoBar.Text & " user |"
|
|
|
|
|
End If
|
|
|
|
|
InfoBar.Text = InfoBar.Text & " " & CurrentInterpreter & " |"
|
|
|
|
|
InfoBar.Text = InfoBar.Text & " " & Strings.ComputerInfo(2) & " CP |"
|
2022-11-07 02:16:34 -05:00
|
|
|
|
InfoBar.Text = InfoBar.Text & " " & TrackPos & " |"
|
|
|
|
|
End Sub
|
|
|
|
|
|
|
|
|
|
Private Sub TextBox1_Click(sender As Object, e As MouseEventArgs) Handles TextBox1.MouseDoubleClick, TextBox1.Click
|
|
|
|
|
|
2022-11-04 02:12:41 -04:00
|
|
|
|
End Sub
|
2022-11-01 18:57:27 -04:00
|
|
|
|
End Class
|