Ver3.5 ๐ ๏ธ ๋๋ง์ ๋ฏธ๋ IDE/์๋ํฐ ๊ธฐ๋ฅ ๊ตฌํํ๊ธฐ์์ค์ฝ๋๋ก ๋ฐฐ์ฐ๋ ํ ์คํธ ์๋ํฐ์ ๋ชจ๋ ๊ฒ

๐ ๏ธ ๋๋ง์ ๋ฏธ๋ IDE/์๋ํฐ ๊ธฐ๋ฅ ๊ตฌํํ๊ธฐ
์์ค์ฝ๋๋ก ๋ฐฐ์ฐ๋ ํ
์คํธ ์๋ํฐ์ ๋ชจ๋ ๊ฒ
IDE(ํตํฉ ๊ฐ๋ฐ ํ๊ฒฝ)๋ ์ฝ๋ ์๋ํฐ๋ ๊ฐ๋ฐ์๋ค์ด ๋งค์ผ ์ฐ๋ ํต์ฌ ๋๊ตฌ์ธ๋ฐ, ๋ง์ "์ด๊ฑฐ ์ด๋ป๊ฒ ๋ง๋ค์ด?" ํ๋ฉด ๋ง๋งํ๊ฒ ๋๊ปด์ง๋ ๊ฒฝ์ฐ๊ฐ ๋ง์ฃ . ๊ทผ๋ฐ ์ฌ์ค ํต์ฌ ๊ธฐ๋ฅ๋ค์ ๋ถํดํด์ ๋ณด๋ฉด ํ๋ํ๋๋ ๊ทธ๋ ๊ฒ ๋ณต์กํ์ง ์์์! ์ค๋์ ๊ฐ๋จํ IDE/์๋ํฐ์ ์ฃผ์ ๊ธฐ๋ฅ๋ค์ ์ค์ ์์ค์ฝ๋์ ํจ๊ป ๋ฏ์ด๋ณผ ๊ฑฐ์์. ๐ฏ
๐ 1. ๊ธฐ๋ณธ ์๋ํฐ ๊ตฌ์กฐ ์ก๊ธฐ
์ผ๋จ ์๋ํฐ์ ๋ผ๋๋ถํฐ ๋ง๋ค์ด์ผ์ฃ ! HTML + CSS + JavaScript๋ก ๊ธฐ๋ณธ ๊ตฌ์กฐ๋ฅผ ์ก๋ ๊ฒ ์ฒซ ๋ฒ์งธ ์คํ
์ด์์. contenteditable ์์ฑ์ด๋ textarea๋ฅผ ํ์ฉํ๋ ๋ฐฉ๋ฒ์ด ์๋๋ฐ, ๊ฐ๊ฐ ์ฅ๋จ์ ์ด ์์ด์.
textarea๋ก ์์ํ๊ณ , ์ ํ์ค ํ์ด๋ผ์ดํ
์ด ํ์ํ๋ฉด contenteditable div๋ก ์
๊ทธ๋ ์ด๋ํ๋ ๊ฒ ๊ตญ๋ฃฐ์ ใ
ใ
1HTML ๊ธฐ๋ณธ ๊ตฌ์กฐ
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<title>๋ฏธ๋ ์ฝ๋ ์๋ํฐ</title>
<style>
* { box-sizing: border-box; margin: 0; padding: 0; }
body { background: #1e1e1e; color: #d4d4d4; font-family: 'Consolas', monospace; }
.editor-container {
display: flex;
height: 100vh;
overflow: hidden;
}
/* ์ฌ์ด๋๋ฐ (ํ์ผ ํธ๋ฆฌ) */
.sidebar {
width: 220px;
background: #252526;
border-right: 1px solid #3c3c3c;
padding: 10px;
overflow-y: auto;
}
/* ๋ฉ์ธ ์๋ํฐ ์์ญ */
.editor-main {
flex: 1;
display: flex;
flex-direction: column;
}
/* ํญ ๋ฐ */
.tab-bar {
background: #2d2d2d;
display: flex;
border-bottom: 1px solid #3c3c3c;
min-height: 35px;
}
.tab {
padding: 8px 20px;
cursor: pointer;
border-right: 1px solid #3c3c3c;
font-size: 13px;
display: flex;
align-items: center;
gap: 8px;
}
.tab.active {
background: #1e1e1e;
border-top: 2px solid #007acc;
}
/* ์๋ํฐ ๋ณธ์ฒด */
.editor-body {
flex: 1;
display: flex;
overflow: hidden;
}
/* ์ค ๋ฒํธ */
.line-numbers {
width: 50px;
background: #1e1e1e;
color: #858585;
text-align: right;
padding: 10px 8px;
font-size: 14px;
line-height: 1.6;
user-select: none;
overflow: hidden;
}
/* ์ฝ๋ ์
๋ ฅ ์์ญ */
.code-area {
flex: 1;
background: #1e1e1e;
color: #d4d4d4;
border: none;
outline: none;
padding: 10px;
font-size: 14px;
line-height: 1.6;
font-family: 'Consolas', monospace;
resize: none;
overflow: auto;
tab-size: 2;
}
/* ์ํ๋ฐ */
.status-bar {
background: #007acc;
color: #fff;
padding: 3px 15px;
font-size: 12px;
display: flex;
gap: 20px;
}
</style>
</head>
<body>
<div class="editor-container">
<div class="sidebar" id="sidebar">
<div style="color:#ccc;font-size:12px;margin-bottom:8px;">๐ ํ์๊ธฐ</div>
<!-- ํ์ผ ํธ๋ฆฌ๊ฐ ์ฌ๊ธฐ์ ๋์ ์ผ๋ก ์์ฑ๋จ -->
</div>
<div class="editor-main">
<div class="tab-bar" id="tabBar"></div>
<div class="editor-body">
<div class="line-numbers" id="lineNumbers">1</div>
<textarea class="code-area" id="codeArea"
spellcheck="false"
autocomplete="off"
autocorrect="off"
autocapitalize="off"></textarea>
</div>
<div class="status-bar">
<span id="cursorPos">์ค 1, ์ด 1</span>
<span id="langMode">JavaScript</span>
<span>UTF-8</span>
</div>
</div>
</div>
</body>
</html>
spellcheck="false", autocomplete="off" ์ด๋ฐ ์์ฑ๋ค ๊ผญ ๋ฃ์ด์ค์ผ ํด์. ์ ๋ฃ์ผ๋ฉด ์ฝ๋ ์์ฑํ ๋ ์๊พธ ๋นจ๊ฐ ์ค ๋จ๊ณ ์๋์์ ๋๋ ๋ถ์์ฌ๊ฐ... ๐
๐ข 2. ์ค ๋ฒํธ(Line Numbers) ๊ตฌํ
์ค ๋ฒํธ๋ ์๋ํฐ์ ๊ธฐ๋ณธ ์ค์ ๊ธฐ๋ณธ! ๊ทผ๋ฐ ์๊ฐ๋ณด๋ค ์ ๊ฒฝ ์จ์ผ ํ ๊ฒ ์์ด์. ์คํฌ๋กค ๋๊ธฐํ, ์ค ์ ์ ๋ฐ์ดํธ ๋ฑ๋ฑ... ๊ฐ์ด ๊ตฌํํด๋ด์ ใ ใ
// ์ค ๋ฒํธ ์
๋ฐ์ดํธ ํจ์
function updateLineNumbers() {
const codeArea = document.getElementById('codeArea');
const lineNumbers = document.getElementById('lineNumbers');
// ํ์ฌ ์ฝ๋์ ์ค ์ ๊ณ์ฐ
const lines = codeArea.value.split('\n');
const lineCount = lines.length;
// ์ค ๋ฒํธ HTML ์์ฑ
let numbersHTML = '';
for (let i = 1; i <= lineCount; i++) {
numbersHTML += `<div class="line-num">${i}</div>`;
}
lineNumbers.innerHTML = numbersHTML;
}
// ์คํฌ๋กค ๋๊ธฐํ (ํต์ฌ!)
function syncScroll() {
const codeArea = document.getElementById('codeArea');
const lineNumbers = document.getElementById('lineNumbers');
codeArea.addEventListener('scroll', () => {
// ์ค ๋ฒํธ ์์ญ์ ์คํฌ๋กค์ ์ฝ๋ ์์ญ๊ณผ ๋๊ธฐํ
lineNumbers.scrollTop = codeArea.scrollTop;
});
}
// ์ปค์ ์์น ํ์
function updateCursorPosition() {
const codeArea = document.getElementById('codeArea');
const cursorPos = document.getElementById('cursorPos');
codeArea.addEventListener('keyup', () => {
const text = codeArea.value;
const selStart = codeArea.selectionStart;
// ํ์ฌ ์ปค์๊น์ง์ ํ
์คํธ์์ ์ค/์ด ๊ณ์ฐ
const textBeforeCursor = text.substring(0, selStart);
const lines = textBeforeCursor.split('\n');
const currentLine = lines.length;
const currentCol = lines[lines.length - 1].length + 1;
cursorPos.textContent = `์ค ${currentLine}, ์ด ${currentCol}`;
});
}
// ์ด๋ฒคํธ ์ฐ๊ฒฐ
document.addEventListener('DOMContentLoaded', () => {
const codeArea = document.getElementById('codeArea');
// ์
๋ ฅํ ๋๋ง๋ค ์ค ๋ฒํธ ์
๋ฐ์ดํธ
codeArea.addEventListener('input', updateLineNumbers);
codeArea.addEventListener('keyup', updateLineNumbers);
syncScroll();
updateCursorPosition();
updateLineNumbers(); // ์ด๊ธฐ ์คํ
});
๐จ 3. ์ ํ์ค ํ์ด๋ผ์ดํ ๊ตฌํ
์ด๊ฒ ์๋ํฐ์ ๊ฝ์ด์ฃ ! ๐ธ ์ ํ์ค ํ์ด๋ผ์ดํ
์ ์ ๊ท์(RegEx)์ ํ์ฉํด์ ํค์๋, ๋ฌธ์์ด, ์ฃผ์ ๋ฑ์ ์๊น๋ก ๊ตฌ๋ถํด์ฃผ๋ ๊ธฐ๋ฅ์ด์์. textarea๋ง์ผ๋ก๋ ๊ตฌํ์ด ์ด๋ ต๊ณ , ์ค๋ฒ๋ ์ด ๋ฐฉ์์ด๋ contenteditable ๋ฐฉ์์ ์จ์ผ ํด์.
1์ค๋ฒ๋ ์ด(Overlay) ๋ฐฉ์ - ๊ฐ์ฅ ๋ง์ด ์ฐ๋ ๋ฐฉ๋ฒ
// JavaScript ์ ํ์ค ํ์ด๋ผ์ดํ
ํ ํฌ๋์ด์
const JS_TOKENS = [
// ์ฃผ์ (๋จผ์ ์ฒ๋ฆฌํด์ผ ํจ!)
{ type: 'comment', regex: /\/\/[^\n]*/g, color: '#6a9955' },
{ type: 'comment-block', regex: /\/\*[\s\S]*?\*\//g, color: '#6a9955' },
// ๋ฌธ์์ด
{ type: 'string', regex: /(["'`])(?:(?!\1)[^\\]|\\.)*\1/g, color: '#ce9178' },
// ํค์๋
{
type: 'keyword',
regex: /\b(const|let|var|function|return|if|else|for|while|class|import|export|from|async|await|new|this|typeof|instanceof|null|undefined|true|false)\b/g,
color: '#569cd6'
},
// ์ซ์
{ type: 'number', regex: /\b\d+(\.\d+)?\b/g, color: '#b5cea8' },
// ํจ์๋ช
{ type: 'function', regex: /\b([a-zA-Z_$][a-zA-Z0-9_$]*)\s*(?=\()/g, color: '#dcdcaa' },
// ๋ด์ฅ ๊ฐ์ฒด
{
type: 'builtin',
regex: /\b(console|document|window|Array|Object|String|Number|Math|JSON|Promise|setTimeout|setInterval)\b/g,
color: '#4ec9b0'
}
];
// ํ์ด๋ผ์ดํ
์ ์ฉ ํจ์
function applyHighlighting(code) {
// HTML ํน์๋ฌธ์ ์ด์ค์ผ์ดํ (XSS ๋ฐฉ์ง!)
let escaped = code
.replace(/&/g, '&')
.replace(/</g, '<')
.replace(/>/g, '>');
// ํ ํฐ ์์น ์์ง
const tokens = [];
JS_TOKENS.forEach(tokenDef => {
let match;
const regex = new RegExp(tokenDef.regex.source, 'g');
while ((match = regex.exec(escaped)) !== null) {
tokens.push({
start: match.index,
end: match.index + match[0].length,
text: match[0],
color: tokenDef.color,
type: tokenDef.type
});
}
});
// ๊ฒน์น๋ ํ ํฐ ์ ๊ฑฐ (๋จผ์ ๋ฐ๊ฒฌ๋ ๊ฒ ์ฐ์ )
tokens.sort((a, b) => a.start - b.start);
const filtered = [];
let lastEnd = 0;
tokens.forEach(token => {
if (token.start >= lastEnd) {
filtered.push(token);
lastEnd = token.end;
}
});
// HTML ์์ฑ
let result = '';
let pos = 0;
filtered.forEach(token => {
// ํ ํฐ ์ด์ ์ผ๋ฐ ํ
์คํธ
result += escaped.substring(pos, token.start);
// ์์ ์ ์ฉ๋ ํ ํฐ
result += `<span style="color:${token.color}">${token.text}</span>`;
pos = token.end;
});
result += escaped.substring(pos);
return result;
}
// ์ค๋ฒ๋ ์ด ์๋ํฐ ์ค์
function setupOverlayEditor() {
const textarea = document.getElementById('codeArea');
const highlight = document.getElementById('highlightLayer');
textarea.addEventListener('input', () => {
// ํ์ด๋ผ์ดํ
๋ ์ด์ด ์
๋ฐ์ดํธ
highlight.innerHTML = applyHighlighting(textarea.value) + '\n';
updateLineNumbers();
});
// ์คํฌ๋กค ๋๊ธฐํ
textarea.addEventListener('scroll', () => {
highlight.scrollTop = textarea.scrollTop;
highlight.scrollLeft = textarea.scrollLeft;
});
}
โก 4. ์๋์์ฑ(AutoComplete) ๊ตฌํ
์๋์์ฑ์ ๊ฐ๋ฐ ์์ฐ์ฑ์ ์์ฒญ๋๊ฒ ์ฌ๋ ค์ฃผ๋ ๊ธฐ๋ฅ์ด์์! ๊ธฐ๋ณธ์ ์ธ ์๋ฆฌ๋ ํ์ฌ ์ ๋ ฅ ์ค์ธ ๋จ์ด๋ฅผ ๊ฐ์งํ๊ณ , ๋ฏธ๋ฆฌ ์ ์๋ ๋จ์ด ๋ชฉ๋ก์์ ๋งค์นญ๋๋ ๊ฒ๋ค์ ๋๋กญ๋ค์ด์ผ๋ก ๋ณด์ฌ์ฃผ๋ ๊ฑฐ์์.
// ์๋์์ฑ ์์คํ
๊ตฌํ
class AutoComplete {
constructor(editor) {
this.editor = editor;
this.dropdown = null;
this.selectedIndex = -1;
// ์๋์์ฑ ๋จ์ด ๋ชฉ๋ก (์ค์ ๋ก๋ ์ธ์ด๋ณ๋ก ๋ ๋ฐฉ๋ํจ)
this.keywords = [
'const', 'let', 'var', 'function', 'return', 'if', 'else',
'for', 'while', 'class', 'import', 'export', 'async', 'await',
'console', 'document', 'window', 'Array', 'Object', 'String',
'Promise', 'setTimeout', 'addEventListener', 'querySelector',
'getElementById', 'innerHTML', 'textContent', 'appendChild'
];
this.init();
}
init() {
// ๋๋กญ๋ค์ด ์๋ฆฌ๋จผํธ ์์ฑ
this.dropdown = document.createElement('div');
this.dropdown.className = 'autocomplete-dropdown';
this.dropdown.style.cssText = `
position: absolute;
background: #252526;
border: 1px solid #454545;
border-radius: 4px;
max-height: 200px;
overflow-y: auto;
z-index: 1000;
display: none;
min-width: 180px;
box-shadow: 0 4px 12px rgba(0,0,0,0.4);
`;
document.body.appendChild(this.dropdown);
// ์ด๋ฒคํธ ๋ฆฌ์ค๋ ๋ฑ๋ก
this.editor.addEventListener('input', (e) => this.handleInput(e));
this.editor.addEventListener('keydown', (e) => this.handleKeydown(e));
document.addEventListener('click', () => this.hide());
}
// ํ์ฌ ์ปค์ ์์น์ ๋จ์ด ์ถ์ถ
getCurrentWord() {
const text = this.editor.value;
const pos = this.editor.selectionStart;
const textBefore = text.substring(0, pos);
// ๋ง์ง๋ง ๋จ์ด ์ถ์ถ (์๋ฌธ์, ์ซ์, _ ๋ง ํฌํจ)
const match = textBefore.match(/[a-zA-Z_$][a-zA-Z0-9_$]*$/);
return match ? match[0] : '';
}
// ๋งค์นญ ๋จ์ด ๊ฒ์
getMatches(word) {
if (word.length < 2) return []; // 2๊ธ์ ์ด์๋ถํฐ ๊ฒ์
const lower = word.toLowerCase();
return this.keywords
.filter(kw => kw.toLowerCase().startsWith(lower) && kw !== word)
.slice(0, 10); // ์ต๋ 10๊ฐ
}
// ์
๋ ฅ ์ฒ๋ฆฌ
handleInput() {
const word = this.getCurrentWord();
const matches = this.getMatches(word);
if (matches.length > 0) {
this.show(matches, word);
} else {
this.hide();
}
}
// ๋๋กญ๋ค์ด ํ์
show(matches, currentWord) {
this.selectedIndex = -1;
this.dropdown.innerHTML = '';
matches.forEach((match, index) => {
const item = document.createElement('div');
item.style.cssText = `
padding: 6px 12px;
cursor: pointer;
font-family: Consolas, monospace;
font-size: 13px;
color: #d4d4d4;
display: flex;
align-items: center;
gap: 8px;
`;
// ๋งค์นญ ๋ถ๋ถ ๋ณผ๋ ์ฒ๋ฆฌ
const boldPart = match.substring(0, currentWord.length);
const restPart = match.substring(currentWord.length);
item.innerHTML = `
<span style="color:#007acc;font-size:11px;">โก</span>
<span><strong style="color:#fff">${boldPart}</strong>${restPart}</span>
`;
item.addEventListener('mouseenter', () => {
this.setSelected(index);
});
item.addEventListener('click', () => {
this.applyCompletion(match, currentWord);
});
this.dropdown.appendChild(item);
});
// ์ปค์ ์์น์ ๋๋กญ๋ค์ด ํ์
const coords = this.getCursorCoords();
this.dropdown.style.left = coords.x + 'px';
this.dropdown.style.top = (coords.y + 20) + 'px';
this.dropdown.style.display = 'block';
}
// ํค๋ณด๋ ๋ค๋น๊ฒ์ด์
handleKeydown(e) {
if (this.dropdown.style.display === 'none') return;
const items = this.dropdown.querySelectorAll('div');
if (e.key === 'ArrowDown') {
e.preventDefault();
this.setSelected(Math.min(this.selectedIndex + 1, items.length - 1));
} else if (e.key === 'ArrowUp') {
e.preventDefault();
this.setSelected(Math.max(this.selectedIndex - 1, 0));
} else if (e.key === 'Enter' || e.key === 'Tab') {
if (this.selectedIndex >= 0) {
e.preventDefault();
const selectedText = items[this.selectedIndex]
.querySelector('span:last-child').textContent;
this.applyCompletion(selectedText, this.getCurrentWord());
}
} else if (e.key === 'Escape') {
this.hide();
}
}
// ์ ํ ํญ๋ชฉ ๋ณ๊ฒฝ
setSelected(index) {
const items = this.dropdown.querySelectorAll('div');
items.forEach((item, i) => {
item.style.background = i === index ? '#094771' : 'transparent';
});
this.selectedIndex = index;
}
// ์๋์์ฑ ์ ์ฉ
applyCompletion(completion, currentWord) {
const pos = this.editor.selectionStart;
const text = this.editor.value;
const start = pos - currentWord.length;
// ํ์ฌ ๋จ์ด๋ฅผ ์์ฑ๋ ๋จ์ด๋ก ๊ต์ฒด
this.editor.value =
text.substring(0, start) + completion + text.substring(pos);
// ์ปค์๋ฅผ ์์ฑ๋ ๋จ์ด ๋์ผ๋ก ์ด๋
const newPos = start + completion.length;
this.editor.setSelectionRange(newPos, newPos);
this.editor.focus();
this.hide();
}
hide() {
this.dropdown.style.display = 'none';
this.selectedIndex = -1;
}
// ์ปค์ ์ขํ ๊ณ์ฐ (๊ฐ๋ตํ ๋ฒ์ )
getCursorCoords() {
const rect = this.editor.getBoundingClientRect();
return {
x: rect.left + 80,
y: rect.top + 100
};
}
}
// ์ฌ์ฉ
const editor = document.getElementById('codeArea');
const ac = new AutoComplete(editor);
๐ 5. ๊ฒ์ & ์นํ(Find & Replace) ๊ตฌํ
Ctrl+F ํ๋ฉด ๋จ๋ ๊ทธ ๊ธฐ๋ฅ! ์๋ํฐ์์ ์์ผ๋ฉด ์ง์ง ๋ถํธํ ๊ธฐ๋ฅ ์ค ํ๋์ฃ . ์ ๊ท์ ๊ฒ์๊น์ง ์ง์ํ๋ฉด ์์ ํ๋ก ์๋ํฐ ๋๋ ๋์ ใ ใ ใ
// ๊ฒ์ & ์นํ ๋ชจ๋
class FindReplace {
constructor(editor) {
this.editor = editor;
this.matches = [];
this.currentMatch = -1;
this.createUI();
this.bindShortcuts();
}
createUI() {
const panel = document.createElement('div');
panel.id = 'findPanel';
panel.style.cssText = `
position: fixed;
top: 50px;
right: 20px;
background: #252526;
border: 1px solid #454545;
border-radius: 8px;
padding: 12px;
z-index: 2000;
display: none;
min-width: 320px;
box-shadow: 0 8px 24px rgba(0,0,0,0.5);
`;
panel.innerHTML = `
<div style="display:flex;gap:8px;margin-bottom:8px;align-items:center;">
<input id="findInput" placeholder="๊ฒ์..." style="
flex:1; background:#3c3c3c; border:1px solid #555;
color:#d4d4d4; padding:5px 10px; border-radius:4px;
font-size:13px; outline:none;
">
<button id="findPrev" style="background:#3c3c3c;color:#ccc;border:1px solid #555;
border-radius:4px;padding:5px 10px;cursor:pointer;">โ</button>
<button id="findNext" style="background:#3c3c3c;color:#ccc;border:1px solid #555;
border-radius:4px;padding:5px 10px;cursor:pointer;">โ</button>
<span id="matchCount" style="color:#858585;font-size:12px;min-width:60px;"></span>
<button id="closeFind" style="background:transparent;color:#ccc;border:none;
cursor:pointer;font-size:16px;">โ</button>
</div>
<div style="display:flex;gap:8px;align-items:center;">
<input id="replaceInput" placeholder="์นํ..." style="
flex:1; background:#3c3c3c; border:1px solid #555;
color:#d4d4d4; padding:5px 10px; border-radius:4px;
font-size:13px; outline:none;
">
<button id="replaceOne" style="background:#007acc;color:#fff;border:none;
border-radius:4px;padding:5px 12px;cursor:pointer;font-size:12px;">์นํ</button>
<button id="replaceAll" style="background:#007acc;color:#fff;border:none;
border-radius:4px;padding:5px 12px;cursor:pointer;font-size:12px;">๋ชจ๋ ์นํ</button>
</div>
<div style="margin-top:8px;display:flex;gap:12px;">
<label style="color:#ccc;font-size:12px;cursor:pointer;">
<input type="checkbox" id="caseSensitive"> ๋์๋ฌธ์ ๊ตฌ๋ถ
</label>
<label style="color:#ccc;font-size:12px;cursor:pointer;">
<input type="checkbox" id="useRegex"> ์ ๊ท์
</label>
</div>
`;
document.body.appendChild(panel);
this.panel = panel;
this.bindEvents();
}
bindEvents() {
document.getElementById('findInput').addEventListener('input', () => this.search());
document.getElementById('findNext').addEventListener('click', () => this.next());
document.getElementById('findPrev').addEventListener('click', () => this.prev());
document.getElementById('replaceOne').addEventListener('click', () => this.replaceOne());
document.getElementById('replaceAll').addEventListener('click', () => this.replaceAll());
document.getElementById('closeFind').addEventListener('click', () => this.hide());
document.getElementById('caseSensitive').addEventListener('change', () => this.search());
document.getElementById('useRegex').addEventListener('change', () => this.search());
}
bindShortcuts() {
document.addEventListener('keydown', (e) => {
if ((e.ctrlKey || e.metaKey) && e.key === 'f') {
e.preventDefault();
this.show();
}
if (e.key === 'Escape') this.hide();
});
}
search() {
const query = document.getElementById('findInput').value;
const caseSensitive = document.getElementById('caseSensitive').checked;
const useRegex = document.getElementById('useRegex').checked;
const text = this.editor.value;
this.matches = [];
if (!query) {
document.getElementById('matchCount').textContent = '';
return;
}
try {
let regex;
if (useRegex) {
regex = new RegExp(query, caseSensitive ? 'g' : 'gi');
} else {
// ํน์๋ฌธ์ ์ด์ค์ผ์ดํ
const escaped = query.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
regex = new RegExp(escaped, caseSensitive ? 'g' : 'gi');
}
let match;
while ((match = regex.exec(text)) !== null) {
this.matches.push({ start: match.index, end: match.index + match[0].length });
}
const count = this.matches.length;
document.getElementById('matchCount').textContent =
count > 0 ? `${count}๊ฐ ๋ฐ๊ฒฌ` : '์์';
if (count > 0) {
this.currentMatch = 0;
this.highlight();
}
} catch (err) {
document.getElementById('matchCount').textContent = '์ ๊ท์ ์ค๋ฅ';
}
}
highlight() {
if (this.matches.length === 0) return;
const match = this.matches[this.currentMatch];
this.editor.setSelectionRange(match.start, match.end);
this.editor.focus();
// ๋งค์น ์์น๋ก ์คํฌ๋กค
const lineHeight = 22;
const textBefore = this.editor.value.substring(0, match.start);
const lineNum = textBefore.split('\n').length;
this.editor.scrollTop = (lineNum - 3) * lineHeight;
document.getElementById('matchCount').textContent =
`${this.currentMatch + 1} / ${this.matches.length}`;
}
next() {
if (this.matches.length === 0) return;
this.currentMatch = (this.currentMatch + 1) % this.matches.length;
this.highlight();
}
prev() {
if (this.matches.length === 0) return;
this.currentMatch = (this.currentMatch - 1 + this.matches.length) % this.matches.length;
this.highlight();
}
replaceOne() {
if (this.matches.length === 0 || this.currentMatch < 0) return;
const replaceWith = document.getElementById('replaceInput').value;
const match = this.matches[this.currentMatch];
const text = this.editor.value;
this.editor.value =
text.substring(0, match.start) + replaceWith + text.substring(match.end);
this.search(); // ์ฌ๊ฒ์
}
replaceAll() {
const query = document.getElementById('findInput').value;
const replaceWith = document.getElementById('replaceInput').value;
if (!query) return;
const caseSensitive = document.getElementById('caseSensitive').checked;
const useRegex = document.getElementById('useRegex').checked;
try {
let regex;
if (useRegex) {
regex = new RegExp(query, caseSensitive ? 'g' : 'gi');
} else {
const escaped = query.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
regex = new RegExp(escaped, caseSensitive ? 'g' : 'gi');
}
const count = (this.editor.value.match(regex) || []).length;
this.editor.value = this.editor.value.replace(regex, replaceWith);
alert(`${count}๊ฐ ํญ๋ชฉ์ ์นํํ์ด์! โ
`);
this.search();
} catch (err) {
alert('์ ๊ท์ ์ค๋ฅ๊ฐ ์์ด์!');
}
}
show() {
this.panel.style.display = 'block';
document.getElementById('findInput').focus();
}
hide() {
this.panel.style.display = 'none';
this.editor.focus();
}
}
// ์ฌ์ฉ
const findReplace = new FindReplace(document.getElementById('codeArea'));
๐ 6. ๊ดํธ ๋งค์นญ & ์ค๋งํธ ํญ ์ฒ๋ฆฌ
๊ดํธ ์๋ ๋ซ๊ธฐ๋ ํญ ๋ค์ฌ์ฐ๊ธฐ๋ ์๋ํฐ UX์์ ์์ฒญ ์ค์ํ ๋ถ๋ถ์ด์์. ์ด๊ฑฐ ์์ผ๋ฉด ์ง์ง ๋ถํธํด์ ๋ชป ์ ใ ใ ใ
// ๊ดํธ ์๋ ๋ซ๊ธฐ & ์ค๋งํธ ์
๋ ฅ ์ฒ๋ฆฌ
class SmartInput {
constructor(editor) {
this.editor = editor;
this.pairs = {
'(': ')',
'[': ']',
'{': '}',
'"': '"',
"'": "'",
'`': '`'
};
this.init();
}
init() {
this.editor.addEventListener('keydown', (e) => this.handleKeydown(e));
}
handleKeydown(e) {
const key = e.key;
const pos = this.editor.selectionStart;
const end = this.editor.selectionEnd;
const text = this.editor.value;
const charAfter = text[pos];
// ํญ ํค ์ฒ๋ฆฌ (๋ค์ฌ์ฐ๊ธฐ)
if (key === 'Tab') {
e.preventDefault();
if (e.shiftKey) {
// Shift+Tab: ๋ด์ด์ฐ๊ธฐ
this.unindent(pos, end);
} else if (pos !== end) {
// ์ ํ ์์ญ ๋ค์ฌ์ฐ๊ธฐ
this.indentSelection(pos, end);
} else {
// ์ผ๋ฐ ํญ (์คํ์ด์ค 2๊ฐ ์ฝ์
)
this.insertText(' ', pos);
}
return;
}
// ๊ดํธ ์๋ ๋ซ๊ธฐ
if (this.pairs[key]) {
// ์ ํ ์์ญ์ด ์์ผ๋ฉด ๊ฐ์ธ๊ธฐ
if (pos !== end) {
e.preventDefault();
const selected = text.substring(pos, end);
const wrapped = key + selected + this.pairs[key];
this.editor.value = text.substring(0, pos) + wrapped + text.substring(end);
this.editor.setSelectionRange(pos + 1, end + 1);
return;
}
// ๋ซ๋ ๊ดํธ ์คํต (์ด๋ฏธ ์์ผ๋ฉด)
if (key === charAfter && Object.values(this.pairs).includes(key)) {
e.preventDefault();
this.editor.setSelectionRange(pos + 1, pos + 1);
return;
}
// ์๋ ๋ซ๊ธฐ ์ฝ์
e.preventDefault();
const closing = this.pairs[key];
this.editor.value = text.substring(0, pos) + key + closing + text.substring(pos);
this.editor.setSelectionRange(pos + 1, pos + 1);
return;
}
// Backspace: ๋น ๊ดํธ ์ ์ญ์
if (key === 'Backspace') {
const charBefore = text[pos - 1];
if (charBefore && this.pairs[charBefore] === charAfter) {
e.preventDefault();
this.editor.value = text.substring(0, pos - 1) + text.substring(pos + 1);
this.editor.setSelectionRange(pos - 1, pos - 1);
return;
}
}
// Enter: ์๋ ๋ค์ฌ์ฐ๊ธฐ
if (key === 'Enter') {
e.preventDefault();
const textBefore = text.substring(0, pos);
const currentLine = textBefore.split('\n').pop();
const indent = currentLine.match(/^(\s*)/)[1];
const charBefore = text[pos - 1];
// ์ฌ๋ ๊ดํธ ๋ค Enter๋ฉด ๋ค์ฌ์ฐ๊ธฐ ์ถ๊ฐ
if (charBefore === '{' || charBefore === '[' || charBefore === '(') {
const extraIndent = indent + ' ';
const newText = '\n' + extraIndent + '\n' + indent;
this.editor.value = text.substring(0, pos) + newText + text.substring(pos);
this.editor.setSelectionRange(pos + extraIndent.length + 1, pos + extraIndent.length + 1);
} else {
// ์ผ๋ฐ Enter: ํ์ฌ ์ค์ ๋ค์ฌ์ฐ๊ธฐ ์ ์ง
const newText = '\n' + indent;
this.editor.value = text.substring(0, pos) + newText + text.substring(pos);
this.editor.setSelectionRange(pos + indent.length + 1, pos + indent.length + 1);
}
}
}
insertText(str, pos) {
const text = this.editor.value;
this.editor.value = text.substring(0, pos) + str + text.substring(pos);
this.editor.setSelectionRange(pos + str.length, pos + str.length);
}
indentSelection(start, end) {
const text = this.editor.value;
const lines = text.substring(start, end).split('\n');
const indented = lines.map(line => ' ' + line).join('\n');
this.editor.value = text.substring(0, start) + indented + text.substring(end);
this.editor.setSelectionRange(start, start + indented.length);
}
unindent(start, end) {
const text = this.editor.value;
const lines = text.substring(start, end).split('\n');
const unindented = lines.map(line => line.replace(/^ /, '')).join('\n');
this.editor.value = text.substring(0, start) + unindented + text.substring(end);
this.editor.setSelectionRange(start, start + unindented.length);
}
}
const smartInput = new SmartInput(document.getElementById('codeArea'));
โฉ๏ธ 7. ์คํ์ทจ์(Undo) / ๋ค์์คํ(Redo) ๊ตฌํ
Ctrl+Z ์๋ ์๋ํฐ๋ ์์๋ ๋ชป ํ์ฃ ใ ใ ๋ธ๋ผ์ฐ์ ๊ธฐ๋ณธ undo/redo๋ฅผ ์ธ ์๋ ์์ง๋ง, ์ปค์คํ ํ์คํ ๋ฆฌ ์คํ์ ๊ตฌํํ๋ฉด ํจ์ฌ ์ธ๋ฐํ๊ฒ ์ ์ดํ ์ ์์ด์.
// ์ปค์คํ
Undo/Redo ํ์คํ ๋ฆฌ ๊ด๋ฆฌ
class HistoryManager {
constructor(editor) {
this.editor = editor;
this.history = []; // ํ์คํ ๋ฆฌ ์คํ
this.future = []; // ๋ค์์คํ ์คํ
this.maxHistory = 100; // ์ต๋ ํ์คํ ๋ฆฌ ๊ฐ์
this.lastSaved = ''; // ๋ง์ง๋ง ์ ์ฅ ์ํ
this.saveTimer = null; // ๋๋ฐ์ด์ค ํ์ด๋จธ
this.init();
}
init() {
// ์ด๊ธฐ ์ํ ์ ์ฅ
this.saveState();
this.editor.addEventListener('input', () => {
// ๋๋ฐ์ด์ค: 300ms ๋์ ์
๋ ฅ ์์ผ๋ฉด ์ํ ์ ์ฅ
clearTimeout(this.saveTimer);
this.saveTimer = setTimeout(() => {
this.saveState();
}, 300);
});
// ํค๋ณด๋ ๋จ์ถํค
document.addEventListener('keydown', (e) => {
if ((e.ctrlKey || e.metaKey) && !e.shiftKey && e.key === 'z') {
e.preventDefault();
this.undo();
}
if ((e.ctrlKey || e.metaKey) && (e.shiftKey && e.key === 'z' || e.key === 'y')) {
e.preventDefault();
this.redo();
}
});
}
// ํ์ฌ ์ํ ์ ์ฅ
saveState() {
const currentState = {
value: this.editor.value,
selectionStart: this.editor.selectionStart,
selectionEnd: this.editor.selectionEnd,
timestamp: Date.now()
};
// ์ด์ ์ํ์ ๋์ผํ๋ฉด ์ ์ฅ ์ ํจ
if (this.history.length > 0) {
const lastState = this.history[this.history.length - 1];
if (lastState.value === currentState.value) return;
}
this.history.push(currentState);
this.future = []; // ์ ์
๋ ฅ ์ ๋ค์์คํ ์คํ ์ด๊ธฐํ
// ์ต๋ ๊ฐ์ ์ด๊ณผ ์ ์ค๋๋ ๊ฒ ์ ๊ฑฐ
if (this.history.length > this.maxHistory) {
this.history.shift();
}
}
// ์คํ ์ทจ์
undo() {
if (this.history.length <= 1) return; // ์ด๊ธฐ ์ํ๋ ์ทจ์ ๋ถ๊ฐ
const current = this.history.pop();
this.future.push(current);
const prevState = this.history[this.history.length - 1];
this.restoreState(prevState);
}
// ๋ค์ ์คํ
redo() {
if (this.future.length === 0) return;
const nextState = this.future.pop();
this.history.push(nextState);
this.restoreState(nextState);
}
// ์ํ ๋ณต์
restoreState(state) {
this.editor.value = state.value;
this.editor.setSelectionRange(state.selectionStart, state.selectionEnd);
this.editor.focus();
// ์ค ๋ฒํธ ๋ฑ UI ์
๋ฐ์ดํธ ํธ๋ฆฌ๊ฑฐ
this.editor.dispatchEvent(new Event('input'));
}
// ํ์คํ ๋ฆฌ ์ ๋ณด ๋ฐํ
getInfo() {
return {
canUndo: this.history.length > 1,
canRedo: this.future.length > 0,
historyCount: this.history.length,
futureCount: this.future.length
};
}
}
const historyManager = new HistoryManager(document.getElementById('codeArea'));
๐ 8. ์ ์ฒด ํตํฉ & ๋ง๋ฌด๋ฆฌ
์ด์ ๋ชจ๋ ๋ชจ๋์ ํ๋๋ก ํฉ์ณ๋ณผ ์๊ฐ! ๊ฐ ๊ธฐ๋ฅ์ ๋ ๋ฆฝ ํด๋์ค๋ก ๋ง๋ค์์ผ๋ ํตํฉ์ด ๊น๋ํด์ ใ ใ
// ๋ฏธ๋ IDE ๋ฉ์ธ ์ด๊ธฐํ
class MiniIDE {
constructor() {
this.editor = document.getElementById('codeArea');
this.modules = {};
this.init();
}
init() {
// ๋ชจ๋ ๋ชจ๋ ์ด๊ธฐํ
this.modules.autoComplete = new AutoComplete(this.editor);
this.modules.findReplace = new FindReplace(this.editor);
this.modules.smartInput = new SmartInput(this.editor);
this.modules.history = new HistoryManager(this.editor);
// ์ค ๋ฒํธ & ์คํฌ๋กค ๋๊ธฐํ
this.setupLineNumbers();
this.setupScrollSync();
this.setupStatusBar();
// ๊ธฐ๋ณธ ์ฝ๋ ๋ก๋
this.loadDefaultCode();
console.log('๐ ๋ฏธ๋ IDE ์ด๊ธฐํ ์๋ฃ!');
}
setupLineNumbers() {
const update = () => {
const lines = this.editor.value.split('\n').length;
const lineNumbers = document.getElementById('lineNumbers');
lineNumbers.innerHTML = Array.from(
{length: lines}, (_, i) => `<div>${i + 1}</div>`
).join('');
};
this.editor.addEventListener('input', update);
update();
}
setupScrollSync() {
const lineNumbers = document.getElementById('lineNumbers');
this.editor.addEventListener('scroll', () => {
lineNumbers.scrollTop = this.editor.scrollTop;
});
}
setupStatusBar() {
this.editor.addEventListener('keyup', () => {
const pos = this.editor.selectionStart;
const textBefore = this.editor.value.substring(0, pos);
const lines = textBefore.split('\n');
document.getElementById('cursorPos').textContent =
`์ค ${lines.length}, ์ด ${lines[lines.length-1].length + 1}`;
});
}
loadDefaultCode() {
this.editor.value = `// ๐ ๋ฏธ๋ IDE์ ์ค์ ๊ฑธ ํ์ํด์!
// Ctrl+F: ๊ฒ์, Ctrl+Z: ์คํ์ทจ์
function hello(name) {
const greeting = \`์๋
ํ์ธ์, \${name}!\`;
console.log(greeting);
return greeting;
}
hello("๊ฐ๋ฐ์");`;
this.editor.dispatchEvent(new Event('input'));
}
}
// ์ฑ ์์!
document.addEventListener('DOMContentLoaded', () => {
window.ide = new MiniIDE();
});
๐ฆ 9. ์ง์ ๊ตฌํ vs ๋ผ์ด๋ธ๋ฌ๋ฆฌ ์ ํ ๊ฐ์ด๋
์ง์ ๋ค ๋ง๋๋ ๊ฒ ํญ์ ์ ๋ต์ ์๋์์! ์ํฉ์ ๋ฐ๋ผ ๊ฒ์ฆ๋ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ์ฐ๋ ๊ฒ ํจ์ฌ ํจ์จ์ ์ผ ์ ์์ด์. ์ด๋ค ๊ฑธ ์ ํํด์ผ ํ ์ง ์ ๋ฆฌํด๋ดค์ด์ ใ ใ
| ๋ผ์ด๋ธ๋ฌ๋ฆฌ | ํน์ง | ์ ํฉํ ์ํฉ |
|---|---|---|
| ์ง์ ๊ตฌํ | ์์ ํ ์ปค์คํฐ๋ง์ด์ง, ๋ฒ๋ค ํฌ๊ธฐ ์ต์ํ | ํ์ต ๋ชฉ์ , ๋งค์ฐ ํน์ํ ์๊ตฌ์ฌํญ |
| CodeMirror 6 | ๋ชจ๋์, ๊ฐ๋ณ๊ณ ํ์ฅ์ฑ ์ฐ์ | ์น ์ฑ ๋ด ์๋ฒ ๋๋ ์๋ํฐ |
| Monaco Editor | VS Code ์์ง, ํ๋ถํ ๊ธฐ๋ฅ | VS Code ์์ค์ ์๋ํฐ ํ์ ์ |
| Ace Editor | ์ฑ์ํ ๋ผ์ด๋ธ๋ฌ๋ฆฌ, ๋์ ์ธ์ด ์ง์ | ๋น ๋ฅธ ํ๋กํ ํ์ดํ |
| Prism.js | ํ์ด๋ผ์ดํ ์ ์ฉ, ์ด๊ฒฝ๋ | ์ฝ๊ธฐ ์ ์ฉ ์ฝ๋ ํ์ |
โ ํต์ฌ ์ ๋ฆฌ & ๋ค์ ๋จ๊ณ
spellcheck="false" ํ์!์ค๋ ๋ฐฐ์ด ๋ด์ฉ๋ค์ ์กฐํฉํ๋ฉด ์ง์ง ์ธ๋งํ ๋ฏธ๋ IDE๋ฅผ ๋ง๋ค ์ ์์ด์! ๐ ๊ฐ ๊ธฐ๋ฅ์ ๋ ๋ฆฝ ํด๋์ค๋ก ๋ถ๋ฆฌํด์ ๊ตฌํํ๊ธฐ ๋๋ฌธ์ ์ ์ง๋ณด์๋ ํธํ๊ณ , ํ์ํ ๊ธฐ๋ฅ๋ง ๊ณจ๋ผ์ ์ธ ์๋ ์์ด์. ๋ค์ ๋จ๊ณ๋ก๋ LSP(Language Server Protocol) ์ฐ๋์ด๋ ํ๋ฌ๊ทธ์ธ ์์คํ ๊ตฌํ์ ๋์ ํด๋ณด์ธ์! ํ์ดํ ๐ฅ
๊ด๋ จ ํค์๋
๋๊ธ ์์ฑ
์ด ๊ธ์ ๋ํ ์ฌ๋ฌ๋ถ์ ์๊ฐ์ ๋ค๋ ค์ฃผ์ธ์
๋ก๊ทธ์ธ์ด ํ์ํฉ๋๋ค
๋๊ธ์ ์์ฑํ๋ ค๋ฉด ๋จผ์ ๋ก๊ทธ์ธํด์ฃผ์ธ์.
๋๊ธ 0
์ง์์ธ์ ์ฒ - ์ง์ ์ฌ์ฐ๊ถ ๋ณดํธ ๊ณ ์ง
์ง์ ์ฌ์ฐ๊ถ ๋ณดํธ ๊ณ ์ง
- ์ ์๊ถ ๋ฐ ์์ ๊ถ: ๋ณธ ์ปจํ ์ธ ๋ ์ฌ๋ฅ๋ท์ ๋ ์ AI ๊ธฐ์ ๋ก ์์ฑ๋์์ผ๋ฉฐ, ๋ํ๋ฏผ๊ตญ ์ ์๊ถ๋ฒ ๋ฐ ๊ตญ์ ์ ์๊ถ ํ์ฝ์ ์ํด ๋ณดํธ๋ฉ๋๋ค.
- AI ์์ฑ ์ปจํ ์ธ ์ ๋ฒ์ ์ง์: ๋ณธ AI ์์ฑ ์ปจํ ์ธ ๋ ์ฌ๋ฅ๋ท์ ์ง์ ์ฐฝ์๋ฌผ๋ก ์ธ์ ๋๋ฉฐ, ๊ด๋ จ ๋ฒ๊ท์ ๋ฐ๋ผ ์ ์๊ถ ๋ณดํธ๋ฅผ ๋ฐ์ต๋๋ค.
- ์ฌ์ฉ ์ ํ: ์ฌ๋ฅ๋ท์ ๋ช ์์ ์๋ฉด ๋์ ์์ด ๋ณธ ์ปจํ ์ธ ๋ฅผ ๋ณต์ , ์์ , ๋ฐฐํฌ, ๋๋ ์์ ์ ์ผ๋ก ํ์ฉํ๋ ํ์๋ ์๊ฒฉํ ๊ธ์ง๋ฉ๋๋ค.
- ๋ฐ์ดํฐ ์์ง ๊ธ์ง: ๋ณธ ์ปจํ ์ธ ์ ๋ํ ๋ฌด๋จ ์คํฌ๋ํ, ํฌ๋กค๋ง, ๋ฐ ์๋ํ๋ ๋ฐ์ดํฐ ์์ง์ ๋ฒ์ ์ ์ฌ์ ๋์์ด ๋ฉ๋๋ค.
- AI ํ์ต ์ ํ: ์ฌ๋ฅ๋ท์ AI ์์ฑ ์ปจํ ์ธ ๋ฅผ ํ AI ๋ชจ๋ธ ํ์ต์ ๋ฌด๋จ ์ฌ์ฉํ๋ ํ์๋ ๊ธ์ง๋๋ฉฐ, ์ด๋ ์ง์ ์ฌ์ฐ๊ถ ์นจํด๋ก ๊ฐ์ฃผ๋ฉ๋๋ค.
์์ง ๋๊ธ์ด ์์ต๋๋ค.