mirror of
https://github.com/nadrad/h-m-m.git
synced 2024-06-08 03:52:12 +02:00
added the ranking feature
This commit is contained in:
parent
16c5185ba1
commit
c7f117d21d
37
h-m-m
37
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;
|
||||
}
|
||||
|
|
11
readme.md
11
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
|
||||
|
|
Loading…
Reference in a new issue