mIRC Home    About    Download    Register    News    Help

Print Thread
Minor Issue #198374 27/04/08 03:20 PM
Joined: Aug 2005
Posts: 1,052
L
Lpfix5 Offline OP
Hoopy frood
OP Offline
Hoopy frood
L
Joined: Aug 2005
Posts: 1,052
Code:
dialog notepad {
  title "Notepad Editor"
  size -1 -1 181 197
  option dbu
  edit "", 1, 0 10 181 189, multi return autohs autovs hsbar vsbar
  edit "", 4, 80 0 56 10
  text "Filename:", 5, 55 1 24 8
  menu "File", 8
  item "Open", 14, 8
  item "Close", 13, 8
  item "Save", 15, 8
  item "Save As", 16, 8
  menu "Edit", 9
  item "Replace", 10, 9
  item "Copy (Ctrl + C)", 11, 9
  item "Paste (Ctrl + V)", 12, 9
  menu "Help", 6
  item "About", 7, 6
}

alias note { dialog -m notepad notepad }
alias xrep { return $read(temp.txt,w,$+(*,$did(replace,1).text,*),$1) }

on *:DIALOG:notepad:init:0:{
  did -a $dname 1 Click Open File to open any readable text format such has txt wpd etc..
}

on *:dialog:notepad:menu:10:{
  dialog -m replace replace
  var %num = 1
  while (%num <= $did($dname,1).lines) {
    write temp.txt $did($dname,1,%num).text $crlf
    inc %num
  }
}

on *:DIALOG:notepad:menu:11:{
  echo -a Copying all information in Notepad Editor
  .clipboard
  var %num = 1
  while (%num <= $did($dname,1).lines) {
    clipboard -na $did($dname,1,%num)
    inc %num
  }
}

on *:dialog:notepad:menu:12:{
  var %num = 1
  while (%num <= $cb(0)) {
    did -a $dname 1 $cb(%num) $crlf
    inc %num
  }
}

on *:dialog:notepad:menu:13:{
  dialog -x notepad
}

on *:dialog:notepad:menu:14:{
  did -r $dname 1
  var %nsel = $sfile(C:\) , %num = 1
  did -ra $dname 4 $nopath(%nsel)
  while (%num <= $lines(%nsel)) {
    did -a $dname 1 $read(%nsel,%num) $crlf
    inc %num
  }
}

on *:dialog:notepad:menu:15:{
  var %num = 1 , %ndir = $sdir(C:\)
  if ($did($dname,4).edited == $true) { 
    var %nedit = $did($dname,4).text 
    if ($exists($+(%ndir,%nedit)) == $true) {
      if ($?!="Do you wish to overwrite file?" == $true) {
        remove $+(%ndir,%nedit)
        clear -s
        while (%num <= $did($dname,1).lines) {
          write -a $+(%ndir,%nedit) $did($dname,1,%num) $crlf
          inc %num
        }
      }
      else { halt } 
    }
    else {
      while (%num <= $did($dname,1).lines) {
        write -a $+(%ndir,%nedit) $did($dname,1,%num) $crlf
        inc %num
      }
    }
  }
}

dialog replace {
  title "Replace (notepad)"
  size -1 -1 155 65
  option dbu
  edit "", 1, 42 4 65 10
  edit "", 2, 42 16 65 10
  text "Find What:", 3, 6 5 27 8
  text "Replace With:", 4, 6 17 35 8
  box "", 5, 2 -2 110 35
  box "", 6, 113 -2 40 66
  box "", 7, 115 0 36 62
  button "Find Next", 8, 117 5 32 12, disable flat
  button "Replace", 9, 117 19 32 12, flat
  button "Replace All", 10, 117 33 32 12, flat
  button "Cancel", 11, 117 47 32 12, flat
  box "", 12, 2 31 110 33
  text "This Script is purely Beta I hold no responsibility to damaged files during replace token. This is intetionally meant to edit mIRC scripts or documents.", 13, 3 35 107 27
}

on *:dialog:replace:sclick:8:{
  did -c notepad 1 $didwm(notepad,1,$+(*,$did(replace,1).text,*))
}

on *:dialog:replace:sclick:9:{
  did -r notepad 1
  if ($did($dname,1).edited) && ($did($dname,2).edited) {
    var %rep = $xrep(1) , %num = 1
    write -l $+ $readn temp.txt $replace($xrep(1),$did($dname,1),$did($dname,2).text)
    while (%num <= $lines(temp.txt)) {    
      did -a notepad 1 $read(temp.txt,%num) $crlf
      inc %num
    }
    dialog -x $dname
    remove temp.txt
    clear -s
  }
  else { echo -a Sorry you have NOT entered any information for me to replace }
}

on *:dialog:replace:sclick:10:{
  did -r notepad 1
  if ($did($dname,1).edited) && ($did($dname,2).edited) {  
    :START    
    if (!$xrep(1)) {
      goto END
    }
    else {
      var %rep = $xrep(1) , %num = 1
      write -l $+ $readn temp.txt $replace($xrep(1),$did($dname,1),$did($dname,2).text)
      goto START
      :END
      while (%num <= $lines(temp.txt)) {    
        did -a notepad 1 $read(temp.txt,%num) $crlf
        inc %num
      }
      remove temp.txt
      dialog -x $dname
      clear -s
    }
  }
  else { echo -a Sorry you have NOT entered any information for me to replace }
}

on *:dialog:replace:sclick:11:{
  dialog -x replace
}

on *:dialog:replace:close:0:{
  remove temp.txt
  clear -s
}


Here is the whole script im trying to make it look as close as possible to notepad for windows.

Anyhoo my issue is if you click on the MENU, EDIT, CTRL + C it will copy the whole thing but what im trying to accomplish here is selection only which in theory I would use

$did($dname,1).seltext and copy that to clipboard what im having issues with is that everytime I make a selection that command removes all spacers and crams everything togheter meaning that if...

A file is like this

P.S < > means start and end of selection

Hello <my name is george

I am a monkey> from the distance future

Instead of copying to clipboard

my name is george

I am a money

it copies it like this my name is george I am a monkey

Im trying to copy it the same route as I see it

I managed to load any text files as it is and using the replace function as is but im having tons of issues with the Copying part


Code:
if $reality > $fiction { set %sanity Sane }
Else { echo -a *voices* }
Re: Minor Issue [Re: Lpfix5] #198399 27/04/08 07:21 PM
Joined: Jul 2006
Posts: 3,927
W
Wims Offline
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,927
Code:
on *:DIALOG:notepad:menu:11:{
  echo -a Copying all information in Notepad Editor
  .clipboard
  var %num = 1
  echo -a $did(1).seltext
  clipboard -na $did(1).seltext
  ; while (%num <= $did(1).lines) {
  ; echo -a $v2
  ;  clipboard -na $did($dname,1,%num).seltext
  ;inc %num
  ;}
}
I think it's good with this smile


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Re: Minor Issue [Re: Wims] #198443 28/04/08 06:57 PM
Joined: Aug 2005
Posts: 1,052
L
Lpfix5 Offline OP
Hoopy frood
OP Offline
Hoopy frood
L
Joined: Aug 2005
Posts: 1,052
Yup thanks smile


Code:
if $reality > $fiction { set %sanity Sane }
Else { echo -a *voices* }