From 2b3db775535290cbbaae570dc79ed3438afe4795 Mon Sep 17 00:00:00 2001 From: hut Date: Sun, 22 Nov 2009 23:56:47 +0100 Subject: the basic loop --- code/__init__.py | 0 code/__init__.pyc | Bin 0 -> 125 bytes code/debug.py | 12 ++++++++++++ code/fm.py | 38 ++++++++++++++++++++++++++++++++++++++ code/options.py | 5 +++++ code/ui.py | 4 ++++ ranger | 29 +++++++++++++++++++++++++++++ test1.py | 5 ++++- 8 files changed, 92 insertions(+), 1 deletion(-) create mode 100644 code/__init__.py create mode 100644 code/__init__.pyc create mode 100644 code/debug.py create mode 100644 code/fm.py create mode 100644 code/options.py create mode 100644 code/ui.py create mode 100644 ranger diff --git a/code/__init__.py b/code/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/code/__init__.pyc b/code/__init__.pyc new file mode 100644 index 00000000..2479f90e Binary files /dev/null and b/code/__init__.pyc differ diff --git a/code/debug.py b/code/debug.py new file mode 100644 index 00000000..12d5d654 --- /dev/null +++ b/code/debug.py @@ -0,0 +1,12 @@ +# a module to faciliate debuggin + +LOGFILE = '/tmp/errorlog' + +def log(txt): + f = open(LOGFILE, 'a') + f.write("r1: ") + f.write(str(txt)) + f.write("\n") + f.close() + + diff --git a/code/fm.py b/code/fm.py new file mode 100644 index 00000000..76316a9d --- /dev/null +++ b/code/fm.py @@ -0,0 +1,38 @@ +import time +import sys +from code import ui, debug + +class FM(): + def __init__(self, options): + self.singleton = None + self.options = options + self.ui = ui.UI() + + def run(self): + try: + while 1: + try: + self.ui.draw() + except KeyboardInterrupt: + self.interrupt() + except: + debug.log(sys.exc_info()[1]) + + try: + key = None +# key = curses.getch() +# curses.flushinp() + self.press(key) + except KeyboardInterrupt: + self.interrupt() + except: + raise + pass + + def press(self, key): + pass + + def interrupt(self): + self.buffer = "" + time.sleep(0.2) + diff --git a/code/options.py b/code/options.py new file mode 100644 index 00000000..eed79f1e --- /dev/null +++ b/code/options.py @@ -0,0 +1,5 @@ +def get(): + return [] + +def dummy(): + return [] diff --git a/code/ui.py b/code/ui.py new file mode 100644 index 00000000..0e48a68a --- /dev/null +++ b/code/ui.py @@ -0,0 +1,4 @@ +class UI(): + def draw(self): + import time + time.sleep(0.1) diff --git a/ranger b/ranger new file mode 100644 index 00000000..585108b8 --- /dev/null +++ b/ranger @@ -0,0 +1,29 @@ +#!/usr/bin/python +# coding=utf-8 + +# TODO: cd after exit + +from code import debug +from code import fm +from code import ui +from code import options + +# TODO: find out the real name of this script and include files relative to here + +# TODO: Parse arguments + +# TODO: load config + +# TODO: initialize classes + +# TODO: run main loop + + +def main(): + import locale + locale.setlocale(locale.LC_ALL, 'en_US.utf8') + + fm.singleton = fm.FM(options.get()) + fm.singleton.run() + +if __name__ == "__main__": main() diff --git a/test1.py b/test1.py index 715e510d..97505c41 100644 --- a/test1.py +++ b/test1.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 # coding=utf-8 # some tests with curses, threads and unicode import os @@ -6,6 +6,9 @@ import curses import time import threading import locale +import _thread + +lock = _thread.allocate_lock() locale.setlocale(locale.LC_ALL, 'en_US.utf8') -- cgit 1.4.1-2-gfad0