All Projects → zachariahreed → Pyterminfo

zachariahreed / Pyterminfo

Licence: other
A terminfo-to-python cross compiler

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Pyterminfo

Sultan
Sultan: Command and Rule over your Shell
Stars: ✭ 625 (+12400%)
Mutual labels:  terminal, compiler
Seeless
C IDE for iOS
Stars: ✭ 71 (+1320%)
Mutual labels:  terminal, compiler
Qr Filetransfer
Transfer files over WiFi between your computer and your smartphone from the terminal
Stars: ✭ 738 (+14660%)
Mutual labels:  terminal
Typescripttolua
Typescript to lua transpiler. https://typescripttolua.github.io/
Stars: ✭ 783 (+15560%)
Mutual labels:  compiler
J2cl
Java to Closure JavaScript transpiler
Stars: ✭ 773 (+15360%)
Mutual labels:  compiler
Imgp
📸 High-performance cli batch image resizer and rotator
Stars: ✭ 744 (+14780%)
Mutual labels:  terminal
Numba
NumPy aware dynamic Python compiler using LLVM
Stars: ✭ 7,090 (+141700%)
Mutual labels:  compiler
Unicodeplots.jl
Unicode-based scientific plotting for working in the terminal
Stars: ✭ 724 (+14380%)
Mutual labels:  terminal
Tvm
Open deep learning compiler stack for cpu, gpu and specialized accelerators
Stars: ✭ 7,494 (+149780%)
Mutual labels:  compiler
Chafa
📺🗿 Terminal graphics for the 21st century.
Stars: ✭ 774 (+15380%)
Mutual labels:  terminal
Tinycc
Unofficial mirror of mob development branch
Stars: ✭ 784 (+15580%)
Mutual labels:  compiler
Pyret Lang
The Pyret language.
Stars: ✭ 771 (+15320%)
Mutual labels:  compiler
Termdown
Countdown timer and stopwatch in your terminal
Stars: ✭ 749 (+14880%)
Mutual labels:  terminal
Compiler
Compiler for Elm, a functional language for reliable webapps.
Stars: ✭ 6,672 (+133340%)
Mutual labels:  compiler
Vtil Core
Virtual-machine Translation Intermediate Language
Stars: ✭ 738 (+14660%)
Mutual labels:  compiler
Opscloud
运维管理平台(阿里云),自动同步阿里云配置信息,堡垒机(容器),批量运维,Kubernetes,Zabbix管理等功能
Stars: ✭ 788 (+15660%)
Mutual labels:  terminal
Suplemon
🍋 Console (CLI) text editor with multi cursor support. Suplemon replicates Sublime Text like functionality in the terminal. Try it out, give feedback, fork it!
Stars: ✭ 734 (+14580%)
Mutual labels:  terminal
Wezterm
A GPU-accelerated cross-platform terminal emulator and multiplexer written by @wez and implemented in Rust
Stars: ✭ 770 (+15300%)
Mutual labels:  terminal
Elm Platform
Bundle of all core development tools for Elm
Stars: ✭ 775 (+15400%)
Mutual labels:  compiler
Ergonomica
🖥️ a cross-platform modern shell.
Stars: ✭ 815 (+16200%)
Mutual labels:  terminal

pyterminfo is a parser for terminfo-style terminal descriptions. Roughly, it provides equivalent functionality of the ncurses functions tigetflag, tigetnum, tigetstr, and, tparm. The API presented is different though and hopefully more "pythonic".

An example shows basic usage:

import pyterminfo
  
# loads capabilities for $TERM
t = pyterminfo.terminfo()
    
t.os                  # a boolean capability
t.cols                # a numeric capability
t.sgr0                # a string capability
t.setaf(6)            # a parameterized-string capability
t.set_a_foreground(6) # long names work as well

By default, string capabilities are strs (or functions returning a str). While not strictly correct, it can be convenient. Passing binary=True to pyterminfo.terminfo causes string capabilities to be bytes based.

Finally, a note about pyterminfo's implementation. Typically, parameterized-string capabilities are implemented in a manner similiar to printf (parsing the format string on each invokation). Here, parameterized-string capabilities are implemented through generation of python bytecode. For example, from the capability:

setab=\E[%?%p1%{8}%<%t4%p1%d%e%p1%{16}%<%t10%p1%{8}%-%d%e48;5;%p1%d%;m,

the following is generated (in str mode):


  1           0 LOAD_CONST               0 #str.join
              3 LOAD_CONST               1 ('\x1b[')
              6 LOAD_FAST                0 (a1)
              9 LOAD_CONST               2 (8)
             12 COMPARE_OP               0 (<)
             15 POP_JUMP_IF_FALSE       33
             18 LOAD_CONST               3 ('4')
             21 LOAD_CONST               4 (<class 'str'>)
             24 LOAD_FAST                0 (a1)
             27 CALL_FUNCTION            1 (1 positional, 0 keyword pair)
             30 JUMP_FORWARD            43 (to 76)
        >>   33 LOAD_FAST                0 (a1)
             36 LOAD_CONST               5 (16)
             39 COMPARE_OP               0 (<)
             42 POP_JUMP_IF_FALSE       64
             45 LOAD_CONST               6 ('10')
             48 LOAD_CONST               4 (<class 'str'>)
             51 LOAD_FAST                0 (a1)
             54 LOAD_CONST               2 (8)
             57 BINARY_SUBTRACT
             58 CALL_FUNCTION            1 (1 positional, 0 keyword pair)
             61 JUMP_FORWARD            12 (to 76)
        >>   64 LOAD_CONST               7 ('48;5;')
             67 LOAD_CONST               4 (<class 'str'>)
             70 LOAD_FAST                0 (a1)
             73 CALL_FUNCTION            1 (1 positional, 0 keyword pair)
        >>   76 LOAD_CONST               8 ('m')
             79 BUILD_TUPLE              4
             82 CALL_FUNCTION            1 (1 positional, 0 keyword pair)
             85 RETURN_VALUE

The transformation from format string to bytecode happens in serveral stages which can be visualized by the curious. For the above, we can render:

High Level Low Level

pyterminfo depends on byteasm.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].