Пример #1
0
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();
}
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
	}

}