mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-11-10 10:17:11 +03:00
Merge pull request #4240 from atom/ks-write-text-async-to-selection-clipboard
Write text async to selection clipboard
This commit is contained in:
commit
9b28e7a47c
@ -2686,6 +2686,10 @@ describe "TextEditorComponent", ->
|
|||||||
|
|
||||||
describe "middle mouse paste on Linux", ->
|
describe "middle mouse paste on Linux", ->
|
||||||
it "pastes the previously selected text", ->
|
it "pastes the previously selected text", ->
|
||||||
|
spyOn(require('ipc'), 'send').andCallFake (eventName, selectedText) ->
|
||||||
|
if eventName is 'write-text-to-selection-clipboard'
|
||||||
|
require('clipboard').writeText(selectedText, 'selection')
|
||||||
|
|
||||||
atom.clipboard.write('')
|
atom.clipboard.write('')
|
||||||
component.listenForMiddleMousePaste()
|
component.listenForMiddleMousePaste()
|
||||||
|
|
||||||
|
@ -238,6 +238,11 @@ class AtomApplication
|
|||||||
win = BrowserWindow.fromWebContents(event.sender)
|
win = BrowserWindow.fromWebContents(event.sender)
|
||||||
win[method](args...)
|
win[method](args...)
|
||||||
|
|
||||||
|
clipboard = null
|
||||||
|
ipc.on 'write-text-to-selection-clipboard', (event, selectedText) ->
|
||||||
|
clipboard ?= require 'clipboard'
|
||||||
|
clipboard.writeText(selectedText, 'selection')
|
||||||
|
|
||||||
# Public: Executes the given command.
|
# Public: Executes the given command.
|
||||||
#
|
#
|
||||||
# If it isn't handled globally, delegate to the currently focused window.
|
# If it isn't handled globally, delegate to the currently focused window.
|
||||||
|
@ -6,6 +6,7 @@ scrollbarStyle = require 'scrollbar-style'
|
|||||||
{Range, Point} = require 'text-buffer'
|
{Range, Point} = require 'text-buffer'
|
||||||
grim = require 'grim'
|
grim = require 'grim'
|
||||||
{CompositeDisposable} = require 'event-kit'
|
{CompositeDisposable} = require 'event-kit'
|
||||||
|
ipc = require 'ipc'
|
||||||
|
|
||||||
GutterComponent = require './gutter-component'
|
GutterComponent = require './gutter-component'
|
||||||
InputComponent = require './input-component'
|
InputComponent = require './input-component'
|
||||||
@ -444,7 +445,10 @@ TextEditorComponent = React.createClass
|
|||||||
|
|
||||||
@subscribe @props.editor.onDidChangeSelectionRange =>
|
@subscribe @props.editor.onDidChangeSelectionRange =>
|
||||||
if selectedText = @props.editor.getSelectedText()
|
if selectedText = @props.editor.getSelectedText()
|
||||||
clipboard.writeText(selectedText, 'selection')
|
# This uses ipc.send instead of clipboard.writeText because
|
||||||
|
# clipboard.writeText is a sync ipc call on Linux and that
|
||||||
|
# will slow down selections.
|
||||||
|
ipc.send('write-text-to-selection-clipboard', selectedText)
|
||||||
|
|
||||||
observeConfig: ->
|
observeConfig: ->
|
||||||
@subscribe atom.config.observe 'editor.useHardwareAcceleration', @setUseHardwareAcceleration
|
@subscribe atom.config.observe 'editor.useHardwareAcceleration', @setUseHardwareAcceleration
|
||||||
|
Loading…
Reference in New Issue
Block a user