Skip to content

Commit

Permalink
Add line pause
Browse files Browse the repository at this point in the history
  • Loading branch information
tspivey committed Dec 3, 2020
1 parent a031881 commit 4fff435
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
1 change: 1 addition & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ Once in the config menu, you can use:
* v - set volume (value between 0 and 100).
* p - toggle symbol processing.
* d - set cursor delay (in MS). The default is 20.
* l - Toggle pausing at newlines.
* Enter - exit, saving the configuration.

## Symbols
Expand Down
18 changes: 15 additions & 3 deletions tdsr
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ class State:
self.tempsilence = False
self.key_handlers = []
self.config = configparser.ConfigParser()
self.config['speech'] = {'process_symbols': 'false', 'key_echo': True, 'cursor_tracking': True}
self.config['speech'] = {'process_symbols': 'false', 'key_echo': True, 'cursor_tracking': True,
"line_pause": True}
self.config['symbols'] = {}
self.symbols_Re = None
self.copy_x = None
Expand Down Expand Up @@ -110,6 +111,7 @@ class ConfigHandler(KeyHandler):
b'd': self.set_delay,
b'e': self.set_echo,
b'c': self.set_cursor_tracking,
b'l': self.set_line_pause,
}
super().__init__(self.keymap)

Expand Down Expand Up @@ -164,6 +166,13 @@ class ConfigHandler(KeyHandler):
state.save_config()
say("cursor tracking on" if current else "cursor tracking off")

def set_line_pause(self):
current = state.config.getboolean('speech', 'line_pause')
current = not current
state.config['speech']['line_pause'] = str(current)
state.save_config()
say("line pause on" if current else "line pause off")

def set_delay(self):
say("Cursor delay")
state.key_handlers.append(BufferHandler(on_accept=self.set_delay2))
Expand Down Expand Up @@ -351,7 +360,7 @@ def main():
state.revx, state.revy = screen.cursor.x, screen.cursor.y
if not state.silence and not state.tempsilence:
if speech_buffer.tell() > 0 and not state.delaying_output:
schedule(0.001, read_buffer_scheduled)
schedule(0.005, read_buffer_scheduled)
os.write(1, bytes)
run_scheduled()

Expand Down Expand Up @@ -494,7 +503,10 @@ class MyScreen(pyte.Screen):
super().tab()

def linefeed(self):
sb()
if state.config.getboolean('speech', 'line_pause'):
sb()
else:
speech_buffer.write(' ')
super(MyScreen, self).linefeed()

def backspace(self):
Expand Down

0 comments on commit 4fff435

Please sign in to comment.