MCPcopy
hub / github.com/di-sukharev/opencommit / onKeypress

Method onKeypress

out/cli.cjs:426–435  ·  view source on GitHub ↗
(u3, F5)

Source from the content-addressed store, hash-verified

424 this.subscribers.clear();
425 }
426 onKeypress(u3, F5) {
427 if (this.state === "error" && (this.state = "active"), F5?.name && !this._track && z3.has(F5.name) && this.emit("cursor", z3.get(F5.name)), F5?.name && lD2.has(F5.name) && this.emit("cursor", F5.name), u3 && (u3.toLowerCase() === "y" || u3.toLowerCase() === "n") && this.emit("confirm", u3.toLowerCase() === "y"), u3 === " " && this.opts.placeholder && (this.value || (this.rl.write(this.opts.placeholder), this.emit("value", this.opts.placeholder))), u3 && this.emit("key", u3.toLowerCase()), F5?.name === "return") {
428 if (this.opts.validate) {
429 const e3 = this.opts.validate(this.value);
430 e3 && (this.error = e3, this.state = "error", this.rl.write(this.value));
431 }
432 this.state !== "error" && (this.state = "submit");
433 }
434 u3 === "" && (this.state = "cancel"), (this.state === "submit" || this.state === "cancel") && this.emit("finalize"), this.render(), (this.state === "submit" || this.state === "cancel") && this.close();
435 }
436 close() {
437 this.input.unpipe(), this.input.removeListener("keypress", this.onKeypress), this.output.write(`
438`), v3(this.input, false), this.rl.close(), this.emit(`${this.state}`, this.value), this.unsubscribe();

Callers

nothing calls this directly

Calls 7

toLowerCaseMethod · 0.80
renderMethod · 0.80
hasMethod · 0.45
emitMethod · 0.45
getMethod · 0.45
writeMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected