File tree Expand file tree Collapse file tree 2 files changed +31
-1
lines changed Expand file tree Collapse file tree 2 files changed +31
-1
lines changed Original file line number Diff line number Diff line change 175175 "terminal-view" : {
176176 "buttons" : {
177177 "clear" : " Clear console" ,
178- "scroll" : " Scroll to bottom"
178+ "scroll" : " Scroll to bottom" ,
179+ "content-copy" : " Copy content"
179180 }
180181 },
181182 "top-bar" : {
Original file line number Diff line number Diff line change 1515 icon =" lens"
1616 class =" separator"
1717 />
18+ <VueButton
19+ class =" icon-button flat"
20+ icon-left =" content_copy"
21+ v-tooltip =" $t('org.vue.components.terminal-view.buttons.content-copy')"
22+ @click =" copyContent()"
23+ />
1824 <VueButton
1925 class =" icon-button flat"
2026 icon-left =" subdirectory_arrow_left"
@@ -196,6 +202,29 @@ export default {
196202 this .$_terminal .scrollToBottom ()
197203 },
198204
205+ copyContent () {
206+ const textarea = this .$_terminal .textarea
207+ if (! textarea) {
208+ return
209+ }
210+ const textValue = textarea .value
211+ const emptySelection = ! this .$_terminal .hasSelection ()
212+ try {
213+ if (emptySelection) {
214+ this .$_terminal .selectAll ()
215+ }
216+ var selection = this .$_terminal .getSelection ()
217+ textarea .value = selection
218+ textarea .select ()
219+ document .execCommand (' copy' )
220+ } finally {
221+ textarea .value = textValue
222+ if (emptySelection) {
223+ this .$_terminal .clearSelection ()
224+ }
225+ }
226+ },
227+
199228 handleLink (event , uri ) {
200229 if (this .openLinks ) {
201230 window .open (uri, ' _blank' )
You can’t perform that action at this time.
0 commit comments