Changeset View
Changeset View
Standalone View
Standalone View
src/worksheet.cpp
Show First 20 Lines • Show All 1159 Lines • ▼ Show 20 Line(s) | 1156 | { | |||
---|---|---|---|---|---|
1160 | if(expr==nullptr) | 1160 | if(expr==nullptr) | ||
1161 | return; | 1161 | return; | ||
1162 | 1162 | | |||
1163 | //We're only interested in help results, others are handled by the WorksheetEntry | 1163 | //We're only interested in help results, others are handled by the WorksheetEntry | ||
1164 | for (auto* result : expr->results()) | 1164 | for (auto* result : expr->results()) | ||
1165 | { | 1165 | { | ||
1166 | if(result && result->type()==Cantor::HelpResult::Type) | 1166 | if(result && result->type()==Cantor::HelpResult::Type) | ||
1167 | { | 1167 | { | ||
1168 | QString help = result->toHtml(); | 1168 | QString help = static_cast<Cantor::HelpResult*>(result)->plain(); | ||
1169 | //TODO: Do we need this replacing? | ||||
1169 | //Do some basic LaTeX replacing | 1170 | //Do some basic LaTeX replacing | ||
1170 | help.replace(QRegExp(QLatin1String("\\\\code\\{([^\\}]*)\\}")), QLatin1String("<b>\\1</b>")); | 1171 | // help.replace(QRegExp(QLatin1String("\\\\code\\{([^\\}]*)\\}")), QLatin1String("<b>\\1</b>")); | ||
1171 | help.replace(QRegExp(QLatin1String("\\$([^\\$])\\$")), QLatin1String("<i>\\1</i>")); | 1172 | // help.replace(QRegExp(QLatin1String("\\$([^\\$])\\$")), QLatin1String("<i>\\1</i>")); | ||
1172 | 1173 | | |||
1173 | emit showHelp(help); | | |||
1174 | 1174 | | |||
1175 | //TODO: break after the first help result found, not clear yet how to handle multiple requests for help within one single command (e.g. ??ev;??int). | 1175 | QTextDocument* doc = new QTextDocument(); | ||
1176 | doc->setPlainText(help); | ||||
1177 | | ||||
1178 | // Use new highlighter, because m_highlighter store some worksheet-depend information, | ||||
1179 | // like variable list, user defined list, etc. | ||||
1180 | // TODO: For example, MaximaHighlighter get user variable list from parent session, so how handle it? | ||||
1181 | // create new session for help request? | ||||
1182 | // or create empty session in Worksheet constructor? | ||||
1183 | // or pass some flag (withoutState, for example) in syntaxHighlighter function? | ||||
1184 | // TODO: add variable parsing for highlighting variables defined inside help? | ||||
1185 | QSyntaxHighlighter* highlighter = m_session->syntaxHighlighter(this); | ||||
1186 | Cantor::DefaultHighlighter* hl = qobject_cast<Cantor::DefaultHighlighter*>(highlighter); | ||||
1187 | if (hl) | ||||
1188 | hl->highlightHelpDocument(doc); | ||||
1189 | highlighter->deleteLater(); | ||||
1190 | | ||||
1191 | emit showHelp(doc); | ||||
1192 | | ||||
1176 | break; | 1193 | break; | ||
1177 | } | 1194 | } | ||
1178 | } | 1195 | } | ||
1179 | } | 1196 | } | ||
1180 | 1197 | | |||
1181 | void Worksheet::removeCurrentEntry() | 1198 | void Worksheet::removeCurrentEntry() | ||
1182 | { | 1199 | { | ||
1183 | qDebug()<<"removing current entry"; | 1200 | qDebug()<<"removing current entry"; | ||
▲ Show 20 Lines • Show All 759 Lines • Show Last 20 Lines |