[Home] [Downloads] [Search] [Help/forum]


Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Suggestions
. . -> [Subject]  Telnet clearscreen via plugins or optional

Telnet clearscreen via plugins or optional

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page


Pages: 1 2  

Posted by David Haley   USA  (3,881 posts)  [Biography] bio
Date Thu 06 Jan 2005 04:49 PM (UTC)
Message
I know that a lot of people have been asking for the clearscreen ability, and you've not wanted to for a variety of reasons. For instance, the problem of what to do with the log.

Since it really can be useful from a MUD server's point of view, I'd like to propose a compromise of sorts. :-)

Option 1: make it an option - if the client receives a clear screen directive, the client will simply print out the appropriate amount of newlines to the output. The client will choose a character or sequence of characters to be printed out to the log, e.g. a horizontal rule in HTML.

Option 2: have the necessary commands available to plugins to do the same thing. In essence it'd be world.noting lines, but I don't know if there's functionality to obtain the number of lines in the window height. It would be something like:
for i = 0 to window.numberOfLines {
  world.note "\n"
}
The plugin could then generate the appropriate response for the log.

The plugin could also probably choose to replace lines from the scrollback buffer, which would be even better in some situations.


In any case, it really can be useful, and in fact I've found a few uses for BMud that I'll discuss at some point, so it would be nice to have the functionality one way or another in MUSHclient. If you don't want to answer the questions yourself (e.g. what to do with the log?) then let it be delegated to plugin authors, who can respond as they see fit for their particular usage.

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
[Go to top] top

Posted by Nick Gammon   Australia  (22,973 posts)  [Biography] bio   Forum Administrator
Date Reply #1 on Fri 07 Jan 2005 05:09 AM (UTC)
Message
You could estimate the number of lines from the client window size, which you can currently get. It is hard to give an exact figure, because the player may do a second window and resize it, thus having two different size windows for the same world, in which case there is not single figure for the number of lines.

You can already write such a thing in a plugin by using OnPluginPacketReceived to detect clearscreens and output the lines yourself.

However what I can see happening is that MUD server writers will then start doing a clearscreen for every room, and your output buffer will start filling up with mostly blank lines which is your attempt to simulate screen clears. That would be really annoying when you try to scroll back to find things.

What I have done as a compromise is add a new function "NoteHr" which lets you add a horizontal rule, like the MXP <hr> tag. You could use this to logically break up descriptions - that is, put a rule where the clearscreen is.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by David Haley   USA  (3,881 posts)  [Biography] bio
Date Reply #2 on Fri 07 Jan 2005 07:16 AM (UTC)
Message
The thing is that it's really not for breaks - it's for truly erasing whatever came before (e.g. maps, or the login sequence before the MOTD.) I suppose a break would somewhat work, even if it's really not the visual effect intended.

Still, this kind of effect certainly wouldn't be used for every room - that would be silly. This kind of feature I've seen used primarily for maps that get updated every once in a while, or similar things - in general, displays of information that gets updated in-place. Instead of outputting the same thing over and over again, which clogs up lots and lots of screen space, simply remove the old one and add a new one.

I suppose the solution would be to throw in newlines, but is there no way to get the exact line count of the primary window? If somebody has two windows open, too bad for them. :-)

It wouldn't really bother me to have newlines. But ideally, the buffer contents would actually be replaced somehow. I'm really not concerned about what happens in the log; that's why I thought that the plugin could manage what happens in the log. Perhaps the log could have the horizontal line as you described, but the buffer would lose whatever contents were in the 'screen' or output newlines as necessary, to create the very important visual effect of having the contents replaced.

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
[Go to top] top

Posted by Nick Gammon   Australia  (22,973 posts)  [Biography] bio   Forum Administrator
Date Reply #3 on Fri 07 Jan 2005 07:47 PM (UTC)
Message
Quote:

But ideally, the buffer contents would actually be replaced somehow.


Ah, then that is simple. A small plugin will do it for you ...


<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>

<muclient>
<plugin
   name="clearscreen"
   author="Nick Gammon"
   id="9cd2234d5d678d86d412f266"
   language="Lua"
   purpose="Clears output buffer on clearscreen character"
   date_written="2005-01-08"
   requires="3.59"
   version="1.0"
   >
</plugin>

<!--  Script  -->

<script>
<![CDATA[

function OnPluginPacketReceived (s)

 if string.find (s, string.char (12)) then
   DeleteOutput ()
 end -- if
  
end -- function OnPluginPacketReceived
]]>
</script>

</muclient>


This detects the clearscreen character (0x0C) and deletes all output when received. Of course, you won't be able to scroll back, but you said you don't mind that.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by David Haley   USA  (3,881 posts)  [Biography] bio
Date Reply #4 on Fri 07 Jan 2005 11:27 PM (UTC)
Message
Hmm. I didn't have in mind *all* the output, just one page, but I suspect this is getting somewhat irritating. *grin* Still, that solution would be good, I think.

