Skip to content

Commit

Permalink
Add ability to suppress game output to only sure user interactions
Browse files Browse the repository at this point in the history
  • Loading branch information
tedivm committed Oct 26, 2016
1 parent 75df49d commit 0c5da92
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 5 deletions.
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,14 @@ commands however.

* `about` - displays information about the program.
* `clear` - resets the console display.
* `console` - allows users to suppress normal console output and only sure user interactions.
* `disconnect` - disconnects the console from the Screeps server.
* `exit` - exits the shell.
* `filter` - applies filters to the console output.
* `list` - lists these and other built in commands and aliases.
* `pause` - disables autoscrolling (hit enter on an empty terminal to reenable).
* `reconnect` - reconnects the console to the Screeps server.
* `themes` - lists available themes when called without an argument, or switches.
* `themes` - lists available themes when called without an argument, or switches.
Otherwise switches themes when called with the theme name as the first
argument.
* `time` - displays the time (in ticks) on the Screeps server.
Expand All @@ -115,12 +116,12 @@ through the console buffer a bit quicker.
Console output can be filtered using regular expressions and the `filter`
command. Only commands that match at least one filter will be displayed.

`filter list` - this lists each current regex filter and its index.
`filter add REGEX` - add a regular expression to the filter list.
`filter list` - this lists each current regex filter and its index.
`filter add REGEX` - add a regular expression to the filter list.
`filter clear` - remove all filters.
`filter contains STRING` - add a filter that looks for log lines that contain the
supplied string.
`filter remove INDEX` - remove a regular expression using it's index.
supplied string.
`filter remove INDEX` - remove a regular expression using it's index.


## Colors and Severity
Expand Down
21 changes: 21 additions & 0 deletions screeps_console/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,27 @@ def clear(self, comp):
comp.listwalker[:] = [urwid.Text('')]
return

def console(self, comp):
helpmessage = 'Control console output. `console quiet` to suppress console output and `console reset` to turn it back on.'
userInput = comp.edit
user_text = userInput.get_edit_text()
user_command_split = user_text.split(' ')

if len(user_command_split) < 2:
comp.listwalker.append(urwid.Text(('logged_response', helpmessage)))
return False

command = user_command_split[1]

if command == 'quiet':
comp.consolemonitor.quiet = True
comp.listwalker.append(urwid.Text(('logged_response', 'Limiting display to user interactions only.')))
elif command == 'reset' or command == 'verbose':
comp.consolemonitor.quiet = False
comp.listwalker.append(urwid.Text(('logged_response', 'Displaying all console output.')))
else:
comp.listwalker.append(urwid.Text(('logged_response', helpmessage)))

def disconnect(self, comp):
comp.consolemonitor.disconnect()
comp.listwalker.append(urwid.Text(('logged_response', 'disconnecting')))
Expand Down
4 changes: 4 additions & 0 deletions screeps_console/interactive.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ def keypress(self, size, key):
class ScreepsConsoleMonitor:

proc = False
quiet = False
filters = []

def __init__(self, widget, walker, loop):
Expand Down Expand Up @@ -283,6 +284,9 @@ def onUpdate(self, data):

log_type = outputparser.getType(line)

if self.quiet and log_type != 'result':
return

if log_type == 'result':
formatting = 'logged_response'
elif log_type == 'highlight':
Expand Down

0 comments on commit 0c5da92

Please sign in to comment.