mirror of
https://gitlab.gnome.org/GNOME/gitg
synced 2024-08-27 11:59:17 +00:00
Use tab-size css to control tab width
This commit is contained in:
parent
77b54401c8
commit
89a3c8168e
|
@ -212,20 +212,20 @@ function split_words(lines)
|
|||
return ret;
|
||||
}
|
||||
|
||||
function make_content(content, ccontext)
|
||||
function make_content(content)
|
||||
{
|
||||
return html_escape(content).replace(/\t/g, ccontext.tabrepl);
|
||||
return html_escape(content);;
|
||||
}
|
||||
|
||||
function make_content_cell(content, tws, ccontext)
|
||||
function make_content_cell(content, tws)
|
||||
{
|
||||
content = make_content(content, ccontext);
|
||||
content = make_content(content);
|
||||
|
||||
var ws = '';
|
||||
|
||||
if (tws)
|
||||
{
|
||||
ws = make_content(tws, ccontext);
|
||||
ws = make_content(tws);
|
||||
ws = '<span class="trailing-whitespace">' + ws + '</span>';
|
||||
}
|
||||
|
||||
|
@ -371,7 +371,7 @@ function lines_to_word_diff_rows(removed, added, ccontext)
|
|||
}
|
||||
else
|
||||
{
|
||||
var content = make_content(word, ccontext);
|
||||
var content = make_content(word);
|
||||
var cls = edit_type_to_cls(dist.moves[i]);
|
||||
|
||||
if (cls.length != 0)
|
||||
|
@ -449,7 +449,7 @@ function line_to_row(l, ccontext)
|
|||
}
|
||||
|
||||
row += '<td class="gutter type">' + o + '</td>';
|
||||
row += make_content_cell(l.content, l.trailing_whitespace, ccontext);
|
||||
row += make_content_cell(l.content, l.trailing_whitespace);
|
||||
row += '</tr>';
|
||||
|
||||
return row;
|
||||
|
@ -457,12 +457,9 @@ function line_to_row(l, ccontext)
|
|||
|
||||
function diff_file(file, lnstate, data)
|
||||
{
|
||||
var tabrepl = '<span class="tab" style="width: ' + data.settings.tab_width + 'ex">\t</span>';
|
||||
|
||||
var file_body = '';
|
||||
|
||||
var ccontext = {
|
||||
tabrepl: tabrepl,
|
||||
added: 0,
|
||||
removed: 0,
|
||||
old: 0,
|
||||
|
|
|
@ -4,6 +4,9 @@
|
|||
<link rel="stylesheet" href="diff-view.css" type="text/css" media="screen" charset="utf-8" />
|
||||
<script type="text/javascript" src="jquery-2.0.3.min.js"></script>
|
||||
<script type="text/javascript" src="diff-view.js"></script>
|
||||
|
||||
<style id="dynamic_styles">
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="templates">
|
||||
|
|
|
@ -334,6 +334,22 @@ function xhr_get(action, data, onload)
|
|||
r.send();
|
||||
}
|
||||
|
||||
var tab_width_rule = null;
|
||||
|
||||
function update_tab_width(width)
|
||||
{
|
||||
settings.tab_width = width;
|
||||
|
||||
if (tab_width_rule == null)
|
||||
{
|
||||
var sheet = document.getElementById('dynamic_styles').sheet;
|
||||
sheet.addRule('#diff td.code', 'tab-size: ' + width, 0);
|
||||
tab_width_rule = sheet.rules[0];
|
||||
}
|
||||
|
||||
tab_width_rule.style.tabSize = width;
|
||||
}
|
||||
|
||||
function update_diff(id, lsettings)
|
||||
{
|
||||
if (html_builder_worker)
|
||||
|
@ -365,6 +381,8 @@ function update_diff(id, lsettings)
|
|||
workeruri += '?t' + t;
|
||||
}
|
||||
|
||||
update_tab_width(settings.tab_width);
|
||||
|
||||
html_builder_worker = new Worker(workeruri);
|
||||
html_builder_tick = 0;
|
||||
|
||||
|
|
Loading…
Reference in a new issue