mIRC Homepage
Posted By: kap .reload -rs switches focus in remote editor - 27/07/19 10:16 AM
Hi Khaled,

Not sure if this is a bug, but I figured I'd let you know about this behaviour. I've known for quite some time that it is difficult to work with a new script file in the remote editor when PnP (Peace and Protection) scripts are loaded. If you click on File > New, in a couple of seconds the remote editor tab switches focus from Remotes to Users, preventing you from working with a new script file. (or save it)

PnP has an internal timer running and takes action if (*last.mrc !iswm $script($script(0)) and then proceeds to reload that file at the end.

Basically, to replicate, in a new mirc environment, try the following steps:

1. You have this in remote.ini: (basically make sure remote.ini exists in the scripts\ directory and is the only script file loaded)

Code
alias hw echo -a Hello World!


2. Add this content to aliases.ini:

Code
_timer.on .timer.internal -io 0 10 _internal.timer
_internal.timer {
  if (*remote.ini !iswm $script($script(0))) _screload
}
_screload {
  if ($exists(scripts\remote.ini) == $false) halt
  echo 4 -a Script load detected $+ $chr(44) reordering scripts
  .reload -rs $+ $calc($script(0) + 1) "scripts\remote.ini"
}


3. Run /_timer.on

4. Open remote editor and click on File > New

best regards,

kap
Just to be more descriptive, this has the potential to be destructive of the contents of the users tab, depending on whether you've started typing into the new script without having saved to create a disk file at some point.

When this timer executes, the glitch happens if the remotes window is the active tab, and it's looking at a window created with file/new but hasn't yet been saved as a disk file. And it won't let you create a diskfile until you actually start typing content other than blank lines since it always strips blank lines from the end of a scriptfile.

When the timer executes the reload, if the active window hasn't been created as a disk file, that new window is removed from the list of remote scripts in the "view" dropdown, and the focus shifts to the Users tab. If there's nothing to save to disk, the focus is simply shifted to the users tab. But if there is something to write to disk, it autosaves the content in the newly created (but now vanished) remotes window to the filename of the active users window.
Thanks this issue has been fixed for the next version.
© mIRC Discussion Forums