-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Добавлен в проект выравниватель списков IN и других упорядоченных данных. Вызывается комбинацией Ctrl+Shift+A (если внешний выравниватель не задан). Интегрировать код выравнивателя пришлось из-за бага wxWidgets. Ошибочное поведение появляется при вызове внешних утилит, если им передаётся большой объём текста (более 6 кб). Выравниватель может зациклиться на произвольных наборах данных. Используйте с осторожностью. Выравниватель имеет диалог настройки работы: При выборе первого пункта диалога все переводы строк остаются как есть. При выборе второго пункта первая строка будет образцом длинны и под неё будут подгонятся все прочие строки. Первый вариант используется для выравнивания insert команд. Второй для списков IN. Третий параметр используется, если иногда встречаются короткие строки алгоритм пытается найти выше строку которая больше или равна текущей. Например эти строки будут смотреться лучше: int rs = 0; int ls = 0; int type = 0; int up_item = -1; bool br = false; private: int align = LEFT; int maxlen = 0; wxString it;
- Loading branch information
lsv
committed
May 22, 2023
1 parent
2fbed7a
commit c197ea4
Showing
7 changed files
with
580 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#pragma once | ||
#include "Item.h" | ||
|
||
class AlignWrap { | ||
public: | ||
enum cfg | ||
{ | ||
// Выравнивание списка строк можно использовать вместе с FIND_UP_LONG_LINE | ||
// например insert команды с одинаковым перечнем элементов | ||
ALL_LINES = 1, | ||
// выравнивание по длинне первой строки | ||
// все переводы строк начиная со второй строки игнорируются | ||
// удобно для выравнивания списков IN | ||
FIRST_LINE= 2, | ||
// вспомогательный флаг применяется если встречаются случайные короткие строки | ||
// и при помощи этого флага ищутся более длинные строки обработанные ранее | ||
FIND_UP_LONG_LINE=4 | ||
}; | ||
AlignWrap() {} | ||
#define CHKCFGPARAM(val,par) ((val & par)==par) | ||
|
||
wxString build(wxString & strsrc, int config,wxString linesep); | ||
void Resize(int idx, int newSize); | ||
wxString range_print(int s, int e); | ||
private: | ||
|
||
int range_size(int s, int e); | ||
int range_size(int s); | ||
Item parseItem(int &pos, bool &breakline); | ||
int chkspace(int &pos, bool& br); | ||
int find(int s, int e, Item& k); | ||
// | ||
int parserows = 0; | ||
|
||
std::vector <Item> list; | ||
|
||
wxString str, lnsep; | ||
int cfg = 0; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#pragma once | ||
#include <wx/wx.h> | ||
class Item { | ||
public: | ||
enum align | ||
{ | ||
LEFT = 0, | ||
RIGHT | ||
}; | ||
enum type | ||
{ | ||
SPACE = 0, | ||
NUM, | ||
WORD, | ||
LITERAL, | ||
ANCHOR, | ||
COMMENT | ||
}; | ||
|
||
Item(const wxString &str, int type_item, int align_type=LEFT) { | ||
it = str; | ||
type = type_item; | ||
align = align_type; | ||
} | ||
bool operator==(const Item& rh); | ||
bool operator!=(const Item& rh); | ||
wxString print(); | ||
wxString println(); | ||
const wxString getValue() { return it; } | ||
const wxString getComment() { return comment; } | ||
const int getMaxSize(); | ||
const int getParent() { return up_item; } | ||
void setMaxSize(int newSize); | ||
const void add_space(int align, int count_space) { if (align == Item::align::LEFT) rs += count_space; else ls+= count_space;} | ||
const void setParent(int idxPar) { up_item = idxPar; }; | ||
const void setComment(wxString c) { comment = c; }; | ||
int rs = 0; | ||
int ls = 0; | ||
int type = 0; | ||
int up_item = -1; | ||
bool br = false; | ||
private: | ||
int align = LEFT; | ||
int maxlen = 0; | ||
wxString it; | ||
wxString comment; | ||
|
||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.