jkh@meepmeep.pcs.com (Jordan K. Hubbard) (08/24/89)
I have an application where I need to display a file (quickly) in a widget and hilight a line in it under program control. I also need to allow the user to scroll through this file, perhaps clicking on a line of particular interest (which will become the highlighted line). I decided to use an asciiStringWidget for this and quickly noticed a few things that it would be handy to have. 1. When the user clicks on a line, I need to know what line was clicked. I've defined my own selectionType array that disallows all but line selection, but querying the selection only gives me start and ending character positions. Given that the text widget keeps an internal line table, it seems a real shame that I have to duplicate its work by building a line table of my own and translating the start/end positions into a line number by brute force. This also keeps me from using an asciiDiskWidget, which is a lot closer to what I want in the first place. Likewise, when I want to highlight a line, I cannot do it except by means of my own internal table. 2. There doesn't seem to be any way of calling the action proceedures under program control. This would be useful. Jordan PCS Computer Systeme GmbH, Munich, West Germany UUCP: pyramid!pcsbst!jkh jkh@meepmeep.pcs.com EUNET: unido!pcsbst!jkh ARPA: jkh@violet.berkeley.edu or hubbard@decwrl.dec.com
kit@EXPO.LCS.MIT.EDU (Chris D. Peterson) (08/25/89)
> 1. When the user clicks on a line, I need to know what line was clicked. I've > defined my own selectionType array that disallows all but line selection, > but querying the selection only gives me start and ending character > positions. Given that the text widget keeps an internal line table, it > seems a real shame that I have to duplicate its work by building a line > table of my own and translating the start/end positions into a line number > by brute force. The line table kept by the text widget does not contain the line number from the top of the file, it only contains the lines that are currently visable on the screen. There is no quick method for determining which line is currently visable. > 2. There doesn't seem to be any way of calling the action proceedures > under program control. This would be useful. A generic method of doing this will be avaliable in the R4 Xt Intrinsics. > I have an application where I need to display a file (quickly) in > a widget and hilight a line in it under program control. I also need > to allow the user to scroll through this file, perhaps clicking on > a line of particular interest (which will become the highlighted line). If you are not interested in editing the file perhaps you would be better served by using a List widget. If you force it to one column, and break your file up into an array of strings (1 per line) then the list widget will highlight by line, and return the item number (which is really the line number) to you quite quickly. Remember, all text need not use the Text widget :-) Chris D. Peterson MIT X Consortium Net: kit@expo.lcs.mit.edu Phone: (617) 253 - 9608 Address: MIT - Room NE43-213