本文整理汇总了C++中Fl_Text_Buffer::selection_position方法的典型用法代码示例。如果您正苦于以下问题:C++ Fl_Text_Buffer::selection_position方法的具体用法?C++ Fl_Text_Buffer::selection_position怎么用?C++ Fl_Text_Buffer::selection_position使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Fl_Text_Buffer
的用法示例。
在下文中一共展示了Fl_Text_Buffer::selection_position方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Paste
void CFLTKEditor::Paste()
{
string sText, sNewText;
int iInsStart = 0, iInsEnd = 0;
Fl_Text_Editor *pEditor = GetEditor();
Fl_Text_Buffer *pBuffer = pEditor->buffer();
pBuffer->selection_position(&iInsStart, &iInsEnd);
if (iInsStart == iInsEnd)
{
iInsStart = pEditor->insert_position();
Fl_Text_Editor::kf_paste(0, pEditor);
iInsEnd = pEditor->insert_position();
}
else
{
Fl_Text_Editor::kf_paste(0, pEditor);
iInsEnd = pEditor->insert_position();
}
pBuffer->select(iInsStart, iInsEnd);
sText = pBuffer->selection_text();
if (AdaptText(sNewText, sText))
{
pBuffer->replace_selection(sNewText.c_str());
}
pBuffer->unselect();
}
示例2: UnIndent
void CFLTKEditor::UnIndent()
{
bool bChangedBuffer = false;
int iSelStart = 0, iSelEnd = 0, iCurPos = 0, iTabSize, i;
char *pcLine;
Fl_Text_Buffer *pBuffer = GetTextBuffer();
pBuffer->selection_position(&iSelStart, &iSelEnd);
if (iSelEnd > iSelStart)
{
iCurPos = pBuffer->line_start(iSelStart);
iTabSize = pBuffer->tab_distance();
while (pBuffer->line_end(iCurPos) < iSelEnd)
{
pcLine = pBuffer->line_text(iCurPos);
if (pcLine[0] == '\t')
{
bChangedBuffer = true;
pBuffer->remove(iCurPos, iCurPos+1);
--iSelEnd;
}
else if (pcLine[0] == ' ')
{
for (i = 1; i < iTabSize; i++)
{
if (pcLine[i] != ' ')
break;
}
if (i == iTabSize) // same number of spaces as a tab
{
bChangedBuffer = true;
pBuffer->remove(iCurPos, iCurPos + iTabSize);
iSelEnd -= iTabSize;
}
}
iCurPos = pBuffer->skip_lines(iCurPos, 1);
free(pcLine);
}
if (bChangedBuffer)
pBuffer->select(pBuffer->line_start(iSelStart), iSelEnd);
}
}
示例3: Indent
void CFLTKEditor::Indent()
{
bool bChangedBuffer = false;
int iSelStart = 0, iSelEnd = 0, iCurPos = 0;
Fl_Text_Buffer *pcBuffer = GetTextBuffer();
pcBuffer->selection_position(&iSelStart, &iSelEnd);
if (iSelEnd <= iSelStart)
return;
iCurPos = pcBuffer->line_start(iSelStart);
while (pcBuffer->line_end(iCurPos) < iSelEnd)
{
bChangedBuffer = true;
pcBuffer->insert(iCurPos, "\t");
iCurPos = pcBuffer->skip_lines(iCurPos, 1);
++iSelEnd;
}
if (bChangedBuffer)
pcBuffer->select(pcBuffer->line_start(iSelStart), iSelEnd);
}