void BookViewPreview::ScrollToFragmentInternal(const QString &fragment) { if (fragment.isEmpty()) { ScrollToTop(); return; } QString caret_location = "var element = document.getElementById(\"" % fragment % "\");"; QString scroll = "var from_top = window.innerHeight / 2.5;" "$.scrollTo(element, 0, {offset: {top:-from_top, left:0 } });"; EvaluateJavascript(caret_location % scroll % SET_CURSOR_JS); }
void CIMoteTerminal::WidthAdjustment(){ if(!m_outputRichEditControl.MaxCharCountChange()) return; m_lines.Clear(); m_lines.Add(0); m_buffer = m_bufferTrue; //m_buffer.Replace("\\\n",""); for(int i = 0, j = 0; i < m_buffer.GetLength(); i++, j++){ if(m_buffer[i] == '\r'){ m_lines.Add(i); if(i + 1 < m_buffer.GetLength() && m_buffer[i + 1] == '\n') i++; j = -1; } else if(j == m_outputRichEditControl.MaxCharCount()){ m_buffer.Insert(i - 1, '\\'); m_lines.Add(i++); m_buffer.Insert(i - 1, '\n'); j = 1; i++; } } int oldLine = m_curLine; if(m_trueCurLine == m_trueLines) ScrollToBottom(); else if(oldLine < m_lines.GetSize() / 2){ ScrollToTop(); while(m_curLine < oldLine) Scroll(false); } else if(oldLine < m_lines.GetSize()){ ScrollToBottom(); while(m_curLine > oldLine) Scroll(true); } else ScrollToBottom(); UpdateText(); }