filecon 0.3.0 → 0.4.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: df1c9b636fd924aa180e49679581afcb96338d18d854ab359046cbf91e048642
4
- data.tar.gz: deb0a271ed914d69e8d4c7a138a83a1d7942c5a451de227b9c23d3637dea89f3
3
+ metadata.gz: 27fa8d3a100f9d752db3fde969136cb2c1435c809970691629e46e0c897b2a46
4
+ data.tar.gz: 87bd4e4845433cbda8c0c35f70c4e7dcc94ff95c026cfa0f84fd9cecc211201d
5
5
  SHA512:
6
- metadata.gz: cdd7f22ae47392a10f1485dad5fdebd98860604e28bac74e214a13ca9b3d9b4f0b838878e8e523f827c91d724246c620fb8c526dcfbe97fb67817c4d3253bc40
7
- data.tar.gz: 75e4a171320400619c0923ed985c9b93f598c454477cec23adad90b78adad58e2f8533e7ff535ac428c595cf39f26c212b7a709c173fc4802b4a405ab54cd6c0
6
+ metadata.gz: 9cc34718bdfdd72ebbadf9cf91cd3d654df2ac6b5350c9c9160ba03577d692541e8d117ead9452cba6f1a5b8f9a05a3195691a53caccce496b8790e53ed7e5eb
7
+ data.tar.gz: 4ddf3aefa8c71081089b61ebfc03a731c31f763478310091aa5cce43ff1aa16bc129a1e158c5620f7aad17b7a917090fd14ae22cb61ec435f61f44f8b6a372f8
data/CHANGELOG.md ADDED
@@ -0,0 +1,156 @@
1
+ # Changelog
2
+
3
+ ## [vx.y.z] — __DATE__
4
+
5
+ ## [v0.4.0] — 2026-09-05
6
+
7
+ ### Added
8
+ - Shell TAB completion in the command editor — alt+hint opens the edit line with live completions from the shell's completion system, shown in a pickable grid above the input
9
+ - Clickable bottom bar and head — clicking a binding label on the status line runs that action, and clicking the filter/sort/views columns of the head opens the corresponding popup
10
+ - Two-pane help — `h` shows the clickable keybinding grid (the line's `list`) beside the help text; Filecon composes the HELP panel itself, mirrors wheel/arrow navigation to both panels, and clicking a binding row returns its trigger key
11
+ - Clicking outside a popup dismisses it — a click on empty space cancels the command, history, or filter/sort/views picker just like Escape, and the two-pane help closes on a click outside both panes
12
+ - Colored help titles — the FILECON, HINTS, COMMANDS, CONFIG headings and the KEYBINDINGS grid header are yellow; the redundant HELP text header is removed
13
+
14
+ ### Fixed
15
+ - The mouse wheel scrolls the command, history, and filter/sort/views popups — previously the live filter reapplied itself after each wheel tick and snapped the list back to the top
16
+ - The colored `[f]ilter`/`[s]ort`/`[v]iews` bindings on the bottom bar now react to clicks — the trigger-key extraction no longer trips on their ANSI color codes
17
+ - The filter/sort/views columns on the head open their popups when clicked in a real terminal — the head row now matches the 1-based mouse coordinates
18
+ - Clicking the bottom bar binds to the row above it — the clickable row check now uses 1-based mouse coordinates, so bindings activate where they are rendered
19
+ - Clicking a keybinding row in the two-pane help no longer crashes — the clicked row now maps to the line's binding labels (`@user.bindings`) instead of an undefined App `@bindings`, so the trigger key is returned and dispatched
20
+ - `cd` owns the path column flag — array `cd` sets `@show_path` (single dirs clear it), so `reset_view` preserves the path listing after `execute`/`recurse` instead of dropping it; `recurse` just builds the recursive directory array and delegates the loading to `cd`
21
+ - Array `cd` fills the path column after the full load — previously only the first directory's rows got values (the rest stayed blank on `reset_view`), and custom Hash views dropped the column entirely; the trailing `change_view` now runs once on complete data, and computed views keep PATH too
22
+ - Clickable header path — left-clicking the username goes home and each directory segment navigates there, while right-click opens the command list for that path without leaving the current directory
23
+ - A binding picked in help now runs — `fly` re-dispatches a String return from `send` (as it already did for mouse clicks), so pressing `h` and clicking e.g. `[R]ecurse` executes that action instead of just closing the help page
24
+ - The help text panel sits flush with the terminal edge — the text panel's `right: -2` border now draws on the last column, matching the browser edge; the previous inset was caused by an off-by-one in the `draw_border` guard
25
+
26
+ ## [v0.3.0] — 2026-08-15
27
+
28
+ ### Added
29
+ - New `%cmd` substitution — lists the PATH, picks an executable, and inserts its path; the listing is left and the original directory restored afterwards
30
+ - Alt + hint digit in the command and cmd-history popups puts the picked command into a `read_line` for editing before it runs (dir-history entries are not edited); the command popup resolves its `%name`/`%dir`/`%file`/`%str` substitutions before the resulting command is offered for editing
31
+ - Alt + number in the main view opens the command list for the hinted file (replacing the `o` action)
32
+ - Right-click in the main view opens the command list for the clicked file — mirroring Alt+number, with left-click still running the default action
33
+ - Return with marked files (`m`) opens their command list — replacing the `o` action's multi-select behaviour, now reachable through the default confirm key
34
+
35
+ ### Changed
36
+ - `%dir` picking relies on typr's `pick :directory` to confirm the current directory with Return — the `@pick_dir` state is gone, and `%dir`/`%file`/`%cmd` share one substitution branch
37
+ - Renamed the view-switching method to `change_view` (was `switch_to`), matching the clearer typr naming — keybinding, popup, and specs updated
38
+ - Removed the `o` key action — the command list for a file is now opened with Alt+number
39
+ - Shell-generated custom view columns are passed through `coerce_type`, so numeric output (e.g. `wc` counts) sorts and displays numerically
40
+ - Custom view shell output is stripped before display, so trailing newlines no longer yield a trailing `|` in multi-line columns
41
+ - Dropped the now-redundant `hints: "1234567890"` overrides from the command and history popups — digits-only hints are the typr default
42
+
43
+ ### Fixed
44
+ - `%dir` substitution pickers confirm the current directory with Return again — the Return-marked-files action only applies outside substitution mode
45
+ - The file list is redrawn immediately while a `|` command's output is shown — the command picker popup no longer stays on screen behind the statusline, and the statusline keeps showing the command after it returns
46
+ - Per-MIME-type row colors stay correct after deleting a file — `delete_row` now reindexes the `@colors[:fields]` keys together with `@map`, so rows below the deletion no longer show the previous row's color until `[r]eset`
47
+ - PTY driver no longer garbles or hangs — the screen decoder holds partial multi-byte UTF-8 across read chunks (box-drawing glyphs render intact), clamps the cursor to the terminal grid and caps the raw log so the rendered screen stays bounded, key resends ignore a dead pty instead of raising, and `quit` escalates `ESC` → `TERM` → `KILL` so it always reaps the app
48
+ - Spec cleanup — `picker_double`, `test_id`, `with_path`, and `with_cmd_target` helpers removed the grid-picker and id-lookup boilerplate, and duplicated `#change_view`, `#history`, `%cmd`, and colored `%dir`/`%file` examples were merged into looping specs
49
+
50
+ ## [v0.2.1] — 2026-08-03
51
+
52
+ ### Added
53
+ - Mouse support in `fly` — click a row to open it in its default app, wheel up/down scrolls the listing (requires typr `~> 1.3` mouse reporting, enabled by `Typr.init`)
54
+ - PTY integration driver — `spec/integration/pty_driver.rb` is an expect-style smoke suite that spawns the real `bin/filecon` on a pseudo-terminal, drives it with keystrokes, and asserts on the rendered screen; run as part of `rake test` (or manually via `ruby spec/integration/pty_driver.rb`, with `--interactive` for a live probe and `--keep` to retain temp fixtures)
55
+
56
+ ## [v0.2.0] — 2026-08-02
57
+
58
+ ### Added
59
+ - `executable` command category — `commands:` entries under `executable:` (`run`, `run_terminal`) are added to the `open_file` picker ahead of `default` whenever the selected file(s) have the executable bit set, regardless of MIME type; multi-select adds them only when every selection is executable
60
+ - `execute` command (`x`, `e[x]ecute`) — lists every executable from all `$PATH` directories in the main view, with a `path` column showing each binary's containing directory
61
+ - `open_current` (`` ` ``) — opens the directory under the cursor in its default app
62
+ - Full-path filenames: `cd` stores absolute paths in `@data`; `@procs[NAME]` displays basenames via `File.basename`; `build` uses `@data[id][NAME]` directly (no `@directory` prefix)
63
+ - `@directory` accepts an Array (for multi-path listings like `execute`); `draw` joins Array entries with `": "` for the status display
64
+ - `frequency_limit` config var (default 10) — only the top N most-used entries get frequency coloring in history popups, listed frequency-first then most-recent
65
+ - `filter_dirs` config flag (default true) — active filters also hide directories that don't match
66
+ - Shell history importer — `import_shell_history` reads `~/.bash_history`/`~/.zsh_history` once at startup, validates commands against `$PATH` and built-ins, resolves aliases from `.zshrc`/`.bashrc`, and merges new entries into `cmd_history`; a `shell_sync` flag in the state dir prevents re-import
67
+ - `open_file` status line now shows the picked command name first in `colors.commands` colors — `> name:display : output` (name in `colors.commands[0]`, the built command in `colors.commands[1]`; default `["green", "red"]`); the command picker popup uses the same configurable colors
68
+ - `build` prompts for `%dir`/`%file`/`%str` prepend the colored command `name:` prefix, so the partial command stays identifiable while being filled in
69
+ - `term_hold` config — hold flag appended to `@term` at init (e.g. `foot --hold`)
70
+
71
+ ### Changed
72
+ - Config location moved to `~/.config/filecon/config.yaml` — on first run the bundled `config.yaml` is copied there; state/history remain under `~/.local/share/filecon/`; string-keyed `colors:` settings (as loaded from YAML) are now honored
73
+ - `binaries` → `execute` (`x`), reset restored to `[r]eset`, recurse brought back as `[R]ecurse`
74
+ - `recurse` restored to `cd`-based appends (absolute paths), adding a `path` column (`Typr::PATH`) before the filename via a shared `add_path_column` helper
75
+ - `%str` substitution uses the shared `Typr.read_line` editor (renamed from `Typr.edit`): arrow/ctrl-arrow word jumps, in-place editing, Escape aborts the whole command
76
+ - Adapted to typr API renames: `Typr.read` → `read_key`, `Typr.edit` → `read_line`, frontend `show` → `draw` / widget render `draw` → `show`
77
+ - History storage: `@history`/`@frequency` ivars and the separate frequency files replaced with flat `@cmd_history`/`@dir_history` arrays of `[count, entry]` pairs managed by a `record` helper; file format is `count,entry` per line
78
+ - `run` executes unprefixed commands (e.g. from imported shell history) in a terminal window instead of doing nothing; the shell-history import skips `cd`/`pushd` entries (their directory targets still land in `dir_history`)
79
+ - Config command templates restructured (explicit `%str` args, image view alias)
80
+ - `[H]idden_files` binding moved after `[~]:home`; backtick dispatches through `Stack#send` as `open_current`
81
+ - Runtime dependency on typr raised to `~> 1.2` (requires the `read_key`/`read_line` API)
82
+
83
+ ### Removed
84
+ - `Filecon::PATH` constant — paths consolidated into a `@path` hash (`:config`, `:state`, `:dir_history`, `:cmd_history`)
85
+ - Separate `cmd_frequency`/`dir_frequency` files (merged into the `[count, entry]` history pairs)
86
+
87
+ ### Fixed
88
+ - `Grid#sort` used `ids` (which returns `@map` when set), so rows appended by subsequent `$PATH` dirs were invisible — now uses the full row range
89
+ - `cd` Array branch: missing `Dir.chdir(d)` and stale `@directory` before each append `super`, causing procs to resolve relative to the wrong directory
90
+ - `history`: `each_with_index.each_with_object` misrouted the memo block parameter (`fields[[i,0]] = ...` raised `NoMethodError`)
91
+ - `import_shell_history`: `shell_sync` was never written because the `added` flag checked `@cmd_history` after `record` already inserted; every occurrence now increments frequency, and the resolved command text (not the alias name) is stored
92
+ - `open_file` executable-category check skips when no row is selected (`open_current` with a nil id) instead of crashing on `@data[nil]`
93
+ - `recurse` no longer leaks hidden directory contents past the basename-only check
94
+ - `open_file` command picker keeps a fixed height derived from its full command list, so live-filter redraws don't resize/jump the popup
95
+ - History and command-picker popups scroll with arrow keys again — PageUp/PageDown/Home/End and TAB hint cycling are no longer swallowed by the line editor
96
+ - `Stack#send` keymap dispatch only normalizes printable ASCII keys, preserving control characters for correct key matching
97
+ - History popups show frequency entries with a grey background and `:brown` dir foreground; `du`/`wc`/`whatis` outputs trimmed of the trailing filename
98
+
99
+ ---
100
+
101
+ ## [v0.1.2] — 2026-07-28
102
+
103
+ ### Added
104
+ - Help page with keybindings and description (`h` key)
105
+ - Terminal resize handler (`Typr.on_resize`)
106
+ - `new_file` and `new_dir` commands for directories
107
+ - `count` view (chars, words, lines) replaces `lines` view
108
+ - `open_file` accepts optional `types` parameter for filtered command resolution
109
+ - `build` handles nil `id` for directory-level commands (backtick)
110
+
111
+ ### Changed
112
+ - Help page: simplified layout with proper positioning
113
+ - Backtick key opens commands for current directory instead of navigating to root
114
+ - `open_file`: pipe output displayed in status line instead of fork; `+` commands run directly (no terminal spawn)
115
+ - `run` uses instance vars `@cmd_history_path`, `@max_history` instead of module methods
116
+ - Setup code moved from `Filecon` module into `bin/filecon`
117
+ - `Filecon` module: removed `setup_config`, `deep_symbolize_keys`, `config`, `dir_history_path`, `cmd_history_path` — only `PATH` and `VERSION` remain
118
+ - Config uses string keys (no deep symbolization)
119
+ - Rakefile: cleaned to standard targets (build, clean, test, release)
120
+ - config.yaml: `copy` command uses pipe instead of terminal; `lines` view → `count`
121
+ - Man page: full rewrite — Typr references, YAML config, new keybinding docs
122
+ - README updated for YAML config, command prefixes, substitution variables
123
+ - Specs updated for new API (string keys, constructor args)
124
+
125
+ ### Fixed
126
+ - Constant redefinition warnings in tests
127
+ - Removed bundler dependency (Gemfile, Gemfile.lock)
128
+
129
+ ## [v0.1.1] — 2026-07-27
130
+
131
+ ### Added
132
+ - Error logging to `/tmp/filecon.log` for debugging crashes
133
+ - Fallback to `$TERM` when terminal config is missing
134
+
135
+ ### Changed
136
+ - Switched configuration format from TOML to YAML
137
+ - Simplified command execution: only `!` (Ruby eval) and shell commands (`|`, `+`, `=`)
138
+ - Config keys are now strings (no deep symbolization needed)
139
+ - Inlined setup code into `bin/filecon`, stripped `Filecon` module to `PATH` and `VERSION`
140
+ - Require strategy: `require_relative` for development, gem fallback for installed use
141
+ - Restructured as a proper Ruby gem with `bin/filecon` entry point
142
+
143
+ ### Fixed
144
+ - Relative paths in `lib/filecon.rb`
145
+ - `config.yaml` `colors.default` structure
146
+ - Removed obsolete root-level script and config files
147
+ - Updated all links to Codeberg (`typr/filecon`, `typr/typr`)
148
+
149
+ ## [v0.1.0] — 2026-07-20
150
+
151
+ ### Added
152
+ - Initial release: terminal file manager with MIME-type detection
153
+ - Directory and command history
154
+ - Customizable views, keybindings, and colors
155
+ - Configurable command execution with `%name`, `%dir`, `%file`, `%str` substitutions
156
+ - Built on the Typr terminal UI toolkit
data/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  ## Description
6
6
 
7
- Filecon is a terminal-based file manager built on the [Typr](https://codeberg.org/typr/typr) terminal UI toolkit. It packs everything a file manager should do into a keyboard-driven terminal program: every file, command, and directory is reachable in a few keystrokes, and the most common operations take the fewest key presses.
7
+ Filecon is a terminal-based file manager built on the [Typr](https://codeberg.org/typr/typr) terminal UI toolkit. Every file, command, and directory is reachable in a few keystrokes, and the most common operations take the fewest key presses.
8
8
 
9
9
  Filecon is designed to be **intuitive**, **complete**, **powerful**, and the **fastest possible** file manager. The whole interface is built around that principle:
10
10
 
@@ -12,8 +12,6 @@ Filecon is designed to be **intuitive**, **complete**, **powerful**, and the **f
12
12
  - **Live search in popups** — command and history popups open in `/` search mode; type to distill the list, then pick one of the few remaining results with a number.
13
13
  - **Frequency-ordered history** — directory and command history are ranked by use count, so the most likely choice is always near the top.
14
14
 
15
- Filecon's long-term goal is to become an **interactive shell**: a separate companion program will handle command building, and combined with Filecon the two will form a full interactive shell that competes with interactive CLI shells.
16
-
17
15
  Filecon runs on Typr, whose self-contained terminal layer ships its own precompiled terminfo key table and MIME-type database in the gem — no ncurses or external tooling required — so Filecon works on any raw, ANSI-capable terminal (including Termux).
18
16
 
19
17
  ## Features
@@ -21,7 +19,7 @@ Filecon runs on Typr, whose self-contained terminal layer ships its own precompi
21
19
  - **Directory browsing with MIME-type detection** — files are typed from a packaged MIME database and colored accordingly, with optional `file --mime-type` magic detection for unknowns
22
20
  - **Fastest possible navigation** — hint numbers (1–9, 0) open rows directly; TAB pages hints beyond the first ten
23
21
  - **Default `[/]:search` in popups** — command and history popups open in search mode: start typing to distill the list down to the matches, then press a number hint to pick from the few remaining results. The listing itself searches the same way
24
- - **Mouse support** — click a row to open it with its default action, right-click to open its command list; the mouse wheel scrolls the listing (pointer-only mode is planned)
22
+ - **Mouse support** — click a row to open it with its default action, right-click to open its command list, click a binding on the bottom bar or a filter/sort/views column to run that action; the mouse wheel scrolls the listing (pointer-only mode is planned)
25
23
  - **Command execution modes** — commands run in one of four ways, chosen by prefix: `|` status line, `=` text viewer, `+` new terminal window, `!` Ruby eval; per-MIME-type command sets with `%name`, `%dir`, `%file`, `%cmd`, `%str` substitution
26
24
  - **Customizable column views** — view columns run shell commands with `%name` substitution (content preview, char/word/line counts, type info, disk usage, man-page descriptions)
27
25
  - **Directory and command history with a frequency counter** — entries stored as `[count, entry]` pairs, most-used first then most-recent; `frequency_limit` controls how many frequent entries lead the list
@@ -78,7 +76,7 @@ filecon [directory]
78
76
 
79
77
  ### Mouse
80
78
 
81
- Click a row to open it with its default action, right-click to open its command list; the mouse wheel scrolls the listing. Mouse reporting is enabled automatically when Filecon starts.
79
+ Click a row to open it with its default action, right-click to open its command list; click a binding label on the bottom bar or a filter/sort/views column on the head to run that action; the mouse wheel scrolls the listing. Clicking outside a popup dismisses it. `h` shows a two-pane help with the keybinding grid (from the line's `list`) beside the help text — clicking a binding row returns its trigger key, and clicking outside both panes closes it. Mouse reporting is enabled automatically when Filecon starts.
82
80
 
83
81
  ### Popups and search
84
82
 
@@ -106,11 +104,6 @@ State and history files live under `~/.local/share/filecon/`.
106
104
 
107
105
  See `filecon(1)` for the full manual.
108
106
 
109
- ## Roadmap
110
-
111
- - **Pointer-only mode** — full mouse-driven operation of the entire interface, building on the click/wheel mouse support already present
112
- - **Interactive shell** — a separate command-building program that combines with Filecon into an interactive shell competing with interactive CLI shells
113
-
114
107
  ## Development
115
108
 
116
109
  ```bash
data/config.yaml CHANGED
@@ -129,12 +129,14 @@ commands:
129
129
  default:
130
130
  # copy: "|rsync --progress %name %dir"
131
131
  info: "=file %name"
132
+ view: "+moor %name"
133
+ edit: "+micro %name"
132
134
  copy: "|cp -R %name %dir"
133
135
  move: "|mv %name %dir"
134
136
  rename: "|mv %name %str"
135
137
  delete: "|rm -rf %name"
136
- open_with: "|%file %name %str"
137
- open_with_terminal: "+%file %name %str"
138
+ open_with: "|%cmd %name %str"
139
+ open_with_terminal: "+%cmd %name %str"
138
140
  xdg_open: "|xdg-open %name"
139
141
 
140
142
  executable:
@@ -153,8 +155,6 @@ commands:
153
155
  play: "+mpv %name"
154
156
 
155
157
  text:
156
- view: "+moor %name"
157
- edit: "+micro %name"
158
158
  count: "|wc -l %name | cut -wf1"
159
159
 
160
160
  troff:
@@ -210,9 +210,9 @@ commands:
210
210
  "x-c++":
211
211
  run: "+g++ %name && ./a.out"
212
212
 
213
- markdown:
214
- view: "+glow %name"
215
- edit: "+micro %name"
213
+ # markdown:
214
+ # view: "+glow %name"
215
+ # edit: "+micro %name"
216
216
 
217
217
  json:
218
218
  view: "=cat %name | jq ."
@@ -1,3 +1,3 @@
1
1
  module Filecon
2
- VERSION = "0.3.0"
2
+ VERSION = "0.4.0"
3
3
  end
data/lib/filecon.rb CHANGED
@@ -12,6 +12,7 @@ class Filecon::App < Typr::Browser
12
12
  def cd dir, append=false
13
13
  @selected[:rows] = [] unless append
14
14
  if dir.is_a? Array
15
+ @show_path = true
15
16
  dirs = dir.filter_map { |d| d = File.expand_path(d.to_s); Dir.exist?(d) ? d : nil }
16
17
  dirs.each_with_index { |d, i|
17
18
  @directory = d if i.positive?
@@ -19,8 +20,10 @@ class Filecon::App < Typr::Browser
19
20
  super d, i.positive?
20
21
  }
21
22
  @directory = dirs
23
+ change_view @view if dirs.any?
22
24
  nil
23
25
  else
26
+ @show_path = false unless append
24
27
  dir = @dir_history[dir+1][1] if dir.is_a? Integer
25
28
  record :dir, File.expand_path(dir) unless append || [?/, ENV["HOME"]].include?(dir)
26
29
  super dir, append
@@ -28,7 +31,7 @@ class Filecon::App < Typr::Browser
28
31
  end
29
32
  end
30
33
 
31
- def execute; cd ENV["PATH"].split(":"); add_path_column end
34
+ def execute; cd ENV["PATH"].split(":") end
32
35
 
33
36
  def pick type='file', **kw
34
37
  return super unless type == :cmd
@@ -62,6 +65,10 @@ class Filecon::App < Typr::Browser
62
65
  @header.index(head.to_s) || (@header += [head.to_s]; @header.count-1) }
63
66
  clear
64
67
  self << data
68
+ if @show_path
69
+ @data.each { |row| row[PATH] = File.dirname(row[NAME]) } if @data.any?
70
+ @sequence.insert(@sequence.index(NAME) || 0, PATH) unless @sequence.include?(PATH)
71
+ end
65
72
  @current = id
66
73
  @view = id
67
74
  end
@@ -100,7 +107,7 @@ class Filecon::App < Typr::Browser
100
107
  cmd = build pair.last, id, pair.first
101
108
  return unless cmd
102
109
  if alt
103
- edited = Typr.read_line "> ", left: left, top: @user.top, initial: cmd
110
+ edited = Typr.read_line "> ", left: left, top: @user.top, initial: cmd, completions: true, redraw: method(:show)
104
111
  return unless edited
105
112
  cmd = edited
106
113
  end
@@ -128,7 +135,7 @@ class Filecon::App < Typr::Browser
128
135
  name = row[NAME]
129
136
  return delete_row id unless File.symlink?(name) || File.exist?(name)
130
137
  updated = scan_file name
131
- updated[-2,2] = row[-2,2]
138
+ updated[TYPE, 2] = row[TYPE, 2]
132
139
  @data[id] = updated
133
140
  process id
134
141
  end
@@ -223,7 +230,8 @@ class Filecon::App < Typr::Browser
223
230
 
224
231
  entry = ordered[n][1]
225
232
  if is_cmd and picker.modifier == :alt
226
- edited = Typr.read_line "> ", left: left, top: @user.top, initial: entry
233
+ edited = Typr.read_line "> ", left: left, top: @user.top, initial: entry,
234
+ completions: true, redraw: -> { picker.show }
227
235
  return unless edited
228
236
  entry = edited
229
237
  end
@@ -306,39 +314,29 @@ class Filecon::App < Typr::Browser
306
314
  def recurse
307
315
  return if @directory.is_a?(Array)
308
316
  root = File.expand_path(@directory)
309
- clear
310
- cd root
311
- Dir.glob("**/*", File::FNM_DOTMATCH, base: root).sort.each { |p|
317
+ dirs = [root] + Dir.glob("**/*", File::FNM_DOTMATCH, base: root).sort.filter_map { |p|
312
318
  next if !@show_hidden && p.split(?/).any? { |c| c.start_with?(?.) }
313
- next unless File.directory?(File.join(root, p))
314
319
  d = File.expand_path(p, root)
315
- @directory = d
316
- Dir.chdir d
317
- cd d, true
320
+ d if File.directory?(d)
318
321
  }
319
- Dir.chdir root
320
- @directory = root
321
- add_path_column
322
+ cd dirs
322
323
  @current = 0
323
324
  nil
324
325
  end
325
326
 
326
- def add_path_column
327
- Typr.const_set :PATH, @header.size unless Typr.const_defined?(:PATH)
328
- @header << "path" unless @header.include?("path")
329
- @data.each { |row| row[PATH] = File.dirname(row[NAME]) }
330
- @sequence.insert(@sequence.index(NAME) || 0, PATH) unless @sequence.include?(PATH)
331
- # @align[@header.size-1] = :right
332
- end
327
+
333
328
 
334
329
  def help
335
- info = "\nFILECON - a terminal file manager\n\n" \
336
- "HINTS: press a number (1-9,0) to open that file with its default action.\n" \
337
- " Alt+number opens the command list for that file instead.\n" \
338
- " Right-click a file to open its command list.\n" \
339
- " Mark files with m, then Return opens their command list.\n" \
340
- " TAB cycles pages of hints.\n\n" \
341
- "COMMANDS:\n" \
330
+ grid = @user.list
331
+ y = color_code :yellow
332
+ d = color_code @colors[:default]
333
+ text = Text.new( input: "\n#{y}FILECON#{d} - a terminal file manager\n\n" \
334
+ "#{y}HINTS:#{d}\n press a number (1-9,0) to open that file with its default action.\n" \
335
+ " Alt+number opens the command list for that file instead.\n" \
336
+ " Right-click a file to open its command list.\n" \
337
+ " Mark files with m, then Return opens their command list.\n" \
338
+ " TAB cycles pages of hints.\n\n" \
339
+ "#{y}COMMANDS:#{d}\n" \
342
340
  " e[x]ecute browse all executables on your PATH\n" \
343
341
  " [R]ecurse expand the current directory tree (subdirectories listed inline)\n" \
344
342
  " [d]irectories jump to a recently visited directory\n" \
@@ -347,11 +345,32 @@ class Filecon::App < Typr::Browser
347
345
  " entries first, then the rest in most-recent order. The frequency_limit\n" \
348
346
  " setting in config.yaml (default 10) controls how many frequent entries\n" \
349
347
  " lead the list.\n\n" \
350
- "CONFIG: ~/.config/filecon/config.yaml\n\n" \
351
- "KEYBINDINGS:\n\n" + @user.bindings.join(?\n)
352
- Text.new( input: info, top:2, left:3, right: -3, bottom: -3, header: "HELP",
353
- colors: { header: [:black,:white], border:[:white,:grey10] },
354
- border: :light ).pick :none
348
+ "#{y}CONFIG:#{d}\n ~/.config/filecon/config.yaml\n",
349
+ top: 2, right: -2, bottom: -3,
350
+ colors: { border:[:white,:grey10] },
351
+ border: :light )
352
+ text.left = -> { grid.right + 2 }
353
+ loop do
354
+ grid.show
355
+ text.show
356
+ key = Typr.read_key
357
+ case key
358
+ when @keymap[:exit], @keymap[:confirm]; return
359
+ when Typr::Mouse
360
+ if key.press? and key.left?
361
+ if row = grid.data_at( key.x, key.y )
362
+ return extract_key( @user.bindings[ row ] )
363
+ end
364
+ return if grid.send( key ) == :outside and text.send( key ) == :outside
365
+ else
366
+ grid.send key
367
+ text.send key
368
+ end
369
+ else
370
+ grid.send key
371
+ text.send key
372
+ end
373
+ end
355
374
  end
356
375
 
357
376
  def initialize args={}
@@ -378,6 +397,13 @@ class Filecon::App < Typr::Browser
378
397
 
379
398
  def open_current; open_file nil, false, ["directory", "inode"] - [??] + ["default"] end
380
399
 
400
+ def open_path path
401
+ dir, @directory = @directory, path
402
+ open_file nil, false, ["directory", "inode"] - [??] + ["default"]
403
+ ensure
404
+ @directory = dir
405
+ end
406
+
381
407
  def fly
382
408
  loop do
383
409
  show
@@ -387,17 +413,18 @@ class Filecon::App < Typr::Browser
387
413
  case key
388
414
  when KEY_ESCAPE; exit
389
415
  when Typr::Mouse
390
- if key.wheel? and key.press?
391
- send( key.wheel_up? ? @keymap[:up] : @keymap[:down] )
392
- elsif key.press? and ( key.left? or key.right? )
393
- id = hit( key.y, key.x )
394
- open_file( id, !key.right? ) if id.is_a? Integer
416
+ if key.press? and ( key.left? or key.right? ) and target = @head.path_at( key.x, key.y )
417
+ key.right? ? open_path( target ) : cd( target )
418
+ else
419
+ value = send( key )
420
+ open_file( value, !key.right? ) if value.is_a?( Integer )
395
421
  end
396
422
  @user.reset
397
423
  else
398
424
  alt = key.is_a?(String) && key[/\A\e(\d)\z/]
399
425
  key = key[1] if alt
400
426
  id = send( key )
427
+ id = send( id ) while id.is_a? String
401
428
  open_file( id, !alt ) if id.is_a? Integer
402
429
  @user.reset
403
430
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: filecon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kilian Reitmayr
@@ -74,6 +74,7 @@ executables:
74
74
  extensions: []
75
75
  extra_rdoc_files: []
76
76
  files:
77
+ - CHANGELOG.md
77
78
  - LICENSE
78
79
  - README.md
79
80
  - bin/filecon