示例#1
0
文件: ApiHandler.cpp 项目: BBkBlade/e
void ApiHandler::IpcEditorGetCurrentLine(EditorCtrl& editor, IConnection& conn) {
	const unsigned int line_id = editor.GetCurrentLineNumber()-1;

	hessian_ipc::Writer& writer = conn.get_reply_writer();
	writer.write_reply(line_id);
}
示例#2
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();
}