Feature #5050 2010-07-01 08:56
weiti83
Add Current Selection to the Macros
We needed for an external Tool the current Selection of the active editor as argument. Is it possible to add this to the trunk?
- Category
- Status
- Open
- Close date
- Assigned to
History
weiti83 2010-07-01 08:57
Diff: Index: macrosmanager.cpp =================================================================== --- macrosmanager.cpp (Revision 6378) +++ macrosmanager.cpp (Arbeitskopie) @@ -155,6 +155,27 @@ m_Macros[_T("WORKSPACEDIRECTORY")] = m_WorkspaceDir; } +wxString GetSelectedText() +{ + cbEditor* ed = Manager::Get()->GetEditorManager()->GetBuiltinActiveEditor(); + if (ed) + { + cbStyledTextCtrl* stc = ed->GetControl(); + wxString text = stc->GetSelectedText(); + if ( text.size() ) + { + return text; + } + else + { + int iCurrentPos = stc->GetCurrentPos(); + return stc->GetTextRange(stc->WordStartPosition(iCurrentPos, true), stc->WordEndPosition(iCurrentPos, true)); + } + } + + return wxT(""); +} + void MacrosManager::RecalcVars(cbProject* project, EditorBase* editor, ProjectBuildTarget* target) { m_ActiveEditorFilename = wxEmptyString; // invalidate @@ -340,6 +361,8 @@ temp_str.Printf(_T("%d"), (m_ActiveEditorColumn>0) ? m_ActiveEditorColumn-1 : -1); // zero based, but keep value for "invalid" m_Macros[_T("ACTIVE_EDITOR_COLUMN_0")] = temp_str; + m_Macros[_T("ACTIVE_EDITOR_SELECTION")]=GetSelectedText(); + wxDateTime now(wxDateTime::Now()); m_Macros[_T("TDAY")] = now.Format(_T("%Y%m%d")); m_Macros[_T("TODAY")] = now.Format(_T("%Y-%m-%d"));
weiti83 2010-07-01 08:57
Diff: Index: edit_tool.xrc =================================================================== --- edit_tool.xrc (Revision 6378) +++ edit_tool.xrc (Arbeitskopie) @@ -108,6 +108,7 @@ $${ACTIVE_EDITOR_FILENAME} $${ACTIVE_EDITOR_LINE} ($${ACTIVE_EDITOR_LINE_0}) $${ACTIVE_EDITOR_COLUMN} ($${ACTIVE_EDITOR_COLUMN_0}) +$${ACTIVE_EDITOR_SELECTION} $${ALL_PROJECT_FILES} $${TARGET_OUTPUT_DIR} $${TARGET_NAME} @@ -150,4 +151,4 @@ </object> </object> </object> -</resource> \ No newline at end of file +</resource>