Fixes #274 : pasting tabs

1008-fix
B-CE 2018-02-19 00:35:01 +01:00 committed by B-CE
parent 0e6d22a549
commit da1b7e8c2d
1 changed files with 24 additions and 6 deletions

View File

@ -2537,6 +2537,8 @@ bool CEdit::Paste()
{
char c;
char* text;
int iTabToInsert=0;
int iTmp; //temp for tab space equivalant insertion
if ( !m_bEdit )
{
@ -2551,20 +2553,36 @@ bool CEdit::Paste()
}
UndoMemorize(OPERUNDO_SPEC);
for ( unsigned int i = 0; i < strlen(text); i++ )
for (unsigned int i = 0; i<strlen(text); ++i)
{
c = text[i];
if ( c == '\r' )
switch(c)
{
case '\r':
continue;
case '\t':
if (m_bAutoIndent)
{
if (0<m_cursor1 && m_cursor1<=m_len && '\n'!=m_text[m_cursor1-1])
iTabToInsert++;
continue;
}
break;
case '\n':
iTabToInsert=0;
}
if ( c == '\t' && m_bAutoIndent )
if (0<iTabToInsert && m_bAutoIndent)
{
continue;
for (iTmp=m_engine->GetEditIndentValue()*iTabToInsert; iTmp>0; --iTmp)
InsertOne(' ');
iTabToInsert=0;
}
InsertOne(c);
}
if (0<iTabToInsert && m_bAutoIndent && 0<m_cursor1
&& (m_cursor1>=m_len || '\n'!=m_text[m_cursor1]))
for (iTmp=m_engine->GetEditIndentValue() ; iTmp>0; --iTmp)
InsertOne(' ');
SDL_free(text);
Justif();
ColumnFix();
@ -2869,7 +2887,7 @@ int CEdit::IndentTabCount()
return nb;
}
// Adds or removes qq tabs.
// Adds or removes some tabs.
void CEdit::IndentTabAdjust(int number)
{