ruby-shell 2.5 → 2.6.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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/bin/rsh +30 -9
  3. metadata +4 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e4cbdfe9d1c09e98287dff7de8cfabb7dd776fa6f7617f4a0801d17f7b463bad
4
- data.tar.gz: cf3b1311d1891caa516b427ef065f79f3d6b23e2486f5d070111f7040a812a05
3
+ metadata.gz: c448c172084960387cf539a563720fdc291cac640eb74a5d34fa4b65bc21b966
4
+ data.tar.gz: bf946b66b54703b33e8f001739ae5b143475525b2faa7e6428f027a7303475de
5
5
  SHA512:
6
- metadata.gz: 673ee174f332d75d8cc0bf5a9570f18d02931e047386e23e727fb6f8ecb16a694095d59d609cc45b7438b49d5b7be4b801465398fe831f84bbc78b38287af69a
7
- data.tar.gz: 35a0eac8a83bbf933deb101fd5e920414c59827dd43292889a300a26d0979cf1de9967acbb78c56ee332da7f605311e57bd7caba799eb82ea15b5dd3160fb3b2
6
+ metadata.gz: f098198470e145eae96a6d59438279d38f786129b1b45370b407403a4de8c11d595304b5d975b0d590aca5ae8bf4e5cab2b9311a3c3806b6d2b41d6cbd307a46
7
+ data.tar.gz: e682544786e24f145682628c7598e1b848a99f3db2e8df910adeb3b30f7c422d15f50c80326b9d7d02a8d7ca11fef8d8d50b332ff7b327b614fbb21dd79b319a
data/bin/rsh CHANGED
@@ -8,7 +8,7 @@
8
8
  # Web_site: http://isene.com/
9
9
  # Github: https://github.com/isene/rsh
10
10
  # License: Public domain
11
- @version = "2.5"
11
+ @version = "2.6.1"
12
12
 
13
13
  # MODULES, CLASSES AND EXTENSIONS
14
14
  class String # Add coloring to strings (with escaping for Readline)
@@ -42,6 +42,14 @@ module Cursor # Terminal cursor movement ANSI codes (thanks to https://github.co
42
42
  m = res.match /(?<row>\d+);(?<col>\d+)/
43
43
  return m[:row].to_i, m[:col].to_i
44
44
  end
45
+ def rowget
46
+ row, col = self.pos
47
+ return row
48
+ end
49
+ def colget
50
+ row, col = self.pos
51
+ return col
52
+ end
45
53
  def up(n = nil) # Move cursor up by n
46
54
  print(CSI + "#{(n || 1)}A")
47
55
  end
@@ -260,12 +268,16 @@ def getstr # A custom Readline-like function
260
268
  @pos = 0
261
269
  chr = ""
262
270
  @history.unshift("")
271
+ @row0, p = @c.pos
263
272
  while chr != "ENTER" # Keep going with readline until user presses ENTER
264
273
  @ci = nil
265
274
  lift = false
266
275
  right = false
276
+ # The actual printing og the command line
277
+ @c.row(@row0)
267
278
  @c.clear_line
268
279
  print @prompt
280
+ @c.clear_screen_down
269
281
  row, @pos0 = @c.pos
270
282
  #@history[0] = "" if @history[0].nil?
271
283
  print cmd_check(@history[0])
@@ -278,7 +290,15 @@ def getstr # A custom Readline-like function
278
290
  print @ciprompt.c(@c_stamp)
279
291
  right = true
280
292
  end
281
- @c.col(@pos0 + @pos)
293
+ c_col = @pos0 + @pos
294
+ c_row = @row0 + c_col/(@maxcol)
295
+ c_col == 0 ? @c.row(c_row + 1) : @c.row(c_row)
296
+ if c_col.modulo(@maxcol) == 0
297
+ @c.col(c_col)
298
+ @c.row(@c.rowget - 1)
299
+ else
300
+ @c.col(c_col.modulo(@maxcol))
301
+ end
282
302
  chr = getchr
283
303
  case chr
