What is wrong with this GTKSourceView syntax highlighting code?

From: Date: Wed, 05 Dec 2007 18:40:58 +0000
Subject: What is wrong with this GTKSourceView syntax highlighting code?
Groups: php.gtk.general 
Request: Send a blank email to php-gtk-general+get-8136@lists.php.net to get a copy of this message
I'm runnig this simple PHP-GTK2 code to highlight PHP source code, based on this article: http://www.php-gtk.eu/code-snippets/extending-gtksourceview-widget The problem is that the GTKSourceView widget stops doing correct highlight if you type some invalid PHP code then correct it. I installed PHPGTk2 in WIndows XP using this Gnope installation: http://www.gnope.org/download.php Why does it stops hightlting syntax? The code follows: <?php error_reporting(E_ALL); class EditWidget extends GtkSourceView { protected $buffer; protected $lang; protected $mime_lang; function __construct() { parent::__construct(); # default lang $this->mime_lang = 'text/x-php'; $this->set_lang($this->mime_lang); $this->buffer = new GtkSourceBuffer(); $this->set_buffer($this->buffer); $this->set_show_line_numbers(true); $this->set_show_line_markers(true); $this->buffer->set_language($this->lang); $this->buffer->set_highlight(true); } protected function set_lang($mime_type) { $lang_manager = new GtkSourceLanguagesManager(); $this->lang = $lang_manager->get_language_from_mime_type($mime_type); } public function load_file($file) { if (!file_exists($file)) return false; $lines = file_get_contents($file); $this->buffer->begin_not_undoable_action(); $this->buffer->set_text($lines); $this->buffer->end_not_undoable_action(); return true; } } // Create our windows, centered, with scrollbars and the EditWidget class App extends GtkWindow { protected $scrolled_win; protected $edit_widget; function __construct() { parent::__construct(); $edit_widget = new EditWidget(); $edit_widget->load_file(__FILE__); $scrolled_win = new GtkScrolledWindow(); $scrolled_win->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC); $scrolled_win->add_with_viewport($edit_widget); parent::add($scrolled_win); parent::set_title("GtkSourceView Syntax Highlight"); parent::set_size_request(600,480); parent::set_position(Gtk::WIN_POS_CENTER); parent::connect_simple('destroy', array("Gtk", 'main_quit')); parent::show_all(); } } new App; Gtk::Main(); ?>

« previous php.gtk.general (#8136) next »