rubyterm 0.1.0 → 0.1.1
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/README.md +25 -8
- data/example-config.toml +8 -0
- data/lib/keymap.rb +10 -7
- data/lib/rubyterm/app.rb +2 -1
- data/lib/rubyterm/engine.rb +23 -0
- data/lib/rubyterm/version.rb +1 -1
- data/lib/rubyterm.rb +12 -26
- data/lib/window.rb +6 -1
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: eaf865731aa7f369f532b56ea31e90fc542a1d0ce88c649bd39a336614bcd446
|
|
4
|
+
data.tar.gz: 32daf9da2882ba26c505ceaecb41502a9a140005e0120c3d0036d64a3056a628
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8d6e3a1b56ecf612e5f5f8058b0f57e030ee03159629899825cf8ea804dc32839f68cb529f10ae93bcb160dc52774a075509fdd10f6a4e12b11cc574fc57de8c
|
|
7
|
+
data.tar.gz: adcc26061be88db1f5da30f369b01f64f38e01fcb117118e37fb0581176e0b851d66305a28b3f2a2a7822ae8503e26fcdbe45c14b4d5c2657bcb3a52ea310a92
|
data/README.md
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
# rubyterm
|
|
2
2
|
|
|
3
3
|
A terminal emulator written **entirely in Ruby** — including a pure-Ruby
|
|
4
|
-
X11 client to talk to the X server
|
|
5
|
-
|
|
4
|
+
X11 client to talk to the X server and a pure-Ruby font renderer.
|
|
5
|
+
|
|
6
|
+
There is no C extension and no libvte; the escape-sequence interpreter, the screen buffer, the rendering and the
|
|
6
7
|
X11 protocol handling are all Ruby.
|
|
7
8
|
|
|
8
9
|
It is still rough and opinionated, but it now runs as an installable gem
|
|
@@ -11,13 +12,18 @@ with a `rubyterm` executable, renders with a damage-driven pipeline
|
|
|
11
12
|
split into a reusable terminal *engine* that can be driven without X11 at
|
|
12
13
|
all.
|
|
13
14
|
|
|
14
|
-
> **
|
|
15
|
-
> is
|
|
16
|
-
> basic, and the keymap is limited. Full-screen apps mostly work; some will
|
|
15
|
+
> **NOTE**: Escape-code coverage is partial (VT100/VT102 plus a useful chunk of xterm), font handling is
|
|
16
|
+
> basic, and the keymap is limited. It is *slow*, though it is my main driver. Full-screen apps mostly work; some will
|
|
17
17
|
> still misbehave. I have specific ideas about direction, so if you'd like
|
|
18
18
|
> to contribute, **talk to me first** (vidar@hokstad.com) or fork — I won't
|
|
19
19
|
> promise to merge changes we haven't discussed.
|
|
20
20
|
|
|
21
|
+
## Screenshots of Ruby-in-Ruby-in-Ruby-...
|
|
22
|
+
|
|
23
|
+

