Loading ...
Sorry, an error occurred while loading the content.

Re: scrollwheel and fontsize

Expand Messages
  • Christian J. Robinson
    ... It s definitely possible, as long as you re willing to parse the existing guifont value for the font size so you can change it. I don t use Windows, but
    Message 1 of 3 , Feb 7 6:11 AM
    • 0 Attachment
      Today (Sat, 7 Feb 2004), Hugo Ahlenius wrote:

      > I am on windows, and I am using gvim. A lot of MS windows apps (IE,
      > Office and others) have functionality so that when holding down
      > Control and scrolling the scroll wheel you zoom in/out by
      > increasing/decreasing the font-size.
      >
      > Is that possible to implement in a script? I am not sure how the wheel
      > is handled...

      It's definitely possible, as long as you're willing to parse the
      existing 'guifont' value for the font size so you can change it.

      I don't use Windows, but I do use GTK2, so I wrote this which might
      also work for Windows (very quick and dirty):


      " Add "|| has('gui_win32')" to this if this works in windows:
      if has('gui_gtk2')
      function! ChangeFontSize(dir)
      let space = strridx(&guifont, ' ')
      let font = strpart(&guifont, 0, space)
      let size = strpart(&guifont, space + 1)

      if a:dir ==? 'bigger'
      let size = size + 1
      elseif a:dir ==? 'smaller'
      let size = size - 1
      else
      echoerr "Argument must be 'bigger' or 'smaller'."
      return
      endif

      let &guifont = font . ' ' . size
      endfunction

      nmap <silent> <C-MouseDown> :call ChangeFontSize('bigger')<CR>
      nmap <silent> <C-MouseUp> :call ChangeFontSize('smaller')<CR>
      imap <silent> <C-MouseDown> <C-O>:call ChangeFontSize('bigger')<CR>
      imap <silent> <C-MouseUp> <C-O>:call ChangeFontSize('smaller')<CR>
      vmap <silent> <C-MouseDown> <C-C>:call ChangeFontSize('bigger')<CR>gv
      vmap <silent> <C-MouseUp> <C-C>:call ChangeFontSize('smaller')<CR>gv
      endif


      - Christian

      --
      Boldly Going Nowhere
      Christian J. Robinson <infynity@...> http://infynity.spodzone.com/
      PGP key: 0x893B0EAF / 0xFB698360 http://infynity.spodzone.com/pgp
    Your message has been successfully submitted and would be delivered to recipients shortly.