# ACTIVESTATE TEAPOT-PKG BEGIN TM -*- tcl -*- # -- Tcl Module # @@ Meta Begin # Package linenoise::facade 0.1 # Meta author {Andreas Kupries} # Meta build::by andreask # Meta build::date 2015-06-11 # Meta description Sub-class of 'linenoise::repl' enabling customization # Meta description by delegation. # Meta location https://core.tcl.tk/akupries/linenoise-utilities # Meta platform tcl # Meta require {Tcl 8.5-} # Meta require TclOO # Meta require linenoise::repl # Meta subject {command loop} repl {read eval print loop} # Meta subject {command dispatcher} linenoise {line editor} readline # Meta subject editline {edit line} tty console terminal {read line} # Meta subject {line reader} # Meta summary Delegation-based linenoise-based read-eval-print-loop. # Meta vc::revision 9b8d6162d2f15006a5d5504cb4790d4557e651b2 # Meta vc::system fossil # @@ Meta End # ACTIVESTATE TEAPOT-PKG BEGIN REQUIREMENTS package require Tcl 8.5- package require TclOO package require linenoise::repl # ACTIVESTATE TEAPOT-PKG END REQUIREMENTS # ACTIVESTATE TEAPOT-PKG BEGIN DECLARE package provide linenoise::facade 0.1 # ACTIVESTATE TEAPOT-PKG END DECLARE # ACTIVESTATE TEAPOT-PKG END TM ## -*- tcl -*- # # ## ### ##### ######## ############# ##################### ## Linenoise OO REPL facade class (delegation). # @@ Meta Begin # Package linenoise::facade 0 # Meta author {Andreas Kupries} # Meta location https://core.tcl.tk/akupries/linenoise-utilities # Meta platform tcl # Meta summary Delegation-based linenoise-based read-eval-print-loop. # Meta description Sub-class of 'linenoise::repl' enabling customization # Meta description by delegation. # Meta subject {command loop} repl {read eval print loop} {command dispatcher} # Meta subject linenoise {line editor} readline editline {edit line} tty console # Meta subject terminal {read line} {line reader} # Meta require {Tcl 8.5-} # Meta require TclOO # Meta require linenoise::repl # @@ Meta End # # ## ### ##### ######## ############# ##################### ## Requisites package require Tcl 8.5 package require TclOO package require linenoise::repl # # ## ### ##### ######## ############# ##################### ## oo::class create ::linenoise::facade { superclass linenoise::repl # # ## ### ##### ######## ############# ## Lifecycle constructor {actor} { set myactor $actor next return } # # ## ### ##### ######## ############# ## REPL hook methods. ## We override the base class implementations to delegate them to ## the chosen actor. # TclOO forward'ing usable for this ? method prompt1 {} { $myactor prompt1 } method prompt2 {} { $myactor prompt2 } method complete {line} { $myactor complete $line } method continued {line} { $myactor continued $line } method dispatch {cmd} { $myactor dispatch $cmd } method report {what data} { $myactor report $what $data } method exit {} { $myactor exit } # # ## ### ##### ######## ############# ## Instance command of the object the facade delegates the REPL ## hooks to. variable myactor ## # # ## ### ##### ######## ############# } # # ## ### ##### ######## ############# ##################### ## Ready package provide linenoise::facade 0.1