[ditz-talk] GNU/Readline redux

yesmar yesmar at speakeasy.net
Mon Apr 14 02:47:05 EDT 2008


I created a second patch for GNU/Readline support in ditz. This one is  
published in the readline2 branch of the yesmar-clone of ditz:

	http://gitorious.org/projects/ditz/repos/yesmar-clone/logs/readline2

William, please merge into ditz edge when you get a chance.

Description of change:

Although GNU/Readline support is ostensibly included in all Ruby  
distributions (for use in irb) sometimes it may not be present. Two  
examples come to mind: (1) you roll your own Ruby and forget to  
include Readline into the mix, (2) you download a pre-compiled binary  
release that either has no Readline support or your library search  
path is messed up. Regardless, it would be a shame to get a stack  
trace when you run Ditz just because Readline isn't accessible.

This patch moves the Readline require from lib/lowline.rb to the lib/ 
ditz.rb and traps the require. We set a class variable in the Ditz  
module to true if and only if Readline was successfully required. If  
Readline isn't present, Ditz falls back on the original text entry  
code. If, on the other hand, Readline was successfully required, you  
get GNU/Readline editing (with history and vi/emacs key bindings).



More information about the ditz-talk mailing list