ruby-shell 3.6.11 → 3.6.12

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 +24 -24
  3. metadata +3 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bc237db0d5ce57180ac174417e467c0c56514acb38e2513734ae0461bab02a42
4
- data.tar.gz: 601a94aa508e4b36060533b81039b33dcf69bdee82fdb4d9d38ac3b3cc857c44
3
+ metadata.gz: 83be89da460ab7d6b0534773b414a23daebaa9c93e3dedae3c1e78d53fba1a3b
4
+ data.tar.gz: c95fffc211adbc81780bcf3e9d4003cd2880d0d370777ebeb9c70a90e9f4e5e3
5
5
  SHA512:
6
- metadata.gz: 108f628485a2a6d62902e68e6ead540c870b08ac2670d3beeacf1f176ea18b5a1ccee5eab5c4a9f7e59c18f5bf5a76862e73a88971dab10f8b08f4f5614a01cf
7
- data.tar.gz: 73c30f2461c7c45055485998756e7dc350b175f426a84eda6bd6d9d59f318b8f173357eea02d786778ebe5ab0de41de6ebf168494427fa26fd36f3b58cdbaf37
6
+ metadata.gz: fd7b51b6c55a5c84e4a3a04a7ab3ce127a6977e064cc4f133c2d2ebf9759835398b60f7044e76aeb6ecf1f286db59110815e37733b0ff6ce0949ed039e1cc71b
7
+ data.tar.gz: 84f6015d8eede6d78a226124730676bbb241dd9205077767776f8b4b19b9f45fa60716fc3b2a65d7bbd5547f85f6c8e3e50f6e52b71b272682d35353df780cdc
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 = "3.6.11" # Fix auto-heal destroying .rshrc on load errors
11
+ @version = "3.6.12" # Fix long command line wrapping
12
12
 
13
13
  # MODULES, CLASSES AND EXTENSIONS
14
14
  class String # Add coloring to strings (with escaping for Readline)
@@ -374,30 +374,23 @@ def getstr # A custom Readline-like function
374
374
  row, col = @c.pos
375
375
  @prompt_last_line = @display_prompt
376
376
  # Calculate visible length (strip ANSI) - don't trust @c.pos with complex prompts
377
- @pos0 = @display_prompt.gsub(/\001\e\[[0-9;]*m\002/, '').length
377
+ @pos0 = @display_prompt.gsub(/\001?\e\[[0-9;]*m\002?/, '').length
378
378
  @cmd_row = @row0
379
379
  @is_multiline = false
380
380
  end
381
381
 
382
- @skip_prompt_print = false # Track if prompt already printed (for Ctrl-L)
383
-
384
382
  while chr != "ENTER" # Keep going with readline until user presses ENTER
385
383
  @ci = nil
386
384
  lift = false
387
385
  right = false
388
386
 
389
- # Update command line display (not the prompt!)
387
+ # Clear from cmd_row down (handles wrapped lines from previous iteration)
390
388
  @c.row(@cmd_row)
389
+ @c.col(1)
390
+ @c.clear_screen_down
391
391
 
392
- # Reprint the prompt line (preserves colors) - skip if Ctrl-L just printed it
393
- unless @skip_prompt_print
394
- @c.col(1)
395
- print @prompt_last_line
396
- @c.clear_line_after
397
- end
398
- @skip_prompt_print = false # Reset flag
399
-
400
- # Print command text with syntax highlighting
392
+ # Always reprint prompt + command text
393
+ print @prompt_last_line
401
394
  print cmd_check(@history[0])
402
395
 
403
396
  # Print history suggestion if available
@@ -411,12 +404,21 @@ def getstr # A custom Readline-like function
411
404
  right = true
412
405
  end
413
406
 
414
- # Position cursor (unified - both now use string length which is 0-indexed)
415
- # @pos0 = visible length of prompt (14 for "geir@juba: ~/ ")
416
- # @pos = position in command text (0 = start, 5 = after 5 chars)
417
- # Terminal columns are 1-indexed, so add +1
418
- cursor_col = @pos0 + @pos + 1
419
- @c.row(@cmd_row)
407
+ # Detect if terminal scrolled due to wrapping near the bottom
408
+ end_row, _ = @c.pos
409
+ printed_len = @pos0 + @history[0].to_s.length
410
+ printed_len += @ciprompt.to_s.length if right # Include suggestion text
411
+ expected_rows = printed_len > 0 ? (printed_len - 1) / @maxcol : 0
412
+ actual_start = end_row - expected_rows
413
+ if actual_start < @cmd_row
414
+ @cmd_row = [actual_start, 1].max # Terminal scrolled; adjust (min row 1)
415
+ end
416
+
417
+ # Position cursor with wrapping math
418
+ total_pos = @pos0 + @pos # 0-indexed total position
419
+ cursor_row = @cmd_row + total_pos / @maxcol
420
+ cursor_col = total_pos % @maxcol + 1
421
+ @c.row(cursor_row)
420
422
  @c.col(cursor_col)
421
423
  chr = getchr
422
424
  puts "DEBUG: Got char: '#{chr}' (length: #{chr.length})" if ENV['RSH_DEBUG']
@@ -473,11 +475,10 @@ def getstr # A custom Readline-like function
473
475
  row, col = @c.pos
474
476
  @prompt_last_line = @display_prompt
475
477
  # Calculate visible length (match main init)
476
- @pos0 = @display_prompt.gsub(/\001\e\[[0-9;]*m\002/, '').length
478
+ @pos0 = @display_prompt.gsub(/\001?\e\[[0-9;]*m\002?/, '').length
477
479
  @cmd_row = @row0
478
480
  @is_multiline = false
479
481
  end
480
- @skip_prompt_print = true # Skip reprinting on next loop iteration
481
482
  when 'UP' # Go up in history
482
483
  if @stk == 0 and @history[0].length > 0
483
484
  @tabsearch = @history[0]
@@ -541,7 +542,6 @@ def getstr # A custom Readline-like function
541
542
  @history[0][@pos] = ""
542
543
  end
543
544
  lift = true
544
- @c.clear_line_after
545
545
  when 'WBACK' # Delete one word to the left (Ctrl-W)
546
546
  unless @pos == @pos0
547
547
  # Skip over any trailing spaces first
@@ -556,7 +556,6 @@ def getstr # A custom Readline-like function
556
556
  end
557
557
  end
558
558
  lift = true
559
- @c.clear_line_after
560
559
  when 'C-Y' # Copy command line to primary selection
561
560
  system("echo -n '#{@history[0]}' | xclip")
562
561
  puts "\n#{Time.now.strftime("%H:%M:%S")}: Copied to primary selection (paste with middle buttoni)".c(@c_stamp)
@@ -603,6 +602,7 @@ def getstr # A custom Readline-like function
603
602
  end
604
603
  while $stdin.ready?
605
604
  chr = $stdin.getc
605
+ chr = " " if chr == "\n" || chr == "\r" # Flatten pasted newlines
606
606
  @history[0].insert(@pos,chr)
607
607
  @pos += 1
608
608
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-shell
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.6.11
4
+ version: 3.6.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Geir Isene
@@ -12,7 +12,8 @@ date: 2026-02-19 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. UPDATE
15
- v3.6.11: Fix auto-heal destroying .rshrc - never strip user config on load errors.'
15
+ v3.6.12: Fix long command line wrapping - correct cursor positioning when commands
16
+ exceed terminal width.'
16
17
  email: g@isene.com
17
18
  executables:
18
19
  - rsh