From 572b12ee63bedae0947f34b86d87484634a4f4a9 Mon Sep 17 00:00:00 2001 From: Christopher Vagnetoft Date: Thu, 15 Dec 2016 22:25:51 +0100 Subject: [PATCH] Bugfixed parameter mapping --- bin/phpl-edit | 9 +++++++++ bin/phpl-reload | 12 ++++++----- modules/git.php | 4 ++-- themes/default.theme | 14 +++++-------- themes/mono.theme | 6 ++++++ themes/solarized.theme | 45 ++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 74 insertions(+), 16 deletions(-) create mode 100644 themes/mono.theme create mode 100644 themes/solarized.theme diff --git a/bin/phpl-edit b/bin/phpl-edit index f49a79b..0e94ac0 100755 --- a/bin/phpl-edit +++ b/bin/phpl-edit @@ -142,7 +142,16 @@ if (cmdl_get($opts,'list')) { } elseif (cmdl_get($opts,'E')) { passthru("editor ".escapeshellarg(PHPL_CONFIG)); if (RELOAD) passthru("phpl-reload --prompt"); + exit; } elseif (($theme = cmdl_get($opts,'theme'))) { + if ($theme == 'list') { + $themes = glob(PHPL_THEMES."/*.theme"); + printf("Installed themes:\n"); + foreach ($themes as $theme) { + printf(" - %s\n", basename($theme,".theme")); + } + exit(0); + } if (!file_exists(PHPL_THEMES."/{$theme}.theme")) { printf("Error: No such theme, %s\n", $theme); exit(1); diff --git a/bin/phpl-reload b/bin/phpl-reload index dea1d91..ea62f1f 100755 --- a/bin/phpl-reload +++ b/bin/phpl-reload @@ -47,17 +47,18 @@ function reload_prompt() { continue; } $opts = $_MODULES[$item[1]]->opts; - $defs = []; - $type = []; + $defs = []; $type = []; $maps = []; foreach ($opts as $opt) { $defs[$opt->key] = $opt->def; - $type[$opt->key] = $opt->type; + $type[$opt->name] = $opt->type; + $maps[$opt->name] = $opt->key; } // Coerce types + $aout = []; foreach ($attr as $k=>$v) { if (array_key_exists($k,$type)) { switch ($type[$k]) { - case 'bool': + case 'boolean': $attr[$k] = (bool)$v; break; case 'int': @@ -69,9 +70,10 @@ function reload_prompt() { default: QUIET or printf("Warning: Unknown option type %s", $type[$k]); } + $aout[$maps[$k]] = $v; } } - $segments[] = sprintf("_%s(%s)", $item[1], var_export(array_merge($defs,$attr),true)); + $segments[] = sprintf("_%s(%s)", $item[1], var_export(array_merge($defs,$aout),true)); } $modsrc = []; diff --git a/modules/git.php b/modules/git.php index a2f3b25..7ae6bd7 100644 --- a/modules/git.php +++ b/modules/git.php @@ -13,7 +13,7 @@ define("GIT_SHOW_STATUS", "show_status"); // Module -function _git(array $opts=[]) { +function _git(array $opts) { $git = "env LANG=C git"; @@ -35,7 +35,7 @@ function _git(array $opts=[]) { $marks[] = ICON_GIT_NEED_PULL_SYMBOL.$match[1]; } - if ($opts[GIT_SHOW_TAG]==true) { + if ($opts[GIT_SHOW_TAG]) { $tag = exec("{$git} describe --tags 2>/dev/null"); if ($tag) $marks[] = ICON_GIT_TAG.(strpos($tag,'-')?substr($tag,0,strpos($tag,'-')).'+':$tag); diff --git a/themes/default.theme b/themes/default.theme index 7a9e5db..4224edd 100644 --- a/themes/default.theme +++ b/themes/default.theme @@ -9,6 +9,11 @@ path { background: cyan; } +loadavg { + color: bright-yellow; + background: gray; +} + .vcs { background: blue; } @@ -27,12 +32,3 @@ status.bad { background: red; } -loadavg { - color: bright-yellow; - background: gray; -} - -text.test { - background: white; - color: black; -} diff --git a/themes/mono.theme b/themes/mono.theme new file mode 100644 index 0000000..d12ed7a --- /dev/null +++ b/themes/mono.theme @@ -0,0 +1,6 @@ +* { + color: white; + background: none; + pad-before: 1; + pad-after: 1; +} diff --git a/themes/solarized.theme b/themes/solarized.theme new file mode 100644 index 0000000..d35e068 --- /dev/null +++ b/themes/solarized.theme @@ -0,0 +1,45 @@ +$pragma(256color) + +// Solarized color theme +$set(base03,#002b36) +$set(base02,#073642) +$set(base01,#586e75) +$set(base00,#657b83) +$set(base0,#839496) +$set(base1,#93a1a1) +$set(base2,#eee8d5) +$set(base3,#fdf6e3) +$set(yellow,#b58900) +$set(orange,#cb4b16) +$set(red,#dc322f) +$set(magenta,#d33682) +$set(violet,#6c71c4) +$set(blue,#268bd2) +$set(cyan,#2aa198) +$set(green,#859900) + +* { + color: %base0; + background: %base03; + pad-before: 1; + pad-after: 1; +} + +path { + color: %base1; +} + +loadavg { + background: %base01; + color: %base2; +} + +.vcs { + background: %base01; + color: %base1; +} + +.sys { + background: %base02; + color: %base2 +}