diff --git a/h-m-m b/h-m-m index c66e35c..13e8a7b 100755 --- a/h-m-m +++ b/h-m-m @@ -241,6 +241,9 @@ const special_keys = 'arr_up' => "\033\133\101", 'arr_left' => "\033\133\104", + 'alt_arr_up' => "\033\133\061\073\063\101", + 'alt_arr_down' => "\033\133\061\073\063\102", + 'meta_arr_left' => "\033\033\133\104", 'ctrl_arr_left' => "\033\133\061\073\065\104", 'shift_arr_left' => "\033\133\061\073\062\104", @@ -381,6 +384,9 @@ $keybindings[special_keys['arr_up']] = 'go_up'; $keybindings[special_keys['arr_right']] = 'go_right'; $keybindings[special_keys['arr_left']] = 'go_left'; +$keybindings[special_keys['alt_arr_up']] = 'add_star'; +$keybindings[special_keys['alt_arr_down']] = 'remove_star'; + $keybindings['1'] = 'collapse_level_1'; $keybindings['2'] = 'collapse_level_2'; $keybindings['3'] = 'collapse_level_3'; @@ -3677,6 +3683,59 @@ function sort_siblings() } +// }}} +// {{{ add or remove stars + +function add_star() +{ + add_or_remove_stars(+1); +} + +function remove_star() +{ + add_or_remove_stars(-1); +} + +function add_or_remove_stars($change) +{ + global $mm; + push_change($mm); + $mm['nodes'][ $mm['active_node'] ]['title'] = + replace_stars + ( + $mm['nodes'][ $mm['active_node'] ]['title'] + , + max + ( + 0 + ,min + ( + 5 + ,mb_substr_count + ( + $mm['nodes'][ $mm['active_node'] ]['title'] + ,'★' + ) + +$change + ) + ) + ) + ; + build_map($mm); + display($mm); +} + +function replace_stars($text,$stars) +{ + $stars_string = str_repeat('★',$stars).str_repeat('☆',5-$stars); + + if (mb_ereg('[★☆]',$text)) + return mb_ereg_replace('[★☆]+',$stars_string,$text); + else + return $text . $stars_string; +} + + // }}} // {{{ monitor key presses diff --git a/readme.md b/readme.md index a45251e..f4f06ea 100644 --- a/readme.md +++ b/readme.md @@ -32,6 +32,8 @@ Marks: * `+` - decreases the positive ranking * `-` - increases the negative ranking * `_` - decreases the negative ranking +* `alt+up` - adds a star +* `alt+down` - removes a star * `H` - toggles the hidden flag Relative navigating and moving: @@ -113,6 +115,8 @@ Other than the text editor key bindings, you can change all in your config file. When working with a group of people in a workshop, sometimes you need to decide on a subtopic (i.e., selecting one of the proposed items). After discussing them, people can vote "yes" or "no" for each item. You can add a positive point for each "yes" (`=`) and a negative one for each "no" (`-`). In the end, you can press shift+t to sort them and see the highest-ranking choices on the top. +Another way of ranking is to use stars. To do so, you can press `alt+up` or `alt+down` to add or remove stars and show a zero to five rank. + # Configuration @@ -204,6 +208,8 @@ You can also change key bindings with a `bind x = command` syntax. The following bind arr_up = go_up bind arr_right = go_right bind arr_left = go_left + bind alt_arr_up = add_star + bind alt_arr_down = remove_star bind 1 = collapse_level_1 bind 2 = collapse_level_2 bind 3 = collapse_level_3