File: mouse_query.py

package info (click to toggle)
python-blessed 1.25-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 8,812 kB
  • sloc: python: 14,645; makefile: 13; sh: 7
file content (15 lines) | stat: -rwxr-xr-x 600 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#!/usr/bin/env python3
from blessed import Terminal

term = Terminal()

# check basic mouse support
if not term.does_mouse():
    print(f"mouse_enabled() {term.bright_red('not supported')} on this Terminal")
else:
    # check for, enable, and report all supported advanced features
    feature_kwargs = {mouse_feature: True
                      for mouse_feature in ('report_pixels', 'report_drag', 'report_motion')
                      if term.does_mouse(**{mouse_feature: True})}
    with term.mouse_enabled(**feature_kwargs):
        print(f"mouse_enabled({', '.join(feature_kwargs)}) enabled")