Esempio n. 1
0
void ApiHandler::IpcEditorDeleteRange(EditorCtrl& editor, IConnection& conn) {
	const hessian_ipc::Call& call = *conn.get_call();
	
	// Get the inset position
	const size_t start = call.GetParameter(1).GetInt();
	const size_t end = call.GetParameter(2).GetInt();
	if (end > editor.GetLength() || start > end) return; // fault: invalid positions

	// Delete the range
	const size_t byte_len = editor.RawDelete(start, end);

	// Write the reply
	hessian_ipc::Writer& writer = conn.get_reply_writer();
	writer.write_reply(byte_len);
}
Esempio n. 2
0
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);
}
Esempio n. 3
0
void ApiHandler::IpcEditorGetLength(EditorCtrl& editor, IConnection& conn) {
	hessian_ipc::Writer& writer = conn.get_reply_writer();
	writer.write_reply(editor.GetLength());
}