纯python中的终端/控制台寻呼机模块

pager的Python项目详细描述


python模块,页面输出到屏幕,读取键和 不执行外部实用程序的控制台维度。

它本应被列入标准图书馆 http://bugs.python.org/issue8408

作者:anatoly techtonik<;techtonik@gmail.com>;
许可证:公共域(如果需要许可证,则为MIT)

演示

python -m pager <file>
<command> | pager.py     (Windows only - see issue #7)
pager.py < <file>        (Windows only)

# run manual tests that are also a demo
python -m pager --test

状态

3.3(稳定)
  • 修复关键问题6:3.2在Linux上损坏,谢谢 卡尔文·斯佩尔曼(@ironfroggy)报道
  • 从stdin读取内容是windows独有的功能 目前(见第7期)
3.2(在Linux上中断)
  • 如果按Esc或“Q”键,则中止分页
  • 提示回调现在可以通过 返回false
3.1(在Linux上中断)
  • 支持管道输入(在Windows上测试)
3.0(alpha)-函数getch中的api中断
  • 在2.0中还原的getch()行为已更改-现在 getch()再次返回单个字符
  • 为getch()键添加下划线的新常量
  • 始终返回list的新getchars()函数
2.2(稳定)
  • Linux:修复版本2.1中的回归-的错误名称 _在此平台上获取Unix调用生成的名称错误 (第6期,感谢Calvin Spealman的报道)
2.1(在Linux上中断)
  • 将getch()拆分为getch_unix()和getch_windows() 并在导入时检测正确的味道(加速)
2.0(稳定)-getch()函数中的API中断
  • getch()现在总是返回字符列表 (以前它可以返回单个字符)。完成了 简化从 返回结果
1.4(稳定)
  • pager.py<;文件>;
  • Linux:termios注释、文档和 getch()函数中可能出现api中断
1.3(稳定)
  • Windows:Python3需要getwch()
  • windows:fix输入左上右下esc键代码
1.2(稳定)
  • 为输入左上右下Esc键添加名称
  • getch()的手动测试(修复错误4)
  • dumpkey()helper函数获取值的十六进制转储 由getch()返回
1.1(稳定)
  • python 3兼容性
  • 无缓冲输出的echo()助手函数(在py3中 输出不会立即出现在屏幕上,除非它 以换行符结尾)
1.0(稳定)
  • getch()现在返回特殊键的字符列表 (修复了特殊键跳过几页时出现的错误1)
  • page()回调接收必需的pageNumber参数
  • default page()callback现在显示页码
0.2(稳定)
  • 不要在页面之间插入空行
0.1(稳定)
  • 逐页显示内容
  • 允许获取控制台/终端尺寸
  • 在Windows上工作
  • 在Linux上工作

API(输出)

。函数:page(content,[pagecallback=prompt])

Output content iterable, calling pagecallback function after each page with page number as a parameter. pagecallback function may return False to terminate pagination.

Default prompt() callback shows page number with ‘Press any key to continue … ‘ prompt, waits for keypress and aborts if ‘q’, ESC or Ctrl-C are pressed.

。函数:echo(msg)

Print msg to the screen without linefeed and flush the output.

。函数:getwidth()

Return width of available window in characters. If detection fails, return value of standard width 80. Coordinate of the last character on a line is -1 from returned value.

。函数:getheight()

Return available window height in characters or 25 if detection fails. Coordinate of the last line is -1 from returned value.

API(输入)

。函数:getch()

Wait for keypress, return first char generated as a result.

Arrows and special keys generate sequence of chars. Use getchars function to receive all chars generated or present in buffer.

。函数:getchars()

Wait for keypress. Return list of chars generated as a result. More than one char in result list is returned when arrows and special keys are pressed. Returned sequences differ between platforms, so use constants defined in this module to guess correct keys.

。函数:dumpkey(key)

Helper to convert result of getch (string) or getchars (list) to hex string.

学分

danny yoo for getch()-类似于无缓冲字符读取配方
Calvin Spealman(@ironfroggy),第6期

参考文献

Adrian Worley为win32控制台提供的优秀教程
由william mcsleen维护的公共域诅咒库
ioctl(输入/输出控制)维基百科简介
Linux程序员手册-终端和串行线的ioctls

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
默认情况下,JavaApachePOI锁定所有单元格。如何使所有单元格解锁?   java Play框架:为什么https url在使用“sbt dist”命令时不起作用?   ldap查询搜索筛选器中“&”的java意义   java构造不带警告的ImmutableSortedSet   用户界面Java GUI图形有多高效?   java在整个应用程序中使用相同的数据还是复制它?   java如何为所有打开的文档应用插入键操作   java存储setter方法的路径,以便以后可以调用它   java加载具有相同密钥的外部属性文件   Java通过inputmap跟踪击键   Java SSLSocket错误:无法从非静态上下文引用   java访问名为的文件的正确方式   java左括号打印在后缀中&右括号错误   java在循环中对齐数字列