| 1 |
<!doctype html> |
| 2 |
|
| 3 |
<title>CodeMirror: Visible tabs demo</title> |
| 4 |
<meta charset="utf-8"/> |
| 5 |
<link rel=stylesheet href="../doc/docs.css"> |
| 6 |
|
| 7 |
<link rel="stylesheet" href="../lib/codemirror.css"> |
| 8 |
<script src="../lib/codemirror.js"></script> |
| 9 |
<script src="../mode/clike/clike.js"></script> |
| 10 |
<style> |
| 11 |
.CodeMirror {border-top: 1px solid #eee; border-bottom: 1px solid #eee;} |
| 12 |
.cm-tab { |
| 13 |
background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAMCAYAAAAkuj5RAAAAAXNSR0IArs4c6QAAAGFJREFUSMft1LsRQFAQheHPowAKoACx3IgEKtaEHujDjORSgWTH/ZOdnZOcM/sgk/kFFWY0qV8foQwS4MKBCS3qR6ixBJvElOobYAtivseIE120FaowJPN75GMu8j/LfMwNjh4HUpwg4LUAAAAASUVORK5CYII=); |
| 14 |
background-position: right; |
| 15 |
background-repeat: no-repeat; |
| 16 |
} |
| 17 |
</style> |
| 18 |
<div id=nav> |
| 19 |
<a href="https://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../doc/logo.png"></a> |
| 20 |
|
| 21 |
<ul> |
| 22 |
<li><a href="../index.html">Home</a> |
| 23 |
<li><a href="../doc/manual.html">Manual</a> |
| 24 |
<li><a href="https://github.com/codemirror/codemirror">Code</a> |
| 25 |
</ul> |
| 26 |
<ul> |
| 27 |
<li><a class=active href="#">Visible tabs</a> |
| 28 |
</ul> |
| 29 |
</div> |
| 30 |
|
| 31 |
<article> |
| 32 |
<h2>Visible tabs demo</h2> |
| 33 |
<form><textarea id="code" name="code"> |
| 34 |
#include "syscalls.h" |
| 35 |
/* getchar: simple buffered version */ |
| 36 |
int getchar(void) |
| 37 |
{ |
| 38 |
static char buf[BUFSIZ]; |
| 39 |
static char *bufp = buf; |
| 40 |
static int n = 0; |
| 41 |
if (n == 0) { /* buffer is empty */ |
| 42 |
n = read(0, buf, sizeof buf); |
| 43 |
bufp = buf; |
| 44 |
} |
| 45 |
return (--n >= 0) ? (unsigned char) *bufp++ : EOF; |
| 46 |
} |
| 47 |
</textarea></form> |
| 48 |
|
| 49 |
<p>Tabs inside the editor are spans with the |
| 50 |
class <code>cm-tab</code>, and can be styled.</p> |
| 51 |
|
| 52 |
<script> |
| 53 |
var editor = CodeMirror.fromTextArea(document.getElementById("code"), { |
| 54 |
lineNumbers: true, |
| 55 |
tabSize: 4, |
| 56 |
indentUnit: 4, |
| 57 |
indentWithTabs: true, |
| 58 |
mode: "text/x-csrc" |
| 59 |
}); |
| 60 |
</script> |
| 61 |
|
| 62 |
</article> |