pgadmin3/utils/align/Item.cpp
lsv ffeda8c9b6 Add align option Compat view for All Line mode. Some optimuzation.
Добавлена опция Compat view для All Line режима. В некоторых случаях она делает более красивое выравнивание.
Для примера:
f(iObjId,  1073,'text',null  )  ;
f(iObjId+1,130 ,'te'  ,iObjId)  ;
f(iObjId+2,1   ,'te2' ,iObjId+1);

Исправлено добавление пробелов в конце строки в режиме All Line.
2025-11-11 10:26:39 +05:00

67 lines
1.6 KiB
C++

#include "pgAdmin3.h"
#include "utils/align/Item.h"
bool Item::operator==(const Item& rh)
{
if (type == rh.type && type == ANCHOR) {
if (it == rh.it) return true;
return false;
}
// null ( NUM or LITERAL)
if (it.IsSameAs("null", false) && true) {
if (rh.type == LITERAL || rh.type == NUM || rh.type == WORD)
return true;
return false;
}
//NUM or LITERAL
if (type == NUM || type == LITERAL ) {
if (rh.it.IsSameAs("null", false) && true)
return true;
if (rh.type == LITERAL || rh.type == NUM ) return true;
return false;
}
//
if (type == rh.type) return true;
return false;
}
bool Item::operator!=(const Item& rh) {
return !this->operator==(rh);
}
wxString Item::println() {
wxString s = wxString::Format("Type %d val:\"%s\"", type, it);
if (ls > 0) s += wxString::Format(" L:\"%d\"", ls);
if (rs > 0) s += wxString::Format(" R:\"%d\"", rs);
if (br) s += wxString::Format(" BR");
s += wxString::Format("\n");
return s;
}
wxString Item::print() {
wxString s = wxString::Format("%s", it);
wxString r(' ', rs), l(' ', ls);
if (br)
s = l + r + s + wxString::Format("%s", comment); // для последнего элемента строки пробелы справа не добавляем
else
s = l + s + r + wxString::Format("%s", comment);
#ifdef _DEBUG
std::cout << s;
#endif
return s;
}
const int Item::getMaxSize() {
int tmp = rs + ls + it.Length();
if (!br) tmp += comment.Length();
return tmp;
}
void Item::setMaxSize(int newSize) {
ls = 0;
int tmp = newSize - it.Length() - comment.Length();
if (tmp >= 0) {
rs = tmp;
}
else {
//this->println();
return;
}
}