|
|
24
|
+
|
|
25
|
+
This shows Rubyterm running on my [Ruby based WM](https://github/vidarh/rubywm), running [Rubyterm with a text-based-backend](examples/) that renders a a terminal *to text* (so it can run in any terminal), running my [editor Re](https://github.com/vidarh/re) editing the Rubyterm example. The text is rendered using the pure-Ruby TrueType font renderer [Skrift](https://github.com/vidarh/re), and connected to my X11 server using the [Pure-X11](https://github.com/vidarh/ruby-x11) Ruby X11 bindings (no libX or XCB, just pure Ruby socket code).
|
|
26
|
+
|
|
21
27
|
## Architecture
|
|
22
28
|
|
|
23
29
|
The code is deliberately small and split along clean seams so the pieces
|
|
@@ -51,14 +57,21 @@ For the full picture and the rationale behind the layering, see:
|
|
|
51
57
|
|
|
52
58
|
## Installation
|
|
53
59
|
|
|
54
|
-
Dependencies are managed with Bundler
|
|
55
|
-
developed alongside this project and are referenced as local path gems in
|
|
56
|
-
the `Gemfile`.
|
|
60
|
+
Dependencies are managed with Bundler.
|
|
57
61
|
|
|
58
62
|
```bash
|
|
59
63
|
bundle install
|
|
60
64
|
```
|
|
61
65
|
|
|
66
|
+
`skrift` and `skrift-x11` are developed alongside this project and are
|
|
67
|
+
pulled from git. To build against a local checkout instead of the pushed
|
|
68
|
+
branch, set a per-machine local override (kept out of the repo):
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
bundle config set --global local.skrift /path/to/skrift
|
|
72
|
+
bundle config set --global local.skrift-x11 /path/to/skrift-x11
|
|
73
|
+
```
|
|
74
|
+
|
|
62
75
|
## Running
|
|
63
76
|
|
|
64
77
|
```bash
|
|
@@ -83,6 +96,10 @@ file is absent, defaults are used.
|
|
|
83
96
|
(`"~/fonts/MyFont.ttf"`), a file in `~/.local/share/fonts/`, or a name
|
|
84
97
|
resolved via `fc-match` (`"monospace"`, `"monospace:weight=bold"`).
|
|
85
98
|
- **`fontsize`** — font size in points (e.g. `fontsize = 24`).
|
|
99
|
+
- **`width`** / **`height`** — initial window size in pixels; the terminal
|
|
100
|
+
grid is derived from it and the font cell size. Defaults to `1000 x 600`
|
|
101
|
+
(~80×24 at the default font); on a big display, e.g. `width = 2000` /
|
|
102
|
+
`height = 1200`.
|
|
86
103
|
- **`deccolm`** — how the 80/132-column DECCOLM switch is realised:
|
|
87
104
|
`"font"` (rescale the glyph cell, the default) or `"window"` (ask the WM
|
|
88
105
|
to resize).
|
data/example-config.toml
CHANGED
|
@@ -46,6 +46,14 @@ fontsize = 32
|
|
|
46
46
|
|
|
47
47
|
shell="/home/vidarh/bin/rsh"
|
|
48
48
|
|
|
49
|
+
# Initial window size in pixels. The terminal grid (columns x rows) is
|
|
50
|
+
# derived from this and the font's cell size, so a bigger window opens a
|
|
51
|
+
# bigger terminal. Omit either to use the default (1000 x 600, ~80x24 at
|
|
52
|
+
# the default font). On a large display you might e.g. double them:
|
|
53
|
+
#
|
|
54
|
+
#width = 2000
|
|
55
|
+
#height = 1200
|
|
56
|
+
|
|
49
57
|
# DECCOLM (the 80/132-column switch, ESC [ ? 3 h / l) is supported. Choose
|
|
50
58
|
# how the column change is realised:
|
|
51
59
|
#
|
data/lib/keymap.rb
CHANGED
|
@@ -87,13 +87,16 @@ KEYMAP = {
|
|
|
87
87
|
:f3 => "\e[13~",
|
|
88
88
|
:f4 => "\e[14~",
|
|
89
89
|
:f5 => "\e[15~",
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
:
|
|
94
|
-
:
|
|
95
|
-
:
|
|
96
|
-
:
|
|
90
|
+
# VT220/xterm/rxvt skip codes 16, 22, 27, 30, ... so F6+ are not
|
|
91
|
+
# consecutive with F5. These must match the kf6..kf12 terminfo entries
|
|
92
|
+
# for TERM (rxvt-256color), or apps like htop won't recognise the keys.
|
|
93
|
+
:f6 => "\e[17~",
|
|
94
|
+
:f7 => "\e[18~",
|
|
95
|
+
:f8 => "\e[19~",
|
|
96
|
+
:f9 => "\e[20~",
|
|
97
|
+
:f10 => "\e[21~",
|
|
98
|
+
:f11 => "\e[23~",
|
|
99
|
+
:f12 => "\e[24~",
|
|
97
100
|
:shift_up => "\e[1;2A",
|
|
98
101
|
:shift_down => "\e[1;2B",
|
|
99
102
|
:shift_tab => "\e[Z",
|
data/lib/rubyterm/app.rb
CHANGED
|
@@ -47,7 +47,8 @@ class RubyTerm
|
|
|
47
47
|
# :window asks the WM to resize the window. Default :font.
|
|
48
48
|
@deccolm_mode = (@config[:deccolm] || "font").to_s.to_sym
|
|
49
49
|
|
|
50
|
-
@window = Window.new(fonts: @config[:fonts], fontsize: @config[:fontsize]
|
|
50
|
+
@window = Window.new(fonts: @config[:fonts], fontsize: @config[:fontsize],
|
|
51
|
+
width: @config[:width], height: @config[:height])
|
|
51
52
|
@adapter = WindowAdapter.new(@window, self)
|
|
52
53
|
|
|
53
54
|
# Yes, this is "bad" and we should define our
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# rubyterm engine — the reusable terminal core WITHOUT the X11 front end.
|
|
4
|
+
#
|
|
5
|
+
# Loads the escape interpreter (Term), the screen buffer (TermBuffer), the
|
|
6
|
+
# damage tracker (TrackChanges), the escape/UTF-8 parsers, and the ANSI
|
|
7
|
+
# backend (AnsiBackend). None of these depend on X11 or skrift, so a TUI
|
|
8
|
+
# application (e.g. an editor) can drive the buffer and emit minimal escape
|
|
9
|
+
# sequences without being an X client.
|
|
10
|
+
#
|
|
11
|
+
# `require "rubyterm"` loads this and then adds the X11 front end on top.
|
|
12
|
+
|
|
13
|
+
require "set"
|
|
14
|
+
|
|
15
|
+
require_relative "version"
|
|
16
|
+
require_relative "../palette" # PALETTE_BASIC, PALETTE256, FG, BG
|
|
17
|
+
require_relative "../charsets"
|
|
18
|
+
require_relative "../escapeparser"
|
|
19
|
+
require_relative "../utf8decoder"
|
|
20
|
+
require_relative "../termbuffer"
|
|
21
|
+
require_relative "../trackchanges"
|
|
22
|
+
require_relative "../term"
|
|
23
|
+
require_relative "../ansibackend"
|
data/lib/rubyterm/version.rb
CHANGED
data/lib/rubyterm.rb
CHANGED
|
@@ -5,41 +5,27 @@
|
|
|
5
5
|
# Requiring "rubyterm" loads the whole stack:
|
|
6
6
|
#
|
|
7
7
|
# * the terminal *engine* - escape interpreter, virtual buffer, damage
|
|
8
|
-
# tracking and the
|
|
9
|
-
# AnsiBackend
|
|
10
|
-
#
|
|
11
|
-
#
|
|
8
|
+
# tracking and the ANSI backend (Term, TrackChanges, TermBuffer,
|
|
9
|
+
# AnsiBackend); usable headlessly / embedded in a TUI. This is
|
|
10
|
+
# "rubyterm/engine" and carries NO X11/skrift dependency; and
|
|
11
|
+
# * the X11 *front end* - the Window/BitmapWindow backends, pty Controller,
|
|
12
|
+
# keymap and the RubyTerm application class that bin/rubyterm runs.
|
|
12
13
|
#
|
|
13
|
-
#
|
|
14
|
-
#
|
|
15
|
-
# runnable terminal. (They are pure Ruby, so requiring them needs no running
|
|
16
|
-
# X server - only instantiating Window does.)
|
|
14
|
+
# A TUI application that only needs the core can `require "rubyterm/engine"`
|
|
15
|
+
# instead and avoid pulling in X11/skrift.
|
|
17
16
|
|
|
17
|
+
require_relative "rubyterm/engine"
|
|
18
|
+
|
|
19
|
+
# X11 front end and its dependencies (pure Ruby, so requiring them needs no
|
|
20
|
+
# running X server - only instantiating Window does).
|
|
18
21
|
require "pty"
|
|
19
22
|
require "io/console"
|
|
20
|
-
require "set"
|
|
21
|
-
|
|
22
23
|
require "X11"
|
|
23
24
|
require "skrift"
|
|
24
25
|
require "skrift/x11"
|
|
25
26
|
require "toml-rb"
|
|
26
27
|
|
|
27
|
-
require_relative "
|
|
28
|
-
|
|
29
|
-
# Engine
|
|
30
|
-
require_relative "palette"
|
|
31
|
-
require_relative "charsets"
|
|
32
|
-
require_relative "escapeparser"
|
|
33
|
-
require_relative "utf8decoder"
|
|
34
|
-
require_relative "termbuffer"
|
|
35
|
-
require_relative "trackchanges"
|
|
36
|
-
require_relative "term"
|
|
37
|
-
|
|
38
|
-
# Backends
|
|
39
|
-
require_relative "ansibackend"
|
|
40
|
-
require_relative "bitmapwindow"
|
|
41
|
-
|
|
42
|
-
# X11 front end
|
|
28
|
+
require_relative "bitmapwindow" # skrift glyph -> bitmap backend
|
|
43
29
|
require_relative "keymap"
|
|
44
30
|
require_relative "window"
|
|
45
31
|
require_relative "windowadapter"
|
data/lib/window.rb
CHANGED
|
@@ -114,7 +114,12 @@ class Window
|
|
|
114
114
|
|
|
115
115
|
@visual = @dpy.find_visual(0, 32).visual_id
|
|
116
116
|
|
|
117
|
-
|
|
117
|
+
# Initial window size in pixels. The terminal grid (cols x rows) is
|
|
118
|
+
# derived from this by the configure/resize path, so a larger window
|
|
119
|
+
# opens a larger terminal. Configurable via the `width`/`height` config
|
|
120
|
+
# keys; defaults sized to roughly 80x24 at the default font.
|
|
121
|
+
@width = (opts[:width] || 1000).to_i
|
|
122
|
+
@height = (opts[:height] || 600).to_i
|
|
118
123
|
|
|
119
124
|
@wid = @dpy.create_window(
|
|
120
125
|
0, 0, @width, @height,
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rubyterm
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Vidar Hokstad
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-06-
|
|
11
|
+
date: 2026-06-19 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: pure-x11
|
|
@@ -93,6 +93,7 @@ files:
|
|
|
93
93
|
- lib/palette.rb
|
|
94
94
|
- lib/rubyterm.rb
|
|
95
95
|
- lib/rubyterm/app.rb
|
|
96
|
+
- lib/rubyterm/engine.rb
|
|
96
97
|
- lib/rubyterm/version.rb
|
|
97
98
|
- lib/term.rb
|
|
98
99
|
- lib/termbuffer.rb
|