11package vscextension
22
3- import scala .concurrent .ExecutionContext .Implicits .global
43import scala .scalajs .js
54import scala .scalajs .js .JSConverters ._
65
76import typings .vscode .mod as vscode
87
9- import facade .vscodeUtils .*
10- import functorcoder .actions .Commands
118
129/** Show a quick pick palette to select items in multiple steps
1310 *
@@ -56,30 +53,35 @@ object quickPick {
5653 }
5754
5855 def showQuickPick (arg : Any ): Unit = {
59- val items =
60- Commands .mainMenuItems.map(_._1).toJSArray
56+ val mMenu = functorcoder.editorUI.menu.myMenu
6157
6258 val quickPick : vscode.QuickPick [vscode.QuickPickItem ] =
6359 vscode.window.createQuickPick()
6460
65- quickPick.title = " Quick Pick "
66- quickPick.placeholder = " pick one item "
67- quickPick.totalSteps = 3
61+ quickPick.title = mMenu.title
62+ quickPick.placeholder = " select an action "
63+ // quickPick.totalSteps = 3
6864 quickPick.buttons = js.Array (vscode.QuickInputButtons .Back )
6965
70- // option items for user to pick
71- quickPick.items = items .map { itemStr => //
66+ // set the items in the quick pick
67+ quickPick.items = mMenu.menuItems.map(_._1).toJSArray .map { itemStr => //
7268 vscode
73- .QuickPickItem (itemStr)
74- .setAlwaysShow(true )
75- .setButtons(js.Array (vscode.QuickInputButtons .Back ))
76- .setDescription(itemStr + " description " )
77- .setDetail(itemStr + " detail" )
69+ .QuickPickItem (itemStr) // label is itemStr
70+ // .setAlwaysShow(true)
71+ // .setButtons(js.Array(vscode.QuickInputButtons.Back))
72+ .setDescription(itemStr)
73+ // .setDetail(itemStr + " detail")
7874 }
7975
8076 quickPick.onDidChangeSelection { selection =>
81- println(s " selected: ${selection(0 ).label}" )
82- if (selection(0 ).label == " item1" ) {
77+ val selectedLabel = selection(0 ).label
78+ // execute the function associated with the selected item
79+ mMenu.menuItems.find(_._1 == selectedLabel).foreach { (_, fun) =>
80+ fun()
81+ quickPick.hide()
82+ }
83+
84+ /* if (selection(0).label == "item1") {
8385 println(s"selected: ${selection(0).label}")
8486
8587 // show another input box after selecting item1
@@ -93,7 +95,8 @@ object quickPick {
9395 showMessage("input: " + input)
9496 }
9597
96- }
98+ } */
99+
97100 }
98101
99102 quickPick.onDidHide({ _ =>
0 commit comments