aboutsummaryrefslogtreecommitdiff
path: root/ShiftOS-TheRevival/TerminalApplications/External/TerminalExternalApps.vb
blob: 24a6435037066a68c1f17335cc50dc435950ecdf (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
Imports System.IO

Module TerminalExternalApps
    Public ShouldChange As Boolean = False
    Public KeyInput As Keys
    'This is for GTN's RAM
    Public TheNumber As Integer = 0
    Public FreezeText As String
    'Basic Calculator's RAM
    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
    'TextPad's RAM
    Public TextPad_FileName As String
    Public TextPad_TempText As New Timer

    Public Sub ChangeCP(Addition As Boolean, NeededCP As Integer)
        Dim TempCP As Integer = Convert.ToInt32(Strings.ComputerInfo(2))
        If Addition = True Then
            TempCP = TempCP + NeededCP
        Else
            TempCP = TempCP - NeededCP
        End If
        Strings.ComputerInfo(2) = Convert.ToString(TempCP)
    End Sub

    Public Sub AppHost(App As Object, UseToolBar As Boolean)
        Select Case App
            Case "bc"
                Console.DefaultPrompt = "> "
                ResetLine("bc (Basic Calcultator)")
                NewLine("Copyright, Free Software Foundation.")
                NewLine("ShiftOS port by DevX.")
                NewLine("This is free software with ABSOLUTELY NO WARRANTY.")
                NewLine(Nothing)
                Console.CurrentInterpreter = "bc"
                ShouldChange = True
            Case "guess" 'Guess the Number
                Console.DefaultPrompt = "Your answer: "
                NewLine("Guess the Number")
                NewLine("Guess the correct number between 1 and 50 and you'll get anything between 1 to 10 Codepoints")
                NewLine("Type 'exit' to terminate this game")
                Console.CurrentInterpreter = "guess"
                GTN_GenerateNumber()
                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
                Console.DefaultPrompt = "Navigate> "
                Console.CurrentInterpreter = "shiftoriumfx"
                ShiftoriumFX_DisplayPackages()
                NewLine(Nothing)
                NewLine("Type any package you want to investigate")
                ShouldChange = True
            Case "textpad"
                Console.DefaultPrompt = Nothing
                Console.TextBox1.Text = Nothing
                Console.ToolBarUse = True
                Console.CheckFeature()
                Console.CurrentInterpreter = "textpad"
                TextPad_CheckExist(command)
                Console.ToolBar.Text = "TextPad - " & command & Environment.NewLine & "Ctrl-Q Exit | Ctrl-N New | Ctrl-O Open | Ctrl-S Save | F12 Save As"
                Console.ReleaseCursor = True
                TextRebind()
        End Select
        If Console.ReleaseCursor = True Then
            'Strings.OnceInfo(5) = Terminal.TrackPos
            'Terminal.TrackPos = Nothing
        End If
        If ShouldChange = True Then
            Console.ChangeInterpreter = True
            ShouldChange = False
        End If
    End Sub

    Public Sub CaptureKeyBinding(KeysInput As Keys)
        Select Case KeysInput
            Case (Keys.S + Keys.Control)
                Select Case Console.CurrentInterpreter
                    Case "textpad"
                        If File.Exists(Console.CurrentDirectory & "\" & command) = True Then
                            Dim TempCompare As String = File.ReadAllText(Console.CurrentDirectory & "\" & command)
                            If Console.TextBox1.Text = TempCompare Then

                            Else
                                Dim BeforeCP As Integer = Strings.ComputerInfo(2)
                                SaveFile(command)
                                TextPad_GenerateCP_SavedFile()
                                Dim AfterCP As Integer = Strings.ComputerInfo(2) - BeforeCP
                                Console.ToolBar.Text = "TextPad - " & command & " - You've got " & AfterCP & " Codepoints" & Environment.NewLine & "Ctrl-Q Exit | Ctrl-N New | Ctrl-O Open | Ctrl-S Save | F12 Save As"
                            End If
                        Else
                            Dim BeforeCP As Integer = Strings.ComputerInfo(2)
                            SaveFile(command)
                            TextPad_GenerateCP_SavedFile()
                            Dim AfterCP As Integer = Strings.ComputerInfo(2) - BeforeCP
                            Console.ToolBar.Text = "TextPad - " & command & " - You've got " & AfterCP & " Codepoints" & Environment.NewLine & "Ctrl-Q Exit | Ctrl-N New | Ctrl-O Open | Ctrl-S Save | F12 Save As"
                        End If
                End Select
            Case (Keys.N + Keys.Control)
                Select Case Console.CurrentInterpreter
                    Case "textpad"
                        Console.TextBox1.Text = Nothing
                End Select
        End Select
    End Sub

    Public Sub TerminateApp(KeyInput As Keys)
        Select Case Console.CurrentInterpreter
            Case "textpad"
                Dim BeforeCP As Integer = Strings.ComputerInfo(2)
                If File.Exists(Console.CurrentDirectory & "\" & command) = True Then
                    Dim TextCompare As String = My.Computer.FileSystem.ReadAllText(Console.CurrentDirectory & "\" & command)
                    If Console.TextBox1.Text = TextCompare Then
                        Console.TextBox1.Text = Nothing
                    Else
                        SaveFile(command)
                        TextPad_GenerateCP_SavedFile()
                        Dim AfterCP As Integer = Strings.ComputerInfo(2) - BeforeCP
                        Console.TextBox1.Text = "You've got " & AfterCP & " Codepoints"
                    End If
                Else
                    SaveFile(command)
                    TextPad_GenerateCP_SavedFile()
                    Dim AfterCP As Integer = Strings.ComputerInfo(2) - BeforeCP
                    Console.TextBox1.Text = "You've got " & AfterCP & " Codepoints"
                End If
                Console.ToolBarUse = False
                Console.ChangeInterpreter = False
                Console.ReleaseCursor = False
                Console.CurrentInterpreter = "terminal"
                Console.CheckFeature()
                Terminal_AssignPrompt()
                Terminal_PrintPrompt()
                TextRebind()
            Case Else
                Console.ToolBarUse = False
                Console.ChangeInterpreter = False
                Console.ReleaseCursor = False
                Console.CurrentInterpreter = "terminal"
                Console.CheckFeature()
                Terminal_AssignPrompt()
                Terminal_PrintPrompt()
                TextRebind()
        End Select
    End Sub

    Public Sub DoChildCommand()
        Select Case Console.CurrentInterpreter
            Case "guess"
                Select Case command
                    Case "exit"
                        TerminateApp(Nothing)
                    Case Else
                        Try
                            GTN_CheckNumber()
                        Catch ex As Exception
                            NewLine("Invalid value!")
                        End Try
                End Select
            Case "shiftoriumfx"
                Select Case command
                    Case ""

                    Case "exit"
                        TerminateApp(Nothing)
                    Case Else
                        ShiftoriumFX_DisplayPackages()
                        NewLine(Nothing)
                        NewLine("Type any package you want to investigate")
                        NewLine("Invalid package or bad command")
                End Select
            Case "bc"
                Select Case command
                    Case "jim"
                        NewLine("69, the funni number")
                        NewLine("gotcha!")
                    Case "ojas"
                        NewLine("dis calculator is very gud")
                        NewLine("it counts from another universe")
                    Case "exit"
                        TerminateApp(Nothing)
                    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 = 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 "."
                                        NewLine("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
                        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
            Case "^"
                BC_Result = FirstNum ^ SecondNum
        End Select
    End Sub

    Public Sub GTN_GenerateNumber()
        Dim RandNum As New Random
        TheNumber = RandNum.Next(1, 51)
    End Sub

    Public Sub GTN_CheckNumber()
        Dim TheirNumber As Integer = Convert.ToInt32(command)
        If TheirNumber > 0 And TheirNumber < 51 Then
            If TheirNumber = TheNumber Then
                Dim GetCP As New Random
                Dim GotCP As Integer = GetCP.Next(1, 11)
                ChangeCP(True, GotCP)
                NewLine("You are correct!, you got " & GotCP & " Codepoint(s)")
                NewLine("Guess the new number between 1 and 50.")
                GTN_GenerateNumber()
            Else
                If TheirNumber < TheNumber Then
                    NewLine("Higher!")
                ElseIf TheirNumber > TheNumber Then
                    NewLine("Lower!")
                End If
            End If
        End If
    End Sub

    Public Sub ShOSKey_InputCommand(lastcommand As String)
        Console.ShOSKey = lastcommand
    End Sub

    Public Sub ShOSKey_Display()
        Console.TextBox1.Text = Console.TextBox1.Text & Console.ShOSKey
        Try
            Console.TrackPos = Console.ShOSKey.Length
        Catch ex As Exception
            Console.TrackPos = 0
        End Try
    End Sub

    Public Sub ShiftoriumFX_DisplayPackages()
        Console.TextBox1.Text = "Shiftorium FX!" & Environment.NewLine & "The place to shiftisize the ShiftOS" & Environment.NewLine & Environment.NewLine & "Available Package(s)"
        Shiftorium_ListFeatures()
    End Sub
End Module