chjj / blessed

A high-level terminal interface library for node.js.
Other
11.31k stars 535 forks source link

Mouse listening interferes with `screen.exec` #358

Open gjuchault opened 6 years ago

gjuchault commented 6 years ago

Hello,

If one of the component has mouse supports, it calls screen._listenMouse, which register events on mouse actions. Theses are not cleared before screen.exec, which results in characters being written in the executed.

Example: if you press b to get the bash input and try scrolling or moving the mouse, the bash input will be filled with characters.

const blessed = require('blessed')

const screen = blessed.screen({
  autoPadding: true,
  smartCSR: true,
  title: 'kitermatic'
})

const box = blessed.box({
  content: 'hello'.repeat(30),
  scrollable: true,
  mouse: true,
  top: '0%+5',
  left: '30%',
  height: '20%',
  interactive: true,
  alwaysScroll: true,
  width: '30%',
  border: { type: 'line' },
  onClick() {
    screen.exec('bash')
  }
})

screen.append(box)

screen.key('b', () => screen.exec('bash'))

screen.key(['escape', 'q', 'C-c'], () => process.exit(0))

screen.render()
Bacto commented 1 month ago

Hi,

Go the same problem. I found a hack by disabling the mouse before running the exec or spawn command and reenable it after. This the default behaviour I expected from "exec".

screen.program.clear();
screen.program.disableMouse();
screen.program.showCursor();

// run exec here

screen.program.enableMouse();
screen.program.hideCursor();
screen.render();