rtfm-filemanager 1.3.5 → 1.3.9

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/bin/rtfm +43 -26
  3. metadata +3 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2fdfba59295e424a39605d0501e0df29a7a37d9ad36429adb412d8d13c54c752
4
- data.tar.gz: 2a5523150436439dbbcabf66a7e9c8505c7ad30c82fd827e2b198ab5f73361e9
3
+ metadata.gz: da9c8e1fd1f0c686be71e26551d824ec5a7163c63a312b52f0858947c53d9884
4
+ data.tar.gz: 697e2567e81bece7afba8b466d4d6f803fb631cf410d0c2f2e44112ea88ba813
5
5
  SHA512:
6
- metadata.gz: 5e1cf39a6d5e205a7ea226bc8c70d885037077d1ed918450634a8fc9feb179dee05a03f58bcc174609c7419231b2d4df3b1f1b3bd7cb4cc89bd4a01d658124c6
7
- data.tar.gz: 5a152abd6d7c54de6c116f6ecac690e939cd2d07b28a1e7b9d4261337f72e6b23a833162567ccd6fb6674d5e92882551d9f27e3d7167ac4d61c00d6eb894b492
6
+ metadata.gz: 4879b5abfa28e6f3023a48e105d20e8009f64ddbcfee3e5e6cb47a84c3fce93f645bd4cee6c6540460ef2539af9b47b21792c8cebd32a7e7dc9960b7cad497fd
7
+ data.tar.gz: d52ced54337ef56d9e7e666f5139f8f8cc0a4685a2496526572aa76492e984e684d06db37e35598419e537f79d0b70ab0356bab18ef9c51cba14c9adeb473b50
data/bin/rtfm CHANGED
@@ -188,7 +188,7 @@ begin # BASIC SETUP
188
188
  end
189
189
  end
190
190
  class Curses::Window # CLASS EXTENSION
191
- attr_accessor :fg, :bg, :attr, :text, :update, :pager, :pager_more, :pager_cmd, :locate, :nohistory
191
+ attr_accessor :fg, :bg, :attr, :text, :update, :pager, :pager_more, :pager_cmd, :locate, :nohistory
192
192
  # General extensions (see https://github.com/isene/Ruby-Curses-Class-Extension)
193
193
  def clr
194
194
  self.setpos(0, 0)
@@ -228,12 +228,12 @@ def get_ls_color(type) # GET THE COLOR FOR THE FILETYPE FROM IMPORTED LS_COLORS
228
228
  return color.to_i, bold
229
229
  end
230
230
  def color_parse(input) # PARSE ANSI COLOR SEQUENCES
