Giter Site home page Giter Site logo

ansi-term's People

Contributors

abhinav avatar data-man avatar dependabot[bot] avatar ethanholz avatar joachimschmidt557 avatar lordmzte avatar mattnite avatar zanovelloalberto avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

ansi-term's Issues

Proposal: Add Color.Default

Right now, a Style has a foreground color and a background color, which are both of type ?Color. In my view, this is supposed to represent that a style does not have a foreground or background color, but I think it may be useful to think about changing this.

Proposal: A Style should represent a complete style which can be drawn onto an ANSI terminal, meaning it is mandatory to specify foreground and background color for a style. But what if an application using this library wants to specify just bold text? Then it can use Color.Default, a new "pseudo"-color. This also makes everything more explicit and transparent.

Previously, if a Style containing only FontStyle.bold and null for foreground and background was applied to a terminal which already had red background applied to it, applying the new style would have a different effect than if the terminal previously had blue background (red and bold vs blue and bold). With the proposed change, programmers apply a Style and can be 100% sure that this specific style is now active on the terminal.

Example of Color.Default: If the terminal currently has red foreground color and the new Style has Color.Default foreground color, the ANSI Reset CSI is written.

custom `format` function

Do you think it would make sense to include a format function, so that Styles can be printed directly?

I added this,

pub fn format(value: Self, comptime _: []const u8, _: std.fmt.FormatOptions, writer: anytype) std.os.WriteError!void {
    try @import("format.zig").updateStyle(writer, value, null);
}

while porting a program away from a different lib, where I had added something similar, and it made the port easy, if suboptimal.

And another thing, when you don't want the cursor to be misplaced, you need yet more escape codes around the bytes that aren't displayed. Currently I have a wrapping writer that adds them as neccessary, but maybe that should be part of the lib in some way?

Would be happy to send patches for those things.

Add ANSI terminal "mocking"

I think it would be nice to include a terminal emulator (basically an interpreter for ANSI escape sequences) in this repository as well. Something along the lines of https://github.com/selectel/pyte for example.

This would enable testing zig libraries and applications which use ANSI escape sequences for correct display without requiring a "real" terminal emulator like xterm and manually checking the output. Maybe this can even help in developing "real" full-featured terminal emulators.

missing cursor modes

it seem missing the cursor mode (e.g. blinking, underscore, solid state... )
most of terminal emulator seem support it:

whit N that is 1...6
echo -en "\e[N q"

API ideas

  • implement format fn for Color and FontStyle types
  • with custom specifiers:
    if specifier is empty then write CSI-sequence
    bg & fg specifiers for Color type: treat value as background & foreground respectively
    np: don't write CSI prefix for intelligent updates

As result:

   debug.print("{fg} FG red {bg} BG green {} default", { .Red, .Green, .Reset });

Add package file

Add a single file that can be added as a package so people can easily use this library

fails to build on latest zig version

The current build.zig fails to build on the latest version of zig due to std.build no longer existing.

/home/hanna/.cache/zig/p/122007393793c7f8e875d4b7c6f8b80ffff936c43a5ed0f21e111574b7ad9b20f897/build.zig:1:31: error: root struct of file 'std' has no member named 'build'
const Builder = @import("std").build.Builder;
                ~~~~~~~~~~~~~~^~~~~~
/nix/store/h4y9hqs666rgcq2b0g3zmws05ifs28m8-zig-0.12.0-dev.2139+e025ad7b4/lib/std/std.zig:1:1: note: struct declared here
pub const ArrayHashMap = array_hash_map.ArrayHashMap;
^~~
referenced by:
    build: /home/hanna/.cache/zig/p/122007393793c7f8e875d4b7c6f8b80ffff936c43a5ed0f21e111574b7ad9b20f897/build.zig:3:18
    runBuild__anon_15827: /nix/store/h4y9hqs666rgcq2b0g3zmws05ifs28m8-zig-0.12.0-dev.2139+e025ad7b4/lib/std/Build.zig:1857:50
    remaining reference traces hidden; use '-freference-trace' to see all reference traces

Proposal: Use integers for FontStyle

Currently, FontStyle is represented as a (possibly packed after #5) struct of bools.

I think using integer types and bitwise operations, we could achieve better and possibly faster functionality. Consider the following simplified example:

const FontStyle = u3;

const default: FontStyle = 0b000;
const bold: FontStyle = 0b001;
const dim: FontStyle = 0b010;
const italic: FontStyle = 0b100;

Combining font styles can be done with bitwise or; checking for a style can be done with bitwise and.

cc @data-man

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.