ghcup-hs icon indicating copy to clipboard operation
ghcup-hs copied to clipboard

ghcup tui shows docs on ctrl-c

Open alanz opened this issue 2 years ago • 8 comments

When I am in ghcup tui, I instinctively hit ctrl-c to quit.

And I am always surprised to be taken to a web browser opened to the docs of whatever my cursor is on at the time.

The legend at the bottom does not mention this possibility, perhaps it should, bound to something sane like d

alanz avatar Aug 26 '23 13:08 alanz

Changing the key mapping will break lots of users workflows. You can change it yourself: https://github.com/haskell/ghcup-hs/blob/d759535faaa0f7a75414e46ccb61e1ee2e5d4563/data/config.yaml#L33

We could also detect control keys and not trigger any of the actions if they are in combination with such.

hasufell avatar Aug 26 '23 13:08 hasufell

Ah, so it is looking for the key, regardless of modifiers. Can you make it ignore them if ctrl is pressed at the same time.

Going to the changelog is great, I just have a problem with <ctrl-c> doing it.

alanz avatar Aug 26 '23 14:08 alanz

The code is here: https://github.com/haskell/ghcup-hs/blob/d759535faaa0f7a75414e46ccb61e1ee2e5d4563/app/ghcup/BrickMain.hs#L315

PRs welcome.

hasufell avatar Aug 26 '23 15:08 hasufell

The code is here:

https://github.com/haskell/ghcup-hs/blob/d759535faaa0f7a75414e46ccb61e1ee2e5d4563/app/ghcup/BrickMain.hs#L315

PRs welcome.

Basically, we're ignoring the modifier: https://hackage.haskell.org/package/vty-5.38/docs/Graphics-Vty-Input-Events.html#t:Event

https://github.com/haskell/ghcup-hs/blob/d759535faaa0f7a75414e46ccb61e1ee2e5d4563/app/ghcup/BrickMain.hs#L328-L331

Should be something like

    (VtyEvent (Vty.EvKey key [])) ->
      case find (\(key', _, _) -> key' == key) (keyHandlers kb) of
        Nothing -> put st
        Just (_, _, handler) -> handler st

hasufell avatar Aug 27 '23 03:08 hasufell

I decided I could live with it when I got

[15 of 15] Compiling Codec.Archive    ( src/Codec/Archive.hs, dist/build/Codec/Archive.o, dist/build/Codec/Archive.dyn_o )

c/archive_random.c:54:13: error:
     error: static declaration of ‘arc4random_buf’ follows non-static declaration
       54 | static void arc4random_buf(void *, size_t);
          |             ^~~~~~~~~~~~~~
   |
54 | static void arc4random_buf(void *, size_t);
   |             ^

In file included from c/archive_random.c:30:0: error: 

/usr/include/stdlib.h:542:13: error:
     note: previous declaration of ‘arc4random_buf’ with type ‘void(void *, size_t)’ {aka ‘void(void *, long unsigned int)’}
      542 | extern void arc4random_buf (void *__buf, size_t __size)
          |             ^~~~~~~~~~~~~~
    |
542 | extern void arc4random_buf (void *__buf, size_t __size)
    |             ^
`gcc' failed in phase `C Compiler'. (Exit code: 1)
Error: cabal: Failed to build libarchive-3.0.3.2 (which is required by
exe:ghcup from ghcup-0.1.19.5). See the build log above for details.

having installed the deps from https://github.com/haskell/ghcup-hs/blob/d759535faaa0f7a75414e46ccb61e1ee2e5d4563/.github/workflows/bootstrap.yaml#L41

alanz avatar Aug 27 '23 09:08 alanz

See https://github.com/vmchale/libarchive/issues/32

hasufell avatar Aug 27 '23 10:08 hasufell

This unfortunately regressed:

https://github.com/haskell/ghcup-hs/blob/456200e747137761df9e7161240d014553638d17/app/ghcup/BrickMain.hs#L651-L652

@lsmor

hasufell avatar Mar 14 '24 10:03 hasufell

I am reviewing it

lsmor avatar Mar 14 '24 10:03 lsmor