Mercurial > kallithea
changeset 5095:3a139a5500dd stable
diff view: improve appearance of line numbers
* display the ellipsis just once and centered
instead of showing in twice in both - and + columns
* expand column width as needed to accomodate longer numbers
(previously, the column width was fixed)
* enable box-sizing: border-box for the number links to
make it easier to set paddings
author | Andrew Shadura <andrew@shadura.me> |
---|---|
date | Tue, 05 May 2015 18:13:00 +0200 |
parents | 200f43d9c86d |
children | fe3c9c048740 |
files | kallithea/lib/diffs.py kallithea/public/css/style.css |
diffstat | 2 files changed, 22 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/kallithea/lib/diffs.py Tue May 05 17:39:00 2015 +0200 +++ b/kallithea/lib/diffs.py Tue May 05 18:13:00 2015 +0200 @@ -642,6 +642,7 @@ def as_html(self, table_class='code-difftable', line_class='line', old_lineno_class='lineno old', new_lineno_class='lineno new', + no_lineno_class='lineno', code_class='code', enable_comments=False, parsed_lines=None): """ Return given diff as html table with customized css classes @@ -693,6 +694,8 @@ change['old_lineno']) cond_new = (change['new_lineno'] != '...' and change['new_lineno']) + no_lineno = (change['old_lineno'] == '...' and + change['new_lineno'] == '...') if cond_old: anchor_old_id = 'id="%s"' % anchor_old if cond_new: @@ -700,9 +703,10 @@ ########################################################### # OLD LINE NUMBER ########################################################### - _html.append('''\t<td %(a_id)s class="%(olc)s">''' % { + _html.append('''\t<td %(a_id)s class="%(olc)s" %(colspan)s>''' % { 'a_id': anchor_old_id, - 'olc': old_lineno_class + 'olc': no_lineno_class if no_lineno else old_lineno_class, + 'colspan': 'colspan="2"' if no_lineno else '' }) _html.append('''%(link)s''' % { @@ -714,16 +718,17 @@ # NEW LINE NUMBER ########################################################### - _html.append('''\t<td %(a_id)s class="%(nlc)s">''' % { - 'a_id': anchor_new_id, - 'nlc': new_lineno_class - }) + if not no_lineno: + _html.append('''\t<td %(a_id)s class="%(nlc)s">''' % { + 'a_id': anchor_new_id, + 'nlc': new_lineno_class + }) - _html.append('''%(link)s''' % { - 'link': _link_to_if(True, change['new_lineno'], - '#%s' % anchor_new) - }) - _html.append('''</td>\n''') + _html.append('''%(link)s''' % { + 'link': _link_to_if(True, change['new_lineno'], + '#%s' % anchor_new) + }) + _html.append('''</td>\n''') ########################################################### # CODE ###########################################################
--- a/kallithea/public/css/style.css Tue May 05 17:39:00 2015 +0200 +++ b/kallithea/public/css/style.css Tue May 05 18:13:00 2015 +0200 @@ -4901,7 +4901,6 @@ table.code-difftable .lineno { padding-left: 2px; padding-right: 2px !important; - text-align: right; width: 30px; -moz-user-select: none; -webkit-user-select: none; @@ -4910,20 +4909,24 @@ border-top: 0px solid #CCC !important; border-bottom: none !important; vertical-align: middle !important; + text-align: center; } table.code-difftable .lineno.new { + text-align: right; } table.code-difftable .lineno.old { + text-align: right; } table.code-difftable .lineno a { color: #aaa !important; font: 11px Consolas, Monaco, Inconsolata, Liberation Mono, monospace !important; letter-spacing: -1px; - text-align: right; + padding-left: 10px; padding-right: 8px; + box-sizing: border-box; cursor: pointer; display: block; - width: 30px; + width: 100%; } table.code-difftable .lineno-inline {