mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
Parameterize clipboard on TextEditor
This commit is contained in:
@@ -175,7 +175,7 @@ class Atom extends Model
|
||||
@workspace = new Workspace({
|
||||
@config, @project, packageManager: @packages, grammarRegistry: @grammars,
|
||||
notificationManager: @notifications, setRepresentedFilename: @setRepresentedFilename.bind(this),
|
||||
setDocumentEdited: @setDocumentEdited.bind(this)
|
||||
setDocumentEdited: @setDocumentEdited.bind(this), @clipboard
|
||||
})
|
||||
@themes.workspace = @workspace
|
||||
|
||||
|
||||
@@ -76,6 +76,7 @@ class TextEditor extends Model
|
||||
state.displayBuffer = displayBuffer
|
||||
state.config = atomEnvironment.config
|
||||
state.notificationManager = atomEnvironment.notifications
|
||||
state.clipboard = atomEnvironment.clipboard
|
||||
new this(state)
|
||||
|
||||
constructor: (params={}) ->
|
||||
@@ -84,7 +85,7 @@ class TextEditor extends Model
|
||||
{
|
||||
@softTabs, @scrollRow, @scrollColumn, initialLine, initialColumn, tabLength,
|
||||
softWrapped, @displayBuffer, buffer, suppressCursorCreation, @mini, @placeholderText,
|
||||
lineNumberGutterVisible, largeFileMode, @config, @notificationManager
|
||||
lineNumberGutterVisible, largeFileMode, @config, @notificationManager, @clipboard
|
||||
} = params
|
||||
|
||||
@emitter = new Emitter
|
||||
@@ -460,7 +461,7 @@ class TextEditor extends Model
|
||||
softTabs = @getSoftTabs()
|
||||
newEditor = new TextEditor({
|
||||
@buffer, displayBuffer, @tabLength, softTabs, suppressCursorCreation: true,
|
||||
@config, @notificationManager
|
||||
@config, @notificationManager, @clipboard
|
||||
})
|
||||
for marker in @findMarkers(editorId: @id)
|
||||
marker.copy(editorId: newEditor.id, preserveFolds: true)
|
||||
@@ -590,7 +591,7 @@ class TextEditor extends Model
|
||||
# Copies the current file path to the native clipboard.
|
||||
copyPathToClipboard: ->
|
||||
if filePath = @getPath()
|
||||
atom.clipboard.write(filePath)
|
||||
@clipboard.write(filePath)
|
||||
|
||||
###
|
||||
Section: File Operations
|
||||
@@ -2618,7 +2619,7 @@ class TextEditor extends Model
|
||||
#
|
||||
# * `options` (optional) See {Selection::insertText}.
|
||||
pasteText: (options={}) ->
|
||||
{text: clipboardText, metadata} = atom.clipboard.readWithMetadata()
|
||||
{text: clipboardText, metadata} = @clipboard.readWithMetadata()
|
||||
return false unless @emitWillInsertTextEvent(clipboardText)
|
||||
|
||||
metadata ?= {}
|
||||
|
||||
@@ -26,7 +26,7 @@ class Workspace extends Model
|
||||
constructor: (params) ->
|
||||
super
|
||||
|
||||
{@packageManager, @config, @project, @grammarRegistry, @notificationManager} = params
|
||||
{@packageManager, @config, @project, @grammarRegistry, @notificationManager, @clipboard} = params
|
||||
{@setRepresentedFilename, @setDocumentEdited} = params
|
||||
|
||||
@emitter = new Emitter
|
||||
@@ -456,7 +456,7 @@ class Workspace extends Model
|
||||
@buildTextEditor(_.extend({buffer, largeFileMode}, options))
|
||||
|
||||
buildTextEditor: (params) ->
|
||||
new TextEditor(_.extend({@config, @notificationManager}, params))
|
||||
new TextEditor(_.extend({@config, @notificationManager, @clipboard}, params))
|
||||
|
||||
# Public: Asynchronously reopens the last-closed item's URI if it hasn't already been
|
||||
# reopened.
|
||||
|
||||
Reference in New Issue
Block a user