Skip to content

Implement activate_mouse_input and suspend_mouse_input for MouseTerminal

Franco Bugnano requested to merge bugnano/termion:master into master

Fixes #200

RawTerminal has the methods suspend_raw_mode and activate_raw_mode for forcing suspending and activating of raw mode, which can be useful in some situations.

In the same situations where suspending and activating raw mode are useful, it's as useful to be able to activate and suspend mouse inputs programmatically (think for example temporarily suspending the current app with the SIGTSTP signal, and resuming it with the SIGCONT signal: it would be great to suspend the mouse input before handling SIGTSTP, and activate the mouse input when handling SIGCONT). Another useful example for wanting this is: Imagine having a TUI app that uses Termion, and temporarily executes another command line app. Before executing the other command line app, it's better to suspend the mouse input, and activate it back after the other app has completed.

This PR allows suspending and activating the mouse input in 2 ways:

  1. MouseTerminal now provides the suspend_mouse_input and activate_mouse_input methods
  2. The input module provides the StartMouseInput and StopMouseInput structs, that can be used the same way as the ToAlternateScreen and ToMainScreen structs
Edited by Franco Bugnano

Merge request reports