diff --git a/doc.h b/doc.h index 10b47002..410a3f98 100644 --- a/doc.h +++ b/doc.h @@ -1318,6 +1318,8 @@ class CMUSHclientDoc : public CDocument long m_nCount_IAC_WONT; // count of IAC WONT we got long m_nCount_IAC_SB; // count of IAC SB x IAC SE we got + CString m_strWordUnderMenu; // word under menu in output window + #ifdef PANE // for pane windows diff --git a/mushview.cpp b/mushview.cpp index 7cddf02d..2306157d 100644 --- a/mushview.cpp +++ b/mushview.cpp @@ -1891,6 +1891,49 @@ void CMUSHView::AliasMenu (CPoint point) CMUSHclientDoc* pDoc = GetDocument(); ASSERT_VALID(pDoc); + if (!pDoc->m_FontHeight) + return; + + CPoint wordPoint (point); + + // CView changes the viewport origin and mapping mode. + // It's necessary to convert the point from device coordinates + // to logical coordinates, such as are stored in the document. + CClientDC dc(this); + OnPrepareDC(&dc); + dc.DPtoLP(&wordPoint); + + int line, start_col, end_col, col; + + // find which line and column the mouse position is at + + calculate_line_and_column (wordPoint, dc, line, col, false); + + POSITION pos = pDoc->GetLinePosition (line); + + start_col = end_col = col; + + // find word under mouse for GetInfo (86) + + CLine * pLine = pDoc->m_LineList.GetAt (pos); + while (start_col >= 0 && + !isspace ((unsigned char) pLine->text [start_col]) && + strchr (App.m_strWordDelimitersDblClick, pLine->text [start_col]) == NULL) + start_col--; + start_col++; // now onto the start of that word + + // a word will end on a space, or whatever + while (end_col < pLine->len && + !isspace ((unsigned char) pLine->text [end_col]) && + strchr (App.m_strWordDelimitersDblClick, pLine->text [end_col]) == NULL) + end_col++; + + if (end_col > start_col) + pDoc->m_strWordUnderMenu = CString (&pLine->text [start_col], + end_col - start_col); + else + pDoc->m_strWordUnderMenu.Empty (); + CPoint menupoint = point; CMenu menu; @@ -1907,7 +1950,7 @@ CPoint menupoint = point; CAlias * pAlias; CString strAliasName; - for (POSITION pos = pDoc->m_AliasMap.GetStartPosition(); + for (pos = pDoc->m_AliasMap.GetStartPosition(); pos && i < MXP_MENU_COUNT; ) { diff --git a/scripting/methods/methods_info.cpp b/scripting/methods/methods_info.cpp index c91576a9..b1f8e95f 100644 --- a/scripting/methods/methods_info.cpp +++ b/scripting/methods/methods_info.cpp @@ -182,6 +182,8 @@ tInfoTypeMapping InfoTypes [] = { 83, "SQLite3 version" }, { 84, "File browsing directory" }, { 85, "State files path (directory)" }, + { 86, "Word under mouse on mouse menu" }, + @@ -538,6 +540,7 @@ VARIANT CMUSHclientDoc::GetInfo(long InfoType) case 83: SetUpVariantString (vaResult, sqlite3_libversion ()); break; case 84: SetUpVariantString (vaResult, file_browsing_dir); break; case 85: SetUpVariantString (vaResult, App.m_strDefaultStateFilesDirectory); break; + case 86: SetUpVariantString (vaResult, m_strWordUnderMenu); break; case 101: SetUpVariantBool (vaResult, m_bNoEcho); break;