void ApiHandler::IpcEditorSelect(EditorCtrl& editor, IConnection& conn) { const hessian_ipc::Call& call = *conn.get_call(); const int v2 = call.GetParameter(1).GetInt(); const int v3 = call.GetParameter(2).GetInt(); if (v2 != v3) { editor.Select(v2, v3); editor.MakeSelectionVisible(); } editor.SetPos(v3); editor.ReDraw(); hessian_ipc::Writer& writer = conn.get_reply_writer(); writer.write_reply(true); }
void ApiHandler::IpcEditorInsertAt(EditorCtrl& editor, IConnection& conn) { // Get the insert position const hessian_ipc::Call& call = *conn.get_call(); const size_t pos = call.GetParameter(1).GetInt(); if (pos > editor.GetLength()) return; // fault: invalid position // Get the text to insert const hessian_ipc::Value& v3 = call.GetParameter(2); const string& t = v3.GetString(); const wxString text(t.c_str(), wxConvUTF8, t.size()); // Insert the text // TODO: adjust selections const unsigned int cpos = editor.GetPos(); const size_t byte_len = editor.RawInsert(pos, text); if (cpos >= pos) editor.SetPos(cpos + byte_len); editor.ReDraw(); // Write the reply hessian_ipc::Writer& writer = conn.get_reply_writer(); writer.write_reply(byte_len); }