At least does something closer to what will be in the end

git-svn-id: http://galileo.dmi.unict.it/svn/relational/trunk@224 014f5005-505e-4b48-8d0a-63407b615a7c
master
LtWorf 2010-03-28 13:54:57 +07:00
parent f1018b20f8
commit 425dc5cf4c
1 changed files with 83 additions and 19 deletions

@ -18,45 +18,58 @@
# author Salvo "LtWorf" Tomaselli <tiposchi@tiscali.it>
import curses
import curses.panel
import locale
import signal
import sys
from relational import *
def terminate(*a):
'''Restores the terminal and terminates'''
curses.nocbreak()
#stdscr.keypad(0)
stdscr.keypad(0)
curses.echo()
curses.endwin()
sys.exit(0)
def main():
global stdscr
#Initializes the signal
signal.signal(signal.SIGINT,terminate)
#Initialize locale, to print unicode chars
locale.setlocale(locale.LC_ALL,"")
#Initializes curses
stdscr = curses.initscr()
curses.start_color()
curses.noecho()
curses.cbreak()#Handles keys immediately rather than awaiting for enter
stdscr.keypad(1)
termsize=stdscr.getmaxyx()
symselect=init_symbol_list(termsize)
win=curses.panel.new_panel(curses.newwin(9,90))
win.window().box()
win.window().addstr(3,3,"suca")
lop=curses.panel.new_panel(stdscr)
win=curses.panel.new_panel(curses.newwin(termsize[0],termsize[1]))
#win.window().box()
win.window().addstr(0,(termsize[1]/2)-5,"Relational")
win.window().refresh()
curses.napms(1000)
#curses.napms(1000)
w=curses.panel.new_panel(curses.newwin(4,80))
w.window().box()
w.window().addstr(2,2,"ciao")
w.window().refresh()
curses.napms(1000)
win.show()
query=curses.panel.new_panel(curses.newwin(3,termsize[1],1,0))
query.window().box()
query.window().addstr(1,1,"")
query.window().refresh()
#curses.napms(1000)
curses.napms(1000)
#win.show()
#curses.napms(1000)
#qq=curses.textpad.Textbox(stdscr)
@ -70,7 +83,7 @@ def main():
stdscr.addstr(5, 30, "Welcome to Relational")#,curses.A_REVERSE)
stdscr.refresh()
curses.napms(1000)
stdscr.refresh()
curses.napms(300)
curses.flash()
@ -78,12 +91,63 @@ def main():
while True:
c = win.window().getch()
win.window().addstr(str(c))
win.window().addstr(str(chr(c)))
win.window().refresh()
s=""
if c==27: #Escape
query.window().addstr(add_symbol(symselect))
query.window().refresh()
else:
#w.window().addstr(str(c))
query.window().addstr(str(chr(c)))
def init_symbol_list(termsize):
p=curses.panel.new_panel(curses.newwin(15,16,1,0))
p.window().box()
#p.window().addstr(1,1,"\n8 \na \nb \n")
p.window().addstr(01,2,"0 *")
p.window().addstr(02,2,"1 -")
p.window().addstr(03,2,"2 ")
p.window().addstr(04,2,"3 ᑎ")
p.window().addstr(05,2,"4 ᐅᐊ")
p.window().addstr(06,2,"5 ᐅLEFTᐊ")
p.window().addstr(07,2,"6 ᐅRIGHTᐊ")
p.window().addstr( 8,2,"7 ᐅFULLᐊ")
p.window().addstr( 9,2,"8 σ")
p.window().addstr(10,2,"9 ρ")
p.window().addstr(11,2,"a π")
p.window().addstr(12,2,"b ➡")
p.window().addstr(13,2,"")
p.hide()
return p
pass
def add_symbol(p):
d_={'0':'*',
'1':'-',
'2':'',
'3':'',
'4':'ᐅᐊ',
'5':'ᐅLEFTᐊ',
'6':'ᐅRIGHTᐊ',
'7':'ᐅFULLᐊ',
'8':'σ',
'9':'ρ',
'a':'π',
'b':''}
p.show()
p.window().refresh()
#curses.napms(1000)
c = p.window().getch()
p.hide()
p.window().refresh()
return d_[chr(c)]
main()