Giter Site home page Giter Site logo

qui's Introduction

QUI

QUI is a Text User Interface library for the D Language.


Features

  1. OOP based
  2. Support for Mouse events
  3. Abstracted scrolling
  4. Tries to optimise drawing

Setting it up

To use qui in your dub package, run this in your dub package's directory:

dub add qui

Getting Started

Some built in widgets are contained in qui.widgets, and the base classes are in qui.qui.

You should also read through docs/*.md for a quick start on how to use and write new widgets.

Building demo

The included demo configuration (source/demo.d) demonstrates the usage of some of the included widgets. To build & run it, run the following:

dub fetch qui
dub run qui -b=release -c=quidemo

Documentation

See docs/ for documentation on how to use qui and how to write widgets.

Additionally, you could also see source/qui/widgets.d and see some existing widgets, this can be helpful in writing new widgets.


Known Issues

See the issues tab.


TODO for upcoming versions

See issues marked as enhancement.


License

QUI is licensed under the MIT license - see LICENSE.

QUI uses Adam D. Ruppe's terminal.d which is licensed under the Boost License - see source/arsd/LICENSE.

qui's People

Contributors

jakobkogler avatar nafees10 avatar nafees100 avatar notmichaelchen avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar

qui's Issues

adding widget to layout before `QTerminal.run` causes segFault

adding a widget (or more), before calling QTerminal.run will cause a segmentation fault.
I've figured out that it is caused in the file widgets.d wherever a line like: following appears

if (&widgetTheme && widgetTheme.hasColors(name,[]))

assuming that the segfault really does occur at that line, the theme-ing is probably also broken

TextLabelWidget and EditLineWidget 's dispalys are not working properly.

Using this code:

module app;

import qui.qui;
import qui.widgets;
void main(){
	QTerminal term = new QTerminal("Term");
	EditLineWidget input = new EditLineWidget("Input: ");
	TextLabelWidget label = new TextLabelWidget("someText");
	term.addWidget(label);
	term.addWidget(input);
	term.run;
}

The display is "bugged" (look into screenshots).
latest
Although the pattern formed is good-looking, it's a bug and needs to go.

I have rewritten EditLineWidget, but the result is same. This might be an indication that the bug is not in the widgets but probably in Matrix class.

mouse is necessary to make widgets active.

Since it's a TUI, mouse shouldn't be necessary in it, but it is. If there is a memo or any keyboard-input-receiving widget, then it can only receive input after it has been clicked with mouse. A key like Tab should have the functionality to switch between active widgets.

Character encoding

When I type special characters (such as á é ñ) in any input widget, they don't appear with the correct encoding. I am using linux, and utf-8 encoding on my terminals (gnome-terminal, guake).

@adamdruppe

Rounding errors in layouts

Hey. I've been playing a little bit with qui, and noticed a bug concerning layouts.

When the screen with is 101 pixel, and you have two widgets in a horizontal layout, both widgets get the width 50. Which means there is one pixel spare.
This can have nasty effects. E.g. if you hide one of the widgets, making the other widget taking 100% of the width, and then show the hidden widget again. Characters that were drawn in the 100% mode in column 101 will not be erased.

animation

The problem is in the recalculateWidgetsSize(QLayout.Type T) method of the QLayout class and the ratioToRaw function. It just rounds down the float value (selectedRatio / ratioTotal * total). A typical solution to this problem is to round some of the values up. Usually the values with the highest remainder. So to round one of the two widgets up to size 51, and the other one down to size 50. E.g. see here: round_preserve_sum.

Characters that do not occupy a cell mess up cursor position

The cursor appears 1 cell right than it should for each of a character like this.
Need to use some function that counts "visible" length of strings rather than the number of characters in them.
Additionally, if this is fixed, maybe tab character will no longer have to be converted to space.

MemoWidget is broken

modifying the content of MemoWidget, i.e MemoWidget.lines, doesnt always work, for example:

import utils.misc : fileToArray; // from utils packages
MemoWidget memo  = new MemoWidget;
...
memo.lines.loadArray(fileToArray("some file with long lines"));

This messes up the horizontal scrolling, and some lines arent even visible, while some are half visible, with some characters not shown. However, if you "manually" type in all that into it, it works.
I'll be working on fixing this issue, so in the meanwhile, try to avoid using this widget.

If max-size is non-zero, widgets above don't fill up space

A terminal has 2 widgets, a MemoWidget, and TextLabelWidget. The max height (or width in case of Horizontal) is above zero.
The expected behavior is:
The MemoWidget should occupy all the space that is made available because of the max-height limit on the TextLabelWidget.
Current behavior:
The space made available by TextLabelWidget is not used, and is left empty at the bottom (or right, in case of Horizontal) of the terminal.

termbox-d is broken, qui doesn't work because of that.

termbox-d has several bugs that prevent qui from compiling, if it is added as a dependency. Even if not added as dependency, for example, if you run dub build qui, it will most likely not compile. That can be fixed by:

  1. Locating the qui directory in ~/.dub/packages/
  2. Locating the termbox-d directory in ~/.dub/packages
  3. Copy termbox.a file in qui directory to ~/.dub/packages/termbox-VERSION/termbox/
  4. Build again

There are several other issues with termbox-d too:

  1. When qui is added as dependency of a package, it won't build. Running dub build qui --config=demo will work, but a dependent pacakge will fail to build as termbox.a fails to link. Not sure if this is caused by termbox-d or qui.
  2. Only works on GNU/Linux - or at least I think it only does, because maybe the build-termbox.sh is GNU/Linux only? Not sure

So now qui will have to move back to terminal.d and fix the bug in timedCheckForInput, or figure out a way to make it work with termbox-d.

LogWidget is buged

After the elements in LogWidget's list exceed the max capacity, the display gets "weird". This is probably because of an issue in LogList.
TODO: Instead of using LogList, which wastes memory as well, the LinkedList could be used, and might be a possible fix to this bug.

Escape key registered as a character event as well

Escape key should only cycle active widgets, however, in the demo build, keeping escape key pressed, a non-visible character is inserted in the memo.

Might take me some time to get to fixing it as I'm busy with QScript.

Resizing is broken on some terminals unless TERM=xterm

Resizing in alacritty and kitty can permanently break qui, requiring a restart of the program.
running the same program after setting TERM=xterm (not TERM=xterm-alacritty or TERM=xterm-kitty) fixes this for some reason, even the the terminal is same (alacritty or kitty). So far this has only happened when width is changed, changes in height dont seem to be causing this issue. Demo program to test this bug:

import qui.qui;
import qui.widgets;
import std.conv : to;
void main (){
	QTerminal term = new QTerminal(QLayout.Type.Horizontal);
	foreach (i; 0 .. 5){
		QLayout vl = new QLayout(QLayout.Type.Vertical);
		foreach (j; 0 .. 5){
			SplitterWidget split = new SplitterWidget();
			split.color = (i + j) % 2 ? Color.red : Color.green;
			vl.addWidget(split);
		}
		term.addWidget(vl);
	}
	term.run();
	.destroy(term); 
}

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.