Public paste
CB Edit form NoName Script
By: cbedit | Date: Mar 22 2011 02:06 | Format: None | Expires: never | Size: 9.69 KB | Hits: 567

  1. ; 末末末末末末末末末末末末末末末末末末末末
  2. ; NNScript by ESNation v4.22 - clipboard editor - coded by greeny & mute
  3. ; Don't edit anything in here unless you REALLY know what you're doing!
  4. ; 末末末末末末末末末末末末末末末末末末末末
  5. alias cbedit { nndlg -m cbedit }
  6. dialog cbedit {
  7.   title "Clipboard editor [/cbedit]"
  8.   size -1 -1 498 380
  9.   option pixels
  10.   icon scriptspicsnntray.ico
  11.   edit "", 1, 2 0 494 312, multi return autohs autovs hsbar vsbar
  12.   edit "", 20, 282 316 66 22, read center
  13.   text "lines", 21, 354 320 24 14
  14.   edit "", 22, 394 316 66 22, read center
  15.   text "bytes", 23, 464 320 28 14
  16.   button "C&opy", 3, 4 352 80 24
  17.   button "&Paste", 5, 88 352 80 24
  18.   button "&Re-load", 29, 184 352 80 24
  19.   button "&Close", 4, 414 352 80 24
  20.   box "", 2, -10 338 520 80
  21.   text "Amount of data currently in the clipboard:", 24, 4 320 206 16
  22.   menu "&File", 6
  23.   item "Copy &file to clipboard", 70, 6
  24.   item "&Save clipboard to file", 30, 6
  25.   item break, 31, 6
  26.   item "C&opy data to clipboard", 11, 6
  27.   item "&Reload clipboard content", 16, 6
  28.   item break, 28, 6
  29.   item "&Close", 8, 6
  30.   menu "&Edit clipboard", 7
  31.   item "&Add line numbers", 25, 7
  32.   item break, 26, 7
  33.   item "&Remove tokens", 10, 7
  34.   item "R&emove empty lines", 31, 7
  35.   item "Remove &lines containing...", 46, 7
  36.   item "Remove lines &not containing...", 47, 7
  37.   item break, 32, 7
  38.   menu "Str&ip codes", 9, 7
  39.   item "&All", 12, 9
  40.   item break, 13, 9
  41.   item "&Bold", 14, 9
  42.   item "&Color", 15, 9
  43.   item "Reset", 48, 9
  44.   item "&Reverse", 17, 9
  45.   item "&Underline", 18, 9
  46.   item break, 45, 7
  47.   menu "S&ort", 38, 7
  48.   menu "&Numerical", 42, 38
  49.   item "&Ascending (0-9)", 43, 42
  50.   item "&Descending (9-0)", 44, 42
  51.   item "&Ascending (A-Z)", 39, 38
  52.   item "&Descending (Z-A)", 40, 38
  53.   item break, 49, 7
  54.   item "Convert to lo&wercase", 33, 7
  55.   item "Convert to u&ppercase", 34, 7
  56.   item break, 37, 7
  57.   item "&Break lines", 50, 7
  58.   item "&Trim lines", 52, 7
  59.   item break, 60, 7
  60.   item "Replace strin&g", 61, 7
  61.   item break, 51, 7
  62.   item "Searc&h", 36, 7
  63.   item "&Select all", 41, 7
  64.   item break, 35, 7
  65.   item "&Clear clipboard", 27, 7
  66. }
  67. alias cbedit.cpfile {
  68.   var %f = $$sfile(C:*.txt)
  69.   loadbuf -ro cbedit 1 %f
  70.   cbedit.copy
  71.   idialog File %f copied to clipboard.
  72. }
  73. alias cbedit.opentmp { .fopen -o tmp scriptstxtcbedit.tmp }
  74. alias cbedit.closetmp {
  75.   loadbuf -ro cbedit 1 scriptstxtcbedit.tmp
  76.   did -c cbedit 1 1
  77.   .fclose tmp
  78.   tryremove scriptstxtcbedit.tmp
  79. }
  80. alias cbedit.cupper {
  81.   tokenize 32 $1-
  82.   if ($1 == 1) { did -r cbedit 1 }
  83.   did -a cbedit 1 $replace($upper($2-),,ワ,,レ,,ル,,ロ,,ト,,チ,,タ,,ツ,,ヨ,,モ,,メ,,ヤ) $+ $crlf
  84. }
  85. alias cbedit.clower {
  86.   tokenize 32 $1-
  87.   if ($1 == 1) { did -r cbedit 1 }
  88.   did -a cbedit 1 $replace($lower($2-),ワ,,レ,,ル,,ロ,,ト,,チ,,タ,,ツ,,ヨ,,モ,,メ,,ヤ,) $+ $crlf
  89. }
  90. alias cbedit.strip {
  91.   tokenize 32 $1-
  92.   if ($1 == 1) { did -r cbedit 1 }
  93.   if (o isin %cbedit.strip) { did -a cbedit 1 $strip($remove($2-,),%cbedit.strip) $+ $crlf }
  94.   else { did -a cbedit 1 $strip($2-,%cbedit.strip) $+ $crlf }
  95. }
  96. alias cbedit.break {
  97.   tokenize 32 $1-
  98.   if ($1 == 1) { did -r cbedit 1 }
  99.   var %i = 1,%z = $len($2-)
  100.   while (%i <= %z) {
  101.     did -a cbedit 1 $mid($2-,%i,%cbedit.break) $+ $crlf
  102.     inc %i %cbedit.break
  103.   }
  104. }
  105. alias cbedit.trim {
  106.   tokenize 32 $1-
  107.   if ($1 == 1) { did -r cbedit 1 }
  108.   did -a cbedit 1 $left($2-,%cbedit.trim) $+ $crlf
  109. }
  110. alias cbedit.falias {
  111.   did -h cbedit 1
  112.   filter -ink cbedit 1 $1-
  113.   did -fvc cbedit 1 1
  114. }
  115. alias cbedit.replace {
  116.   tokenize 32 $1-
  117.   if ($1 == 1) { did -r cbedit 1 }
  118.   did -a cbedit 1 $replace($2-,%cbedit.replace.1,%cbedit.replace.2) $+ $crlf
  119. }
  120. alias cbedit.paste {
  121.   if ($istok(channel query chat,$window($active).type,32)) {
  122.     window -a $active
  123.     .com.sendkeys ^V
  124.     .timer 1 0 dialog -v cbedit
  125.   }
  126.   else { errdialog you can't paste in $active $+ ! }
  127. }
  128. on *:dialog:cbedit:*:*:{
  129.   if ($devent == init) {
  130.     .timercbedit.ref -imo 0 100 cbedit.refcount
  131.     cbedit.refcount
  132.     cbedit.load
  133.   }
  134.   elseif ($devent == sclick) {
  135.     if ($did == 3) { cbedit.copy }
  136.     elseif ($did == 4) { cbedit.close }
  137.     elseif ($did == 29) { cbedit.load }
  138.     elseif ($did == 5) { cbedit.paste }
  139.   }
  140.   elseif ($devent == menu) {
  141.     if ($did == 8) { cbedit.close }
  142.     elseif ($did == 70) { cbedit.cpfile }
  143.     elseif ($did == 11) { cbedit.copy }
  144.     elseif ($did == 16) { cbedit.load }
  145.     elseif ($did == 41) { did -c $dname 1 1 1 -1 }
  146.     elseif ($did == 39) { filter -ioct 1 32 $dname 1 $dname 1 }
  147.     elseif ($did == 40) { filter -iocte 1 32 $dname 1 $dname 1 }
  148.     elseif ($did == 43) { filter -ioctu 1 32 $dname 1 $dname 1 }
  149.     elseif ($did == 44) { filter -ioctue 1 32 $dname 1 $dname 1 }
  150.     elseif ($did == 46) { filter -iocx $dname 1 $dname 1 $+(*,$$eddialog(Delete all lines containing the following string:),*) }
  151.     elseif ($did == 47) { filter -ioc $dname 1 $dname 1 $+(*,$$eddialog(Delete all lines except those containing the following string:),*) }
  152.     elseif ($did == 36) {
  153.       var %s = $$eddialog(What do you want to search for?)
  154.       if ($didwm(cbedit,1,$+(*,%s,*),1)) {
  155.         var %i = $v1,%l = $pos($did(1,%i),%s,1)
  156.         did -c $dname 1 %i %l $calc(%l + $len(%s))
  157.       }
  158.       else { idialog No occurences of $qt(%s) found. }
  159.     }
  160.     elseif ($did == 34) { cbedit.falias cbedit.cupper }
  161.     elseif ($did == 33) { cbedit.falias cbedit.clower }
  162.     elseif ($did == 50) {
  163.       set %cbedit.break $$eddialog(After how many characters do you want lines to be broken up?,80)
  164.       cbedit.falias cbedit.break
  165.       unset %cbedit.break
  166.     }
  167.     elseif ($did == 52) {
  168.       set %cbedit.trim $$eddialog(After how many characters do you want lines to be trimmed?,80)
  169.       cbedit.falias cbedit.trim
  170.       unset %cbedit.trim
  171.     }
  172.     elseif ($did == 31) { filter -iocxg $dname 1 $dname 1 /^[s]*$/ }
  173.     elseif ($did == 25) { filter -inco $dname 1 $dname 1 }
  174.     elseif ($istok(12 14 15 17 18 48,$did,32)) {
  175.       set %cbedit.strip $replace($did,12,burc,14,b,15,c,17,r,18,u,48,o)
  176.       cbedit.falias cbedit.strip
  177.       unset %cbedit.strip
  178.     }
  179.     elseif ($did == 27) {
  180.       if (!$did(cbedit,1).edited) || (($did(cbedit,1).edited) && ($ydialog(Do you really want to discard the changes you made to the clipboard?))) {
  181.         did -rj $dname 1
  182.         clipboard
  183.       }
  184.     }
  185.     elseif ($did == 10) { noop $dialog(cbedit.remtok,cbedit.remtok,-4) }
  186.     elseif ($did == 61) { noop $dialog(cbedit.replace,cbedit.replace,-4) }
  187.     elseif ($did == 30) {
  188.       var %f = $relpath($$sfile($mircdir $+ clipboard.txt,Where do you want to save the clipboard?,Save))
  189.       if (!$isfile(%f)) || ($ydialog(The file $nopath(%f) already exists! Do you want to overwrite it?)) {
  190.         did -j cbedit 1
  191.         savebuf -o $dname 1 %f
  192.         idialog Clipboard saved to %f $+ .
  193.       }
  194.     }
  195.   }
  196. }
  197. dialog cbedit.replace {
  198.   title "Clipboard editor - replace strings"
  199.   size -1 -1 288 90
  200.   option pixels
  201.   icon scriptspicsnntray.ico
  202.   box "", 1, -6 48 302 60
  203.   text "String to be replaced", 2, 6 8 106 16
  204.   text "New string", 3, 6 32 60 16
  205.   edit "", 4, 122 4 164 22, autohs limit 100
  206.   edit "", 5, 122 28 164 22, autohs limit 100
  207.   button "&Ok", 6, 120 62 80 24, ok
  208.   button "&Cancel", 7, 204 62 80 24, cancel
  209. }
  210. on *:dialog:cbedit.replace:*:*:{
  211.   if ($devent == sclick) && ($did == 6) {
  212.     set %cbedit.replace.1 $did(4)
  213.     set %cbedit.replace.2 $did(5)
  214.     cbedit.falias cbedit.replace
  215.     unset %cbedit.replace.?
  216.   }
  217. }
  218. dialog cbedit.remtok {
  219.   title "Clipboard editor - remove tokens"
  220.   size -1 -1 240 104
  221.   option pixels
  222.   icon scriptspicsnntray.ico
  223.   box "", 1, -6 62 254 62
  224.   text "Token number(s) to remove (single number or range)", 2, 6 8 140 30
  225.   text "Token separator", 3, 6 44 88 16
  226.   edit "", 4, 156 4 80 22, center
  227.   combo 5, 156 40 80 166, size limit 1 drop
  228.   button "&Ok", 6, 72 76 80 24
  229.   button "&Cancel", 7, 156 76 80 24, cancel
  230. }
  231. on *:dialog:cbedit.remtok:*:*:{
  232.   if ($devent == init) {
  233.     did -a $dname 4 1
  234.     did -a $dname 5 [tab]
  235.     var %i = 32,%z
  236.     while (%i < 256) {
  237.       %z = ""
  238.       if (%i = 32) { %z = [space] }
  239.       elseif (%i = 160) { %z = [hard space] }
  240.       else { %z = $chr(%i) }
  241.       did -a $dname 5 %z
  242.       inc %i
  243.     }
  244.     did -c $dname 5 2
  245.   }
  246.   elseif ($devent == sclick) && ($did == 6) {
  247.     if (!$regex($did(4),/^[d-]+$/)) { errdialog you have to enter a number or number range! }
  248.     else {
  249.       cbedit.opentmp
  250.       var %i = 1,%t = $did(cbedit,1).lines,%z,%ch = $iif($did(5).sel > 1,$calc($v1 +30),9)
  251.       while (%i <= %t) {
  252.         %z = $deltok($did(cbedit,1,%i),$did(4),%ch)
  253.         if ($spcnull(%z)) { .fwrite -n tmp $cr }
  254.         else { .fwrite -n tmp %z }
  255.         inc %i
  256.       }
  257.       dialog -c $dname
  258.       cbedit.closetmp
  259.     }
  260.   }
  261. }
  262. alias cbedit.copy {
  263.   did -fj cbedit 1
  264.   .com.sendkeys ^{HOME}+^{END}^C^{HOME}
  265.   cbedit.refcount
  266. }
  267. alias cbedit.refcount {
  268.   if ($dialog(cbedit)) {
  269.     if (!$cb(0).len) { did -ra cbedit 20,22 0 }
  270.     else {
  271.       if ($did(cbedit,20) != $bytes($cb(0),b)) { did -ra cbedit 20 $v2 }
  272.       if ($did(cbedit,22) != $bytes($cb(0).len,b)) { did -ra cbedit 22 $v2 }
  273.     }
  274.   }
  275.   else { .timercbedit.ref off }
  276. }
  277. alias cbedit.load {
  278.   if (!$did(cbedit,1).edited) || (($did(cbedit,1).edited) && ($ydialog(Do you really want to discard the changes you made to the clipboard?))) {
  279.     did -rf $dname 1
  280.     .com.sendkeys ^V
  281.     .timer 1 0 cbedit.refcount $chr(124) did -j $dname 1 $chr(124) did -c $dname 1 1
  282.   }
  283. }
  284. alias cbedit.close {
  285.   if ($did(cbedit,1).edited) { if ($ydialog(Do you really want to discard the changes you made to the clipboard?)) { dialog -x cbedit } }
  286.   else { dialog -x cbedit }
  287. }
  288. ; 末末末末末末末末末末末末末末末末末末末末
  289. ; End of file
  290. ; 末末末末末末末末末末末末末末末末末末末末