Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance parameter selection #162

Closed
wants to merge 7 commits into from
Closed

Conversation

ofey404
Copy link
Contributor

@ofey404 ofey404 commented Mar 18, 2021

Issue #, if available:

Description of changes:

Add a keyboard shortcut ^U to clear selected parameter in parameter expanding view. Useful when you set a default value, but don't like it. You can quickly kill it and replace with things you like.

Also simplified title of each parameter view.

For example, a parameter like <Name=DefaultValue>

  • Old title: Name=DefaultValue
  • New title: Name

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@ofey404 ofey404 closed this Mar 18, 2021
@ofey404 ofey404 reopened this Mar 18, 2021
@RamiAwar
Copy link
Collaborator

RamiAwar commented Jan 30, 2024

I think the real issue behind this is the fact that you can't use typical text editing commands like:
Ctrl+Backspace to delete everything until beginning of line
Alt+Arrows to jump words

etc.

I also believe gocui supports creating a custom 'editor', something like this, which we could then use to add these natural text editing shortcuts and fix this issue and more!

Will add this to the backlog with medium prio

func simpleEditor(v *gocui.View, key gocui.Key, ch rune, mod gocui.Modifier) {
	var tab = false
	var inHistroy = false

	switch {
	case key == gocui.KeyTab:
		tab = true
	case ch != 0 && mod == 0:
		v.EditWrite(ch)
	case key == gocui.KeySpace:
		v.EditWrite(' ')
	case key == gocui.KeyBackspace || key == gocui.KeyBackspace2:
		v.EditDelete(true)
	case key == gocui.KeyDelete:
		v.EditDelete(false)
	case key == gocui.KeyInsert:
		v.Overwrite = !v.Overwrite
	case key == gocui.KeyEnter:

		if line := v.ViewBuffer(); len(line) > 0 {
			GetLine(Server.Gui, v)
		} else {
			if c, err := Server.Gui.View(Server.CurrentChannel); err == nil {
				c.Autoscroll = true
			}
		}

		InputHistory.Current()

		// v.EditNewLine()
		// v.Rewind()

	// case key == gocui.MouseMiddle:
	// nextView(Server.Gui, v)
	// case key == gocui.MouseRight:

	case key == gocui.KeyArrowDown:
		inHistroy = true

		if line := InputHistory.Next(); len(line) > 0 {
			v.Clear()
			v.SetCursor(0, 0)
			v.SetOrigin(0, 0)

			fmt.Fprint(v, line)
			v.SetCursor(len(v.Buffer())-1, 0)
		}
	...
}

This ends up being a lot less code and more explicit in terms of what it's doing imo!

#249

I'll probably pick this up a bit later, so let me know if you're interested in doing it instead 😏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants