Converted scripting language Tamarin to Risor (#55)
- Converted Tamarin script language to Risor - Added a "find" and "merge" method to the result set script type. - Added the ability to copy the table of results to the pasteboard by pressing C - Added the -q flag, which will run a query and display the results as a CSV file on the command line - Upgraded Go to 1.21 in Github actions - Fix issue with missing limits - Added the '-where' switch to the mark - Added the 'marked' function to the query expression. - Added a sampled time and count on the right-side of the mode line - Added the 'M' key binding to toggle the marked items - Started working on tab completion for 'sa' and 'da' commands - Added count and sample time to the right-side of the mode line - Added Ctrl+V to the prompt to paste the text of the pasteboard with all whitespace characters trimmed - Fixed failing unit tests
This commit is contained in:
parent
ed53173a1d
commit
7ca0cf6982
54 changed files with 1227 additions and 281 deletions
|
|
@ -18,9 +18,10 @@ import (
|
|||
const commandsCategory = "commands"
|
||||
|
||||
type CommandController struct {
|
||||
historyProvider IterProvider
|
||||
commandList *CommandList
|
||||
lookupExtensions []CommandLookupExtension
|
||||
historyProvider IterProvider
|
||||
commandList *CommandList
|
||||
lookupExtensions []CommandLookupExtension
|
||||
completionProvider CommandCompletionProvider
|
||||
}
|
||||
|
||||
func NewCommandController(historyProvider IterProvider) *CommandController {
|
||||
|
|
@ -40,6 +41,10 @@ func (c *CommandController) AddCommandLookupExtension(ext CommandLookupExtension
|
|||
c.lookupExtensions = append(c.lookupExtensions, ext)
|
||||
}
|
||||
|
||||
func (c *CommandController) SetCommandCompletionProvider(provider CommandCompletionProvider) {
|
||||
c.completionProvider = provider
|
||||
}
|
||||
|
||||
func (c *CommandController) Prompt() tea.Msg {
|
||||
return events.PromptForInputMsg{
|
||||
Prompt: ":",
|
||||
|
|
@ -47,6 +52,24 @@ func (c *CommandController) Prompt() tea.Msg {
|
|||
OnDone: func(value string) tea.Msg {
|
||||
return c.Execute(value)
|
||||
},
|
||||
// TEMP
|
||||
OnTabComplete: func(value string) (string, bool) {
|
||||
if c.completionProvider == nil {
|
||||
return "", false
|
||||
}
|
||||
|
||||
if strings.HasPrefix(value, "sa ") || strings.HasPrefix(value, "da ") {
|
||||
tokens := shellwords.Split(strings.TrimSpace(value))
|
||||
lastToken := tokens[len(tokens)-1]
|
||||
|
||||
options := c.completionProvider.AttributesWithPrefix(lastToken)
|
||||
if len(options) == 1 {
|
||||
return value[:len(value)-len(lastToken)] + options[0], true
|
||||
}
|
||||
}
|
||||
return "", false
|
||||
},
|
||||
// END TEMP
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -19,3 +19,7 @@ type CommandList struct {
|
|||
type CommandLookupExtension interface {
|
||||
LookupCommand(name string) Command
|
||||
}
|
||||
|
||||
type CommandCompletionProvider interface {
|
||||
AttributesWithPrefix(prefix string) []string
|
||||
}
|
||||
|
|
|
|||
|
|
@ -54,3 +54,8 @@ type MessageWithMode interface {
|
|||
MessageWithStatus
|
||||
ModeMessage() string
|
||||
}
|
||||
|
||||
type MessageWithRightMode interface {
|
||||
MessageWithStatus
|
||||
RightModeMessage() string
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,8 +21,9 @@ type ModeMessage string
|
|||
|
||||
// PromptForInput indicates that the context is requesting a line of input
|
||||
type PromptForInputMsg struct {
|
||||
Prompt string
|
||||
History services.HistoryProvider
|
||||
OnDone func(value string) tea.Msg
|
||||
OnCancel func() tea.Msg
|
||||
Prompt string
|
||||
History services.HistoryProvider
|
||||
OnDone func(value string) tea.Msg
|
||||
OnCancel func() tea.Msg
|
||||
OnTabComplete func(value string) (string, bool)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue