Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 0.6, 0.7, and 0.7.1

changeset: support user-defined tab widths

Uses python str.expandtabs() function to expand tabs within the patch
lines before displaying them. This provides correct tab functionality,
but has the downside of making cut-paste of the GUI buffer different
from the actual patch. Since we offer patch export to file
functionality, this is probably a good tradeoff.

Changeset 988cc5fc328c

Parent a94de20ebd94

by Steve Borho

Changes to 2 files · Browse files at 988cc5fc328c Showing diff from parent a94de20ebd94 Diff from another changeset...

 
376
377
378
 
 
379
380
381
 
405
406
407
 
 
408
409
410
 
 
411
412
413
414
415
 
 
416
417
 
 
418
419
420
 
376
377
378
379
380
381
382
383
 
407
408
409
410
411
412
413
414
415
416
417
418
419
 
 
420
421
422
423
424
425
426
427
428
@@ -376,6 +376,8 @@
    def prepare_diff(self, difflines, offset, fname):   '''Borrowed from hgview; parses changeset diffs''' + import hglib + tw = hglib.gettabwidth(self.ui)   DIFFHDR = "=== %s ===\n"   idx = 0   outlines = [] @@ -405,16 +407,22 @@
  continue   elif l.startswith("---"):   continue + elif l.startswith("@@"): + tag = "blue"   elif l.startswith("+"):   tag = "green"   stats[0] += 1 + if tw: + l = l[0] + l[1:].expandtabs(tw)   elif l.startswith("-"):   stats[1] += 1   tag = "red" - elif l.startswith("@@"): - tag = "blue" + if tw: + l = l[0] + l[1:].expandtabs(tw)   else:   tag = "black" + if tw: + l = l[0] + l[1:].expandtabs(tw)   l = l+"\n"   length = len(l.decode('utf-8'))   addtag( tag, offset, length )
Change 1 of 1 Show Entire File hggtk/​hglib.py Stacked
 
72
73
74
 
 
 
 
 
 
 
 
 
 
75
76
77
 
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
@@ -72,6 +72,16 @@
  return ''   return p   +def gettabwidth(ui): + tabwidth = ui.config('tortoisehg', 'tabwidth') + try: + tabwidth = int(tabwidth) + if tabwidth < 1 or tabwidth > 16: + tabwidth = None + except (ValueError, TypeError), e: + tabwidth = None + return tabwidth +    class GtkUi(ui.ui):   '''