From 1e5f13b21b33b0d7ce86fe97ca145a3561433a7a Mon Sep 17 00:00:00 2001 From: wei <> Date: Mon, 18 Sep 2006 22:57:16 +0000 Subject: Add an interactive php shell that loads Prado classes. --- .../PhpShell/PHP/Shell/Extensions/Colour.php | 120 +++++++++++++++++++++ 1 file changed, 120 insertions(+) create mode 100644 framework/3rdParty/PhpShell/PHP/Shell/Extensions/Colour.php (limited to 'framework/3rdParty/PhpShell/PHP/Shell/Extensions/Colour.php') diff --git a/framework/3rdParty/PhpShell/PHP/Shell/Extensions/Colour.php b/framework/3rdParty/PhpShell/PHP/Shell/Extensions/Colour.php new file mode 100644 index 00000000..05d7be1d --- /dev/null +++ b/framework/3rdParty/PhpShell/PHP/Shell/Extensions/Colour.php @@ -0,0 +1,120 @@ +registerOption("background", $this, "optSetBackground"); + $opt->registerOptionAlias("bg", "background"); + + $this->registerColourScheme( + "plain", array( + "default" => "", "value" => "", + "exception" => "", "reset" => "")); + + $this->registerColourScheme( + "dark", array( + "default" => self::C_YELLOW, + "value" => self::C_WHITE, + "exception" => self::C_PURPLE)); + + $this->registerColourScheme( + "light", array( + "default" => self::C_BLACK, + "value" => self::C_BLUE, + "exception" => self::C_RED)); + + } + + /** + * background colours + */ + public function optSetBackground($key, $value) { + if (is_null($value)) { + print(':set '.$key.' needs a colour-scheme, e.g. :set '.$key.'=dark'); + return; + } + if (false == $this->applyColourScheme($value)) { + print('setting colourscheme failed: colourscheme '.$value.' is unknown'); + return; + } + } + + /** + * get a colour for the shell + * + * @param string $type one of (value|exception|reset|default) + * @return string a colour string or a empty string + */ + public function getColour($type) { + return isset($this->colour[$type]) ? $this->colour[$type] : ''; + } + + /** + * apply a colour scheme to the current shell + * + * @param string $scheme name of the scheme + * @return false if colourscheme is not known, otherwise true + */ + public function applyColourScheme($scheme) { + if (!isset($this->colour_scheme[$scheme])) return false; + + $this->colour = $this->colour_scheme[$scheme]; + + return true; + } + + /** + * registers a colour scheme + * + * @param string $scheme name of the colour scheme + * @param array a array of colours + */ + public function registerColourScheme($scheme, $colours) { + if (!is_array($colours)) return; + + /* set a reset colour if it is not supplied from the outside */ + if (!isset($colours["reset"])) $colours["reset"] = self::C_RESET; + + $this->colour_scheme[$scheme] = $colours; + } +} + -- cgit v1.2.3