Ghostling

(github.com)

57 points | by bjornroberg 2 hours ago

3 comments

  • oDot 1 hour ago
    I use libghostty for Trolley[0], which packages TUIs as desktop apps, like Electron does for web apps.

    It really is quite an amazing piece of software. I just wrapped it in a useful GUI and a bundle/package CLI and it just works. Even on Windows. Kudos to the Ghostty developers.

    [0] https://github.com/weedonandscott/trolley

    • nout 1 hour ago
      I think your github readme is really missing a picture/screenshot to quickly understand what is the experience like. I.e. if your app is mainly about adding the chrome (as in the surrounding UI pixels) around the TUI, then it would be good to show what is the chrome like.
  • vintagedave 1 hour ago
    The C file is small enough to read (over a few minutes.)

    I got to about line 5 and realized: I’ve never seen quite that technique for embedding a font via an autogenerated header before. I’m more used to Windows resources; this seems to generate a byte array in CMake code. I’m somewhere between horrified and impressed, in that I feel we’ve finally discovered a cross platform binary resource embedding solution.

    • simonw 1 hour ago
      Here's the build script that uses: https://github.com/ghostty-org/ghostling/blob/main/bin2heade...

      I ran it against a 1x1 pixel GIF:

        cmake -DINPUT=pixel.gif -DOUTPUT=pixel.h -DARRAY_NAME=pixel_gif -P bin2header.cmake
      
      And got this:

        // Auto-generated from /private/tmp/exp/pixel.gif — do not edit.
        static const unsigned char pixel_gif[] = {
            0x47, 0x49, 0x46, 0x38, 0x39, 0x61, 0x01, 0x00, 0x01, 0x00, 0x80, 0x00, 
            0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00, 0x00, 
            0x01, 0x00, 0x01, 0x00, 0x00, 0x02, 0x02, 0x44, 0x01, 0x00, 0x3b
        };
    • fresh_broccoli 1 hour ago
      Fun fact: XPM bitmaps were designed to be #included unmodified, the files contain C boilerplate: https://en.wikipedia.org/wiki/X_PixMap
    • electroly 27 minutes ago
      You can use `xxd` from the vim package to generate these. You'll find out pretty quickly that this is only suitable for small resources: gcc and clang blow up in both time and space on very large literal arrays. If you need to ship more than a few megabytes, find a different technique.

      I used this technique for awhile, but it was too problematic for my use case. Now, I use https://github.com/lief-project/LIEF -- among other things, this project can modify Windows PE, macOS Mach-O, and Linux ELF binaries to add resources to them, then offers an API to read them back later. It's a little different for each format, but it's capable of doing all three and I was able to build a cross-platform resource-bundling system that doesn't care how big the resources are.

    • vintagedave 1 hour ago
      And as a Windows programmer the use of a method called DrawTextEx surprised me :)

      A really neat sample. Shows the power of the ghosttty library very well. The author chose well with their other libraries, it’s the kind of demo that lets the code actually demo what to trying to without much else getting in the way. Rather inspirational to wrote my own terminal app now.

    • kingforaday 55 minutes ago
      For cross-compilation ease it makes sense if you don't care about the size explosion.
  • imiric 54 minutes ago
    This looks interesting.

    I don't need my terminal emulator to support tabs, windows, or session management. My WM manages tabs and windows, and I use tmux for sessions, which also gives me a scrollback buffer, selection, clipboard, search, etc. This combination allows me to use any simple terminal emulator, such as urxvt, st, and now foot, without issues.

    Ghostty didn't appeal to me, but I might give this a try. It's good that OSC support is planned. A plugin-like system, similar to st's but less cumbersome, would be nice to have.