aplsimple / alited

a lite editor / IDE for Tcl/Tk projects
https://aplsimple.github.io/en/tcl/alited/
MIT License
19 stars 3 forks source link

Issue with e-menu on WSL Linux #23

Closed georgtree closed 1 month ago

georgtree commented 1 month ago

Hello! I faced with the error while using git e-menu: image

The full error stack is: can't use empty string as operand of "+" can't use empty string as operand of "+" while executing "expr {20+$x}" (procedure "callmenu" line 24) invoked from within "callmenu $typ $s1 $amp button" (procedure "::em::callmenu_button" line 4) invoked from within "{*}$comm" (procedure "::em::prButton" line 9) invoked from within "::em::prButton 23 ::em::callmenu M: m23 &" invoked from within ".em.fr.win.fr23.butt invoke" ("uplevel" body line 1) invoked from within "uplevel #0 [list $w invoke]" (procedure "tk::ButtonUp" line 22) invoked from within "tk::ButtonUp .em.fr.win.fr23.butt" (command bound to event)

Regards, George.

aplsimple commented 1 month ago

It looks like a sort of magic, as the x's value is taken from [wm geometry .em] command that should work for .em toplevel (seen on the screenshot). I never saw this in any platforms I used.

Obviously WSL Linux is of different opinion about this subject:)

Also I cannot be sure about Macs, having no access to Apple machines.

Nonetheless I've placed a checking line after the [wm geometry .em] command, hopefully it will work (though not in the intended manner).

aplsimple commented 1 month ago

George,

It would be fine if you did some work helpful for me, namely: place please a message after the "set geo [wm geometry .em]" line of e_menu.tcl, say this one:

tk_messageBox -message geo=$geo

... and tell me the output of it.

Thanks in advance.

Regards, Alex

georgtree commented 1 month ago

Hello, yes I'll do it on Monday :)

georgtree commented 1 month ago

Hello, the output is: image

aplsimple commented 1 month ago

Thank you. Very good. I'll fix this today.

aplsimple commented 1 month ago

Hopefully, fixed in v1.8.6.

On 20 July I've changed the thing a bit.

(To be honest it is the first time that I see such a manner of Tk's coordinate presentation. Never thought about it earlier and can't imagine why it had been made.)

aplsimple commented 1 month ago

George,

Could you test this issue with alited 1.8.6.2?

Ideally show please the same screenshot as the above one, updated (hopefully without the error:)

Thanks in advance.

georgtree commented 1 month ago

Hello, unfortunately problem was not solved: image Also I repeat inserting the additional command into the code: image

aplsimple commented 1 month ago

Huh, there is obviously a progress from -1076-150 to -32730-32709 :)

Well, I'll try to debug this in WSL if it is installeable on my Windows with those sanctions, donnerwetter и т.д.

aplsimple commented 1 month ago

Honestly, I don't understand what's happening with that code piece of e_menu.tcl.

I tried to imitate your case with changing geo variable and then inserting two messages:

  set geo [wm geometry .em]
set geo 316x622-1076-150
  # shift the new menu if it's shown above the current one
  catch {
    if {$::em::solo && ($noME || $::em::ontop)} {
      lassign [apave::splitGeometry $geo] - - x y negat
tk_messageBox -message "::em::callmenu 1: $x $y $negat"  ;#! TODEL
      set x [expr {20+$x}]
      set y [expr {30+$y}]
      if {$negat} {
        if {$x>=0} {set x -$x} ;# coordinates from bottom right corner
        if {$y>=0} {set y -$y}
      } else {
        if {$x<=0} {set x 0} ;# coordinates from top left corner
        if {$y<=0} {set y 0}
        set x +$x
        set y +$y
      }
      set geo $x$y
tk_messageBox -message "::em::callmenu 2: $geo"  ;#! TODEL
    }
  }

which works fine. The first message shows -1076 -150 1, the second -1056-120, both are correct as expected. Thus, no error.

Moreover, the malignant line set x [expr {20+$x}] is wrapped with catch meaning the possible exception should be caught and as such not resulting in the error of your screenshot.

Very frustrating. Am at a loss.


I'd like to ask you again to show the two tabs of Help/About... dialogue, on this specific case. Thanks in advance.

georgtree commented 1 month ago

Hello, yes I will do that, maybe I will try to test it more with additional tweaking. Maybe issue is that it is WSL and window manager sometimes is very buggy... I have no issue on Windows machine and my own Kubuntu system at home.

aplsimple commented 1 month ago

Perhaps this will be helpful.

The apave::splitGeometry procedure of apave.tcl considers two possible types of result got from [wm geometry $w] command (as mentioned in its man page):

  1. Both of coordinates X and Y begin with "+", e.g. 100x200+300+400 (it can include the negative X and/or Y e.g. for X=-30, Y=-40: 100x200+-30+-40); this case means that X and Y are the window's left top corner coordinates calculated from left top corner of the screen.

  2. Both of coordinates X and Y begin with "-", e.g. 100x200-300-400 (it can include the negative X and/or Y e.g. for X=-30, Y=-40: 100x200--30--40); this case means that X and Y are the window's right bottom corner coordinates calculated from right bottom corner of the screen.

The apave::splitGeometry accordingly separates these two cases, using [string] command instead of [regexp] just because the case is simple and regexp would be excessive for it.

georgtree commented 1 month ago

Hello! Sorry, my bad, I clear old installation of alited and install again, now version of Alited is the last version, and error doesn't appear. Thank you in advance for help!