mirror of
https://github.com/nadrad/h-m-m.git
synced 2024-05-20 23:16:32 +02:00
text map export
This commit is contained in:
parent
3cabf66edf
commit
c447c06223
31
h-m-m
31
h-m-m
|
@ -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.');
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue