From ec9b0a21476e7f39a1bd35f70ad5ad0e1232d6e0 Mon Sep 17 00:00:00 2001 From: Hans-Albert Maritz Date: Sat, 14 Feb 2015 09:02:46 +1100 Subject: [PATCH] Insert completion suggestion. issue #20 --- src/dlangide/tools/d/DCDInterface.d | 3 +++ src/dlangide/ui/commands.d | 1 + src/dlangide/ui/dsourceedit.d | 6 +++++- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/dlangide/tools/d/DCDInterface.d b/src/dlangide/tools/d/DCDInterface.d index ed7df02..5fb7fc6 100644 --- a/src/dlangide/tools/d/DCDInterface.d +++ b/src/dlangide/tools/d/DCDInterface.d @@ -13,8 +13,11 @@ class DCDInterface { ProtectedTextStorage stdoutTarget = new ProtectedTextStorage(); ExternalProcess dcdProcess = new ExternalProcess(); //TODO: Working Directory, where is that? + //TODO: Inform user when dcd-client is not available. dcdProcess.run("dcd-client".dup, arguments, "/usr/bin".dup, stdoutTarget); + while(dcdProcess.poll() == ExternalProcessState.Running){ } + output = stdoutTarget.readText(); return true; } diff --git a/src/dlangide/ui/commands.d b/src/dlangide/ui/commands.d index 7ae97be..4a305e7 100644 --- a/src/dlangide/ui/commands.d +++ b/src/dlangide/ui/commands.d @@ -42,6 +42,7 @@ enum IDEActions : int { ProjectFolderRenameItem, GoToDefinition, GetCompletionSuggestions, + InsertCompletion, } const Action ACTION_PROJECT_FOLDER_ADD_ITEM = new Action(IDEActions.ProjectFolderAddItem, "MENU_PROJECT_FOLDER_ADD_ITEM"c); diff --git a/src/dlangide/ui/dsourceedit.d b/src/dlangide/ui/dsourceedit.d index fc08684..985c520 100644 --- a/src/dlangide/ui/dsourceedit.d +++ b/src/dlangide/ui/dsourceedit.d @@ -80,6 +80,10 @@ class DSourceEdit : SourceEdit { case IDEActions.FileSave: save(); return true; + case IDEActions.InsertCompletion: + EditOperation edit = new EditOperation(EditAction.Replace, getCaretPosition, a.label); + _content.performOperation(edit, this); + return true; default: break; } @@ -93,7 +97,7 @@ class DSourceEdit : SourceEdit { MenuItem completionPopupItem = new MenuItem(null); //Create popup menu foreach(int i, dstring suggestion ; suggestions) { - auto action = new Action(i+1, suggestion); + auto action = new Action(IDEActions.InsertCompletion, suggestion); completionPopupItem.add(action); } completionPopupItem.updateActionState(this);