*show newVolume using strfmt
*remove unneeded exports *remove proc notes/exec() *added checkError to comply with standard
This commit is contained in:
parent
019108b523
commit
41fc9eb5d5
59
src/term.nim
59
src/term.nim
|
@ -4,7 +4,7 @@ import
|
||||||
client, sequtils, parseutils,
|
client, sequtils, parseutils,
|
||||||
httpclient, net
|
httpclient, net
|
||||||
|
|
||||||
proc clear* =
|
proc clear =
|
||||||
eraseScreen()
|
eraseScreen()
|
||||||
setCursorPos 0, 0
|
setCursorPos 0, 0
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ proc error*(str: string) =
|
||||||
styledEcho fgRed, "Error: ", str
|
styledEcho fgRed, "Error: ", str
|
||||||
quit QuitFailure
|
quit QuitFailure
|
||||||
|
|
||||||
proc sayBlue*(strList: varargs[string]) =
|
proc sayBlue(strList: varargs[string]) =
|
||||||
for str in strList:
|
for str in strList:
|
||||||
setCursorXPos 5
|
setCursorXPos 5
|
||||||
styledEcho fgBlue, str
|
styledEcho fgBlue, str
|
||||||
|
@ -47,7 +47,7 @@ proc parseJArray(file: string): seq[string] =
|
||||||
if result.len mod 2 != 0:
|
if result.len mod 2 != 0:
|
||||||
error "JArrayResult.len not even"
|
error "JArrayResult.len not even"
|
||||||
|
|
||||||
proc exitEcho* =
|
proc exitEcho =
|
||||||
showCursor()
|
showCursor()
|
||||||
echo ""
|
echo ""
|
||||||
randomize()
|
randomize()
|
||||||
|
@ -75,20 +75,20 @@ proc exitEcho* =
|
||||||
rand * 2
|
rand * 2
|
||||||
)
|
)
|
||||||
|
|
||||||
proc say*(txt: string) =
|
proc say(txt: string) =
|
||||||
styledEcho fgYellow, txt
|
styledEcho fgYellow, txt
|
||||||
|
|
||||||
proc sayPos*(x: int, a: string; echo = true) =
|
proc sayPos(x: int, a: string; echo = true) =
|
||||||
setCursorXPos x
|
setCursorXPos x
|
||||||
if echo: styledEcho fgGreen, a
|
if echo: styledEcho fgGreen, a
|
||||||
else: stdout.styledWrite fgGreen, a
|
else: stdout.styledWrite fgGreen, a
|
||||||
|
|
||||||
proc sayIter*(txt: string) =
|
proc sayIter(txt: string) =
|
||||||
for f in splitLines txt:
|
for f in splitLines txt:
|
||||||
setCursorXPos 5
|
setCursorXPos 5
|
||||||
styledEcho fgBlue, f
|
styledEcho fgBlue, f
|
||||||
|
|
||||||
proc sayIter*(txt: seq[string]; ret = true) =
|
proc sayIter(txt: seq[string]; ret = true) =
|
||||||
var
|
var
|
||||||
chars =
|
chars =
|
||||||
@[
|
@[
|
||||||
|
@ -108,7 +108,7 @@ proc sayIter*(txt: seq[string]; ret = true) =
|
||||||
if ret: sayBlue "R Return"
|
if ret: sayBlue "R Return"
|
||||||
sayBlue "Q Quit"
|
sayBlue "Q Quit"
|
||||||
|
|
||||||
proc warn*(txt: string; x = -1) =
|
proc warn(txt: string; x = -1) =
|
||||||
if x != -1: setCursorXPos x
|
if x != -1: setCursorXPos x
|
||||||
styledEcho fgRed, txt
|
styledEcho fgRed, txt
|
||||||
#if echo == false: stdout.styledWrite fgRed,txt
|
#if echo == false: stdout.styledWrite fgRed,txt
|
||||||
|
@ -122,9 +122,9 @@ proc inv =
|
||||||
eraseLine()
|
eraseLine()
|
||||||
cursorUp()
|
cursorUp()
|
||||||
|
|
||||||
template sayTermDraw8*() =
|
template sayTermDraw8() =
|
||||||
say "Poor Mans Radio Player in Nim-lang " & '-'.repeat int terminalWidth() / 8
|
say "Poor Mans Radio Player in Nim-lang " & '-'.repeat int terminalWidth() / 8
|
||||||
proc sayTermDraw12*() =
|
proc sayTermDraw12() =
|
||||||
sayPos 0, '-'.repeat((terminalWidth()/8).int) & '>'.repeat int terminalWidth() / 12
|
sayPos 0, '-'.repeat((terminalWidth()/8).int) & '>'.repeat int terminalWidth() / 12
|
||||||
|
|
||||||
proc drawMenu(sub: string, x: string | seq[string], sect = "") =
|
proc drawMenu(sub: string, x: string | seq[string], sect = "") =
|
||||||
|
@ -137,13 +137,15 @@ proc drawMenu(sub: string, x: string | seq[string], sect = "") =
|
||||||
else: sayPos 4, fmt"{sect} Station Playing Music:"
|
else: sayPos 4, fmt"{sect} Station Playing Music:"
|
||||||
sayIter x
|
sayIter x
|
||||||
|
|
||||||
proc exec*(x: string, args: openArray[string]; stream = false) =
|
proc exec(x: string, args: openArray[string]; stream = false) =
|
||||||
discard waitForExit startProcess(x, args = args,
|
discard waitForExit startProcess(x, args = args,
|
||||||
options =
|
options =
|
||||||
if stream: {poUsePath, poParentStreams}
|
if stream: {poUsePath, poParentStreams}
|
||||||
else: {poUsePath}
|
else: {poUsePath}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
template cE(s: cint) = checkError s
|
||||||
|
|
||||||
proc exit(ctx: ptr Handle, isPaused: bool) =
|
proc exit(ctx: ptr Handle, isPaused: bool) =
|
||||||
if not isPaused:
|
if not isPaused:
|
||||||
ctx.terminateDestroy
|
ctx.terminateDestroy
|
||||||
|
@ -160,33 +162,14 @@ proc notes =
|
||||||
sayIter """PNimRP Copyright (C) 2021-2024 antonl05/bloomingchad
|
sayIter """PNimRP Copyright (C) 2021-2024 antonl05/bloomingchad
|
||||||
This program comes with ABSOLUTELY NO WARRANTY
|
This program comes with ABSOLUTELY NO WARRANTY
|
||||||
This is free software, and you are welcome to redistribute
|
This is free software, and you are welcome to redistribute
|
||||||
under certain conditions. press `t` for details"""
|
under certain conditions."""
|
||||||
while true:
|
while true:
|
||||||
case getch():
|
case getch():
|
||||||
of 'T', 't':
|
|
||||||
when defined windows: exec "notepad.exe", ["LICENSE"], stream = true; break
|
|
||||||
when defined posix:
|
|
||||||
when defined android:
|
|
||||||
showCursor()
|
|
||||||
exec "editor", ["LICENSE"], stream = true
|
|
||||||
hideCursor()
|
|
||||||
break
|
|
||||||
else:
|
|
||||||
warn "type esc, :q and enter to exit"
|
|
||||||
showCursor()
|
|
||||||
exec "vi", ["LICENSE"], stream = true
|
|
||||||
hideCursor()
|
|
||||||
else:
|
|
||||||
showCursor()
|
|
||||||
echo "please open LICENSE file"
|
|
||||||
quit()
|
|
||||||
of 'r', 'R': j = true; break
|
of 'r', 'R': j = true; break
|
||||||
of 'Q', 'q': exitEcho()
|
of 'Q', 'q': exitEcho()
|
||||||
else: inv()
|
else: inv()
|
||||||
if j: break
|
if j: break
|
||||||
|
|
||||||
template cE(s: cint) = checkError s
|
|
||||||
|
|
||||||
proc init(parm: string, ctx: ptr Handle) =
|
proc init(parm: string, ctx: ptr Handle) =
|
||||||
let file = allocCStringArray ["loadfile", parm] #couldbe file,link,playlistfile
|
let file = allocCStringArray ["loadfile", parm] #couldbe file,link,playlistfile
|
||||||
var val: cint = 1
|
var val: cint = 1
|
||||||
|
@ -333,7 +316,7 @@ proc call(sub: string; sect = ""; stat,
|
||||||
cursorUp()
|
cursorUp()
|
||||||
|
|
||||||
var val: cint = 0
|
var val: cint = 0
|
||||||
ctx.setProperty "pause", fmtFlag, addr val
|
cE ctx.setProperty("pause", fmtFlag, addr val)
|
||||||
echoPlay = true
|
echoPlay = true
|
||||||
isPaused = false
|
isPaused = false
|
||||||
|
|
||||||
|
@ -343,7 +326,7 @@ proc call(sub: string; sect = ""; stat,
|
||||||
cursorUp()
|
cursorUp()
|
||||||
|
|
||||||
var val: cint = 1
|
var val: cint = 1
|
||||||
ctx.setProperty "pause", fmtFlag, addr val
|
cE ctx.setProperty("pause", fmtFlag, addr val)
|
||||||
isPaused = true
|
isPaused = true
|
||||||
|
|
||||||
of 'm', 'M':
|
of 'm', 'M':
|
||||||
|
@ -357,7 +340,7 @@ proc call(sub: string; sect = ""; stat,
|
||||||
cursorUp()
|
cursorUp()
|
||||||
|
|
||||||
var val: cint = 0
|
var val: cint = 0
|
||||||
ctx.setProperty "mute", fmtFlag, addr val
|
cE ctx.setProperty("mute", fmtFlag, addr val)
|
||||||
echoPlay = true
|
echoPlay = true
|
||||||
isPaused = false
|
isPaused = false
|
||||||
|
|
||||||
|
@ -367,7 +350,7 @@ proc call(sub: string; sect = ""; stat,
|
||||||
cursorUp()
|
cursorUp()
|
||||||
|
|
||||||
var val: cint = 1
|
var val: cint = 1
|
||||||
ctx.setProperty "mute", fmtFlag, addr val
|
cE ctx.setProperty("mute", fmtFlag, addr val)
|
||||||
isPaused = true
|
isPaused = true
|
||||||
|
|
||||||
of '/', '+':
|
of '/', '+':
|
||||||
|
@ -376,7 +359,7 @@ proc call(sub: string; sect = ""; stat,
|
||||||
#mpv cant access it? ->dont put outside while true
|
#mpv cant access it? ->dont put outside while true
|
||||||
val += 5
|
val += 5
|
||||||
cE ctx.setProperty("volume", fmtInt64, addr val)
|
cE ctx.setProperty("volume", fmtInt64, addr val)
|
||||||
echo "Volume: ", val
|
#echo "Volume: ", val
|
||||||
|
|
||||||
#[var metadata: NodeList
|
#[var metadata: NodeList
|
||||||
echo "getPropreturnVal:", ctx.getProperty("metadata", fmtNodeMap, addr metadata)
|
echo "getPropreturnVal:", ctx.getProperty("metadata", fmtNodeMap, addr metadata)
|
||||||
|
@ -385,7 +368,7 @@ proc call(sub: string; sect = ""; stat,
|
||||||
try:echo "metadatavalues", metadata.values[i]
|
try:echo "metadatavalues", metadata.values[i]
|
||||||
except:discard]#
|
except:discard]#
|
||||||
cursorDown()
|
cursorDown()
|
||||||
warn "Volume+", 4
|
warn fmt"Volume+: {val}" , 4
|
||||||
cursorUp()
|
cursorUp()
|
||||||
eraseLine()
|
eraseLine()
|
||||||
cursorUp()
|
cursorUp()
|
||||||
|
@ -453,7 +436,7 @@ proc initIndx*(dir = "assets"): seq[seq[string]] =
|
||||||
if dir == "assets": names.add "Notes"
|
if dir == "assets": names.add "Notes"
|
||||||
@[names, files, dirs]
|
@[names, files, dirs]
|
||||||
|
|
||||||
proc menu*(sub, file: string; sect = ""; ) =
|
proc menu(sub, file: string; sect = ""; ) =
|
||||||
let
|
let
|
||||||
list = initJsonLists(sub, file, sect)
|
list = initJsonLists(sub, file, sect)
|
||||||
n = list[0]
|
n = list[0]
|
||||||
|
|
Loading…
Reference in New Issue