NSIS: Maximize/Minimize Button event Handling - event-handling

I want to know how can I handle the event when I click the maximize button(I have enabled it already) of my nsis dialog.
I want to perform some other dialog element resizing every time I click maximize button, and restore when its minimized.
So, how can I achieve it???
Please help.
Thanks in advance.

NSIS was really not designed to handle re-sizable dialogs.
The only way to catch a size event would be to use a plugin. You could write your own custom plugin or try the experimental WndSubclass plugin, either way you pretty much need to know a bit about the Windows API to do this...
Edit:
!include nsDialogs.nsh
!include WinCore.nsh
!include WndSubclass.nsh
!macro _Win_HIWORD_FIXED _outvar _in
IntOp ${_outvar} "${_in}" >> 16 ;sign extended
${LOWORD} ${_outvar} ${_outvar} ;make sure we strip off the upper word
!macroend
!undef HIWORD
!define HIWORD "!insertmacro _Win_HIWORD_FIXED "
Var ParentSubProc
Function ParentSubProc
${If} $2 = ${WM_SIZE}
${LOWORD} $1 $4
${HIWORD} $2 $4
${NSD_SetText} $hwndparent "Size: $1 x $2"
${EndIf}
FunctionEnd
Function .onGuiInit
${NSD_AddStyle} $hwndparent 0x70000
${WndSubclass_Subclass} $hwndparent ParentSubProc $ParentSubProc $ParentSubProc
FunctionEnd

Related

Reuse old buffer for the same command in VIM for competitive programming

