Project

Profile

Help

Revision fa348e33

Added by Vincent Le Goff over 4 years ago

Add the basic hierarchy of SharpScript
The #say function is provided as a test.

View differences:

src/client.py
43 43
    say = None
44 44
    braille = None
45 45

  
46
from sharp.engine import SharpScript
47

  
46 48
# Constants
47 49
ANSI_ESCAPE = re.compile(r'\x1b[^m]*m')
48 50

  
......
57 59
        self.timeout = timeout
58 60
        self.engine = engine
59 61
        self.running = False
62
        self.sharp_engine = SharpScript(engine, self)
60 63

  
61 64
        # Try to connect to the specified host and port
62 65
        self.client = Telnet(host, port)
......
74 77
        """When the client receives a message."""
75 78
        pass
76 79

  
80
    def write(self, text):
81
        """Write text to the client."""
82
        if text.startswith("#"):
83
            print "Executing", text
84
            self.sharp_engine.execute(text)
85
        else:
86
            self.client.write(text)
87

  
77 88

  
78 89
class GUIClient(Client):
79 90

  
......
100 111

  
101 112
        """
102 113
        self.window = window
103
        window.client = self.client
114
        window.client = self
104 115

  
105 116
    def handle_message(self, msg):
106 117
        """When the client receives a message."""

Also available in: Unified diff