Merge pull request #1115 from B-CE/dev-tabMgt

fix #274 : pasting tabs
1008-fix
tomangelo 2018-09-08 22:00:18 +02:00 committed by GitHub
commit aed74321cb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 24 additions and 6 deletions

View File

@ -2540,6 +2540,8 @@ bool CEdit::Paste()
{ {
char c; char c;
char* text; char* text;
int iTabToInsert=0;
int iTmp; //temp for tab space equivalant insertion
if ( !m_bEdit ) if ( !m_bEdit )
{ {
@ -2554,20 +2556,36 @@ bool CEdit::Paste()
} }
UndoMemorize(OPERUNDO_SPEC); UndoMemorize(OPERUNDO_SPEC);
for ( unsigned int i = 0; i < strlen(text); i++ ) for (unsigned int i = 0; i<strlen(text); ++i)
{ {
c = text[i]; c = text[i];
if ( c == '\r' ) switch(c)
{ {
case '\r':
continue; 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); 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); SDL_free(text);
Justif(); Justif();
ColumnFix(); ColumnFix();
@ -2872,7 +2890,7 @@ int CEdit::IndentTabCount()
return nb; return nb;
} }
// Adds or removes qq tabs. // Adds or removes some tabs.
void CEdit::IndentTabAdjust(int number) void CEdit::IndentTabAdjust(int number)
{ {