Different fixes
This commit is contained in:
parent
478e6e0e62
commit
a49b93dc74
@ -113,13 +113,12 @@ int IEclass::dispchar(vchar __ch, int attr) {
|
||||
|
||||
if(__ch == NUL) // possible if line empty
|
||||
__ch = ' ';
|
||||
if(__ch != '\n') {
|
||||
if(__ch == ' ')
|
||||
__ch = EDIT->CharSpace();
|
||||
}
|
||||
else {
|
||||
if(__ch == '\n') {
|
||||
__ch = EDIT->CharPara();
|
||||
}
|
||||
else if(__ch == ' ') {
|
||||
__ch = EDIT->CharSpace();
|
||||
}
|
||||
|
||||
int atr;
|
||||
vchar chr;
|
||||
@ -566,7 +565,8 @@ void IEclass::GoLeft() {
|
||||
GoUp();
|
||||
GoEOL();
|
||||
// if((col != mincol) and ((currline->txt[col] == '\n') or not ((col == (maxcol + 1)) and (currline->txt[col-1] == ' '))))
|
||||
// col--;
|
||||
if((col != mincol) and (currline->txt.c_str()[col] == NUL))
|
||||
col--;
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -587,7 +587,7 @@ void IEclass::GoRight() {
|
||||
|
||||
_test_haltab(col > maxcol, col, maxcol);
|
||||
|
||||
if((col == maxcol) or (col >= currline->txt.length()) or (currline->txt[col] == '\n')) {
|
||||
if((col == maxcol) or ((col+1) >= currline->txt.length())) {
|
||||
if(currline->next != NULL) {
|
||||
GoDown();
|
||||
col = mincol;
|
||||
@ -610,6 +610,8 @@ Line* IEclass::wrapit(Line** __currline, uint* __curr_col, uint* __curr_row, boo
|
||||
_test_halt(__currline == NULL);
|
||||
_test_halt(*__currline == NULL);
|
||||
|
||||
int scroll = 0;
|
||||
|
||||
uint _quotelen;
|
||||
char _quotebuf[MAXQUOTELEN];
|
||||
*_quotebuf = NUL;
|
||||
@ -632,7 +634,7 @@ Line* IEclass::wrapit(Line** __currline, uint* __curr_col, uint* __curr_row, boo
|
||||
uint _wrapmargin = (_thisline->type & GLINE_QUOT) ? marginquotes : margintext;
|
||||
|
||||
// Does this line need wrapping?
|
||||
if((_thislen > _wrapmargin) or ((_thislen == _wrapmargin) and not (_thisline->txt[_thislen-1] == ' '))) {
|
||||
if((_thislen > _wrapmargin) or ((_thislen == _wrapmargin) and not ((_thisline->txt[_thislen-1] == ' ') or (_thisline->txt[_thislen-1] == '\n')))) {
|
||||
|
||||
// Reset quote string length
|
||||
_quotelen = 0;
|
||||
@ -668,7 +670,7 @@ Line* IEclass::wrapit(Line** __currline, uint* __curr_col, uint* __curr_row, boo
|
||||
// NOTE: Leading spaces to this word will be nulled out!
|
||||
|
||||
// Begin at the first char outside the margin
|
||||
if((_wrappos + 1) <= maxcol)
|
||||
if(_wrappos <= maxcol)
|
||||
_wrappos++;
|
||||
}
|
||||
else {
|
||||
@ -681,7 +683,7 @@ Line* IEclass::wrapit(Line** __currline, uint* __curr_col, uint* __curr_row, boo
|
||||
int _atmargin = _wrappos;
|
||||
|
||||
// Search backwards until a space or the beginning of the line is found
|
||||
while(_wrappos > 0 and (_thisline->txt[_wrappos-1] != ' '))
|
||||
while((_wrappos > 0) and (_thisline->txt[_wrappos-1] != ' '))
|
||||
_wrappos--;
|
||||
|
||||
// Check if we hit leading spaces
|
||||
@ -702,7 +704,7 @@ Line* IEclass::wrapit(Line** __currline, uint* __curr_col, uint* __curr_row, boo
|
||||
}
|
||||
}
|
||||
|
||||
// The wrapptr now points to the location to be wrapped or NUL
|
||||
// The wrappos now points to the location to be wrapped or NUL
|
||||
|
||||
// Is the line hard-terminated?
|
||||
if(_thisline->txt.find('\n', _wrappos) != _thisline->txt.npos) {
|
||||
@ -733,7 +735,7 @@ Line* IEclass::wrapit(Line** __currline, uint* __curr_col, uint* __curr_row, boo
|
||||
if(_thisrow < maxrow) {
|
||||
|
||||
// Scroll the lines below to make room for the new line
|
||||
scrolldown(mincol, _thisrow+1, maxcol, maxrow);
|
||||
--scroll;
|
||||
|
||||
// Display the new line
|
||||
if(_wrapline->txt.length() <= (maxcol+1))
|
||||
@ -788,7 +790,7 @@ Line* IEclass::wrapit(Line** __currline, uint* __curr_col, uint* __curr_row, boo
|
||||
if(_line_added_below and (_thisrow < maxrow)) {
|
||||
|
||||
// Scroll the lines below to make room for the new line
|
||||
scrolldown(mincol, _thisrow+1, maxcol, maxrow);
|
||||
--scroll;
|
||||
}
|
||||
|
||||
// Display the new/wrapped line
|
||||
@ -890,12 +892,20 @@ Line* IEclass::wrapit(Line** __currline, uint* __curr_col, uint* __curr_row, boo
|
||||
if(_cursrow > maxrow) {
|
||||
_cursrow = maxrow;
|
||||
if(__display) {
|
||||
scrollup(mincol, minrow, maxcol, maxrow);
|
||||
++scroll;
|
||||
if(scroll > 0) {
|
||||
scrollup(mincol, minrow, maxcol, maxrow);
|
||||
scroll = 0;
|
||||
}
|
||||
displine(*__currline, *__curr_row);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(__display and (scroll != 0)) {
|
||||
refresh((*__currline)->next, _cursrow+1);
|
||||
}
|
||||
|
||||
// Update cursor position
|
||||
*__curr_row = _cursrow;
|
||||
*__curr_col = _curscol;
|
||||
@ -1011,6 +1021,12 @@ void IEclass::DelChar() {
|
||||
_thisline->txt.erase(col, 1);
|
||||
batch_mode = BATCH_MODE;
|
||||
}
|
||||
else if((col == _thislen) && _nextline) {
|
||||
GFTRK(NULL);
|
||||
GoRight();
|
||||
DelChar();
|
||||
return;
|
||||
}
|
||||
|
||||
// Did we delete the last char on the line or
|
||||
// was the cursor at or beyond the nul-terminator?
|
||||
@ -1061,9 +1077,16 @@ void IEclass::DelChar() {
|
||||
setlinetype(_thisline);
|
||||
|
||||
// Rewrap this line
|
||||
wrapdel(&currline, &col, &row);
|
||||
|
||||
refresh(currline, row);
|
||||
bool display = (row > maxrow / 2) ? false : true;
|
||||
wrapdel(&currline, &col, &row, display);
|
||||
if(display) {
|
||||
refresh(currline, row);
|
||||
}
|
||||
else {
|
||||
// Refresh the display
|
||||
Line* _topline = findtopline();
|
||||
refresh(_topline, minrow);
|
||||
}
|
||||
|
||||
GFTRK(NULL);
|
||||
}
|
||||
|
@ -2395,7 +2395,7 @@ void MakeLineIndex(GMsg* msg, int margin, bool header_recode) {
|
||||
reflow = true;
|
||||
line->type |= GLINE_WRAP;
|
||||
ptr = spanfeeds(ptr);
|
||||
if((*bp == ' ') or (isspace(*ptr) && (*ptr != LF)))
|
||||
if((*bp == ' ') or (isspace(*ptr) and (*ptr != LF)))
|
||||
ptr = spanspaces(ptr);
|
||||
else {
|
||||
if(tmp) {
|
||||
|
@ -423,10 +423,10 @@ inline bool issoftcr(char c) {
|
||||
|
||||
inline char *spanspaces(const char *str) {
|
||||
if(CFG->switches.get(dispsoftcr))
|
||||
while(isspace(*str))
|
||||
while(strchr(" \t", *str))
|
||||
str++;
|
||||
else
|
||||
while(isspace(*str) or (*str == SOFTCR))
|
||||
while(strchr(" \t", *str) or (*str == SOFTCR))
|
||||
str++;
|
||||
return (char *)str;
|
||||
}
|
||||
|
@ -49,10 +49,16 @@ extern "C" {
|
||||
extern char tl[256], tu[256];
|
||||
inline int _nls_tolower(int c) { return tl[c]; }
|
||||
inline int _nls_toupper(int c) { return tu[c]; }
|
||||
#ifdef __MSVCRT__
|
||||
inline int _nls_isspace(int c) { return (iscntrl(c) or (c == ' ')); }
|
||||
#endif
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#define tolower(a) _nls_tolower((unsigned char)(a))
|
||||
#define toupper(a) _nls_toupper((unsigned char)(a))
|
||||
#ifdef __MSVCRT__
|
||||
#define isspace(a) _nls_isspace((unsigned char)(a))
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@ -62,9 +68,8 @@ inline int _nls_toupper(int c) { return tu[c]; }
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
inline int iswhite(char c) { return c and (iscntrl(c) or (c == ' ')); }
|
||||
// NLS chars detected by converting to lower or upper case and in case they don't match they treated as characters
|
||||
inline int isxalnum(char c) { return isalnum(c) or ((c >= 128) and ((c != tolower(c)) or (c != toupper(c)))); }
|
||||
inline int isxalnum(char c) { return isascii(c) ? isalnum(c) : (c != tolower(c)) or (c != toupper(c)); }
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -796,8 +796,9 @@ int wmenuitem(int wrow, int wcol, const char* str, char schar, int tagid, int fm
|
||||
|
||||
int width = 1 + (gwin.cmenu->ecol-border) - (gwin.cmenu->scol+border);
|
||||
size_t _titlen = gwin.cmenu->title ? strlen(gwin.cmenu->title) : 0;
|
||||
int length = maximum_of_two(strlen(str), _titlen);
|
||||
if(length > width)
|
||||
size_t _strlen = strlen(str);
|
||||
size_t length = maximum_of_two(_strlen, _titlen);
|
||||
if((int)length > width)
|
||||
gwin.cmenu->ecol += length - width;
|
||||
|
||||
if(gwin.cmenu->menutype & M_VERT) {
|
||||
|
Reference in New Issue
Block a user