#/usr/bin/python

"""
sdl expect:
	view_blit(x,y,filename,rotation,mirror,width,heitg,col,row,...)
	view_load(filename)
	table_event()
	

zmq create:
	table_connection(id,port)
	table_queue(id,msg,conn_id)
	function_emit(conn_id,msg)

ncurse expect:
	view_puts(col,row,fg,bg,char)
	table_gets()

i consider view as read only by the worker
i consider table as read and write by the worker
i consider function as write only by the worker

lua scripting ?
	because it is pure C and performant
	i think that the sandbox of the exectution should isolate the code
	i think:
		function_proc_eval_lua(src) -> have access to the same database with sqlite_query() and sqlite_exec()
		function_method_eval_lua(src,table,row) -> method with table and row name as argument
		function_transform_eval_lua(src,table) -> no method, row in new row out
		function_filter_eval_lua(src,table) -> no method, row in, boolean out
		function_aggregate_eval_lua(src,table) -> no method, table in, sum out
	see whom is possible

observer pattern ?
	trigger and emit function may help
	or an event manager structure that we can replicate as a block chain accros multiple databases
"""

###############################################################################
# ncurses
###############################################################################
"""	ncurses expect
	table_ncurses_cfg()
	view_puts(char,fg,bg,col,row)
	table_gets(key,att)
"""
ncursessql = """
"""
def ncursesproof():
	"""
	>>> ncursesproof()
	"""
	import sqlite3

	import curses
	stdscr = curses.initscr()
	curses.start_color()
	def init_curses():
		curses.noecho()
		curses.cbreak()
		stdscr.keypad(1)
	def exit_curses():
		curses.nocbreak() 
		stdscr.keypad(0) 
		curses.echo()
		curses.endwin()
	def set_color_pair(id,fg,bg):
		table = {
			#0:black, 1:red, 2:green, 3:yellow, 4:blue, 5:magenta, 6:cyan, and 7:white
			0 : curses.COLOR_BLACK,
			1 : curses.COLOR_RED,
			2 : curses.COLOR_GREEN,
			3 : curses.COLOR_YELLOW,
			4 : curses.COLOR_BLUE,
			5 : curses.COLOR_MAGENTA,
			6 : curses.COLOR_CYAN,
			7 : curses.COLOR_WHITE
		}
		curses.init_pair(id, table[fg], table[bg])
	def add_str(col,row,str,pair_id=0):
		stdscr.addstr(col,row, str, curses.color_pair(pair_id))
	init_curses()
	add_str(20,20,"hello")
	stdscr.getch()
	exit_curses()
		


###############################################################################
# main
###############################################################################
if __name__ == '__main__':
	pass
	import doctest
	doctest.testmod()
