Script Library: 1238 scripts
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

Archive version of: klipper.r ... version: 1 ... piotrgapinsk 18-Feb-2005

Amendment note: new script || Publicly available? Yes

REBOL [
  Title: "linux/kde clipboard handler"
  Purpose: "Share clipboard between KDE klipper and Rebol"
  Author: "Piotr Gapinski"
  Email: {news [at] rowery! olsztyn.pl}
  File: %klipper.r
  Date: 2005-02-17
  Version: 0.1.0
  Copyright: "Olsztynska Strona Rowerowa http://www.rowery.olsztyn.pl/"
  License: "GNU Lesser General Public License (Version 2.1)"
  Library: [
    level: 'intermediate
    platform: 'all
    type: [protocol tool]
    domain: [protocol]
    tested-under: [
      view 1.2.48 on [Linux]
    ]
    support: none
    license: 'LGPL
  ]
]

make root-protocol [
  scheme: 'kde
  port-id: 8883
  port-flags: system/standard/port-flags/direct
  awake: none

  open-check: none
  init: func [port] [none] ;[print "init"]
  open: func [port] [none] ;[print "open"]
  close: func [port] [none] ;[print "close"]
  insert: func [port] [none] ;[print "insert"]
  copy: func [port] [none] ;[print "copy"]
  read: func [port data [string!]] [
    port/state/inBuffer: make string! 100
    call/wait/output "dcop klipper klipper getClipboardHistoryItem 0" port/state/inBuffer
    ;; call/wait/output "dir" port/state/inBuffer
    port/state/num: port/state/tail: length? port/state/inBuffer
    append data port/state/inBuffer
    system/words/write clipboard:// data
    ;; print ["read" length? data trim/tail data]
  ]
  write: func [port data] [
    ;; print ["write" data]
    call/wait rejoin [{dcop klipper klipper setClipboardContents "} form data {"}]
    system/words/write clipboard:// data
  ]
  net-utils/net-install :scheme self :port-id
]

comment {  
; example
  dat: read kde://
  write kde:// {rebol clipboard}
}