Skip to content

Commit e7f3786

Browse files
author
Dominic Price
committed
Allow console resizing and handling LaTeX output
1 parent 90091dd commit e7f3786

File tree

6 files changed

+345
-238
lines changed

6 files changed

+345
-238
lines changed

client_server/ComputeThread.cc

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -311,11 +311,11 @@ void ComputeThread::on_message(websocketpp::connection_hdl hdl, message_ptr msg)
311311
else
312312
cell_id.created_by_client=false;
313313
// std::cerr << "received cell with id " << cell_id.id << std::endl;
314-
if (parent_id.id == interactive_cell) {
314+
if (interactive_cells.find(parent_id.id) != interactive_cells.end()) {
315+
interactive_cells.insert(cell_id.id);
315316
docthread->on_interactive_output(root);
316-
console_child_ids.push_back(cell_id.id);
317-
}
318-
else if (cell_id.id == interactive_cell || std::find(console_child_ids.begin(), console_child_ids.end(), parent_id.id) != console_child_ids.end()) {
317+
}
318+
else if (interactive_cells.find(cell_id.id) != interactive_cells.end()) {
319319
docthread->on_interactive_output(root);
320320
}
321321
else if (msg_type.find("csl_") == 0) {
@@ -446,11 +446,11 @@ void ComputeThread::on_message(websocketpp::connection_hdl hdl, message_ptr msg)
446446
gui->process_data();
447447
}
448448

449-
void ComputeThread::execute_interactive(const std::string& code)
449+
void ComputeThread::execute_interactive(uint64_t id, const std::string& code)
450450
{
451451
assert(gui_thread_id == std::this_thread::get_id());
452452

453-
if (!connection_is_open || interactive_cell == 0)
453+
if (!connection_is_open)
454454
return;
455455

456456
if (code.substr(0, 7) == "reset()")
@@ -459,7 +459,7 @@ void ComputeThread::execute_interactive(const std::string& code)
459459
nlohmann::json req, header, content;
460460

461461
header["msg_type"] = "execute_request";
462-
header["cell_id"] = interactive_cell;
462+
header["cell_id"] = id;
463463
header["interactive"] = true;
464464
content["code"] = code.c_str();
465465

@@ -470,11 +470,7 @@ void ComputeThread::execute_interactive(const std::string& code)
470470
std::ostringstream oss;
471471
oss << req << std::endl;
472472
wsclient.send(our_connection_hdl, oss.str(), websocketpp::frame::opcode::text);
473-
}
474-
475-
void ComputeThread::register_interactive_cell(uint64_t id)
476-
{
477-
interactive_cell = id;
473+
interactive_cells.insert(id);
478474
}
479475

480476
void ComputeThread::execute_cell(DTree::iterator it)

client_server/ComputeThread.hh

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include <websocketpp/common/thread.hpp>
88
#include <websocketpp/common/functional.hpp>
99
#include <thread>
10+
#include <set>
1011
#include <glibmm/spawn.h>
1112

1213
typedef websocketpp::client<websocketpp::config::asio_client> WSClient;
@@ -65,9 +66,7 @@ namespace cadabra {
6566

6667
void execute_cell(DTree::iterator);
6768

68-
void execute_interactive(const std::string& code);
69-
70-
void register_interactive_cell(uint64_t id);
69+
void execute_interactive(uint64_t id, const std::string& code);
7170

7271
/// Stop the current cell execution on the server and remove
7372
/// all other cells from the run queue as well.
@@ -133,8 +132,7 @@ namespace cadabra {
133132
/// report the status of each cell to the GUI.
134133
void all_cells_nonrunning();
135134

136-
uint64_t interactive_cell;
137-
std::vector<uint64_t> console_child_ids;
135+
std::set<uint64_t> interactive_cells;
138136

139137
// Self-started server
140138
Glib::Pid server_pid;

0 commit comments

Comments
 (0)