Advertisement
Guest User

no keyboard

a guest
Jul 24th, 2016
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Nim 1.84 KB | None | 0 0
  1. import cx
  2. import asyncDispatch, asyncnet
  3.  
  4. # testing some new interface ideas
  5. # no keyboard required to start/stop/quit
  6. # works by selecting the required action
  7. # needs xclip installed
  8.  
  9.  
  10. proc doMenu() =
  11.    printBiCol(" .Start | .Stop ","|",lime,truetomato,xpos = 60)
  12.    println("| .Quit ",salmon)
  13.  
  14.  
  15. var cp = ""
  16. var stopflag:bool = false
  17. proc doDash() {.async.} =
  18.     cleanscreen()
  19.     curdn(1)
  20.     while true:        
  21.          
  22.          cp = checkClip()
  23.          cp = strip(cp,true,false)
  24.            
  25.          if cp.startswith(".Stop") == true and stopflag == false :  
  26.             stopflag = true
  27.             curup(1)
  28.             printlnBiCol(rightarrow & " Status : stopped",":",greenyellow,red,xpos = 90)          
  29.             # we are still getting high cpu upon stop  
  30.          
  31.          elif cp.startswith(".Start") == true and stopflag == true:  
  32.             stopflag = false
  33.             curup(1)
  34.             printlnBiCol(rightarrow & " Status : ok" & spaces(6),":",greenyellow,skyblue,xpos = 90)
  35.          
  36.          
  37.          elif cp.startswith(".Quit") == true :  
  38.             #curup(1)
  39.             printlnBiCol(rightarrow & " Status : exiting" & spaces(6),":",greenyellow,salmon,xpos = 90)
  40.             quit(0)
  41.                    
  42.          else : discard
  43.          
  44.          var s = 0
  45.          if stopflag == false and cp.startswith(".Start") == true:
  46.            print(clearline)
  47.            curup(1)
  48.            for x in 0.. 100000:
  49.               s =  getRandomInt(0,10000)
  50.               printSlimNumber($s,xpos = 2)
  51.               curup(3)
  52.          
  53.            
  54.            doMenu()
  55.            
  56.            
  57.            await sleepAsync(1000)
  58.          
  59.        
  60. cleanscreen()
  61. echo()
  62. printBiCol(" .Start | .Stop ","|",lime,truetomato,xpos = 60)
  63. println("| .Quit ",salmon)  
  64. asyncCheck doDash()
  65. runForever()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement