text map export

This commit is contained in:
nadrad 2023-03-18 14:38:26 +01:00
parent 3cabf66edf
commit c447c06223
2 changed files with 8 additions and 26 deletions

31
h-m-m
View file

@ -2084,32 +2084,13 @@ function export_html_node(&$mm, $parent_id)
function export_text(&$mm)
{
if (empty($mm['filename']))
{
message($mm, "Can't export the map when it doesn't have a file name yet. Save it first.");
return;
}
$file = fopen($mm['filename'].'.txt', "w");
if ($file===false)
{
message($mm, 'ERROR! Could not save the file');
return;
}
fwrite
(
$file
,implode("\n",$mm['map'])
);
fclose($file);
message($mm, 'Exported as '.$mm['filename'].'.txt');
$filename = getenv('PWD').'/'.basename($mm['filename']).'.txt';
copy_to_clipboard($mm, $filename);
$output = '';
foreach ($mm['map'] as $line)
if (rtrim($line) != '')
$output .= substr(rtrim($line),3)."\n";
copy_to_clipboard($mm, $output);
message($mm, 'Exported the map to clipboard.');
}

View file

@ -81,7 +81,8 @@ Save, export, and quit:
* `s` - saves with the previous file name (or asks for one if there's none)
* `S` - saves with a new file name
* `x` - export as HTML
* `x` - export as an HTML file
* `X` - export as a text map into clipboard
* `q` - quits (if the changes were already saved)
* `Q` - quits, ignoring the changes