Mercurial > libervia-backend
comparison frontends/src/primitivus/primitivus @ 1119:5968fd8d2248
primitivus: change behavior of commands ":presence" and ":status" :
- ":presence " and ":status " open a dialog (like if you type it without the trailing space)
- you need to type ":presence online" to directly reset your presence (was done with ":presence " before)
- there's no more way to directly set an empty status (you now do it via the dialog)
author | souliane <souliane@mailoo.org> |
---|---|
date | Sat, 23 Aug 2014 20:11:37 +0200 |
parents | e2e1e27a3680 |
children | 7ee18dbfb661 |
comparison
equal
deleted
inserted
replaced
1118:b1cb1d70bea9 | 1119:5968fd8d2248 |
---|---|
110 self.commandHandler() | 110 self.commandHandler() |
111 | 111 |
112 def commandHandler(self): | 112 def commandHandler(self): |
113 #TODO: separate class with auto documentation (with introspection) | 113 #TODO: separate class with auto documentation (with introspection) |
114 # and completion method | 114 # and completion method |
115 command = self.get_edit_text() | 115 tokens = self.get_edit_text().split(' ') |
116 command, args = tokens[0], tokens[1:] | |
116 if command == 'quit': | 117 if command == 'quit': |
117 self.app.onExit() | 118 self.app.onExit() |
118 raise urwid.ExitMainLoop() | 119 raise urwid.ExitMainLoop() |
119 elif command == 'messages': | 120 elif command == 'messages': |
120 wid = sat_widgets.GenericList(logging.memoryGet()) | 121 wid = sat_widgets.GenericList(logging.memoryGet()) |
121 self.app.addWindow(wid) | 122 self.app.addWindow(wid) |
122 elif command == 'presence': | 123 elif command == 'presence': |
123 self.app.status_bar.onPresenceClick() | 124 values = [value for value in commonConst.PRESENCE.keys()] |
124 elif command in ['presence %s' % show for show in commonConst.PRESENCE.keys()]: | 125 values = [value if value else 'online' for value in values] # the empty value actually means 'online' |
125 self.app.status_bar.onChange(user_data=sat_widgets.ClickableText(commonConst.PRESENCE[command[9:]])) | 126 if args and args[0] in values: |
127 presence = '' if args[0] == 'online' else args[0] | |
128 self.app.status_bar.onChange(user_data=sat_widgets.ClickableText(commonConst.PRESENCE[presence])) | |
129 else: | |
130 self.app.status_bar.onPresenceClick() | |
126 elif command == 'status': | 131 elif command == 'status': |
127 self.app.status_bar.onStatusClick() | 132 if args: |
128 elif command.startswith('status '): | 133 self.app.status_bar.onChange(user_data=sat_widgets.AdvancedEdit(args[0])) |
129 self.app.status_bar.onChange(user_data=sat_widgets.AdvancedEdit(command[7:])) | 134 else: |
135 self.app.status_bar.onStatusClick() | |
130 else: | 136 else: |
131 return | 137 return |
132 self.set_edit_text('') | 138 self.set_edit_text('') |
133 | 139 |
134 def keypress(self, size, key): | 140 def keypress(self, size, key): |