fork download
  1. Imports System.IO
  2. Imports System.Text
  3.  
  4. Module mainModule
  5.  
  6. Private Function ReadAFile(ByVal FileName As String, ByVal Encode As Encoding) As String
  7. Try
  8. If My.Computer.FileSystem.FileExists(FileName) Then
  9. Dim fileReader As New StreamReader(FileName, Encode)
  10. Dim R As String = fileReader.ReadToEnd()
  11. fileReader.Close()
  12. Return R
  13. Else
  14. Console.WriteLine("File not found.")
  15. Return ""
  16. End If
  17. Catch ex As Exception
  18. Console.WriteLine("{0}", ex.Message)
  19. Return ""
  20. End Try
  21. End Function
  22.  
  23. Sub Main()
  24. Dim CurrentLine As Integer = 0, cursorLine As Integer = 0, perviousPositions As New List(Of Integer)
  25. Dim undoID As Integer = 0
  26. Dim Lines As New List(Of String)
  27. Dim EncodeID As Integer = Encoding.Default.CodePage
  28. If My.Application.CommandLineArgs.Count > 0 AndAlso File.Exists(My.Application.CommandLineArgs(0)) Then
  29. Console.Title = "Loading"
  30. Console.WriteLine("Current Encoding Page is {0}", Encoding.GetEncoding(EncodeID).EncodingName)
  31. Console.WriteLine("Reading File {0}...", My.Computer.FileSystem.GetName(My.Application.CommandLineArgs(0)))
  32. Lines.AddRange(ReadAFile(My.Application.CommandLineArgs(0), Encoding.GetEncoding(EncodeID)).Replace(vbCrLf, vbLf).Replace(vbCr, vbLf).Split(vbLf))
  33. Console.Title = My.Computer.FileSystem.GetName(My.Application.CommandLineArgs(0))
  34. perviousPositions.Add(0)
  35. undoID = 0
  36. Do
  37. Try
  38. Console.WriteLine("Line #{0}", CurrentLine)
  39. For i As Integer = CurrentLine To Lines.Count - 1
  40. If Console.CursorTop >= Console.WindowHeight - 1 Then
  41. cursorLine = i
  42. Exit For
  43. End If
  44. Console.WriteLine("{0}", Lines(i))
  45. Next
  46. Select Case Console.ReadKey.Key
  47. Case ConsoleKey.Escape
  48. Exit Sub
  49. Case ConsoleKey.Spacebar, ConsoleKey.PageDown
  50. CurrentLine = cursorLine
  51. perviousPositions.Add(CurrentLine)
  52. undoID = perviousPositions.Count - 1
  53. Case ConsoleKey.PageUp
  54. If CurrentLine > Console.WindowHeight Then CurrentLine -= Console.WindowHeight Else CurrentLine = 0
  55. perviousPositions.Add(CurrentLine)
  56. undoID = perviousPositions.Count - 1
  57. Case ConsoleKey.DownArrow
  58. If CurrentLine < Lines.Count - 1 Then CurrentLine += 1
  59. perviousPositions.Add(CurrentLine)
  60. undoID = perviousPositions.Count - 1
  61. Case ConsoleKey.UpArrow
  62. If CurrentLine > 0 Then CurrentLine -= 1
  63. perviousPositions.Add(CurrentLine)
  64. undoID = perviousPositions.Count - 1
  65. Case ConsoleKey.Backspace
  66. If perviousPositions.Count > 1 Then
  67. cursorLine = perviousPositions(undoID)
  68. If undoID > 0 Then undoID -= 1
  69. End If
  70. Case ConsoleKey.Home
  71. CurrentLine = 0
  72. perviousPositions.Add(CurrentLine)
  73. undoID = perviousPositions.Count - 1
  74. Case ConsoleKey.End
  75. CurrentLine = Lines.Count - 1 - Console.WindowHeight
  76. perviousPositions.Add(CurrentLine)
  77. undoID = perviousPositions.Count - 1
  78. Case ConsoleKey.Tab
  79. If perviousPositions.Count > 1 Then
  80. If undoID < perviousPositions.Count - 1 Then undoID += 1
  81. cursorLine = perviousPositions(undoID)
  82. End If
  83. Case ConsoleKey.Enter
  84. Console.Write("{0}", ">")
  85. Dim sTextSplit() As String = Console.ReadLine.ToLower.Split(" ")
  86. Select Case sTextSplit(0)
  87. Case "goto"
  88. CurrentLine = CInt(sTextSplit(1))
  89. perviousPositions.Add(CurrentLine)
  90. undoID = perviousPositions.Count - 1
  91. Case "encode"
  92. EncodeID = CInt(sTextSplit(1))
  93. Console.WriteLine("Encoding switch to {0}", Encoding.GetEncoding(EncodeID).EncodingName)
  94. GoTo reload
  95. Case "reload"
  96. reload: Lines.Clear()
  97. Lines.AddRange(ReadAFile(My.Application.CommandLineArgs(0), Encoding.GetEncoding(EncodeID)).Replace(vbCrLf, vbLf).Replace(vbCr, vbLf).Split(vbLf))
  98. perviousPositions.Clear()
  99. perviousPositions.Add(0)
  100. undoID = 0
  101. End Select
  102. End Select
  103. Console.Clear()
  104. Catch ex As Exception
  105. Console.WriteLine("{0}", ex.Message)
  106. End Try
  107. Loop
  108. End If
  109. End Sub
  110.  
  111. End Module
  112.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Visual Basic.Net Compiler version 0.0.0.5914 (Mono 2.4.2 - r)
Copyright (C) 2004-2008 Rolf Bjarne Kvinge. All rights reserved.


/home/0pRyeP/prog.vb (25,1) : Error VBNC30451: Could not resolve the name 'List'
/home/0pRyeP/prog.vb (27,1) : Error VBNC30451: Could not resolve the name 'List'
There were 2 errors and 0 warnings.
Compilation took 00:00:00.7454060
stdout
Standard output is empty