diff --git a/h-m-m b/h-m-m index 29f6b3f..3145d3f 100755 --- a/h-m-m +++ b/h-m-m @@ -2728,6 +2728,38 @@ function mmput(&$mm,$x,$y,$s) } +// }}} +// {{{ rank + +function rank(&$mm, $add_positive, $add_negative) +{ + + $negative = 0; + $positive = 0; + $existing = []; + + if (mb_ereg('^\((\d+)\+,(\d+)\-\)', $mm['nodes'][ $mm['active_node'] ]['title'], $existing)) + { + $positive = $existing[1]; + $negative = $existing[2]; + $mm['nodes'][ $mm['active_node'] ]['title'] = + mb_ereg_replace('^\(\d+\+,\d+\-\) *', '', $mm['nodes'][ $mm['active_node'] ]['title']); + } + + $negative = max(0, $negative + $add_negative); + $positive = max(0, $positive + $add_positive); + + $mm['nodes'][ $mm['active_node'] ]['title'] = + "({$positive}+,{$negative}-) " + .$mm['nodes'][ $mm['active_node'] ]['title'] + ; + + $mm['modified'] = true; + build_map($mm); + display($mm); +} + + // }}} // {{{ monitor key presses @@ -2841,6 +2873,11 @@ function monitor_key_presses(&$mm) case '?': search($mm); break; case ctrl_f: search($mm); break; + case '=': rank($mm, +1, 0); break; + case '+': rank($mm, -1, 0); break; + case '-': rank($mm, 0,+1); break; + case '_': rank($mm, 0,-1); break; + case "\n": insert_new_node($mm, insert_sibling); break; case "\t": insert_new_node($mm, insert_child); break; } diff --git a/readme.md b/readme.md index c422680..a1251e5 100644 --- a/readme.md +++ b/readme.md @@ -22,11 +22,18 @@ Adding, removing, and editing nodes: * `Ctrl+p` - appends the clipboard text at the end of the active node's title * `e`, `i`, or `a` - edits the active node * `E`, `I`, or `A` - edits the active node, ignoring the existing text -* `t` - toggles '✓ ', '✗ ', and '' at the beginning of the title -* `#` - adds or removes sequential numbers at the beginning of the titles of a node and its siblings * `u` - undo * `Ctrl+r` - redo +Marks: + +* `t` - toggles '✓ ', '✗ ', and '' at the beginning of the title +* `#` - adds or removes sequential numbers at the beginning of the titles of a node and its siblings +* `=` - increase the positive ranking +* `+` - decrease the positive ranking +* `-` - increase the negative ranking +* `_` - decrease the negative ranking + Relative navigating and moving: * `h` or `←` - activate the parent of the previously active node