Exemple #1
0
/*
 * show all the commands supported by KTextEditor
 * It's a debug function
 */
void EditorPage::aboutCommand()
{
    KTextEditor::Editor *editor = m_pDoc->editor();
    KTextEditor::CommandInterface *iface = qobject_cast<KTextEditor::CommandInterface *>(editor);

    if (iface == NULL) {
        qDebug("CommandInterface cast failed");
        return;
    }

    QString msg;
    const QString cmd("set-tab-width");
    KTextEditor::Command *pcmd = iface->queryCommand(cmd);
    QStringList list = pcmd->cmds();

#if 0
    for (int i = 0; i < list.size(); i++)
        qDebug("cmd: %s", list[i].toAscii().data());
#endif

    if (pcmd) {
        pcmd->help(m_pView, cmd, msg);
        qDebug("%s", msg.toAscii().data());
    } else {
        qDebug("no this cmd");
    }
}
void EditorPage::setTabWidth(uint nTabWidth)
{
	KTextEditor::CommandInterface *pCmdIf;
	KTextEditor::Command *pKateCmd;
	QString sCmd, sResult;

	pCmdIf = qobject_cast<KTextEditor::CommandInterface *>(KTextEditor::EditorChooser::editor());
	if ( pCmdIf && (pKateCmd = pCmdIf->queryCommand("set-tab-width"))) {
		sCmd.sprintf("set-tab-width %u", nTabWidth);
		pKateCmd->exec(m_pView, sCmd, sResult);
	}
}
Exemple #3
0
// set Tab charactor's width (4 / 8 or else)
void EditorPage::setTabWidth(uint nTabWidth)
{
    KTextEditor::Editor *editor = m_pDoc->editor();
    KTextEditor::CommandInterface *iface = 
        qobject_cast<KTextEditor::CommandInterface *>(editor);

	QString sCmd, sResult;
    const QString cmd("set-tab-width");
    KTextEditor::Command *pCmd = iface->queryCommand(cmd);

    if (pCmd) {
		sCmd.sprintf("set-tab-width %u", nTabWidth);
		if (pCmd->exec(m_pView, sCmd, sResult) == false) {
            qDebug("set tab width failed: %s", sResult.toAscii().data());
        }
    } else {
        qDebug("no this cmd");
    }
}