mirror of
https://github.com/atom/atom.git
synced 2026-02-16 01:25:13 -05:00
Merge branch 'nak-nostream' into nak-powered-search
This commit is contained in:
@@ -16,7 +16,9 @@ class AtomTheme extends Theme
|
||||
if fs.isFile(metadataPath)
|
||||
stylesheetNames = CSON.readObject(metadataPath)?.stylesheets
|
||||
if stylesheetNames
|
||||
@loadStylesheet(fs.join(@path, name)) for name in stylesheetNames
|
||||
for name in stylesheetNames
|
||||
filename = fs.resolveExtension(fs.join(@path, name), ['.css', '.less', ''])
|
||||
@loadStylesheet(filename)
|
||||
else
|
||||
@loadStylesheet(stylesheetPath) for stylesheetPath in fs.list(@path, ['.css', '.less'])
|
||||
|
||||
|
||||
@@ -373,7 +373,7 @@ class Editor extends View
|
||||
else if clickCount == 3
|
||||
@activeEditSession.selectLine() unless e.shiftKey
|
||||
|
||||
@selectOnMousemoveUntilMouseup() unless e.originalEvent.which > 1
|
||||
@selectOnMousemoveUntilMouseup() unless e.ctrlKey or e.originalEvent.which > 1
|
||||
|
||||
@renderedLines.on 'mousedown', onMouseDown
|
||||
|
||||
@@ -393,10 +393,6 @@ class Editor extends View
|
||||
@gutter.widthChanged = (newWidth) =>
|
||||
@scrollView.css('left', newWidth + 'px')
|
||||
|
||||
@gutter.on 'mousedown', (e) =>
|
||||
e.pageX = @renderedLines.offset().left
|
||||
onMouseDown(e)
|
||||
|
||||
@scrollView.on 'scroll', =>
|
||||
if @scrollView.scrollLeft() == 0
|
||||
@gutter.removeClass('drop-shadow')
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
{View, $$, $$$} = require 'space-pen'
|
||||
Range = require 'range'
|
||||
$ = require 'jquery'
|
||||
_ = require 'underscore'
|
||||
|
||||
module.exports =
|
||||
@@ -16,21 +17,42 @@ class Gutter extends View
|
||||
return if @attached or not onDom
|
||||
@attached = true
|
||||
|
||||
editor = @editor()
|
||||
highlightLines = => @highlightLines()
|
||||
editor.on 'cursor:moved', highlightLines
|
||||
editor.on 'selection:changed', highlightLines
|
||||
@getEditor().on 'cursor:moved', highlightLines
|
||||
@getEditor().on 'selection:changed', highlightLines
|
||||
@on 'mousedown', (e) => @handleMouseEvents(e)
|
||||
|
||||
editor: ->
|
||||
getEditor: ->
|
||||
@parentView
|
||||
|
||||
beforeRemove: ->
|
||||
$(document).off(".gutter-#{@getEditor().id}")
|
||||
|
||||
handleMouseEvents: (e) ->
|
||||
editor = @getEditor()
|
||||
startRow = editor.screenPositionFromMouseEvent(e).row
|
||||
if e.shiftKey
|
||||
editor.selectToScreenPosition([startRow + 1, 0])
|
||||
return
|
||||
else
|
||||
editor.getSelection().setScreenRange([[startRow, 0], [startRow, 0]])
|
||||
|
||||
moveHandler = (e) =>
|
||||
start = startRow
|
||||
end = editor.screenPositionFromMouseEvent(e).row
|
||||
if end > start then end++ else start++
|
||||
editor.getSelection().setScreenRange([[start, 0], [end, 0]])
|
||||
|
||||
$(document).on "mousemove.gutter-#{@getEditor().id}", moveHandler
|
||||
$(document).one "mouseup.gutter-#{@getEditor().id}", => $(document).off 'mousemove', moveHandler
|
||||
|
||||
setShowLineNumbers: (showLineNumbers) ->
|
||||
if showLineNumbers then @lineNumbers.show() else @lineNumbers.hide()
|
||||
|
||||
updateLineNumbers: (changes, renderFrom, renderTo) ->
|
||||
if renderFrom < @firstScreenRow or renderTo > @lastScreenRow
|
||||
performUpdate = true
|
||||
else if @editor().getLastScreenRow() < @lastScreenRow
|
||||
else if @getEditor().getLastScreenRow() < @lastScreenRow
|
||||
performUpdate = true
|
||||
else
|
||||
for change in changes
|
||||
@@ -41,7 +63,7 @@ class Gutter extends View
|
||||
@renderLineNumbers(renderFrom, renderTo) if performUpdate
|
||||
|
||||
renderLineNumbers: (startScreenRow, endScreenRow) ->
|
||||
editor = @editor()
|
||||
editor = @getEditor()
|
||||
maxDigits = editor.getLineCount().toString().length
|
||||
rows = editor.bufferRowsForScreenRows(startScreenRow, endScreenRow)
|
||||
|
||||
@@ -81,8 +103,8 @@ class Gutter extends View
|
||||
@highlightedLineNumbers.push(highlightedLineNumber)
|
||||
|
||||
highlightLines: ->
|
||||
if @editor().getSelection().isEmpty()
|
||||
row = @editor().getCursorScreenPosition().row
|
||||
if @getEditor().getSelection().isEmpty()
|
||||
row = @getEditor().getCursorScreenPosition().row
|
||||
rowRange = new Range([row, 0], [row, 0])
|
||||
return if @selectionEmpty and @highlightedRows?.isEqual(rowRange)
|
||||
|
||||
@@ -91,7 +113,7 @@ class Gutter extends View
|
||||
@highlightedRows = rowRange
|
||||
@selectionEmpty = true
|
||||
else
|
||||
selectedRows = @editor().getSelection().getScreenRange()
|
||||
selectedRows = @getEditor().getSelection().getScreenRange()
|
||||
endRow = selectedRows.end.row
|
||||
endRow-- if selectedRows.end.column is 0
|
||||
selectedRows = new Range([selectedRows.start.row, 0], [endRow, 0])
|
||||
|
||||
@@ -38,7 +38,7 @@ class Keymap
|
||||
@loadDirectory(fs.join(config.configDirPath, 'keymaps'))
|
||||
|
||||
loadDirectory: (directoryPath) ->
|
||||
@load(filePath) for filePath in fs.list(directoryPath, ['.cson', '.json']) ? []
|
||||
@load(filePath) for filePath in fs.list(directoryPath, ['.cson', '.json'])
|
||||
|
||||
load: (path) ->
|
||||
@add(path, CSON.readObject(path))
|
||||
|
||||
@@ -145,6 +145,9 @@ class Buffer
|
||||
lineLengthForRow: (row) ->
|
||||
@lines[row].length
|
||||
|
||||
lineEndingLengthForRow: (row) ->
|
||||
(@lineEndingForRow(row) ? '').length
|
||||
|
||||
rangeForRow: (row, { includeNewline } = {}) ->
|
||||
if includeNewline and row < @getLastRow()
|
||||
new Range([row, 0], [row + 1, 0])
|
||||
@@ -165,15 +168,16 @@ class Buffer
|
||||
new Point(lastRow, @lineLengthForRow(lastRow))
|
||||
|
||||
characterIndexForPosition: (position) ->
|
||||
position = Point.fromObject(position)
|
||||
position = @clipPosition(position)
|
||||
|
||||
index = 0
|
||||
index += @lineLengthForRow(row) + 1 for row in [0...position.row]
|
||||
for row in [0...position.row]
|
||||
index += @lineLengthForRow(row) + Math.max(@lineEndingLengthForRow(row), 1)
|
||||
index + position.column
|
||||
|
||||
positionForCharacterIndex: (index) ->
|
||||
row = 0
|
||||
while index >= (lineLength = @lineLengthForRow(row) + 1)
|
||||
while index >= (lineLength = @lineLengthForRow(row) + Math.max(@lineEndingLengthForRow(row), 1))
|
||||
index -= lineLength
|
||||
row++
|
||||
|
||||
@@ -358,7 +362,7 @@ class Buffer
|
||||
@scanInRange(regex, @getRange(), iterator)
|
||||
|
||||
scanInRange: (regex, range, iterator, reverse=false) ->
|
||||
range = Range.fromObject(range)
|
||||
range = @clipRange(range)
|
||||
global = regex.global
|
||||
flags = "gm"
|
||||
flags += "i" if regex.ignoreCase
|
||||
|
||||
@@ -26,6 +26,7 @@ class TextMateGrammar
|
||||
repository: null
|
||||
initialRule: null
|
||||
firstLineRegex: null
|
||||
maxTokensPerLine: 100
|
||||
|
||||
constructor: ({ @name, @fileTypes, @scopeName, patterns, repository, @foldingStopMarker, firstLineMatch}) ->
|
||||
@initialRule = new Rule(this, {@scopeName, patterns})
|
||||
@@ -38,6 +39,7 @@ class TextMateGrammar
|
||||
@repository[name] = new Rule(this, data)
|
||||
|
||||
tokenizeLine: (line, ruleStack=[@initialRule], firstLine=false) ->
|
||||
originalRuleStack = ruleStack
|
||||
ruleStack = new Array(ruleStack...) # clone ruleStack
|
||||
tokens = []
|
||||
position = 0
|
||||
@@ -46,6 +48,12 @@ class TextMateGrammar
|
||||
previousRuleStackLength = ruleStack.length
|
||||
previousPosition = position
|
||||
|
||||
if tokens.length >= (@getMaxTokensPerLine() - 1)
|
||||
token = new Token(value: line[position..], scopes: scopes)
|
||||
tokens.push token
|
||||
ruleStack = originalRuleStack
|
||||
break
|
||||
|
||||
if line.length == 0
|
||||
tokens = [new Token(value: "", scopes: scopes)]
|
||||
return { tokens, ruleStack }
|
||||
@@ -79,6 +87,9 @@ class TextMateGrammar
|
||||
ruleStack.forEach (rule) -> rule.clearAnchorPosition()
|
||||
{ tokens, ruleStack }
|
||||
|
||||
getMaxTokensPerLine: ->
|
||||
@maxTokensPerLine
|
||||
|
||||
class Rule
|
||||
grammar: null
|
||||
scopeName: null
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
fs = require 'fs-utils'
|
||||
$ = require 'jquery'
|
||||
_ = require 'underscore'
|
||||
{less} = require 'less'
|
||||
{spawn} = require 'child_process'
|
||||
require 'jquery-extensions'
|
||||
@@ -36,12 +37,9 @@ window.setUpEnvironment = ->
|
||||
|
||||
# This method is only called when opening a real application window
|
||||
window.startup = ->
|
||||
if fs.isDirectory('/opt/boxen')
|
||||
installAtomCommand('/opt/boxen/bin/atom')
|
||||
else if fs.isDirectory('/opt/github')
|
||||
installAtomCommand('/opt/github/bin/atom')
|
||||
else if fs.isDirectory('/usr/local')
|
||||
installAtomCommand('/usr/local/bin/atom')
|
||||
directory = _.find ['/opt/boxen', '/opt/github', '/usr/local'], (dir) -> fs.isDirectory(dir)
|
||||
if directory
|
||||
installAtomCommand(fs.join(directory, 'bin/atom'))
|
||||
else
|
||||
console.warn "Failed to install `atom` binary"
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ class DirectoryView extends View
|
||||
@div outlet: 'header', class: 'header', =>
|
||||
@span class: 'disclosure-arrow', outlet: 'disclosureArrow'
|
||||
@span directory.getBaseName(), class: 'name', outlet: 'directoryName'
|
||||
@span "", class: 'highlight'
|
||||
@span class: 'highlight'
|
||||
|
||||
directory: null
|
||||
entries: null
|
||||
|
||||
@@ -9,7 +9,7 @@ class FileView extends View
|
||||
@content: ({file} = {}) ->
|
||||
@li class: 'file entry', =>
|
||||
@span file.getBaseName(), class: 'name', outlet: 'fileName'
|
||||
@span '', class: 'highlight'
|
||||
@span class: 'highlight'
|
||||
|
||||
file: null
|
||||
|
||||
|
||||
@@ -56,6 +56,7 @@ class TreeView extends ScrollView
|
||||
afterAttach: (onDom) ->
|
||||
@focus() if @focusAfterAttach
|
||||
@scrollTop(@scrollTopAfterAttach) if @scrollTopAfterAttach > 0
|
||||
@find('.selected > .highlight').width(@treeViewList[0].scrollWidth)
|
||||
|
||||
serialize: ->
|
||||
directoryExpansionStates: @root?.serializeEntryExpansionStates()
|
||||
@@ -304,10 +305,11 @@ class TreeView extends ScrollView
|
||||
entry = entry.view() unless entry instanceof View
|
||||
@selectedPath = entry.getPath()
|
||||
@deselect()
|
||||
entry.children('.highlight').width(@treeViewList[0].scrollWidth)
|
||||
entry.addClass('selected')
|
||||
|
||||
deselect: ->
|
||||
@treeViewList.find('.selected').removeClass('selected')
|
||||
@treeViewList.find('.selected').removeClass('selected').children('.highlight').width('')
|
||||
|
||||
scrollTop: (top) ->
|
||||
if top
|
||||
|
||||
@@ -90,7 +90,7 @@ module.exports =
|
||||
# Returns an array with all the names of files contained
|
||||
# in the directory path.
|
||||
list: (rootPath, extensions) ->
|
||||
return unless @isDirectory(rootPath)
|
||||
return [] unless @isDirectory(rootPath)
|
||||
paths = fs.readdirSync(rootPath)
|
||||
paths = @filterExtensions(paths, extensions) if extensions
|
||||
paths = paths.map (path) => @join(rootPath, path)
|
||||
|
||||
Reference in New Issue
Block a user