Skip to content

Commit 4a65ae2

Browse files
author
t3tra-dev
committed
format
1 parent 40aad02 commit 4a65ae2

26 files changed

Lines changed: 153 additions & 140 deletions

.vscode/settings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
22
"makefile.configureOnOpen": true
3-
}
3+
}

gui/index.html

Lines changed: 47 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,55 @@
11
<!DOCTYPE html>
22
<html lang="en">
3-
<head>
4-
<meta charset="utf-8" />
5-
<title>WebVM - POSIX-compatible WebAssembly OS</title>
6-
<link rel="stylesheet" href="gui/styles.css">
7-
</head>
8-
<body>
9-
<div id="desktop">
10-
<!-- ターミナルウィンドウ -->
11-
<div class="window" id="terminal-window" style="top: 50px; left: 50px; width: 800px; height: 600px;">
12-
<div class="window-header">
13-
<div class="window-title">Terminal - WebVM</div>
14-
<div class="window-controls">
15-
<div class="window-control minimize"></div>
16-
<div class="window-control maximize"></div>
17-
<div class="window-control close"></div>
3+
<head>
4+
<meta charset="utf-8" />
5+
<title>WebVM - POSIX-compatible WebAssembly OS</title>
6+
<link rel="stylesheet" href="gui/styles.css" />
7+
</head>
8+
<body>
9+
<div id="desktop">
10+
<!-- ターミナルウィンドウ -->
11+
<div
12+
class="window"
13+
id="terminal-window"
14+
style="top: 50px; left: 50px; width: 800px; height: 600px"
15+
>
16+
<div class="window-header">
17+
<div class="window-title">Terminal - WebVM</div>
18+
<div class="window-controls">
19+
<div class="window-control minimize"></div>
20+
<div class="window-control maximize"></div>
21+
<div class="window-control close"></div>
22+
</div>
1823
</div>
19-
</div>
20-
<div class="window-content">
21-
<div class="terminal" id="terminal">
22-
<div id="terminal-output" class="terminal-output"></div>
23-
<div class="terminal-input-line">
24-
<span class="terminal-prompt">$ </span>
25-
<input type="text" id="terminal-input" class="terminal-input" autofocus />
26-
<span class="terminal-cursor"></span>
24+
<div class="window-content">
25+
<div class="terminal" id="terminal">
26+
<div id="terminal-output" class="terminal-output"></div>
27+
<div class="terminal-input-line">
28+
<span class="terminal-prompt">$ </span>
29+
<input
30+
type="text"
31+
id="terminal-input"
32+
class="terminal-input"
33+
autofocus
34+
/>
35+
<span class="terminal-cursor"></span>
36+
</div>
2737
</div>
2838
</div>
2939
</div>
3040
</div>
31-
</div>
3241

33-
<script type="module">
34-
import { boot } from "./syslib/index.js";
35-
import { initializeTerminal } from "./gui/terminal.js";
36-
import { initializeWindowManager } from "./gui/window-manager.js";
37-
38-
// 初期化
39-
initializeTerminal();
40-
initializeWindowManager();
41-
42-
// カーネルを起動
43-
boot();
44-
</script>
45-
</body>
46-
</html>
42+
<script type="module">
43+
import { boot } from "./syslib/index.js";
44+
import { initializeTerminal } from "./gui/terminal.js";
45+
import { initializeWindowManager } from "./gui/window-manager.js";
46+
47+
// 初期化
48+
initializeTerminal();
49+
initializeWindowManager();
50+
51+
// カーネルを起動
52+
boot();
53+
</script>
54+
</body>
55+
</html>

gui/styles.css

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ body {
77
margin: 0;
88
padding: 0;
99
background-color: #1e1e1e;
10-
font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
10+
font-family: "Consolas", "Monaco", "Courier New", monospace;
1111
color: #d4d4d4;
1212
overflow: hidden;
1313
}
@@ -61,16 +61,16 @@ body {
6161
opacity: 0.8;
6262
}
6363

