Skip to content

Commit

Permalink
Renamed pointer to point and cleaned code
Browse files Browse the repository at this point in the history
  • Loading branch information
lmariscal committed Jun 23, 2019
1 parent 5de35ce commit c2b1970
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 22 deletions.
7 changes: 2 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,8 @@ Windows CMD only supports a [limited character set](http://en.wikipedia.org/wiki
All checks are runned at compile time, if you need a run time solution please
let me know and will consider adding support for it.

The new windows terminal fully supports Unicode symbols, unfortunately there
is no proper way to indetify it yet. A work around is currently detecting the
terminal type but it is not documented as such in the official terminal repo.

You can force unicode symbols by defining ```forceFigures```
The new windows terminal and integrated VsCode terminal fully support Unicode
symbol.

Based from npm [figures](https://github.com/sindresorhus/figures) by
sindresorhus.
Expand Down
2 changes: 1 addition & 1 deletion figures.nimble
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Package

version = "1.0.0"
version = "1.1.0"
author = "Leonardo Mariscal"
description = "Unicode symbols with Windows CMD fallbacks "
license = "MIT"
Expand Down
33 changes: 18 additions & 15 deletions src/figures.nim
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,20 @@
##
## `from figures import nil`

# Since the new microsoft terminal is on the horizon forceFigures exists.

when defined(windows):
from os import getEnv, execShellCmd

proc isNewWindowsTerminal(): bool =
# This hack is used to display UTF-8 in the Windows command prompt.
when not defined(nochcp):
discard execShellCmd("@chcp 65001 > nul")

proc terminalSupportUnicode(): bool =
# Hopefully https://github.com/microsoft/terminal/issues/1040 comes to be.
not (getEnv("WT_SESSION") == "")
getEnv("WT_SESSION") != "" or getEnv("TERM_PROGRAM") == "vscode"
else:
proc terminalSupportUnicode(): bool = true

when not defined(windows) or defined(forceFigures) or isNewWindowsTerminal():
when terminalSupportUnicode():
const
tick* = ""
cross* = ""
Expand All @@ -33,7 +37,7 @@ when not defined(windows) or defined(forceFigures) or isNewWindowsTerminal():
dot* = ""
line* = ""
ellipsis* = ""
pointer* = ""
point* = ""
pointerSmall* = ""
info* = ""
warning* = ""
Expand Down Expand Up @@ -72,12 +76,15 @@ when not defined(windows) or defined(forceFigures) or isNewWindowsTerminal():
spinner* = ["", "", "", "", "", "", "", "", "", ""]

# It doesn't look so good in linux/windows
when not defined(linux) and not defined(windows):
const questionMarkPrefix* = "?⃝"
const circleQuestionMark* = "?⃝"
else:
when defined(linux) or defined(windows):
const questionMarkPrefix* = "?"
else:
const questionMarkPrefix* = "?⃝"

when defined(windows):
const circleQuestionMark* = "(?)"
else:
const circleQuestionMark* = "?⃝"
else:
const
tick* = ""
Expand All @@ -99,7 +106,7 @@ else:
dot* = "."
line* = ""
ellipsis* = "..."
pointer* = ">"
point* = ">"
pointerSmall* = "»"
info* = "i"
warning* = ""
Expand Down Expand Up @@ -137,7 +144,3 @@ else:
fiveEighths* = "5/8"
sevenEighths* = "7/8"
spinner* = ["-", "\\", "|", "/"]

# This hack is used to display UTF-8 in the Windows command prompt.
when not defined(nochcp):
discard execShellCmd("@chcp 65001 > nul")
2 changes: 1 addition & 1 deletion tests/test.nim
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ echo "bullet " & figures.bullet
echo "dot " & figures.dot
echo "line " & figures.line
echo "ellipsis " & figures.ellipsis
echo "pointer " & figures.pointer
echo "point " & figures.point
echo "pointerSmall " & figures.pointerSmall
echo "info " & figures.info
echo "warning " & figures.warning
Expand Down

0 comments on commit c2b1970

Please sign in to comment.