rtfm-filemanager 3.5 → 3.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -0
- data/bin/rtfm +30 -44
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4e42eb95b56118347846698cdfba4ff623a1e26232f27b65eca95ccc6fee9ccf
|
4
|
+
data.tar.gz: 18b33ed860c9b92d7c6001bdb1b218010dece44855a1724d35242cd29ebfa1c9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d4b834369ab3664df99aaa15272daea2f2f64bfaefc32ec740e6517e55fa9e177c21a32e134efe349d610909d5d0c565b6b0d4fb97a3c3d708a2fe9a24560ffd
|
7
|
+
data.tar.gz: 62b6910acae2d26a51c9a00beae8f7521c5d2b7c2cf8773248d965c838e12e706b875f3acb0ca8ff6b1db47cf03a89b70410d53716c04fd7ba4015dcdd7cd835
|
data/README.md
CHANGED
@@ -64,6 +64,9 @@ of the selected item (directory or file) is shown in the right pane. The right
|
|
64
64
|
pane is also used to show information such as the currently tagged items, your
|
65
65
|
(book)marks, output from commands, etc.
|
66
66
|
|
67
|
+
When you start RTFM, you can supply a directory path as an argument to let
|
68
|
+
RTFM start up in that directory.
|
69
|
+
|
67
70
|
You can run any command in the bottom "command bar" and have the output
|
68
71
|
presented in the right pane. Use LEFT and RIGHT keys to go back and forth on
|
69
72
|
the command line, HOME to beginning of line, END to end of line, Backspace or
|
data/bin/rtfm
CHANGED
@@ -14,7 +14,7 @@
|
|
14
14
|
# for any damages resulting from its use. Further, I am under no
|
15
15
|
# obligation to maintain or extend this software. It is provided
|
16
16
|
# on an 'as is' basis without any expressed or implied warranty.
|
17
|
-
@version = "3.
|
17
|
+
@version = "3.9"
|
18
18
|
|
19
19
|
# PRELIMINARIES
|
20
20
|
@help = <<HELPTEXT
|
@@ -177,6 +177,7 @@ end
|
|
177
177
|
begin # BASIC SETUP
|
178
178
|
require 'fileutils'
|
179
179
|
require 'io/console'
|
180
|
+
require 'io/wait'
|
180
181
|
require 'date'
|
181
182
|
require 'timeout'
|
182
183
|
require 'curses'
|
@@ -199,7 +200,6 @@ begin # BASIC SETUP
|
|
199
200
|
cmd?('bat') ? @bat = "bat" : @bat = "batcat"
|
200
201
|
|
201
202
|
STDIN.set_encoding(Encoding::UTF_8) # Set encoding for STDIN
|
202
|
-
LScolors = `echo $LS_COLORS` # Import LS_COLORS
|
203
203
|
|
204
204
|
## Curses setup
|
205
205
|
Curses.init_screen
|
@@ -251,8 +251,10 @@ begin # BASIC SETUP
|
|
251
251
|
if File.exist?(Dir.home+'/.rtfm.conf')
|
252
252
|
load(Dir.home+'/.rtfm.conf')
|
253
253
|
end
|
254
|
+
Dir.chdir(ARGV[0]) if Dir.exist?(ARGV[0]) and ARGV[0] !~ /\/tmp/
|
254
255
|
end
|
255
|
-
|
256
|
+
# CLASS EXTENSIONS
|
257
|
+
class Curses::Window
|
256
258
|
attr_accessor :fg, :bg, :attr, :text, :update, :pager, :pager_more, :pager_cmd, :locate, :nohistory
|
257
259
|
# General extensions (see https://github.com/isene/Ruby-Curses-Class-Extension)
|
258
260
|
def clr
|
@@ -282,16 +284,6 @@ class Curses::Window # CLASS EXTENSION
|
|
282
284
|
# RTFM specific extensions
|
283
285
|
end
|
284
286
|
# GENERIC FUNCTIONS
|
285
|
-
def get_ls_color(type) # GET THE COLOR FOR THE FILETYPE FROM IMPORTED LS_COLORS
|
286
|
-
bold = 0
|
287
|
-
begin
|
288
|
-
color = LScolors.match(/#{type}=\d*;\d*;(\d*)/)[1]
|
289
|
-
bold = 1 if LScolors.match(/#{type}=\d*;\d*;\d*;1/)
|
290
|
-
rescue
|
291
|
-
color = 7 # Default color
|
292
|
-
end
|
293
|
-
return color.to_i, bold
|
294
|
-
end
|
295
287
|
def syntax_highlight(input) # SYNTAX HIGHLIGHTING FROM ANSI COLOR CODES
|
296
288
|
color_ary = color_parse(input)
|
297
289
|
color_ary.each do | pair |
|
@@ -308,13 +300,15 @@ def syntax_highlight(input) # SYNTAX HIGHLIGHTING FROM ANSI COLOR CODES
|
|
308
300
|
end
|
309
301
|
end
|
310
302
|
def color_parse(input) # PARSE ANSI COLOR SEQUENCES
|
311
|
-
input.gsub!(
|
312
|
-
input.gsub!(
|
313
|
-
input.gsub!(
|
314
|
-
input.gsub!(
|
315
|
-
input.gsub!(
|
303
|
+
input.gsub!(/\e\[\d;38;5;(\d+);*(\d*)m/, '¤¤\1¤¤\2¤¤')
|
304
|
+
input.gsub!(/\e\[38;5;(\d+);*(\d*)m/, '¤¤\1¤¤\2¤¤')
|
305
|
+
input.gsub!(/\e\[\d;38;2;(\d+);*(\d*);\d*m/, '¤¤\1¤¤\2¤¤')
|
306
|
+
input.gsub!(/\e\[38;2;(\d+);*(\d*);\d*m/, '¤¤\1¤¤\2¤¤')
|
307
|
+
input.gsub!(/\e\[\d+;(\d+);*(\d*)m/, '¤¤\1¤¤\2¤¤')
|
308
|
+
input.gsub!(/\e\[0m/, "")
|
316
309
|
color_array = input.split("¤¤")
|
317
310
|
color_array = color_array.drop(1)
|
311
|
+
#color_array.map! { |x| x || 0 }
|
318
312
|
output = color_array.each_slice(3).to_a
|
319
313
|
return output
|
320
314
|
end
|
@@ -325,9 +319,9 @@ def getchr # PROCESS KEY PRESSES
|
|
325
319
|
c = STDIN.getch(min: 0, time: 3)
|
326
320
|
case c
|
327
321
|
when "\e" # ANSI escape sequences
|
328
|
-
case
|
322
|
+
case STDIN.getc
|
329
323
|
when '[' # CSI
|
330
|
-
case
|
324
|
+
case STDIN.getc
|
331
325
|
when 'A' then chr = "UP"
|
332
326
|
when 'B' then chr = "DOWN"
|
333
327
|
when 'C' then chr = "RIGHT"
|
@@ -341,7 +335,7 @@ def getchr # PROCESS KEY PRESSES
|
|
341
335
|
when '8' then chr = "END" ; chr = "C-END" if STDIN.getc == "^"
|
342
336
|
end
|
343
337
|
when 'O' # Set Ctrl+ArrowKey equal to ArrowKey; May be used for other purposes in the future
|
344
|
-
case
|
338
|
+
case STDIN.getc
|
345
339
|
when 'a' then chr = "C-UP"
|
346
340
|
when 'b' then chr = "C-DOWN"
|
347
341
|
when 'c' then chr = "C-RIGHT"
|
@@ -351,6 +345,7 @@ def getchr # PROCESS KEY PRESSES
|
|
351
345
|
when "", "" then chr = "BACK"
|
352
346
|
when "" then chr = "WBACK"
|
353
347
|
when "" then chr = "LDEL"
|
348
|
+
when "" then chr = "C-C"
|
354
349
|
when "" then chr = "C-G"
|
355
350
|
when "" then chr = "C-L"
|
356
351
|
when "" then chr = "C-N"
|
@@ -360,7 +355,7 @@ def getchr # PROCESS KEY PRESSES
|
|
360
355
|
when "" then chr = "C-Y"
|
361
356
|
when "\r" then chr = "ENTER"
|
362
357
|
when "\t" then chr = "TAB"
|
363
|
-
when
|
358
|
+
when /[[:print:]]/ then chr = c
|
364
359
|
end
|
365
360
|
return chr
|
366
361
|
end
|
@@ -960,7 +955,8 @@ end
|
|
960
955
|
def get_files(win) # The core of the directory listings
|
961
956
|
ls_cmd = "ls 2>/dev/null #{@lsbase} #{@lsall} #{@lsorder} #{@lsinvert} #{@lsuser}" # Get files in current directory
|
962
957
|
ls_cmd += @selected_safe if win == "right"
|
963
|
-
@
|
958
|
+
@cfiles = `#{ls_cmd} --color`.split("\n")
|
959
|
+
@files = @cfiles.map {|f| f.sub(/^\e\[.*\dm(..*$)/, '\1').sub(/\e.+/, '')}
|
964
960
|
ls_cmd += " -H " if win == "right"
|
965
961
|
ls_cmd += %q[ -lh --time-style="long-iso" | awk '{printf "%s%s%s%11s%6s%6s", $1, " " $3, ":" $4,$6,$7,$5"\n"}']
|
966
962
|
@fspes = `#{ls_cmd}`.split("\n").drop(1)
|
@@ -1027,7 +1023,8 @@ def list_dir(active) # LIST CONTENT OF A DIRECTORY (BOTH active AND RIGHT WINDOW
|
|
1027
1023
|
@cont = ""
|
1028
1024
|
end
|
1029
1025
|
while ix < @files.size and t < win.maxy do
|
1030
|
-
str
|
1026
|
+
str = @files[ix]
|
1027
|
+
cstr = @cfiles[ix]
|
1031
1028
|
active ? str_path = str : str_path = "#{@selected}/#{str}"
|
1032
1029
|
begin # Add items matching @tag to @tagged
|
1033
1030
|
if str.match(/#{@tag}/) and @tag != false
|
@@ -1036,25 +1033,9 @@ def list_dir(active) # LIST CONTENT OF A DIRECTORY (BOTH active AND RIGHT WINDOW
|
|
1036
1033
|
end
|
1037
1034
|
rescue
|
1038
1035
|
end
|
1039
|
-
# Determine the filetype of the item
|
1040
|
-
ftype = ""
|
1041
|
-
ftype = str.match(/\.([^.]*$)/)[1] if str.match?(/\.([^.]*$)/)
|
1042
|
-
# Set special filetypes (sequence matters)
|
1043
|
-
ftype = "bd" if File.blockdev?(str_path)
|
1044
|
-
ftype = "cd" if File.chardev?(str_path)
|
1045
|
-
ftype = "pi" if File.pipe?(str_path)
|
1046
|
-
ftype = "st" if File.sticky?(str_path)
|
1047
|
-
ftype = "so" if File.socket?(str_path)
|
1048
|
-
ftype = "ex" if File.executable?(str_path)
|
1049
|
-
ftype = "di" if File.directory?(str_path)
|
1050
|
-
ftype = "ln" if File.symlink?(str_path)
|
1051
|
-
begin
|
1052
|
-
File.stat(str_path) # Checking if not an orphaned link
|
1053
|
-
rescue
|
1054
|
-
ftype = "or" # Set to orphant if no link target
|
1055
|
-
end
|
1056
1036
|
fg = 7; bold = 0; bg = 0 # Set default color
|
1057
|
-
|
1037
|
+
fl = color_parse(cstr)
|
1038
|
+
fg, bold = fl[0][0].to_i, fl[0][1].to_i unless fl[0] == nil
|
1058
1039
|
init_pair(fg, fg, bg)
|
1059
1040
|
file_marker = color_pair(fg)
|
1060
1041
|
file_marker = file_marker | Curses::A_BOLD if bold == 1
|
@@ -1461,7 +1442,7 @@ def w_b_getstr(pretext, text) # A SIMPLE READLINE-LIKE ROUTINE
|
|
1461
1442
|
@w_b.setpos(0,pretext.length + pos)
|
1462
1443
|
@w_b.refresh
|
1463
1444
|
chr = getchr
|
1464
|
-
if chr ==
|
1445
|
+
if chr == 'C-G' or chr == 'C-C'
|
1465
1446
|
Curses.curs_set(0)
|
1466
1447
|
Curses.noecho
|
1467
1448
|
@w_b.update = true
|
@@ -1554,6 +1535,11 @@ def w_b_getstr(pretext, text) # A SIMPLE READLINE-LIKE ROUTINE
|
|
1554
1535
|
@history[stk].insert(pos,chr)
|
1555
1536
|
pos += 1
|
1556
1537
|
end
|
1538
|
+
while STDIN.ready?
|
1539
|
+
chr = STDIN.getc
|
1540
|
+
@history[stk].insert(pos,chr)
|
1541
|
+
pos += 1
|
1542
|
+
end
|
1557
1543
|
end
|
1558
1544
|
curstr = @history[stk]
|
1559
1545
|
@history.shift if @w_b.nohistory
|
@@ -1708,7 +1694,7 @@ loop do # OUTER LOOP - CATCHING REFRESHES VIA 'r'
|
|
1708
1694
|
close_screen
|
1709
1695
|
# If launched via the script "r", return current dir and "r" will cd to that
|
1710
1696
|
begin
|
1711
|
-
File.write(ARGV[0], Dir.pwd) if ARGV[0] and ARGV[0].match(/\/tmp
|
1697
|
+
File.write(ARGV[0], Dir.pwd) if ARGV[0] and ARGV[0].match(/\/tmp/)
|
1712
1698
|
rescue
|
1713
1699
|
end
|
1714
1700
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rtfm-filemanager
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '3.
|
4
|
+
version: '3.9'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Geir Isene
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-05-
|
11
|
+
date: 2023-05-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: curses
|
@@ -47,7 +47,8 @@ dependencies:
|
|
47
47
|
description: 'A full featured terminal browser with syntax highlighted files, images
|
48
48
|
shown in the terminal, videos thumbnailed, etc. You can bookmark and jump around
|
49
49
|
easily, delete, rename, copy, symlink and move files. RTFM has a a wide range of
|
50
|
-
other features. New in 3.
|
50
|
+
other features. New in 3.9: You can now paste onto the bottom command line. Removed
|
51
|
+
control chars in input.'
|
51
52
|
email: g@isene.com
|
52
53
|
executables:
|
53
54
|
- rtfm
|