Inheritance: IDisposable
Esempio n. 1
0
 public CommandEndpoint(string editorKey, ITypeCache cache, EventEndpoint eventEndpoint)
 {
     _keyPath = editorKey;
     _cache = cache;
     _eventEndpoint = eventEndpoint;
     _server = new TcpServer();
     _server.IncomingMessage += Handle_serverIncomingMessage;
     _server.Start();
     _editor = new Editor();
     _editor.RecievedMessage += Handle_editorRecievedMessage;
     _editor.Connect(_keyPath);
 }
Esempio n. 2
0
 private void goToType(ITypeCache cache, Editor editor)
 {
     _ctx.Post((s) =>
         {
             if (_gotoType == null || !_gotoType.Visible)
             {
                 _gotoType = new TypeSearchForm(
                     cache,
                     (file, line, column) => { editor.GoTo(file, line, column); },
                     () => { new System.Threading.Thread(() => { System.Threading.Thread.Sleep(1000); editor.SetFocus(); }).Start(); });
                 _gotoType.Show(this);
             }
             setToForeground(_gotoType);
         }, null);
 }
Esempio n. 3
0
 private void explore(ITypeCache cache, Editor editor)
 {
     _ctx.Post((s) =>
         {
             if (_exploreForm == null || !_exploreForm.Visible)
             {
                 _exploreForm = new FileExplorer(
                     cache,
                     _defaultLanguage,
                     (file, line, column) => { editor.GoTo(file, line, column); },
                     () => { editor.SetFocus(); });
                 _exploreForm.Show(this);
             }
             setToForeground(_exploreForm);
         }, null);
 }
Esempio n. 4
0
 public CommandEndpoint(string editorKey, ITypeCache cache, EventEndpoint eventEndpoint)
 {
     Logger.Write("Initializing command endpoint using editor key " + editorKey);
     _keyPath = editorKey;
     _cache = cache;
     Logger.Write("Setting up event endpoint");
     _eventEndpoint = eventEndpoint;
     _eventEndpoint.DispatchThrough((m) => {
             handle(new MessageArgs(Guid.Empty, m));
         });
     _server = new TcpServer();
     _server.IncomingMessage += Handle_serverIncomingMessage;
     _server.Start();
     Logger.Write("CodeEngine started listening on port {0}", _server.Port);
     _editor = new Editor();
     Logger.Write("Binding editor RecievedMessage");
     _editor.RecievedMessage += Handle_editorRecievedMessage;
     Logger.Write("Connecting to editor");
     _editor.Connect(_keyPath);
     Logger.Write("Done - Connecting to editor");
 }
Esempio n. 5
0
 private void handleMessage(MessageArgs message, ITypeCache cache, Editor editor)
 {
     if (message.Message == "gototype")
         goToType(cache, editor);
     if (message.Message == "explore")
         explore(cache, editor);
     if (message.Message.StartsWith("snippet-complete "))
         snippetComplete(message, editor);
     if (message.Message.StartsWith("snippet-create "))
         snippetCreate(message, editor);
     if (message.Message.StartsWith("member-lookup "))
         memberLookup(message, editor);
 }
Esempio n. 6
0
 private void snippetCreate(MessageArgs message, Editor editor)
 {
     var command = "snippet-create ";
             var msg = message.Message
                 .Substring(command.Length, message.Message.Length - command.Length);
             new CreateSnippetHandler(editor, _cacheBuilder, Environment.CurrentDirectory)
                 .Handle(
                     new CommandStringParser()
                         .Parse(msg).ToArray());
 }
Esempio n. 7
0
 private void memberLookup(MessageArgs message, Editor editor)
 {
     _ctx.Post((s) =>
         {
             var members = new string[]
                 {
                     "Text|Type: System.Int",
                     "Visible|Type: System.bool",
                     "BringToFront|Return Type: void",
                     "Parse(string[], bool)|Return Type: string[[newline]]\tstring[]: Line Array[[newline]]\tbool: Remove Empty entries"
                 };
             _memberLookup = new MemberLookupForm(members);
             _memberLookup.Show(this);
             setToForeground(_memberLookup);
         }, null);
 }
 public CompleteSnippetHandler(Editor editor, ICacheBuilder cache, string keyPath)
 {
     _editor = editor;
     _cache = cache;
     _keyPath = keyPath;
 }
Esempio n. 9
0
 private static void messageHandler(MessageArgs message, ITypeCache cache, Editor editor)
 {
     var msg = CommandMessage.New(message.Message);
     _handlers
         .Where(x => x.Handles(msg)).ToList()
         .ForEach(x => x.Handle(message.ClientID, msg));
 }
