User Tools

Site Tools



This shows you the differences between two versions of the page.

Link to this comparison view

input_handling [2007/04/25 05:56] (current)
Line 1: Line 1:
 +I get many requests for utf8 support. ​ As of the time I write this, epic does
 +not support utf8, and support for it is not planned in the short term.
 +This document describes how epic handles your keypresses, and discusses how
 +utf8 support might grow in the future. ​ This document is not intended to be 
 +excruciatingly exacting enough to satisfy pedants, but rather to gently ​
 +introduce people to the issues and why console programs have a much harder
 +time of it than graphical program.s
 +======How epic handles user input======
 +=====The flow chart=====
 + 1) You press a key
 + 2) Your terminal emulator converts it to a string
 + 3) That string is sent to epic
 + 4) EPIC decomposes the string into individual characters
 + 5) Sequences of characters are accumulated to match your [[bind]]ings.
 + 6) The actions associated with your [[bind]]ings are executed.
 +=====Your terminal emulator and epic must agree=====
 +If your terminal emulator sends ^[[D when you press cursor left (trust me,
 +it does), then you must /bind ^[[D backward_character to get the cursor ​
 +left key to move the cursor back one character. ​ All characters work in 
 +this way.  Your emulator converts one keypress into one or more bytes, and
 +sends those bytes to the program you're running (epic). ​
 +It is important to realize that this is not magic: your emulator can send 
 +whatever string it wants, and epic would not have any idea what that is.  ​
 +However, there is historical precedent that certain keys generate certain ​
 +strings, and most terminal emulators use them for maximum compatability.
 +So you usually never have to think about this.  It Just Works(tm).
 +=====EPIC receives the string=====
 +Whatever string your terminal emulator sent is received by epic as user 
 +input. ​ EPIC has to convert this string of bytes into a sequence of 
 +//​characters//,​ which then are grouped together to form 
 +//character sequences// which are associated with a //key binding//, ​
 +which performs an //action//.
 +=====Keybindings regroup strings back into key presses=====
 +Since pressing some keys generates multiple bytes of input, you have to 
 +tell epic how to re-assemble those bytes of input back into one logical
 +character. ​ This is done through keybindings.
 +In our current example, you did /bind ^[[D backward_character. ​ What this
 +does is tell epic to treat the character sequence ^[[D as one keypress
 +and you want it to execute the [[backward_characte]] action when you do
 +that keypress. ​ If you didn't have the keybinding, then epic would treat
 +each of the three keys as individual keypresses, and do whatever action
 +each of the three were bound to!
input_handling.txt ยท Last modified: 2007/04/25 05:56 (external edit)