Compare commits
8 Commits
Author | SHA1 | Date |
---|---|---|
xfnw | 7c288d91da | |
xfnw | e66b4b31cf | |
xfnw | 06d9fce20a | |
xfnw | 0f1c1c570c | |
vulpine | 71720bcbb3 | |
JMW Software 2020 | e2d9565c68 | |
xfnw | 5412b5b225 | |
vulpine | 04a362e01b |
|
@ -16,4 +16,5 @@ for i in $(cat remotes.txt); do echo $i | xargs git remote add 2>/dev/null || ec
|
|||
|
||||
which will go through all the remotes in remotes.txt and add them to git
|
||||
|
||||
:D
|
||||
|
||||
|
|
167
nboard
167
nboard
|
@ -3,12 +3,15 @@
|
|||
|
||||
import curses,time,json,sys,os,subprocess
|
||||
|
||||
dataPath = os.path.expanduser('~')+'/.nboard/nboard.json'
|
||||
dataPath = '/home/xfnw/.nboard/nboard.json'
|
||||
|
||||
allowedChars = " `~1234567890-=!@#$%^&*()_+qwertyuiop[]\\QWERTYUIOP{}|asdfghjkl;'ASDFGHJKL:\"zxcvbnm,./ZXCVBNM<>?"
|
||||
data = {}
|
||||
|
||||
def main(stdscr):
|
||||
curses.halfdelay(5)
|
||||
curses.use_default_colors()
|
||||
|
||||
stdscr.erase()
|
||||
stdscr.refresh()
|
||||
k='NOU'
|
||||
|
@ -20,97 +23,101 @@ def main(stdscr):
|
|||
|
||||
stdscr.move(cy,cx)
|
||||
while True:
|
||||
cx = width // 2
|
||||
cy = height // 2
|
||||
try:
|
||||
cx = width // 2
|
||||
cy = height // 2
|
||||
|
||||
stdscr.clear()
|
||||
#stdscr.clear()
|
||||
|
||||
height, width = stdscr.getmaxyx()
|
||||
height, width = stdscr.getmaxyx()
|
||||
|
||||
if k == '\x1b':
|
||||
k=""
|
||||
for i in range(5):
|
||||
k += stdscr.getkey()
|
||||
if k == '\x0c':
|
||||
stdscr.clear()
|
||||
|
||||
# detect where to move cursor
|
||||
if k == 'KEY_UP':
|
||||
vy += -1
|
||||
nl = vx
|
||||
if k == 'KEY_DOWN':
|
||||
vy += 1
|
||||
nl = vx
|
||||
if k == 'KEY_LEFT':
|
||||
vx += -1
|
||||
nl = vx
|
||||
if k == 'KEY_RIGHT':
|
||||
vx += 1
|
||||
nl = vx
|
||||
# detect where to move cursor
|
||||
if k == 'KEY_UP':
|
||||
vy += -1
|
||||
nl = vx
|
||||
if k == 'KEY_DOWN':
|
||||
vy += 1
|
||||
nl = vx
|
||||
if k == 'KEY_LEFT':
|
||||
vx += -1
|
||||
nl = vx
|
||||
if k == 'KEY_RIGHT':
|
||||
vx += 1
|
||||
nl = vx
|
||||
|
||||
if k == '[1;5A' or k == 'kUP5':
|
||||
vy += 0-(height//2)
|
||||
nl = vx
|
||||
if k == '[1;5B' or k == 'kDN5':
|
||||
vy += height//2
|
||||
nl = vx
|
||||
if k == '[1;5D' or k == 'kLFT5':
|
||||
vx += 0-(width//2)
|
||||
nl = vx
|
||||
if k == '[1;5C' or k == 'kRIT5':
|
||||
vx += width//2
|
||||
nl = vx
|
||||
if k == '[1;5A' or k == 'kUP5':
|
||||
vy += 0-(height//2)
|
||||
nl = vx
|
||||
if k == '[1;5B' or k == 'kDN5':
|
||||
vy += height//2
|
||||
nl = vx
|
||||
if k == '[1;5D' or k == 'kLFT5':
|
||||
vx += 0-(width//2)
|
||||
nl = vx
|
||||
if k == '[1;5C' or k == 'kRIT5':
|
||||
vx += width//2
|
||||
nl = vx
|
||||
|
||||
if k == '\n':
|
||||
vx = nl
|
||||
vy += 1
|
||||
if k == 'KEY_BACKSPACE' or k == '\x7f':
|
||||
vx += -1
|
||||
if k == '\n':
|
||||
vx = nl
|
||||
vy += 1
|
||||
if k == 'KEY_BACKSPACE' or k == '\x7f':
|
||||
vx += -1
|
||||
|
||||
# make sure the cursor is on the screen
|
||||
# this is not nessesary for the view as it is infinite
|
||||
cx = max(0, cx)
|
||||
cx = min(width-1, cx)
|
||||
# make sure the cursor is on the screen
|
||||
# this is not nessesary for the view as it is infinite
|
||||
cx = max(0, cx)
|
||||
cx = min(width-1, cx)
|
||||
|
||||
cy = max(0, cy)
|
||||
cy = min(height-2, cy)
|
||||
cy = max(0, cy)
|
||||
cy = min(height-2, cy)
|
||||
|
||||
# calculate true position
|
||||
tx = cx + (vx) - width // 2
|
||||
ty = cy + (vy) - (height-1) // 2
|
||||
|
||||
# get json data
|
||||
with open(dataPath, 'r') as openfile:
|
||||
data = json.load(openfile)
|
||||
|
||||
# if valid key pressed, write it
|
||||
if k in allowedChars:
|
||||
data[str((ty,tx))] = k
|
||||
if k == ' ':
|
||||
data.pop(str((ty,tx)))
|
||||
vx = vx+1
|
||||
time.sleep(0)
|
||||
with open(dataPath, 'w') as outfile:
|
||||
json.dump(data, outfile, indent=1)
|
||||
# calculate true position
|
||||
tx = cx + (vx) - width // 2
|
||||
ty = cy + (vy) - (height-1) // 2
|
||||
|
||||
# draw the screen
|
||||
stdscr.move(0, 0)
|
||||
for y in range(height-1):
|
||||
for x in range(width):
|
||||
stdscr.move(y,x)
|
||||
stdscr.addstr(data.get(str((ty - cy + y,tx - cx + x)), ' '))
|
||||
# get json data
|
||||
with open(dataPath, 'r') as openfile:
|
||||
data = json.load(openfile)
|
||||
|
||||
# if valid key pressed, write it
|
||||
if k in allowedChars:
|
||||
data[str((ty,tx))] = k
|
||||
if k == ' ':
|
||||
data.pop(str((ty,tx)))
|
||||
vx = vx+1
|
||||
time.sleep(0)
|
||||
with open(dataPath, 'w') as outfile:
|
||||
json.dump(data, outfile, indent=1)
|
||||
tx = cx + (vx) - width // 2
|
||||
|
||||
# draw the screen
|
||||
stdscr.move(0, 0)
|
||||
for y in range(height-1):
|
||||
for x in range(width):
|
||||
stdscr.move(y,x)
|
||||
stdscr.addstr(data.get(str((ty - cy + y,tx - cx + x)), ' '))
|
||||
|
||||
|
||||
# display some info
|
||||
stdscr.addstr(height-1, 0, 'x: {}, y: {}, arrow keys to move, ctrl to go faster'.format(tx, 1-ty)[:width-1])
|
||||
# display some info
|
||||
stdscr.addstr(height-1, 0, 'x: {}, y: {}, arrow keys to move, ctrl to go faster '.format(tx, 1-ty)[:width-1])
|
||||
|
||||
|
||||
# move the cursor where its actually supposed to be
|
||||
stdscr.move(cy,cx)
|
||||
# move the cursor where its actually supposed to be
|
||||
stdscr.move(cy,cx)
|
||||
|
||||
#print(str(k)) # debug keycodes
|
||||
|
||||
k = stdscr.getkey()
|
||||
time.sleep(0)
|
||||
#print(str(k)) # debug keycodes
|
||||
|
||||
try:
|
||||
k = stdscr.getkey()
|
||||
except curses.error:
|
||||
k = 'NOU'
|
||||
time.sleep(0)
|
||||
except json.decoder.JSONDecodeError:
|
||||
time.sleep(0.1)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
@ -142,10 +149,10 @@ bugs and stuff:
|
|||
please report any bugs to ~xfnw on IRC, anywhere you can find him, or
|
||||
on the tildegit page, https://tildegit.org/xfnw/nboard
|
||||
""")
|
||||
elif sys.argv[1] == 'pull':
|
||||
branches=subprocess.run(['git','--dir-dir='+os.path.expanduser('~')+'/.nboard','for-each-ref','refs/remotes','--format','%(rename)'], capture_output=True).stdout.decode().splitlines()
|
||||
subprocess.run(['git','--git-dir='+os.path.expanduser('~')+'/.nboard','pull','--all'])
|
||||
subprocess.run(['git','--git-dir='+os.path.expanduser('~')+'/.nboard','merge']+branches)
|
||||
elif len(sys.argv) > 1 and sys.argv[1] == 'pull':
|
||||
branches=subprocess.run(['git','--git-dir='+os.path.expanduser('~')+'/.nboard/.git','for-each-ref','refs/remotes','--format','%(refname)'], capture_output=True).stdout.decode().splitlines()
|
||||
subprocess.run(['git','--git-dir='+os.path.expanduser('~')+'/.nboard/.git','fetch','--all'])
|
||||
subprocess.run(['git','--git-dir='+os.path.expanduser('~')+'/.nboard/.git','merge']+branches)
|
||||
print("pulled all remotes!")
|
||||
else:
|
||||
try:
|
||||
|
|
Loading…
Reference in New Issue