On Thu, Jul 10, 2014 at 11:52 AM, Raphaël Proust <raphla...@gmail.com> wrote: > On Thu, Jul 10, 2014 at 1:56 AM, Dimitris Zervas <dzer...@dzervas.gr> wrote: >>>Also it would be nice if the actual text editing >>>component >>>would be clearly separated out, such that different editor frontends >>>can be implemented easily. >> >> Well, this is much easier implemented in OOP languages (which I don't love >> that much) but I don't know what would be the performance, complexity and >> code readability would be. >> I'll take a look, but no promises, as I love TUI (but I hate curses :P ) > > On the FP side there is Yi[0] > > The trick that Yi uses is quite clever and not very complicated: > keyboard input is passed to a lexer/parser which can be rewritten to > provide alternative bindings. Treating keyboard events like that > actually makes a lot of sense. It is not very specific to any > programming paradigm and could be implemented in C (with a recursive > descent parser if yacc is deemed to suck to much).
Actually, I do not think you will need a "real" recursive parser. It should be enough to use a finite state machine since you won't have any recursively nested key bindings. I am not completely sure how to implement this but it sounds like a very interesting problem. The states transition should probably look something like this (count)? -> (operation)->(object) where the functions will be called in the final state (?). I will probably have to think some more about this... Cheers, Silvan