[gitg] Use tab-size css to control tab width
- From: Jesse van den Kieboom <jessevdk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gitg] Use tab-size css to control tab width
- Date: Thu, 10 Jul 2014 17:10:31 +0000 (UTC)
commit 89a3c8168eed26922c8b3c4ee29286eda41942b8
Author: Jesse van den Kieboom <jessevdk gnome org>
Date: Thu Jul 10 19:09:51 2014 +0200
Use tab-size css to control tab width
libgitg/resources/diff-view-html-builder.js | 17 +++++++----------
libgitg/resources/diff-view.html | 3 +++
libgitg/resources/diff-view.js | 18 ++++++++++++++++++
3 files changed, 28 insertions(+), 10 deletions(-)
---
diff --git a/libgitg/resources/diff-view-html-builder.js b/libgitg/resources/diff-view-html-builder.js
index 750820b..d6a06df 100644
--- a/libgitg/resources/diff-view-html-builder.js
+++ b/libgitg/resources/diff-view-html-builder.js
@@ -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,
diff --git a/libgitg/resources/diff-view.html b/libgitg/resources/diff-view.html
index d816d8a..cc0be60 100644
--- a/libgitg/resources/diff-view.html
+++ b/libgitg/resources/diff-view.html
@@ -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">
diff --git a/libgitg/resources/diff-view.js b/libgitg/resources/diff-view.js
index 865e4ac..ac90a0f 100644
--- a/libgitg/resources/diff-view.js
+++ b/libgitg/resources/diff-view.js
@@ -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;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]