Skip to content

Commit f80244f

Browse files
committed
Fix highlighting of the player name in the initial prompt
Importing readline seems to break escape codes in input.
1 parent d312a6f commit f80244f

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/fantasy_forge/shell.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import logging
44
import os.path
5-
import readline
65
from cmd import Cmd
76
from typing import TYPE_CHECKING
87

@@ -54,15 +53,17 @@ def __init__(self, messages: Messages, player: Player, stdin=None, stdout=None):
5453
self.messages = messages
5554

5655
if not stdin and not stdout: # check if singleplayer
56+
import readline
5757
self.histfile = xdg_cache_home() / "fantasy_forge.hist"
58-
if readline and os.path.exists(self.histfile):
58+
if os.path.exists(self.histfile):
5959
readline.read_history_file(self.histfile)
6060
else:
6161
self.histfile = None
6262

6363
def postloop(self):
6464
histfile_size = 1000
65-
if readline and self.histfile:
65+
if self.histfile:
66+
import readline
6667
readline.set_history_length(histfile_size)
6768
readline.write_history_file(self.histfile)
6869

0 commit comments

Comments
 (0)