| 182 | } |
| 183 | |
| 184 | void ScopyJS::hasText() |
| 185 | { |
| 186 | QTextStream in(stdin); |
| 187 | QTextStream out(stdout); |
| 188 | |
| 189 | QString str = in.readLine(); |
| 190 | js_cmd.append(str); |
| 191 | |
| 192 | qWarning() << str; |
| 193 | unsigned int nb_open_braces = js_cmd.count(QChar('{')); |
| 194 | unsigned int nb_closing_braces = js_cmd.count(QChar('}')); |
| 195 | |
| 196 | if(nb_open_braces == nb_closing_braces) { |
| 197 | QJSValue val = m_engine.evaluate(js_cmd); |
| 198 | |
| 199 | if(val.isError()) { |
| 200 | out << "Exception:" << val.toString() << Qt::endl; |
| 201 | } else if(!val.isUndefined()) { |
| 202 | out << val.toString() << Qt::endl; |
| 203 | } |
| 204 | |
| 205 | js_cmd.clear(); |
| 206 | out << "scopy > "; |
| 207 | } else { |
| 208 | js_cmd.append(QChar('\n')); |
| 209 | |
| 210 | out << "> "; |
| 211 | } |
| 212 | |
| 213 | out.flush(); |
| 214 | } |
| 215 | |
| 216 | void ScopyJS::jsCategoryFilter(QLoggingCategory *category) |
| 217 | { |