1a45ae5f8SJohn Marino# Extended prompt. 2*ef5ccd6cSJohn Marino# Copyright (C) 2011-2013 Free Software Foundation, Inc. 3a45ae5f8SJohn Marino 4a45ae5f8SJohn Marino# This program is free software; you can redistribute it and/or modify 5a45ae5f8SJohn Marino# it under the terms of the GNU General Public License as published by 6a45ae5f8SJohn Marino# the Free Software Foundation; either version 3 of the License, or 7a45ae5f8SJohn Marino# (at your option) any later version. 8a45ae5f8SJohn Marino# 9a45ae5f8SJohn Marino# This program is distributed in the hope that it will be useful, 10a45ae5f8SJohn Marino# but WITHOUT ANY WARRANTY; without even the implied warranty of 11a45ae5f8SJohn Marino# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12a45ae5f8SJohn Marino# GNU General Public License for more details. 13a45ae5f8SJohn Marino# 14a45ae5f8SJohn Marino# You should have received a copy of the GNU General Public License 15a45ae5f8SJohn Marino# along with this program. If not, see <http://www.gnu.org/licenses/>. 16a45ae5f8SJohn Marino 17a45ae5f8SJohn Marino"""GDB command for working with extended prompts.""" 18a45ae5f8SJohn Marino 19a45ae5f8SJohn Marinoimport gdb 20a45ae5f8SJohn Marinoimport gdb.prompt 21a45ae5f8SJohn Marino 22a45ae5f8SJohn Marinoclass _ExtendedPrompt(gdb.Parameter): 23a45ae5f8SJohn Marino 24a45ae5f8SJohn Marino """Set the extended prompt. 25a45ae5f8SJohn Marino 26a45ae5f8SJohn MarinoUsage: set extended-prompt VALUE 27a45ae5f8SJohn Marino 28a45ae5f8SJohn MarinoSubstitutions are applied to VALUE to compute the real prompt. 29a45ae5f8SJohn Marino 30a45ae5f8SJohn MarinoThe currently defined substitutions are: 31a45ae5f8SJohn Marino 32a45ae5f8SJohn Marino""" 33a45ae5f8SJohn Marino # Add the prompt library's dynamically generated help to the 34a45ae5f8SJohn Marino # __doc__ string. 35a45ae5f8SJohn Marino __doc__ = __doc__ + gdb.prompt.prompt_help() 36a45ae5f8SJohn Marino 37a45ae5f8SJohn Marino set_doc = "Set the extended prompt." 38a45ae5f8SJohn Marino show_doc = "Show the extended prompt." 39a45ae5f8SJohn Marino 40a45ae5f8SJohn Marino def __init__(self): 41a45ae5f8SJohn Marino super(_ExtendedPrompt, self).__init__("extended-prompt", 42a45ae5f8SJohn Marino gdb.COMMAND_SUPPORT, 43a45ae5f8SJohn Marino gdb.PARAM_STRING_NOESCAPE) 44a45ae5f8SJohn Marino self.value = '' 45a45ae5f8SJohn Marino self.hook_set = False 46a45ae5f8SJohn Marino 47a45ae5f8SJohn Marino def get_show_string (self, pvalue): 48a45ae5f8SJohn Marino if self.value is not '': 49a45ae5f8SJohn Marino return "The extended prompt is: " + self.value 50a45ae5f8SJohn Marino else: 51a45ae5f8SJohn Marino return "The extended prompt is not set." 52a45ae5f8SJohn Marino 53a45ae5f8SJohn Marino def get_set_string (self): 54a45ae5f8SJohn Marino if self.hook_set == False: 55a45ae5f8SJohn Marino gdb.prompt_hook = self.before_prompt_hook 56a45ae5f8SJohn Marino self.hook_set = True 57a45ae5f8SJohn Marino return "" 58a45ae5f8SJohn Marino 59a45ae5f8SJohn Marino def before_prompt_hook(self, current): 60a45ae5f8SJohn Marino if self.value is not '': 61a45ae5f8SJohn Marino newprompt = gdb.prompt.substitute_prompt(self.value) 62a45ae5f8SJohn Marino return newprompt.replace('\\', '\\\\') 63a45ae5f8SJohn Marino else: 64a45ae5f8SJohn Marino return None 65a45ae5f8SJohn Marino 66a45ae5f8SJohn Marino_ExtendedPrompt() 67