From 5aceb7cf1efbfa21ab6a56e2e0cde13774217f97 Mon Sep 17 00:00:00 2001 From: EverythingWindows Date: Wed, 16 Nov 2022 08:07:44 +0700 Subject: [PATCH] Moving more commands from TerminalAPI into its own module --- ShiftOS-TheRevival/API/TerminalAPI.vb | 47 ++-------- ShiftOS-TheRevival/ShiftOS-TheRevival.vbproj | 6 ++ .../Internal/Com_Cowsay.vb | 85 +++++++++++++++++++ .../Internal/Com_Hostname.vb | 6 ++ .../Internal/Com_Infobar.vb | 25 ++++++ .../Terminal Applications/Internal/Com_Rev.vb | 5 ++ .../Internal/Com_Shiftorium.vb | 18 ++++ .../Internal/Com_Username.vb | 6 ++ .../Internal/TerminalInternalApps.vb | 82 +----------------- 9 files changed, 158 insertions(+), 122 deletions(-) create mode 100644 ShiftOS-TheRevival/Terminal Applications/Internal/Com_Cowsay.vb create mode 100644 ShiftOS-TheRevival/Terminal Applications/Internal/Com_Hostname.vb create mode 100644 ShiftOS-TheRevival/Terminal Applications/Internal/Com_Infobar.vb create mode 100644 ShiftOS-TheRevival/Terminal Applications/Internal/Com_Rev.vb create mode 100644 ShiftOS-TheRevival/Terminal Applications/Internal/Com_Shiftorium.vb create mode 100644 ShiftOS-TheRevival/Terminal Applications/Internal/Com_Username.vb diff --git a/ShiftOS-TheRevival/API/TerminalAPI.vb b/ShiftOS-TheRevival/API/TerminalAPI.vb index a401576..c77524b 100644 --- a/ShiftOS-TheRevival/API/TerminalAPI.vb +++ b/ShiftOS-TheRevival/API/TerminalAPI.vb @@ -218,7 +218,7 @@ End If If command Like "cowsay *" Then If Strings.AvailableFeature(22) = 1 Then - Cowsay_Say(RawCommand.Substring(7)) + Cowsay(RawCommand.Substring(7)) Console.BadCommand = False End If End If @@ -231,35 +231,14 @@ End If If command Like "hostname *" Then If Strings.AvailableFeature(20) = 1 Then - Strings.ComputerInfo(0) = command.Substring(command.LastIndexOf(" ") + 1, command.Length - (command.LastIndexOf(" ") + 1)) - Terminal_AssignPrompt() + Hostname() AdvancedCommand = False Console.BadCommand = False End If End If If command Like "infobar *" Then If Strings.AvailableFeature(4) = "1" Then - 'Infobar panel-ish and some sort - Dim infobarcommand As String = command.Replace("infobar ", "") - Dim advancedtool As Boolean = True - Select Case infobarcommand - Case "on" - Strings.OnceInfo(2) = "True" - Console.CheckFeature() - Console.BadCommand = False - advancedtool = False - Case "off" - Strings.OnceInfo(2) = "False" - Console.CheckFeature() - Console.BadCommand = False - advancedtool = False - End Select - If advancedtool = True Then - If infobarcommand Like "color *" Then - GetColor("infobar", infobarcommand.Substring(6, 1), infobarcommand.Substring(7, 1)) - Console.BadCommand = False - End If - End If + Infobar() End If End If If command Like "man *" Then @@ -283,7 +262,7 @@ End If If command Like "rev *" Then If Strings.AvailableFeature(21) = 1 Then - NewLine(StrReverse(RawCommand.Substring(4))) + Reverse() Console.BadCommand = False AdvancedCommand = False End If @@ -303,20 +282,7 @@ End If End If If command Like "shiftorium *" Then - Dim prompt As String = command.Replace("shiftorium ", "") - NewLine("Shiftorium ShiftOS Center") - If prompt Like "info *" Then - Shiftoriums.prompt = command.Replace("shiftorium info ", "") - Shiftorium_InformationFeatures() - End If - If prompt Like "install *" Then - Shiftoriums.prompt = command.Replace("shiftorium install ", "") - Shiftorium_DetectInstallFeatures() - End If - If prompt = "list" Then - Shiftorium_ListFeatures() - Console.BadCommand = False - End If + Shiftorium() End If If command Like "textpad *" Then If Strings.AvailableFeature(17) = 1 Then @@ -332,8 +298,7 @@ If command.Substring(9) = "root" Then NewLine("This username is already taken!") Else - Strings.ComputerInfo(1) = command.Substring(command.LastIndexOf(" ") + 1, command.Length - (command.LastIndexOf(" ") + 1)) - Terminal_AssignPrompt() + Username() End If AdvancedCommand = False Console.BadCommand = False diff --git a/ShiftOS-TheRevival/ShiftOS-TheRevival.vbproj b/ShiftOS-TheRevival/ShiftOS-TheRevival.vbproj index 528b339..9052206 100644 --- a/ShiftOS-TheRevival/ShiftOS-TheRevival.vbproj +++ b/ShiftOS-TheRevival/ShiftOS-TheRevival.vbproj @@ -154,10 +154,16 @@ + + + + + + diff --git a/ShiftOS-TheRevival/Terminal Applications/Internal/Com_Cowsay.vb b/ShiftOS-TheRevival/Terminal Applications/Internal/Com_Cowsay.vb new file mode 100644 index 0000000..2fd17c1 --- /dev/null +++ b/ShiftOS-TheRevival/Terminal Applications/Internal/Com_Cowsay.vb @@ -0,0 +1,85 @@ +Module Com_Cowsay + Public Sub Cowsay(Say As String) + Select Case Say.Length + Case 1 To 40 + Dim SubtractLength As Integer = Say.Length + 1 + NewLine(" ") + Do + AddLine("_") + SubtractLength = SubtractLength - 1 + If SubtractLength = 0 Then + AddLine("_") + SubtractLength = Say.Length + 1 + Exit Do + End If + Loop + NewLine("< " & Say & " >") + NewLine(" ") + Do + AddLine("-") + SubtractLength = SubtractLength - 1 + If SubtractLength = 0 Then + AddLine("-") + SubtractLength = Say.Length + 1 + Exit Do + End If + Loop + NewLine(" \ ^__^") + NewLine(" \ (oo)\_______") + NewLine(" (__)\ )\/\") + NewLine(" ||----w |") + NewLine(" || ||") + Case 41 To 80 + NewLine(" __________________________________________ ") + NewLine("/ " & Say.Substring(0, 40) & " \") + Say = Say.Substring(40, Say.Length - 40) + NewLine("\ " & Say) + Dim Spaces As Integer = 40 - Say.Length + Do + AddLine(" ") + If Spaces = 0 Then + AddLine("/") + Exit Do + End If + Spaces = Spaces - 1 + Loop + NewLine(" ------------------------------------------ ") + NewLine(" \ ^__^") + NewLine(" \ (oo)\_______") + NewLine(" (__)\ )\/\") + NewLine(" ||----w |") + NewLine(" || ||") + Case >= 81 + NewLine("cowsay: Character limit exceeded") + 'Dim SubtractLength As Integer = Say.Length + 1 + 'Terminal.TextBox1.Text = Terminal.TextBox1.Text & Environment.NewLine & " __________________________________________ " + 'Terminal.TextBox1.Text = Terminal.TextBox1.Text & Environment.NewLine & "/ " & Say.Substring(0, 40) & " \" + 'Dim CurrentLength As Integer = 40 + 'Dim WhatSay As String + 'Dim Spaces As Integer + 'Do + ' Try + ' WhatSay = Say.Substring(CurrentLength, 40) + ' Catch ex As Exception + ' WhatSay = Say.Substring(CurrentLength, (CurrentLength + 40) - Say.Length) + ' End Try + ' Spaces = 40 - WhatSay.Length + ' If Spaces > 0 Then + ' Terminal.TextBox1.Text = Terminal.TextBox1.Text & Environment.NewLine & "\ " & WhatSay + ' Do + ' Terminal.TextBox1.Text = Terminal.TextBox1.Text & " " + ' If Spaces = 0 Then + ' Terminal.TextBox1.Text = Terminal.TextBox1.Text & "/" + ' Exit Do + ' End If + ' Spaces = Spaces - 1 + ' Loop + ' Exit Do + ' Else + ' Terminal.TextBox1.Text = Terminal.TextBox1.Text & Environment.NewLine & "| " & WhatSay & " |" + ' CurrentLength = CurrentLength + 40 + ' End If + 'Loop + End Select + End Sub +End Module diff --git a/ShiftOS-TheRevival/Terminal Applications/Internal/Com_Hostname.vb b/ShiftOS-TheRevival/Terminal Applications/Internal/Com_Hostname.vb new file mode 100644 index 0000000..8903069 --- /dev/null +++ b/ShiftOS-TheRevival/Terminal Applications/Internal/Com_Hostname.vb @@ -0,0 +1,6 @@ +Module Com_Hostname + Public Sub Hostname() + Strings.ComputerInfo(0) = command.Substring(command.LastIndexOf(" ") + 1, command.Length - (command.LastIndexOf(" ") + 1)) + Terminal_AssignPrompt() + End Sub +End Module diff --git a/ShiftOS-TheRevival/Terminal Applications/Internal/Com_Infobar.vb b/ShiftOS-TheRevival/Terminal Applications/Internal/Com_Infobar.vb new file mode 100644 index 0000000..c067125 --- /dev/null +++ b/ShiftOS-TheRevival/Terminal Applications/Internal/Com_Infobar.vb @@ -0,0 +1,25 @@ +Module Com_Infobar + Public Sub Infobar() + 'Infobar panel-ish and some sort + Dim infobarcommand As String = command.Replace("infobar ", "") + Dim advancedtool As Boolean = True + Select Case infobarcommand + Case "on" + Strings.OnceInfo(2) = "True" + Console.CheckFeature() + Console.BadCommand = False + advancedtool = False + Case "off" + Strings.OnceInfo(2) = "False" + Console.CheckFeature() + Console.BadCommand = False + advancedtool = False + End Select + If advancedtool = True Then + If infobarcommand Like "color *" Then + GetColor("infobar", infobarcommand.Substring(6, 1), infobarcommand.Substring(7, 1)) + Console.BadCommand = False + End If + End If + End Sub +End Module diff --git a/ShiftOS-TheRevival/Terminal Applications/Internal/Com_Rev.vb b/ShiftOS-TheRevival/Terminal Applications/Internal/Com_Rev.vb new file mode 100644 index 0000000..b78911f --- /dev/null +++ b/ShiftOS-TheRevival/Terminal Applications/Internal/Com_Rev.vb @@ -0,0 +1,5 @@ +Module Com_Rev + Public Sub Reverse() + NewLine(StrReverse(RawCommand.Substring(4))) + End Sub +End Module diff --git a/ShiftOS-TheRevival/Terminal Applications/Internal/Com_Shiftorium.vb b/ShiftOS-TheRevival/Terminal Applications/Internal/Com_Shiftorium.vb new file mode 100644 index 0000000..47fecd1 --- /dev/null +++ b/ShiftOS-TheRevival/Terminal Applications/Internal/Com_Shiftorium.vb @@ -0,0 +1,18 @@ +Module Com_Shiftorium + Public Sub Shiftorium() + Dim prompt As String = command.Replace("shiftorium ", "") + NewLine("Shiftorium ShiftOS Center") + If prompt Like "info *" Then + Shiftoriums.prompt = command.Replace("shiftorium info ", "") + Shiftorium_InformationFeatures() + End If + If prompt Like "install *" Then + Shiftoriums.prompt = command.Replace("shiftorium install ", "") + Shiftorium_DetectInstallFeatures() + End If + If prompt = "list" Then + Shiftorium_ListFeatures() + Console.BadCommand = False + End If + End Sub +End Module diff --git a/ShiftOS-TheRevival/Terminal Applications/Internal/Com_Username.vb b/ShiftOS-TheRevival/Terminal Applications/Internal/Com_Username.vb new file mode 100644 index 0000000..0f8b4e7 --- /dev/null +++ b/ShiftOS-TheRevival/Terminal Applications/Internal/Com_Username.vb @@ -0,0 +1,6 @@ +Module Com_Username + Public Sub Username() + Strings.ComputerInfo(1) = command.Substring(command.LastIndexOf(" ") + 1, command.Length - (command.LastIndexOf(" ") + 1)) + Terminal_AssignPrompt() + End Sub +End Module diff --git a/ShiftOS-TheRevival/Terminal Applications/Internal/TerminalInternalApps.vb b/ShiftOS-TheRevival/Terminal Applications/Internal/TerminalInternalApps.vb index 0167f72..f4bba89 100644 --- a/ShiftOS-TheRevival/Terminal Applications/Internal/TerminalInternalApps.vb +++ b/ShiftOS-TheRevival/Terminal Applications/Internal/TerminalInternalApps.vb @@ -1,86 +1,6 @@ Module TerminalInternalApps Public Sub Cowsay_Say(Say As String) - Select Case Say.Length - Case 1 To 40 - Dim SubtractLength As Integer = Say.Length + 1 - NewLine(" ") - Do - AddLine("_") - SubtractLength = SubtractLength - 1 - If SubtractLength = 0 Then - AddLine("_") - SubtractLength = Say.Length + 1 - Exit Do - End If - Loop - NewLine("< " & Say & " >") - NewLine(" ") - Do - AddLine("-") - SubtractLength = SubtractLength - 1 - If SubtractLength = 0 Then - AddLine("-") - SubtractLength = Say.Length + 1 - Exit Do - End If - Loop - NewLine(" \ ^__^") - NewLine(" \ (oo)\_______") - NewLine(" (__)\ )\/\") - NewLine(" ||----w |") - NewLine(" || ||") - Case 41 To 80 - NewLine(" __________________________________________ ") - NewLine("/ " & Say.Substring(0, 40) & " \") - Say = Say.Substring(40, Say.Length - 40) - NewLine("\ " & Say) - Dim Spaces As Integer = 40 - Say.Length - Do - AddLine(" ") - If Spaces = 0 Then - AddLine("/") - Exit Do - End If - Spaces = Spaces - 1 - Loop - NewLine(" ------------------------------------------ ") - NewLine(" \ ^__^") - NewLine(" \ (oo)\_______") - NewLine(" (__)\ )\/\") - NewLine(" ||----w |") - NewLine(" || ||") - Case >= 81 - NewLine("cowsay: Character limit exceeded") - 'Dim SubtractLength As Integer = Say.Length + 1 - 'Terminal.TextBox1.Text = Terminal.TextBox1.Text & Environment.NewLine & " __________________________________________ " - 'Terminal.TextBox1.Text = Terminal.TextBox1.Text & Environment.NewLine & "/ " & Say.Substring(0, 40) & " \" - 'Dim CurrentLength As Integer = 40 - 'Dim WhatSay As String - 'Dim Spaces As Integer - 'Do - ' Try - ' WhatSay = Say.Substring(CurrentLength, 40) - ' Catch ex As Exception - ' WhatSay = Say.Substring(CurrentLength, (CurrentLength + 40) - Say.Length) - ' End Try - ' Spaces = 40 - WhatSay.Length - ' If Spaces > 0 Then - ' Terminal.TextBox1.Text = Terminal.TextBox1.Text & Environment.NewLine & "\ " & WhatSay - ' Do - ' Terminal.TextBox1.Text = Terminal.TextBox1.Text & " " - ' If Spaces = 0 Then - ' Terminal.TextBox1.Text = Terminal.TextBox1.Text & "/" - ' Exit Do - ' End If - ' Spaces = Spaces - 1 - ' Loop - ' Exit Do - ' Else - ' Terminal.TextBox1.Text = Terminal.TextBox1.Text & Environment.NewLine & "| " & WhatSay & " |" - ' CurrentLength = CurrentLength + 40 - ' End If - 'Loop - End Select + End Sub Public Sub DateTerm()