231
- input.gsub!( /\e\[\d;38;5;(\d+)m/, '%-%\1%-%')
232
- input.gsub!( /\e\[38;5;(\d+)m/, '%-%\1%-%')
231
+ input.gsub!( /\e\[\d;38;5;(\d+);*(\d*)m/, '¤¤\1¤¤\2¤¤')
232
+ input.gsub!( /\e\[38;5;(\d+);*(\d*)m/, '¤¤\1¤¤\2¤¤')
233
233
  input.gsub!( /\e\[0m/, "\t")
234
- color_array = input.split("%-%")
234
+ color_array = input.split("¤¤")
235
235
  color_array = color_array.drop(1)
236
- output = color_array.each_slice(2).to_a
236
+ output = color_array.each_slice(3).to_a
237
237
  return output
238
238
  end
239
239
  def getchr # PROCESS KEY PRESSES
@@ -561,23 +561,27 @@ def main_getkey # GET KEY FROM USER
561
561
  @w_b.update = false
562
562
  when 'S' # Show comprehensive system info
563
563
  @w_r.pager_cmd = ""
564
- systext = `uname -o`.chop + " "
565
- systext += `uname -r`.chop + " "
566
- systext += `uname -v`.chop + " "
567
- systext += `uname -p` + "\n"
568
- systext += `free -h` + "\n"
569
- systext += "CPUs = " + `nproc`.chop + " "
570
- cpuinfo = `lscpu`
571
- systext += cpuinfo[/^.*Model name:\s*(.*)/, 1] + " "
572
- systext += "Max: " + cpuinfo[/^.*CPU max MHz:\s*(.*)/, 1][/(.*),.*/, 1] + "MHz "
573
- systext += "Min: " + cpuinfo[/^.*CPU min MHz:\s*(.*)/, 1][/(.*),.*/, 1] + "MHz "
574
- systext += "\n\n"
575
- systext += `df -H`
576
- systext += "\nDMESG:\n"
577
- systext += `dmesg | tail -10`
578
- @w_r.fg = 155
579
- w_r_info(systext)
580
- @w_r.update = false
564
+ uname = `uname -o`.chop + " "
565
+ uname += `uname -r`.chop + " "
566
+ uname += `uname -v`.chop + " "
567
+ uname += `uname -p` + "\n"
568
+ text = [[253, 1, uname]]
569
+ cpu = "CPUs = " + `nproc`.chop + " "
570
+ cpuinfo = `lscpu`
571
+ cpu += cpuinfo[/^.*Model name:\s*(.*)/, 1] + " "
572
+ cpu += "Max: " + cpuinfo[/^.*CPU max MHz:\s*(.*)/, 1][/(.*),.*/, 1] + "MHz "
573
+ cpu += "Min: " + cpuinfo[/^.*CPU min MHz:\s*(.*)/, 1][/(.*),.*/, 1] + "MHz\n\n"
574
+ text += [[154, 0, cpu]]
575
+ mem = `free -h` + "\n"
576
+ text += [[229, 0, mem]]
577
+ ps = `ps -eo comm,pid,user,pcpu,pmem,stat --sort -pcpu,-pmem | head` + "\n"
578
+ text += [[195, 0, ps]]
579
+ disk = `df -H | head -8`
580
+ text += [[172, 0, disk]]
581
+ dmesg = "\nDMESG:\n"
582
+ dmesg += `dmesg | tail -6`
583
+ text += [[219, 0, dmesg]]
584
+ w_r_info(ansifix(text))
581
585
  # RIGHT PANE
582
586
  when 'ENTER' # Refresh right pane
583
587
  @w_r.clr # First clear the window, then clear any previously showing image
@@ -696,6 +700,16 @@ def conf_write
696
700
  end
697
701
  File.write(Dir.home+'/.rtfm.conf', conf)
698
702
  end
703
+ def ansifix(text) # Format [[fg, attr, text]]
704
+ output = ""
705
+ text.each do |e|
706
+ ansi = "\e[38;5;#{e[0]}"
707
+ ansi += ";1" if e[1] == 1
708
+ ansi += "m"
709
+ output += ansi + e[2].gsub(/\n/, "\n#{ansi}")
710
+ end
711
+ return output
712
+ end
699
713
  # TOP WINDOW FUNCTIONS
700
714
  def w_t_info # SHOW INFO IN @w_t
701
715
  text = " " + ENV['USER'].to_s + "@" + `hostname 2>/dev/null`.to_s.chop + ": " + Dir.pwd + "/"
@@ -971,15 +985,17 @@ def tagged_info # SHOW THE LIST OF TAGGED ITEMS IN @w_r
971
985
  @tagged.empty? ? info += "(None)" : info += @tagged.join("\n")
972
986
  w_r_info(info)
973
987
  end
974
- def syntax_highlight(input) # BATCAT SYNTAX HIGHLIGHTING
988
+ def syntax_highlight(input) # SYNTAX HIGHLIGHTING FROM ANSI COLOR CODES
975
989
  color_ary = color_parse(input)
976
990
  color_ary.each do | pair |
977
991
  begin
978
992
  fg = pair[0].to_i
979
- text = pair[1]
993
+ atr = pair[1].to_i
994
+ atr == 1 ? atr = Curses::A_BOLD : atr = 0
995
+ text = pair[2]
980
996
  text.gsub!(/\t/, '')
981
997
  init_pair(fg, fg, 0)
982
- @w_r.attron(color_pair(fg)) { @w_r << text }
998
+ @w_r.attron(color_pair(fg) | atr) { @w_r << text }
983
999
  rescue
984
1000
  end
985
1001
  end
@@ -1033,7 +1049,8 @@ def pager_show # SHOW THE CURRENT PAGE CONTENT
1033
1049
  end_l = beg_l + @w_r.maxy - 2
1034
1050
  input = @w_r.text.lines[beg_l..end_l].join() + "\n"
1035
1051
  input.lines.count > @w_r.maxy - 2 ? @w_r.pager_more = true : @w_r.pager_more = false
1036
- if @w_r.pager_cmd.match(/batcat/)
1052
+ #if @w_r.pager_cmd.match(/batcat/)
1053
+ if @w_r.text.match(/^\e\[/)
1037
1054
  syntax_highlight(input)
1038
1055
  else
1039
1056
  if @w_r.fg == nil
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: 1.3.5
4
+ version: 1.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: 2021-10-25 00:00:00.000000000 Z
11
+ date: 2021-10-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: curses
@@ -33,8 +33,7 @@ dependencies:
33
33
  description: 'A full featured terminal browser with syntax highlighted files, images
34
34
  shown in the terminal, videos thumbnailed, etc. You can bookmark and jump around
35
35
  easily, delete, rename, copy, symlink and move files. RTFM has a a wide range of
36
- other features. New in 1.3.5: Sexify by color some of the info shown in right pane
37
- (like Help, Tagged, Marks and System Info)'
36
+ other features. New in 1.3.9: Code cleanup and a minor bug fix'
38
37
  email: g@isene.com
39
38
  executables:
40
39
  - rtfm