64-
.close {
65-
background-color: #f44336;
64+
.close {
65+
background-color: #f44336;
6666
}
6767

68-
.minimize {
69-
background-color: #ffeb3b;
68+
.minimize {
69+
background-color: #ffeb3b;
7070
}
7171

72-
.maximize {
73-
background-color: #4caf50;
72+
.maximize {
73+
background-color: #4caf50;
7474
}
7575

7676
.window-content {
@@ -84,7 +84,7 @@ body {
8484
background-color: #1e1e1e;
8585
color: #d4d4d4;
8686
padding: 10px;
87-
font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
87+
font-family: "Consolas", "Monaco", "Courier New", monospace;
8888
font-size: 14px;
8989
line-height: 1.4;
9090
height: 100%;
@@ -126,8 +126,14 @@ body {
126126
}
127127

128128
@keyframes blink {
129-
0%, 50% { opacity: 1; }
130-
51%, 100% { opacity: 0; }
129+
0%,
130+
50% {
131+
opacity: 1;
132+
}
133+
51%,
134+
100% {
135+
opacity: 0;
136+
}
131137
}
132138

133139
/* レスポンシブ対応 */
@@ -137,4 +143,4 @@ body {
137143
left: 10px !important;
138144
right: 10px !important;
139145
}
140-
}
146+
}

gui/terminal.js

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,27 @@
33
*/
44

55
// ターミナル要素
6-
const terminalOutput = document.getElementById('terminal-output');
7-
const terminalInput = document.getElementById('terminal-input');
6+
const terminalOutput = document.getElementById("terminal-output");
7+
const terminalInput = document.getElementById("terminal-input");
88

99
/**
1010
* ターミナルAPIを初期化
1111
*/
1212
export function initializeTerminal() {
1313
// ターミナル出力関数
14-
window.terminalWrite = function(text) {
14+
window.terminalWrite = function (text) {
1515
terminalOutput.textContent += text;
1616
terminalOutput.scrollTop = terminalOutput.scrollHeight;
1717
};
18-
19-
window.terminalWriteLine = function(text) {
20-
window.terminalWrite(text + '\n');
18+
19+
window.terminalWriteLine = function (text) {
20+
window.terminalWrite(text + "\n");
2121
};
22-
23-
window.terminalClear = function() {
24-
terminalOutput.textContent = '';
22+
23+
window.terminalClear = function () {
24+
terminalOutput.textContent = "";
2525
};
26-
26+
2727
// 入力ハンドラを設定
2828
setupInputHandler();
2929
}
@@ -32,25 +32,25 @@ export function initializeTerminal() {
3232
* 入力ハンドラを設定
3333
*/
3434
function setupInputHandler() {
35-
terminalInput.addEventListener('keydown', (e) => {
36-
if (e.key === 'Enter') {
35+
terminalInput.addEventListener("keydown", (e) => {
36+
if (e.key === "Enter") {
3737
const command = terminalInput.value;
38-
window.terminalWriteLine('$ ' + command);
39-
38+
window.terminalWriteLine("$ " + command);
39+
4040
// カーネルにコマンドを送信
4141
if (window.handleCommand) {
4242
window.handleCommand(command);
4343
}
44-
45-
terminalInput.value = '';
44+
45+
terminalInput.value = "";
4646
}
4747
});
48-
48+
4949
// 自動フォーカス
5050
terminalInput.focus();
51-
51+
5252
// クリック時にフォーカス
53-
document.getElementById('terminal').addEventListener('click', () => {
53+
document.getElementById("terminal").addEventListener("click", () => {
5454
terminalInput.focus();
5555
});
56-
}
56+
}

gui/window-manager.js

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ let windowY = 0;
1616
export function initializeWindowManager() {
1717
// ウィンドウドラッグ機能
1818
setupWindowDragging();
19-
19+
2020
// ウィンドウコントロール
2121
setupWindowControls();
2222
}
@@ -25,36 +25,36 @@ export function initializeWindowManager() {
2525
* ウィンドウドラッグ機能を設定
2626
*/
2727
function setupWindowDragging() {
28-
document.querySelectorAll('.window-header').forEach(header => {
29-
header.addEventListener('mousedown', (e) => {
30-
if (e.target.classList.contains('window-control')) return;
31-
28+
document.querySelectorAll(".window-header").forEach((header) => {
29+
header.addEventListener("mousedown", (e) => {
30+
if (e.target.classList.contains("window-control")) return;
31+
3232
isDragging = true;
3333
currentWindow = header.parentElement;
3434
startX = e.clientX;
3535
startY = e.clientY;
3636
const rect = currentWindow.getBoundingClientRect();
3737
windowX = rect.left;
3838
windowY = rect.top;
39-
39+
4040
// 最前面に移動
4141
bringToFront(currentWindow);
42-
42+
4343
e.preventDefault();
4444
});
4545
});
46-
47-
document.addEventListener('mousemove', (e) => {
46+
47+
document.addEventListener("mousemove", (e) => {
4848
if (!isDragging) return;
49-
49+
5050
const deltaX = e.clientX - startX;
5151
const deltaY = e.clientY - startY;
52-
53-
currentWindow.style.left = (windowX + deltaX) + 'px';
54-
currentWindow.style.top = (windowY + deltaY) + 'px';
52+
53+
currentWindow.style.left = windowX + deltaX + "px";
54+
currentWindow.style.top = windowY + deltaY + "px";
5555
});
56-
57-
document.addEventListener('mouseup', () => {
56+
57+
document.addEventListener("mouseup", () => {
5858
isDragging = false;
5959
currentWindow = null;
6060
});
@@ -65,24 +65,24 @@ function setupWindowDragging() {
6565
*/
6666
function setupWindowControls() {
6767
// 閉じるボタン
68-
document.querySelectorAll('.close').forEach(btn => {
69-
btn.addEventListener('click', () => {
70-
btn.closest('.window').style.display = 'none';
68+
document.querySelectorAll(".close").forEach((btn) => {
69+
btn.addEventListener("click", () => {
70+
btn.closest(".window").style.display = "none";
7171
});
7272
});
73-
73+
7474
// 最小化ボタン
75-
document.querySelectorAll('.minimize').forEach(btn => {
76-
btn.addEventListener('click', () => {
75+
document.querySelectorAll(".minimize").forEach((btn) => {
76+
btn.addEventListener("click", () => {
7777
// TODO: 最小化実装
78-
console.log('Minimize not implemented yet');
78+
console.log("Minimize not implemented yet");
7979
});
8080
});
81-
81+
8282
// 最大化ボタン
83-
document.querySelectorAll('.maximize').forEach(btn => {
84-
btn.addEventListener('click', () => {
85-
const window = btn.closest('.window');
83+
document.querySelectorAll(".maximize").forEach((btn) => {
84+
btn.addEventListener("click", () => {
85+
const window = btn.closest(".window");
8686
toggleMaximize(window);
8787
});
8888
});
@@ -92,40 +92,40 @@ function setupWindowControls() {
9292
* ウィンドウを最前面に移動
9393
*/
9494
function bringToFront(window) {
95-
const windows = document.querySelectorAll('.window');
95+
const windows = document.querySelectorAll(".window");
9696
let maxZ = 0;
97-
98-
windows.forEach(w => {
99-
const z = parseInt(w.style.zIndex || '0');
97+
98+
windows.forEach((w) => {
99+
const z = parseInt(w.style.zIndex || "0");
100100
if (z > maxZ) maxZ = z;
101101
});
102-
102+
103103
window.style.zIndex = maxZ + 1;
104104
}
105105

106106
/**
107107
* ウィンドウの最大化をトグル
108108
*/
109109
function toggleMaximize(window) {
110-
if (window.dataset.maximized === 'true') {
110+
if (window.dataset.maximized === "true") {
111111
// 元のサイズに戻す
112112
window.style.width = window.dataset.originalWidth;
113113
window.style.height = window.dataset.originalHeight;
114114
window.style.left = window.dataset.originalLeft;
115115
window.style.top = window.dataset.originalTop;
116-
window.dataset.maximized = 'false';
116+
window.dataset.maximized = "false";
117117
} else {
118118
// 現在のサイズを保存
119119
window.dataset.originalWidth = window.style.width;
120120
window.dataset.originalHeight = window.style.height;
121121
window.dataset.originalLeft = window.style.left;
122122
window.dataset.originalTop = window.style.top;
123-
123+
124124
// 最大化
125-
window.style.width = '100vw';
126-
window.style.height = '100vh';
127-
window.style.left = '0';
128-
window.style.top = '0';
129-
window.dataset.maximized = 'true';
125+
window.style.width = "100vw";
126+
window.style.height = "100vh";
127+
window.style.left = "0";
128+
window.style.top = "0";
129+
window.dataset.maximized = "true";
130130
}
131-
}
131+
}

kernel/drivers/console.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,4 +138,4 @@ void console_set_color(int fg, int bg) {
138138
void console_reset_attr(void) {
139139
const char *reset_seq = "\033[0m";
140140
wasi_write(STDOUT_FILENO, reset_seq, 4);
141-
}
141+
}

0 commit comments

Comments
 (0)