-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
59b5306
commit 2d0a195
Showing
7 changed files
with
92 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,37 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using System.Windows; | ||
using System.Windows.Controls; | ||
using System.Windows.Data; | ||
using System.Windows.Documents; | ||
using System.Windows.Input; | ||
using System.Windows.Media; | ||
using System.Windows.Media.Imaging; | ||
using System.Windows.Navigation; | ||
using System.Windows.Shapes; | ||
|
||
namespace condo | ||
namespace condo | ||
{ | ||
using System; | ||
using System.ComponentModel; | ||
using System.IO; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using System.Windows; | ||
|
||
/// <summary> | ||
/// Interaction logic for MainWindow.xaml | ||
/// </summary> | ||
public partial class MainWindow : Window | ||
{ | ||
private ConsoleBuffer.ConsoleWrapper consoleWrapper; | ||
|
||
public MainWindow() | ||
{ | ||
InitializeComponent(); | ||
this.stuff.Text = "sdkjashfgdjkas"; | ||
var terminal = TerminalManager.Instance.GetOrCreate(0, "ping -t localhost"); | ||
terminal.PropertyChanged += this.UpdateContents; | ||
} | ||
|
||
private void UpdateContents(object sender, PropertyChangedEventArgs args) | ||
{ | ||
var con = sender as ConsoleBuffer.ConsoleWrapper; | ||
if (sender == null && args.PropertyName != "Content") | ||
{ | ||
return; // XXX: log? | ||
} | ||
|
||
this.consoleWrapper = new ConsoleBuffer.ConsoleWrapper("debian run yes"); | ||
this.stuff.DataContext = this.consoleWrapper; | ||
this.stuff.Text = this.consoleWrapper.Contents; | ||
Dispatcher.InvokeAsync(() => | ||
{ | ||
this.stuff.Text = con.Contents; | ||
}); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
namespace condo | ||
{ | ||
using ConsoleBuffer; | ||
using System.Collections.Generic; | ||
using System.Threading.Tasks; | ||
|
||
/// <summary> | ||
/// Manages creating/destroying terminals through queued requests. | ||
/// </summary> | ||
public sealed class TerminalManager | ||
{ | ||
public static readonly TerminalManager Instance = new TerminalManager(); | ||
|
||
private readonly object terminalLock = new object(); | ||
private readonly Dictionary<int, ConsoleWrapper> terminals; | ||
|
||
private TerminalManager() | ||
{ | ||
this.terminals = new Dictionary<int, ConsoleWrapper>(); | ||
} | ||
|
||
public ConsoleWrapper GetOrCreate(int id, string command) | ||
{ | ||
ConsoleWrapper con; | ||
lock (this.terminalLock) | ||
{ | ||
if (this.terminals.TryGetValue(id, out con)) | ||
{ | ||
return con; | ||
} | ||
|
||
con = new ConsoleWrapper(command); | ||
this.terminals[id] = con; | ||
return con; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters