This commit is contained in:
WenHuxian 2024-05-02 08:57:00 +02:00 committed by GitHub
commit 1b1c9aeec9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

46
h-m-m
View file

@ -766,6 +766,7 @@ function calculate_x_and_lh(&$mm, $id)
{ {
$node = $mm['nodes'][$id]; $node = $mm['nodes'][$id];
$mm['nodes'][$id]['x'] = $mm['nodes'][$id]['x'] =
$mm['nodes'][ $node['parent'] ]['x'] $mm['nodes'][ $node['parent'] ]['x']
+ $mm['nodes'][ $node['parent'] ]['w'] + $mm['nodes'][ $node['parent'] ]['w']
@ -799,7 +800,7 @@ function calculate_x_and_lh(&$mm, $id)
$mm['nodes'][$id]['w'] = 0; $mm['nodes'][$id]['w'] = 0;
foreach ($lines as $line) foreach ($lines as $line)
$mm['nodes'][$id]['w'] = $mm['nodes'][$id]['w'] =
max($mm['nodes'][$id]['w'], trim(mb_strwidth($line))); max($mm['nodes'][$id]['w'], mb_strwidth(trim($line)));
$mm['nodes'][$id]['lh'] = count($lines); $mm['nodes'][$id]['lh'] = count($lines);
} }
@ -827,6 +828,7 @@ function calculate_x_and_lh(&$mm, $id)
calculate_x_and_lh($mm, $cid); calculate_x_and_lh($mm, $cid);
$mm['nodes'][$id]['clh'] += $mm['nodes'][$cid]['clh']; $mm['nodes'][$id]['clh'] += $mm['nodes'][$cid]['clh'];
} }
} }
@ -1228,6 +1230,27 @@ function draw_connections(&$mm, $id)
draw_connections($mm, $cid); draw_connections($mm, $cid);
} }
function calculate_xo(&$mm)
{
foreach($mm['nodes'] as $id=>$node) {
$node = $mm['nodes'][$id];
$mm['nodes'][$id]['xo'] = 0;
if (!array_key_exists('yo',$node)) {
$node['yo'] = 0;
}
foreach($mm['nodes'] as $fore_node ) {
if (!array_key_exists('yo', $fore_node)) {
$fore_node['yo'] = 0;
}
if ($fore_node['y'] + $fore_node['yo'] == $node['y'] + $node['yo'] && $fore_node['x'] < $node['x']) {
$mm['nodes'][$id]['xo'] += mb_strlen($fore_node['title']) - mb_strwidth($fore_node['title']);
}
}
}
}
// }}} // }}}
// {{{ add content to the map // {{{ add content to the map
@ -1266,10 +1289,10 @@ function add_content_to_the_map(&$mm, $id)
$num_lines = count($lines); $num_lines = count($lines);
for ( $i=0 ; $i<$num_lines ; $i++ ) for ( $i=0 ; $i<$num_lines ; $i++ )
mmputcontent mmput
( (
$mm, $mm,
$node['x'], $node['x']+$node['xo'],
$node['y']+$node['yo']+$i, $node['y']+$node['yo']+$i,
$lines[$i].' ' $lines[$i].' '
); );
@ -1302,6 +1325,7 @@ function build_map(&$mm)
} }
$mm['nodes'][0]['x'] = 0; $mm['nodes'][0]['x'] = 0;
$mm['nodes'][0]['xo'] = 0;
$mm['nodes'][0]['w'] = left_padding; $mm['nodes'][0]['w'] = left_padding;
$mm['nodes'][0]['lh'] = 1; $mm['nodes'][0]['lh'] = 1;
@ -1322,6 +1346,8 @@ function build_map(&$mm)
calculate_y($mm); calculate_y($mm);
calculate_height_shift($mm, $mm['root_id']); calculate_height_shift($mm, $mm['root_id']);
calculate_xo($mm);
// resetting the map, 2/2 // resetting the map, 2/2
$height = max($mm['map_bottom'],$mm['terminal_height']); $height = max($mm['map_bottom'],$mm['terminal_height']);
$blank = str_repeat(' ', max($mm['map_width'],$mm['terminal_width'])); $blank = str_repeat(' ', max($mm['map_width'],$mm['terminal_width']));
@ -3332,14 +3358,14 @@ function display(&$mm, $force_center = false)
max max
( (
0 0
,$mm['nodes'][ $mm['active_node'] ]['x'] ,$mm['nodes'][ $mm['active_node'] ]['x'] + $mm['nodes'][ $mm['active_node'] ]['xo']
-1 -1
-$mm['viewport_left'] -$mm['viewport_left']
) )
; ;
$x2 $x2
= $mm['nodes'][ $mm['active_node'] ]['w'] = mb_strlen($mm['nodes'][ $mm['active_node'] ]['title'])
+ $x1 + $x1
+ 2 + 2
- ($mm['active_node']==0 && left_padding==0) - ($mm['active_node']==0 && left_padding==0)
@ -3515,16 +3541,6 @@ function mmput(&$mm,$x,$y,$s)
{ {
$y = round($y); $y = round($y);
$mm['map'][$y]
= mb_substr( $mm['map'][$y], 0, $x)
. $s
. mb_substr( $mm['map'][$y], $x + mb_strlen($s) );
}
function mmputcontent(&$mm,$x,$y,$s)
{
$y = round($y);
$mm['map'][$y] $mm['map'][$y]
= mb_substr( $mm['map'][$y], 0, $x) = mb_substr( $mm['map'][$y], 0, $x)
. $s . $s