Toggle between drvname/name when pressing n - #162
Conversation
maralorn
left a comment
There was a problem hiding this comment.
Nice. I know you are not finished, but I hope it’s okay when I already leave a few remarks.
| System.IO.hSetBuffering stdin NoBuffering | ||
| System.IO.hSetEcho stdin False |
There was a problem hiding this comment.
We should only do this once not within this forever loop. We should also make sure, that we restore the terminal state correctly on a crash.
There was a problem hiding this comment.
Wrapped this acquisition/release in a bracket call. PTAL
| data PrintNameStyle = PrintName | PrintDerivationPath deriving stock (Show, Eq, Ord, Generic) | ||
|
|
||
| data PrintState = MkPrintState | ||
| { printName :: PrintNameStyle | ||
| , printHelp :: Bool | ||
| } | ||
| deriving stock (Show, Eq, Ord, Generic) | ||
|
|
||
| initPrintState :: PrintState | ||
| initPrintState = | ||
| MkPrintState | ||
| { printName = PrintName | ||
| , printHelp = False | ||
| } | ||
|
|
There was a problem hiding this comment.
I somehow consider this thing more generally "RuntimeConfig" than "PrintState". And I wonder we could even just merge it with "Config". (But that might be annoying depending on where that is used.)
| stateToText :: Config -> NOMV1State -> Maybe (Window Int) -> (ZonedTime, Double) -> Text | ||
| stateToText config buildState@MkNOMV1State{..} = memo printWithSize . fmap Window.height | ||
| stateToText :: Config -> NOMV1State -> PrintState -> Maybe (Window Int) -> (ZonedTime, Double) -> Text | ||
| stateToText config buildState@MkNOMV1State{..} printState = memo printWithSize . fmap Window.height |
There was a problem hiding this comment.
This might be a problem. What I was trying to do here is to memoize this whole function. It should only be called new when the state or the window size changes. The function tries to precalculate most of its state and only use the input time event a little. (This might be overengineered and I am not sure whether I ever benchmarked this.)
Never-the-less passing in the new print state on every print event will invalidate the memoisation here.
There was a problem hiding this comment.
Right, I see. Hmm. I'm not familiar with memotrie, I'll have to read a bit about it to understand how it works.
|
By the way, this is awesome because there is a different feature which I would love to see: I have a commented out section somewhere where download state is shown per output and not per derivation. It is really nice because you actually see which outputs of a derivation you are downloading. However I deemed it to complex to have it on by default, but we can bring it back as a toggleable option. |
a481685 to
13894dd
Compare
| let writeToScreen :: IO () | ||
| writeToScreen = writeStateToScreen (not config.silent) linesVar state_var output_builder_var refresh_display_var maintenance printer output_handle | ||
| let keepProcessingStdin :: IO () | ||
| keepProcessingStdin = bracket setBuffering restoreBuffering $ const processStdinForeverLoop |
There was a problem hiding this comment.
Sorry for not being more explicit about this, but we are already doing some terminal mode switching in Main.hs (grep for hideCursor, showCursor). We should strive for a unified solution.
13894dd to
7f7bbf4
Compare
Here's my personal use case for this: Sometimes, I'm on my laptop and start a build before realizing I'm about to build something massive. In that case, I'd like to copy paste the drv path to launch the build on a beefy remote builder. The idea is to make NOM print the drv path instead of the derivation name when pressing the "n" key.
a85251d to
99cbe13
Compare
When the user presses h or ?, we print a short usage/help text listing the interactive key bindings. When the user presses f, we freeze the output text. I personally use this to copy/paste stuff from the terminal output, that's quite convenient. There's no visual feedback showing the output text is paused at the moment. This might be a UX footgun ><
99cbe13 to
53e2a8a
Compare
Kind of a Nit.
53e2a8a to
ea9aba0
Compare
Note: I'll add more context when this will be ready to merge. But in very short, sometimes, I'm on my laptop and start a build before realizing I'm about to build something massive. In that case, I'd like to copy paste the drv path to launch the build on a beefy remote builder. The idea is to make NOM print the drv path instead of the derivation name when pressing the
nkey.TODO