Skip to content

Commit

Permalink
Respect grrui arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
awaescher committed Dec 18, 2018
1 parent 958eac0 commit 3b18e09
Showing 1 changed file with 22 additions and 16 deletions.
38 changes: 22 additions & 16 deletions grrui/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ class Program
private static RepoZIpcClient _client;
private static ListView _repositoryList;
private static RepositoriesView _repositoriesView;
private static TextField _filterField;

static void Main(string[] args)
static void Main(string[] args)
{
_client = new RepoZIpcClient();
var answer = _client.GetRepositories();
Expand All @@ -39,13 +40,13 @@ static void Main(string[] args)
Application.Init();

var filterLabel = new Label(1, 1, "Filter: ");
var filterField = new TextField("")
_filterField = new TextField("")
{
X = Pos.Right(filterLabel) + 2,
Y = Pos.Top(filterLabel),
Width = Dim.Fill(margin: 1),
};
filterField.Changed += FilterField_Changed;
_filterField.Changed += FilterField_Changed;

_repositoryList = new ListView(_repositoriesView.Repositories)
{
Expand All @@ -57,7 +58,7 @@ static void Main(string[] args)

var win = new KeyPreviewWindow("grr: Git repositories of RepoZ");
win.Add(filterLabel);
win.Add(filterField);
win.Add(_filterField);
win.Add(_repositoryList);

var buttonX = Pos.Left(filterLabel);
Expand Down Expand Up @@ -90,7 +91,7 @@ static void Main(string[] args)
var quitButton = new Button("Quit")
{
Clicked = Application.RequestStop,
X = Pos.AnchorEnd(8 + 1),
X = Pos.AnchorEnd("Quit".Length + BUTTON_BORDER + BUTTON_DISTANCE),
Y = Pos.AnchorEnd(1),
CanFocus = false
};
Expand All @@ -100,22 +101,27 @@ static void Main(string[] args)
win.DefineKeyAction(Key.Enter, () => win.SetFocus(_repositoryList));
win.DefineKeyAction(Key.Esc, () =>
{
if (filterField.HasFocus)
{
filterField.Text = "";
FilterField_Changed(filterField, EventArgs.Empty);
}
if (_filterField.HasFocus)
SetFilterText("");
else
{
win.SetFocus(filterField);
}
win.SetFocus(_filterField);
});

Application.Top.Add(win);
Application.Run();
if (args?.Length > 0)
SetFilterText(String.Join(" ", args));

Application.Top.Add(win);
Application.Run();
}

private static void Navigate()
private static void SetFilterText(string filter)
{
_filterField.Text = filter;
_filterField.PositionCursor();
FilterField_Changed(_filterField, EventArgs.Empty);
}

private static void Navigate()
{
ExecuteOnSelectedRepository(r =>
{
Expand Down

0 comments on commit 3b18e09

Please sign in to comment.