nkh / P5-App-Asciio

Plain ASCII diagram
https://nkh.github.io/P5-App-Asciio/
56 stars 4 forks source link

Key completion position error when scroll bar is not in initial position #162

Closed qindapao closed 1 year ago

qindapao commented 1 year ago

binding_complet_error

If the scroll bar is not in the initial position, the key completion popup will be in the wrong position.

qindapao commented 1 year ago

@nkh I have fixed it, and Also fixed a command box encoding error in some environments.

https://github.com/qindapao/P5-App-Asciio/tree/fix_binding_compl

This time I tried to draw a asciio to analyze this problem

                                y
                                ^
                                │
                                │
   (mouse_x = 0,mouse_y = 0)    │
                    |           │
                    |           │
                    '---------->o═══════════════════════════╤═══════════════╗ ──────
                                │                           ┃   ^           ║    ^
                                │                           ┃   │           ║    │
                                │                           ┃   │           ║    │
                                │                           │   │           ║    │
                                │                           │ window_height ║    │
                                │                           │   │           ║    │ CANVAS_HEIGHT * character_height
   .---------------.            │                           │   │           ║    │
   | initial state |            │                           │   │           ║    │
   '---------------'            │                           │   v           ║    │
                           ─────┾━━━━━━─────────────────────┼───────────────╫────┼──────> x
                                │                           │               ║    │
                                │<─────────────────────────>│               ║    │
                                │       window_width        │               ║    │
                                │                                           ║    │
                                │                                           ║    │
                                │                                           ║    v
                                ╞═══════════════════════════════════════════╝  ──────
                                │
                                │                                           │
                                │<─────────────────────────────────────────>│
                                │     CANVAS_WIDTH * character_width        │

    (mouse_x = 0,mouse_y = 0)
                |
                '-------.       y                  my ($window_width, $window_height) = $self->{root_window}->get_size() ;
                        |       ^                  my ($scroll_bar_x, $scroll_bar_y) = ($self->{sc_window}->get_hadjustment(), $self->{sc_window}->get_vadjustment()) ;
-------------------.    |       │
 scroll bar scroll |    v       │
-------------------'    ╔═══════╪═══════════════════════════════════╗---------------------------------------
                        ║       │                                   ║                               ^
                        ║       │                                   ║                               │scroll_bar_y
                        ║       ├───────────────────────────╮---------------------------------------v
                        ║       │                           │       ║
                        ║       │     *(mouse_x,mouse_y)    │       ║
                   scroll_bar_x │                           ┃       ║
                        ║<─────>│                           ┃       ║
                        ║       │                           ┃       ║
                        ║       │                           ┃       ║
                        ║       │                           │       ║
                        ║       │                           │       ║
                        ║       │                           │       ║
                        ║  ─────┼─────━━━━━━━───────────────┴───────╫───────────────────> x
                        ║       │                                   ║
                        ║       │                                   ║
                        ║       │                                   ║
                        ╚═══════╪═══════════════════════════════════╝
                                │
                                │
                                │
                                │
                                │

binding_completion.zip

nkh commented 1 year ago

@qindapao merged