Coder Social home page Coder Social logo

demo.tty's Introduction

demo.tty

short demo of a virtual TTY (teleprinter) device for Zig with xterm256-color support

zig run example.zig

  • intermixes string formatting with tty primitives
  • offers simple indent/dedent push/pop mechanism
  • models a set of hues independent of actual color: { hue0, hue1, hue2, info, positive, negative, caution, alert }
  • supports a few basic zig types: { [] const u8, bool, unsigned-int }
  • formatting is evolving
  • lots still to be done

screenshot of example

unstable grammer/wishlist:

format_string := <item> *
item := <text> | <maybe_replacement>
maybe_replacement := '{' '{' | '}' '}' | <replacement>
replacement := '{' [arg_index '/'] [spec] ['!' coercion] '}'
arg_index := <unsigned>
spec := bool_spec | unsigned_spec | signed_spec | float_spec | string_spec | pointer_spec
coercion := 'bool' | 'unsigned' | 'signed' | 'float' | 'string' | pointer' | 'type'

bool_spec     := [[fill] align] [width] [bool_style [bool_case]]
unsigned_spec := [[fill] align] [width] [unsigned_style ['p' | 'P'] ['\'' | '_' | ','] [['0'] iwidth]]
signed_spec   := [[fill] align] [width] [signed_style ['+'] ['p' | 'P']  ['\'' | '_' | ','] [['0'] iwidth]]
float_spec    := [[fill] align] [width] [float_style ['+'] ['p' | 'P']  ['\'' | '_' | ','] [['0'] iwidth] ['.' fwidth]]
string_spec   := [[fill] align] [width] [string_style]
pointer_spec  := [[fill] align] [width] [pointer_style ['_'] [['0'] iwidth]]
type_spec     := [[fill] align] [width] [type_style]

fill  := not ( '{' | '}' | align )
align := '<' | '>' | '^'
width := <unsigned>
 
bool_style     := 'e' | 'o' | 'p' | 't' | 'y'
bool_case      := 'c' | 'l' | 'u'
unsigned_style := 'b' | 'o' | 'd' | 'x' | 'X'
signed_style   := 'b' | 'o' | 'd' | 'x' | 'X'
float_style    := 'e' | 'E' | 'f' | 'F' | '%'
string_style   := 's'
pointer_style  := 'p' | 't' | 'x'
type_style     := TODO

bool_case := 'l', 'u', 'c'

note: positional parameters:
- fill: '*' and arg must be u8 or []const u8
- width, iwidth, fwidth: '*' and arg must be unsigned

demo.tty's People

Contributors

mikdusan avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

demo.tty's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.