Files
atom/src/cursor-component.coffee
Nathan Sobo 030bcd6d4f Make react cursor the width of a default character at the end of lines
When the cursor is positioned before a character, we always make it the
width of that character. But at the end of a line, there is no character
to use to set the width, so we just use the defaultCharWidth.

This makes the block cursor visible on empty lines in vim-mode.
2014-06-11 11:54:10 -06:00

17 lines
547 B
CoffeeScript

React = require 'react-atom-fork'
{div} = require 'reactionary-atom-fork'
module.exports =
CursorComponent = React.createClass
displayName: 'CursorComponent'
render: ->
{editor, screenRange, scrollTop, scrollLeft, defaultCharWidth} = @props
{top, left, height, width} = editor.pixelRectForScreenRange(screenRange)
top -= scrollTop
left -= scrollLeft
width = defaultCharWidth if width is 0
WebkitTransform = "translate3d(#{left}px, #{top}px, 0px)"
div className: 'cursor', style: {height, width, WebkitTransform}