Half-baked: Have a lines reasonably looking cursor working.

A bunch of tests are failing but you can load a buffer and display its
lines.
This commit is contained in:
Nathan Sobo 2012-01-16 22:11:38 -08:00
parent 4274ff4a81
commit 5198a88cce
9 changed files with 73 additions and 10 deletions

View File

@ -1,5 +1,6 @@
<html>
<head>
<link rel="stylesheet" type="text/css" src="static/reset.css">
<script src='src/stdlib/require.js'></script>
<script>

View File

@ -19,7 +19,7 @@ describe "Editor", ->
it "sets the cursor to the beginning of the file", ->
expect(editor.getPosition()).toEqual(row: 0, col: 0)
fdescribe ".setPosition({row, col})", ->
describe ".setPosition({row, col})", ->
it "moves the cursor to cover the character at the given row and column", ->
editor.attachToDom()
editor.setBuffer(buffer)

View File

@ -8,8 +8,7 @@ require 'window'
afterEach ->
(new Native).resetMainMenu()
atom.globalKeymap.reset()
# $('#jasmine-content').empty()
# $('head style[path]').remove()
$('#jasmine-content').empty()
window.atom = new (require 'app')

View File

@ -17,6 +17,7 @@ class Editor extends Template
initialize: () ->
requireStylesheet 'editor.css'
@setBuffer(new Buffer)
@one 'attach', => @calculateDimensions()
setBuffer: (@buffer) ->
@lines.empty()
@ -34,11 +35,9 @@ class Editor extends Template
{ top: row * @lineHeight(), left: col * @charWidth() }
lineHeight: ->
@calculateDimensions() unless @cachedLineHeight
@cachedLineHeight
charWidth: ->
@calculateDimensions() unless @cachedCharWidth
@cachedCharWidth
calculateDimensions: ->
@ -46,6 +45,5 @@ class Editor extends Template
@lines.append(fragment)
@cachedCharWidth = fragment.width()
@cachedLineHeight = fragment.outerHeight()
console.log @cachedLineHeight
fragment.remove()

View File

@ -14,8 +14,6 @@ module.exports =
class RootView extends Template
content: ->
@div id: 'app-horizontal', =>
@link rel: 'stylesheet', href: "#{require.resolve('atom.css')}?#{(new Date).getTime()}"
@link rel: 'stylesheet', href: "#{require.resolve('editor.css')}?#{(new Date).getTime()}"
@div id: 'app-vertical', outlet: 'vertical', =>
@div id: 'main', outlet: 'main', =>
@subview 'editor', Editor.build()

View File

@ -60,3 +60,7 @@ for key, value of windowAdditions
console.warn "DOMWindow already has a key named `#{key}`" if window[key]
window[key] = value
requireStylesheet 'reset.css'
requireStylesheet 'atom.css'

View File

@ -6,7 +6,6 @@
body {
font-family: Lucida Grande;
font-size: 12px;
overflow: hidden;
}
#app-horizontal {

View File

@ -1,5 +1,4 @@
.editor {
font-family: Inconsolata, Monaco, Courier;
font: 18px Inconsolata, Monaco, Courier !important;
position: relative;
width: 100%;

65
static/reset.css Executable file
View File

@ -0,0 +1,65 @@
/* --------------------------------------------------------------
reset.css
* Resets default browser CSS.
-------------------------------------------------------------- */
html {
margin:0;
padding:0;
border:0;
}
body, div, span, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, code,
del, dfn, em, img, q, dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, dialog, figure, footer, header,
hgroup, nav, section {
margin: 0;
padding: 0;
border: 0;
font-size: 100%;
font: inherit;
vertical-align: baseline;
}
/* This helps to make newer HTML5 elements behave like DIVs in older browers */
article, aside, details, figcaption, figure, dialog,
footer, header, hgroup, menu, nav, section {
display:block;
}
/* Line-height should always be unitless! */
body {
line-height: 1.5;
background: white;
}
/* Tables still need 'cellspacing="0"' in the markup. */
table {
border-collapse: separate;
border-spacing: 0;
}
/* float:none prevents the span-x classes from breaking table-cell display */
caption, th, td {
text-align: left;
font-weight: normal;
float:none !important;
}
table, th, td {
vertical-align: middle;
}
/* Remove possible quote marks (") from <q>, <blockquote>. */
blockquote:before, blockquote:after, q:before, q:after { content: ''; }
blockquote, q { quotes: "" ""; }
/* Remove annoying border on linked images. */
a img { border: none; }
/* Remember to define your own focus styles! */
:focus { outline: 0; }