Xref: utzoo comp.windows.open-look:307 comp.windows.x:30905 Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!zaphod.mps.ohio-state.edu!rpi!crdgw1!barnett From: barnett@grymoire.crd.ge.com (Bruce Barnett) Newsgroups: comp.windows.open-look,comp.windows.x Subject: Re: XView textsw question Message-ID: Date: 20 Dec 90 22:20:14 GMT References: <6336@pizza.cam.nist.gov> Sender: news@crdgw1.crd.ge.com Reply-To: barnett@crdgw1.ge.com Followup-To: comp.windows.open-look Organization: GE Corp. R & D, Schenectady, NY Lines: 35 In-reply-to: straw@cam.nist.gov's message of 20 Dec 90 20:57:41 GMT In article <6336@pizza.cam.nist.gov> straw@cam.nist.gov (Mike Strawbridge) writes: > I am interposing a Text Subwindow to catch mouse events in the window. In > the interposing function how can I calculate the mouse location in terms of > a character index or line index in the Text Subwindow? My xvttool program (on titan.rice.edu) does this. If you type Control-LeftButton, it sends a special sequence to the program running in the tty window. The client understands the escape sequence and positions the cursor at the location of the mouse click. (The only client that understands this so far is Mike Gerard's 3270 emulator) Here is the appropriate code. - first get the height and width of the font. font_height = (int)xv_get (terminal_sw, WIN_ROW_HEIGHT); font_width = (int)xv_get (terminal_sw, WIN_COLUMN_WIDTH); if ( debug && verbose ) Fprintf(console," Pixel Width: %d, height: %d\n", font_width, font_height); and in the event handler: (The || is because of a different between OW 2.0 pre-fcs and OW 2.0) if (event_is_button(event) && (event_left_is_down(event) || (event_id(event) == BUT(1))) && event_ctrl_is_down (event) ) { column = (event_x(event) / font_width); /* the first line would be 0 - we'll add one to it */ line = (event_y(event) / font_height) +1; if (debug) Fprintf(console, "Mouse at [%d(%d),%d(%d)]\n", line, event_y(event), column, event_x(event)); -- Bruce G. Barnett barnett@crd.ge.com uunet!crdgw1!barnett