Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ General ➜ Feature request, hiding 'backspace' character

Feature request, hiding 'backspace' character

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


Posted by Dcruze   (8 posts)  Bio
Date Thu 02 Aug 2018 02:42 PM (UTC)
Message
With the following LPC code, which is meant to make it more difficult for players to use triggers - it displays normally in CMUD and TinyFugue, but in MushClient it tries to print the backspace characters (char 8), which makes it look like garbage in the terminal window.

Is there something I can do (as a player), to prevent this? It should appear like normal text.

-d


string no_trig(string str)
{
   string *chars;
   int     i;

   if(!stringp(str) || ((i = strlen(str)) < 2)){
      return str;
   }

   chars = allocate(i);

   while(i--){
      chars = str[i..i];
   }

   return implode(chars, " " + sprintf("%c", 8));
}
Top

Posted by Dcruze   (8 posts)  Bio
Date Reply #1 on Thu 02 Aug 2018 03:12 PM (UTC)
Message
This is what I mean, MushClient is on the left and CMUD is on the right. The added space and backspace should cancel themselves out, but it doesn't in MushClient.

https://i.imgur.com/rk0g7Gj.png

[img]https://i.imgur.com/rk0g7Gj.png[/img]
Top

Posted by Nick Gammon   Australia  (23,140 posts)  Bio   Forum Administrator
Date Reply #2 on Thu 02 Aug 2018 07:58 PM (UTC)
Message
There's some discussion about that here:

Template:post=5114 Please see the forum thread: http://gammon.com.au/forum/?id=5114.


This simple plugin will handle the case you've shown which has a character followed by a single backspace:

Template:saveplugin=Handle_Backspaces To save and install the Handle_Backspaces plugin do this:
  1. Copy between the lines below (to the Clipboard)
  2. Open a text editor (such as Notepad) and paste the plugin into it
  3. Save to disk on your PC, preferably in your plugins directory, as Handle_Backspaces.xml
  4. Go to the MUSHclient File menu -> Plugins
  5. Click "Add"
  6. Choose the file Handle_Backspaces.xml (which you just saved in step 3) as a plugin
  7. Click "Close"



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

<muclient>
<plugin
   name="Handle_Backspaces"
   author="Nick Gammon"
   id="955936e1d411d5663bcc5dba"
   language="Lua"
   purpose="Attempts to processing incoming backspaces"
   date_written="2018-08-03"
   requires="4.90"
   version="1.0"
   >
</plugin>

<!--  Script  -->
<script>
<![CDATA[

function OnPluginPacketReceived (sText)
  return string.gsub (sText, ".\008", "")  -- backspace removes previous character
end -- function

]]>
</script>
</muclient>



That uses the OnPluginPacketReceived callback to get at the incoming packet before it is displayed. This will fail for more complex cases (eg. xxx\b\b\b) however it should get you past this initial problem.

If they try getting funny and having two or three backspaces in a row (with a corresponding number of junk characters) then this modification to the function would handle it:


function OnPluginPacketReceived (sText)
  sText = string.gsub (sText, "...\008\008\008", "")  -- three in a row
  sText = string.gsub (sText, "..\008\008", "")        -- two in a row
  return string.gsub (sText, ".\008", "")  -- backspace removes previous character
end -- function


After that you might want to write a proper loop to handle any number of them.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Dcruze   (8 posts)  Bio
Date Reply #3 on Thu 02 Aug 2018 08:20 PM (UTC)
Message
That works perfectly. Thanks a bunch :)

-d
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.


13,040 views.

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

Go to topic:           Search the forum


[Go to top] top

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