示例#1
0
文件: ApiHandler.cpp 项目: BBkBlade/e
void ApiHandler::IpcGetActiveEditor(IConnection& conn) {
	EditorCtrl* editor = m_app.GetActiveEditorCtrl();
	const int id = -editor->GetId();

	hessian_ipc::Writer& writer = conn.get_reply_writer();
	writer.write_reply_handle(id);
}
示例#2
0
文件: ApiHandler.cpp 项目: BBkBlade/e
void ApiHandler::IpcEditorEndChange(EditorCtrl& editor, IConnection& conn) {
	const int editorId = editor.GetId();

	boost::ptr_map<IConnection*,ConnectionState>::iterator p = m_connStates.find(&conn);
	if (p == m_connStates.end()) return;
	set<int>& editorsInChange = p->second->editorsInChange;
	if (editorsInChange.find(editorId) != editorsInChange.end()) return;
	editorsInChange.erase(editorId);

	editor.EndChange();
}
示例#3
0
文件: ApiHandler.cpp 项目: BBkBlade/e
void ApiHandler::IpcEditorWatchChanges(EditorCtrl& editor, IConnection& conn) {
	// Register notifier
	const unsigned int notifier_id = GetNextNotifierId();
	m_notifiers[notifier_id] = &conn;

	// Add to watch list
	const EditorWatch ew = {WATCH_EDITOR_CHANGE, editor.GetId(), editor.GetChangeToken(), notifier_id};
	m_editorWatchers.push_back(ew);

	// Return notifier id
	hessian_ipc::Writer& writer = conn.get_reply_writer();
	writer.write_reply(notifier_id);
}
示例#4
0
文件: ApiHandler.cpp 项目: BBkBlade/e
void ApiHandler::IpcEditorStartChange(EditorCtrl& editor, IConnection& conn) {
	const int editorId = editor.GetId();

	// Only allow one level of change grouping
	boost::ptr_map<IConnection*,ConnectionState>::iterator p = m_connStates.find(&conn);
	if (p == m_connStates.end()) {
		IConnection* c = &conn;
		m_connStates.insert(c, new ConnectionState);
		p = m_connStates.find(&conn);
	}
	else {
		const set<int>& editorsInChange = p->second->editorsInChange;
		if (editorsInChange.find(editorId) != editorsInChange.end()) return;
	}

	p->second->editorsInChange.insert(editorId);
	editor.StartChange();
}
示例#5
0
void SymbolList::OnIdle(wxIdleEvent& WXUNUSED(event)) {
	EditorCtrl* editorCtrl = m_parentFrame.GetEditorCtrl();
	if (!editorCtrl) return;
	const int id = editorCtrl->GetId();

	// In rare cases a new editorCtrl may get same address as
	// a previous one, so we also track the window id.
	const bool newEditorCtrl = (editorCtrl != m_editorCtrl || id != m_editorCtrlId);

	if (newEditorCtrl) m_changeToken = 0; // reset token
	const unsigned int currentChangeToken = editorCtrl->GetChangeToken();

	// Only update if the editorCtrl has changed
	if (newEditorCtrl || m_changeToken != currentChangeToken) { // || m_pos != editorCtrl->GetPos()) {
		m_editorCtrl = editorCtrl;
		m_editorCtrlId = id;

		// Reload symbols
		m_symbols.clear();
		m_symbolStrings.Empty();
		const int res = editorCtrl->GetSymbols(m_symbols);
		if (res == 1) {
			// reload symbol strings
			for (vector<Styler_Syntax::SymbolRef>::const_iterator p = m_symbols.begin(); p != m_symbols.end(); ++p) {
				const Styler_Syntax::SymbolRef& sr = *p;
				m_symbolStrings.Add(editorCtrl->GetSymbolString(sr));
			}
			m_listBox->SetAllItems();
		}
		else if (res == 2) { // DEBUG: double implementation to view path in crash dump (remove when bug is solved)
			// reload symbol strings
			for (vector<Styler_Syntax::SymbolRef>::const_iterator p = m_symbols.begin(); p != m_symbols.end(); ++p) {
				const Styler_Syntax::SymbolRef& sr = *p;
				m_symbolStrings.Add(editorCtrl->GetSymbolString(sr));
			}
			m_listBox->SetAllItems();
		}
		else {
			m_listBox->SetAllItems(); // clear list
			return;
		}

		// Get editor state
		m_pos = editorCtrl->GetPos();
		m_changeToken = currentChangeToken;

		// Keep scrollpos so we can stay at the same pos
		const unsigned int scrollPos = m_listBox->GetScrollPos(wxVERTICAL);

		// Set current symbol
		if (!m_symbols.empty()) {
			/*// Set new symbols
			bool currentSet = false;
			unsigned int id = 0;
			for (vector<Styler_Syntax::SymbolRef>::const_iterator p = m_symbols.begin(); p != m_symbols.end(); ++p) {
				// Select current
				if (!currentSet && m_pos < p->start) {
					if (p != m_symbols.begin()) {
						SetSelection(id-1, true);
					}
					currentSet = true;
				}

				++id;
			}

			// Current symbol may be the last and therefore not checked above
			if (!currentSet && m_pos >= m_symbols.back().start) {
				SetSelection(id-1, true);
			}*/

			// Keep same position
			if (!newEditorCtrl) {
				m_listBox->SetScrollPos(wxVERTICAL, scrollPos);
			}
		}
	}
}
示例#6
0
文件: StatusBar.cpp 项目: dxtravi/e
void StatusBar::UpdateBarFromActiveEditor() {
	EditorCtrl* editorCtrl = m_parentFrame.GetEditorCtrl();
	if (!editorCtrl) return;

	const unsigned int changeToken = editorCtrl->GetChangeToken();
	const int id = editorCtrl->GetId();
	const unsigned int pos = editorCtrl->GetPos();

	// In rare cases a new editorCtrl may get same address as
	// a previous one, so we also track the window id.
	const bool newEditorCtrl = (editorCtrl != m_editorCtrl || id != m_editorCtrlId);

	// Only update if the editorCtrl has changed
	const bool updatePanels = newEditorCtrl || (m_changeToken != changeToken) || (m_pos != pos);
	if (!updatePanels) return;

	if (newEditorCtrl) m_changeToken = 0; // reset
	m_editorCtrl = editorCtrl;
	m_editorCtrlId = id;

	Freeze();
	UpdateTabs();

	if (editorCtrl) {
		// Caret position
		const unsigned int line = editorCtrl->GetCurrentLineNumber();
		const unsigned int column = editorCtrl->GetCurrentColumnNumber();

		if (line != m_line || column != m_column) {
			SetStatusText(wxString::Format(wxT("Line: %u  Column: %u"), line, column), 0);

			m_line = line;
			m_column = column;
		}

		// Syntax
		SetPanelTextIfDifferent(editorCtrl->GetSyntaxName(), 1);

		// Only reload symbol list if doc has changed
		bool symbolsChanged = false;
		if (newEditorCtrl || m_changeToken != changeToken) {
			m_symbols.clear();
			if (editorCtrl->GetSymbols(m_symbols)) {
				m_changeToken = editorCtrl->GetChangeToken(); // Track change state (so we only update on change)
				symbolsChanged = true;
			}
		}

		// Symbols
		if (newEditorCtrl || symbolsChanged || m_pos != pos) {
			SetStatusText(wxEmptyString, 3);
			for (std::vector<SymbolRef>::reverse_iterator p = m_symbols.rbegin(); p != m_symbols.rend(); ++p) {
				if (m_pos >= p->start) {
					const SymbolRef& sr = *p;
					SetStatusText(editorCtrl->GetSymbolString(sr), 3);
					break;
				}
			}
		}

		// Encoding
		wxFontEncoding enc = editorCtrl->GetEncoding();
		wxTextFileType eol = editorCtrl->GetEOL();

		wxString encoding = wxFontMapper::GetEncodingName(enc).Lower();
		if (enc == wxFONTENCODING_DEFAULT) enc = wxLocale::GetSystemEncoding();
		if (enc == wxFONTENCODING_UTF7 || enc == wxFONTENCODING_UTF8 || enc == wxFONTENCODING_UTF16LE ||
			enc == wxFONTENCODING_UTF16BE || enc == wxFONTENCODING_UTF32LE || enc == wxFONTENCODING_UTF32BE) {
			if (editorCtrl->GetBOM()) encoding += wxT("+bom");
		}

		if (eol == wxTextFileType_None) eol = wxTextBuffer::typeDefault;
		if (eol == wxTextFileType_Dos) encoding += wxT(" crlf");
		else if (eol == wxTextFileType_Unix) encoding += wxT(" lf");
		else if (eol == wxTextFileType_Mac) encoding += wxT(" cr");

		SetStatusText(encoding, 4);

		m_pos = pos;
	}

	Thaw();
}