Open ReneFroger opened 10 years ago
Maybe anyone have an idea on this?
I could not reproduce this issue.
I tested using my Macbook Pro with different resolutions - maximum 2880x1800. I normally use guifont h13
.
At this moment, I could not think of any reason that font size can be related to this plugins.
echo GoldenView#Info()
and paste the output. It may help me to get some hints. Thanks for your reply! I'm not able to test this at this moment, but when I'm back home today, I will let you know what the test results are.
@zhaocai
Thanks for the patience. I have created a video where I'm explaining my issue. With empty vimrc and another plugins disabled, it seems I'm still having issues, that the resizing is not working.
When I have smaller viewport, Goldenview worked again. I can believe it is unclear to explain it. So I made a video to make it clear.
Any thoughts?
Thanks in advance
@ReneFroger
I understand your issue. However, this issue does not recur in my vim environment. I cannot debug it. So you will have to provide more info.
Please type the command echo GoldenView#Info()
and show me the output:
a. when it is working b. when it is not working
@zhaocai , excuse for my late response. Busy with work. To answer your question:
I use Haroogan's Vim binary for Windows, my Gvim version is 7.4 32-bit, included patches 1-193.
a. When it is working:
{'goldenview;' : {'nrwin': 2, 'bufs': {'1': {'winr':2, 'winehieght': 23, 'winwidth': 49}}, 'cmdheight': 1}, 'setting': {'lazyredraw' : 0, 'win_count': 2, 'winminwidth': 10, 'winheight' : 15, 'winfixheight' : 0, 'winminheight' : 1, 'cmdheight': 1, 'winwdith': 49, 'winfixwidth': 0, 'winminheight': 1, 'cmdheight' : 1, 'winwidth': 49, 'winfixwidth': 0}, 'buffer': {'bufname': '', 'winheight': 23, 'filetype': '', 'buftype': '', 'winwidth' : 49 }}
b. When it is not working (after resizing):
{'goldenview;' : {'nrwin': 2, 'bufs': {'1': {'winr': 2, 'wineheight': 54, 'winwidth': 49}}, 'cmdheight': 1}, 'setting': {'lazyredraw' : 0, 'win_count': 2, 'winminwidth': 10, 'winheight' : 15, 'winfixheight' : 0, 'winminheight' : 1, 'cmdheight': 1, 'winwdith': 49, 'winfixwidth': 0, 'winminheight': 1, 'cmdheight' : 1, 'winwidth': 49, 'winfixwidth': 0}, 'buffer': {'bufname': '', 'winheight': 54, 'filetype': '', 'buftype': '', 'winwidth' : 140 }}
I typed it over. From the info is in 2b, I have resized it in width, the second buffer is larger in width, but GoldenView is not working anymore. Thanks in advance for your help, much appreciated.
@ReneFroger
Please type command echo &columns
and show the output for case a and b.
@zhaocai, as my pleasure! Output of command echo &columns
2a. When it is working:
80
2b. When it's not working:
150
And another test, when I'm going further with larger window.
175
how about echo GoldenView#TextWidth()
Output of command echo GoldenView#TextWidth()
2a. When it is working:
49
2b. When it's not working anymore:
106
try let &winwidth = 106
in case 2b. Does the window size change? if not, try to increase and decrease 106.
When I add let &winwidth = 106, the window changes when switchting from window! It's working properly now, seems you found a fix for this issue! :tada:
Any idea how we could make this automatically?
try autocmd VimResized
. One possible cause is that this autocommand is not implemented in the vim
Output when I'm typing :autcmd VimResized (no splitting windows opened):
--- Auto-Commands ----
GoldenView VimRezied
* call GoldenView#Enter{{'event' : 'VimResized'})
So propably the autocommand for GoldenView is already implemented. In my Vim, the autocommand works fine for another thins in my Vimrc. Any idea why the autocommand is not working properly for GoldenView?
Have you remote desktop by any chance?
Ok, I changed this:
if !&winfixwidth || opts['force']
let &winwidth =
\ s:eval(a:profile, a:profile['focus_window_winwidth'])
endif
To
if !&winfixwidth || opts['force']
let old_winwidth = &winwidth
let &winwidth =
\ s:eval(a:profile, a:profile['focus_window_winwidth'])
call GoldenView#zl#print#echomsg('winwidth from: ' . old_winwidth . ' to ' . &winwidth)
endif
When I start Vim again, I get the message:
winwidth from: 49 to 49
do you get the same message when you resize?
try echo eval(function('GoldenView#TextWidth'))
To your first question, yes, I get the same message.
If I'm not wrong, I start Vim, which is usually in small window. I get the message. When I resize again, and then I type :message, I still see same message in command line.
Your second question:
I open Vim, then two splitted windows. Keep in mind that the implemented changes above between if & ends are still in plugin. I type :echo eval(function('GoldenView#TextWidth'))
I get the error E729, funcref using as a String (translated from Dutch). And below the value 0.
After resizing to a larger window, I still get the same message.
Any chance you're working on Windows now?
OK. I found the problem. Basically, the vim you are using does not allow Funcref
( reference to function ) to be dynamically evaluated. I do not know if this is limited to all vim in Windows platform or just to your build. You may try to install other vim build
eval({string}) Evaluate {string} and return the result. Especially useful to
turn the result of |string()| back into the original value.
This works for Numbers, Floats, Strings and composites of
them. Also works for |Funcref|s that refer to existing
functions.
< *E745* *E728* *E703* *E729* *E730* *E731*
List, Dictionary and Funcref types are not automatically converted.
Thanks for your answer, it's clear now. I will look for another Vim build for Windows platform.
Many many thanks for all your time you're trying to help me! :)
If other vim build does not work, we can try to bypass dynamic funcref evalution.
I already asked Haroogan's if there is any chance that he could compile Gvim with funcref evalution. :)
https://bitbucket.org/Haroogan/vim-for-windows/issue/8/please-update-to-the-latest-patch-74393
I am not sure if this issue is related to latest patch. In the mean time, you can try to find all s:eval
in Line 350, 354, 372, 376, and replace s:eval
with direct function call.
For example, change
let &winwidth =
\ s:eval(a:profile, a:profile['focus_window_winwidth'])
to
let &winwidth = GoldenView#TextWidth()
The default profile dictionary is defined in line 43
\ 'default' : {
\ 'focus_window_winheight' : function('GoldenView#GoldenHeight') ,
\ 'focus_window_winwidth' : function('GoldenView#TextWidth') ,
\ 'other_window_winheight' : function('GoldenView#GoldenMinHeight') ,
\ 'other_window_winwidth' : function('GoldenView#GoldenMinWidth') ,
\ },
I changed it into the following, from line 347:
try
if !&winfixwidth || opts['force']
let &winwidth = GoldenView#TextWidth()
endif
if !&winfixheight || opts['force']
let &winheight = GoldenView#TextWidth()
endif
catch /^Vim\%((\a\+)\)\=:E36/ " Not enough room
call GoldenView#zl#print#warning('GoldenView2: ' . v:exception)
endtry
endfunction
function! s:set_other_window(profile,...)
let opts = {
\ 'force' : 0
\ }
if a:0 >= 1 && GoldenView#zl#var#is_dict(a:1)
call extend(opts, a:1)
endif
try
if !&winfixwidth || opts['force']
let &winminwidth = GoldenView#TextWidth()
endif
if !&winfixheight || opts['force']
let &winminheight = GoldenView#TextWidth()
endif
catch /^Vim\%((\a\+)\)\=:E36/ " Not enough room
call GoldenView#zl#print#warning('GoldenView1: ' . v:exception)
endtry
endfunction
When saving, and starting Gvim again, I get an error message from the latest try (marked as GoldenView1) that there would be not enough room?
you should check the profile definition.
let &winheight = GoldenView#TextWidth()
should be let &winheight = GoldenView#GoldenHeight()
....and so on...
What do you mean by
the vim you are using does not allow Funcref ... to be dynamically evaluated
I used the following exampe:
fu! g:MyFunc()
echom "TEST 1234"
endfu
let g:Func=function('g:MyFunc')
echo eval(g:Func)
I always get error E729. So what do you think is the error? I can't seem to reproduce what you want to make work.
What works however is :echo eval(g:Func())
so you might need to add some () to your eval() calls.
Thanks for your comment, Chrisbra! Your thoughts are much appreciated, I will try it tomorrow! (hell of busy work lately....)
@zhaocai
I would like to thank you for your time. I replaced the lines with the profile definition. It is not working, unfortunately.
But I noticed something. GoldenView is not working, when I have a empty Vimrc and one plugin.
But when I load my another plugins, and my Vimrc. Goldenview is now working? But I still I still get same problem, as pointed out here.
But one thing is different. Instead font size 10 (h10), it will work properly only on the font size h8. (on a 2560x1600 display), it is working properly. But when I change the font to h12, the adjacent window will be so small that it's unsuitable.
I'm wondering if I'm clear enough (English is not my first language), or you need a video?
@chrisbra and @ReneFroger
You are right. I forgot the () for funcref. You should test echo eval(function('GoldenView#TextWidth')())
or echo function('GoldenView#TextWidth')()
@ReneFroger
But one thing is different. Instead font size 10 (h10), it will work properly only on the font size h8. (on a 2560x1600 display), it is working properly. But when I change the font to h12, the adjacent window will be so small that it's unsuitable.
Font is not the root cause! GoldenView seems to work for smaller font because the value returned from function evaluation of GoldenView#TextWidth
is a small number on error (exception).
Sorry for belated answer, due to personal issues in family. Thanks for your reply, zhaocai! With both commands echo eval(function('GoldenView#TextWidth')())
and echo function('GoldenView#TextWidth')()
I got 240 in both cases as result.
Any tips how I could use that number in order to solve this issue? Thanks in advance!
try set textwidth=80
We're close to a solution, @zhaocai zhaocai!
Now I don't get the issue of small windows anymore! :+1: (Textwidth
was set on 180
earlier).
But it is not working entirely properly. When I set the font size on h15, I get clear difference in width ratio between the inactive window and active window. This will increase further on font size 16/17/18.
But when I set the font size on h14, the difference in ratio will be smaller. I always work with font size 12. But there is so small difference in ratio between the inactive and active window (some of 5 pixels difference, I guess).
How enable proper ratio when there are (smaller than font size 15) default font sizes set?
Thanks in advance for your kind help!
Not any idea? I know I ask too much here. I understand that the font was not causing this problem. But when I set the textwidth on other sizes, it didn't help eiter.
Sorry for my poor English. And I would like to thank you for creating such an awesome plugin.
Unfortunately, I have serious issues with the plugin. It makes me sad, because I'm switching the windows very often.
Problem: GoldenView is only working properly (displaying the right aspect ratio) when the fontsize is small and unreadable. When I change the fontsize, GoldenView is not displaying the right ratio anymore.
I have 2 systems. One system with a display resolution of 2560x1600. Called display 1. Another system with a display resolution of 1920x1080. I call this display 2. The problem is with different font size on each display.
Environment Information
Maybe the issue will be more clear when I'm explaining it with screenshots.
Display 1 (2560x1600)
On display one (2560x1600), font size 10.
GoldenView is displaying the right ratio.
Then I am switching to adjacent window, from main view:
The display ratio is still right. But the letters were too small to be readable. When I'm setting guifont on h11, the letters are more readable. But the display ratio is very wrong now:
When I am switching to another window:
When I set the guifont on h12, the problem is getting worser. The adjacent or the main window will be so small, that you can't read nothing there. I get same problem with h8, h9, h13, h14, h15, and so on.
And the problem is getting more weird:
Display 2 (1920x1080) On display two, the font size is 10 too (both systems use the same Vimrc).
But the ratio's are wrong. The adjacent window or the main window will be too small to be useful. When I change the fontsize to 8, suddenly the display ratio is good again. Unfortunately, the fontsize is so tiny to be readable. When I change the font size to another sizes, the issue will not change. GoldenView is only displaying the right ratio on font size 8.
When I have same Vimrc loaded on display 1 (2560x1600), GoldenView is displaying the wrong ratio on font size 8. On display 2 (1920x1080), it was displaying the right ratio. When I change the font size again to 10, GoldenView is displaying the good ratio again. But the letters are still too small to be readable.
I tried various ways to solve this. I tried an another option too, from another issue: https://github.com/zhaocai/GoldenView.Vim/issues/5#issuecomment-16910190
So I changed the number 2 of other_window_winheight to different numbers. But I get an error, the command was not recognized. I didn't changed anything than only the number.
I need this plugin so bad. How can I solve this? Anyone have a suggestion?