How hard would it be to write a function that, given an output window, returned the number of vertical lines? Then to be able to clear (delete) just that many lines from the buffer?

Perhaps this could turn into a pseudo-telnet command handler; that is, the cursor could indeed be moved up lines. Of course, what happens to the log is an interesting question but that could be left up to the plugin writer (or user.)

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
[Go to top] top

Posted by Nick Gammon   Australia  (22,973 posts)  [Biography] bio   Forum Administrator
Date Reply #5 on Sat 08 Jan 2005 07:02 PM (UTC)
Message
Quote:

How hard would it be to write a function that, given an output window, returned the number of vertical lines? Then to be able to clear (delete) just that many lines from the buffer?


I don't see what that would achieve. Every time you get a clearscreen you throw away the last 20 (say) lines of output.

And what if you have two windows, of different heights?

The reason is hasn't been done so far is that there is no easy solution.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by David Haley   USA  (3,881 posts)  [Biography] bio
Date Reply #6 on Sat 08 Jan 2005 07:09 PM (UTC)
Message
Quote:
I don't see what that would achieve. Every time you get a clearscreen you throw away the last 20 (say) lines of output.
That seems acceptable, since in the places where clearscreen is used, you'd probably be doing that anyhow - throwing away e.g. the last map, or the last information display...

Or, perhaps, clearscreen could move the window display so that it puts the new text at the top of the output window, and a lot of empty lines below it - then if you scroll up you see everything, but you have the illusion at least of having the screen cleared because all you see is what's after the clear screen. Is that an ok compromise for you?

Quote:
And what if you have two windows, of different heights?
Well, I suppose that would be a problem, but the plugin could simply claim to not support multiple windows.

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
[Go to top] top

Posted by Shadowfyr   USA  (1,786 posts)  [Biography] bio
Date Reply #7 on Sat 08 Jan 2005 07:37 PM (UTC)
Message
One alternative is to make it act like pages, sort of like Adobe Acrobat Reader does. Set a code in the buffer that says, "there is a page break here.", then when you scroll back, it automatically treats it like a page and pops up only those lines at the end of that page, scroll up more and it goes through the normal lines, until it hits a page marker, where it clears again and shows the last line of 'that' page as the last line in output. This is how I have seen many do it. By the same token, when you get a 'clear screen' command, you embed the 'page-break' into the buffer, clear the visible contents and start at the top again when displaying.

The only real issue is when the 'page' is smaller than the number of displayable lines in the output window. But you only need to look back through the buffer no more than #_Output_Lines + 1, to determine if you should start showing that 'page' by clearing the output windows first. If there are more lines than can be displayed anyway, then do things the same way for that page as you now do for the entire buffer. You have to search back X lines to page up anyway, so checking to make sure that one of the lines doesn't contain a page break, clearing the display and starting at the line that follows that instead when showing the result, is not that much more complicated. As for storing the character, since it might interfer with UTF-8, Do you have any bits left in some of the style info? You could mark it as part of a style, so it is not actually shown, but is just used by the display code.
[Go to top] top

Posted by David Haley   USA  (3,881 posts)  [Biography] bio
Date Reply #8 on Sun 09 Jan 2005 03:18 AM (UTC)
Message
The problem with page breaks is that it would require a significant change in how the display window works. If a clear screen were to simply scroll the window such that the following lines (after the clear screen) appear at the very top of the window, the illusion of a clear screen would be more or less preserved.

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
[Go to top] top

Posted by Shadowfyr   USA  (1,786 posts)  [Biography] bio
Date Reply #9 on Sun 09 Jan 2005 03:40 AM (UTC)
Message
Yeah, but I am not sure how major the change would have to be, as I said, to back up x lines when someone hits pageup, you still have to redraw the lines. Checking for a page break and dealing with it properly as you do is not that complicated. Feeding lines is just that, a simulation of the result and not necessarily a good one. Just think an alternative might be better if ever implimented as a real feature.
[Go to top] top

Posted by David Haley   USA  (3,881 posts)  [Biography] bio
Date Reply #10 on Sun 09 Jan 2005 04:15 AM (UTC)
Message
Well, feeding lines was just an idea; scrolling so that next lines were at the top is another. The only problem I see with your idea (which I think I understand better now) is that it might not work too well with mouse scrolling, but then, mine doesn't try either.

In fact, I think your idea somewhat needs my suggestion of scrolling to a "new page" (without adding blank lines) anyhow, in order to give the impression of a new page.

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
[Go to top] top

Posted by Flannel   USA  (1,230 posts)  [Biography] bio
Date Reply #11 on Sun 09 Jan 2005 07:54 AM (UTC)
Message
What about utilizing bookmarks?
I honestly have never actually USED a bookmark, but I know they're there. Doesnt look like there are script functions for them (except DoCommand, I suppose) but if they are numbered, or something, we could ask nick for some functionality like... a "BookmarkToTop" or something function. And some way to set a given line as a bookmark, as DoCommand would require you to highlight the line first, I think.

