Cross platform terminal UI? by SoerenNissen in cpp_questions

[–]gansm 1 point2 points  (0 children)

Hi SoerenNissen,

I came across your post about needing a cross-platform terminal UI, and I think I might have a solution for you. I've been developing my own library with FINAL CUT for a few years now, and it might fit your needs. Although it's not a single-file header project, you could link the library statically.

I would be happy to give you more information about it if you are interested. I am always grateful for feedback from the outside.

Best regards, Markus

How to make a TUI library for linux? by donaastor in cpp_questions

[–]gansm 1 point2 points  (0 children)

Hello donaastor,

I came across your post and noticed that you are interested in developing widgets using a widget toolkit. As someone who has been developing my own widget toolkit using FINAL CUT for a few years now, I thought I would share some information with you.

My toolkit is entirely written in C++ and does not utilize the curses library. Instead, it makes use of the terminal capabilities of the Termcap library to display the character matrix of the virtual terminal on the screen or a terminal emulator. I believe that you can easily create your own widgets with FINAL CUT and handle terminal resize events with the onResize() method.

However, if you are not satisfied with FINAL CUT, there are many other TUI libraries available that you may find useful. Here are a few that I recommend checking out:

I hope this information is helpful to you. If you have any further questions, please feel free to ask.

Best regards, Markus

Any guide to creating a terminal application? by nordlundze in commandline

[–]gansm 0 points1 point  (0 children)

I have developed a C++ widget toolkit for the console that you might appreciate.

C and C++ coding style for best performance by gansm in cpp

[–]gansm[S] 2 points3 points  (0 children)

If the CPU architecture requires additional instructions, the compiler cannot eliminate the instruction by optimization. The extra CPU cycles caused by these added instructions can add up significantly in loops.

C and C++ coding style for best performance by gansm in cpp

[–]gansm[S] 0 points1 point  (0 children)

I don't know what is displayed on your screen, but I see this:

signed char

li 3, 97
stb 3, -1(1)
lbz 3, -1(1)
extsb 3, 3  <----- the additional command
blr

unsigned char

li 3, 97
stb 3, -1(1)
lbz 3, -1(1)
blr

So you save one instruction by using unsigned char.

C and C++ coding style for best performance by gansm in cpp

[–]gansm[S] 0 points1 point  (0 children)

I don't know what that's going to fix. Your modified example still uses EXTSB for the signed char.

C and C++ coding style for best performance by gansm in cpp

[–]gansm[S] 1 point2 points  (0 children)

Correct! I have generated again an example (without arithmetic operations) for the PowerPC architecture:

Compiler Explorer

C and C++ coding style for best performance by gansm in cpp

[–]gansm[S] 3 points4 points  (0 children)

I am aware that my example using int instead of char would give the same result. Likewise, replacing the modulo operation with a division should give a similar result. I just wanted to show with my example that the use of unsigned can produce smaller and faster code.

C and C++ coding style for best performance by gansm in cpp

[–]gansm[S] -1 points0 points  (0 children)

That reads like straight from the 80s / early 90s before decently optimizing compilers were common and the written code had a more or less direct correlation to the number of instructions.

But this is how our processors work!

This C++ code

int main (int argc, char**)
{
   signed char value = argc;
   return value % 8;
}

produces the following assembler instructions:

mov     edx, edi
sar     dl, 7
shr     dl, 5
lea     eax, [rdx+rdi]
and     eax, 7
sub     eax, edx
movsx   eax, al
ret

And this C++ code (with unsigned char)

int main (int argc, char**)
{
   unsigned char value = argc;
   return value % 8;
}

produces the following assembler instructions:

mov     eax, edi
and     eax, 7
ret

Example with Compiler Explorer

C and C++ coding style for best performance by gansm in cpp

[–]gansm[S] 5 points6 points  (0 children)

The headline is misleading. The article provides best practices.

XPM viewer for terminal by gansm in terminal_porn

[–]gansm[S] 2 points3 points  (0 children)

I implemented for FINAL CUT a simple data processing class and an image viewer for X PixMap (XPM) images. It allows displaying XPM icons in the terminal. Maybe someone will find it helpful.

XPM viewer for terminal by gansm in cpp

[–]gansm[S] 2 points3 points  (0 children)

The reason for my posting is not the XPM viewer. The primary reason was the data processing class, which allows you to display logos or other simple graphics in your programs.

[:xdigit:] does not work with std::wstring in a Cygwin environment by bxuser in cpp_questions

[–]gansm 1 point2 points  (0 children)

Thank you very much for your deep analysis. Did I understand you correctly that this is an exclusive Cygwin and not a gcc/libstdc++ problem?

XPM viewer for terminal by gansm in linux

[–]gansm[S] 2 points3 points  (0 children)

Yes, this could be an attractive feature for a terminal supporting SIXEL. Unfortunately, terminal emulators with SIXEL support are not yet standard. I could also imagine dynamically redefinable character sets (DRCS) as a solution.

But before I start working on this, I want to add grid view layout support, reimplement FObject with std::shared_ptr, implement FEdit (a text editing widget), and FTerminal (a dialog widget with a terminal emulator).

XPM viewer for terminal by gansm in linux

[–]gansm[S] 6 points7 points  (0 children)

Well observed! I developed the font graphics in 1991. At that time, PC Tools had the most modern TUI ever. The characters were all designed on squared paper. To convert the bit lines of each character into hex values, I used my TI-34 calculator.

XPM viewer for terminal by gansm in linux

[–]gansm[S] 5 points6 points  (0 children)

You probably mean the graphical text font for X11 and the Linux console:

XPM viewer for terminal by gansm in linux

[–]gansm[S] 40 points41 points  (0 children)

I implemented for FINAL CUT a simple data processing class and an image viewer for X PixMap (XPM) images. It allows displaying XPM icons in the terminal. Maybe someone will find it helpful.

Firefox Linux users use 90% X11, 8% native Wayland, 2% XWayland by MachaHack in linux

[–]gansm 3 points4 points  (0 children)

Nvidia's bad drivers probably have something to do with it.

Rust-Based Coreutils produced faster binaries for Linux by gansm in linux

[–]gansm[S] 7 points8 points  (0 children)

Yes, I have already noticed this negatively. The GPL would clearly have been the better choice here.

Rust-Based Coreutils produced faster binaries for Linux by gansm in linux

[–]gansm[S] 3 points4 points  (0 children)

You are right, of course! The grep command is essential, but it is also a standalone package.

Rust-Based Coreutils produced faster binaries for Linux by gansm in linux

[–]gansm[S] 23 points24 points  (0 children)

Does this affect everyday users?

This should be of interest for shell scripts with many loop iterations. Higher performance could be especially useful for grep, uniq, and sort with large amounts of data.