Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to "verify" your details, 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.
Entire forum
➜ MUSHclient
➜ Suggestions
➜ Wrap input?
It is now over 60 days since the last post. This thread is closed.
Refresh page
Pages: 1 2
Posted by
| Neva
USA (117 posts) Bio
|
Date
| Mon 15 Aug 2011 02:01 AM (UTC) |
Message
| Something I've noticed now that I've got a huge monitor on my desktop--it's great because I can spawn a lot of stuff off into a miniwindow, but it's hard to judge how long my input is in "real" 80-character lines because while my output text wraps at column 80, the input text doesn't. It would be nice if one could set a wrap column for both. | Top |
|
Posted by
| Neva
USA (117 posts) Bio
|
Date
| Reply #1 on Wed 23 Nov 2011 02:48 PM (UTC) |
Message
| Any chance on this, still? It's a minor thing but visually annoying when I'm writing a bunch; it's very hard to read things that wide. | Top |
|
Posted by
| Fiendish
USA (2,533 posts) Bio
Global Moderator |
Date
| Reply #2 on Wed 23 Nov 2011 03:35 PM (UTC) Amended on Wed 23 Nov 2011 03:45 PM (UTC) by Fiendish
|
Message
| It's not built in, but it looks like you should easily be able to do this with a combination of the OnPluginCommandChanged() callback and GetCommand() and PushCommand()+SetCommand().
At every call to OnPluginCommandChanged, use GetCommand() to get the current input area text. Then check for the distance between line break characters. If any distance is more than 80 chars, insert a line break. Then use PushCommand() to clear the buffer and then SetCommand(final_text) to replace the input with the newly split text.
If someone else doesn't get to it first before I find the time (probably not today), I'll write up a quick plugin for you. |
https://github.com/fiendish/aardwolfclientpackage | Top |
|
Posted by
| Twisol
USA (2,257 posts) Bio
|
Date
| Reply #3 on Wed 23 Nov 2011 07:47 PM (UTC) |
Message
|
Fiendish said: At every call to OnPluginCommandChanged, use GetCommand() to get the current input area text. Then check for the distance between line break characters. If any distance is more than 80 chars, insert a line break. Then use PushCommand() to clear the buffer and then SetCommand(final_text) to replace the input with the newly split text.
Wouldn't that effectively break one command into two? If I type "say to SomeBody something really really really really long" (insert as many "really"s as needed here) and the command gets wrapped by this plugin, it would get sent as "say to SomeBody something really really really" and "really long", which is wrong. |
'Soludra' on Achaea
Blog: http://jonathan.com/
GitHub: http://github.com/Twisol | Top |
|
Posted by
| Fiendish
USA (2,533 posts) Bio
Global Moderator |
Date
| Reply #4 on Wed 23 Nov 2011 08:27 PM (UTC) Amended on Wed 23 Nov 2011 08:37 PM (UTC) by Fiendish
|
Message
| Of course. This wouldn't be on all the time. Only when one needs to write something formatted, like a note. Aardwolf, for example, leaves wrapping of says and channel messages to the client, but limits (circumventably) forum notes to 79 char width. Players frequently ask about ways to automatically format notes to fit into the width restriction. One way would be to automate the width circumvention, and another would be to automate wrapping like OP seems to want. |
https://github.com/fiendish/aardwolfclientpackage | Top |
|
Posted by
| Twisol
USA (2,257 posts) Bio
|
Date
| Reply #5 on Wed 23 Nov 2011 08:46 PM (UTC) Amended on Wed 23 Nov 2011 08:47 PM (UTC) by Twisol
|
Message
| This might be helpful, then. I use something similar for writing newsposts and journal entries.
<aliases>
<alias
match="^\s*compose\s*$"
enabled="y"
regexp="y"
send_to="12"
omit_from_output="y"
ignore_case="y"
keep_evaluating="y"
sequence="100"
>
<send>local text = utils.editbox("Enter your input below.", "Input Box")
if text then
Send(text)
end</send>
</alias>
</aliases>
I experimented with reply_width to make the input area wrap closer to 80 characters (which I'm sure you could do precisely with math and font metrics), but it didn't seem to do anything. |
'Soludra' on Achaea
Blog: http://jonathan.com/
GitHub: http://github.com/Twisol | Top |
|
Posted by
| Fiendish
USA (2,533 posts) Bio
Global Moderator |
Date
| Reply #6 on Thu 24 Nov 2011 12:57 AM (UTC) Amended on Mon 28 Nov 2011 05:52 AM (UTC) by Fiendish
|
Message
| [EDIT] replaced by the version below |
https://github.com/fiendish/aardwolfclientpackage | Top |
|
Posted by
| Neva
USA (117 posts) Bio
|
Date
| Reply #7 on Thu 24 Nov 2011 06:10 PM (UTC) |
Message
| Okay, yeah. Something that breaks lines? Is NOT going to be useful, here. At all. That would be more annoying than things as they currently are. I don't want multiple lines sent to the server, I just want to be able to see my input the way it's going to show up on the other send, every time. | Top |
|
Posted by
| Fiendish
USA (2,533 posts) Bio
Global Moderator |
Date
| Reply #8 on Thu 24 Nov 2011 07:12 PM (UTC) |
Message
| How do you know how it shows up on the other end? |
https://github.com/fiendish/aardwolfclientpackage | Top |
|
Posted by
| Nick Gammon
Australia (23,046 posts) Bio
Forum Administrator |
Date
| Reply #9 on Thu 24 Nov 2011 07:42 PM (UTC) |
Message
| What you can do is add another three lines that take away the extra linefeeds, like this:
function OnPluginCommandEntered (sText)
return string.gsub (sText, "\n", " ")
end -- OnPluginCommandEntered
]]>
</script>
</muclient>
Add the three lines in bold just before the last three lines of the plugin (shown above). |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Nick Gammon
Australia (23,046 posts) Bio
Forum Administrator |
Date
| Reply #10 on Thu 24 Nov 2011 07:43 PM (UTC) |
Message
|
Fiendish said:
How do you know how it shows up on the other end?
Well if you do: say <blah blah>
Then only the first line is said and the other are rejected as bad commands. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Neva
USA (117 posts) Bio
|
Date
| Reply #11 on Thu 24 Nov 2011 09:59 PM (UTC) |
Message
| That helps a little bit. The "standard" line on this game, also, is always 78-80 characters long, and we have some general guidelines for how many lines long things should be, and it's a little annoying to have to test everything out either in another program or whatever to see how long it all is. The big question then is the ability to edit stuff, which is certainly necessary in anything you're writing that's more than a few words long. I'm poking at the script and I haven't been able to figure out anything that would automatically allow that, yet. I think I could set something else to remove the line breaks, edit, and then add them back, but that, again, is adding just so much extra work to something that I'm not saving time over pasting stuff into a text editor every time.
Is this really that hard to implement in the program itself? I'm not against using a script if it works, but I've never really understood why this is a simple option available for output but not input. | Top |
|
Posted by
| Twisol
USA (2,257 posts) Bio
|
Date
| Reply #12 on Thu 24 Nov 2011 10:14 PM (UTC) |
Message
| Low-tech workaround: resize your window so the input bar only has enough room for 80 characters. |
'Soludra' on Achaea
Blog: http://jonathan.com/
GitHub: http://github.com/Twisol | Top |
|
Posted by
| Fiendish
USA (2,533 posts) Bio
Global Moderator |
Date
| Reply #13 on Fri 25 Nov 2011 12:20 AM (UTC) Amended on Fri 25 Nov 2011 03:09 AM (UTC) by Fiendish
|
Message
| [EDIT]found bugs, so pulled code for now.
Quote: Low-tech workaround: resize your window so the input bar only has enough room for 80 characters. This isn't viable at all for miniwindow-based layouts unless you like the idea of constantly resizing your world window.
Quote: What you can do is add another three lines that take away the extra linefeeds, like this: I actually don't think that would have worked as expected for several of my test cases.
Nick Gammon said:
Fiendish said: How do you know how it shows up on the other end?
Well if you do: say <blah blah>
Then only the first line is said and the other are rejected as bad commands. That says nothing about what another player would see if you type a command longer than 80 characters. This sort of answers, but not really:
Quote: The "standard" line on this game, also, is always 78-80 characters long
Unless the MUD is wrapping everything you send to fit within an 80 character width, e.g. if you send "say a_line_longer_than_80_chars" then the MUD displays "player says '80 chars\r\n80chars\r\n etc.'", then I don't see the value in this. But maybe that's what is going on. But then this can't generically account for that initial "player says" bit, so it'll still not be ideal. Not sure how to get around that last problem. I can only hope that your mud starts the 80-wide paragraph on a new line while I work on a way to make editing in the middle of lines work without any bugs. :p |
https://github.com/fiendish/aardwolfclientpackage | Top |
|
Posted by
| Fiendish
USA (2,533 posts) Bio
Global Moderator |
Date
| Reply #14 on Mon 28 Nov 2011 05:44 AM (UTC) Amended on Mon 28 Nov 2011 06:13 AM (UTC) by Fiendish
|
Message
| This version should wrap the input bar non-destructively so that data gets sent with only those newlines that were added explicitly by the player. It also allows modifications/insertions mid-line. The comment about me not seeing the point of this still applies, but if this is what the OP wants, then this is what the OP gets.
To get a version that sends with the wrap line breaks included (useful for automatically formatting Aardwolf notes, for example, if you change 80 to 79), just remove these three linesfunction OnPluginCommandEntered(sText)
return stripLoneLF(sText)
end
And, of course, modify the plugin name/purpose appropriately, as it's no longer non-destructive.
|
To save and install the AutoWrapInput plugin do this:
- Copy between the lines below (to the Clipboard)
- Open a text editor (such as Notepad) and paste the plugin into it
- Save to disk on your PC, preferably in your plugins directory, as AutoWrapInput.xml
- Go to the MUSHclient File menu -> Plugins
- Click "Add"
- Choose the file AutoWrapInput.xml (which you just saved in step 3) as a plugin
- Click "Close"
|
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<muclient>
<plugin
name="AutoWrapInput_non_destructive"
author="Fiendish"
id="0620f3f9b9bf0ea4d2f5703b"
language="Lua"
purpose="Wraps input at 80 characters non-destructively"
save_state="y"
date_written="2011-11-23 19:36:00"
requires="4.79"
version="1.0"
>
</plugin>
<aliases>
<alias
match="^wrap_input( (.*))?$"
enabled="y"
regexp="y"
sequence="100"
ignore_case="y"
script="activate_wrapping"
></alias>
</aliases>
<script>
<![CDATA[
SetVariable("wrapping", GetVariable("wrapping") or "off")
local wrapping = (GetVariable("wrapping") == "on")
function activate_wrapping(name, line, wildcards)
if wildcards[1] == "" then
Note("Input wrapping is currently: "..GetVariable("wrapping"))
elseif wildcards[2] == "on" or wildcards[2] == "off" then
SetVariable("wrapping", wildcards[2])
wrapping = (wildcards[2] == "on")
Note("Input wrapping set to: "..wildcards[2])
else
Note("WRAP_INPUT ERROR: Expected either 'wrap_input on' or 'wrap_input off'.")
end
end
-- We distinguish between \n and \r\n given an assumption that on Windows (and through Wine)
-- the Enter key always inserts \r\n so that \n can be used to display wrapped lines (MUSHclient handles this)
-- while differentiating line breaks inserted by the user.
function lines(str)
local t = {}
local function helper(line) table.insert(t, line) return "" end
helper((str:gsub("(.-)\r\n", helper)))
return t
end
function OnPluginCommandEntered(sText)
return stripLoneLF(sText)
end
function stripLoneLF(sText)
return string.gsub(sText,"([^\r])\n","%1")
end
function OnPluginCommandChanged()
if not wrapping then
return
end
local user_input = GetCommand()
local user_input_lines = lines(stripLoneLF(user_input))
for i,v in ipairs(user_input_lines) do
local char_count = 80
local line_len = #v
while line_len > char_count do
if string.sub(user_input_lines[i],char_count+1,char_count+1) ~= "\n" then
user_input_lines[i] = string.sub(user_input_lines[i],1,char_count).."\n"..string.sub(user_input_lines[i],char_count+1)
char_count = char_count + 1
line_len = line_len + 1
end
char_count = char_count + 80
end
end
final_input = table.concat(user_input_lines,"\r\n")
-- prevent display errors if the user has input auto-resizing enabled
-- by temporarily changing the minimum number of lines to the amount that
-- the user has typed
if GetOption ("auto_resize_command_window") == 1 then
min_lines = GetOption ("auto_resize_minimum_lines")
max_lines = GetOption ("auto_resize_maximum_lines")
SetOption ("auto_resize_minimum_lines", math.min(max_lines,#user_input_lines))
end
-- enable insertion/deletion in the middle of sections
local selection_start = GetInfo(236)
local selection_end = math.max(0,selection_start-1)
SetCommandSelection (1, -1) -- select everything
PasteCommand(final_input) -- overwrite with wrapped version
-- put the cursor back in the right place after mid-line insertion/deletions
local count = 0
for i in string.gmatch(string.sub(user_input,1,selection_end),"[^\r]\n") do
count = count - 1
end
for i in string.gmatch(string.sub(final_input,1,selection_end),"[^\r]\n") do
count = count + 1
end
SetCommandSelection (selection_start+count, selection_end+count)
-- undo the above resize change
if GetOption ("auto_resize_command_window") == 1 then
SetOption ("auto_resize_minimum_lines", min_lines)
end
end
]]>
</script>
</muclient>
|
https://github.com/fiendish/aardwolfclientpackage | 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.
63,256 views.
This is page 1, subject is 2 pages long: 1 2
It is now over 60 days since the last post. This thread is closed.
Refresh page
top