Add a scrollbar to the kakoune text editor (experimental!)

Related tags

CLI scrollbar.kak
Overview

Scrollbar.kak

This is a scrollbar for kakoune, the educated programmer's terminal editor of choice.

It uses the line-flagging feature and a compiled script to provide a real-time, smooth-as-silk scrollbar display. A limitation of this is that the scrollbar isn't a clickable UI element—you'll still have to roll your sleeves up and apply finger to keyboard to navigate around that document. This is kak, so you oughtta either be or get used to it!

This is version 0.0.4. The whole feature is—and will remain—somewhat experimental, and won't promise anything like a perfect experience, because it's not easy to implement as a plugin.

Scrollbar image

See selections outside your current view

The scrollbar will show the locations of your selections as you make them, allowing you to see selections outside of your current view.

Installation

Just put the scrollbar.kak into either your plugins or your autoload folder in kak's configuration directory. I highly recommend plug.kak to handle this for you.

Then you'll need to compile kak-calc-scrollbar to have your scrollbar.kak script use its C-language engine. It's the simplest C program ever and should be compilable on almost every system. You can either pop into to the command line and enter:

make kak-calc-scrollbar

Or you could just have plug do it for you—add the following to your kakrc:

plug "sawdust-and-diamonds/scrollbar.kak" do %{
    make kak-calc-scrollbar
}

If there's a problem with using make like this, you can use the more verbose, but more proper call to gcc: gcc kak-calc-scrollbar.c -o kak-calc-scrollbar.

If you'd prefer to use another compilation system, clang for instance—which shouldn't be any problem—then I'll assume you're knowledgeable enough to manage by yourself!

Using the scrollbar

Once you have scrollbar.kak and calc-scrollbar-kak installed, there is not much to do. Use the scrollbar-enable command to make it appear in the current window. You can set it for all windows in your kakrc like so:

hook global WinCreate .* %{ scrollbar-enable }

