Skip to content

moledoc/hl

Repository files navigation

hl

This project is WIP and used for exploration

Text displaying tool (to enhance acme workflow) - might become something else in the future.

Why

  • Enable some highlighting in my acme workflow, when I need it (screensharing, visual parsing, etc).
  • Seemed like an interesting project for me to expand my knowledge and skills.

Dependencies:

  • libsdl2-ttf-dev
  • libsdl2-dev

TODO:

  • tokenizing file
    • based on extension
      • able to override the style
    • words/strings/numbers/tabs/spaces/newlines
    • comments
    • comment keywords
    • code keywords
      • c/cpp/h
      • golang
      • python
      • markdown
      • others when needed
    • golden file testing
    • MAYBE: scoping tokens. i.e. currently stuff in backticks are not easily highlightable via double click
  • TUI - print text to terminal
    • intermediate step, serves as backup to GUI
    • auto-update code when it's modified
  • GUI with SDL2
    • non-colored text
    • auto-update code when it's modified
    • horizontal/vertical scrolling (unbounded)
    • font increase/decrease
      • ctrl+plus(or ctrl+equal for convenience)/ctrl+minus
      • ctrl+mouse-wheel
      • reset to default
    • keyword based highlighting in GUI
      • multi-line strings are not properly handling newline chars
    • bounded horizontal/vertical scrolling
      • extension: horizontal scrolling only when text doesn't fit the screen
      • extension: able to specify scrolling factor
      • extension: snap back if text fits on screen, but horizontal scroll is non-zero
    • scrollbar (horizontal/vertical)
      • acme inspired movements on scrollbar
    • when font is resized, keep same place in view
      • smaller font increment instead
    • highlighting text with mouse
      • token based highlighting
      • keep highlighting after letting go, stop highlighting after click
      • char based highlighting
      • better accuracy on highlighting
      • mouse scrolling highlight previously highlighted area, instead of moving along
        • store beginning token instead of beginning mouse pos
      • acme-inspired highlighting (inside quotes, parenthesis, brackets etc)
      • double-click to highlight a word
      • triple-click or double click beginning/end of line to highlight a line
    • copy-paste highlighted text
    • colorschemes; currently:
      • light (default)
      • dark
      • gruvbox-light
      • gruvbox-dark
      • solarized-light
      • solarized-dark
    • soft-wrap text
    • row and col numbers
      • goto line nr
      • MAYBE: jump to <path>:<line>:<col> support
    • text search
    • display cursor
    • vendor SDL2 how to vendor:
      • installed libtool-bin and some lib.*-dev packages
      • steps to build SDL2 and SDL2_ttf for vendoring:
       git clone -b SDL2 https://github.com/libsdl-org/SDL.git
       git clone -b SDL2 https://github.com/libsdl-org/SDL_ttf.git
       mkdir vendor
       cd vendor
       mkdir SDL2
       cd SDL; ./configure --prefix=$(pwd)/../SDL2; make -j4; make -j4 install; cd ..
       cd SDL_ttf; ./configure --prefix=$(pwd)/../SDL2 --disable-freetype-builtin --disable-harfbuzz-builtin; make -j4; make -j4 install; cd ..
       PKG_CONFIG_PATH=./SDL2/lib/pkgconfig pkg-config --cflags --libs sdl2 SDL2_ttf # prints include and lib paths, but this has been added to Makefile as well
      
       # compile cmd
       clang -Wall -o ./bin/hl ./main.c -lm `PKG_CONFIG_PATH="./vendor/SDL2/lib/pkgconfig" pkg-config --cflags --libs sdl2 SDL2_ttf`
    • move tokens and textures to state
    • use linked lists for holding tokens/textures instead of array
      • rationale: my hope is that this would enable reasonable enough text editing for this project
    • UTF handling
    • able to specify font
      • cmd args
      • on the fly
    • specify color schemes
      • cmd args
      • on the fly
    • some acme-inspired mouse actions
      • TBD
    • some keyboard shortcuts for navigation
      • ctrl+d/ctrl+u = jump half a page down/up (vim inspired)
      • ctrl+a/ctrl+e = jump to beginning/end of file
      • TBD
    • MAYBE: MAYBE: lsp integration
    • MAYBE: possible performance optimization
      • when font changes scale by factor first, and when the font persists for some time, calculate the textures again.
      • MAYBE: instead of list (of textures/tokens):
        • linked list
        • map
      • MAYBE: compute values/obj only once, that don't need to be recomputed
      • render only rows fitting on window
      • render only columns fitting on window
  • fix mem-leaks
  • building
    • `make
    • something inspired by nobuild instead of make
  • merge tokenize_test into the main file
  • commandline arguments to toggle different functionality; eg tui vs gui mode, overriding comment/code style, etc
    • override what to color/what not to color
  • resolve TODOs and others
  • placeholder
  • proper readme
  • make it work on other platforms than linux (grep ifdef OSX)

Some Resources

Author

Meelis Utt

About

text displaying tool (to enhance acme workflow) - might become something else in the future

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published