added the ranking feature

This commit is contained in:
nadrad 2022-12-22 17:07:30 +01:00
parent 16c5185ba1
commit c7f117d21d
2 changed files with 46 additions and 2 deletions

37
h-m-m
View file

@ -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;
}

View file

@ -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