##// END OF EJS Templates
chistedit: add basic colours to diff view...
Jordi Gutiérrez Hermoso -
r42258:16692aa3 default
parent child Browse files
Show More
@@ -963,6 +963,7 b' ACTION_LABELS = {'
963 }
963 }
964
964
965 COLOR_HELP, COLOR_SELECTED, COLOR_OK, COLOR_WARN, COLOR_CURRENT = 1, 2, 3, 4, 5
965 COLOR_HELP, COLOR_SELECTED, COLOR_OK, COLOR_WARN, COLOR_CURRENT = 1, 2, 3, 4, 5
966 COLOR_DIFF_ADD_LINE, COLOR_DIFF_DEL_LINE, COLOR_DIFF_OFFSET = 6, 7, 8
966
967
967 E_QUIT, E_HISTEDIT = 1, 2
968 E_QUIT, E_HISTEDIT = 1, 2
968 E_PAGEDOWN, E_PAGEUP, E_LINEUP, E_LINEDOWN, E_RESIZE = 3, 4, 5, 6, 7
969 E_PAGEDOWN, E_PAGEUP, E_LINEUP, E_LINEDOWN, E_RESIZE = 3, 4, 5, 6, 7
@@ -1249,6 +1250,9 b' def _chisteditmain(repo, rules, stdscr):'
1249 curses.init_pair(COLOR_WARN, curses.COLOR_BLACK, curses.COLOR_YELLOW)
1250 curses.init_pair(COLOR_WARN, curses.COLOR_BLACK, curses.COLOR_YELLOW)
1250 curses.init_pair(COLOR_OK, curses.COLOR_BLACK, curses.COLOR_GREEN)
1251 curses.init_pair(COLOR_OK, curses.COLOR_BLACK, curses.COLOR_GREEN)
1251 curses.init_pair(COLOR_CURRENT, curses.COLOR_WHITE, curses.COLOR_MAGENTA)
1252 curses.init_pair(COLOR_CURRENT, curses.COLOR_WHITE, curses.COLOR_MAGENTA)
1253 curses.init_pair(COLOR_DIFF_ADD_LINE, curses.COLOR_GREEN, -1)
1254 curses.init_pair(COLOR_DIFF_DEL_LINE, curses.COLOR_RED, -1)
1255 curses.init_pair(COLOR_DIFF_OFFSET, curses.COLOR_MAGENTA, -1)
1252
1256
1253 # don't display the cursor
1257 # don't display the cursor
1254 try:
1258 try:
@@ -1345,16 +1349,30 b' pgup/K: move patch up, pgdn/J: move patc'
1345 addln(rulesscr, y, 2, rule)
1349 addln(rulesscr, y, 2, rule)
1346 rulesscr.noutrefresh()
1350 rulesscr.noutrefresh()
1347
1351
1348 def renderstring(win, state, output):
1352 def renderstring(win, state, output, diffcolors=False):
1349 maxy, maxx = win.getmaxyx()
1353 maxy, maxx = win.getmaxyx()
1350 length = min(maxy - 1, len(output))
1354 length = min(maxy - 1, len(output))
1351 for y in range(0, length):
1355 for y in range(0, length):
1352 win.addstr(y, 0, output[y])
1356 line = output[y]
1357 if diffcolors:
1358 if line and line[0] == '+':
1359 win.addstr(
1360 y, 0, line, curses.color_pair(COLOR_DIFF_ADD_LINE))
1361 elif line and line[0] == '-':
1362 win.addstr(
1363 y, 0, line, curses.color_pair(COLOR_DIFF_DEL_LINE))
1364 elif line.startswith('@@ '):
1365 win.addstr(
1366 y, 0, line, curses.color_pair(COLOR_DIFF_OFFSET))
1367 else:
1368 win.addstr(y, 0, line)
1369 else:
1370 win.addstr(y, 0, line)
1353 win.noutrefresh()
1371 win.noutrefresh()
1354
1372
1355 def renderpatch(win, state):
1373 def renderpatch(win, state):
1356 start = state['modes'][MODE_PATCH]['line_offset']
1374 start = state['modes'][MODE_PATCH]['line_offset']
1357 renderstring(win, state, patchcontents(state)[start:])
1375 renderstring(win, state, patchcontents(state)[start:], diffcolors=True)
1358
1376
1359 def layout(mode):
1377 def layout(mode):
1360 maxy, maxx = stdscr.getmaxyx()
1378 maxy, maxx = stdscr.getmaxyx()
General Comments 0
You need to be logged in to leave comments. Login now