Giter Site home page Giter Site logo

eraserhd / kak-ansi Goto Github PK

View Code? Open in Web Editor NEW
40.0 6.0 4.0 97 KB

Kakoune support for rendering ANSI-colored text.

Home Page: https://github.com/eraserhd/kak-ansi

License: The Unlicense

C 50.82% Shell 28.55% Nix 7.50% Makefile 0.33% KakouneScript 12.80%
kakoune plugin

kak-ansi's Introduction

kak-ansi

Kakoune support for rendering ANSI-colored text.

Installing

You’ll need a C99-compatible C compiler. The Kakoune plugin will build the filter program automatically if it’s not already built on load. If you want to build it manually instead:

$ make

Usage

This plugin provides ansi-render, ansi-render-selection, ansi-clear, ansi-enable and ansi-disable commands. In addition, when Kakoune is used as a pager, it will automatically execute ansi-enable in the *stdin* buffer to process escape codes when idle.

ansi-render

Removes ANSI escapes from the buffer and adds highlighting for regions that were ANSI-colored.

ansi-render-selection

Removes ANSI escapes from selections and adds highlighting for regions that were ANSI-colored.

ansi-clear

Clear highlighting added by the previous two commands.

ansi-enable

Configures current buffer to run ansi-render on the new data received through fifo.

ansi-disable

Disables automatic rendering of new fifo data.

Contributing

New features and bug fixes should have test coverage in tests/tests.bash where possible. Tests can be run with a modern bash:

$ bash tests/tests.bash

kak-ansi's People

Contributors

eraserhd avatar krobelus avatar seerlite avatar sidkshatriya avatar teddydd 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

kak-ansi's Issues

ansi-filter truncates files with unexpected/invalid character encoding

If I run kak < repro.txt it only reads 420 lines, even though the file has 4000 lines.

repro.txt

It looks like there is a race where both the new input and the `|%opt{ansi_filter}` want to update the buffer. Probably a bug in Kakoune?

Ok this just because the file contained invalid UTF-8.
Will try to work on a fix, or at least print a warning.

Does not work as a pager in `man`

Hi! Not sure if this is within the intended scope of the project — I'm not really familiar with the details of formatting text in terminals, but:

I've installed this plugin via plug.kak, and it seems to work well as a pager: PAGER=kak git log has colors and looks great. PAGER=kak man man however — not so much:

       man - format and display the on-line manual pages                                                                                                                                    
                                                                                                                                                                                            
S�SY�YN�NO�OP�PS�SI�IS�S                                                                                                                                                                    
       m�ma�an�n [-�-a�ac�cd�df�fF�Fh�hk�kK�Kt�tw�wW�W] [-�--�-p�pa�at�th�h] [-�-m�m _�s_�y_�s_�t_�e_�m] [-�-p�p _�s_�t_�r_�i_�n_�g] [-�-C�C _�c_�o_�n_�f_�i_�g_�__�f_�i_�l_�e] [-�-M�M     
       _�p_�a_�t_�h_�l_�i_�s_�t] [-�-P�P _�p_�a_�g_�e_�r] [-�-B�B _�b_�r_�o_�w_�s_�e_�r] [-�-H�H _�h_�t_�m_�l_�p_�a_�g_�e_�r] [-�-S�S _�s_�e_�c_�t_�i_�o_�n_�__�l_�i_�s_�t]                 
       [_�s_�e_�c_�t_�i_�o_�n] _�n_�a_�m_�e _�._�._�.                                                                                                                                       
                                                                                                                                                                                            
                                                                                                                                                                                            
D�DE�ES�SC�CR�RI�IP�PT�TI�IO�ON�N                                                                                                                                                           
       m�ma�an�n  formats  and  displays the on-line manual pages.  If you specify _�s_�e_�c_�t_�i_�o_�n, m�ma�an�n only looks in that section of the manual.  _�n_�a_�m_�e is normally the 
       name of the manual                                                                                                                                                                   
       page, which is typically the name of a command, function, or file.  However, if _�n_�a_�m_�e contains a slash (/�/) then m�ma�an�n interprets it as a file specification, so that you
                                                                                                                                                                                            
       can do m�ma�an�n .�./�/f�fo�oo�o.�.5�5 or even m�ma�an�n /�/c�cd�d/�/f�fo�oo�o/�/b�ba�ar�r.�.1�1.�.g�gz�z.                                                                           
                                                                                                                                                                                            
       See below for a description of where m�ma�an�n looks for the manual page files.                                                                                                      
                                                                                                                                                                                            
                                                                                                                                                                                            
M�MA�AN�NU�UA�AL�L S�SE�EC�CT�TI�IO�ON�NS�S                                                                                                                                                 
       The standard sections of the manual include:                                                                                                                                        
[...]

Without any styling, of course.

I've tried all combinations of ansi-enable/disable/render/clear without any changes. Am I doing something wrong?
I'm using macOS with kitty as my terminal, if that's relevant.

Output filtered text to Kakoune incrementally

I'd like to use Kakoune as a pager, but when I do git log in a repository with a long history, the processing of the ANSI sequences takes ages and I have to wait quite a long time until I see any text. Can we let the filtering program output the filtered text right away and then add highlighting later? That would make it viable to actually use Kakoune as a pager for large portions of text.

Processing large files

When I do

PAGER=kak git log

In the kakoune git repository, there is no highlighting even though the escape sequences have been deleted.
When I scroll to the bottom of the buffer, the ansi sequences are still there.
Running ansi-render manually removes the ansi sequences, but still no coloring.

It works fine for smaller git histories though.

Issue with using as Nixos Kakoune plugin

Hello,

I looked at your Nixos dotfiles, as well as nix packages for plugins available to use with Kakoune, and it seems like the code below should work. However, when I run "nixos-rebuild switch" it tells me that kak-ansi is an undefined variable. The kak-buffers plugin that I also listed works as expected.

Also, I am having trouble understanding what this plugin does by the description. I having been looking for a command-line tool that will take my kakoune syntax highlighting from the editor and turn it into ansi color escaping when I send the text to a repl. Is that what this plugin does? It looks like from the code that it does that for a selection (which would be perfect).

Sorry to keep asking you questions. It is tough to find people that share an overlapping interest in Nixos, Clojure, and Kakoune.

  {
    nixpkgs.overlays = [
      (self: super: {
        kakoune = super.wrapKakoune self.kakoune-unwrapped {
          configure = {
            plugins = with self.kakounePlugins; [
              parinfer-rust
              kak-ansi
              kak-buffers
            ];
          };
        };
      })
  ];

  environment.systemPackages = [ pkgs.kakoune ];
}

[BUG] kitty scrollback_pager kak -ro colors

Version of Kakoune

v2020.09.01-1320-g94192402

Reproducer

  1. Install kitty
  2. Install starship
  3. Set kitty scrollback_pager to kak -ro

Outcome

In between lines there's this color code that isn't rendered correctly in the pager (CTRL+SHIFT+h)

Welcome to fish, the friendly interactive shell
Type help for instructions on how to use fish
]133;A�\
�~ 
❯ 
]133;A�\
�~ 
❯ 

image

Expectations

image

Additional information

No response


This is a mawww/kakoune#4801 copy-paste. I noticed I actually use this plugin and was diverted here. Thanks :)

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.