[cmds.display.cc] Add a new command to force the text mode to a user specified value.#1608
[cmds.display.cc] Add a new command to force the text mode to a user specified value.#1608DepthDeluxe wants to merge 1 commit intotstack:masterfrom
Conversation
…specified value. `:set-text-source-type <type>` allows the user to override the automatically detected file type with their own desired file type.
|
Thanks for looking into this. But, I'd like to avoid adding a command, if possible. We'd need to teach people about the command, such as adding a notification to the UI. And, as I mentioned in the bug, some work needs to be done so that something meaningful is displayed and not just some question marks or other garbage. I've pushed a change that gets the "bad-converted.txt" file to display now. The change checks for a file ending in ".txt" and shouldn't treat it as binary. And, if there is non-utf8 text in the first chunk of the file, the heuristic checks if less than 70% of it is printable characters before treating it as binary. |
|
Sounds good, I still think it makes sense to have some type of override just in case the heuristic get it wrong. I originally encountered this problem when working with an embedded device that had a bug that allowed it to emit invalid UTF-8 which made lnav. To be clear, your description of applying the heuristic I believe will solve the problem I hit. That being said if I encounter another problem like this in the future, then I won't be able to use lnav to view that logfile. Thinking about this another way: is there a way to force the current file you are viewing to be viewed in hex mode? That could also be nice additional functionality. |
:set-text-source-type <type>allows the user to override the automatically detected file type with their own desired file type.Sometimes when opening a file with lnav, the file type is improperly deduced. This was first noticed on streaming data and reported in #1296. Taking the example from that issue, I was still able to reproduce improper detection when opening the raw file.
This diff allows for overriding the text source type via a custom command. From my local testing, it appears setting the source type also changes syntax highlighting on the file as well.
Opening

bad-converted.txt:Setting the text source type:
