Revision
102
Author
leonpegg
Date
2007-01-08 03:15:05 -0800 (Mon, 08 Jan 2007)

Log Message

added Visual modified notification, also fixed a few bugs and removed some code duplication

Modified Paths

Diff

Modified: trunk/programs/ide/lib/ide.class.php (101 => 102)


--- trunk/programs/ide/lib/ide.class.php	2007-01-06 18:10:08 UTC (rev 101)
+++ trunk/programs/ide/lib/ide.class.php	2007-01-08 11:15:05 UTC (rev 102)
@@ -26,6 +26,7 @@
 {
 	
 	protected $notebook;
+	protected $last_search;
 	
 	protected $menubar = array(
 		'_File' => array(
@@ -236,6 +237,7 @@
 	
 	public function on_run(){
 		$this->notebook->run();
+		//CC_Os::run('c:\callicore\php.exe c:\php-release\callicore\run.php ide');
 	}
 	
 	public function on_about(){
@@ -290,9 +292,16 @@
 		$this->notebook->redo();
 	}
 
+	public function on_search(){
+		
+	}
+	
 }
 
 # ToDo:-
+# Write CC_Config_XML to alow for better configuration methods
+#  file display settings
+#  convert XML to array structure and retrevable XML node objects
 # preferences dialog
 # php explorer (displaying functions, constants, classes, interfaces)
 # code snippits repo
@@ -300,5 +309,5 @@
 # project manager
 # Indent code (customizable code formater)
 # php manual serach (web or cached local)
-
+# ini editor text and gui based
 ?>
\ No newline at end of file

Modified: trunk/programs/ide/lib/ide_notebook.class.php (101 => 102)


--- trunk/programs/ide/lib/ide_notebook.class.php	2007-01-06 18:10:08 UTC (rev 101)
+++ trunk/programs/ide/lib/ide_notebook.class.php	2007-01-08 11:15:05 UTC (rev 102)
@@ -1,4 +1,31 @@
 <?php
+/**
+ * ide_notebook.class.php - Tabed GtkSourceView Wrapper widget
+ *
+ * handels ide fetures copy, cut, paste, undo, redo, open/newand save
+ * manages GtkSourceView and GtkSourceBuffer properys 
+ *  auto intdent
+ *  space instead of tab
+ *  show line numbers
+ *  smart home end
+ *  tab width
+ *  bracket highlight
+ *  syntax highlight
+ * supports ondrop file open
+ *
+ * This is released under the GPL, see docs/gpl.txt for details
+ *
+ * @author       Leon Pegg <leon@btarchives.com>
+ * @copyright    Leon Pegg (c)2006
+ * @link         http://callicore.net/desktop/programs/ide
+ * @license      http://www.opensource.org/licenses/gpl-license.php GPL
+ * @since        Php 5.2.0
+ * @package      callicore
+ * @subpackage   ide
+ * @category     lib
+ * @filesource
+ * @todo         fix save label issue
+ */
 
 class CC_Ide_notebook extends GtkNotebook {
 
@@ -29,15 +56,22 @@
 		$view = new GtkScrolledWindow();
 		$source = GtkSourceView::new_with_buffer($buffer);
 		$source->set_show_line_numbers(1);
+		$source->set_auto_indent(1);
+		$source->set_highlight_current_line(1);
 		$buffer->set_highlight(1);
+		$buffer->set_check_brackets(1);
 		$view->add($source);
 		$hbox = new GtkHBox();
 		$button = new GtkButton('X');
 		if ($filename == null) {
 			$label = new GtkLabel('untitled-'.self::$count);
+			$label->set_data('filename','untitled-'.self::$count);
 		}else{
 			$label = new GtkLabel(basename($filename));
+			$label->set_data('filename',basename($filename));
 		}
+		$buffer->set_modified(false);
+		$buffer->connect('modified-changed',array($this,'on_modified'),$label);
 		$hbox->pack_start($label);
 		$hbox->pack_start($button);
 		$label->show();
@@ -51,30 +85,57 @@
 		$this->set_current_page($id);
 	}
 	
+	public function get_current_buffer(){
+		$page_id = parent::get_current_page();
+		if ($page_id !== -1){
+			$child = $this->get_nth_page($page_id);
+			$id = $child->get_data('tab_id');
+			return $this->buffers[$id];
+		}
+		return false;
+	}
+	
+	public function get_current_page(){
+		return $this->get_nth_page(parent::get_current_page());
+	}
+	
+	public function &get_current_label(){
+		$child = $this->get_current_page();
+		$tab_label = $this->get_tab_label($child);
+		$tab = $tab_label->get_children();
+		return $tab[0];
+	}
+	
+	public function on_modified($widget, $label){
+		$text = $label->get_data('filename');
+		$text .= ' *';
+		$label->set_text($text);
+	}
+	
 	public function copy(){
 		$cb = GtkClipboard::get(Gdk::atom_intern('CLIPBOARD', false));
-		$child = $this->get_nth_page($this->get_current_page());
+		$child = $this->get_nth_page(parent::get_current_page());
 		$id = $child->get_data('tab_id');
 		$this->buffers[$id]->copy_clipboard($cb);
 	}
 	
 	public function cut(){
 		$cb = GtkClipboard::get(Gdk::atom_intern('CLIPBOARD', false));
-		$child = $this->get_nth_page($this->get_current_page());
+		$child = $this->get_nth_page(parent::get_current_page());
 		$id = $child->get_data('tab_id');
 		$this->buffers[$id]->cut_clipboard($cb,true);
 	}
 	
 	public function paste(){
 		$cb = GtkClipboard::get(Gdk::atom_intern('CLIPBOARD', false));
-		$child = $this->get_nth_page($this->get_current_page());
+		$child = $this->get_nth_page(parent::get_current_page());
 		$id = $child->get_data('tab_id');
 		$iter = $this->buffers[$id]->get_iter_at_mark($this->buffers[$id]->get_insert());
 		$this->buffers[$id]->paste_clipboard($cb,$iter,true);
 	}
 	
 	public function undo(){
-		$child = $this->get_nth_page($this->get_current_page());
+		$child = $this->get_nth_page(parent::get_current_page());
 		$id = $child->get_data('tab_id');
 		if ($this->buffers[$id]->can_undo()) {
 			$this->buffers[$id]->undo();
@@ -82,7 +143,7 @@
 	}
 	
 	public function redo(){
-		$child = $this->get_nth_page($this->get_current_page());
+		$child = $this->get_nth_page(parent::get_current_page());
 		$id = $child->get_data('tab_id');
 		if ($this->buffers[$id]->can_redo()) {
 			$this->buffers[$id]->redo();
@@ -90,9 +151,14 @@
 	}
 	
 	public function save(){
-		$id = $this->get_current_page();
+		$id = parent::get_current_page();
 		if ($id !== -1){
-			$child = $this->get_nth_page($this->get_current_page());
+			$child = $this->get_nth_page(parent::get_current_page());
+			$tab_label = $this->get_tab_label($child);
+			$tab = $tab_label->get_children();
+			$label = $this->get_current_label();
+			//echo $label;
+			$label->set_label($label->get_data('filename'));
 			$filename = $child->get_data('filename');
 			$tab_id = $child->get_data('tab_id');
 			if ($filename !== null) {
@@ -106,13 +172,15 @@
 		// run not complete
 	}
 
+	public function search($sting,$options = array()){
+		
+	}
 	
 	public function on_drop($widget, $context, $x, $y, $data, $info, $time){
 		echo $data->data;
     	$file = explode("\r\n",$data->data);
     	$buffer->set_text(file_get_contents($file[0]));
        	$this->append_page($buffer,$file[0]);
-		//$this->open_file($file[0]);
     }
     
    	public function tab_close($button, $view){