284
304
  when 'C-G', 'C-C'
@@ -292,6 +312,7 @@ def getstr # A custom Readline-like function
292
312
  exit
293
313
  when 'C-L' # Clear screen and set position to top of the screen
294
314
  @c.row(1)
315
+ @row0 = 1
295
316
  @c.clear_screen_down
296
317
  when 'UP' # Go up in history
297
318
  if @stk == 0 and @history[0].length > 0
@@ -311,6 +332,8 @@ def getstr # A custom Readline-like function
311
332
  end
312
333
  lift = false
313
334
  end
335
+ @c.row(@row0)
336
+ @c.clear_screen_down
314
337
  when 'DOWN' # Go down in history
315
338
  if lift
316
339
  @history.unshift("")
@@ -330,6 +353,8 @@ def getstr # A custom Readline-like function
330
353
  @pos = @history[0].length
331
354
  end
332
355
  lift = false
356
+ @c.row(@row0)
357
+ @c.clear_screen_down
333
358
  when 'RIGHT' # Move right on the readline
334
359
  if right
335
360
  if lift
@@ -356,6 +381,7 @@ def getstr # A custom Readline-like function
356
381
  @history[0][@pos] = ""
357
382
  end
358
383
  lift = true
384
+ @c.clear_line_after
359
385
  when 'WBACK' # Delete one word to the left (Ctrl-W)
360
386
  unless @pos == @pos0
361
387
  until @history[0][@pos - 1] == " " or @pos == 0
@@ -368,6 +394,7 @@ def getstr # A custom Readline-like function
368
394
  end
369
395
  end
370
396
  lift = true
397
+ @c.clear_line_after
371
398
  when 'C-Y' # Copy command line to primary selection
372
399
  system("echo -n '#{@history[0]}' | xclip")
373
400
  puts "\n#{Time.now.strftime("%H:%M:%S")}: Copied to primary selection (paste with middle buttoni)".c(@c_stamp)
@@ -406,7 +433,7 @@ def getstr # A custom Readline-like function
406
433
  @pos += 1
407
434
  end
408
435
  end
409
- @c.col(@pos0 + @history[0].length)
436
+ #@c.col(@pos0 + @history[0].length)
410
437
  @c.clear_screen_down
411
438
  end
412
439
  def tab(type)
@@ -545,17 +572,11 @@ def hist_clean # Clean up @history
545
572
  end
546
573
  def cmd_check(str) # Check if each element on the readline matches commands, nicks, paths; color them
547
574
  return if str.nil?
548
- #elements = str.scan(/[^\s']+|'.+?'/)
549
- #elements.map! do |el|
550
- # .... the ifs
551
- #elements.join(" ")
552
575
  str.gsub(/(?:\S'[^']*'|[^ '])+/) do |el|
553
576
  if @exe.include?(el)
554
577
  el.c(@c_cmd)
555
578
  elsif el == "cd"
556
579
  el.c(@c_cmd)
557
- elsif File.executable?(el.gsub("'", ""))
558
- el.c(@c_cmd)
559
580
  elsif File.exist?(el.gsub("'", ""))
560
581
  el.c(@c_path)
561
582
  elsif @nick.include?(el)
metadata CHANGED
@@ -1,19 +1,20 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-shell
3
3
  version: !ruby/object:Gem::Version
4
- version: '2.5'
4
+ version: 2.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Geir Isene
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-10-29 00:00:00.000000000 Z
11
+ date: 2024-10-31 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: 'A shell written in Ruby with extensive tab completions, aliases/nicks,
14
14
  history, syntax highlighting, theming, auto-cd, auto-opening files and more. In
15
15
  continual development. New in 2.0: Full rewrite of tab completion engine. Lots of
16
- other bug fixes. 2.5: Speedup of syntax highlighting and tab completions.'
16
+ other bug fixes. 2.6: Handling line longer than terminal width. 2.6.1: Fixed Ctrl-L
17
+ bug.'
17
18
  email: g@isene.com
18
19
  executables:
19
20
  - rsh