Repository navigation
Expand file tree
/
Copy pathProgram.fs
More file actions
64 lines (51 loc) · 1.98 KB
/
Copy pathProgram.fs
File metadata and controls
64 lines (51 loc) · 1.98 KB
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
open System
open AngouriMath.Terminal.Lib.FSharpInteractive
open AngouriMath.Terminal.Lib.PreRunCode
open AngouriMath.Terminal.Lib.Consts
open UserInterface
open Spectre.Console
open AngouriMath.Terminal.Lib.AssemblyLoadBuilder
open AngouriMath.Terminal.Lib
// A command on the command line answers once and exits. This comes before anything below touches
// the console, which a pipe does not have.
match Environment.GetCommandLineArgs() |> List.ofArray |> List.tail with
| [] -> ()
| args -> exit (OneShot.run args Console.In Console.Out Console.Error)
// All other platforms do not support setting custom window width
if System.OperatingSystem.IsWindows() then
Console.WindowHeight <- Math.Min(50, Console.LargestWindowHeight)
Console.WindowWidth <- Math.Min(150, Console.LargestWindowWidth)
let lineEditor = getLineEditor AnsiConsole.Console
let rec readAndRespond kernel =
printf "\n"
match readLine lineEditor |> nonNull |> execute kernel with
| PlainTextSuccess text ->
writeLine AnsiConsole.Console text
| LatexSuccess (_, text) ->
writeLine AnsiConsole.Console text
| Error message ->
writeLineError AnsiConsole.Console message
| _ -> ()
readAndRespond kernel
let handleErrors errors =
let concat = String.concat "\n"
printfn $"Errors: {concat errors}"
printfn $"Report about it to the official repo. The terminal will be closed."
Console.ReadLine() |> ignore
"\n\n" |> Console.Write
FigletText("AngouriMath", Justification = Justify.Center, Color = Color.Pink1)
|> AnsiConsole.Console.Write
Markup($@"
Hi! Type `help ()` to get more info.
", Justification = Justify.Center)
|> AnsiConsole.Console.Write
printf "Starting the kernel..."
match createKernel () with
| Result.Error reasons -> handleErrors reasons
| Result.Ok kernel ->
execute kernel "1 + 1" |> ignore // warm up
match enableAngouriMath kernel with
| Error msg -> handleErrors [ msg ]
| _ ->
printfn " loaded."
readAndRespond kernel