mirror of
https://github.com/Leonmmcoset/CMLeonOS.git
synced 2026-03-03 15:30:27 +00:00
拆分代码5
This commit is contained in:
26
shell/Commands/Editor/EditCommand.cs
Normal file
26
shell/Commands/Editor/EditCommand.cs
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
namespace CMLeonOS.Commands.Editor
|
||||||
|
{
|
||||||
|
public static class EditCommand
|
||||||
|
{
|
||||||
|
public static void EditFile(string fileName, CMLeonOS.FileSystem fileSystem, Action<string> showError)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(fileName))
|
||||||
|
{
|
||||||
|
showError("Please specify a file name");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var editor = new CMLeonOS.Editor(fileName, fileSystem);
|
||||||
|
editor.Run();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
showError($"Error starting editor: {ex.Message}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
26
shell/Commands/Editor/NanoCommand.cs
Normal file
26
shell/Commands/Editor/NanoCommand.cs
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
namespace CMLeonOS.Commands.Editor
|
||||||
|
{
|
||||||
|
public static class NanoCommand
|
||||||
|
{
|
||||||
|
public static void NanoFile(string fileName, CMLeonOS.FileSystem fileSystem, CMLeonOS.UserSystem userSystem, Shell shell, Action<string> showError)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(fileName))
|
||||||
|
{
|
||||||
|
showError("Please specify a file name");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var nano = new Nano(fileName, true, fileSystem, userSystem, shell);
|
||||||
|
nano.Start();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
showError($"Error starting nano: {ex.Message}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -437,40 +437,12 @@ namespace CMLeonOS
|
|||||||
|
|
||||||
public void EditFile(string fileName)
|
public void EditFile(string fileName)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(fileName))
|
Commands.Editor.EditCommand.EditFile(fileName, fileSystem, ShowError);
|
||||||
{
|
|
||||||
ShowError("Please specify a file name");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var editor = new Editor(fileName, fileSystem);
|
|
||||||
editor.Run();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
ShowError($"Error starting editor: {ex.Message}");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void NanoFile(string fileName)
|
public void NanoFile(string fileName)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(fileName))
|
Commands.Editor.NanoCommand.NanoFile(fileName, fileSystem, userSystem, this, ShowError);
|
||||||
{
|
|
||||||
ShowError("Please specify a file name");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var nano = new Nano(fileName, true, fileSystem, userSystem, this);
|
|
||||||
nano.Start();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
ShowError($"Error starting nano: {ex.Message}");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DiffFiles(string args)
|
public void DiffFiles(string args)
|
||||||
|
|||||||
Reference in New Issue
Block a user