mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-15 14:16:07 -06:00
TextDiffCtrl, ide: In dir diff, new option to ignore indentation
This commit is contained in:
parent
c41a6445a1
commit
f7289c9099
7 changed files with 45 additions and 35 deletions
|
|
@ -14,15 +14,18 @@ static int CompareGetCount(I a, I b, int max_count)
|
|||
return max_count;
|
||||
}
|
||||
|
||||
Vector<String> GetLineMap(Stream& stream)
|
||||
Vector<String> GetLineMap(Stream& stream, bool ignore_indent)
|
||||
{
|
||||
Vector<String> out;
|
||||
int emp = 0;
|
||||
if(stream.IsOpen())
|
||||
while(!stream.IsEof()) {
|
||||
String s = stream.GetLine();
|
||||
const char *p = s, *e = s.End(), *f = e;
|
||||
while(e > p && /*(byte)e[-1] != 9 && */(byte)e[-1] < ' ')
|
||||
const char *p = s, *e = s.end(), *f = e;
|
||||
if(ignore_indent)
|
||||
while((byte)*p <= 32 && p != e)
|
||||
p++;
|
||||
while(e > p && (byte)e[-1] < ' ')
|
||||
e--;
|
||||
if(e == p)
|
||||
emp++;
|
||||
|
|
@ -30,6 +33,9 @@ Vector<String> GetLineMap(Stream& stream)
|
|||
{
|
||||
while(emp-- > 0)
|
||||
out.Add(Null);
|
||||
if(p != s.begin())
|
||||
s = String(p, e);
|
||||
else
|
||||
if(e != f)
|
||||
s.Trim(int(e - p));
|
||||
out.Add(s);
|
||||
|
|
@ -39,18 +45,6 @@ Vector<String> GetLineMap(Stream& stream)
|
|||
return out;
|
||||
}
|
||||
|
||||
Vector<String> GetFileLineMap(const String& path)
|
||||
{
|
||||
FileIn fi(path);
|
||||
return GetLineMap(fi);
|
||||
}
|
||||
|
||||
Vector<String> GetStringLineMap(const String& s)
|
||||
{
|
||||
StringStream ss(s);
|
||||
return GetLineMap(ss);
|
||||
}
|
||||
|
||||
class TextComparator
|
||||
{
|
||||
public:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue