bool EmacsBuffer::translate(mintchar_t mark, const MintString& trstr) { // This function does not change the number of characters or // newlines in the buffer mintcount_t p1 = getMarkPosition(MARK_POINT); mintcount_t p2 = getMarkPosition(mark); if (p1 > p2) { std::swap(p1, p2); } // if if (p1 != p2) { MintString translated; const_iterator last = _text.begin() + p2; for (const_iterator i = _text.begin() + p1; i < last; ++i) { umintchar_t ch = static_cast<umintchar_t>(*i); if ((ch != EOLCHAR) && (ch < trstr.size())) { ch = trstr[ch]; } // if translated.push_back(ch); } // for #if defined(USE_BUFFER_ROPE) && !defined(USE_MINTSTRING_ROPE) _text.replace(p1, p2, translated.data(), translated.size()); #else _text.replace(p1, p2, translated); #endif } // if return true; } // translate
bool EmacsBuffer::insertString(const MintString& str) { if (!str.empty()) { _modified = true; #if defined(USE_BUFFER_ROPE) && !defined(USE_MINTSTRING_ROPE) _text.insert(_point, str.data(), str.size()); #else _text.insert(_point, str); #endif mintcount_t extra_chars = str.size(); mintcount_t extra_newlines = countNewlines(_point, _point + extra_chars); _countNewlines += extra_newlines; _pointLine += extra_newlines; if (_topline > _point) { // topline moves if it is after point _topline += extra_chars; _toplineLine += extra_newlines; } // if adjustMarksIns(extra_chars); _point += extra_chars; } // if return true; } // EmacsBuffer::insertString