kdheepak / TerminalUserInterfaces.jl

Terminal User Interfaces in Julia.
MIT License
97 stars 5 forks source link

undefined reference in disable_raw_mode() #10

Closed remy-luisant closed 3 years ago

remy-luisant commented 3 years ago

This could be a case of me misusing the library, but enable_raw_mode() works just fine and lets me get the work done. It does not seem like I can disable it, however.

julia> TerminalUserInterfaces.disable_raw_mode()
ERROR: UndefRefError: access to undefined reference
Stacktrace:
 [1] getproperty
   @ ./Base.jl:33 [inlined]
 [2] getindex
   @ ./refvalue.jl:56 [inlined]
 [3] disable_raw_mode()
   @ TerminalUserInterfaces ~/.julia/packages/TerminalUserInterfaces/Mhqzn/src/utils.jl:191
 [4] top-level scope
   @ REPL[2]:1
kdheepak commented 3 years ago

I think this is a bug. Can you try calling backup_termios() before enable_raw_mode()?

remy-luisant commented 3 years ago

This appears to fix the problem.

kdheepak commented 3 years ago

I’m guessing you aren’t calling initialize: https://github.com/kdheepak/TerminalUserInterfaces.jl/blob/9d55682a1c9ce67f2af292518f7b0cd3aa2efefd/src/utils.jl#L202

remy-luisant commented 3 years ago

No, I'm using just the one call to enable raw mode, since all I wanted to get is keyboard control. initialize() would clear the screen, hide the cursor, etc...

kdheepak commented 3 years ago

Got it. I’ll have to add a __init__ to the package and call backup_termios there.

kdheepak commented 3 years ago

Fixed in https://github.com/kdheepak/TerminalUserInterfaces.jl/commit/4026cc747ffb9baaf86845a7667b5e5ed2fcb97b.

kdheepak commented 3 years ago

I've made a new release too.