本文整理汇总了C++中Fl_Text_Buffer::count_lines方法的典型用法代码示例。如果您正苦于以下问题:C++ Fl_Text_Buffer::count_lines方法的具体用法?C++ Fl_Text_Buffer::count_lines怎么用?C++ Fl_Text_Buffer::count_lines使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Fl_Text_Buffer
的用法示例。
在下文中一共展示了Fl_Text_Buffer::count_lines方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: cb_save
void text_editor::cb_save(Fl_Widget *widget, void *v)
{
extern std::list<std::string> whitelist;
text_editor *editor = (text_editor*)v;
Fl_Text_Buffer *buffer = editor->buffer;
int buff_length = buffer->length();
int buff_lines = buffer->count_lines(0, buff_length);
if (buff_lines > 0)
{
int pos = 0;
whitelist.clear();
for (int i = 0; i <= buff_lines; i++)
{
char* line_text = buffer->line_text(pos);
std::string line(line_text);
free(line_text);
if(line.length() > 3)
whitelist.push_back(line);
pos = min(buffer->line_end(pos) + 1, buff_length);
}
}
editor->hide();
}
示例2: 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
}
}