Skip to content

Commit

Permalink
0.4.1: Windows fixes: removed unicode char from welcome screen, fixed…
Browse files Browse the repository at this point in the history
… nimble package warning, fixed Windows discard shortcut
  • Loading branch information
AndreiRegiani committed Aug 4, 2018
1 parent 3881ab4 commit 8270622
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 13 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
nimcache/
inim
src/inim
src/inim.exe
inim_*
test
temp.nim
temp
2 changes: 1 addition & 1 deletion inim.nimble
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Package

version = "0.4.0"
version = "0.4.1"
author = "Andrei Regiani"
description = "Interactive Nim Shell / REPL / Playground"
license = "MIT"
Expand Down
35 changes: 25 additions & 10 deletions src/inim.nim
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ type App = ref object
var app:App

const
INimVersion = "0.4.0"
INimVersion = "0.4.1"
indentSpaces = " "
indentTriggers = [",", "=", ":", "var", "let", "const", "type", "import",
"object", "enum"] # endsWith
embeddedCode = staticRead("embedded.nim") # preloaded code into user's session
embeddedCode = staticRead("inimpkg/embedded.nim") # preloaded code into user's session

let
uniquePrefix = epochTime().int
Expand Down Expand Up @@ -53,7 +53,9 @@ proc getNimPath(): string =

proc welcomeScreen() =
stdout.setForegroundColor(fgYellow)
stdout.writeLine "👑 INim ", INimVersion
when defined(posix):
stdout.write "👑 " # Crashes on Windows: Unknown IO Error [IOError]
stdout.writeLine "INim ", INimVersion
stdout.setForegroundColor(fgCyan)
stdout.write getNimVersion()
stdout.write getNimPath()
Expand All @@ -67,6 +69,9 @@ proc cleanExit(exitCode = 0) =
removeDir(getTempDir() & "nimcache")
quit(exitCode)

proc controlCHook() {.noconv.} =
cleanExit(1)

proc getFileData(path: string): string =
try:
result = path.readFile()
Expand Down Expand Up @@ -153,13 +158,22 @@ proc showError(output: string) =
let message_seq = message.split(";") # expression;type, e.g 'a';char
let typeExpression = message_seq[1] # type, e.g. char

let shortcut = fmt"""
stdout.write $({currentExpression})
stdout.write "\e[33m" # Yellow
stdout.write " : "
stdout.write "{typeExpression}"
echo "\e[39m" # Reset color
""".replace(" ", "")
var shortcut:string
when defined(Windows):
shortcut = fmt"""
stdout.write $({currentExpression})
stdout.write " : "
stdout.write "{typeExpression}"
echo ""
""".replace(" ", "")
else: # Posix: colorize type to yellow
shortcut = fmt"""
stdout.write $({currentExpression})
stdout.write "\e[33m" # Yellow
stdout.write " : "
stdout.write "{typeExpression}"
echo "\e[39m" # Reset color
""".replace(" ", "")

buffer.writeLine(shortcut)
buffer.flushFile()
Expand All @@ -183,6 +197,7 @@ proc showError(output: string) =
previouslyIndented = false

proc init(preload: string = nil) =
setControlCHook(controlCHook)
bufferRestoreValidCode()

if preload == nil:
Expand Down
File renamed without changes.

0 comments on commit 8270622

Please sign in to comment.