ruby-shell 3.6.11 → 3.6.13

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 +27 -24
  3. metadata +4 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bc237db0d5ce57180ac174417e467c0c56514acb38e2513734ae0461bab02a42
4
- data.tar.gz: 601a94aa508e4b36060533b81039b33dcf69bdee82fdb4d9d38ac3b3cc857c44
3
+ metadata.gz: d27f9b0e122174a3556a1954950ab96e27ce57193d6a31fe7c8d0ec807fbc9b8
4
+ data.tar.gz: fed1c864573944923034b58fe24a128bbd60899db4d7d2104bc0a1b3e6b2c99d
5
5
  SHA512:
6
- metadata.gz: 108f628485a2a6d62902e68e6ead540c870b08ac2670d3beeacf1f176ea18b5a1ccee5eab5c4a9f7e59c18f5bf5a76862e73a88971dab10f8b08f4f5614a01cf
7
- data.tar.gz: 73c30f2461c7c45055485998756e7dc350b175f426a84eda6bd6d9d59f318b8f173357eea02d786778ebe5ab0de41de6ebf168494427fa26fd36f3b58cdbaf37
6
+ metadata.gz: fde7b317a383ed186df64a0abd17fc35189d90cc522fa5c14df83229584b6ac90c54bfc51fda1c25c4a49b6912ecc464b953d8796fee944e8c469233370bc132
7
+ data.tar.gz: c1dcd5f4fa4a492b4f97443e8c58cc3a77c065ab1f536c46b0d15a6d87ca78e08003943701cea95420b99d399ec378a365855b08a7318409e784ebd998a48707
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.13" # Refresh terminal width each prompt (fix stale @maxcol)
12
12
 
13
13
  # MODULES, CLASSES AND EXTENSIONS
14
14
  class String # Add coloring to strings (with escaping for Readline)
@@ -334,6 +334,9 @@ def getstr # A custom Readline-like function
334
334
  @ai_suggestion = nil
335
335
  end
336
336
 
337
+ # Refresh terminal dimensions (handles resize since startup)
338
+ @maxrow, @maxcol = IO.console.winsize
339
+
337
340
  # Print prompt ONCE at start (optimization + multi-line support)
338
341
  @row0, p = @c.pos
339
342
 
@@ -374,30 +377,23 @@ def getstr # A custom Readline-like function
374
377
  row, col = @c.pos
375
378
  @prompt_last_line = @display_prompt
376
379
  # 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
380
+ @pos0 = @display_prompt.gsub(/\001?\e\[[0-9;]*m\002?/, '').length
378
381
  @cmd_row = @row0
379
382
  @is_multiline = false
380
383
  end
381
384
 
382
- @skip_prompt_print = false # Track if prompt already printed (for Ctrl-L)
383
-
384
385
  while chr != "ENTER" # Keep going with readline until user presses ENTER
385
386
  @ci = nil
386
387
  lift = false
387
388
  right = false
388
389
 
389
- # Update command line display (not the prompt!)
390
+ # Clear from cmd_row down (handles wrapped lines from previous iteration)
390
391
  @c.row(@cmd_row)
392
+ @c.col(1)
393
+ @c.clear_screen_down
391
394
 
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
395
+ # Always reprint prompt + command text
396
+ print @prompt_last_line
401
397
  print cmd_check(@history[0])
402
398
 
403
399
  # Print history suggestion if available
@@ -411,12 +407,21 @@ def getstr # A custom Readline-like function
411
407
  right = true
412
408
  end
413
409
 
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)
410
+ # Detect if terminal scrolled due to wrapping near the bottom
411
+ end_row, _ = @c.pos
412
+ printed_len = @pos0 + @history[0].to_s.length
413
+ printed_len += @ciprompt.to_s.length if right # Include suggestion text
414
+ expected_rows = printed_len > 0 ? (printed_len - 1) / @maxcol : 0
415
+ actual_start = end_row - expected_rows
416
+ if actual_start < @cmd_row
417
+ @cmd_row = [actual_start, 1].max # Terminal scrolled; adjust (min row 1)
418
+ end
419
+
420
+ # Position cursor with wrapping math
421
+ total_pos = @pos0 + @pos # 0-indexed total position
422
+ cursor_row = @cmd_row + total_pos / @maxcol
423
+ cursor_col = total_pos % @maxcol + 1
424
+ @c.row(cursor_row)
420
425
  @c.col(cursor_col)
421
426
  chr = getchr
422
427
  puts "DEBUG: Got char: '#{chr}' (length: #{chr.length})" if ENV['RSH_DEBUG']
@@ -473,11 +478,10 @@ def getstr # A custom Readline-like function
473
478
  row, col = @c.pos
474
479
  @prompt_last_line = @display_prompt
475
480
  # Calculate visible length (match main init)
476
- @pos0 = @display_prompt.gsub(/\001\e\[[0-9;]*m\002/, '').length
481
+ @pos0 = @display_prompt.gsub(/\001?\e\[[0-9;]*m\002?/, '').length
477
482
  @cmd_row = @row0
478
483
  @is_multiline = false
479
484
  end
480
- @skip_prompt_print = true # Skip reprinting on next loop iteration
481
485
  when 'UP' # Go up in history
482
486
  if @stk == 0 and @history[0].length > 0
483
487
  @tabsearch = @history[0]
@@ -541,7 +545,6 @@ def getstr # A custom Readline-like function
541
545
  @history[0][@pos] = ""
542
546
  end
543
547
  lift = true
544
- @c.clear_line_after
545
548
  when 'WBACK' # Delete one word to the left (Ctrl-W)
546
549
  unless @pos == @pos0
547
550
  # Skip over any trailing spaces first
@@ -556,7 +559,6 @@ def getstr # A custom Readline-like function
556
559
  end
557
560
  end
558
561
  lift = true
559
- @c.clear_line_after
560
562
  when 'C-Y' # Copy command line to primary selection
561
563
  system("echo -n '#{@history[0]}' | xclip")
562
564
  puts "\n#{Time.now.strftime("%H:%M:%S")}: Copied to primary selection (paste with middle buttoni)".c(@c_stamp)
@@ -603,6 +605,7 @@ def getstr # A custom Readline-like function
603
605
  end
604
606
  while $stdin.ready?
605
607
  chr = $stdin.getc
608
+ chr = " " if chr == "\n" || chr == "\r" # Flatten pasted newlines
606
609
  @history[0].insert(@pos,chr)
607
610
  @pos += 1
608
611
  end
metadata CHANGED
@@ -1,18 +1,19 @@
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.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Geir Isene
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-02-19 00:00:00.000000000 Z
11
+ date: 2026-02-26 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.13: Fix cursor position on wide terminals - refresh terminal dimensions each
16
+ prompt cycle.'
16
17
  email: g@isene.com
17
18
  executables:
18
19
  - rsh