Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!ucbvax!bloom-beacon!dprg-330.GOVt.shearson.COM!fgreco From: fgreco@dprg-330.GOVt.shearson.COM (Frank Greco) Newsgroups: comp.windows.x Subject: Re: XView textsw question Message-ID: <9012241529.AA21480@fis1.> Date: 24 Dec 90 15:29:28 GMT Sender: daemon@athena.mit.edu (Mr Background) Organization: The Internet Lines: 37 > > 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? > This is determined from the XY of the mouse and the font dimensions (mostly just the font height) of the TEXTSW's font. e.g., To get the on-screen line number, call this little ditty from your event proc, passing the view and the mouse XY. int getscreenline(tswv, x, y) Textsw tswv; /* Which text subwindow (view) */ int x, y; /* Coordinates of mouse */ { Xv_font font; /* Font of the textsw */ Font_string_dims strdims; if ( !(font = (Xv_font) xv_get(tswv, TEXTSW_FONT)) ) return -1; (void) xv_get(font, FONT_STRING_DIMS, "abcde", &strdims); return y / strdims.height; } Of course, you add the line # of the first viewable line in the TEXTSW to this number to get the overall line #. Getting the character index is done similarly. Frank G.