I'm trying to modify the TgenShell class (part of the Tgen parser generator)
to add find/replace functionalilty, and I've pretty much got it working. I added an Edit menu with Find, Find Next, and Replace commands, and by basically copying what the ClassBrowserShell does I've gotten it handle the basics. The problem I'm having is that I'd like it to scroll the view with focus so the found text is visible, and I can't seem to figure out how to do this. I've scouted through the image, I've checked the Education Centre, I've searched the wiki, I've looked through MSDN, and nowhere can I find a reference to some event which gets triggered or some message sent by Windows that I can respond to to tell me that the selection in the TextView has changed after the user hits the 'Find' button on the find dialog. Can some kind soul point me in the right direction? Thank you. -- Bob Jarvis |
Bob,
> I'm trying to modify the TgenShell class (part of the Tgen parser generator) > to add find/replace functionalilty, and I've pretty much got it working. I > added an Edit menu with Find, Find Next, and Replace commands, and by > basically copying what the ClassBrowserShell does I've gotten it handle the > basics. The problem I'm having is that I'd like it to scroll the view with > focus so the found text is visible, and I can't seem to figure out how to do > this. I've scouted through the image, I've checked the Education Centre, > I've searched the wiki, I've looked through MSDN, and nowhere can I find a > reference to some event which gets triggered or some message sent by Windows > that I can respond to to tell me that the selection in the TextView has > changed after the user hits the 'Find' button on the find dialog. Can some > kind soul point me in the right direction? Thank you. From MSDN, is this what you are looking for? I don't think there are any Windows messages (events) that come in when the selection is changed though. ------------- EM_SCROLLCARET The EM_SCROLLCARET message scrolls the caret into view in an edit control. You can send this message to either an edit control or a rich edit control. To send this message, call the SendMessage function with the following parameters. SendMessage( (HWND) hWnd, // handle to destination window EM_SCROLLCARET, // message to send (WPARAM) wParam, // not used; must be zero (LPARAM) lParam // not used; must be zero ); Parameters wParam This parameter is reserved for future use. It should be set to zero. lParam This parameter is reserved for future use. It should be set to zero. Return Values The return value is not meaningful. --------------- Best Regards, Andy Bower Dolphin Support http://www.object-arts.com --- Are you trying too hard? http://www.object-arts.com/Relax.htm --- |
In reply to this post by Bob Jarvis-2
Bob,
I'm not sure if the following fits in with your problem but it might give a pointer. Evaluate all the following in a Workspace and do a search for the word "scroll". Is the lack of scrolling on the second and subsequent search the problem you want to get around?.... t := TextPresenter show: 'Multiline text'. t view canVScroll: true. t view text: 'This is a bunch of characters contauning 3 occurrences of the word scroll and spread across enough lines lines lines lines lines lines lines lines lines lines lines lines lines lines lines lines lines lines lines lines lines lines lines lines to need a scroll lines lines lines lines lines lines lines lines lines lines if you search for scroll'. t view find .... if so then there are at least two possible answers. 1) Add the following method which gets around the lack of a displayed selection. #onFind: is evaluated for each (??) search so all the override does is make sure that any selection is left visible. MultilineTextEdit>>onFind: aFindEvent super onFind: aFindEvent. self hasSelection ifTrue: [self lineScroll: (self lineFromPosition: self selectionRange first)] 2) Convert the TextPresenter.Multiline text into a RichTextPresenter.Default view, which doesn't exhibit the same problem. With the above test just replace the first line with t := RichTextPresenter show. and it should work, i.e. the found text is displayed, without needing any extra methods. Regards Ian |
"Ian Bartholomew" <[hidden email]> wrote in message news:<9jgpmk$npkr4$[hidden email]>...
> Bob, > > I'm not sure if the following fits in with your problem but it might give a > pointer. > <snip!> Ian/Andy, Despite my inability to communicate it seems that Ian managed to decipher what it was that I was looking for. I'd noticed #onFind: and tried to figure out what was going on but didn't grok it. Thanks for walking me through this. I ended up with a combination of both ideas, as follows: MultilineTextEdit>>onFind: aFindEvent | ret | ret := super onFind: aFindEvent. self sendMessage: 16rB7 "EM_SCROLLCARET" wParam: 0 lParam: 0. ^ret This doesn't seem to cause problems for RichTextEdit so I'll stick with it for now. Thanks again to both of you. -- Bob Jarvis |
In reply to this post by Bob Jarvis-2
Bob,
is it possible to get these changes if you're done? Due to STS I should be able to manage the changes. Udo Bob Jarvis wrote: > I'm trying to modify the TgenShell class (part of the Tgen parser generator) > to add find/replace functionalilty, and I've pretty much got it working. I > added an Edit menu with Find, Find Next, and Replace commands, and by > basically copying what the ClassBrowserShell does I've gotten it handle the > basics. The problem I'm having is that I'd like it to scroll the view with > focus so the found text is visible, and I can't seem to figure out how to do > this. I've scouted through the image, I've checked the Education Centre, > I've searched the wiki, I've looked through MSDN, and nowhere can I find a > reference to some event which gets triggered or some message sent by Windows > that I can respond to to tell me that the selection in the TextView has > changed after the user hits the 'Find' button on the find dialog. Can some > kind soul point me in the right direction? Thank you. > -- > Bob Jarvis |
Udo Schneider <[hidden email]> wrote in message news:<[hidden email]>...
> Bob, > > is it possible to get these changes if you're done? Due to STS I should be > able to manage the changes. I'd planned on sending you a message, but I wanted to wait until I was done...and there's always one more change... :-) I'm still in the process of making changes but I'll be happy to send you what I've got. I can email it, put it on a web page, push it to your FTP server (if you have one), or any way you'd like (as long as I can figure out how to do it!). Let me know. As a quick summary - I've only changed the T-gen-interface package, and those changes have been minor usability issues. Some of the changes (adding an Edit menu and sub-commands) have involved changing the default view on TgenShell, and I don't know how this might be integrated with your work (can STS merge view changes?). Anyways, I've got one more change I want to put in (I desperately want the ability to clear the text in the status pane - there's a TgenShell>>#clearStatus method but it doesn't appear to be used) and then I'll package it up. Just let me know how and where you'd like it delivered. -- Bob Jarvis |
Bob,
just send me the changes via mail. You're right. STS does not monitor changes in the view (or did I missed something?). But I think the view isn't so complex that one wouldn't be able to track the changes manually. Udo Bob Jarvis wrote: > Udo Schneider <[hidden email]> wrote in message news:<[hidden email]>... > > Bob, > > > > is it possible to get these changes if you're done? Due to STS I should be > > able to manage the changes. > > I'd planned on sending you a message, but I wanted to wait until I was > done...and there's always one more change... :-) I'm still in the > process of making changes but I'll be happy to send you what I've got. > I can email it, put it on a web page, push it to your FTP server (if > you have one), or any way you'd like (as long as I can figure out how > to do it!). Let me know. > > As a quick summary - I've only changed the T-gen-interface package, > and those changes have been minor usability issues. Some of the > changes (adding an Edit menu and sub-commands) have involved changing > the default view on TgenShell, and I don't know how this might be > integrated with your work (can STS merge view changes?). Anyways, > I've got one more change I want to put in (I desperately want the > ability to clear the text in the status pane - there's a > TgenShell>>#clearStatus method but it doesn't appear to be used) and > then I'll package it up. Just let me know how and where you'd like it > delivered. > -- > Bob Jarvis |
In reply to this post by Bob Jarvis-2
Bob,
> [...] The problem I'm having is that I'd like it to scroll the view with > focus so the found text is visible It's probably too late to help, but I hit the same problem and found different solution (well, it seems to work, i.e. it scrolls correctly, but I don't know why). I noticed that the ordinary workspaces scroll correctly, so I just copied #findNext, and #basicFindNext from SmalltalkWorkspace to TextPresenter (the *presenter* note, not the view), and added: TextPresenter>>find self view find. (I didn't try to make 'replace' work because I don't yet need it.) I've no idea whether this was a sensible thing to do since I've not been able to work out what's *supposed* to be happening with the find commands, and text components (I suspect that the existing code is incomplete). However, it does work... > Bob Jarvis -- chris |
"Chris Uppal" <[hidden email]> wrote in message
news:[hidden email]... > It's probably too late to help, but I hit the same problem and found > different solution (well, it seems to work, i.e. it scrolls correctly, but I > don't know why). Chris, Thanks much for the suggestion. I'll hang on to it because, as it turns out, I've thus far used all the other solutions which have been proposed, leading me to suspect that I'll eventually use yours too. :-) I initially added an #onFind: method (as suggested by Ian Bartholomew) which sent am EM_SCROLLCARET message (as suggested by Andy Bower), which worked fine, but then discovered that my grammar was overflowing a MultilineTextEdit view (and despite trying the obvious things I couldn't make it fit), so I mutated the views to RichEdit views (as suggested by Ian - although I now go back and notice he said to use a RichTextPresenter, and I'm still using a TextPresenter - <sigh>) and now all is well. Thanks very much to everyone who responded. -- Bob Jarvis |
Free forum by Nabble | Edit this page |