Skip to content

Commit a2e8f29

Browse files
authored
Merge pull request #23 from egmontkob/terminal-color-improvements
Terminal color improvements
2 parents 8140b94 + dd8b13e commit a2e8f29

File tree

11 files changed

+508
-357
lines changed

11 files changed

+508
-357
lines changed

src/css/common.css

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,6 @@ table.terminal {
1111
border: 0;
1212
}
1313

14-
td.skin pre
15-
{
16-
color: #BABABA;
17-
background-color: #000000;
18-
}
19-
2014
td.left, td.right
2115
{
2216
width: 2px;
@@ -31,7 +25,7 @@ td.top, td.bottom
3125

3226
/* Editor UI */
3327

34-
button, select{
28+
button#btn-apply, select#skins{
3529
font-size: 20px;
3630
}
3731

src/img/alpha-stripes.png

168 Bytes
Loading

src/img/alpha-stripes.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/usr/bin/python3
2+
3+
from PIL import Image
4+
5+
N = 10
6+
7+
GRAY = 0xD0
8+
ALPHA = 0x38
9+
10+
img = Image.new('RGBA', (2 * N, 2 * N))
11+
12+
for y in range(2 * N):
13+
for x in range(2 * N):
14+
15+
if (x + y) % N == 0:
16+
# antialiased edge
17+
alpha = ALPHA // 2
18+
else:
19+
on = ((x + y) // N) % 2 # 0 or 1
20+
alpha = ALPHA * on # 0 or ALPHA
21+
22+
img.putpixel((x, y), (GRAY, GRAY, GRAY, alpha))
23+
24+
img.save('alpha-stripes.png', 'PNG')

src/index.html

Lines changed: 37 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@
1313
<script src="js/jquery-1.2.6.js" type="text/javascript"></script>
1414
<script src="js/ui.core.js?REV_SE-REV_MC" type="text/javascript"></script>
1515
<script src="js/ui.tabs.js?REV_SE-REV_MC" type="text/javascript"></script>
16-
<script src="js/mc-const.js?REV_SE-REV_MC" type="text/javascript"></script>
16+
<script src="js/mc-palette.js?REV_SE-REV_MC" type="text/javascript"></script>
1717
<script src="js/mc-css-generator.js?REV_SE-REV_MC" type="text/javascript"></script>
1818
<script src="js/mc-tpl.js?REV_SE-REV_MC" type="text/javascript"></script>
1919
<script src="js/mc-templates.js?REV_SE-REV_MC" type="text/javascript"></script>
2020
<script src="js/mc-utils.js?REV_SE-REV_MC" type="text/javascript"></script>
21-
<script src="js/cmp-colors.js?REV_SE-REV_MC" type="text/javascript"></script>
21+
<script src="js/mc-cmp-colors.js?REV_SE-REV_MC" type="text/javascript"></script>
2222

2323
<script type="text/javascript">
2424
$(function () {
@@ -67,16 +67,37 @@
6767

6868
$("select#skins").change();
6969

70-
7170
$(window).keydown(function (e) {
7271
// Ctrl-Enter pressed
7372
if (e.ctrlKey && e.keyCode === 13) {
7473
$('#btn-apply').click();
7574
}
7675
});
7776

78-
// Insert ColorsComponent
79-
$('.cmp-colors').html(new ColorsComponent().render());
77+
McPalette.basic_palettes.forEach(function(element, index) {
78+
$('#terminal-palettes').append($('<option />').val(index).text(element.name));
79+
});
80+
81+
$('#terminal-palettes').change(function() {
82+
$('#btn-apply').click();
83+
// Re-render the palette
84+
$('.cmp-colors').html(new McColorsComponent().render());
85+
});
86+
87+
$('#terminal-light').change(function() {
88+
$('#btn-apply').click();
89+
});
90+
91+
$('#terminal-bgimage').change(function() {
92+
$('#btn-apply').click();
93+
});
94+
95+
$('#terminal-boldbright').change(function() {
96+
$('#btn-apply').click();
97+
});
98+
99+
// Render the palette
100+
$('.cmp-colors').html(new McColorsComponent().render());
80101

81102
$.get('skins.json?REV_SE-REV_MC', {}, function (data) {
82103
$.each(data, function (key, value) {
@@ -123,7 +144,17 @@
123144
<div class="skin-view-container" id="fragment-skin-6"></div>
124145
</div>
125146
<div class="mt-2 ml-2" style="width: 810px">
126-
colors hint<br><br>
147+
Terminal's color settings
148+
<br><br>
149+
Palette:
150+
<select id="terminal-palettes"></select>
151+
&nbsp;&nbsp;
152+
<label><input type="checkbox" id="terminal-light">Light mode</label>
153+
&nbsp;&nbsp;
154+
<label><input type="checkbox" id="terminal-bgimage">Background image</label>
155+
&nbsp;&nbsp;
156+
<label><input type="checkbox" id="terminal-boldbright">First 8 colors bright when bold</label>
157+
<br><br>
127158
<div class="cmp-colors">
128159
<!-- colors will be displayed here -->
129160
</div>

src/js/cmp-colors.js

Lines changed: 0 additions & 21 deletions
This file was deleted.

src/js/mc-cmp-colors.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
class McColorsComponent
2+
{
3+
constructor(){
4+
this.template = `
5+
6+
`;
7+
this.onColorClick = function (colorKey, color) {
8+
9+
}
10+
}
11+
12+
render(){
13+
let result = '';
14+
for(let i = 0; i < 256; i++){
15+
if(i % 36 == 16)
16+
result += `<br>`;
17+
const key = 'color' + i;
18+
const name = McPalette.palette[i][0];
19+
const color = McPalette.palette[i][1];
20+
const onclickrgblabel = i < 16 ? "RGB in this palette" : "Standard RGB";
21+
const onclicktext = `Indexed name: ${key}\\nFriendly name: ${name}\\n${onclickrgblabel}: ${color}`;
22+
const tooltiptext = `${key}${name}${color}`;
23+
result += `<div onclick="alert('${onclicktext}')" title="${tooltiptext}" style="background-color: ${color}; display: inline-block; cursor: pointer; width: 18px; height: 18px; margin-right: 4px"></div>`;
24+
}
25+
return result;
26+
}
27+
}

0 commit comments

Comments
 (0)