GithubHelp home page GithubHelp logo

Comments (5)

mikelorant avatar mikelorant commented on May 27, 2024

See pull request #441 for the fix to both these issues.

The correct output displayed in the screenshot section is the result from the fixed branch.

from vhs.

mikelorant avatar mikelorant commented on May 27, 2024

@maaslalani Are you able to verify this issue exists for you as well?

from vhs.

mikelorant avatar mikelorant commented on May 27, 2024

@maaslalani You probably missed this issue with the flurry of issues and pull requests I have been creating.

Can we verify this issue is reproducible and check that the pull request does fix the issue?

from vhs.

mikelorant avatar mikelorant commented on May 27, 2024

I am basing alt on what Bubbletea defines it as. This might need a lot more thinking about how we handle this.

from vhs.

mikelorant avatar mikelorant commented on May 27, 2024

Definition

I think it is important to firstly clarify what the alt key means.

For me, on a Mac, I am pressing the option key which has been configured by iTerm2 to send Esc+.

We need to remove what terminal and OS (and even keyboard) is being used and just look at it as messages. What really matters is what alt means in the Charm ecosystem. If I build a Bubbletea app that does an action when pressing alt, I should expect something to happen.

Therefore, let's base the answer on what tea.KeyMsg sees.

Testing

So we need two parts to prove this.

  1. Bubbletea application that responds to alt key presses.
  2. VHS tape that sends this key press.

Application

The following code is a short Bubbletea application that responds to alt + s. Using the string key message means we can be sure we are handling the exact case we are targeting.

package main

import (
	"fmt"

	tea "github.com/charmbracelet/bubbletea"
)

type Model struct {
	state bool
	text string
}

func main() {
	p := tea.NewProgram(Model{
		state: false,
		text: "disabled",
	})
	if _, err := p.Run(); err != nil {
		panic(err)
	}
}

func (m Model) Init() tea.Cmd {
	return nil
}

func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
	switch msg := msg.(type) {
	case tea.KeyMsg:
		switch msg.String() {
		case "alt+s":
			switch m.state {
			case true:
				m.text = "disabled"
				m.state = false
			default:
				m.text = "enabled"
				m.state = true
			}
		case "ctrl+c", "q":
			return m, tea.Quit
		}
	}

	return m, nil
}

func (m Model) View() string {
	return fmt.Sprintf("Press Alt+S to toggle state\nState: %v\n", m.text)
}

Tape

Now lets add a VHS tape that will run this app and send the alt + s key a few times. Recommending doing a go run . before using this script to make sure it starts quickly and doesn't miss the alt + s key presses.

Output alts.gif
Type "go run ."
Enter
Sleep 1s
Alt+S
Sleep 1s
Alt+S
Sleep 1s
Ctrl+C
Ctrl+D

Results

All that was needed was to now run VHS on this tape:

vhs alts.tape

VHS stable release

I have used the current release provided by Homebrew. Reported version is:

❯ vhs --version
vhs version v0.7.1 (537d03a)

vhs-alts-stable

As you can see, nothing happens.

VHS branch fix/alt

This is using the code I have provided in pull request #441.

vhs-alts-branch-fix-alt

This shows the text message toggles.

Outcome

Based on these results I conclude that the current VHS implementation sending some alt key presses isn't working as expected.

@maaslalani Let me know if there is any further details you need me to provide so we can understand what the correct solution is.

from vhs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.