|
15 | 15 | # Configuration from environment |
16 | 16 | HINTS = os.environ.get('TMUX_EASYMOTION_HINTS', 'asdfghjkl;') |
17 | 17 | CASE_SENSITIVE = os.environ.get('TMUX_EASYMOTION_CASE_SENSITIVE', 'false').lower() == 'true' |
| 18 | +SMARTSIGN = os.environ.get('TMUX_EASYMOTION_SMARTSIGN', 'false').lower() == 'true' |
| 19 | + |
| 20 | +# Smartsign mapping table |
| 21 | +SMARTSIGN_TABLE = { |
| 22 | + ',': '<', |
| 23 | + '.': '>', |
| 24 | + '/': '?', |
| 25 | + '1': '!', |
| 26 | + '2': '@', |
| 27 | + '3': '#', |
| 28 | + '4': '$', |
| 29 | + '5': '%', |
| 30 | + '6': '^', |
| 31 | + '7': '&', |
| 32 | + '8': '*', |
| 33 | + '9': '(', |
| 34 | + '0': ')', |
| 35 | + '-': '_', |
| 36 | + '=': '+', |
| 37 | + ';': ':', |
| 38 | + '[': '{', |
| 39 | + ']': '}', |
| 40 | + '`': '~', |
| 41 | + "'": '"', |
| 42 | + '\\': '|' |
| 43 | +} |
18 | 44 | VERTICAL_BORDER = os.environ.get('TMUX_EASYMOTION_VERTICAL_BORDER', '│') |
19 | 45 | HORIZONTAL_BORDER = os.environ.get('TMUX_EASYMOTION_HORIZONTAL_BORDER', '─') |
20 | 46 | USE_CURSES = os.environ.get( |
@@ -487,23 +513,31 @@ def draw_all_panes(panes, max_x, padding_cache, terminal_height, screen): |
487 | 513 | def find_matches(panes, search_ch): |
488 | 514 | """Find all matches and return match list""" |
489 | 515 | matches = [] |
| 516 | + |
| 517 | + # If smartsign is enabled, add corresponding symbol |
| 518 | + search_chars = [search_ch] |
| 519 | + if SMARTSIGN and search_ch in SMARTSIGN_TABLE: |
| 520 | + search_chars.append(SMARTSIGN_TABLE[search_ch]) |
| 521 | + |
490 | 522 | for pane in panes: |
491 | 523 | for line_num, line in enumerate(pane.lines): |
492 | | - # Search each position in the line |
493 | 524 | pos = 0 |
494 | 525 | while pos < len(line): |
495 | | - if CASE_SENSITIVE: |
496 | | - idx = line.find(search_ch, pos) |
497 | | - else: |
498 | | - idx = line.lower().find(search_ch.lower(), pos) |
499 | | - if idx == -1: |
| 526 | + found = False |
| 527 | + for ch in search_chars: |
| 528 | + if CASE_SENSITIVE: |
| 529 | + idx = line.find(ch, pos) |
| 530 | + else: |
| 531 | + idx = line.lower().find(ch.lower(), pos) |
| 532 | + if idx != -1: |
| 533 | + visual_col = sum(get_char_width(c) for c in line[:idx]) |
| 534 | + matches.append((pane, line_num, visual_col)) |
| 535 | + found = True |
| 536 | + pos = idx + 1 |
| 537 | + break |
| 538 | + if not found: |
500 | 539 | break |
501 | 540 |
|
502 | | - # Calculate visual column position |
503 | | - visual_col = sum(get_char_width(c) for c in line[:idx]) |
504 | | - matches.append((pane, line_num, visual_col)) |
505 | | - pos = idx + 1 |
506 | | - |
507 | 541 | return matches |
508 | 542 |
|
509 | 543 |
|
|
0 commit comments