Project

Profile

Help

Feature #32

closed

Create command stacking

Added by Vincent Le Goff over 7 years ago. Updated over 7 years ago.

Status:
Closed
Priority:
Normal
Category:
MUD client
Sprint/Milestone:
% Done:

100%

Company:
-
Contact person:
-
Additional contact persons:
-

Description

Some players have requested the usual command stacking using the semicolon (;) to send several commands at once. It would need to be active or inactive in the setting, for I (for one thing) don't really enjoy command stacking.


Checklist

Actions #1

Updated by Vincent Le Goff over 7 years ago

  • Sprint/Milestone set to 5
Actions #2

Updated by Vincent Le Goff over 7 years ago

  • Checklist item Add the command stacking in the preferences added
  • Checklist item Split commands using the chosen command stacking (if any) added
  • Category set to MUD client
  • Status changed from Open to In Progress
  • Assignee set to Vincent Le Goff

Command stacking would be allowed by a single character defined in settings. The most common case is the semicolon, although that could be changed. When the command is checked before sending, if command stacking is active, the entered command should be split using regular expressions.

Using lookahead and lookbehind seems to be the solution. Here is a short code excerpt that seems to do the trick.

>>> stacking = ";" 
>>> stacking = re.escape(stacking)
>>> splitter = re.compile("(?<!{s}){s}(?!{s})".format(s=stacking))
>>> splitter.split("a first command;another one;and a third with a semi;;colon;and a fourth")
['a first command', 'another one', 'and a third with a semi;;colon', 'and a fourth']
>>>

The regular expression is divided into three parts:

  • A negative lookbehind that doesn't match the character: (?<!\;) (note that we escape the semicolon).
  • The character itself: \; .
  • A negative lookahead that does not match the character: (?!\;) .

That way, the regex would match a single semicolon if it's neither preceded, nor followed by, another semicolon.

Actions #3

Updated by Vincent Le Goff over 7 years ago

  • Checklist item Add the command stacking in the preferences set to Done
Actions #4

Updated by Vincent Le Goff over 7 years ago

  • Checklist item deleted (Add the command stacking in the preferences)
  • Checklist item Split commands using the chosen command stacking (if any) set to Done
  • Status changed from In Progress to Closed
  • % Done changed from 0 to 100

Added in commit ab6caef9038b376ee40cf75f8835cff817b0d98c.
Note that the test to encode the message has been moved into the client instead of the window. It shouldn't have consequences, but it may be worth noting.

Please register to edit this issue

Also available in: Atom PDF Tracking page