home *** CD-ROM | disk | FTP | other *** search
/ PC Welt 2006 March / PCWELT_3_2006.ISO / base / 05_common.mo / usr / share / elvis-2.2_0 / scripts / cb.ex < prev    next >
Encoding:
Text File  |  2004-02-22  |  1.2 KB  |  57 lines

  1. " cut buffer operations: cbsave, cbload, cbshow
  2. alias cbload {
  3.  "Load cut-buffers from a file
  4.  local b report=0 magic magicchar=^$.[* noignorecase
  5.  let b=buffer
  6.  if "!1" == ""
  7.  then error cbload requires a file name
  8.  e !1
  9.  %s:^--CBS-- \([a-z]\)$:+;/^--CBS--/-1 y \1:x
  10.  eval buffer (b)
  11. }
  12.  
  13. alias cbsave {
  14.  "Save cut-buffers to a file
  15.  local a b report=0
  16.  let b = buffer
  17.  if "!1" == ""
  18.  then error cbsave requires a file name
  19.  e !1
  20.  %d
  21.  let a = 'a'
  22.  while a <= 'z'
  23.  do {
  24.   if buffer("Elvis cut buffer ";char(a))
  25.   then {
  26.    eval $ a --CBS-- (char(a))
  27.    eval $ put (char(a))
  28.   }
  29.   let a = a + 1
  30.  }
  31.  $ a --CBS--  
  32.  w!?
  33.  eval buffer (b)
  34. }
  35.  
  36. alias cbshow {
  37.  "Show contents of cut-buffers
  38.  local b c i l="!*" q u s
  39.  if l == ""
  40.  then let l = "abcdefghijklmnopqrstuvwxyz123456789"
  41.  echo Buf\| Size & Type \| Contents
  42.  echo ---+-------------+----------------------------------------------------
  43.  for i (1 .. strlen(l))
  44.  do {
  45.   let c = ((l;" ") << i) >> 1
  46.   let b = "Elvis cut buffer ";c
  47.   if buffer(b)
  48.   then {
  49.    (=b) let u = putstyle << 4;
  50.    (=b) let q = u=="char" ? bufchars - 1 : buflines
  51.    let s = q; " "; u; (q == 1 ? " " : "s")
  52.    (=b) calc " "; c; " |"; s >> 12; " | "; line(b,1) << 52
  53.   }
  54.   let i = i + 1
  55.  }
  56. }
  57.