Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

mouse over which cursor position (col, row)

Status
Not open for further replies.

adambrums

Instructor
Jun 13, 2006
11
US
At work we use a sybase dbisqlc to enter sql commands etc...I've gotton all the keys to work however some of the people here use Putty (a terminal emulator) instead of procomm because of it's mouse support...What I mean is that in putty there is a File Edit menu.. This is like a windows style menu and in putty you can click on the File menu a it drops down a box with options etc..however in procomm it doesn't work....I'm guessing it works it putty because of putty's support of xterm sytle menus...which I don't think is possible in procomm...however what I'm trying to do is write a script in procomm that will immitate this behavior...I've found ways to see where the mose is using LMOUSEEVENT etc...and I known which cols rows the Word File Edit etc will always been on the screen...however I can't seem to find a way that will correspond the x y coords of those mouse commands in procomm to the corresponcding cursor position...If somone could help figure out that once peice I should have hte probem solved...the getcur statement only returns the current col,row but can anyone think of create workaround so that when somone clicks with the left mouse button I get cet the row col of where they clicked and then I could say that if it's a certain col,row range then that would send the keyboard keys to drop down that menu?
 
Unfortunately, if xterm is involved, this mapping attempt will not work as what you are getting is the local cursor coordinates and not the remote cursor coordinates. Procomm can only handle "straight" terminal emulation and does not support xterm.

 
So is the any way to determine which col,row the mouse is over when the left mouse button is pressed?
 
Not that I am aware of. The $LMOUSEX and $LMOUSEY system variables can be checked for the X and Y values in the Procomm window, but there is not a way to map those to a row and column.

 
That's what I was afraid of ....you think this could work?...one idea I had was that since I know what the menu's at the top would alwasy says..for instance File Edit Commands etc...I could have a when target that when you double click on the Word .. with the left mouse be default this sends that text to the host system..and since the host system echos that command bacy the when target with the strip option would keep it from appearing on the screen..and in the proc that's called from the when statement it would then send the keyboard keystrokes to like ctrl+a then hit the letter f which would then bring down the file menu...and of course for each option in the file menu I would have a smilar proc....of course it would have to take into consideration that the submenu items on the file menu etc would only be active when the file menu is open etc.....it might be tricky but I think I might be able to come up with something like that...and to the user it would be transparent and they would simply think the menu system is working in procomm...i woudl only have to let them know to double click on items in the menu instread of the normal single click thereby transmitting that text which my script would caputre and act accordingly....that should work right?
 
I just wrote a quick script which showed me that the x and y coordinates from $LMOUSEX and Y are absolute, and not relative to the Procomm window. That's difficult. Maybe if those coordinates could be put in relation to procomm's terminal window it would them be possible to calculate the row and column of the window.

If you think of something, let me know, I've been after this feature too (however I'm using WYSE 50/60 emulation; it shouldn't matter thought)

proc main
integer x,y
string statString

while 1
x = $lmousex
y = $lmousey
strfmt statstring "X: %i - Y: %i" x y
statmsg statString

yield
endwhile

endproc
 
I figured out that you can make the mouse coords relative to a particular window id....which I found here:

aspect mousecoord window | SCREEN

Specifies which window ID that the mouse coordinates will be relative to. SCREEN is the default.

so know that and that $PWMAINWIN is the window id of the procmm screen I came up with this:

set aspect mousecoord $PWMAINWIN

which does work...however I can't figure out a way to correspond the mouse coords with the procomm window to a particlar row or col because the number of pixels in a row or col rectangle area vary base on the the font size and the screen size ..also like most people I have my procmm font set to scale automaticaly on reize...so as you resize the procomm window the font get smaller or bigger and thus chaning the amount of pixel in each col, row.....however one interesting thing I noticed was this:

If you hit alt+/ (that's alt plus the forward slash key) procmm will show you the exact width and height of of the current font size in pixels ....if anyone knows of a way to get those values using a script then I could get this to work
 
This displays the mouse coordinates and row and column coordinates. However, the only elements of the script that aren't automatically configure are the pixel width and height of the terminal area.

One possible solution: if we had the window width and length, then we could derive the terminal window dimensions (which seem to be proportional) because this script needs the terminal window minimum and maximum coordinates. Other things to consider are if any toolbars are present (i believe a toolbar takes up 100 pixels) and hwo the "terminal fonts" is configured in the Options->Data Options->Terminal Fonts section of procomm's setup.

This below script update the status bar at the bottom up a left click. To make it work for you, you would have to manually change the minimum and maximum coordinates at the beginning of the script.

Let me know if comments in the code would help.

-dan hazer
--(dhazer at gmail dot com)



integer totalNumOfRows, totalNumOfCols
proc main
integer cursorx, cursory, minY, maxY, minX, maxX
integer totalXPixels, totalYPixels
string statString
float cursorColFloat, cursorRowFloat
integer cursorRow, cursorCol

minX = 30
minY = 100
maxX = 1200
maxY = 820

totalXPixels = maxX - minX
totalYPixels = maxY - minY

set aspect mousecoord $PWMAINWIN

fetch terminal rows totalNumOfRows
fetch terminal columns totalNumOfCols

;cellWidth = totalXPixels / totalNumOfCols
;cellHeight = totalYPixels / totalNumOfRows

while 1
cursorx = $lmousex
cursory = $lmousey

cursorColFloat = ((cursorx - minX)* totalNumOfCols) / (totalXPixels )
cursorRowFloat = ((cursory - minY) * totalNumOfRows)/ (totalYPixels )

floor cursorColFloat cursorCol
floor cursorRowFloat cursorRow

strfmt statstring "X: %i Y: %i --- Row: %i Col: %i" cursorx cursory cursorRow cursorCol
statmsg statstring

yield
endwhile
endproc
 
Thanks for all your help dhazer..I've almost got the script complete...It automatically caculates the width height of the terminal windows by detecting which tools bars are present font size status bar etc....and it also takes into account different screen resolutions which is important when you've got procomm setup to make the fonts a ceratain percentage of the terminal window upon resize.....I'll post as soon as its done
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top