vimamsa 0.1.26 → 0.1.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/appimage.yml +93 -0
- data/.gitignore +4 -1
- data/Dockerfile +7 -4
- data/README.md +62 -16
- data/custom_example.rb +43 -13
- data/doc/TODO.md +461 -0
- data/doc/bundling_plan.md +569 -0
- data/doc/key_bindings_report_plan.md +168 -0
- data/doc/missing_vim_bindings.md +71 -0
- data/doc/modules_settings_plan.md +433 -0
- data/doc/refactor_dedup_plan.md +117 -0
- data/doc/unused_code_plan.md +120 -0
- data/doc/vim_compatibility_plan.md +296 -0
- data/doc/vimlike_vim_conflicts.md +254 -0
- data/doc/vm_snapshots_plan.md +146 -0
- data/exe/run_tests.rb +117 -3
- data/exe/vimamsa +24 -4
- data/fonts/OFL-Oxanium.txt +93 -0
- data/fonts/Oxanium[wght].ttf +0 -0
- data/icon.png +0 -0
- data/img/demo.gif +0 -0
- data/lang/hyperplaintext.lang +6 -0
- data/lib/vimamsa/ack.rb +11 -1
- data/lib/vimamsa/actions.rb +4 -1
- data/lib/vimamsa/appimage_env.rb +35 -0
- data/lib/vimamsa/audio.rb +2 -5
- data/lib/vimamsa/bookmarks.rb +302 -0
- data/lib/vimamsa/buffer.rb +593 -82
- data/lib/vimamsa/buffer_changetext.rb +102 -42
- data/lib/vimamsa/buffer_cursor.rb +7 -0
- data/lib/vimamsa/buffer_list.rb +4 -0
- data/lib/vimamsa/buffer_manager.rb +4 -1
- data/lib/vimamsa/bundled_fonts.rb +32 -0
- data/lib/vimamsa/clipboard.rb +3 -0
- data/lib/vimamsa/conf.rb +59 -3
- data/lib/vimamsa/constants.rb +3 -0
- data/lib/vimamsa/crash_handler.rb +149 -0
- data/lib/vimamsa/debug.rb +4 -1
- data/lib/vimamsa/desktop_install.rb +96 -0
- data/lib/vimamsa/diff_buffer.rb +39 -10
- data/lib/vimamsa/easy_jump.rb +3 -0
- data/lib/vimamsa/editor.rb +263 -57
- data/lib/vimamsa/encrypt.rb +78 -29
- data/lib/vimamsa/file_finder.rb +4 -19
- data/lib/vimamsa/file_history.rb +3 -0
- data/lib/vimamsa/file_manager.rb +30 -15
- data/lib/vimamsa/fold.rb +226 -0
- data/lib/vimamsa/gui.rb +520 -106
- data/lib/vimamsa/gui_command_line.rb +208 -0
- data/lib/vimamsa/gui_dialog.rb +94 -42
- data/lib/vimamsa/gui_file_panel.rb +356 -25
- data/lib/vimamsa/gui_form_generator.rb +59 -35
- data/lib/vimamsa/gui_func_panel.rb +67 -22
- data/lib/vimamsa/gui_image.rb +3 -0
- data/lib/vimamsa/gui_keylog_panel.rb +246 -0
- data/lib/vimamsa/gui_menu.rb +23 -11
- data/lib/vimamsa/gui_select_window.rb +19 -48
- data/lib/vimamsa/gui_settings.rb +78 -37
- data/lib/vimamsa/gui_sourceview.rb +273 -19
- data/lib/vimamsa/gui_sourceview_autocomplete.rb +319 -90
- data/lib/vimamsa/gui_text.rb +63 -2
- data/lib/vimamsa/gui_theme.rb +606 -0
- data/lib/vimamsa/hook.rb +3 -0
- data/lib/vimamsa/hyper_plain_text.rb +3 -0
- data/lib/vimamsa/key_actions.rb +112 -13
- data/lib/vimamsa/key_binding_tree.rb +242 -215
- data/lib/vimamsa/key_bindings_notepad.rb +43 -0
- data/lib/vimamsa/key_bindings_report.rb +261 -0
- data/lib/vimamsa/key_bindings_vim.rb +354 -0
- data/lib/vimamsa/key_bindings_vimlike.rb +65 -9
- data/lib/vimamsa/langservp.rb +271 -54
- data/lib/vimamsa/macro.rb +3 -0
- data/lib/vimamsa/main.rb +14 -8
- data/lib/vimamsa/rbvma.rb +26 -1
- data/lib/vimamsa/search.rb +3 -0
- data/lib/vimamsa/search_replace.rb +11 -10
- data/lib/vimamsa/string_util.rb +120 -40
- data/lib/vimamsa/terminal.rb +3 -0
- data/lib/vimamsa/test_framework.rb +28 -2
- data/lib/vimamsa/tests.rb +3 -0
- data/lib/vimamsa/text_objects.rb +353 -0
- data/lib/vimamsa/text_transforms.rb +14 -0
- data/lib/vimamsa/util.rb +46 -7
- data/lib/vimamsa/version.rb +1 -1
- data/lib/vimamsa.rb +0 -1
- data/modules/color_highlight/color_highlight.rb +118 -0
- data/modules/color_highlight/color_highlight_info.rb +3 -0
- data/modules/dictation/dictation.rb +1054 -0
- data/modules/dictation/dictation_info.rb +3 -0
- data/modules/dictation/whisper_worker.py +273 -0
- data/modules/ollama/ollama.rb +107 -0
- data/modules/ollama/ollama_info.rb +3 -0
- data/modules/tts/tts.rb +119 -0
- data/modules/tts/tts_info.rb +3 -0
- data/run_e2e_vm.sh +28 -0
- data/run_tests_vm.sh +130 -0
- data/scripts/appimage/AppRun +54 -0
- data/scripts/appimage/Dockerfile +18 -0
- data/scripts/appimage/build.sh +19 -0
- data/scripts/appimage/build_in_container.sh +192 -0
- data/scripts/appimage/smoke_test.sh +27 -0
- data/scripts/demo/demo_steps.txt +59 -0
- data/scripts/demo/record_demo.rb +177 -0
- data/scripts/demo/shapes.rb +28 -0
- data/styles/134272-molokai.xml +3 -0
- data/styles/molokai_cyber.xml +48 -0
- data/styles/molokai_edit.xml +1 -0
- data/tests/support/virtual_keyboard.rb +254 -0
- data/tests/support/virtual_mic.rb +67 -0
- data/tests/test_ack.rb +22 -0
- data/tests/test_auto_format.rb +122 -0
- data/tests/test_autocomplete.rb +211 -0
- data/tests/test_autosave.rb +145 -0
- data/tests/test_basic_editing.rb +33 -3
- data/tests/test_bookmarks.rb +206 -0
- data/tests/test_bracket_match.rb +85 -0
- data/tests/test_bundling.rb +92 -0
- data/tests/test_color_highlight.rb +92 -0
- data/tests/test_command_line.rb +79 -0
- data/tests/test_command_line_file.rb +27 -0
- data/tests/test_context_menu_file.rb +129 -0
- data/tests/test_copy_paste.rb +80 -0
- data/tests/test_crash_handler.rb +39 -0
- data/tests/test_custom_two_phase.rb +92 -0
- data/tests/test_dialog_callback_errors.rb +44 -0
- data/tests/test_dictation.rb +294 -0
- data/tests/test_diff_buffer_name.rb +51 -0
- data/tests/test_double_click.rb +41 -0
- data/tests/test_drag_selection.rb +125 -0
- data/tests/test_e2e_cmdline.rb +116 -0
- data/tests/test_e2e_dictation.rb +98 -0
- data/tests/test_e2e_replace_char.rb +58 -0
- data/tests/test_extract_file_links.rb +55 -0
- data/tests/test_file_format.rb +217 -0
- data/tests/test_file_manager.rb +72 -0
- data/tests/test_file_panel.rb +269 -0
- data/tests/test_flash.rb +78 -0
- data/tests/test_fold.rb +111 -0
- data/tests/test_font_refresh.rb +56 -0
- data/tests/test_func_panel.rb +68 -0
- data/tests/test_grep_apply.rb +46 -0
- data/tests/test_gtk_sync.rb +126 -0
- data/tests/test_hpt_highlight_visible.rb +75 -0
- data/tests/test_hpt_link_highlight.rb +82 -0
- data/tests/test_jump_to_file.rb +41 -0
- data/tests/test_key_bindings.rb +208 -0
- data/tests/test_keylog_panel.rb +101 -0
- data/tests/test_lsp_clangd.rb +281 -0
- data/tests/test_lsp_jump.rb +87 -0
- data/tests/test_lsp_position_encoding.rb +49 -0
- data/tests/test_lsp_symbols.rb +68 -0
- data/tests/test_macro.rb +137 -0
- data/tests/test_markdown_highlight.rb +57 -0
- data/tests/test_mode_badge.rb +41 -0
- data/tests/test_notepad_bindings.rb +67 -0
- data/tests/test_popup_queue.rb +51 -0
- data/tests/test_random_edit.rb +109 -0
- data/tests/test_revert.rb +127 -0
- data/tests/test_startup_file.rb +58 -0
- data/tests/test_status_area.rb +50 -0
- data/tests/test_text_objects.rb +163 -0
- data/tests/test_text_transforms.rb +329 -0
- data/tests/test_tts.rb +68 -0
- data/tests/test_vim_bindings.rb +252 -0
- data/tests/test_vim_conflicts.rb +63 -0
- data/tests/test_window_layout.rb +219 -0
- data/vimamsa.gemspec +3 -1
- data/vm_guest_run.sh +109 -0
- metadata +112 -10
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
# Entry point of the Vimamsa AppImage. The AppImage runtime sets $APPDIR (the
|
|
3
|
+
# mounted image) and $APPIMAGE (the .AppImage file). Everything the editor
|
|
4
|
+
# loads comes from the image except the host's glibc, graphics drivers, fonts,
|
|
5
|
+
# X11/Wayland client libraries and sound server (see build_in_container.sh).
|
|
6
|
+
HERE="$(dirname "$(readlink -f "$0")")"
|
|
7
|
+
export APPDIR="${APPDIR:-$HERE}"
|
|
8
|
+
U="$APPDIR/usr"
|
|
9
|
+
ARCH_LIB="$U/lib"
|
|
10
|
+
|
|
11
|
+
# Everything changed below is listed in VMA_APPIMAGE_ENV, with the previous
|
|
12
|
+
# value (if any) in VMA_HOST_<name>. After startup the editor puts those back
|
|
13
|
+
# (restore_host_env, lib/vimamsa/appimage_env.rb), so programs it starts don't
|
|
14
|
+
# inherit the bundle's settings.
|
|
15
|
+
VMA_APPIMAGE_ENV=""
|
|
16
|
+
for n in GEM_HOME GEM_PATH RUBYOPT RUBYLIB BUNDLE_GEMFILE GI_TYPELIB_PATH XDG_DATA_DIRS \
|
|
17
|
+
GSETTINGS_SCHEMA_DIR GIO_MODULE_DIR GST_PLUGIN_SYSTEM_PATH_1_0 \
|
|
18
|
+
GST_PLUGIN_SCANNER_1_0 GST_REGISTRY_1_0 GDK_PIXBUF_MODULE_FILE; do
|
|
19
|
+
if eval "[ -n \"\${$n+x}\" ]"; then eval "export VMA_HOST_$n=\"\$$n\""; fi
|
|
20
|
+
VMA_APPIMAGE_ENV="$VMA_APPIMAGE_ENV $n"
|
|
21
|
+
done
|
|
22
|
+
export VMA_APPIMAGE_ENV
|
|
23
|
+
|
|
24
|
+
# The bundled Ruby and gems only: a user's GEM_HOME / RUBYOPT / RUBYLIB would
|
|
25
|
+
# mix in gems compiled for another Ruby.
|
|
26
|
+
unset GEM_HOME GEM_PATH RUBYOPT RUBYLIB BUNDLE_GEMFILE
|
|
27
|
+
|
|
28
|
+
# Libraries are found through RUNPATH ($ORIGIN), not LD_LIBRARY_PATH, so
|
|
29
|
+
# programs the editor starts (git, ack, a terminal) don't load bundled libs.
|
|
30
|
+
export GI_TYPELIB_PATH="$ARCH_LIB/girepository-1.0"
|
|
31
|
+
export XDG_DATA_DIRS="$U/share:${XDG_DATA_DIRS:-/usr/local/share:/usr/share}"
|
|
32
|
+
export GSETTINGS_SCHEMA_DIR="$U/share/glib-2.0/schemas"
|
|
33
|
+
export GIO_MODULE_DIR="$ARCH_LIB/gio/modules"
|
|
34
|
+
export GST_PLUGIN_SYSTEM_PATH_1_0="$ARCH_LIB/gstreamer-1.0"
|
|
35
|
+
export GST_PLUGIN_SCANNER_1_0="$ARCH_LIB/gstreamer1.0/gstreamer-1.0/gst-plugin-scanner"
|
|
36
|
+
cache="${XDG_CACHE_HOME:-$HOME/.cache}/vimamsa"
|
|
37
|
+
mkdir -p "$cache" 2>/dev/null
|
|
38
|
+
# Own registry: the host's lists the host's plugins
|
|
39
|
+
export GST_REGISTRY_1_0="$cache/gst-registry-appimage.bin"
|
|
40
|
+
|
|
41
|
+
# gdk-pixbuf's loaders.cache must hold absolute paths: fill in where the
|
|
42
|
+
# image is mounted (it changes on every start).
|
|
43
|
+
pixdir="$ARCH_LIB/gdk-pixbuf-2.0/2.10.0"
|
|
44
|
+
if [ -f "$pixdir/loaders.cache.in" ]; then
|
|
45
|
+
pixcache="$cache/gdk-pixbuf-loaders.cache"
|
|
46
|
+
sed "s|@PIXBUF_LOADERS@|$pixdir/loaders|g" "$pixdir/loaders.cache.in" > "$pixcache" 2>/dev/null &&
|
|
47
|
+
export GDK_PIXBUF_MODULE_FILE="$pixcache"
|
|
48
|
+
fi
|
|
49
|
+
|
|
50
|
+
# ruby-lsp and rufo from the bundle (cnf.lsp.server command "ruby-lsp"),
|
|
51
|
+
# without putting the bundled ruby itself first on PATH.
|
|
52
|
+
export PATH="$U/lib/vimamsa/bin:$PATH"
|
|
53
|
+
|
|
54
|
+
exec "$U/bin/ruby" "$U/bin/vimamsa" "$@"
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# Build environment for the Vimamsa AppImage (see doc/bundling_plan.md).
|
|
2
|
+
# Ubuntu 24.04: the bundle carries this GTK (4.14) and needs glibc >= 2.39.
|
|
3
|
+
FROM ubuntu:24.04
|
|
4
|
+
|
|
5
|
+
ENV DEBIAN_FRONTEND=noninteractive
|
|
6
|
+
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
7
|
+
build-essential git pkg-config wget ca-certificates file patchelf binutils \
|
|
8
|
+
autoconf bison libssl-dev libyaml-dev zlib1g-dev libffi-dev libreadline-dev \
|
|
9
|
+
libgdbm-dev libgmp-dev libatk1.0-dev \
|
|
10
|
+
libgtk-4-dev libgtksourceview-5-dev libvte-2.91-gtk4-dev \
|
|
11
|
+
libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libgirepository1.0-dev \
|
|
12
|
+
gir1.2-gtk-4.0 gir1.2-gtksource-5 gir1.2-vte-3.91 gir1.2-gstreamer-1.0 \
|
|
13
|
+
gstreamer1.0-plugins-base gstreamer1.0-plugins-good \
|
|
14
|
+
adwaita-icon-theme hicolor-icon-theme librsvg2-common shared-mime-info \
|
|
15
|
+
dconf-gsettings-backend libglib2.0-bin \
|
|
16
|
+
xvfb xauth
|
|
17
|
+
# (apt lists kept: Ruby-GNOME gems apt-get a -dev package they find missing)
|
|
18
|
+
RUN git config --system --add safe.directory '*'
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# Build the Vimamsa AppImage in an Ubuntu 24.04 container (needs Docker).
|
|
3
|
+
# scripts/appimage/build.sh # builds HEAD
|
|
4
|
+
# VMA_REF=v0.1.26 scripts/appimage/build.sh
|
|
5
|
+
# VMA_REF=WORKTREE scripts/appimage/build.sh # include uncommitted changes
|
|
6
|
+
# Output: build/appimage/Vimamsa-<version>-x86_64.AppImage. The Ruby build and
|
|
7
|
+
# appimagetool are cached in build/appimage/cache. See doc/bundling_plan.md.
|
|
8
|
+
set -euo pipefail
|
|
9
|
+
REPO="$(git -C "$(dirname "$0")" rev-parse --show-toplevel)"
|
|
10
|
+
OUT="$REPO/build/appimage"
|
|
11
|
+
IMAGE=vimamsa-appimage-build
|
|
12
|
+
mkdir -p "$OUT"
|
|
13
|
+
docker build -q -t "$IMAGE" "$REPO/scripts/appimage" >/dev/null
|
|
14
|
+
docker run --rm \
|
|
15
|
+
-v "$REPO:/src:ro" -v "$OUT:/build" \
|
|
16
|
+
-e VMA_REF="${VMA_REF:-HEAD}" -e RUBY_VERSION="${RUBY_VERSION:-3.4.9}" \
|
|
17
|
+
"$IMAGE" bash /src/scripts/appimage/build_in_container.sh
|
|
18
|
+
# Files written in the container belong to root
|
|
19
|
+
docker run --rm -v "$OUT:/build" "$IMAGE" chown -R "$(id -u):$(id -g)" /build
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# Builds build/appimage/Vimamsa-<version>-x86_64.AppImage inside the container
|
|
3
|
+
# from scripts/appimage/Dockerfile. Started by scripts/appimage/build.sh, which
|
|
4
|
+
# mounts the repository read-only at /src and build/appimage at /build.
|
|
5
|
+
#
|
|
6
|
+
# VMA_REF git ref to build (default HEAD), or WORKTREE for HEAD plus uncommitted
|
|
7
|
+
# changes and new files under lib/ modules/ exe/ tests/
|
|
8
|
+
# RUBY_VERSION Ruby to bundle (default 3.4.9; the build is cached in /build/cache)
|
|
9
|
+
set -euo pipefail
|
|
10
|
+
|
|
11
|
+
RUBY_VERSION="${RUBY_VERSION:-3.4.9}"
|
|
12
|
+
VMA_REF="${VMA_REF:-HEAD}"
|
|
13
|
+
SYSLIB=/usr/lib/x86_64-linux-gnu
|
|
14
|
+
B=/build
|
|
15
|
+
CACHE=$B/cache
|
|
16
|
+
APPDIR=$B/AppDir
|
|
17
|
+
U=$APPDIR/usr
|
|
18
|
+
mkdir -p "$CACHE"
|
|
19
|
+
|
|
20
|
+
step() { echo; echo ">> $*"; }
|
|
21
|
+
|
|
22
|
+
# ── 1. Ruby, relocatable (finds its stdlib and gems relative to bin/ruby) ──
|
|
23
|
+
ruby_tar="$CACHE/ruby-$RUBY_VERSION-installed.tar"
|
|
24
|
+
if [ ! -f "$ruby_tar" ]; then
|
|
25
|
+
step "Building Ruby $RUBY_VERSION"
|
|
26
|
+
rm -rf /tmp/rb && mkdir -p /tmp/rb && cd /tmp/rb
|
|
27
|
+
wget -q "https://cache.ruby-lang.org/pub/ruby/${RUBY_VERSION%.*}/ruby-$RUBY_VERSION.tar.gz"
|
|
28
|
+
tar xzf "ruby-$RUBY_VERSION.tar.gz" && cd "ruby-$RUBY_VERSION"
|
|
29
|
+
./configure -q --prefix=/usr --enable-load-relative --enable-shared --disable-install-doc
|
|
30
|
+
make -s -j"$(nproc)" >/dev/null
|
|
31
|
+
make -s install DESTDIR=/tmp/rb/root >/dev/null
|
|
32
|
+
tar cf "$ruby_tar" -C /tmp/rb/root .
|
|
33
|
+
fi
|
|
34
|
+
step "Fresh AppDir"
|
|
35
|
+
rm -rf "$APPDIR" && mkdir -p "$APPDIR"
|
|
36
|
+
tar xf "$ruby_tar" -C "$APPDIR"
|
|
37
|
+
export PATH="$U/bin:$PATH"
|
|
38
|
+
|
|
39
|
+
# ── 2. vimamsa gem + dependencies, compiled against this container's libs ──
|
|
40
|
+
step "Building the vimamsa gem from $VMA_REF"
|
|
41
|
+
rm -rf /tmp/src && git clone -q /src /tmp/src
|
|
42
|
+
cd /tmp/src
|
|
43
|
+
if [ "$VMA_REF" = WORKTREE ]; then
|
|
44
|
+
# Development build: HEAD plus uncommitted changes to tracked files and new
|
|
45
|
+
# source files (not the other untracked files lying around in the checkout)
|
|
46
|
+
(cd /src && { git ls-files -m; git ls-files -o --exclude-standard -- lib modules exe tests; } |
|
|
47
|
+
grep -v '_vma_autosave$' | sort -u | while read -r f; do [ -f "$f" ] && echo "$f"; done) |
|
|
48
|
+
while read -r f; do mkdir -p "$(dirname "$f")"; cp "/src/$f" "$f"; done
|
|
49
|
+
git -c user.name=build -c user.email=build@localhost add -A >/dev/null
|
|
50
|
+
else
|
|
51
|
+
git checkout -q "$VMA_REF"
|
|
52
|
+
fi
|
|
53
|
+
VERSION=$(ruby -Ilib -e 'require "vimamsa/version"; print Vimamsa::VERSION')
|
|
54
|
+
gem build -q vimamsa.gemspec
|
|
55
|
+
step "Installing gems (compiles the native extensions)"
|
|
56
|
+
gem install --no-document "vimamsa-$VERSION.gem"
|
|
57
|
+
GEMDIR=$(ruby -e 'print Gem.default_dir')
|
|
58
|
+
|
|
59
|
+
# ── 3. Typelibs (Ruby-GNOME loads most of the API through them) ──
|
|
60
|
+
step "Typelibs"
|
|
61
|
+
mkdir -p "$U/lib/girepository-1.0"
|
|
62
|
+
cp "$SYSLIB"/girepository-1.0/*.typelib "$U/lib/girepository-1.0/"
|
|
63
|
+
|
|
64
|
+
# ── 4. Runtime modules loaded with dlopen ──
|
|
65
|
+
step "GStreamer plugins, gdk-pixbuf loaders, GIO modules"
|
|
66
|
+
cp -r "$SYSLIB/gstreamer-1.0" "$U/lib/"
|
|
67
|
+
mkdir -p "$U/lib/gstreamer1.0/gstreamer-1.0"
|
|
68
|
+
cp "$SYSLIB/gstreamer1.0/gstreamer-1.0/gst-plugin-scanner" "$U/lib/gstreamer1.0/gstreamer-1.0/"
|
|
69
|
+
pix=$U/lib/gdk-pixbuf-2.0/2.10.0
|
|
70
|
+
mkdir -p "$pix"
|
|
71
|
+
cp -r "$SYSLIB/gdk-pixbuf-2.0/2.10.0/loaders" "$pix/"
|
|
72
|
+
# AppRun fills in the mount point
|
|
73
|
+
sed "s|$SYSLIB/gdk-pixbuf-2.0/2.10.0/loaders|@PIXBUF_LOADERS@|g" \
|
|
74
|
+
"$SYSLIB/gdk-pixbuf-2.0/2.10.0/loaders.cache" > "$pix/loaders.cache.in"
|
|
75
|
+
mkdir -p "$U/lib/gio/modules"
|
|
76
|
+
# dconf: GSettings are saved like in other apps. No gvfs (trash, remote
|
|
77
|
+
# locations in the file chooser) or proxy modules.
|
|
78
|
+
cp "$SYSLIB/gio/modules/libdconfsettings.so" "$U/lib/gio/modules/"
|
|
79
|
+
gio-querymodules "$U/lib/gio/modules"
|
|
80
|
+
|
|
81
|
+
# ── 5. Shared libraries: everything the above needs, except the host's ──
|
|
82
|
+
# Left to the host (as in the AppImage project's excludelist): glibc, the C++
|
|
83
|
+
# runtime, GL/Vulkan/DRM drivers, X11/xcb/Wayland client libs, fontconfig/
|
|
84
|
+
# freetype/harfbuzz (tied to the host's font setup), and the sound servers.
|
|
85
|
+
EXCLUDE='^(ld-linux.*|libc|libm|libmvec|libdl|libpthread|librt|libresolv|libutil|libanl|libnss_.*|libthread_db|libBrokenLocale|libstdc\+\+|libgcc_s|libGL|libGLX|libGLdispatch|libOpenGL|libEGL|libGLESv2|libgbm|libdrm|libvulkan|libX11|libX11-xcb|libxcb|libxcb-dri2|libxcb-dri3|libxcb-glx|libxcb-present|libxcb-sync|libxcb-xfixes|libICE|libSM|libwayland-client|libwayland-cursor|libwayland-egl|libwayland-server|libfontconfig|libfreetype|libharfbuzz|libasound|libjack|libpipewire-0\.3|libpulse|libpulse-simple|libpulsecommon-.*|libz|libexpat|libuuid|libcom_err|libgpg-error|libusb-1\.0)\.so'
|
|
86
|
+
step "Collecting shared libraries"
|
|
87
|
+
declare -A seen
|
|
88
|
+
queue=()
|
|
89
|
+
add() { [ -n "${seen[$1]:-}" ] && return; seen[$1]=1; queue+=("$1"); }
|
|
90
|
+
for f in "$U/bin/ruby" "$U"/lib/libruby.so.*.*; do add "$f"; done
|
|
91
|
+
while IFS= read -r f; do add "$f"; done < <(find "$GEMDIR" "$U/lib/ruby" "$U/lib/gstreamer-1.0" \
|
|
92
|
+
"$U/lib/gstreamer1.0" "$pix" "$U/lib/gio" -type f \( -name '*.so' -o -name gst-plugin-scanner \))
|
|
93
|
+
# Libraries only reached through typelibs (dlopen by soname)
|
|
94
|
+
for t in "$U"/lib/girepository-1.0/*.typelib; do
|
|
95
|
+
for so in $(strings "$t" | grep -E '^lib.*\.so' | tr ',' ' '); do
|
|
96
|
+
if [ -e "$SYSLIB/$so" ]; then add "$SYSLIB/$so"; fi
|
|
97
|
+
done
|
|
98
|
+
done
|
|
99
|
+
i=0
|
|
100
|
+
while [ $i -lt ${#queue[@]} ]; do
|
|
101
|
+
f=${queue[$i]}; i=$((i + 1))
|
|
102
|
+
name=$(basename "$f")
|
|
103
|
+
# (ldd reports /lib/x86_64-linux-gnu/..., the same dir as $SYSLIB on 24.04)
|
|
104
|
+
if [[ "$f" != "$APPDIR"/* ]] && ! [[ "$name" =~ $EXCLUDE ]]; then
|
|
105
|
+
[ -e "$U/lib/$name" ] || cp -L "$f" "$U/lib/$name"
|
|
106
|
+
fi
|
|
107
|
+
while read -r dep; do
|
|
108
|
+
[[ "$(basename "$dep")" =~ $EXCLUDE ]] && continue
|
|
109
|
+
add "$dep"
|
|
110
|
+
done < <(ldd "$f" 2>/dev/null | awk '/=> \//{print $3}')
|
|
111
|
+
done
|
|
112
|
+
|
|
113
|
+
step "Setting RUNPATH so bundled libraries are found without LD_LIBRARY_PATH"
|
|
114
|
+
relpath() { realpath --relative-to="$1" "$U/lib"; }
|
|
115
|
+
while IFS= read -r f; do
|
|
116
|
+
file -b "$f" | grep -q '^ELF' || continue
|
|
117
|
+
d=$(dirname "$f")
|
|
118
|
+
patchelf --set-rpath "\$ORIGIN/$(relpath "$d")" "$f"
|
|
119
|
+
done < <(find "$U/lib" "$U/bin" -type f \( -name '*.so*' -o -name gst-plugin-scanner -o -name ruby \))
|
|
120
|
+
|
|
121
|
+
# Every bundled ELF file must now resolve all its libraries (bundled ones
|
|
122
|
+
# through RUNPATH, the excluded ones from this system)
|
|
123
|
+
missing=$(find "$U/lib" "$U/bin" -type f \( -name '*.so*' -o -name gst-plugin-scanner -o -name ruby \) \
|
|
124
|
+
-exec sh -c 'ldd "$1" 2>/dev/null | grep "not found" | sed "s|^|$1: |"' _ {} \; | sort -u)
|
|
125
|
+
if [ -n "$missing" ]; then echo "!! unresolved libraries:"; echo "$missing"; exit 1; fi
|
|
126
|
+
|
|
127
|
+
# ── 6. Data files ──
|
|
128
|
+
step "Data: GtkSourceView, schemas, icons, MIME database"
|
|
129
|
+
mkdir -p "$U/share/glib-2.0/schemas" "$U/share/icons"
|
|
130
|
+
cp -r /usr/share/gtksourceview-5 "$U/share/"
|
|
131
|
+
cp /usr/share/glib-2.0/schemas/*.xml "$U/share/glib-2.0/schemas/"
|
|
132
|
+
glib-compile-schemas "$U/share/glib-2.0/schemas"
|
|
133
|
+
cp -r /usr/share/icons/Adwaita /usr/share/icons/hicolor "$U/share/icons/"
|
|
134
|
+
# MIME database: GIO's content type guessing, which gdk-pixbuf (image format
|
|
135
|
+
# detection) and GtkSourceView (language detection) rely on
|
|
136
|
+
cp -r /usr/share/mime "$U/share/"
|
|
137
|
+
|
|
138
|
+
# ── 7. Launchers ──
|
|
139
|
+
step "AppRun, desktop entry, icon"
|
|
140
|
+
cp /src/scripts/appimage/AppRun "$APPDIR/AppRun" && chmod +x "$APPDIR/AppRun"
|
|
141
|
+
# ruby-lsp / rufo on PATH without the bundled ruby (see AppRun)
|
|
142
|
+
mkdir -p "$U/lib/vimamsa/bin"
|
|
143
|
+
for t in ruby-lsp rufo; do
|
|
144
|
+
# (the editor has put the user's GEM_HOME etc. back by the time these run)
|
|
145
|
+
printf '#!/bin/sh\nunset GEM_HOME GEM_PATH RUBYOPT RUBYLIB\nexec "$(dirname "$(readlink -f "$0")")/../../../bin/%s" "$@"\n' "$t" > "$U/lib/vimamsa/bin/$t"
|
|
146
|
+
chmod +x "$U/lib/vimamsa/bin/$t"
|
|
147
|
+
done
|
|
148
|
+
cat > "$APPDIR/vimamsa.desktop" <<EOF
|
|
149
|
+
[Desktop Entry]
|
|
150
|
+
Type=Application
|
|
151
|
+
Name=Vimamsa
|
|
152
|
+
Comment=Vi/Vim-inspired GUI text editor
|
|
153
|
+
Exec=vimamsa %F
|
|
154
|
+
Icon=vimamsa
|
|
155
|
+
Terminal=false
|
|
156
|
+
Categories=Utility;TextEditor;
|
|
157
|
+
StartupWMClass=net.samiddhi.vimamsa
|
|
158
|
+
EOF
|
|
159
|
+
cp /tmp/src/icon.png "$APPDIR/vimamsa.png"
|
|
160
|
+
ln -sf vimamsa.png "$APPDIR/.DirIcon"
|
|
161
|
+
|
|
162
|
+
# ── 8. Smoke test, then pack ──
|
|
163
|
+
step "Smoke test: load the editor's libraries from the AppDir"
|
|
164
|
+
# Clean environment (no host GI_TYPELIB_PATH etc.); the libraries must come
|
|
165
|
+
# from the AppDir through RUNPATH
|
|
166
|
+
xvfb-run -a sh -c 'exec env -i HOME=/tmp PATH=/usr/bin:/bin DISPLAY="$DISPLAY" XAUTHORITY="$XAUTHORITY" \
|
|
167
|
+
GI_TYPELIB_PATH="$0/usr/lib/girepository-1.0" "$0/usr/bin/ruby" \
|
|
168
|
+
-e "%w[gtk4 gtksourceview5 vte4 gstreamer].each { |g| require g }; Gst.init; puts %q(gems load OK)"' "$APPDIR"
|
|
169
|
+
|
|
170
|
+
step "Packing"
|
|
171
|
+
# Pinned versions, checked against their SHA-256 (not the moving "continuous"
|
|
172
|
+
# builds): appimagetool and the static type-2 runtime it puts in front of the
|
|
173
|
+
# image (no libfuse2 needed on the user's machine)
|
|
174
|
+
fetch() { # url sha256 dest
|
|
175
|
+
if ! echo "$2 $3" | sha256sum -c --status 2>/dev/null; then
|
|
176
|
+
wget -q -O "$3" "$1"
|
|
177
|
+
echo "$2 $3" | sha256sum -c --quiet || { echo "!! checksum mismatch: $1"; exit 1; }
|
|
178
|
+
fi
|
|
179
|
+
}
|
|
180
|
+
tool=$CACHE/appimagetool-1.9.1-x86_64.AppImage
|
|
181
|
+
runtime=$CACHE/type2-runtime-20251108-x86_64
|
|
182
|
+
fetch https://github.com/AppImage/appimagetool/releases/download/1.9.1/appimagetool-x86_64.AppImage \
|
|
183
|
+
ed4ce84f0d9caff66f50bcca6ff6f35aae54ce8135408b3fa33abfc3cb384eb0 "$tool"
|
|
184
|
+
fetch https://github.com/AppImage/type2-runtime/releases/download/20251108/runtime-x86_64 \
|
|
185
|
+
2fca8b443c92510f1483a883f60061ad09b46b978b2631c807cd873a47ec260d "$runtime"
|
|
186
|
+
chmod +x "$tool"
|
|
187
|
+
out="$B/Vimamsa-$VERSION-x86_64.AppImage"
|
|
188
|
+
# Pack to a temporary name and rename: the previous AppImage may be running
|
|
189
|
+
ARCH=x86_64 APPIMAGE_EXTRACT_AND_RUN=1 "$tool" --no-appstream --runtime-file "$runtime" "$APPDIR" "$out.tmp"
|
|
190
|
+
mv -f "$out.tmp" "$out"
|
|
191
|
+
ls -lh "$out"
|
|
192
|
+
du -sh "$APPDIR"
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# Run an AppImage on a clean Ubuntu 24.04 (no GTK, no Ruby, no typelibs) in
|
|
3
|
+
# Docker, with only the libraries any desktop provides (the ones the bundle
|
|
4
|
+
# leaves to the host), and run a few test files with it.
|
|
5
|
+
# scripts/appimage/smoke_test.sh build/appimage/Vimamsa-0.1.27-x86_64.AppImage
|
|
6
|
+
set -euo pipefail
|
|
7
|
+
APPIMAGE="$(realpath "$1")"
|
|
8
|
+
REPO="$(git -C "$(dirname "$0")" rev-parse --show-toplevel)"
|
|
9
|
+
TESTS="${SMOKE_TESTS:-tests/test_basic_editing.rb tests/test_bundling.rb}"
|
|
10
|
+
|
|
11
|
+
docker run --rm -v "$APPIMAGE:/app/Vimamsa.AppImage:ro" -v "$REPO/tests:/src/tests:ro" \
|
|
12
|
+
-v "$REPO/exe:/src/exe:ro" -e TESTS="$TESTS" ubuntu:24.04 bash -c '
|
|
13
|
+
set -e
|
|
14
|
+
apt-get update -qq >/dev/null
|
|
15
|
+
DEBIAN_FRONTEND=noninteractive apt-get install -y -qq --no-install-recommends \
|
|
16
|
+
xvfb xauth fonts-dejavu-core libfontconfig1 libfreetype6 libharfbuzz0b libgl1 libegl1 \
|
|
17
|
+
libgles2 libx11-6 libx11-xcb1 libxcb1 libwayland-client0 libwayland-cursor0 \
|
|
18
|
+
libwayland-egl1 libasound2t64 libpulse0 >/dev/null
|
|
19
|
+
if ls /usr/lib/x86_64-linux-gnu/libgtk-4* >/dev/null 2>&1 || command -v ruby >/dev/null; then
|
|
20
|
+
echo "!! test box is not clean (GTK or Ruby installed)"; exit 1
|
|
21
|
+
fi
|
|
22
|
+
cd /tmp && cp /app/Vimamsa.AppImage . && ./Vimamsa.AppImage --appimage-extract >/dev/null
|
|
23
|
+
files=$(for t in $TESTS; do echo /src/$t; done)
|
|
24
|
+
timeout 600 xvfb-run -a ./squashfs-root/AppRun --user-dir /tmp/ud --test $files > run.log 2>&1 || true
|
|
25
|
+
grep -E "^ (FAIL|ERROR|SKIP)|Results" run.log || { tail -30 run.log; exit 1; }
|
|
26
|
+
grep -qE "Results: [0-9]+ passed, 0 failed" run.log
|
|
27
|
+
'
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# Key presses for the README demo, run by scripts/demo/record_demo.rb.
|
|
2
|
+
# Times are at --speed 1; the script divides them by its --speed.
|
|
3
|
+
# keys K K ... press keys one at a time (editor key names: esc, enter,
|
|
4
|
+
# space, ctrl (alone), ctrl-r, or xdotool keysyms), with the
|
|
5
|
+
# current delay
|
|
6
|
+
# type TEXT type TEXT character by character (Insert mode)
|
|
7
|
+
# wait SECONDS pause
|
|
8
|
+
# delay SECONDS time between keys from now on
|
|
9
|
+
# The key log panel on the right shows each key and the action it ran.
|
|
10
|
+
|
|
11
|
+
delay 0.45
|
|
12
|
+
wait 1.5
|
|
13
|
+
|
|
14
|
+
# hjkl: move down, right, up, left
|
|
15
|
+
keys j j j l l l l
|
|
16
|
+
keys k h
|
|
17
|
+
wait 0.6
|
|
18
|
+
|
|
19
|
+
# Words: forward, end, back
|
|
20
|
+
keys w w e b
|
|
21
|
+
wait 0.6
|
|
22
|
+
|
|
23
|
+
# Jump to the end, yank a line and paste it, delete it, undo, redo
|
|
24
|
+
keys G k
|
|
25
|
+
wait 0.4
|
|
26
|
+
keys y y p
|
|
27
|
+
wait 0.8
|
|
28
|
+
keys d d
|
|
29
|
+
wait 0.6
|
|
30
|
+
keys u
|
|
31
|
+
wait 0.6
|
|
32
|
+
keys ctrl-r
|
|
33
|
+
wait 0.8
|
|
34
|
+
|
|
35
|
+
# Insert mode: open a new line and type (the mode badge is top right), then
|
|
36
|
+
# back to Command mode by pressing and releasing ctrl alone
|
|
37
|
+
keys o
|
|
38
|
+
delay 0.07
|
|
39
|
+
type puts "Total: #{shapes.sum(&:area).round(1)}"
|
|
40
|
+
delay 0.45
|
|
41
|
+
wait 0.5
|
|
42
|
+
keys ctrl
|
|
43
|
+
wait 1.0
|
|
44
|
+
|
|
45
|
+
# Visual mode: select two words and yank them
|
|
46
|
+
keys 0 v e e
|
|
47
|
+
wait 0.6
|
|
48
|
+
keys y
|
|
49
|
+
wait 0.8
|
|
50
|
+
|
|
51
|
+
# Easy jump (s): every word start gets a label; type one to jump there
|
|
52
|
+
keys s
|
|
53
|
+
wait 1.6
|
|
54
|
+
keys @JUMP_LABEL@
|
|
55
|
+
wait 1.0
|
|
56
|
+
|
|
57
|
+
# Back to the top
|
|
58
|
+
keys g g
|
|
59
|
+
wait 2.0
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# Records the README demo animation (img/demo.gif) on this machine:
|
|
3
|
+
# runs the editor from this checkout on a hidden X display (Xvfb, so the
|
|
4
|
+
# desktop isn't disturbed), types the keys in demo_steps.txt with xdotool
|
|
5
|
+
# (real key events, so the key log panel shows them), records the window with
|
|
6
|
+
# ffmpeg and converts the video to an optimized GIF.
|
|
7
|
+
#
|
|
8
|
+
# ruby scripts/demo/record_demo.rb [--speed 0.7] [--out img/demo.gif] [--keep] [--frame]
|
|
9
|
+
# --speed playback speed: every delay and wait in demo_steps.txt is
|
|
10
|
+
# divided by it (1 = as written, 0.5 = twice as slow).
|
|
11
|
+
# Default 0.7.
|
|
12
|
+
# --keep also keep the lossless video (build/demo/demo.mkv)
|
|
13
|
+
# --frame run the steps up to the easy jump label without recording and
|
|
14
|
+
# save that moment as build/demo/frame.png, to pick the label
|
|
15
|
+
#
|
|
16
|
+
# Needs: Xvfb, xdotool, ffmpeg, gifsicle.
|
|
17
|
+
require "fileutils"
|
|
18
|
+
require "tmpdir"
|
|
19
|
+
require "optparse"
|
|
20
|
+
|
|
21
|
+
ROOT = File.expand_path("../..", __dir__)
|
|
22
|
+
DIR = __dir__
|
|
23
|
+
WIDTH, HEIGHT = 960, 600
|
|
24
|
+
FPS = 15
|
|
25
|
+
GIF_FPS = 12
|
|
26
|
+
# The label easy jump gives the line to jump to (find it with --frame)
|
|
27
|
+
JUMP_LABEL = %w[f s]
|
|
28
|
+
|
|
29
|
+
opts = { out: File.join(ROOT, "img/demo.gif"), keep: false, frame: false, speed: 0.7 }
|
|
30
|
+
OptionParser.new { |o|
|
|
31
|
+
o.on("--speed FACTOR", Float) { |v| opts[:speed] = v }
|
|
32
|
+
o.on("--out PATH") { |v| opts[:out] = File.expand_path(v) }
|
|
33
|
+
o.on("--keep") { opts[:keep] = true }
|
|
34
|
+
o.on("--frame") { opts[:frame] = true }
|
|
35
|
+
}.parse!
|
|
36
|
+
abort "--speed must be > 0" unless opts[:speed] > 0
|
|
37
|
+
SPEED = opts[:speed]
|
|
38
|
+
|
|
39
|
+
%w[Xvfb xdotool ffmpeg gifsicle].each { |t|
|
|
40
|
+
abort "#{t} not found (sudo apt install xvfb xdotool ffmpeg gifsicle)" unless system("which #{t} >/dev/null")
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
WORK = File.join(ROOT, "build/demo")
|
|
44
|
+
FileUtils.mkdir_p(WORK)
|
|
45
|
+
pids = []
|
|
46
|
+
at_exit { pids.reverse_each { |pid| Process.kill("TERM", pid) rescue nil; Process.wait(pid) rescue nil } }
|
|
47
|
+
|
|
48
|
+
def sh!(*cmd)
|
|
49
|
+
system(*cmd) or abort "failed: #{cmd.join(" ")}"
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
# ── Hidden X display. The editor's first-start size is 90% of the screen, so
|
|
53
|
+
# this screen gives a WIDTH x HEIGHT window. ──
|
|
54
|
+
display = (90..99).find { |n| !File.exist?("/tmp/.X#{n}-lock") } or abort "no free X display"
|
|
55
|
+
disp = ":#{display}"
|
|
56
|
+
screen = "#{(WIDTH / 0.9).ceil}x#{(HEIGHT / 0.9).ceil}x24"
|
|
57
|
+
pids << spawn("Xvfb", disp, "-screen", "0", screen, "-nolisten", "tcp", out: File::NULL, err: File::NULL)
|
|
58
|
+
sleep 0.2 until File.exist?("/tmp/.X11-unix/X#{display}")
|
|
59
|
+
|
|
60
|
+
env = { "DISPLAY" => disp, "GDK_BACKEND" => "x11", "WAYLAND_DISPLAY" => nil,
|
|
61
|
+
"GTK_THEME" => nil, "NO_AT_BRIDGE" => "1" }
|
|
62
|
+
|
|
63
|
+
# ── The editor, with a throwaway config dir: default settings plus the key
|
|
64
|
+
# log panel, and nothing read from or written to the user's own config ──
|
|
65
|
+
ud = Dir.mktmpdir("vma-demo")
|
|
66
|
+
at_exit { FileUtils.rm_rf(ud) }
|
|
67
|
+
File.write(File.join(ud, "custom.rb"), <<~RUBY)
|
|
68
|
+
cnf.lsp.enabled = false
|
|
69
|
+
def hook_custom_after_init
|
|
70
|
+
vma.gui.toggle_keylog_panel
|
|
71
|
+
end
|
|
72
|
+
RUBY
|
|
73
|
+
# A short path for the title bar
|
|
74
|
+
demo_dir = "/tmp/vimamsa-demo"
|
|
75
|
+
FileUtils.rm_rf(demo_dir)
|
|
76
|
+
FileUtils.mkdir_p(demo_dir)
|
|
77
|
+
at_exit { FileUtils.rm_rf(demo_dir) }
|
|
78
|
+
file = File.join(demo_dir, "shapes.rb")
|
|
79
|
+
FileUtils.cp(File.join(DIR, "shapes.rb"), file)
|
|
80
|
+
pids << spawn(env, RbConfig.ruby, File.join(ROOT, "exe/vimamsa"), "--user-dir", ud, file,
|
|
81
|
+
chdir: demo_dir, out: File.join(WORK, "editor.log"), err: [:child, :out])
|
|
82
|
+
|
|
83
|
+
def xdo(env, *args)
|
|
84
|
+
out = IO.popen(env, ["xdotool", *args], err: File::NULL, &:read)
|
|
85
|
+
$?.success? ? out : nil
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
win = nil
|
|
89
|
+
60.times {
|
|
90
|
+
win = xdo(env, "search", "--onlyvisible", "--name", "^Vimamsa")&.split&.last
|
|
91
|
+
break if win
|
|
92
|
+
sleep 0.5
|
|
93
|
+
}
|
|
94
|
+
abort "editor window did not appear (log: #{WORK}/editor.log)" unless win
|
|
95
|
+
sleep 3 # first layout, highlighting, key log panel
|
|
96
|
+
xdo(env, "windowfocus", "--sync", win)
|
|
97
|
+
geo = xdo(env, "getwindowgeometry", "--shell", win).scan(/(\w+)=(\d+)/).to_h.transform_values(&:to_i)
|
|
98
|
+
x, y = geo["X"], geo["Y"]
|
|
99
|
+
w, h = geo["WIDTH"] & ~1, geo["HEIGHT"] & ~1 # even sizes for the encoder
|
|
100
|
+
puts "window #{w}x#{h} at #{x},#{y}"
|
|
101
|
+
|
|
102
|
+
# Editor key names to xdotool keysyms
|
|
103
|
+
KEYSYMS = { "ctrl" => "Control_L", "esc" => "Escape", "enter" => "Return", "space" => "space", "tab" => "Tab",
|
|
104
|
+
"backspace" => "BackSpace", "$" => "dollar", "0" => "0" }
|
|
105
|
+
def press(env, key)
|
|
106
|
+
k = key.sub(/\Actrl-/, "ctrl+").sub(/\Ashift-/, "shift+")
|
|
107
|
+
k = KEYSYMS.fetch(k, k)
|
|
108
|
+
xdo(env, "key", "--clearmodifiers", k) or abort "xdotool key #{k} failed"
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
def grab_png(disp, x, y, w, h, png)
|
|
112
|
+
sh!("ffmpeg", "-loglevel", "error", "-y", "-f", "x11grab", "-video_size", "#{w}x#{h}",
|
|
113
|
+
"-draw_mouse", "0", "-i", "#{disp}+#{x},#{y}", "-frames:v", "1", png)
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
# Runs demo_steps.txt. With stop_at_label, returns just before the easy
|
|
117
|
+
# jump label would be typed.
|
|
118
|
+
def run_steps(env, stop_at_label: false)
|
|
119
|
+
delay = 0.4 / SPEED
|
|
120
|
+
File.readlines(File.join(DIR, "demo_steps.txt"), chomp: true).each { |line|
|
|
121
|
+
line = line.sub(/\s+#\s.*\z/, "") unless line.start_with?("type ")
|
|
122
|
+
next if line.strip.empty? || line.start_with?("#")
|
|
123
|
+
cmd, arg = line.split(" ", 2)
|
|
124
|
+
case cmd
|
|
125
|
+
when "wait" then sleep arg.to_f / SPEED
|
|
126
|
+
when "delay" then delay = arg.to_f / SPEED
|
|
127
|
+
when "keys"
|
|
128
|
+
keys = arg.split
|
|
129
|
+
return if stop_at_label && keys.include?("@JUMP_LABEL@")
|
|
130
|
+
keys = keys.flat_map { |k| k == "@JUMP_LABEL@" ? JUMP_LABEL : [k] }
|
|
131
|
+
keys.each { |k| press(env, k); sleep delay }
|
|
132
|
+
when "type"
|
|
133
|
+
arg.each_char { |c|
|
|
134
|
+
xdo(env, "type", "--delay", "0", c) or abort "xdotool type failed"
|
|
135
|
+
sleep delay
|
|
136
|
+
}
|
|
137
|
+
else abort "demo_steps.txt: unknown command #{line.inspect}"
|
|
138
|
+
end
|
|
139
|
+
}
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
if opts[:frame]
|
|
143
|
+
run_steps(env, stop_at_label: true)
|
|
144
|
+
png = File.join(WORK, "frame.png")
|
|
145
|
+
grab_png(disp, x, y, w, h, png)
|
|
146
|
+
puts "saved #{png}"
|
|
147
|
+
exit
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
# ── Record ──
|
|
151
|
+
video = File.join(WORK, "demo.mkv")
|
|
152
|
+
rec = spawn("ffmpeg", "-loglevel", "warning", "-nostdin", "-y", "-f", "x11grab", "-framerate", FPS.to_s,
|
|
153
|
+
"-video_size", "#{w}x#{h}", "-draw_mouse", "0", "-i", "#{disp}+#{x},#{y}",
|
|
154
|
+
"-c:v", "libx264rgb", "-crf", "0", "-preset", "ultrafast", video)
|
|
155
|
+
sleep 0.5
|
|
156
|
+
run_steps(env)
|
|
157
|
+
Process.kill("INT", rec)
|
|
158
|
+
Process.wait(rec)
|
|
159
|
+
# ffmpeg exits 255 when stopped with INT; anything else is an error
|
|
160
|
+
abort "recording failed (ffmpeg exit #{$?.exitstatus})" unless [0, 255].include?($?.exitstatus)
|
|
161
|
+
system("ffmpeg", "-v", "error", "-i", video, "-f", "null", "-", err: File.join(WORK, "decode.log"))
|
|
162
|
+
abort "the recorded video is damaged: #{File.read(File.join(WORK, "decode.log"))[0, 300]}" unless File.size(File.join(WORK, "decode.log")).zero?
|
|
163
|
+
|
|
164
|
+
# ── GIF: one palette for the whole clip, only changed rectangles stored ──
|
|
165
|
+
palette = File.join(WORK, "palette.png")
|
|
166
|
+
filters = "fps=#{GIF_FPS}"
|
|
167
|
+
sh!("ffmpeg", "-loglevel", "error", "-y", "-i", video,
|
|
168
|
+
"-vf", "#{filters},palettegen=max_colors=128:stats_mode=diff", palette)
|
|
169
|
+
raw_gif = File.join(WORK, "demo_raw.gif")
|
|
170
|
+
sh!("ffmpeg", "-loglevel", "error", "-y", "-i", video, "-i", palette, "-lavfi",
|
|
171
|
+
"#{filters}[v];[v][1:v]paletteuse=dither=none:diff_mode=rectangle", raw_gif)
|
|
172
|
+
FileUtils.mkdir_p(File.dirname(opts[:out]))
|
|
173
|
+
sh!("gifsicle", "-O3", "--lossy=30", "-o", opts[:out], raw_gif)
|
|
174
|
+
FileUtils.rm_f([palette, raw_gif])
|
|
175
|
+
FileUtils.rm_f(video) unless opts[:keep]
|
|
176
|
+
dur = IO.popen(["ffprobe", "-v", "error", "-show_entries", "format=duration", "-of", "csv=p=0", opts[:out]], &:read).to_f
|
|
177
|
+
puts "wrote #{opts[:out]} at speed #{SPEED} (#{(File.size(opts[:out]) / 1024.0 / 1024).round(2)} MB, #{dur.round(1)} s)"
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# Example file for the README demo
|
|
2
|
+
class Shape
|
|
3
|
+
def initialize(name)
|
|
4
|
+
@name = name
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
def area
|
|
8
|
+
0
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def to_s
|
|
12
|
+
"#{@name}: #{area.round(2)}"
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
class Circle < Shape
|
|
17
|
+
def initialize(radius)
|
|
18
|
+
super("circle")
|
|
19
|
+
@radius = radius
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def area
|
|
23
|
+
Math::PI * @radius**2
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
shapes = [Circle.new(1), Circle.new(2.5)]
|
|
28
|
+
shapes.each { |s| puts s }
|
data/styles/134272-molokai.xml
CHANGED
|
@@ -29,5 +29,8 @@
|
|
|
29
29
|
<style foreground="#465457" name="def:comment"/>
|
|
30
30
|
<style background="#3e3d32" name="current-line"/>
|
|
31
31
|
<style background="#3b3a32" foreground="#bcbca7" name="line-numbers"/>
|
|
32
|
+
<style name="def:hyperlink" foreground="lightblue" bold="true" />
|
|
33
|
+
<style name="def:bold" bold="true" />
|
|
34
|
+
<style name="def:emphasis" italic="true" />
|
|
32
35
|
</style-scheme>
|
|
33
36
|
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
<?xml version="1.0" ?>
|
|
2
|
+
<style-scheme id="molokai_cyber" name="Molokai_cyber" version="1.0">
|
|
3
|
+
<color name="lightblue" value="#00FFF8"/>
|
|
4
|
+
|
|
5
|
+
<author/>
|
|
6
|
+
<_description>
|
|
7
|
+
Molokai variant with navy backgrounds to match the Cyberpunk glow GUI theme.
|
|
8
|
+
</_description>
|
|
9
|
+
|
|
10
|
+
<color name="heading" value="#ffffff" />
|
|
11
|
+
<style name="selection" foreground="#ffffff" background="#10bd8e"/>
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
<style foreground="#AE81FF" name="def:boolean"/>
|
|
15
|
+
<style foreground="#AE81FF" name="def:number"/>
|
|
16
|
+
<style foreground="#E6DB74" name="def:string"/>
|
|
17
|
+
<style bold="true" foreground="#AE81FF" name="def:constant"/>
|
|
18
|
+
<style background="#F8F8F0" foreground="#ffffff" name="cursor"/>
|
|
19
|
+
<style background="#13354A" name="diff:added-line"/>
|
|
20
|
+
<style background="#4C4745" foreground="#89807D" name="diff:changed-line"/>
|
|
21
|
+
<style background="#1E0010" foreground="#960050" name="diff:removed-line"/>
|
|
22
|
+
<style background="#1E0010" foreground="#960050" name="def:error"/>
|
|
23
|
+
<style foreground="#A6E22E" name="def:function"/>
|
|
24
|
+
<style foreground="#FD971F" name="def:identifier"/>
|
|
25
|
+
<style bold="true" foreground="#F92672" name="def:keyword"/>
|
|
26
|
+
<style background="#FD971F" bold="true" foreground="#000000" name="bracket-match"/>
|
|
27
|
+
<style foreground="#A6E22E" name="def:preprocessor"/>
|
|
28
|
+
<style background="#455354" foreground="#FFFFFF" name="search-match"/>
|
|
29
|
+
<style background="#bg" foreground="#66D9EF" italic="true" name="def:specials"/>
|
|
30
|
+
<style bold="true" foreground="#F92672" name="def:statement"/>
|
|
31
|
+
<style foreground="#66D9EF" name="def:type"/>
|
|
32
|
+
<style background="#0b0c0c" foreground="#F8F8F2" name="text"/>
|
|
33
|
+
<style foreground="#b0b0b0" name="def:comment"/>
|
|
34
|
+
<style background="#141d33" name="current-line"/>
|
|
35
|
+
<style background="#0b0c0c" foreground="#8fb0b8" name="line-numbers"/>
|
|
36
|
+
|
|
37
|
+
<style name="def:title" scale="2.0" bold="true" />
|
|
38
|
+
<style name="def:hyperlink" foreground="lightblue" bold="true" />
|
|
39
|
+
<style name="def:heading0" scale="2.0" bold="true" foreground="heading" />
|
|
40
|
+
<style name="def:heading1" scale="1.75" bold="true" foreground="heading" underline="true" />
|
|
41
|
+
<style name="def:heading2" scale="1.5" foreground="heading" underline="single" />
|
|
42
|
+
<style name="def:heading3" scale="1.25" bold="true" foreground="heading" />
|
|
43
|
+
<style name="def:heading4" scale="1.175" bold="true" foreground="heading" />
|
|
44
|
+
<style name="def:heading5" scale="1.1" bold="true" foreground="heading" />
|
|
45
|
+
<style name="def:heading6" scale="1.0" bold="true" foreground="heading" />
|
|
46
|
+
<style name="def:bold" bold="true" />
|
|
47
|
+
<style name="def:emphasis" italic="true" />
|
|
48
|
+
</style-scheme>
|
data/styles/molokai_edit.xml
CHANGED
|
@@ -48,5 +48,6 @@
|
|
|
48
48
|
<style name="def:heading5" scale="1.1" bold="true" foreground="heading" />
|
|
49
49
|
<style name="def:heading6" scale="1.0" bold="true" foreground="heading" />
|
|
50
50
|
<style name="def:bold" bold="true" />
|
|
51
|
+
<style name="def:emphasis" italic="true" />
|
|
51
52
|
</style-scheme>
|
|
52
53
|
|