mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-24 05:35:00 +00:00
refactor: commandline parsing
* `--rebase-todo-editor` launches this app as a git `sequence.editor` * `--rebase-message-editor` launches this app as a git `core.editor` which runs on background by reading rebasing jobs * `--core-editor` launches this app as a git `core.editor` * `--askpass` launches this app as a SSH askpass program
This commit is contained in:
parent
cbe4c36525
commit
6930b51c64
14 changed files with 320 additions and 155 deletions
54
src/Views/CodeEditor.axaml.cs
Normal file
54
src/Views/CodeEditor.axaml.cs
Normal file
|
@ -0,0 +1,54 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using Avalonia.Input;
|
||||
using Avalonia.Interactivity;
|
||||
|
||||
namespace SourceGit.Views
|
||||
{
|
||||
public partial class CodeEditor : ChromelessWindow
|
||||
{
|
||||
public CodeEditor()
|
||||
{
|
||||
DataContext = this;
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public CodeEditor(string file)
|
||||
{
|
||||
_file = file;
|
||||
DataContext = this;
|
||||
InitializeComponent();
|
||||
|
||||
var content = File.ReadAllText(file).ReplaceLineEndings("\n");
|
||||
var firstLineEnd = content.IndexOf('\n');
|
||||
if (firstLineEnd == -1)
|
||||
{
|
||||
Editor.SubjectEditor.Text = content;
|
||||
}
|
||||
else
|
||||
{
|
||||
Editor.SubjectEditor.Text = content.Substring(0, firstLineEnd);
|
||||
Editor.DescriptionEditor.Text = content.Substring(firstLineEnd + 1);
|
||||
}
|
||||
}
|
||||
|
||||
private void BeginMoveWindow(object sender, PointerPressedEventArgs e)
|
||||
{
|
||||
BeginMoveDrag(e);
|
||||
}
|
||||
|
||||
private void CloseWindow(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Environment.Exit(-1);
|
||||
}
|
||||
|
||||
private void SaveAndClose(object sender, RoutedEventArgs e)
|
||||
{
|
||||
File.WriteAllText(_file, Editor.Text);
|
||||
Environment.Exit(0);
|
||||
}
|
||||
|
||||
private string _file = string.Empty;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue