Here's a demo of me using it in my modified General Text Files section:
https://conchaos.synchro.net/img/viewfile_demo.gif
As discussed in Synchronet Discussion, I wanted a viewer for text files with a scrollable interface.
This is the one that I came up with. Some parts I lifted from other modules to try to understand how frames and scrollbars work. It works, but it's far from perfect. I plan to use it in conjunction with some other mods that I tinker with (news readers, inter-bbs one-liner history, etc) as well as general text files.
It uses a frame object to display the text, but I'm starting to think that's not the best idea. Some files take a long time to load, and files no larger than 117 KB can lead to "out of memory" errors. Getting the impression frames weren't meant for "large" objects, so maybe there's a better way.
I agree: large files can be problematic. Modern log files can be gigabytes in size these days (!). You could maybe have some file size threshold beyond which you just punt and use printfile() or have your script load the file into memory in chunks (how printfile() works by default).
script load the file into memory in chunks (how printfile() works by
default).
That's interesting. Like just use the frame object as a kind of viewport for the lines I want to display, and use the up/down/etc to control which range of lines come into view. Seems very doable. Thanks for the thought.
file_lines = convertAttrsToSyncPerSysCfg(txt.read() ).replace(/\f/g,
Re: Custom Scrollabe Text File Viewer
By: Codefenix to Digital Man on Wed Nov 06 2024 06:05 pm
file_lines = convertAttrsToSyncPerSysCfg(txt.read() ).replace(/\f/g,
ConvertAttrsToSyncPerSysCfg() uses the configuration optoins from SCFG > Message Options > Extra Attribute Codes, which I think are specifically intended for messages posted in the message sub-boards. DM might correct me on this, but if you're making a general text file viewer, I'm wondering if it might make more sense to ignore those settings and just convert all attribute codes, or have your reader have its own settings for which attributes to convert.
The settings in SCFG->Message Options->Extra Attribute Codes actually impact the function of sbbs_t::putmsg() routine, used by printfile, menu and friends (and their JS equivalents), so not just message text.
Sysop: | MarisaG |
---|---|
Location: | South San Francisco, CA |
Users: | 81 |
Nodes: | 15 (0 / 15) |
Uptime: | 153:46:13 |
Calls: | 1,431 |
Calls today: | 1 |
Files: | 7 |
Messages: | 22,128 |