2022-11-07 07:16:34 +00:00
Imports System . IO
2022-11-13 08:15:05 +00:00
Module TerminalExternalApps
2022-11-03 15:27:40 +00:00
Public ShouldChange As Boolean = False
2022-11-07 07:16:34 +00:00
Public KeyInput As Keys
2022-11-03 15:27:40 +00:00
'This is for GTN's RAM
Public TheNumber As Integer = 0
2022-11-05 15:24:30 +00:00
Public FreezeText As String
2022-11-06 08:20:38 +00:00
'Basic Calculator's RAM
2022-11-05 15:24:30 +00:00
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
2022-11-07 07:16:34 +00:00
'TextPad's RAM
Public TextPad_FileName As String
Public TextPad_TempText As New Timer
2022-11-03 15:27:40 +00:00
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
2022-11-06 11:45:00 +00:00
Public Sub AppHost ( App As Object , UseToolBar As Boolean )
2022-11-03 15:27:40 +00:00
Select Case App
2022-11-05 15:24:30 +00:00
Case " bc "
2022-11-13 08:15:05 +00:00
Console . DefaultPrompt = " > "
2022-11-13 14:22:42 +00:00
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 )
2022-11-13 08:15:05 +00:00
Console . CurrentInterpreter = " bc "
2022-11-05 15:24:30 +00:00
ShouldChange = True
2022-11-03 15:27:40 +00:00
Case " guess " 'Guess the Number
2022-11-13 08:15:05 +00:00
Console . DefaultPrompt = " Your answer: "
2022-11-13 14:22:42 +00:00
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 " )
2022-11-13 08:15:05 +00:00
Console . CurrentInterpreter = " guess "
2022-11-03 15:27:40 +00:00
GTN_GenerateNumber ( )
ShouldChange = True
2022-11-05 15:24:30 +00:00
'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
2022-11-04 23:27:35 +00:00
Case " shiftoriumfx " 'ShiftoriumFX : Advanced Shiftorium
2022-11-13 08:15:05 +00:00
Console . DefaultPrompt = " Navigate> "
Console . CurrentInterpreter = " shiftoriumfx "
2022-11-04 22:36:43 +00:00
ShiftoriumFX_DisplayPackages ( )
2022-11-13 14:22:42 +00:00
NewLine ( Nothing )
NewLine ( " Type any package you want to investigate " )
2022-11-04 22:36:43 +00:00
ShouldChange = True
2022-11-06 11:45:00 +00:00
Case " textpad "
2022-11-13 08:15:05 +00:00
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
2022-11-13 14:22:42 +00:00
TextRebind ( )
2022-11-03 15:27:40 +00:00
End Select
2022-11-13 08:15:05 +00:00
If Console . ReleaseCursor = True Then
2022-11-07 07:16:34 +00:00
'Strings.OnceInfo(5) = Terminal.TrackPos
'Terminal.TrackPos = Nothing
2022-11-06 11:45:00 +00:00
End If
2022-11-03 15:27:40 +00:00
If ShouldChange = True Then
2022-11-13 08:15:05 +00:00
Console . ChangeInterpreter = True
2022-11-03 15:27:40 +00:00
ShouldChange = False
End If
End Sub
2022-11-07 07:16:34 +00:00
Public Sub CaptureKeyBinding ( KeysInput As Keys )
Select Case KeysInput
Case ( Keys . S + Keys . Control )
2022-11-13 08:15:05 +00:00
Select Case Console . CurrentInterpreter
2022-11-08 23:30:53 +00:00
Case " textpad "
2022-11-13 08:15:05 +00:00
If File . Exists ( Console . CurrentDirectory & " \ " & command ) = True Then
Dim TempCompare As String = File . ReadAllText ( Console . CurrentDirectory & " \ " & command )
If Console . TextBox1 . Text = TempCompare Then
2022-11-07 07:16:34 +00:00
2022-11-08 23:30:53 +00:00
Else
Dim BeforeCP As Integer = Strings . ComputerInfo ( 2 )
2022-11-13 08:15:05 +00:00
SaveFile ( command )
2022-11-08 23:30:53 +00:00
TextPad_GenerateCP_SavedFile ( )
Dim AfterCP As Integer = Strings . ComputerInfo ( 2 ) - BeforeCP
2022-11-13 08:15:05 +00:00
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 "
2022-11-08 23:30:53 +00:00
End If
Else
Dim BeforeCP As Integer = Strings . ComputerInfo ( 2 )
2022-11-13 08:15:05 +00:00
SaveFile ( command )
2022-11-08 23:30:53 +00:00
TextPad_GenerateCP_SavedFile ( )
Dim AfterCP As Integer = Strings . ComputerInfo ( 2 ) - BeforeCP
2022-11-13 08:15:05 +00:00
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 "
2022-11-08 23:30:53 +00:00
End If
End Select
Case ( Keys . N + Keys . Control )
2022-11-13 08:15:05 +00:00
Select Case Console . CurrentInterpreter
2022-11-08 23:30:53 +00:00
Case " textpad "
2022-11-13 08:15:05 +00:00
Console . TextBox1 . Text = Nothing
2022-11-08 23:30:53 +00:00
End Select
2022-11-07 07:16:34 +00:00
End Select
End Sub
Public Sub TerminateApp ( KeyInput As Keys )
2022-11-13 08:15:05 +00:00
Select Case Console . CurrentInterpreter
2022-11-07 07:16:34 +00:00
Case " textpad "
Dim BeforeCP As Integer = Strings . ComputerInfo ( 2 )
2022-11-13 08:15:05 +00:00
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
2022-11-07 07:16:34 +00:00
Else
2022-11-13 08:15:05 +00:00
SaveFile ( command )
2022-11-07 07:16:34 +00:00
TextPad_GenerateCP_SavedFile ( )
Dim AfterCP As Integer = Strings . ComputerInfo ( 2 ) - BeforeCP
2022-11-13 08:15:05 +00:00
Console . TextBox1 . Text = " You've got " & AfterCP & " Codepoints "
2022-11-07 07:16:34 +00:00
End If
Else
2022-11-13 08:15:05 +00:00
SaveFile ( command )
2022-11-07 07:16:34 +00:00
TextPad_GenerateCP_SavedFile ( )
Dim AfterCP As Integer = Strings . ComputerInfo ( 2 ) - BeforeCP
2022-11-13 08:15:05 +00:00
Console . TextBox1 . Text = " You've got " & AfterCP & " Codepoints "
2022-11-07 07:16:34 +00:00
End If
2022-11-13 08:15:05 +00:00
Console . ToolBarUse = False
Console . ChangeInterpreter = False
Console . ReleaseCursor = False
Console . CurrentInterpreter = " terminal "
Console . CheckFeature ( )
Terminal_AssignPrompt ( )
Terminal_PrintPrompt ( )
TextRebind ( )
2022-11-07 07:16:34 +00:00
Case Else
2022-11-13 08:15:05 +00:00
Console . ToolBarUse = False
Console . ChangeInterpreter = False
Console . ReleaseCursor = False
Console . CurrentInterpreter = " terminal "
Console . CheckFeature ( )
Terminal_AssignPrompt ( )
Terminal_PrintPrompt ( )
TextRebind ( )
2022-11-07 07:16:34 +00:00
End Select
2022-11-03 15:27:40 +00:00
End Sub
Public Sub DoChildCommand ( )
2022-11-13 08:15:05 +00:00
Select Case Console . CurrentInterpreter
2022-11-03 15:27:40 +00:00
Case " guess "
2022-11-13 08:15:05 +00:00
Select Case command
2022-11-03 15:27:40 +00:00
Case " exit "
2022-11-07 07:16:34 +00:00
TerminateApp ( Nothing )
2022-11-03 15:27:40 +00:00
Case Else
Try
GTN_CheckNumber ( )
Catch ex As Exception
2022-11-13 14:22:42 +00:00
NewLine ( " Invalid value! " )
2022-11-03 15:27:40 +00:00
End Try
End Select
2022-11-04 22:36:43 +00:00
Case " shiftoriumfx "
2022-11-13 08:15:05 +00:00
Select Case command
2022-11-05 15:24:30 +00:00
Case " "
2022-11-04 22:36:43 +00:00
Case " exit "
2022-11-07 07:16:34 +00:00
TerminateApp ( Nothing )
2022-11-04 22:36:43 +00:00
Case Else
ShiftoriumFX_DisplayPackages ( )
2022-11-13 14:22:42 +00:00
NewLine ( Nothing )
NewLine ( " Type any package you want to investigate " )
NewLine ( " Invalid package or bad command " )
2022-11-04 22:36:43 +00:00
End Select
2022-11-05 15:24:30 +00:00
Case " bc "
2022-11-13 08:15:05 +00:00
Select Case command
2022-11-05 15:24:30 +00:00
Case " jim "
2022-11-13 14:22:42 +00:00
NewLine ( " 69, the funni number " )
NewLine ( " gotcha! " )
2022-11-05 15:24:30 +00:00
Case " ojas "
2022-11-13 14:22:42 +00:00
NewLine ( " dis calculator is very gud " )
NewLine ( " it counts from another universe " )
2022-11-05 15:24:30 +00:00
Case " exit "
2022-11-07 07:16:34 +00:00
TerminateApp ( Nothing )
2022-11-05 15:24:30 +00:00
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
2022-11-13 08:15:05 +00:00
GetText = command . Chars ( BC_ReadNumbers )
2022-11-05 15:24:30 +00:00
Select Case GetText
Case " 0 " , " 1 " , " 2 " , " 3 " , " 4 " , " 5 " , " 6 " , " 7 " , " 8 " , " 9 "
BC_CurrentNumber = BC_CurrentNumber & GetText
2022-11-14 05:11:31 +00:00
Case " + " , " - " , " * " , " / " , " ^ "
2022-11-05 15:24:30 +00:00
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 " . "
2022-11-14 05:11:31 +00:00
NewLine ( " Decimals aren't supported yet! " )
2022-11-05 15:24:30 +00:00
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
2022-11-13 14:22:42 +00:00
NewLine ( BC_Result )
2022-11-05 15:24:30 +00:00
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
2022-11-14 05:11:31 +00:00
Case " ^ "
BC_Result = FirstNum ^ SecondNum
2022-11-03 15:27:40 +00:00
End Select
End Sub
Public Sub GTN_GenerateNumber ( )
Dim RandNum As New Random
TheNumber = RandNum . Next ( 1 , 51 )
End Sub
2022-11-02 04:17:14 +00:00
2022-11-03 15:27:40 +00:00
Public Sub GTN_CheckNumber ( )
2022-11-13 08:15:05 +00:00
Dim TheirNumber As Integer = Convert . ToInt32 ( command )
2022-11-03 15:27:40 +00:00
If TheirNumber > 0 And TheirNumber < 51 Then
If TheirNumber = TheNumber Then
Dim GetCP As New Random
2022-11-06 11:45:00 +00:00
Dim GotCP As Integer = GetCP . Next ( 1 , 11 )
2022-11-03 15:27:40 +00:00
ChangeCP ( True , GotCP )
2022-11-13 14:22:42 +00:00
NewLine ( " You are correct!, you got " & GotCP & " Codepoint(s) " )
NewLine ( " Guess the new number between 1 and 50. " )
2022-11-03 15:27:40 +00:00
GTN_GenerateNumber ( )
Else
If TheirNumber < TheNumber Then
2022-11-13 14:22:42 +00:00
NewLine ( " Higher! " )
2022-11-03 15:27:40 +00:00
ElseIf TheirNumber > TheNumber Then
2022-11-13 14:22:42 +00:00
NewLine ( " Lower! " )
2022-11-03 15:27:40 +00:00
End If
End If
End If
2022-11-02 04:17:14 +00:00
End Sub
2022-11-04 22:36:43 +00:00
2022-11-08 03:22:01 +00:00
Public Sub ShOSKey_InputCommand ( lastcommand As String )
2022-11-13 08:15:05 +00:00
Console . ShOSKey = lastcommand
2022-11-08 03:22:01 +00:00
End Sub
Public Sub ShOSKey_Display ( )
2022-11-13 08:15:05 +00:00
Console . TextBox1 . Text = Console . TextBox1 . Text & Console . ShOSKey
2022-11-08 03:22:01 +00:00
Try
2022-11-13 08:15:05 +00:00
Console . TrackPos = Console . ShOSKey . Length
2022-11-08 03:22:01 +00:00
Catch ex As Exception
2022-11-13 08:15:05 +00:00
Console . TrackPos = 0
2022-11-08 03:22:01 +00:00
End Try
End Sub
2022-11-07 07:16:34 +00:00
Public Sub TextPad_CheckExist ( TxtFileName As String )
2022-11-13 08:15:05 +00:00
If File . Exists ( Console . CurrentDirectory & " \ " & TxtFileName ) = True Then
Console . TextBox1 . Text = My . Computer . FileSystem . ReadAllText ( Console . CurrentDirectory & " \ " & TxtFileName )
2022-11-07 07:16:34 +00:00
End If
End Sub
Public Sub TextPad_GenerateCP_SavedFile ( )
2022-11-13 08:15:05 +00:00
Select Case Console . TextBox1 . TextLength
2022-11-07 07:16:34 +00:00
Case 1 To 9
Dim GetCP As New Random
2022-11-07 12:22:19 +00:00
Dim GotCP As Integer = GetCP . Next ( 1 , 3 )
2022-11-07 07:16:34 +00:00
ChangeCP ( True , GotCP )
Case 10 To 99
Dim GetCP As New Random
2022-11-07 12:22:19 +00:00
Dim GotCP As Integer = GetCP . Next ( 4 , 26 )
2022-11-07 07:16:34 +00:00
ChangeCP ( True , GotCP )
Case 100 To 999
Dim GetCP As New Random
2022-11-07 12:22:19 +00:00
Dim GotCP As Integer = GetCP . Next ( 27 , 251 )
2022-11-07 07:16:34 +00:00
ChangeCP ( True , GotCP )
Case 1000 To 9999
Dim GetCP As New Random
2022-11-07 12:22:19 +00:00
Dim GotCP As Integer = GetCP . Next ( 252 , 2501 )
2022-11-07 07:16:34 +00:00
ChangeCP ( True , GotCP )
End Select
End Sub
2022-11-04 22:36:43 +00:00
Public Sub ShiftoriumFX_DisplayPackages ( )
2022-11-13 08:15:05 +00:00
Console . TextBox1 . Text = " Shiftorium FX! " & Environment . NewLine & " The place to shiftisize the ShiftOS " & Environment . NewLine & Environment . NewLine & " Available Package(s) "
2022-11-04 22:36:43 +00:00
Shiftorium_ListFeatures ( )
End Sub
2022-11-02 04:17:14 +00:00
End Module