Reputation: 243
I'm trying to create a script using lua in hammpersppon. Where pressing "x" will give the user option to paste the kind of template that they want to paste into a text field in web.
Unfortunately, I am not able to figure out how to format that text as tables ( with rows and columns)?
I tried pasting the table from google sheet (excel) into lua code but still, it doesn't render it as a table in the text field.
-- Focus the last used window.
local function focusLastFocused()
local wf = hs.window.filter
local lastFocused = wf.defaultCurrentSpace:getWindows(wf.sortByFocusedLast)
if #lastFocused > 0 then lastFocused[1]:focus() end
end
-- On selection, copy the text and type it into the focused application.
local chooser = hs.chooser.new(function(choice)
if not choice then focusLastFocused(); return end
hs.pasteboard.setContents(choice["subText"])
focusLastFocused()
hs.eventtap.keyStrokes(hs.pasteboard.getContents())
end)
chooser:choices({
{
["text"] = "Option 1",
["subText"] = [[ Text 1 Text 2
Text 3 Text 4]]
},
{
["text"] = "Option 2",
["subText"] = [[ Text 1 Text 2
Text 3 Text 4]]
},
})
hs.hotkey.bind({"X"}, "X", function() chooser:show() end)
Upvotes: 2
Views: 701