diff --git a/config/absytree_config_wasm.wasm b/config/absytree_config_wasm.wasm index 20946e0c..aacf45b3 100755 Binary files a/config/absytree_config_wasm.wasm and b/config/absytree_config_wasm.wasm differ diff --git a/config/default_config.nim b/config/default_config.nim index 17803a4c..f9026dbc 100644 --- a/config/default_config.nim +++ b/config/default_config.nim @@ -215,7 +215,8 @@ proc loadDefaultKeybindings*(clearExisting: bool = false) = addCommand "popup.selector", "", "next" addCommand "popup.selector", "", "prev-x" addCommand "popup.selector", "", "next-x" - addCommand "popup.selector", "", "send-to-location-list" + addCommandBlock "popup.selector", "": + setLocationListFromCurrentPopup() addCommand "editor", "", "goto-prev-location" addCommand "editor", "", "goto-next-location" diff --git a/scripting/editor_api_wasm.nim b/scripting/editor_api_wasm.nim index 60413b77..aa923207 100644 --- a/scripting/editor_api_wasm.nim +++ b/scripting/editor_api_wasm.nim @@ -4,6 +4,15 @@ import scripting_api, misc/myjsonutils ## This file is auto generated, don't modify. +proc editor_setLocationListFromCurrentPopup_void_App_wasm(arg: cstring): cstring {. + importc.} +proc setLocationListFromCurrentPopup*() = + var argsJson = newJArray() + let argsJsonString = $argsJson + let res {.used.} = editor_setLocationListFromCurrentPopup_void_App_wasm( + argsJsonString.cstring) + + proc editor_getBackend_Backend_App_wasm(arg: cstring): cstring {.importc.} proc getBackend*(): Backend = var argsJson = newJArray() diff --git a/src/app.nim b/src/app.nim index eadce359..6bd48bc0 100644 --- a/src/app.nim +++ b/src/app.nim @@ -232,6 +232,7 @@ proc openSymbolsPopup*(self: App, symbols: seq[Symbol], handleItemSelected: proc proc help*(self: App, about: string = "") proc getAllDocuments*(self: App): seq[Document] proc setHandleInputs*(self: App, context: string, value: bool) +proc setLocationList*(self: App, list: seq[SelectorItem]) implTrait AppInterface, App: proc platform*(self: App): Platform = self.platform @@ -262,6 +263,7 @@ implTrait AppInterface, App: popPopup(void, App, Popup) openSymbolsPopup(void, App, seq[Symbol], proc(symbol: Symbol), proc(symbol: Symbol), proc()) getAllDocuments(seq[Document], App) + setLocationList(void, App, seq[SelectorItem]) type AppLogger* = ref object of Logger @@ -1087,6 +1089,22 @@ proc getEditor(): Option[App] = static: addInjector(App, getEditor) +proc setLocationListFromCurrentPopup*(self: App) {.expose("editor").} = + if self.popups.len == 0: + return + + let popup = block: + let popup = self.popups[self.popups.high] + if not (popup of SelectorPopup): + log lvlError, &"Not a selector popup" + return + popup.SelectorPopup + + if popup.textEditor.isNil or popup.completions.len == 0: + return + + self.setLocationList(popup.completions) + proc getBackend*(self: App): Backend {.expose("editor").} = return self.backend diff --git a/src/app_interface.nim b/src/app_interface.nim index 236a7a17..be5860ca 100644 --- a/src/app_interface.nim +++ b/src/app_interface.nim @@ -26,6 +26,7 @@ traitRef AppInterface: method getEditorForId*(self: AppInterface, id: EditorId): Option[DocumentEditor] method getPopupForId*(self: AppInterface, id: EditorId): Option[Popup] method createSelectorPopup*(self: AppInterface): Popup + method setLocationList*(self: AppInterface, list: seq[SelectorItem]) method pushSelectorPopup*(self: AppInterface, popup: SelectorPopupBuilder): ISelectorPopup method pushPopup*(self: AppInterface, popup: Popup) method popPopup*(self: AppInterface, popup: Popup)