295 QsciScintilla.SCI_CHARRIGHT: self.__QScintillaCharRight, |
295 QsciScintilla.SCI_CHARRIGHT: self.__QScintillaCharRight, |
296 QsciScintilla.SCI_WORDLEFT: self.__QScintillaWordLeft, |
296 QsciScintilla.SCI_WORDLEFT: self.__QScintillaWordLeft, |
297 QsciScintilla.SCI_WORDRIGHT: self.__QScintillaWordRight, |
297 QsciScintilla.SCI_WORDRIGHT: self.__QScintillaWordRight, |
298 QsciScintilla.SCI_VCHOME: self.__QScintillaVCHome, |
298 QsciScintilla.SCI_VCHOME: self.__QScintillaVCHome, |
299 QsciScintilla.SCI_LINEEND: self.__QScintillaLineEnd, |
299 QsciScintilla.SCI_LINEEND: self.__QScintillaLineEnd, |
300 QsciScintilla.SCI_LINEUP: self.__QScintillaLineUp, |
300 QsciScintilla.SCI_LINEUP: self.__QScintillaCommand, |
301 QsciScintilla.SCI_LINEDOWN: self.__QScintillaLineDown, |
301 QsciScintilla.SCI_LINEDOWN: self.__QScintillaCommand, |
|
302 QsciScintilla.SCI_LINESCROLLUP: self.__QScintillaHistoryUp, |
|
303 QsciScintilla.SCI_LINESCROLLDOWN: self.__QScintillaHistoryDown, |
302 |
304 |
303 QsciScintilla.SCI_PAGEUP: self.__QScintillaAutoCompletionCommand, |
305 QsciScintilla.SCI_PAGEUP: self.__QScintillaAutoCompletionCommand, |
304 QsciScintilla.SCI_PAGEDOWN: self.__QScintillaAutoCompletionCommand, |
306 QsciScintilla.SCI_PAGEDOWN: self.__QScintillaAutoCompletionCommand, |
305 QsciScintilla.SCI_CANCEL: self.__QScintillaAutoCompletionCommand, |
307 QsciScintilla.SCI_CANCEL: self.__QScintillaAutoCompletionCommand, |
306 |
308 |
1208 buf = buf.replace(sys.ps1, "") |
1221 buf = buf.replace(sys.ps1, "") |
1209 if buf.startswith(sys.ps2): |
1222 if buf.startswith(sys.ps2): |
1210 buf = buf.replace(sys.ps2, "") |
1223 buf = buf.replace(sys.ps2, "") |
1211 self.insert('\n') |
1224 self.insert('\n') |
1212 self.__executeCommand(buf) |
1225 self.__executeCommand(buf) |
|
1226 else: |
|
1227 txt = "" |
|
1228 line, col = self.getCursorPosition() |
|
1229 if self.hasSelectedText(): |
|
1230 lineFrom, indexFrom, lineTo, indexTo = self.getSelection() |
|
1231 if line == lineFrom: |
|
1232 txt = self.text(line)[indexFrom:].rstrip() |
|
1233 elif line == lineTo: |
|
1234 txt = self.text(line)[:indexTo] |
|
1235 else: |
|
1236 txt = self.text(line)[col:].rstrip() |
|
1237 |
|
1238 if txt: |
|
1239 line, col = self.__getEndPos() |
|
1240 self.setCursorPosition(line, col) |
|
1241 self.insert(txt) |
1213 |
1242 |
1214 def __QScintillaLeftCommand(self, method, allLinesAllowed=False): |
1243 def __QScintillaLeftCommand(self, method, allLinesAllowed=False): |
1215 """ |
1244 """ |
1216 Private method to handle a QScintilla command working to the left. |
1245 Private method to handle a QScintilla command working to the left. |
1217 |
1246 |
1302 if self.isListActive(): |
1335 if self.isListActive(): |
1303 self.SendScintilla(cmd) |
1336 self.SendScintilla(cmd) |
1304 elif self.__isCursorOnLastLine(): |
1337 elif self.__isCursorOnLastLine(): |
1305 self.moveCursorToEOL() |
1338 self.moveCursorToEOL() |
1306 |
1339 |
1307 def __QScintillaLineUp(self, cmd): |
1340 def __QScintillaHistoryUp(self, cmd): |
1308 """ |
1341 """ |
1309 Private method to handle the Up key. |
1342 Private method to handle the Ctrl+Up key. |
1310 |
1343 |
1311 @param cmd QScintilla command |
1344 @param cmd QScintilla command |
1312 """ |
1345 """ |
1313 if self.isListActive(): |
1346 line, col = self.__getEndPos() |
1314 self.SendScintilla(cmd) |
1347 buf = self.text(line) |
1315 else: |
1348 if buf.startswith(sys.ps1): |
1316 line, col = self.__getEndPos() |
1349 buf = buf.replace(sys.ps1, "") |
1317 buf = self.text(line) |
1350 if buf.startswith(sys.ps2): |
1318 if buf.startswith(sys.ps1): |
1351 buf = buf.replace(sys.ps2, "") |
1319 buf = buf.replace(sys.ps1, "") |
1352 if buf and self.incrementalSearchActive: |
1320 if buf.startswith(sys.ps2): |
1353 if self.incrementalSearchString: |
1321 buf = buf.replace(sys.ps2, "") |
1354 idx = self.__rsearchHistory(self.incrementalSearchString, |
1322 if buf and self.incrementalSearchActive: |
1355 self.histidx) |
1323 if self.incrementalSearchString: |
1356 if idx >= 0: |
1324 idx = self.__rsearchHistory(self.incrementalSearchString, |
1357 self.histidx = idx |
1325 self.histidx) |
1358 self.__useHistory() |
1326 if idx >= 0: |
|
1327 self.histidx = idx |
|
1328 self.__useHistory() |
|
1329 else: |
|
1330 idx = self.__rsearchHistory(buf) |
|
1331 if idx >= 0: |
|
1332 self.histidx = idx |
|
1333 self.incrementalSearchString = buf |
|
1334 self.__useHistory() |
|
1335 else: |
1359 else: |
1336 if self.histidx < 0: |
1360 idx = self.__rsearchHistory(buf) |
1337 self.histidx = len(self.history) |
1361 if idx >= 0: |
1338 if self.histidx > 0: |
1362 self.histidx = idx |
1339 self.histidx = self.histidx - 1 |
1363 self.incrementalSearchString = buf |
1340 self.__useHistory() |
1364 self.__useHistory() |
1341 |
1365 else: |
1342 def __QScintillaLineDown(self, cmd): |
1366 if self.histidx < 0: |
1343 """ |
1367 self.histidx = len(self.history) |
1344 Private method to handle the Down key. |
1368 if self.histidx > 0: |
|
1369 self.histidx = self.histidx - 1 |
|
1370 self.__useHistory() |
|
1371 |
|
1372 def __QScintillaHistoryDown(self, cmd): |
|
1373 """ |
|
1374 Private method to handle the Ctrl+Down key. |
1345 |
1375 |
1346 @param cmd QScintilla command |
1376 @param cmd QScintilla command |
1347 """ |
1377 """ |
1348 if self.isListActive(): |
1378 line, col = self.__getEndPos() |
1349 self.SendScintilla(cmd) |
1379 buf = self.text(line) |
1350 else: |
1380 if buf.startswith(sys.ps1): |
1351 line, col = self.__getEndPos() |
1381 buf = buf.replace(sys.ps1, "") |
1352 buf = self.text(line) |
1382 if buf.startswith(sys.ps2): |
1353 if buf.startswith(sys.ps1): |
1383 buf = buf.replace(sys.ps2, "") |
1354 buf = buf.replace(sys.ps1, "") |
1384 if buf and self.incrementalSearchActive: |
1355 if buf.startswith(sys.ps2): |
1385 if self.incrementalSearchString: |
1356 buf = buf.replace(sys.ps2, "") |
1386 idx = self.__searchHistory( |
1357 if buf and self.incrementalSearchActive: |
1387 self.incrementalSearchString, self.histidx) |
1358 if self.incrementalSearchString: |
1388 if idx >= 0: |
1359 idx = self.__searchHistory( |
1389 self.histidx = idx |
1360 self.incrementalSearchString, self.histidx) |
1390 self.__useHistory() |
1361 if idx >= 0: |
|
1362 self.histidx = idx |
|
1363 self.__useHistory() |
|
1364 else: |
|
1365 idx = self.__searchHistory(buf) |
|
1366 if idx >= 0: |
|
1367 self.histidx = idx |
|
1368 self.incrementalSearchString = buf |
|
1369 self.__useHistory() |
|
1370 else: |
1391 else: |
1371 if self.histidx >= 0 and self.histidx < len(self.history): |
1392 idx = self.__searchHistory(buf) |
1372 self.histidx += 1 |
1393 if idx >= 0: |
|
1394 self.histidx = idx |
|
1395 self.incrementalSearchString = buf |
1373 self.__useHistory() |
1396 self.__useHistory() |
|
1397 else: |
|
1398 if self.histidx >= 0 and self.histidx < len(self.history): |
|
1399 self.histidx += 1 |
|
1400 self.__useHistory() |
1374 |
1401 |
1375 def __QScintillaCharLeftExtend(self): |
1402 def __QScintillaCharLeftExtend(self): |
1376 """ |
1403 """ |
1377 Private method to handle the Extend Selection Left command. |
1404 Private method to handle the Extend Selection Left command. |
1378 """ |
1405 """ |