~evantj/pynotes unlisted

053d38eb15ad3aab8bad30edde372246114ebb26 — evantj 10 months ago master
initial commit
1 files changed, 43 insertions(+), 0 deletions(-)

A view.py
A  => view.py +43 -0
@@ 1,43 @@
import glob, os
import math
import time
notesDir = '/home/evanj/Documents/notes'
os.chdir(notesDir)
Hsep = '_'
Vsep = '~'
cont = '-'
indent = ' '*5
lineStrt = '\n'+Vsep+' '
lineStrtCont = '\n'+' '+cont
def styleLine(line, col, usecont = False):
    global lineStrt 
    global lineStrtCont
    global cont
    if usecont: line = lineStrtCont+line
    else: line = lineStrt+line
    if len(line)>col:
        linecont = line[col:len(line)]
        line = line[0:col]
        line = line+cont+styleLine(linecont, col, True)
    return line
while True:
    row, col = os.popen('stty size', 'r').read().split()
    row, col = int(row), int(col)
    out = ""
    for note in glob.glob('*.note'):
        noteName = note[:-5]
        sepNum = col-len(noteName)
        sideSepNum = sepNum/2
        if sideSepNum != round(sideSepNum): noteName += ' '
        sideSepNum = math.floor(sideSepNum)
        headerSep = Hsep*sideSepNum
        header = headerSep+noteName+headerSep
        fileContent = open(note,'r').read()
        noteLines = fileContent.split('\n')
        styledContent = ""
        for line in noteLines: styledContent += styleLine(line,col)
        out+=header+styledContent
    print(chr(27) + '[2J')
    print(out)
    time.sleep(0.1)