diff --git a/golded3/geedit.cpp b/golded3/geedit.cpp index 923c1d9..7c0da8d 100644 --- a/golded3/geedit.cpp +++ b/golded3/geedit.cpp @@ -567,6 +567,8 @@ void IEclass::GoLeft() { if(currline->prev) { GoUp(); GoEOL(); + if(currline->txt[col] != '\n') + col--; } } else @@ -605,7 +607,7 @@ void IEclass::GoRight() { // ------------------------------------------------------------------ -Line* IEclass::wrapit(Line** __currline, uint* __curr_col, uint* __curr_row, int __display) { +Line* IEclass::wrapit(Line** __currline, uint* __curr_col, uint* __curr_row, bool __display) { _test_halt(__currline == NULL); _test_halt(*__currline == NULL); @@ -667,7 +669,8 @@ Line* IEclass::wrapit(Line** __currline, uint* __curr_col, uint* __curr_row, int // NOTE: Leading spaces to this word will be nulled out! // Begin at the first char outside the margin - _wrappos++; + if((_wrappos + 1) <= maxcol) + _wrappos++; } else { @@ -903,7 +906,7 @@ Line* IEclass::wrapit(Line** __currline, uint* __curr_col, uint* __curr_row, int // ------------------------------------------------------------------ -Line* IEclass::wrapdel(Line** __currline, uint* __curr_col, uint* __curr_row, int __display) { +Line* IEclass::wrapdel(Line** __currline, uint* __curr_col, uint* __curr_row, bool __display) { GFTRK("Editwrapdel"); @@ -917,7 +920,7 @@ Line* IEclass::wrapdel(Line** __currline, uint* __curr_col, uint* __curr_row, in // ------------------------------------------------------------------ -Line* IEclass::wrapins(Line** __currline, uint* __curr_col, uint* __curr_row, int __display) { +Line* IEclass::wrapins(Line** __currline, uint* __curr_col, uint* __curr_row, bool __display) { GFTRK("Editwrapins"); @@ -1033,13 +1036,26 @@ void IEclass::DelChar() { Undo->PushItem(EDIT_UNDO_DEL_LINE|BATCH_MODE, _nextline); } + else if((_thislen > 1) and (_thisline->txt.c_str()[_thislen-2] != '\n') and _nextline and not (_nextline->type & GLINE_QUOT)) { + + _thisline->txt += _nextline->txt.c_str(); + + Undo->PushItem(EDIT_UNDO_CUT_TEXT|batch_mode, _thisline, _thislen-1); + + // Relink this line + _thisline->next = _nextline->next; + if(_thisline->next) + _thisline->next->prev = _thisline; + + Undo->PushItem(EDIT_UNDO_DEL_LINE|BATCH_MODE, _nextline); + } batch_mode = BATCH_MODE; // Make sure the line type still is correct setlinetype(_thisline); // Rewrap this line - wrapdel(&currline, &col, &row); + wrapdel(&currline, &col, &row, false); refresh(currline, row); diff --git a/golded3/geedit.h b/golded3/geedit.h index 0b2eedb..d8ac7fc 100644 --- a/golded3/geedit.h +++ b/golded3/geedit.h @@ -318,9 +318,9 @@ protected: void statusline (); void windowclose (); void windowopen (); - Line* wrapit (Line** __currline, uint* __curr_col, uint* __curr_row, int __display=YES); - Line* wrapdel (Line** __currline, uint* __curr_col, uint* __curr_row, int __display=YES); - Line* wrapins (Line** __currline, uint* __curr_col, uint* __curr_row, int __display=YES); + Line* wrapit (Line** __currline, uint* __curr_col, uint* __curr_row, bool __display=true); + Line* wrapdel (Line** __currline, uint* __curr_col, uint* __curr_row, bool __display=true); + Line* wrapins (Line** __currline, uint* __curr_col, uint* __curr_row, bool __display=true); #ifndef NDEBUG void debugtest (char* __test, int __a, int __b, char* __file, int __line, int __values); diff --git a/golded3/geedit2.cpp b/golded3/geedit2.cpp index d0428ce..fb3dab3 100644 --- a/golded3/geedit2.cpp +++ b/golded3/geedit2.cpp @@ -622,7 +622,7 @@ void IEclass::BlockDel(Line* anchor) { firstcol = blockcol; } else { - if(currline != anchor or blockcol > col) + if((currline != anchor) or (blockcol > col)) lastcol = blockcol; else firstcol = blockcol; @@ -635,8 +635,8 @@ void IEclass::BlockDel(Line* anchor) { size_t __len = firstcutline->txt.length(); firstcutline->txt += lastcutline->txt.c_str()+lastcol; Undo->PushItem(EDIT_UNDO_INS_TEXT, firstcutline, __len); - Undo->PushItem(EDIT_UNDO_DEL_TEXT|BATCH_MODE, firstcutline, firstcol, __len); - firstcutline->txt.erase(firstcol, __len); + Undo->PushItem(EDIT_UNDO_DEL_TEXT|BATCH_MODE, firstcutline, firstcol, __len-firstcol); + firstcutline->txt.erase(firstcol, __len-firstcol); } else { Undo->PushItem(EDIT_UNDO_DEL_TEXT, firstcutline, firstcol, lastcol-firstcol); @@ -661,13 +661,13 @@ void IEclass::BlockDel(Line* anchor) { // Refresh the display if(not RngV(row, minrow, maxrow)) { row = minrow; - wrapdel(&currline, &col, &row, YES); + wrapdel(&currline, &col, &row, false); refresh(currline, minrow); } else { row = MaxV(firstcutlinerow, minrow); Line* topline = findtopline(); - wrapdel(&currline, &col, &row, NO); + wrapdel(&currline, &col, &row, false); refresh(topline, minrow); } @@ -742,7 +742,7 @@ void IEclass::BlockPaste() { currline->txt += _pasteline->txt; setlinetype(currline); col = currline->txt.length(); - wrapins(&currline, &col, &row, NO); + wrapins(&currline, &col, &row, false); currline = _newline; col = 0; if(row < maxrow) @@ -753,7 +753,7 @@ void IEclass::BlockPaste() { currline->txt.insert(col, _pasteline->txt); Undo->PushItem(EDIT_UNDO_INS_TEXT|BATCH_MODE, currline, col, pastelen); col += pastelen; - wrapins(&currline, &col, &row, NO); + wrapins(&currline, &col, &row, false); } setlinetype(currline); @@ -1146,7 +1146,7 @@ void IEclass::editimport(Line* __line, char* __filename, bool imptxt) { // Wrap it uint _tmpcol = 0; uint _tmprow = 0; - _newline = wrapins(&_newline, &_tmpcol, &_tmprow, NO); + _newline = wrapins(&_newline, &_tmpcol, &_tmprow, false); } __line = _newline; @@ -1160,7 +1160,7 @@ void IEclass::editimport(Line* __line, char* __filename, bool imptxt) { // Wrap it uint _tmpcol = 0; uint _tmprow = 0; - __line = wrapins(&__line, &_tmpcol, &_tmprow, NO); + __line = wrapins(&__line, &_tmpcol, &_tmprow, false); } __line->next = saveline; if(saveline) diff --git a/golded3/geline.cpp b/golded3/geline.cpp index 257caf2..f5806c6 100644 --- a/golded3/geline.cpp +++ b/golded3/geline.cpp @@ -213,7 +213,7 @@ const byte KCRQ_CASE = 0x0002; // ------------------------------------------------------------------ -static Kludges fts_list[] = { +static const Kludges fts_list[] = { { "AREA" , FTS_AREA , KCRQ_CASE }, { "INTL" , FTS_INTL , KCRQ_CASE }, @@ -229,7 +229,7 @@ static Kludges fts_list[] = { // ------------------------------------------------------------------ -static Kludges fsc_list[] = { +static const Kludges fsc_list[] = { { "CHARSET" , FSC_CHARSET , KCRQ_CASE }, { "CHRC" , FSC_CHRC , KCRQ_CASE }, @@ -261,7 +261,7 @@ static Kludges fsc_list[] = { // ------------------------------------------------------------------ -static Kludges xxx_list[] = { +static const Kludges xxx_list[] = { { "ACUPDATE" , XXX_ACUPDATE , KCRQ_CASE }, { "CODEPAGE" , XXX_CODEPAGE , KCRQ_CASE }, @@ -299,7 +299,7 @@ static Kludges xxx_list[] = { // ------------------------------------------------------------------ -static Kludges rfc_list[] = { +static const Kludges rfc_list[] = { { "Also-Control" , RFC_ALSO_CONTROL , KCRQ_COLON }, { "Apparently-To" , RFC_APPARENTLY_TO , KCRQ_COLON }, @@ -1293,7 +1293,7 @@ int HandleRFCs(GMsg* msg, Line* line, int kludgenum, const char* ptr, int getval // ------------------------------------------------------------------ -int ScanCtrlList(Kludges* k, char* kludge, char endchar) { +int ScanCtrlList(const Kludges *k, const char *kludge, char endchar) { while(*k->key) { if((k->req & KCRQ_CASE) ? streql(kludge, k->key) : strieql(kludge, k->key)) { @@ -1339,29 +1339,24 @@ int ScanLine(GMsg* msg, Line* line, const char* ptr, int getvalue, int mask) { // Search for it in the known kludges list if(*kludge) { - Kludges* k; while(1) { if(mask & MASK_FTS) { - k = fts_list; - kludgenum = ScanCtrlList(k, kludge, endchar); + kludgenum = ScanCtrlList(fts_list, kludge, endchar); if(kludgenum) break; } if(mask & MASK_FSC) { - k = fsc_list; - kludgenum = ScanCtrlList(k, kludge, endchar); + kludgenum = ScanCtrlList(fsc_list, kludge, endchar); if(kludgenum) break; } if(mask & MASK_RFC) { - k = rfc_list; - kludgenum = ScanCtrlList(k, kludge, endchar); + kludgenum = ScanCtrlList(rfc_list, kludge, endchar); if(kludgenum) break; } if(mask & MASK_XXX) { - k = xxx_list; - kludgenum = ScanCtrlList(k, kludge, endchar); + kludgenum = ScanCtrlList(xxx_list, kludge, endchar); if(kludgenum) break; } @@ -2131,9 +2126,8 @@ void MakeLineIndex(GMsg* msg, int margin, bool header_recode) { switch(*ptr) { case CR: do_cr: - ptr++; ch = CR; - ptr = spanfeeds(ptr); + ptr = spanfeeds(ptr+1); if(wraps and not ((line->type & GLINE_HARD) and not (line->type & GLINE_QUOT))) { if(para != GLINE_QUOT) { if(quoteflag) { @@ -2333,9 +2327,7 @@ void MakeLineIndex(GMsg* msg, int margin, bool header_recode) { } else if((ptr[1] == CR) or (ptr[1] == LF)) { // Skip soft line break - ptr++; - while((*ptr == CR) or (*ptr == LF)) - ptr++; + ptr = spanfeeds(ptr+2); break; } } diff --git a/golded3/gerand.cpp b/golded3/gerand.cpp index e6bb3be..f7d3c1c 100644 --- a/golded3/gerand.cpp +++ b/golded3/gerand.cpp @@ -165,6 +165,7 @@ void Area::InitData() { adat->taglinesupport = CFG->taglinesupport; strcpy(adat->tearline, CFG->tearline); strcpy(adat->tpl, (CFG->tplno and (CFG->tplno < CFG->tpl.size())) ? CFG->tpl[CFG->tplno].file : ""); + strxcpy(adat->wtpl, CFG->wtpl.c_str(), sizeof(adat->wtpl)); adat->templatematch = CFG->templatematch; adat->twitmode = CFG->twitmode; adat->usefwd = CFG->usefwd; diff --git a/golded3/getpls.cpp b/golded3/getpls.cpp index b263bf5..3df5ab6 100644 --- a/golded3/getpls.cpp +++ b/golded3/getpls.cpp @@ -126,7 +126,7 @@ int TemplateToText(int mode, GMsg* msg, GMsg* oldmsg, const char* tpl, int origa int length; }; - tpl_token token_list[] = { + static const tpl_token token_list[] = { { CSTR_COMMA_SIZEOF_CSTR("forward") }, { CSTR_COMMA_SIZEOF_CSTR("changed") }, { CSTR_COMMA_SIZEOF_CSTR("net") },