prompt.py 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660
  1. """
  2. @package gui_core.prompt
  3. @brief wxGUI command prompt
  4. Classes:
  5. - prompt::GPrompt
  6. - prompt::GPromptSTC
  7. (C) 2009-2014 by the GRASS Development Team
  8. This program is free software under the GNU General Public License
  9. (>=v2). Read the file COPYING that comes with GRASS for details.
  10. @author Martin Landa <landa.martin gmail.com>
  11. @author Michael Barton <michael.barton@asu.edu>
  12. @author Vaclav Petras <wenzeslaus gmail.com> (copy&paste customization)
  13. """
  14. import os
  15. import difflib
  16. import codecs
  17. import sys
  18. import wx
  19. import wx.stc
  20. from grass.script import core as grass
  21. from grass.script import task as gtask
  22. from grass.pydispatch.signal import Signal
  23. from core import globalvar
  24. from core import utils
  25. from core.gcmd import EncodeString, DecodeString
  26. class GPrompt(object):
  27. """Abstract class for interactive wxGUI prompt
  28. Signal promptRunCmd - emitted to run command from prompt
  29. - attribute 'cmd'
  30. See subclass GPromptPopUp and GPromptSTC.
  31. """
  32. def __init__(self, parent, giface, menuModel):
  33. self.parent = parent # GConsole
  34. self.panel = self.parent.GetPanel()
  35. self.promptRunCmd = Signal("GPrompt.promptRunCmd")
  36. # probably only subclasses need this
  37. self._menuModel = menuModel
  38. self.mapList = self._getListOfMaps()
  39. self.mapsetList = utils.ListOfMapsets()
  40. # auto complete items
  41. self.autoCompList = list()
  42. self.autoCompFilter = None
  43. # command description (gtask.grassTask)
  44. self.cmdDesc = None
  45. self._loadHistory()
  46. if giface:
  47. giface.currentMapsetChanged.connect(self._loadHistory)
  48. # list of traced commands
  49. self.commands = list()
  50. # reload map lists when needed
  51. if giface:
  52. giface.currentMapsetChanged.connect(self._reloadListOfMaps)
  53. giface.grassdbChanged.connect(self._reloadListOfMaps)
  54. def _readHistory(self):
  55. """Get list of commands from history file"""
  56. hist = list()
  57. env = grass.gisenv()
  58. try:
  59. fileHistory = codecs.open(
  60. os.path.join(
  61. env["GISDBASE"],
  62. env["LOCATION_NAME"],
  63. env["MAPSET"],
  64. ".bash_history",
  65. ),
  66. encoding="utf-8",
  67. mode="r",
  68. errors="replace",
  69. )
  70. except IOError:
  71. return hist
  72. try:
  73. for line in fileHistory.readlines():
  74. hist.append(line.replace("\n", ""))
  75. finally:
  76. fileHistory.close()
  77. return hist
  78. def _loadHistory(self):
  79. """Load history from a history file to data structures"""
  80. self.cmdbuffer = self._readHistory()
  81. self.cmdindex = len(self.cmdbuffer)
  82. def _getListOfMaps(self):
  83. """Get list of maps"""
  84. result = dict()
  85. result["raster"] = grass.list_strings("raster")
  86. result["vector"] = grass.list_strings("vector")
  87. return result
  88. def _reloadListOfMaps(self):
  89. self.mapList = self._getListOfMaps()
  90. def _runCmd(self, cmdString):
  91. """Run command
  92. :param str cmdString: command to run
  93. """
  94. if not cmdString:
  95. return
  96. # parse command into list
  97. try:
  98. cmd = utils.split(str(cmdString))
  99. except UnicodeError:
  100. cmd = utils.split(EncodeString((cmdString)))
  101. cmd = list(map(DecodeString, cmd))
  102. self.promptRunCmd.emit(cmd=cmd)
  103. self.OnCmdErase(None)
  104. self.ShowStatusText("")
  105. def GetCommands(self):
  106. """Get list of launched commands"""
  107. return self.commands
  108. def ClearCommands(self):
  109. """Clear list of commands"""
  110. del self.commands[:]
  111. class GPromptSTC(GPrompt, wx.stc.StyledTextCtrl):
  112. """Styled wxGUI prompt with autocomplete and calltips"""
  113. def __init__(self, parent, giface, menuModel, margin=False):
  114. GPrompt.__init__(self, parent=parent, giface=giface, menuModel=menuModel)
  115. wx.stc.StyledTextCtrl.__init__(self, self.panel, id=wx.ID_ANY)
  116. #
  117. # styles
  118. #
  119. self.SetWrapMode(True)
  120. self.SetUndoCollection(True)
  121. #
  122. # create command and map lists for autocompletion
  123. #
  124. self.AutoCompSetIgnoreCase(False)
  125. #
  126. # line margins
  127. #
  128. # TODO print number only from cmdlog
  129. self.SetMarginWidth(1, 0)
  130. self.SetMarginWidth(2, 0)
  131. if margin:
  132. self.SetMarginType(0, wx.stc.STC_MARGIN_NUMBER)
  133. self.SetMarginWidth(0, 30)
  134. else:
  135. self.SetMarginWidth(0, 0)
  136. #
  137. # miscellaneous
  138. #
  139. self.SetViewWhiteSpace(False)
  140. self.SetUseTabs(False)
  141. self.UsePopUp(True)
  142. self.SetUseHorizontalScrollBar(True)
  143. # support light and dark mode
  144. bg_color = wx.SystemSettings().GetColour(wx.SYS_COLOUR_WINDOW)
  145. fg_color = wx.SystemSettings().GetColour(wx.SYS_COLOUR_WINDOWTEXT)
  146. selection_color = wx.SystemSettings().GetColour(wx.SYS_COLOUR_HIGHLIGHT)
  147. self.StyleSetBackground(wx.stc.STC_STYLE_DEFAULT, bg_color)
  148. self.StyleSetForeground(wx.stc.STC_STYLE_DEFAULT, fg_color)
  149. self.SetCaretForeground(fg_color)
  150. self.SetSelBackground(True, selection_color)
  151. self.StyleClearAll()
  152. #
  153. # bindings
  154. #
  155. self.Bind(wx.EVT_WINDOW_DESTROY, self.OnDestroy)
  156. self.Bind(wx.EVT_CHAR, self.OnChar)
  157. self.Bind(wx.EVT_KEY_DOWN, self.OnKeyPressed)
  158. self.Bind(wx.stc.EVT_STC_AUTOCOMP_SELECTION, self.OnItemSelected)
  159. self.Bind(wx.EVT_LIST_ITEM_SELECTED, self.OnItemChanged)
  160. if sys.platform != "darwin": # unstable on Mac with wxPython 3
  161. self.Bind(wx.EVT_KILL_FOCUS, self.OnKillFocus)
  162. # signal which requests showing of a notification
  163. self.showNotification = Signal("GPromptSTC.showNotification")
  164. # signal to notify selected command
  165. self.commandSelected = Signal("GPromptSTC.commandSelected")
  166. def OnTextSelectionChanged(self, event):
  167. """Copy selected text to clipboard and skip event.
  168. The same function is in GStc class (goutput.py).
  169. """
  170. wx.CallAfter(self.Copy)
  171. event.Skip()
  172. def OnItemChanged(self, event):
  173. """Change text in statusbar
  174. if the item selection in the auto-completion list is changed"""
  175. # list of commands
  176. if self.toComplete["entity"] == "command":
  177. item = (
  178. self.toComplete["cmd"].rpartition(".")[0]
  179. + "."
  180. + self.autoCompList[event.GetIndex()]
  181. )
  182. try:
  183. nodes = self._menuModel.SearchNodes(key="command", value=item)
  184. desc = ""
  185. if nodes:
  186. self.commandSelected.emit(command=item)
  187. desc = nodes[0].data["description"]
  188. except KeyError:
  189. desc = ""
  190. self.ShowStatusText(desc)
  191. # list of flags
  192. elif self.toComplete["entity"] == "flags":
  193. desc = self.cmdDesc.get_flag(self.autoCompList[event.GetIndex()])[
  194. "description"
  195. ]
  196. self.ShowStatusText(desc)
  197. # list of parameters
  198. elif self.toComplete["entity"] == "params":
  199. item = self.cmdDesc.get_param(self.autoCompList[event.GetIndex()])
  200. desc = item["name"] + "=" + item["type"]
  201. if not item["required"]:
  202. desc = "[" + desc + "]"
  203. desc += ": " + item["description"]
  204. self.ShowStatusText(desc)
  205. # list of flags and commands
  206. elif self.toComplete["entity"] == "params+flags":
  207. if self.autoCompList[event.GetIndex()][0] == "-":
  208. desc = self.cmdDesc.get_flag(
  209. self.autoCompList[event.GetIndex()].strip("-")
  210. )["description"]
  211. else:
  212. item = self.cmdDesc.get_param(self.autoCompList[event.GetIndex()])
  213. desc = item["name"] + "=" + item["type"]
  214. if not item["required"]:
  215. desc = "[" + desc + "]"
  216. desc += ": " + item["description"]
  217. self.ShowStatusText(desc)
  218. else:
  219. self.ShowStatusText("")
  220. def OnItemSelected(self, event):
  221. """Item selected from the list"""
  222. lastWord = self.GetWordLeft()
  223. # to insert selection correctly if selected word partly matches written
  224. # text
  225. match = difflib.SequenceMatcher(None, event.GetText(), lastWord)
  226. matchTuple = match.find_longest_match(0, len(event.GetText()), 0, len(lastWord))
  227. compl = event.GetText()[matchTuple[2] :]
  228. text = self.GetTextLeft() + compl
  229. # add space or '=' at the end
  230. end = "="
  231. for char in (".", "-", "="):
  232. if text.split(" ")[-1].find(char) >= 0:
  233. end = " "
  234. compl += end
  235. text += end
  236. self.AddText(compl)
  237. pos = len(text)
  238. self.SetCurrentPos(pos)
  239. cmd = text.strip().split(" ")[0]
  240. if not self.cmdDesc or cmd != self.cmdDesc.get_name():
  241. try:
  242. self.cmdDesc = gtask.parse_interface(cmd)
  243. except IOError:
  244. self.cmdDesc = None
  245. def OnKillFocus(self, event):
  246. """Hides autocomplete"""
  247. # hide autocomplete
  248. if self.AutoCompActive():
  249. self.AutoCompCancel()
  250. event.Skip()
  251. def SetTextAndFocus(self, text):
  252. pos = len(text)
  253. self.commandSelected.emit(command=text)
  254. self.SetText(text)
  255. self.SetSelectionStart(pos)
  256. self.SetCurrentPos(pos)
  257. self.SetFocus()
  258. def UpdateCmdHistory(self, cmd):
  259. """Update command history
  260. :param cmd: command given as a string
  261. """
  262. # add command to history
  263. self.cmdbuffer.append(cmd)
  264. # update also traced commands
  265. self.commands.append(cmd)
  266. # keep command history to a manageable size
  267. if len(self.cmdbuffer) > 200:
  268. del self.cmdbuffer[0]
  269. self.cmdindex = len(self.cmdbuffer)
  270. def EntityToComplete(self):
  271. """Determines which part of command (flags, parameters) should
  272. be completed at current cursor position"""
  273. entry = self.GetTextLeft()
  274. toComplete = dict(cmd=None, entity=None)
  275. try:
  276. cmd = entry.split()[0].strip()
  277. except IndexError:
  278. return toComplete
  279. try:
  280. splitted = utils.split(str(entry))
  281. except ValueError: # No closing quotation error
  282. return toComplete
  283. if len(splitted) > 0 and cmd in globalvar.grassCmd:
  284. toComplete["cmd"] = cmd
  285. if entry[-1] == " ":
  286. words = entry.split(" ")
  287. if any(word.startswith("-") for word in words):
  288. toComplete["entity"] = "params"
  289. else:
  290. toComplete["entity"] = "params+flags"
  291. else:
  292. # get word left from current position
  293. word = self.GetWordLeft(withDelimiter=True)
  294. if word[0] == "=" and word[-1] == "@":
  295. toComplete["entity"] = "mapsets"
  296. elif word[0] == "=":
  297. # get name of parameter
  298. paramName = self.GetWordLeft(
  299. withDelimiter=False, ignoredDelimiter="="
  300. ).strip("=")
  301. if paramName:
  302. try:
  303. param = self.cmdDesc.get_param(paramName)
  304. except (ValueError, AttributeError):
  305. return toComplete
  306. else:
  307. return toComplete
  308. if param["values"]:
  309. toComplete["entity"] = "param values"
  310. elif param["prompt"] == "raster" and param["element"] == "cell":
  311. toComplete["entity"] = "raster map"
  312. elif param["prompt"] == "vector" and param["element"] == "vector":
  313. toComplete["entity"] = "vector map"
  314. elif word[0] == "-":
  315. toComplete["entity"] = "flags"
  316. elif word[0] == " ":
  317. toComplete["entity"] = "params"
  318. else:
  319. toComplete["entity"] = "command"
  320. toComplete["cmd"] = cmd
  321. return toComplete
  322. def GetWordLeft(self, withDelimiter=False, ignoredDelimiter=None):
  323. """Get word left from current cursor position. The beginning
  324. of the word is given by space or chars: .,-=
  325. :param withDelimiter: returns the word with the initial delimeter
  326. :param ignoredDelimiter: finds the word ignoring certain delimeter
  327. """
  328. textLeft = self.GetTextLeft()
  329. parts = list()
  330. if ignoredDelimiter is None:
  331. ignoredDelimiter = ""
  332. for char in set(" .,-=") - set(ignoredDelimiter):
  333. if not withDelimiter:
  334. delimiter = ""
  335. else:
  336. delimiter = char
  337. parts.append(delimiter + textLeft.rpartition(char)[2])
  338. return min(parts, key=lambda x: len(x))
  339. def ShowList(self):
  340. """Show sorted auto-completion list if it is not empty"""
  341. if len(self.autoCompList) > 0:
  342. self.autoCompList.sort()
  343. self.AutoCompShow(0, itemList=" ".join(self.autoCompList))
  344. def OnKeyPressed(self, event):
  345. """Key pressed capture special treatment for tabulator to show help"""
  346. pos = self.GetCurrentPos()
  347. if event.GetKeyCode() == wx.WXK_TAB:
  348. # show GRASS command calltips (to hide press 'ESC')
  349. entry = self.GetTextLeft()
  350. try:
  351. cmd = entry.split()[0].strip()
  352. except IndexError:
  353. cmd = ""
  354. if cmd not in globalvar.grassCmd:
  355. return
  356. info = gtask.command_info(cmd)
  357. self.CallTipSetBackground("#f4f4d1")
  358. self.CallTipSetForeground("BLACK")
  359. self.CallTipShow(pos, info["usage"] + "\n\n" + info["description"])
  360. elif (
  361. event.GetKeyCode() in (wx.WXK_RETURN, wx.WXK_NUMPAD_ENTER)
  362. and not self.AutoCompActive()
  363. ):
  364. # run command on line when <return> is pressed
  365. self._runCmd(self.GetCurLine()[0].strip())
  366. elif (
  367. event.GetKeyCode() in [wx.WXK_UP, wx.WXK_DOWN] and not self.AutoCompActive()
  368. ):
  369. # Command history using up and down
  370. if len(self.cmdbuffer) < 1:
  371. return
  372. self.DocumentEnd()
  373. # move through command history list index values
  374. if event.GetKeyCode() == wx.WXK_UP:
  375. self.cmdindex = self.cmdindex - 1
  376. if event.GetKeyCode() == wx.WXK_DOWN:
  377. self.cmdindex = self.cmdindex + 1
  378. if self.cmdindex < 0:
  379. self.cmdindex = 0
  380. if self.cmdindex > len(self.cmdbuffer) - 1:
  381. self.cmdindex = len(self.cmdbuffer) - 1
  382. try:
  383. # without strip causes problem on windows
  384. txt = self.cmdbuffer[self.cmdindex].strip()
  385. except KeyError:
  386. txt = ""
  387. # clear current line and insert command history
  388. self.DelLineLeft()
  389. self.DelLineRight()
  390. pos = self.GetCurrentPos()
  391. self.InsertText(pos, txt)
  392. self.LineEnd()
  393. self.ShowStatusText("")
  394. else:
  395. event.Skip()
  396. def OnChar(self, event):
  397. """Key char capture for autocompletion, calltips, and command history
  398. .. todo::
  399. event.ControlDown() for manual autocomplete
  400. """
  401. # keycodes used: "." = 46, "=" = 61, "-" = 45
  402. pos = self.GetCurrentPos()
  403. # complete command after pressing '.'
  404. if event.GetKeyCode() == 46:
  405. self.autoCompList = list()
  406. entry = self.GetTextLeft()
  407. self.InsertText(pos, ".")
  408. self.CharRight()
  409. self.toComplete = self.EntityToComplete()
  410. try:
  411. if self.toComplete["entity"] == "command":
  412. for command in globalvar.grassCmd:
  413. try:
  414. if command.find(self.toComplete["cmd"]) == 0:
  415. dotNumber = list(self.toComplete["cmd"]).count(".")
  416. self.autoCompList.append(
  417. command.split(".", dotNumber)[-1]
  418. )
  419. except UnicodeDecodeError as error:
  420. sys.stderr.write(DecodeString(command) + ": " + str(error))
  421. except (KeyError, TypeError):
  422. return
  423. self.ShowList()
  424. # complete flags after pressing '-'
  425. elif (
  426. (event.GetKeyCode() == 45)
  427. or event.GetKeyCode() == wx.WXK_NUMPAD_SUBTRACT
  428. or event.GetKeyCode() == wx.WXK_SUBTRACT
  429. ):
  430. self.autoCompList = list()
  431. entry = self.GetTextLeft()
  432. self.InsertText(pos, "-")
  433. self.CharRight()
  434. self.toComplete = self.EntityToComplete()
  435. if self.toComplete["entity"] == "flags" and self.cmdDesc:
  436. if self.GetTextLeft()[-2:] == " -": # complete e.g. --quite
  437. for flag in self.cmdDesc.get_options()["flags"]:
  438. if len(flag["name"]) == 1:
  439. self.autoCompList.append(flag["name"])
  440. else:
  441. for flag in self.cmdDesc.get_options()["flags"]:
  442. if len(flag["name"]) > 1:
  443. self.autoCompList.append(flag["name"])
  444. self.ShowList()
  445. # complete map or values after parameter
  446. elif event.GetKeyCode() == 61:
  447. self.autoCompList = list()
  448. self.InsertText(pos, "=")
  449. self.CharRight()
  450. self.toComplete = self.EntityToComplete()
  451. if self.toComplete["entity"] == "raster map":
  452. self.autoCompList = self.mapList["raster"]
  453. elif self.toComplete["entity"] == "vector map":
  454. self.autoCompList = self.mapList["vector"]
  455. elif self.toComplete["entity"] == "param values":
  456. param = self.GetWordLeft(
  457. withDelimiter=False, ignoredDelimiter="="
  458. ).strip(" =")
  459. self.autoCompList = self.cmdDesc.get_param(param)["values"]
  460. self.ShowList()
  461. # complete mapset ('@')
  462. elif event.GetKeyCode() == 64:
  463. self.autoCompList = list()
  464. self.InsertText(pos, "@")
  465. self.CharRight()
  466. self.toComplete = self.EntityToComplete()
  467. if self.toComplete["entity"] == "mapsets":
  468. self.autoCompList = self.mapsetList
  469. self.ShowList()
  470. # complete after pressing CTRL + Space
  471. elif event.GetKeyCode() == wx.WXK_SPACE and event.ControlDown():
  472. self.autoCompList = list()
  473. self.toComplete = self.EntityToComplete()
  474. # complete command
  475. if self.toComplete["entity"] == "command":
  476. for command in globalvar.grassCmd:
  477. if command.find(self.toComplete["cmd"]) == 0:
  478. dotNumber = list(self.toComplete["cmd"]).count(".")
  479. self.autoCompList.append(command.split(".", dotNumber)[-1])
  480. # complete flags in such situations (| is cursor):
  481. # r.colors -| ...w, q, l
  482. # r.colors -w| ...w, q, l
  483. elif self.toComplete["entity"] == "flags" and self.cmdDesc:
  484. for flag in self.cmdDesc.get_options()["flags"]:
  485. if len(flag["name"]) == 1:
  486. self.autoCompList.append(flag["name"])
  487. # complete parameters in such situations (| is cursor):
  488. # r.colors -w | ...color, map, rast, rules
  489. # r.colors col| ...color
  490. elif self.toComplete["entity"] == "params" and self.cmdDesc:
  491. for param in self.cmdDesc.get_options()["params"]:
  492. if param["name"].find(self.GetWordLeft(withDelimiter=False)) == 0:
  493. self.autoCompList.append(param["name"])
  494. # complete flags or parameters in such situations (| is cursor):
  495. # r.colors | ...-w, -q, -l, color, map, rast, rules
  496. # r.colors color=grey | ...-w, -q, -l, color, map, rast, rules
  497. elif self.toComplete["entity"] == "params+flags" and self.cmdDesc:
  498. self.autoCompList = list()
  499. for param in self.cmdDesc.get_options()["params"]:
  500. self.autoCompList.append(param["name"])
  501. for flag in self.cmdDesc.get_options()["flags"]:
  502. if len(flag["name"]) == 1:
  503. self.autoCompList.append("-" + flag["name"])
  504. else:
  505. self.autoCompList.append("--" + flag["name"])
  506. self.ShowList()
  507. # complete map or values after parameter
  508. # r.buffer input=| ...list of raster maps
  509. # r.buffer units=| ... feet, kilometers, ...
  510. elif self.toComplete["entity"] == "raster map":
  511. self.autoCompList = list()
  512. self.autoCompList = self.mapList["raster"]
  513. elif self.toComplete["entity"] == "vector map":
  514. self.autoCompList = list()
  515. self.autoCompList = self.mapList["vector"]
  516. elif self.toComplete["entity"] == "param values":
  517. self.autoCompList = list()
  518. param = self.GetWordLeft(
  519. withDelimiter=False, ignoredDelimiter="="
  520. ).strip(" =")
  521. self.autoCompList = self.cmdDesc.get_param(param)["values"]
  522. self.ShowList()
  523. elif event.GetKeyCode() == wx.WXK_SPACE:
  524. items = self.GetTextLeft().split()
  525. if len(items) == 1:
  526. cmd = items[0].strip()
  527. if cmd in globalvar.grassCmd and (
  528. not self.cmdDesc or cmd != self.cmdDesc.get_name()
  529. ):
  530. try:
  531. self.cmdDesc = gtask.parse_interface(cmd)
  532. except IOError:
  533. self.cmdDesc = None
  534. event.Skip()
  535. else:
  536. event.Skip()
  537. def ShowStatusText(self, text):
  538. """Requests showing of notification, e.g. showing in a statusbar."""
  539. self.showNotification.emit(message=text)
  540. def GetTextLeft(self):
  541. """Returns all text left of the caret"""
  542. pos = self.GetCurrentPos()
  543. self.HomeExtend()
  544. entry = self.GetSelectedText()
  545. self.SetCurrentPos(pos)
  546. return entry
  547. def OnDestroy(self, event):
  548. """The clipboard contents can be preserved after
  549. the app has exited"""
  550. if wx.TheClipboard.IsOpened():
  551. wx.TheClipboard.Flush()
  552. event.Skip()
  553. def OnCmdErase(self, event):
  554. """Erase command prompt"""
  555. self.Home()
  556. self.DelLineRight()