def toggleSelectionSensitiveActions(view): doc_type = view.document().highlightingMode() clnt = kate.getXmlGuiClient() has_selection = view.selection() if doc_type in ['C++', 'C++/Qt4', 'JavaScript'] and not has_selection: clnt.stateChanged('doxygen_actions') else: clnt.stateChanged('doxygen_actions', KXMLGUIClient.StateReverse) if common.isKnownCommentStyle(doc_type) and not has_selection: clnt.stateChanged('comment_actions_no_selection') else: clnt.stateChanged('comment_actions_no_selection', KXMLGUIClient.StateReverse)
def toggleDocTypeSeisitiveActions(): view = kate.activeView() if view is None: return doc_type = view.document().highlightingMode() kate.kDebug('toggleDocTypeSeisitiveActions: doc_type={}'.format(doc_type)) clnt = kate.getXmlGuiClient() if doc_type in ['C++', 'C++/Qt4', 'C']: clnt.stateChanged('if0_actions') else: clnt.stateChanged('if0_actions', KXMLGUIClient.StateReverse) if common.isKnownCommentStyle(doc_type): clnt.stateChanged('comment_actions') else: clnt.stateChanged('comment_actions', KXMLGUIClient.StateReverse)
def toggleSelectionSensitiveActions(view): clnt = kate.getXmlGuiClient() filename = _try_make_url_from_text(view.selectionText()) kate.kDebug('Original new filename: {}'.format(repr(filename))) if view.selection() and len(filename) < _SANE_URI_LENGTH: clnt.stateChanged('has_selection') # Change action text... if _URI_LENGTH_SHOW_THRESHOLD < len(filename): lead_pos = int(2 * _URI_LENGTH_SHOW_THRESHOLD / 3) tail_pos = -int(_URI_LENGTH_SHOW_THRESHOLD / 3) filename = filename[:lead_pos] + '...' + filename[tail_pos:] assert('Sanity check' and hasattr(tryOpen, 'action')) kate.kDebug('New filename: {}'.format(filename)) tryOpen.action.setText( i18nc('@ation:inmenu', 'Open <filename>%1</filename>', filename) ) else: clnt.stateChanged('has_selection', KXMLGUIClient.StateReverse) tryOpen.action.setText(i18nc('@ation:inmenu', 'Open selected document'))
def toggleSelectionSensitiveActions(view): clnt = kate.getXmlGuiClient() if not view.selection(): clnt.stateChanged('has_no_selection') else: clnt.stateChanged('has_no_selection', KXMLGUIClient.StateReverse)