Skip to content

Commit

Permalink
Update file by vertical scrolling
Browse files Browse the repository at this point in the history
Signed-off-by: Minggang Li <[email protected]>
  • Loading branch information
LiMinggang committed Apr 4, 2021
1 parent cce6691 commit 2b190cb
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
19 changes: 16 additions & 3 deletions src/MadEdit/MadEdit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3706,7 +3706,7 @@ void MadEdit::UpdateScrollBarPos()
{
m_VScrollBar->Enable();
int ymax = int( m_Lines->m_RowCount ) + m_PageRowCount - 1;
if (IsPartialLoadMode())
if ( IsPartialLoadMode() )
{
MadLineIterator lineiter;
int subrowid = m_TopRow;
Expand Down Expand Up @@ -3778,7 +3778,7 @@ void MadEdit::UpdateScrollBarPos()
{
m_VScrollBar->Enable( true );

if (IsPartialLoadMode())
if ( IsPartialLoadMode() )
{
MadLineIterator lineiter;
int subrowid = m_TopRow;
Expand Down Expand Up @@ -10794,10 +10794,23 @@ void MadEdit::OnSize( wxSizeEvent &evt )
void MadEdit::OnVScroll( wxScrollEvent &evt )
{
m_TopRow = evt.GetPosition();
DBOUT( "OnVScroll:"<<m_TopRow<<"\n" );
DBOUT( "OnVScroll:[type:"<<evt.GetEventType()<<"] rowid:"<<m_TopRow<<"\n" );

if( m_EditMode != emHexMode )
{
if ( IsPartialLoadMode() )
{
int lineid = evt.GetPosition();
MadLineIterator lit;
wxFileOffset pos;
if (lineid < 0) lineid = 0;
if (lineid < m_LineidBeg || lineid > m_LineidEnd)
{
LoadPartial(lineid);
}
m_TopRow = GetLineByLine(lit, pos, lineid - m_LineidBeg);
}

if( m_TopRow < 0 ) m_TopRow = 0;
else
if( m_TopRow >= int( m_Lines->m_RowCount ) ) m_TopRow = int( m_Lines->m_RowCount - 1 );
Expand Down
6 changes: 6 additions & 0 deletions src/MadEdit/MadEditAdvanced.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4329,6 +4329,12 @@ bool MadEdit::LoadPartial(wxFileOffset pos)
!m_Lines->LoadPartial(m_PosOffsetBeg, m_PosOffsetEnd - m_PosOffsetBeg + 1)) return false;

m_PosCaretPos = oldCaretPos;
m_ValidPos_iter = m_Lines->m_LineList.begin();
m_ValidPos_lineid = 0;
m_ValidPos_rowid = 0;
m_ValidPos_pos = 0;
m_CaretPos.Reset( m_ValidPos_iter );
m_LastCaretXPos = 0;
return true;
}

Expand Down

0 comments on commit 2b190cb

Please sign in to comment.