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

Gammon Forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Tips and tricks
. . -> [Subject]  Redefine Ctrl+Backspace accelerator
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

Redefine Ctrl+Backspace accelerator

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


Posted by Ulenspiegel   (3 posts)  [Biography] bio
Date Sun 25 Jun 2017 07:11 AM (UTC)
Message
Hello!

This brings up a question that was coming up before at least twice in different categories of forum, but I don't think it received any resolution. Reply http://www.gammon.com.au/forum/?id=10818&reply=7#reply7 suggests that, to redefine behavior of Ctrl+Backspace, one can use AcceleratorTo(). Does anybody know how, in the script argument of AcceleratorTo(), delete the last word before cursor? Is there Lua functions for editing the text in input area (I'm looking for 'delete last word' or, for the lack of it, something like 'select previous word' + 'delete selection' functions)?
[Go to top] top

Posted by Fiendish   USA  (1,641 posts)  [Biography] bio   Global Moderator
Date Reply #1 on Sun 25 Jun 2017 08:22 AM (UTC)

Amended on Sun 25 Jun 2017 08:23 AM (UTC) by Fiendish

Message
Try

GetCommand, find the last word, SelectCommand (or SetCommandSelection if you prefer), and then PasteCommand

https://github.com/fiendish/aardwolfclientpackage
[Go to top] top

Posted by WillFa   USA  (525 posts)  [Biography] bio
Date Reply #2 on Sun 25 Jun 2017 03:30 PM (UTC)

Amended on Sun 25 Jun 2017 03:33 PM (UTC) by WillFa

Message
nm, SetCommand tries to save us from ourselves.
[Go to top] top

Posted by Fiendish   USA  (1,641 posts)  [Biography] bio   Global Moderator
Date Reply #3 on Sun 25 Jun 2017 06:45 PM (UTC)
Message
WillFa said:

nm, SetCommand tries to save us from ourselves.


lol, yup. PasteCommand claims not to, though.

https://github.com/fiendish/aardwolfclientpackage
[Go to top] top

Posted by Ulenspiegel   (3 posts)  [Biography] bio
Date Reply #4 on Tue 27 Jun 2017 01:20 AM (UTC)

Amended on Tue 27 Jun 2017 01:22 AM (UTC) by Ulenspiegel

Message
Everything works well now; thank you all for the help. :)

I think I'll leave that fragment of code here in this thread, in case somebody else will come looking.


function DeleteWordBeforeCursor()
  local sel_end = GetInfo(237)
  if sel_end == 0 then
    local word_end = GetInfo(236) - 1
    if word_end ~= 0 then
      local cmd = GetCommand()
      local word_begin = string.find(string.sub(cmd, 1, word_end), "%S*%s*$")
      if word_begin ~= nil then
        SetCommandSelection(word_begin, word_end)
        PasteCommand("")
      end
    end
  else
    PasteCommand("")
  end
end

-- Redefine Ctrl+Backspace to delete word before caret position.
AcceleratorTo("Ctrl+Backspace", "DeleteWordBeforeCursor()", sendto.script)
[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.


1,500 views.

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 FutureQuest]