Features & limitations

  • The scrollbar can't display past the last line of the buffer, meaning that it will start to disappear as your view scrolls past the end of your document.

  • It really doesn't work well in heavily line-wrapped documents. Sorry!

  • The scrollbar is composed of simple terminal characters. Currently, it doesn't make use of any fancy tricks to make the display less granular than the height of a single character.

  • Some built-in kak commands mess with the flags list (scrollbar.kak's line-spec value), and there'll be a brief graphical glitch as one character-height of scrollbar is deleted and re-inserted. I haven't figured out a way to make the re-application apply more instantly.

A built-in scrollbar for kakoune?

My next project is to write an update for kak's core that will allow you to build your own custom version of kak with 'baked-in' scrollbar functionality, and which won't have these limitations.

Hopefully it'll be possible to host this feature on the wonderful hakoune project, a fork of kak with optional power features—for the most power-hungry of power users.

Get in touch with more ideas

In the meantime, if you have any ideas as to how I can make scrollbar-kak more efficient in its execution, and thereby help it display even more smoothly, please let me know.

Customization

There are a number of face options you can edit to customize your scrollbar's look:

Scrollbar: This sets the main face for your scrollbar column, i.e. its background colour and the main scrollbar colour.

ScrollbarSel: Sets the colour for in-view selections.

ScrollbarHL: Sets the colour for out-of-view selections, i.e. the scrollbar's display of selections that are outside your current view. I find it helpful to set this to a more... alarming colour, so that you notice when you are editing text outside your current view.

Here are a few examples of how you can change the scrollbar colours. Please enter :doc faces into kak for more information:

set-face global Scrollbar rgb:7080a0,rgb:281090

set-face global ScrollbarSel green

set-face global ScrollbarHL @Information

You can change which characters are used for displaying the scrollbar with the following options:

scrollbar_char : Sets the character used for the scrollbar.

scrollbar_sel_char : Sets the character used for selections.

Scrollbar.kak will try to store the compiled tool in the its own plugin folder, but there is the scrollbar_plugin_path option if you need to change where the tool is stored.

If you've set up the scrollbar and played about with adding new highlighters, you might want to push it back to its left-most position on the highlighter stack. To do so, use the move-scrollbar-to-left command.

License

Oi! 'Ave you got a license for that scrollbar?

Actually, yes you have, because I'm releasing this under the MIT license. Though, to be honest, if you have grand ideas and want to use this elsewhere without the disclaimer or indeed under another license, just let me know and we can arrange it.

Issues
  • Awk rewrite

    Awk rewrite

    This PR replaces the C helper tool with an Awk script that does the same thing. This makes the plugin usable immediately after installation, instead of requiring a separate compilation step. The result does feel perhaps a tad slower on my 4333.33-bogomips Celeron laptop, but still pretty smooth.

    This PR does not include the rendering changes (selection count, different faces) from my previous attempt at rewriting the helper in awk, but it does include the change that calculates the window height based on %val{window_range} rather than %val{window_height}, because it was easy enough to do, and it fit neatly in with the command-line-argument refactoring.

    I was impressed at how easy it was to port the C code to Awk. The main differences turned out to be:

    • no variable types, which in one place meant calling int() explicitly instead of assigning to an integer variable
    • no local variables, but awk does have optional arguments, so the convention is to define functions with the intended parameters, then leave a little space, then the local variables
    • split() is a heck of a lot nicer than strtok()
    • string concatenation is just adjacency ("Label 1:" var1 ", Label 2:" var2)
    • no bitwise operations, so I changed |= to += in the one place it occurred
    • no semicolons
    opened by Screwtapello 8
  • Update scrollbar on ClientCreate and WinResize

    Update scrollbar on ClientCreate and WinResize

    ClientCreate: The scrollbar wouldn't show on a new window until pressing a key (triggering RawKey) with only WinCreate. Updating on the window's ClientCreate instead of updating the scrollbar immediately in scrollbar-enable fixes this issue. Basically the window waits for a terminal to connect to it before updating it.

    WinResize should be self-explanatory ;P

    Thank you for making scrollbar.kak!

    opened by SeerLite 2
  • Fix plug.kak instructions in README

    Fix plug.kak instructions in README

    I believe the plug.kak instructions should use the sawdust-and-diamonds/scrollbar.kak address instead of kak-lsp/scrollbar.kak.

    Thanks for this nice plugin!

    opened by Kabouik 2
  • Enable scrollbar with commands, not an option.

    Enable scrollbar with commands, not an option.

    An option is a nice UI because it feels more "built in", but it introduces a load-order dependency - only plugins loaded after the scrollbar plugin can set the scrollbar option.

    Using commands to enable and disable the scrollbar means they can be called from hooks, which won't be invoked until after all plugins are loaded, solving the load-order dependency. In addition, this makes things a little easier to debug when things go wrong - if the user puts a hook in their kakrc, they know they have to debug hooks; if they set an option in their kakrc they may spend time debugging options when options aren't the problem. For precedent, see the autowrap-enable and ctags-enable-* commands in the standard library.

    Also, I took the liberty of inlining some helper functions. The "enable" and "disable" logic can now be viewed side-by-side to verify that everything that gets installed also gets cleaned up. Added comments mean it's still possible to understand what the code does without being a Kakoune expert.

    opened by Screwtapello 1
  • Find helper tool

    Find helper tool

    Teach the scrollbar plugin to automatically find the helper tool, and complain when it's not present, instead of requiring the user to manually move it into $PATH.

    opened by Screwtapello 1
  • Doesn't work on macOS

    Doesn't work on macOS

    I installed the plugin and compiled binary like make kak-calc-scrollbar. Then manually issuing :scrollbar-enable does nothing, I mean there is no any visible scroll bar I can see.

    Manually invoking the binary results in the following error:

    bash-5.1$ ./kak-calc-scrollbar
    Segmentation fault: 11
    

    Is it problem with binary or did I miss something?

    opened by vbauerster 6
Owner
Sawdust & Diamonds
Whimsical syntaxadermist, cyberscrimshander and life-long cephalapologist.
Sawdust & Diamonds
Command-Based Text Editor written in cpp using Linked Lists and Stack

Command Based Text Editor Our goal in this project is to write a command-based text editor in cpp using linked lists and stack. This text editor will

bedirhanbardakci 3 Jun 9, 2021
Add a command-line interface to any C++ program

Add a command-line interface to any C++ program

Empirical Software Solutions, LLC 405 Jun 8, 2022
Library for writing text-based user interfaces

IMPORTANT This library is no longer maintained. It's pretty small if you have a big project that relies on it, just maintain it yourself. Or look for

null 1.9k Jun 18, 2022
ImTui: Immediate Mode Text-based User Interface

imtui ImTui is an immediate mode text-based user interface library. Supports 256 ANSI colors and mouse/keyboard input. Live demo in the browser Eventh

Georgi Gerganov 1.9k Jul 1, 2022
Draw sequence diagram in text from terminal.

sequence-diagram-cli Draw seqence diagram from terminal.

null 42 Feb 28, 2022
Library for creating terminal applications with text-based widgets

Library for creating terminal applications with text-based widgets FINAL CUT is a C++ class library and widget toolkit with full mouse support for cre

Markus Gans 647 Jul 3, 2022
This is my very own text editor inspired by the kilo text editor

Xenon-text-editor This is my very own text editor inspired by the kilo text editor which you can find here: https://github.com/snaptoken/kilo-src/blob

Arin 15 Aug 28, 2021
Simple text editor in C++ - Simple editor built upon kilo editor.

GUMBO editor Simple editor built upon kilo editor. Still big work in progress although this is just fun side project to learn more C/C++. From 0.0.2->

Filip Ivanušec 3 Sep 15, 2021
✔️The smallest header-only GUI library(4 KLOC) for all platforms

Welcome to GUI-lite The smallest header-only GUI library (4 KLOC) for all platforms. 中文 Lightweight ✂️ Small: 4,000+ lines of C++ code, zero dependenc

null 6.3k Jun 27, 2022
My old heavily modified version of bigbase v1, it has an impulse-like scrollbar, ytd header loader, Vector3 fix + gamestate fix and some other misc changes!

Old Bigbase V1 UI This is my old ui for bigbase v1 but i dont need it anymore because the dev of solar mod menu stole it, and the new paragon menu (Fr

null 11 Jun 19, 2022
QSuspendedScrollBar is a suspended (translucent) scrollbar implementation, written in Qt5.

QSuspendedScrollBar Introduction QSuspendedScrollBar is a suspended (translucent) scrollbar implementation, written in Qt5. Usage Firstly, hide the de

Skykey 2 Feb 11, 2022
I am planning to add a beginner friendly path for my Juniors to Learn DSA and I will try to provide solutions of every problem also. We can add codeChef Challenge solutions also

DSA-Path-And-Important-Questions I am planning to add a beginner friendly path for my Juniors to Learn DSA Are you a Newbie in programming and want to

Arpit Jain 30 May 31, 2022
About Add any Program in any language you like or add a hello world Program ❣️ if you like give us ⭐

Hello-World About Add any Program in any language you like or add a hello world Program ❣️ if you like give us ⭐ Give this Project a Star ⭐ If you lik

Lokesh Jangid 16 Jan 22, 2022
Typewriter Effect with Rich Text + *Correct* Text Wrapping

Typewriter Effect with Rich Text + Correct Text Wrapping I've spent way too long getting this right. This is meant as a base class for a UMG dialogue

Sam Bloomberg 25 Jun 26, 2022
Text - A spicy text library for C++ that has the explicit goal of enabling the entire ecosystem to share in proper forward progress towards a bright Unicode future.

ztd.text Because if text works well in two of the most popular systems programming languages, the entire world over can start to benefit properly. Thi

Shepherd's Oasis 199 Jun 26, 2022
Jittey - A public domain text editor written in C and Win32

Jittey (Jacob's Terrific Text Editor) is a single-file basic text editor written in pure C and Win32, there is no real reason to use it, but it

Jakub Šebek 24 Feb 22, 2022
led is a line-oriented text editor in command line

led is a line-oriented text editor in command line. This editor is similar to the standard program on unix systems - GNU ed. But i'm not going to make an exact clone of that program, it's just a pet project.

Artem Mironov 9 Jun 14, 2022
A very minimal & simple text editor written in C with only Standard C Library.

Texterm Text Editor A very minimal & simple text editor written in C with only Standard Library. Syntax highlighting supported for C JavaScript Python

Biraj 37 Jun 3, 2022
Command-Based Text Editor written in cpp using Linked Lists and Stack

Command Based Text Editor Our goal in this project is to write a command-based text editor in cpp using linked lists and stack. This text editor will

bedirhanbardakci 3 Jun 9, 2021
Skylark Edit is a customizable text/hex editor. Small, Portable, Fast.

Skylark Edit is written in C, a high performance text/hex editor. Embedded Database-client/Redis-client/Lua-engine. You can run Lua scripts and SQL files directly.

hua andy 91 Jun 27, 2022
MINCE is an Emacs-like text editor from Mark of the Unicorn, Inc.

MINCE Is Not Complete[ly] EMACS Overview MINCE is an Emacs-like text editor from Mark of the Unicorn, Inc. Versions were available for many oper

Jeffrey H. Johnson 20 May 17, 2022
C.impl is a small portable C interpreter integrated with a line text editor

C.impl C.impl is a small portable C interpreter integrated with a line text editor, originally developed for the ELLO 1A computer: http://ello.cc The

KnivD 19 Jun 9, 2022
Let's make a text editor like in the 70's

baracle Let's make a text editor like in the 70's Installation Arch Linux and derivatives (AUR) Stable package: baracle Use an AUR helper or git clone

Mirko Rovere 3 Feb 27, 2022
This repository is for my coding practice, making a text editor from scratch in C.

text-editor-practice This repository will contain my coding practice, making a text editor from scratch. I based this practice from this wonderful res

null 2 Dec 13, 2021
te is a small text editor with emacs keybindings.

te - a tiny emacs te is a small text editor with emacs keybindings. Here are söme Ümlautß! Oh no. Come, you spirits That tend on mortal thoughts, unse

Leah Neukirchen 21 Jun 8, 2022
yedit - A text editor made with ncurses and C++

yedit A text editor made with ncurses and C++ dependencies ∙ ncurses in Debian you can install dependencies with this command: # apt install libncurse

MESYETI 15 Jun 8, 2022
Programmer's text editor

README file for JED. For installation instructions on Unix: read INSTALL.unx VMS: read INSTALL.vms Windows:

John E. Davis 8 May 2, 2022
QsciScintilla based text editor

Sqriptor QScintilla based text editor "Every man should plant a tree, have a son and write a TextEditor"                          --- Proverb "The bes

null 10 Apr 27, 2022
Syntax highlighting text editor for ImGui

Syntax highlighting text editor for ImGui

null 970 Jun 27, 2022