本文整理汇总了C++中Fl_Text_Buffer::remove方法的典型用法代码示例。如果您正苦于以下问题:C++ Fl_Text_Buffer::remove方法的具体用法?C++ Fl_Text_Buffer::remove怎么用?C++ Fl_Text_Buffer::remove使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Fl_Text_Buffer
的用法示例。
在下文中一共展示了Fl_Text_Buffer::remove方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ConvertToGCode
void ModelViewController::ConvertToGCode()
{
string GcodeTxt;
Fl_Text_Buffer* buffer = gui->GCodeResult->buffer();
buffer->remove(0, buffer->length());
buffer = gui->GCodeStart->buffer();
char* pText = buffer->text();
string GCodeStart(pText);
buffer = gui->GCodeLayer->buffer();
free(pText);
pText = buffer->text();
string GCodeLayer(pText);
buffer = gui->GCodeEnd->buffer();
free(pText);
pText = buffer->text();
string GCodeEnd(pText);
free(pText);
ProcessControl.ConvertToGCode(GcodeTxt, GCodeStart, GCodeLayer, GCodeEnd);
buffer = gui->GCodeResult->buffer();
GcodeTxt += "\0";
buffer->append( GcodeTxt.c_str() );
redraw();
}
示例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: strlen
static void
serial_handler(
int fd,
void * user_arg
)
{
char line[ 256 ];
int len;
if (serial_fd==0)
return;
if( !read_char_line( serial_fd, line, sizeof(line) ) )
{
perror( "read_char" );
return;
}
len = strlen( line );
line[len++] = '\n';
line[len] = '\0';
if (gui->pause_raw_output->value()!=1) {
gui->raw_serial_output->insert(line);
Fl_Text_Buffer *textBuffer = gui->raw_serial_output->buffer();
int numLines = textBuffer->count_lines(0, textBuffer->length());
gui->raw_serial_output->scroll(numLines, 0);
// ugly way to keep the buffer from growing unchecked
if (numLines > 1000) {
textBuffer->remove(0, (textBuffer->length()-100));
}
}
if( strncmp( line, "$GPADC", 6 ) == 0 )
{
imu_samples++;
update_adc(line);
} else
if( strncmp( line, "$GPPPM", 6 ) == 0 )
{
update_ppm(line);
} else
{
// Ignore the line for now
}
}
示例4: free
static void
style_update(int pos, // I - Position of update
int nInserted, // I - Number of inserted chars
int nDeleted, // I - Number of deleted chars
int /*nRestyled*/, // I - Number of restyled chars
const char * /*deletedText*/,// I - Text that was deleted
void *cbArg) { // I - Callback data
int start, // Start of text
end; // End of text
char last, // Last style on line
*style, // Style data
*text; // Text data
SchemeEditor *editor = (SchemeEditor*)cbArg;
Fl_Text_Buffer *textbuf = editor->buffer();
Fl_Text_Buffer *stylebuf = editor->style_buffer();
// If this is just a selection change, just unselect the style buffer...
if (nInserted == 0 && nDeleted == 0) {
stylebuf->unselect();
return;
}
// Track changes in the text buffer...
if (nInserted > 0) {
// Insert characters into the style buffer...
style = new char[nInserted + 1];
memset(style, 'A', nInserted);
style[nInserted] = '\0';
stylebuf->replace(pos, pos + nDeleted, style);
delete[] style;
} else {
// Just delete characters in the style buffer...
stylebuf->remove(pos, pos + nDeleted);
}
// Select the area that was just updated to avoid unnecessary
// callbacks...
stylebuf->select(pos, pos + nInserted - nDeleted);
// Re-parse the changed region; we do this by parsing from the
// beginning of the previous line of the changed region to the end of
// the line of the changed region... Then we check the last
// style character and keep updating if we have a multi-line
// comment character...
start = textbuf->line_start(pos);
// if (start > 0) start = textbuf->line_start(start - 1);
end = textbuf->line_end(pos + nInserted);
text = textbuf->text_range(start, end);
style = stylebuf->text_range(start, end);
if (start==end)
last = 0;
else
last = style[end - start - 1];
// printf("start = %d, end = %d, text = \"%s\", style = \"%s\", last='%c'...\n",
// start, end, text, style, last);
style_parse(text, style, end - start);
// printf("new style = \"%s\", new last='%c'...\n",
// style, style[end - start - 1]);
stylebuf->replace(start, end, style);
editor->redisplay_range(start, end);
if (start==end || last != style[end - start - 1]) {
// printf("Recalculate the rest of the buffer style\n");
// Either the user deleted some text, or the last character
// on the line changed styles, so reparse the
// remainder of the buffer...
free(text);
free(style);
end = textbuf->length();
text = textbuf->text_range(start, end);
style = stylebuf->text_range(start, end);
style_parse(text, style, end - start);
stylebuf->replace(start, end, style);
editor->redisplay_range(start, end);
}
free(text);
free(style);
}
示例5: ClearGcode
void ModelViewController::ClearGcode()
{
Fl_Text_Buffer* buffer = gui->GCodeResult->buffer();
buffer->remove(0, buffer->length());
}