Recently I've been into VIM and had many attempts to use it for competitive programming. So I tried google stuffs for information and up until now I've gathered codes from other's .vimrc while avoid using plugins (for some specific reasons). So finally I'm now using a pretty decent compile function that I borrowed from Mr.Michael Lan. Now part of my .vimrc look like this :
function! TermWrapper(command) abort
if !exists('g:split_term_style') | let g:split_term_style = 'vertical' | endif
if g:split_term_style ==# 'vertical'
let buffercmd = 'vnew'
elseif g:split_term_style ==# 'horizontal'
let buffercmd = 'new'
else
echoerr 'ERROR! g:split_term_style is not a valid value (must be ''horizontal'' or ''vertical'' but is currently set to ''' . g:split_term_style . ''')'
throw 'ERROR! g:split_term_style is not a valid value (must be ''horizontal'' or ''vertical'')'
endif
exec buffercmd
if exists('g:split_term_resize_cmd')
exec g:split_term_resize_cmd
endif
exec 'term ' . a:command
exec 'setlocal nornu nonu'
exec 'startinsert'
autocmd BufEnter <buffer> startinsert
endfunction
let g:split_term_style = 'vertical'
let g:split_term_resize_cmd = 'vertical resize 80'
command! -nargs=0 CompileAndRun call TermWrapper(printf('g++ -std=c++11 %s && ./a.out', expand('%')))
autocmd FileType cpp nnoremap <leader>fw :CompileAndRun<CR>
As you can see, if I try :CompileAndRun, it will open a new buffer to the right side of my screen, run the .cpp file, etc ... But there is one problem I'm having with this. If you try :CompileAndRun for the second time, it will open a new buffer to run instead of using the old one, which I find ... annoying (well it kinda bug you if your screen for the main cpp file keep getting smaller and smaller, especially in a running contest am I right ?). And I don't see deleting these buffers manually as an option, as it is not very convenient. So can any of you guys help me to cope with this tedious task. Remember that I still want to keep using the :CompileAndRun command, and just want to reuse the buffer opened by the previous command.

MIRC, Ignoring " | " when reading a text file?

in my MIRC script, it is set up to read a text file, in these text files there is the symbol " | " followed by a space on both ends, it seems to read everything before " | " just fine, but cuts it off right at the first space. Any help is appreciated.
I am using
msg $nick $read(test.txt, n, 1)
to read the text file.
EDIT:: I have tried all switches which result in the same thing.
EDIT:: It also tells me in the server window "Unknown Command"
EDIT:: After making a new pastebin uploading script, it still seems to get that issue? It will completely just cut off the rest of the text after a "&" or " | "
The symptoms is matching to a scenario which $read was evaluated to a command and the result will take the separators as set of commands to be executed.
This can be due to aliases or events.
Try the first /play command, which will play the file from the 3rd line to see if it behaving as the line we expect it to be or instead each line as a set of commands, separated by /
Then perform the 2nd /play command to view how it should been send to the server.
This is design to see where the problem lie.
/play -axl3 echo test.txt
/play -exl3 test.txt
The output should be the same and as we expect it with the line being displayed including |.
This will make sure the problem is to blame upon other corrupt aliases or events.
We will perform the following and after each step you will test you code to see if it was solved.
Test to see if it an alias named msg hurt you, by converting your script command to /!msg $nick$read(test.txt, n, 1).
Check for dangerous events such as the infamous INPUT or the rising bandit PARSELINE by disabling them.If the problem solved then return the events one by one the find the problematic event and fix it.
Due to the lack of a responses/answers, I was unable to solve it, I have made a makeshift fix for this issue by using
play -xl# $nick test.txt
rather than
msg $nick $read(test.txt, n, 1)
I had almost the same problem and was able to solve it, using the same solution, try this:
Your previous script was: msg $nick $read(test.txt, n, 1)
Now remove the 'msg $nick' and add that to the beginning of every line in the text.txt file with a space between 'msg $nick' and the rest of the line, i.e : msg $nick Hey I see you are back | msg $nick Missed You!
Then your script becomes: $read(test.txt, p)
^^ Hope that makes sense, but I found the original issues was Double Evaluation hence why sometimes you would see the error: Unknown Command or something along those lines.

Call custom vim completetion menu with Information from Perl-Script

I wrote a script analyzing perl-files (totally without PPI, because it will be used on Servers where the admins don't want PPI to be installed and so on and so forth, but let's not talk about that).
Now, let's say I have this code:
my $object = MySQL->new();
my $ob2 = $object;
$ob2->
(Where MySQL is one of our modules).
My script correctly identifies that $ob2 is a MySQL-Object and sees where it came from, and then returns a list of found subs in that module.
My idea was, that, since I use vim for editing, this could be a really cool way for "CTRL-n"-Completetion.
So, when...
$ob2->[CTRL-n]
It shows the CTRL-n-Box which opens my Perl-Script and gives it a few parameters (I would need: The line that I am actually on, the cursor position and the whole file as it is in vim).
I already found things like vim-perl, which allows me to write something like
if has('perl')
function DefPerl()
perl << EOF
use MyModule;
return call_to_my_function(); # returns all the methods from the object for example
EOF
endfunction
call DefPerl()
endif
But somehow this does not get executed (I tried writing something to a file with a system call just for the sake of testing)...
So, in short:
Does anyone here know how to achieve that? Calling a perl-function from vim by pressing CTRL-n with the full file-code and the line vim is actually in and the position, and then opening a completetion-menu with the results it got from the perl-script?
I hope someone knows what I mean here. Any help would be appreciated.
The details and tips for invoking embedded Perl code from Vim can be found in this Vim Tips Wiki article. Your attempts are already pretty close, but to return stuff from Perl, you need to use Vim's Perl API:
VIM::DoCommand "let retVal=". aMeaningfullThingToReturn
For the completion menu, your Perl code needs to return a List of Vim objects that adhere to the format as described by :help complete-items. And :help complete-functions shows how to trigger the completion. Basically, you define an insert-mode mapping that sets 'completefunc' and then trigger your function via <C-x><C-u>. Here's a skeleton to get your started:
function! ExampleComplete( findstart, base )
if a:findstart
" Locate the start of the keyword.
let l:startCol = searchpos('\k*\%#', 'bn', line('.'))[1]
if l:startCol == 0
let l:startCol = col('.')
endif
return l:startCol - 1 " Return byte index, not column.
else
" Find matches starting with a:base.
let l:matches = [{'word': 'example1'}, {'word': 'example2'}]
" TODO: Invoke your Perl function here, input: a:base, output: l:matches
return l:matches
endif
endfunction
function! ExampleCompleteExpr()
set completefunc=ExampleComplete
return "\<C-x>\<C-u>"
endfunction
inoremap <script> <expr> <Plug>(ExampleComplete) ExampleCompleteExpr()
if ! hasmapto('<Plug>(ExampleComplete)', 'i')
imap <C-x><C-z> <Plug>(ExampleComplete)
endif

How to do escaping in this Perl code?

#!/usr/bin/perl
use warnings;
system ("dialog --menu Customize 10 70 50 'Flush rules' 'Clear all the rules' 'Show rules' 'Shows the current rules' 2> /tmp/tmp.txt ")
I want to write the above code in a more readable form like this
#!/usr/bin/perl
use warnings;
system ("dialog --menu Customize 10 70 50
'Flush rules' 'Clear all the rules'
'Show rules' 'Shows the current rules'
'more options' '........' 2> /tmp/tmp.txt ")
How can I do this?
Perl provides a string concatentation operator that you can use to build up big strings:
system ( "dialog --menu Customize 10 70 50 "
. "'Flush rules' 'Clear all the rules' "
. "'Show rules' 'Shows the current rules' "
. "'more options' '........' 2> /tmp/tmp.txt ");
system can take #args (array form):
system ( 'dialog', #args );
system ( "dialog --menu Customize 10 70 50 "
. "'Flush rules' 'Clear all the rules' "
. "'Show rules' 'Shows the current rules' "
. "'more options' '........' 2> /tmp/tmp.txt ");
Dang, tadmc is fast. Yes, use the . concatenation command.
I would recommend that you create your command in a separate string and then execute that. I also recommend using the qq command to do quoting. That way, you don't have to worry about single vs. double quotes:
my $command = qq(dialog --menu Customize 10 70 50 )
. qq("Flush rules" 'Clear all the rules' )
. qq('Show rules' 'Shows the current rules' )
. qq'more options' '........' 2> /tmp/temp.$$ );
my $error = system $command;
Using qq allows you not to worry about whether I need to use double quotes to allow for variable interpolation or single quotes, or having to escape quotes. For example, I was able to mix double and single quotes, and I can use Perl variables without worrying whether or not I have to change from single to double quotes. For example, I use /tmp/temp.$$. The $$ is the process ID, so if this command is executed twice, there are two different temp files used.
By creating a separate variable for my command, I can now use it later -- like if there was an error in my system command.
By the way, you should always check the return of your system command. There's probably a good chance that if for some reason you can't execute your system command, you probably want to error out or at least note the issue.
One of the problems is that the output of the system command is the opposite of most Perl functions. In most Perl functions, a return of zero indicates a failure while a return of non-zero indicates success. However, the system function is the exact opposite. Zero means success, non-Zero means failure.
That can lead to strange if constructs:
if (system $command) {
die qq(Can't execute command "$command"\n);
};
This looks like I'm saying that if my system command succeeds, I should die, but it really means the same as this:
my $error = system $command;
if ($error) {
die qq(Can't execute command "$command"\n);
}
That syntactically makes a lot more sense.

Vimperator pass-through/unset <C-Tab> by default

By default is mapped to gt command, which selects next tab. I want to pass-through to Crtl+Tab plugin which does MRU for tabs.
Any idea?
Since you want to pass-through, use:
:map <C-Tab> i<C-Tab>
you can map C-Tab to gt command and, maybe, Control-Shift-Tab to gT command.
:inoremap <C-Tab> gt
:inoremap <C-S-Tab> gT
save your vimperatorrc with :mkvimperatorrc!
1) Use pentadactyl instead of vimperator. (pentadactyl is a fork of vimperator)
2) put in ~/_pentadactylrc the following:
nm <C-Tab> <Pass>
nm <C-S-Tab> <Pass>
Then pentadactyl will pass these events directly to Firefox.