You could use bookmarks as page breaks, that wouldn't require (any|much) changing. Unless bookmarks arent internally numbered, or something. Theyd have to be, well, either that or it just searches the lines for the next one when you goto bookmark. In which case, I suppose it would still work for pages. You'd just have to have a "send next bookmark to top of screen" function.

~Flannel

Messiah of Rose
Eternity's Trials.

Clones are people two.
[Go to top] top

Posted by Shadowfyr   USA  (1,786 posts)  [Biography] bio
Date Reply #12 on Sun 09 Jan 2005 06:00 PM (UTC)
Message
Personally.. I just don't see the point of implimenting a hack to simulate what has been a standard function of hundreds of applications, ranging from things like business applications, all the way back to the already well designed precursors of modern mud clients, like the Telemate application I used in the college to log onto BBS systems. The only distinction between that application and a modern mud client (in triggers, scripting, aliases, etc.) was that it didn't understand TCP/IP. It still worked like a telnet application (using VT-52, VT-100, Ansi, etc.) and was specifically designed to work with text based games, amoung other things. Same functionality, you feed it a clear screen, it flags that point as 'new page' in the buffer and proceeds from there as I described. Some games where entirely scrolling, a lot used clear screen and text positioning. It was simply a matter of how they wanted them to work in that particular case.

Really, the only difference between a telnet application and a mud client is the assumption made about what you are going to do with it. No one assumed you where going to use Telemate to remote control your server. 99% of the uses involved either games or downloading software, sometimes to get specialized cheat clients for specific games, like the Tradewars 2002 one that could do botting and find the best ports to trade between (this was btw a scroller, just like a modern mud, but had a 'theatre' and entry screen which did use text positioning). The idea that you might use one type of client specifically for scrollers and something else entirely for ones that use the full set of ansi specs would have been considered totally ludicrous. Why exactly is it considered normal on the internet??

I do realize it is just a choice you made Nick, but imho it doesn't make a lot of sense in the overall world of mudding, since it excludes an unknown number of them from working right with the client. Its hard to predict just how many it is a problem with even, since a mud could do 90% of the stuff without it, then have one room, with a puzzle, that some creative person decided to use any of these things with. Its generally always better to design for what 'might' happen, not what you 'expect' to happen.
[Go to top] top

Posted by Nick Gammon   Australia  (22,973 posts)  [Biography] bio   Forum Administrator
Date Reply #13 on Sun 09 Jan 2005 07:43 PM (UTC)
Message
Expect the unexpected you mean? Always easier said than done.

The thing is, that if I wrote another MUD client from scratch these days I would do lots of things differently, with the benefit of hindsight. Right now there are script routines that overlap in functionality (eg. AddTrigger/AddTriggerEx, WorldName/GetInfo). Also the macros/keyboard accelerator implementations. The notepad windows. Spawned windows. Lots and lots of things.

A major change would be the way data is stored internally. I originally use the MFC (Microsoft Library) structures of lists, maps etc., but now I know STL (Standard Template Library) I would use that instead.

A while ago I tried to change the way the output buffer was stored from the current linked lists, to a STL deque, which would be have been sensible, and would have allowed lines to be easily deleted at random from the output buffer.

However, although it 95% worked, niggling issues remained that made me ditch it all. The screen didn't quite refresh properly, and I was spending hours and hours trying to work out why. Shoe-horning a new approach into the app that hadn't been designed for it from the start wasn't really working.

Similarly with the clearscreen idea. Sure, I understand what you are all saying, but if the screen could clear at a certain point in the drawing sequence, it changes a fair bit lots of things. For example, right now to draw the window, assuming the output window is scrolled to the bottom, I count back x lines where x is the size of the output window, and then start drawing. This doesn't work if halfway through there is a screen clear, so that is one calculation that changes. Then there is clicking to select a word or character. Again, to work out what line that click is really on is a matter of simple counting. But if there are screen clears it isn't.

Also, I can see where this is heading. Once you have screen clears, then you will want cursor positioning. You mention the idea of drawing a puzzle. So you will want to clear the screen, and then make the cursor jump all over it while the puzzle is being drawn.

Sorry, maybe one day. The 0.1% registration rate doesn't exactly encourage me to spend hours if not weeks adding a feature that maybe 4 people will use. I notice that SimpleMU doesn't support it either at present, although zMUD seems to.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by David Haley   USA  (3,881 posts)  [Biography] bio
Date Reply #14 on Sun 09 Jan 2005 07:46 PM (UTC)
Message
There's actually a fairly popular MUD, Forgotten Kingdoms, that uses this feature quite extensively to draw the little map-status-display gadget at the top of the screen. It does use cursor displays and all that, but these features aren't as rare as you seem to say. I agree with your reasoning, mind you, I just disagree with how rare you think it is. :-)

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
[Go to top] top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


47,702 views.

This is page 1, subject is 2 pages long: 1 2  [Next page]

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at HostDash]