From ed6f6ee29d5d29a6e06cb15fadb4c0e3520c6e40 Mon Sep 17 00:00:00 2001 From: EverythingWindows Date: Sat, 5 Nov 2022 22:24:30 +0700 Subject: [PATCH] bc finally freaking worked --- .../MainForms/SaveLoadSystem.vb | 3 + ShiftOS-TheRevival/MainForms/Shiftoriums.vb | 16 ++ ShiftOS-TheRevival/MainForms/Strings.vb | 4 +- ShiftOS-TheRevival/MainForms/Terminal.vb | 168 +++++++++--------- ShiftOS-TheRevival/MainForms/TerminalApps.vb | 101 +++++++++-- .../My Project/Resources.Designer.vb | 18 +- ShiftOS-TheRevival/My Project/Resources.resx | 6 +- .../Resources/man Manuals/bc.txt | 1 + ShiftOS-TheRevival/ShiftOS-TheRevival.vbproj | 1 + 9 files changed, 213 insertions(+), 105 deletions(-) create mode 100644 ShiftOS-TheRevival/Resources/man Manuals/bc.txt diff --git a/ShiftOS-TheRevival/MainForms/SaveLoadSystem.vb b/ShiftOS-TheRevival/MainForms/SaveLoadSystem.vb index caaf46a..bf15c45 100644 --- a/ShiftOS-TheRevival/MainForms/SaveLoadSystem.vb +++ b/ShiftOS-TheRevival/MainForms/SaveLoadSystem.vb @@ -12,6 +12,7 @@ Strings.AvailableFeature(6) = "2" Strings.AvailableFeature(7) = "2" Strings.AvailableFeature(8) = "2" + Strings.AvailableFeature(9) = "2" End Sub Public Sub FreeRoamMode() @@ -26,6 +27,7 @@ Strings.AvailableFeature(6) = "3" Strings.AvailableFeature(7) = "1" Strings.AvailableFeature(8) = "1" + Strings.AvailableFeature(9) = "1" End Sub Public Sub GodMode() @@ -40,5 +42,6 @@ Strings.AvailableFeature(6) = "2" Strings.AvailableFeature(7) = "2" Strings.AvailableFeature(8) = "2" + Strings.AvailableFeature(9) = "2" End Sub End Module diff --git a/ShiftOS-TheRevival/MainForms/Shiftoriums.vb b/ShiftOS-TheRevival/MainForms/Shiftoriums.vb index 18a213a..ced477d 100644 --- a/ShiftOS-TheRevival/MainForms/Shiftoriums.vb +++ b/ShiftOS-TheRevival/MainForms/Shiftoriums.vb @@ -34,6 +34,9 @@ End If End If End If + If Strings.AvailableFeature(9) = "0" Then + Terminal.TextBox1.Text = Terminal.TextBox1.Text & Environment.NewLine & "(bc | 10 CP) Basic Calculator" + End If End If End Sub @@ -106,6 +109,13 @@ Terminal.TextBox1.Text = Terminal.TextBox1.Text & Environment.NewLine & ManHeader(0) & Environment.NewLine & Environment.NewLine & "ShiftOS port of Neofetch, A command-line system information tool" & Environment.NewLine & Environment.NewLine & ManHeader(1) Terminal.BadCommand = False End If + Case "bc" + If Strings.AvailableFeature(9) = "0" Then + ManHeader(0) = "Basic Calculator" + ManHeader(1) = "75 CP" + Terminal.TextBox1.Text = Terminal.TextBox1.Text & Environment.NewLine & ManHeader(0) & Environment.NewLine & Environment.NewLine & "Basic Calculator for simple calculation" & Environment.NewLine & Environment.NewLine & ManHeader(1) + Terminal.BadCommand = False + End If Case Else Terminal.BadCommand = False Terminal.TextBox1.Text = Terminal.TextBox1.Text & Environment.NewLine & "Shiftorium: Bad command or not available" @@ -142,6 +152,9 @@ Case "shiftfetch" Shiftorium_InstallFeatures(True, "shiftfetch", 8, 75) Terminal.BadCommand = False + Case "bc" + Shiftorium_InstallFeatures(True, "bc", 9, 75) + Terminal.BadCommand = False Case Else Terminal.BadCommand = False Terminal.TextBox1.Text = Terminal.TextBox1.Text & Environment.NewLine & "Shiftorium: Bad command or not available" @@ -162,6 +175,7 @@ Strings.AvailableFeature(1) = "1" Strings.AvailableFeature(2) = "0" Strings.AvailableFeature(5) = "0" + Strings.AvailableFeature(9) = "0" success = True Case "print" Strings.AvailableFeature(2) = "1" @@ -190,6 +204,8 @@ success = True Case "shiftfetch" Strings.AvailableFeature(8) = "1" + Case "bc" + Strings.AvailableFeature(9) = "1" success = True End Select If success = False Then diff --git a/ShiftOS-TheRevival/MainForms/Strings.vb b/ShiftOS-TheRevival/MainForms/Strings.vb index 89980bd..2b6f37a 100644 --- a/ShiftOS-TheRevival/MainForms/Strings.vb +++ b/ShiftOS-TheRevival/MainForms/Strings.vb @@ -3,7 +3,7 @@ Public Shared ComputerInfo(4) As String Public Shared IsFree As Boolean Public Shared OnceInfo(0) As String - Public Shared AvailableFeature(8) As String + Public Shared AvailableFeature(9) As String Public Shared CLIInterpreter As String Public Shared SaveFile As String @@ -46,11 +46,13 @@ '6 = Time by Minutes [Showing time in minutes form since midnight] (0.2.2) (default : 0) '7 = Time by Hours [Showing time in hours form since midnight] (0.2.2) (default : 0) '8 = Shiftfetch [ShiftOS port of Neofetch, A command-line system information tool] (0.2.3) (default : 0) + '9 = bc [Basic Calculator for ShiftOS] (0.2.3) (default : 0) ' 'Features bought hierarchy : 'ShiftOS Help Manual (MAN) (20 CP) 'Terminal Clear (CLEAR) (25 CP) '>Terminal Print (PRINT) (30 CP) + '>Basic Calculator (BC) (75 CP) '>>Terminal Display Driver (50 CP) '>>>Terminal InfoBar (55 CP) '>>>Shiftfetch (75 CP) diff --git a/ShiftOS-TheRevival/MainForms/Terminal.vb b/ShiftOS-TheRevival/MainForms/Terminal.vb index 4874534..007fdad 100644 --- a/ShiftOS-TheRevival/MainForms/Terminal.vb +++ b/ShiftOS-TheRevival/MainForms/Terminal.vb @@ -108,6 +108,13 @@ Public Class Terminal Case "" AdvancedCommand = False BadCommand = False + Case "bc" + If Strings.AvailableFeature(9) = "1" Then + ChangeInterpreter = True + AppHost("bc") + AdvancedCommand = False + BadCommand = False + End If Case "clear" If Strings.AvailableFeature(1) = "1" Then TextBox1.Text = Nothing @@ -170,11 +177,6 @@ Public Class Terminal TextBox1.Text = TextBox1.Text & Environment.NewLine AdvancedCommand = False BadCommand = False - Case "pause" - ChangeInterpreter = True - AppHost("pause") - AdvancedCommand = False - BadCommand = False Case "reboot" TextBox1.Text = Nothing AdvancedCommand = False @@ -267,6 +269,12 @@ Public Class Terminal Dim TempUsage As String = "'" & mancommand & "' Usage: " Select Case mancommand 'In process to convert every command from printing from code to printing from text file + Case "bc" + If Strings.AvailableFeature(9) = "1" Then + TempUsage = TempUsage & "bc" + TextBox1.Text = TextBox1.Text & TempUsage & Environment.NewLine & Environment.NewLine & My.Resources.man_bc & Environment.NewLine + BadCommand = False + End If Case "clear" If Strings.AvailableFeature(1) = "1" Then TempUsage = TempUsage & "clear" @@ -358,89 +366,85 @@ Public Class Terminal End Sub Private Sub txtterm_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyDown - If CurrentInterpreter = "pause" Then - TerminateApp() - Else - If e.KeyCode = Keys.T AndAlso e.Control Then - Me.Hide() - e.SuppressKeyPress = True - End If + If e.KeyCode = Keys.T AndAlso e.Control Then + Me.Hide() + e.SuppressKeyPress = True + End If - Select Case e.KeyCode - Case Keys.ShiftKey + Select Case e.KeyCode + Case Keys.ShiftKey + TrackPos = TrackPos - 1 + 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 + If TextBox1.SelectionStart = TextBox1.TextLength Then TrackPos = TrackPos - 1 - 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 - If TextBox1.SelectionStart = TextBox1.TextLength Then - 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 - e.SuppressKeyPress = True - TrackPos = TrackPos - 1 - Case Keys.Down - e.SuppressKeyPress = True - TrackPos = TrackPos - 1 - End Select - - If e.KeyCode = Keys.Enter Then - e.SuppressKeyPress = True - If TextBox1.ReadOnly = True Then - - Else - ReadCommand() - If ChangeInterpreter = True Then - DoChildCommand() - PrintPrompt() - TextBox1.Select(TextBox1.Text.Length, 0) - Else - DoCommand() - PrintPrompt() - TextBox1.Select(TextBox1.Text.Length, 0) - End If End If - - 'If command = "clear" Then - ' PrintPrompt() - ' TextBox1.Select(TextBox1.Text.Length, 0) - - 'Else - ' PrintPrompt() - ' TextBox1.Select(TextBox1.Text.Length, 0) - 'End If - - TrackPos = 0 - Else - If e.KeyCode = Keys.Back Then - Else - TrackPos = TrackPos + 1 - End If - End If - - If e.KeyCode = Keys.Back Then + Case Keys.Left If TrackPos < 1 Then e.SuppressKeyPress = True + TrackPos = TrackPos - 1 Else - If TextBox1.SelectedText.Length < 1 Then - TrackPos = TrackPos - 1 - Else - e.SuppressKeyPress = True - End If + TrackPos = TrackPos - 2 + End If + Case Keys.Up + e.SuppressKeyPress = True + TrackPos = TrackPos - 1 + Case Keys.Down + e.SuppressKeyPress = True + TrackPos = TrackPos - 1 + End Select + + If e.KeyCode = Keys.Enter Then + e.SuppressKeyPress = True + If TextBox1.ReadOnly = True Then + + Else + ReadCommand() + If ChangeInterpreter = True Then + DoChildCommand() + PrintPrompt() + TextBox1.Select(TextBox1.Text.Length, 0) + Else + DoCommand() + PrintPrompt() + TextBox1.Select(TextBox1.Text.Length, 0) + End If + End If + + 'If command = "clear" Then + ' PrintPrompt() + ' TextBox1.Select(TextBox1.Text.Length, 0) + + 'Else + ' PrintPrompt() + ' TextBox1.Select(TextBox1.Text.Length, 0) + 'End If + + TrackPos = 0 + 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 diff --git a/ShiftOS-TheRevival/MainForms/TerminalApps.vb b/ShiftOS-TheRevival/MainForms/TerminalApps.vb index 517dfd2..b45cc0d 100644 --- a/ShiftOS-TheRevival/MainForms/TerminalApps.vb +++ b/ShiftOS-TheRevival/MainForms/TerminalApps.vb @@ -2,6 +2,15 @@ Public ShouldChange As Boolean = False 'This is for GTN's RAM Public TheNumber As Integer = 0 + Public FreezeText As String + Public BC_ReadNumbers As Integer + Public BC_Numbers1 As String + Public BC_Numbers2 As String + Public BC_ThriceMoreValue As Integer + Public BC_ThriceMoreCount As Integer + Public BC_CurrentNumber As String + Public BC_Result As Integer + Public BC_Operation2 As String Public Sub ChangeCP(Addition As Boolean, NeededCP As Integer) Dim TempCP As Integer = Convert.ToInt32(Strings.ComputerInfo(2)) @@ -15,17 +24,24 @@ Public Sub AppHost(App As Object) Select Case App + Case "bc" + Terminal.DefaultPrompt = "> " + Terminal.TextBox1.Text = "bc (Basic Calcultator)" & Environment.NewLine & "Copyright, Free Software Foundation." & Environment.NewLine & "ShiftOS port by DevX." & Environment.NewLine & "This is free software with ABSOLUTELY NO WARRANTY." & Environment.NewLine + Terminal.CurrentInterpreter = "bc" + ShouldChange = True Case "guess" 'Guess the Number Terminal.DefaultPrompt = "Your answer: " Terminal.TextBox1.Text = Terminal.TextBox1.Text & Environment.NewLine & "Guess the Number" & Environment.NewLine & "Guess the correct number between 1 and 50 and you'll get anything between 1 to 5 Codepoints" & Environment.NewLine & "Type 'exit' to terminate this game" Terminal.CurrentInterpreter = "guess" GTN_GenerateNumber() ShouldChange = True - Case "pause" 'Pause function - Terminal.DefaultPrompt = "Press any key to continue..." - Terminal.CurrentInterpreter = "pause" - Terminal.TextBox1.ReadOnly = True - ShouldChange = True + 'Revisit Later + 'Case "pause" 'Pause function + ' Terminal.TextBox1.ReadOnly = True + ' Terminal.DefaultPrompt = "Press any key to continue..." + ' Terminal.CurrentInterpreter = "pause" + ' FreezeText = Terminal.TextBox1.Text + ' ShouldChange = True Case "shiftoriumfx" 'ShiftoriumFX : Advanced Shiftorium Terminal.DefaultPrompt = "Navigate> " Terminal.CurrentInterpreter = "shiftoriumfx" @@ -42,9 +58,7 @@ Public Sub TerminateApp() Terminal.ChangeInterpreter = False Terminal.CurrentInterpreter = "terminal" - Terminal.PrintPrompt() Terminal.AssignPrompt() - Terminal.TextBox1.ReadOnly = False End Sub Public Sub DoChildCommand() @@ -60,11 +74,9 @@ Terminal.TextBox1.Text = Terminal.TextBox1.Text & Environment.NewLine & "Invalid value!" End Try End Select - Case "pause" - TerminateApp() Case "shiftoriumfx" Select Case Terminal.command - 'Case "" + Case "" Case "exit" TerminateApp() @@ -72,6 +84,75 @@ ShiftoriumFX_DisplayPackages() Terminal.TextBox1.Text = Terminal.TextBox1.Text & Environment.NewLine & Environment.NewLine & "Type any package you want to investigate" & Environment.NewLine & "Invalid package or bad command" End Select + Case "bc" + Select Case Terminal.command + Case "jim" + Terminal.TextBox1.Text = Terminal.TextBox1.Text & Environment.NewLine & "69, the funni number" & Environment.NewLine & "gotcha!" + Case "ojas" + Terminal.TextBox1.Text = Terminal.TextBox1.Text & Environment.NewLine & "dis calculator is very gud" & Environment.NewLine & "it counts from another universe" + Case "exit" + TerminateApp() + Case Else + BC_ReadNumbers = 0 + BC_ThriceMoreValue = 1 + BC_Numbers1 = Nothing + BC_Numbers2 = Nothing + BC_Operation2 = Nothing + BC_CurrentNumber = Nothing + BC_Result = Nothing + Dim GetText As String + Try + Do + GetText = Terminal.command.Chars(BC_ReadNumbers) + Select Case GetText + Case "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" + BC_CurrentNumber = BC_CurrentNumber & GetText + Case "+", "-", "*", "/" + Dim BC_Numbers3 As Integer + Select Case BC_ThriceMoreValue + Case 1 + BC_Numbers1 = BC_CurrentNumber + BC_CurrentNumber = Nothing + BC_Operation2 = GetText + BC_ThriceMoreValue = BC_ThriceMoreValue + 1 + Case >= 2 + BC_Numbers2 = BC_CurrentNumber + BC_Counting(BC_Numbers1, BC_Numbers2, BC_Operation2) + BC_Numbers3 = BC_Result + BC_Numbers1 = BC_Numbers3 + BC_Numbers2 = Nothing + BC_CurrentNumber = Nothing + BC_ThriceMoreValue = BC_ThriceMoreValue + 1 + End Select + BC_Operation2 = GetText + Case "." + Terminal.TextBox1.Text = Terminal.TextBox1.Text & "Decimals aren't supported yet!" + Case Else + 'BC_Counting(BC_Numbers1, BC_Numbers2, BC_Operation2) + End Select + BC_ReadNumbers = BC_ReadNumbers + 1 + Loop + Catch ex As Exception + BC_Numbers2 = BC_CurrentNumber + BC_CurrentNumber = Nothing + End Try + BC_Counting(BC_Numbers1, BC_Numbers2, BC_Operation2) + BC_ThriceMoreValue = Nothing + Terminal.TextBox1.Text = Terminal.TextBox1.Text & Environment.NewLine & BC_Result + End Select + End Select + End Sub + + Public Sub BC_Counting(FirstNum As Integer, SecondNum As Integer, Operation As String) + Select Case Operation + Case "+" + BC_Result = FirstNum + SecondNum + Case "-" + BC_Result = FirstNum - SecondNum + Case "*" + BC_Result = FirstNum * SecondNum + Case "/" + BC_Result = FirstNum / SecondNum End Select End Sub diff --git a/ShiftOS-TheRevival/My Project/Resources.Designer.vb b/ShiftOS-TheRevival/My Project/Resources.Designer.vb index 1757b17..b99a0c7 100644 --- a/ShiftOS-TheRevival/My Project/Resources.Designer.vb +++ b/ShiftOS-TheRevival/My Project/Resources.Designer.vb @@ -60,15 +60,6 @@ Namespace My.Resources End Set End Property - ''' - ''' Looks up a localized string similar to . - ''' - Friend ReadOnly Property BuildString() As String - Get - Return ResourceManager.GetString("BuildString", resourceCulture) - End Get - End Property - ''' ''' Looks up a localized string similar to 0.2.2. ''' @@ -78,6 +69,15 @@ Namespace My.Resources End Get End Property + ''' + ''' Looks up a localized string similar to A basic command-line tool for simple calculation.. + ''' + Friend ReadOnly Property man_bc() As String + Get + Return ResourceManager.GetString("man_bc", resourceCulture) + End Get + End Property + ''' ''' Looks up a localized string similar to Clears all contents of the terminal. ''' diff --git a/ShiftOS-TheRevival/My Project/Resources.resx b/ShiftOS-TheRevival/My Project/Resources.resx index d135df8..31da24f 100644 --- a/ShiftOS-TheRevival/My Project/Resources.resx +++ b/ShiftOS-TheRevival/My Project/Resources.resx @@ -117,13 +117,13 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - ..\Resources\CurrentVersion.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252 + + ..\resources\man manuals\bc.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8 + ..\resources\man manuals\clear.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8 diff --git a/ShiftOS-TheRevival/Resources/man Manuals/bc.txt b/ShiftOS-TheRevival/Resources/man Manuals/bc.txt new file mode 100644 index 0000000..c710e86 --- /dev/null +++ b/ShiftOS-TheRevival/Resources/man Manuals/bc.txt @@ -0,0 +1 @@ +A basic command-line tool for simple calculation. \ No newline at end of file diff --git a/ShiftOS-TheRevival/ShiftOS-TheRevival.vbproj b/ShiftOS-TheRevival/ShiftOS-TheRevival.vbproj index be2ccfc..d0d464b 100644 --- a/ShiftOS-TheRevival/ShiftOS-TheRevival.vbproj +++ b/ShiftOS-TheRevival/ShiftOS-TheRevival.vbproj @@ -196,6 +196,7 @@ +