MCPcopy Create free account
hub / github.com/MCSLTeam/MCSL2 / CommandLineEdit

Class CommandLineEdit

MCSL2Lib/ServerControllers/windowCreator.py:94–118  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

92
93
94class CommandLineEdit(LineEdit):
95 def __init__(self, parent=None):
96 super().__init__(parent)
97 self.upT = 0
98 self.userCommandHistory = []
99 self.installEventFilter(self)
100
101 def eventFilter(self, a0: QObject, a1: QEvent) -> bool:
102 if a1.type() == QEvent.KeyPress:
103 if a1.key() == Qt.Key_Up:
104 if len(self.userCommandHistory) and self.upT > -len(self.userCommandHistory):
105 self.upT -= 1
106 lastCommand = self.userCommandHistory[self.upT]
107 self.setText(lastCommand)
108 return True
109 elif a1.key() == Qt.Key_Down:
110 if len(self.userCommandHistory) and self.upT < 0:
111 self.upT += 1
112 nextCommand = self.userCommandHistory[self.upT]
113 self.setText(nextCommand)
114 return True
115 if len(self.userCommandHistory) and self.upT == 0:
116 self.setText("")
117 return True
118 return super().eventFilter(a0, a1)
119
120
121def _normalize_base_url(url: str) -> str:

Callers 1

setupCommandPageMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected