##// END OF EJS Templates
chistedit: remove some local variable and access state on self instead...
Martin von Zweigbergk -
r49028:1895027c default
parent child Browse files
Show More
@@ -1256,9 +1256,7 b' class _chistedit_state(object):'
1256 1256 def render_commit(self, win):
1257 1257 """Renders the commit window that shows the log of the current selected
1258 1258 commit"""
1259 pos = self.pos
1260 rules = self.rules
1261 rule = rules[pos]
1259 rule = self.rules[self.pos]
1262 1260
1263 1261 ctx = rule.ctx
1264 1262 win.box()
@@ -1345,19 +1343,16 b' pgup/K: move patch up, pgdn/J: move patc'
1345 1343 }
1346 1344
1347 1345 def render_rules(self, rulesscr):
1348 rules = self.rules
1349 pos = self.pos
1350 selected = self.selected
1351 1346 start = self.modes[MODE_RULES][b'line_offset']
1352 1347
1353 conflicts = [r.ctx for r in rules if r.conflicts]
1348 conflicts = [r.ctx for r in self.rules if r.conflicts]
1354 1349 if len(conflicts) > 0:
1355 1350 line = b"potential conflict in %s" % b','.join(
1356 1351 map(pycompat.bytestr, conflicts)
1357 1352 )
1358 1353 addln(rulesscr, -1, 0, line, curses.color_pair(COLOR_WARN))
1359 1354
1360 for y, rule in enumerate(rules[start:]):
1355 for y, rule in enumerate(self.rules[start:]):
1361 1356 if y >= self.page_height:
1362 1357 break
1363 1358 if len(rule.conflicts) > 0:
@@ -1365,10 +1360,10 b' pgup/K: move patch up, pgdn/J: move patc'
1365 1360 else:
1366 1361 rulesscr.addstr(y, 0, b" ", curses.COLOR_BLACK)
1367 1362
1368 if y + start == selected:
1363 if y + start == self.selected:
1369 1364 rollcolor = COLOR_ROLL_SELECTED
1370 1365 addln(rulesscr, y, 2, rule, curses.color_pair(COLOR_SELECTED))
1371 elif y + start == pos:
1366 elif y + start == self.pos:
1372 1367 rollcolor = COLOR_ROLL_CURRENT
1373 1368 addln(
1374 1369 rulesscr,
@@ -1424,9 +1419,7 b' pgup/K: move patch up, pgdn/J: move patc'
1424 1419 This takes the current state and based on the current character input from
1425 1420 the user we change the state.
1426 1421 """
1427 selected = self.selected
1428 1422 oldpos = self.pos
1429 rules = self.rules
1430 1423
1431 1424 if ch in (curses.KEY_RESIZE, b"KEY_RESIZE"):
1432 1425 return E_RESIZE
@@ -1442,26 +1435,26 b' pgup/K: move patch up, pgdn/J: move patc'
1442 1435 if action is None:
1443 1436 return
1444 1437 if action in (b'down', b'move-down'):
1445 newpos = min(oldpos + 1, len(rules) - 1)
1438 newpos = min(oldpos + 1, len(self.rules) - 1)
1446 1439 self.move_cursor(oldpos, newpos)
1447 if selected is not None or action == b'move-down':
1440 if self.selected is not None or action == b'move-down':
1448 1441 self.swap(oldpos, newpos)
1449 1442 elif action in (b'up', b'move-up'):
1450 1443 newpos = max(0, oldpos - 1)
1451 1444 self.move_cursor(oldpos, newpos)
1452 if selected is not None or action == b'move-up':
1445 if self.selected is not None or action == b'move-up':
1453 1446 self.swap(oldpos, newpos)
1454 1447 elif action == b'next-action':
1455 1448 self.cycle_action(oldpos, next=True)
1456 1449 elif action == b'prev-action':
1457 1450 self.cycle_action(oldpos, next=False)
1458 1451 elif action == b'select':
1459 selected = oldpos if selected is None else None
1460 self.make_selection(selected)
1461 elif action == b'goto' and int(ch) < len(rules) and len(rules) <= 10:
1462 newrule = next((r for r in rules if r.origpos == int(ch)))
1452 self.selected = oldpos if self.selected is None else None
1453 self.make_selection(self.selected)
1454 elif action == b'goto' and int(ch) < len(self.rules) <= 10:
1455 newrule = next((r for r in self.rules if r.origpos == int(ch)))
1463 1456 self.move_cursor(oldpos, newrule.pos)
1464 if selected is not None:
1457 if self.selected is not None:
1465 1458 self.swap(oldpos, newrule.pos)
1466 1459 elif action.startswith(b'action-'):
1467 1460 self.change_action(oldpos, action[7:])
@@ -1549,16 +1542,14 b' pgup/K: move patch up, pgdn/J: move patc'
1549 1542
1550 1543 def change_action(self, pos, action):
1551 1544 """Change the action state on the given position to the new action"""
1552 rules = self.rules
1553 assert 0 <= pos < len(rules)
1554 rules[pos].action = action
1545 assert 0 <= pos < len(self.rules)
1546 self.rules[pos].action = action
1555 1547
1556 1548 def cycle_action(self, pos, next=False):
1557 1549 """Changes the action state the next or the previous action from
1558 1550 the action list"""
1559 rules = self.rules
1560 assert 0 <= pos < len(rules)
1561 current = rules[pos].action
1551 assert 0 <= pos < len(self.rules)
1552 current = self.rules[pos].action
1562 1553
1563 1554 assert current in KEY_LIST
1564 1555
General Comments 0
You need to be logged in to leave comments. Login now