Esempio n. 10
0
 private void goToType(ITypeCache cache, Editor editor)
 {
     Logger.Write("Preparing to open type search");
     _ctx.Post((s) =>
         {
             Logger.Write("Opening type search");
             try {
                 if (_gotoType == null || !_gotoType.Visible)
                 {
                     Logger.Write("Creating typesearch form");
                     _gotoType = new TypeSearchForm(
                         cache,
                         (file, line, column) => { editor.GoTo(file, line, column); },
                         () => { new System.Threading.Thread(() => { System.Threading.Thread.Sleep(1000); editor.SetFocus(); }).Start(); });
                     _gotoType.Show(this);
                 }
                 setToForeground(_gotoType);
             } catch (Exception ex) {
                 Logger.Write(ex);
             }
         }, null);
 }
Esempio n. 11
0
 private void userSelect(MessageArgs message, Editor editor)
 {
     var state = new ConfigReader(_endpoint.Token).Get("oi.userselect.ui.fallback");
     if (state == "disabled")
         return;
     _ctx.Post((s) =>
         {
             try {
                 var args = new CommandStringParser().Parse(message.Message).ToArray();
                 var items = new List<string>();
                 var keys = new List<string>();
                 foreach (var item in args[3].Split(new[] {','})) {
                     var chunks = item.Split(new[] {"||"}, StringSplitOptions.None);
                     if (chunks.Length > 1) {
                         keys.Add(chunks[0]);
                         items.Add(chunks[1]);
                     } else {
                         keys.Add(item);
                         items.Add(item);
                     }
                 }
                 var command = "user-selected";
                 if (message.Message.StartsWith("user-select-at-caret "))
                     command = "user-selected-at-caret";
                 var form = new UserSelectForm(items, keys, (item) => {
                     if (item != null)
                         _endpoint.PublishEvent(command+" '" + args[2] + "' '"  + item + "'");
                     else
                         _endpoint.PublishEvent(command+" '" + args[2] + "' 'user-cancelled'");
                     editor.SetFocus();
                 });
                 form.Show(this);
                 setToForeground(form);
             } catch {
             }
         }, null);
 }
Esempio n. 12
0
 private void userInput(MessageArgs message, Editor editor)
 {
     Logger.Write("Getting state for userinput fallback");
     var state = new ConfigReader(_endpoint.Token).Get("oi.userinput.ui.fallback");
     Logger.Write("State is "+state);
     if (state == "disabled")
         return;
     _ctx.Post((s) =>
         {
             Logger.Write("Launching user input form");
             try {
                 var args = new CommandStringParser().Parse(message.Message).ToArray();
                 var defaultValue = "";
                 if (args.Length > 3)
                     defaultValue = args[3];
                 var form = new UserInputForm(defaultValue, (item) => {
                     if (item != null)
                         _endpoint.PublishEvent("user-inputted '" + args[2] + "' '"  + item + "'");
                     else
                         _endpoint.PublishEvent("user-inputted '" + args[2] + "' 'user-cancelled'");
                     editor.SetFocus();
                 });
                 form.Show(this);
                 setToForeground(form);
             } catch (Exception ex) {
                 Logger.Write(ex);
             }
         }, null);
 }
Esempio n. 13
0
 private void snippetComplete(MessageArgs message, Editor editor)
 {
     _ctx.Post((s) =>
         {
             var command = "snippet-complete ";
             var msg = message.Message.Substring(command.Length, message.Message.Length - command.Length);
             new CompleteSnippetHandler(_cacheBuilder, _endpoint.Token, _endpoint)
                 .Handle(
                     new CommandStringParser()
                         .Parse(msg).ToArray());
         }, null);
 }
Esempio n. 14
0
 private void handleMessage(MessageArgs message, ITypeCache cache, Editor editor)
 {
     Logger.Write("Message trayform args: " + message.Message);
     if (message.Message == "gototype")
         goToType(cache, editor);
     if (message.Message == "explore")
         explore(cache, editor);
     if (message.Message.StartsWith("snippet-complete "))
         snippetComplete(message, editor);
     if (message.Message.StartsWith("snippet-create "))
         snippetCreate(message, editor);
     if (message.Message.StartsWith("member-lookup "))
         memberLookup(message, editor);
     if (message.Message.StartsWith("user-select \"unsupported\" "))
         userSelect(message, editor);
     if (message.Message.StartsWith("user-select-at-caret \"unsupported\" "))
         userSelect(message, editor);
     if (message.Message.StartsWith("user-input \"unsupported\" "))
         userInput(message, editor);
     if (message.Message == "shutdown")
         _terminateApplication = true;
 }