Wednesday, May 13, 2015

Re: Set highlight colours according to screen

David Fishburn <dfishburn.vim <at> gmail.com> writes:
> If you "extend" your monitor, then you can use the window position to
check.
>
> I extend mine above my existing monitor (instead of beside it).
> These functions report negative values for me when I move it to the
extended monitor.
>
> getwinposx() < 0
> getwinposy() < 0
>
> You can simply check for a range of values.
>
> I also wrote a mapping to toggle my Vim session back and forth
> between the monitors (if this helps):
>
> if has("gui_running")
> " Reposition gvim when using the windows extended monitor
> " Top and bottom
> " Use negative values if screen is above main desktop.
> " Basically, position Vim and look at this output:
> " echo getwinposx() getwinposy()
>
> " nnoremap <Leader>fx :exec 'winpos '.(getwinposx()<0 ? '15' : '-
15').' '.(getwinposy()<0 ? '17' : '-1183')<CR>
> nnoremap <Leader>fx <C-O>:exec 'winpos '.(getwinposx()
<0 ? '15' : '15').' '.(getwinposy()<0 ? '40' : '-1192')<CR>
> " This version will change the font size (since the monitor is
bigger) and move the screen.
> " Had to record the X and Y positions since set guifont= will cause
the screen to move under certain cirumstances.
> nnoremap <Leader>fx :let winx = getwinposx()\|let winy = getwinposy()
\|exec 'set guifont=Bitstream_Vera_Sans_Mono:h'.
(winy<0 ? '11' : '11').':b:cANSI'\|echomsg 'executing winpos '.
(winx<0 ? '15' : '15').' '.(winy<0 ? '40' : '-1192')\|exec 'winpos '.
(winx<0 ? '15' : '15').' '.(winy<0 ? '40' : '-1192')<CR>
> " Move Vim left and right (assuming screen configuration)
> " nnoremap <Leader>fx :exec 'winpos '.(getwinposx()
<1900 ? '2055' : '276').' 14'<CR>
> " nnoremap <Leader>fx <C-O>:exec 'winpos '.(getwinposx()
<1900 ? '2055' : '276').' 14'<CR>
> endif

In my case, it's not really a screen extenxtion situation. I'm either
in the office, in which case I dock the machine and use the big
screen, or I am away from my desk, in which case I rely on the native
low-contrast screen.

It looks like writing a function is the way to go. It will consist of
a few highlighting commands. Thanks.

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments: