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

Problem when Input PF Key #1

Open
iskandarzun opened this issue Dec 9, 2019 · 1 comment
Open

Problem when Input PF Key #1

iskandarzun opened this issue Dec 9, 2019 · 1 comment
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@iskandarzun
Copy link

Hi,
First thing is thanks for cool packages to utilize x3270, I'm using it a lot you know because work related

The problem is, it looks like we can't send F1-F12 key function because validaKeyboard() function always return false in case we send F1-F12 key even it's provided in constant variables causing all variables apart from Enter and Tab useless.

// These constants represent the keyboard keys
const (
	Enter = "Enter"
	Tab   = "Tab"
	F1    = "PF(1)"
	F2    = "PF(2)"
	F3    = "PF(3)"
	F4    = "PF(4)"
	F5    = "PF(5)"
	F6    = "PF(6)"
	F7    = "PF(7)"
	F8    = "PF(8)"
	F9    = "PF(9)"
	F10   = "PF(10)"
	F11   = "PF(11)"
	F12   = "PF(12)"
)

......

//Press press a keyboard key
func (e *Emulator) Press(key string) error {
	if !e.validaKeyboard(key) {
		return fmt.Errorf("invalid key %s", key)
	}
	return e.execCommand(key)
}

//validaKeyboard valid if key passed by parameter if a key valid
func (e *Emulator) validaKeyboard(key string) bool {
	switch key {
	case Tab:
		return true
	case Enter:
		return true
	default:
		return false
	}
}

Should be checked whether it's key command function or not and send command below for example :
x3270if -t e.ScriptPort PF(1)

Maybe adding more function for PF key or just checking input in press() will solve the problem.

Thanks.

@mattheusv
Copy link
Owner

Sorry for delay...It's really nice to see that this package have been used.
Now, about the issue, implementation seems simple. Could you send a PR with fix?

@mattheusv mattheusv added bug Something isn't working good first issue Good for newcomers labels Jan 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants