key binding for adding and removing seq. nums

This commit is contained in:
nadrad 2022-10-13 12:30:38 +02:00
parent be86b68886
commit 70e1c5f875
2 changed files with 30 additions and 0 deletions

29
h-m-m
View file

@ -953,6 +953,34 @@ function build_map(&$mm)
}
// }}}
// {{{ toggle numbers
function toggle_numbers(&$mm)
{
if ($mm['active_node'] <= $mm['root'])
return;
$ordered= false;
$i=1;
foreach ($mm['nodes'][ $mm['nodes'][$mm['active_node']]['parent'] ]['children'] as $cid)
$ordered = $ordered || mb_ereg('^\d+\.',$mm['nodes'][$cid]['title']);
$i=1;
foreach ($mm['nodes'][ $mm['nodes'][$mm['active_node']]['parent'] ]['children'] as $cid)
if ($ordered)
$mm['nodes'][$cid]['title'] = mb_ereg_replace('^\d+\. *','',$mm['nodes'][$cid]['title']);
else
$mm['nodes'][$cid]['title'] = ($i++).'. '.$mm['nodes'][$cid]['title'];
$mm['modified'] = true;
build_map($mm);
display($mm);
}
// }}}
// {{{ toggle symbol
@ -2734,6 +2762,7 @@ function monitor_key_presses(&$mm)
case 'S': save($mm, true); break;
case 't': toggle_symbol($mm); break;
case '#': toggle_numbers($mm); break;
case 'u': undo($mm); break;

View file

@ -23,6 +23,7 @@ Adding, removing, and editing nodes:
* `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