Skip to content

Commit 721ad37

Browse files
authored
Use annotations API (#94)
1 parent 29cbb55 commit 721ad37

File tree

6 files changed

+306
-99
lines changed

6 files changed

+306
-99
lines changed

css/index.css

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,14 @@ body {
173173
border-bottom: 2px dotted red;
174174
}
175175

176-
.gutter-error {
177-
background-color: red;
176+
.warning {
177+
position: absolute;
178+
z-index: 20;
179+
border-bottom: 2px dotted #c4953a;
180+
}
181+
182+
.ace_gutter-tooltip {
183+
white-space: pre-wrap;
178184
}
179185

180186
.error-banner {

index.html

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@
66
<meta content="utf-8" http-equiv="encoding">
77
<meta name="viewport" content="width=device-width, initial-scale=1.0">
88

9-
<link rel="stylesheet" type="text/css" href="//fonts.googleapis.com/css?family=Roboto:300,600">
10-
<link rel="stylesheet" type="text/css" href="//fonts.googleapis.com/css?family=Roboto+Slab:300,600">
11-
<link rel="stylesheet" type="text/css" href="css/index.css">
12-
139
<link rel="icon" type="image/png" href="./img/favicon_clear-16.png" sizes="16x16">
1410
<link rel="icon" type="image/png" href="./img/favicon_clear-32.png" sizes="32x32">
1511
<link rel="icon" type="image/png" href="./img/favicon_clear-256.png" sizes="256x256">
@@ -19,6 +15,10 @@
1915
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/ace/1.1.01/ace.js" charset="utf-8"></script>
2016
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/ace/1.1.01/mode-haskell.js"></script>
2117
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/ace/1.1.01/theme-dawn.js"></script>
18+
19+
<link rel="stylesheet" type="text/css" href="//fonts.googleapis.com/css?family=Roboto:300,600">
20+
<link rel="stylesheet" type="text/css" href="//fonts.googleapis.com/css?family=Roboto+Slab:300,600">
21+
<link rel="stylesheet" type="text/css" href="css/index.css">
2222
</head>
2323
<body>
2424
<div id="wrapper">
@@ -157,7 +157,11 @@
157157
cleanupActions = [];
158158
}
159159

160-
function addErrorMarker(startLine, startColumn, endLine, endColumn) {
160+
function setAnnotations(annotations) {
161+
editor.session.setAnnotations(annotations);
162+
}
163+
164+
function addMarker(type, startLine, startColumn, endLine, endColumn) {
161165
if (startLine === endLine && endColumn <= startColumn) {
162166
// Make sure the range is at least one character wide.
163167
if (startColumn > 0) {
@@ -171,16 +175,13 @@
171175
var range = new(ace.require("ace/range").Range)
172176
(startLine - 1, startColumn - 1, endLine - 1, endColumn - 1);
173177

174-
var marker = editor.session.addMarker(range, "error", "text", true);
175-
176-
editor.session.addGutterDecoration(startLine - 1, "gutter-error");
178+
var marker = editor.session.addMarker(range, type, "text", true);
177179

178-
cleanupActions.push((function(marker, line) {
180+
cleanupActions.push((function(marker) {
179181
return function() {
180182
editor.session.removeMarker(marker);
181-
editor.session.removeGutterDecoration(line, "gutter-error");
182183
};
183-
})(marker, startLine - 1));
184+
})(marker));
184185
}
185186

186187
function setupIFrame($ctr, html, js, onReady) {

0 commit comments

Comments
 (0)