Author: mike
Date: 2012-02-06 08:43:26 -0800 (Mon, 06 Feb 2012)
New Revision: 451
Log:
Try using Sys_Menu_Bar for fldiff (doesn't work...)

Add menu options to toggle line numbers and ignore whitespace for the current
window.

Add "go to line" menu item.


Modified:
   trunk/fldiff/DiffWindow.cxx
   trunk/fldiff/DiffWindow.h

Modified: trunk/fldiff/DiffWindow.cxx
===================================================================
--- trunk/fldiff/DiffWindow.cxx 2010-12-21 19:41:45 UTC (rev 450)
+++ trunk/fldiff/DiffWindow.cxx 2012-02-06 16:43:26 UTC (rev 451)
@@ -3,7 +3,7 @@
 //
 // DiffWindow widget code.
 //
-// Copyright 2005-2006 by Michael Sweet.
+// Copyright 2005-2012 by Michael Sweet.
 //
 // This program is free software; you can redistribute it and/or modify
 // it under the terms of the GNU General Public License v2 as published
@@ -129,12 +129,19 @@
                                        // I - Second file
   : Fl_Overlay_Window(640, 480),
     menubar_(0, 0, 640, 25),
+//#ifdef __APPLE__
+//    view_(0, 0, 640, 480)
+//#else
     view_(0, 25, 640, 455)
+//#endif /* __APPLE__ */
 {
   int  W,                              // Width of window
        H;                              // Height of window
 
 
+  // Load preferences...
+  load_prefs();
+
   // Finalize the UI...
   end();
 
@@ -163,6 +170,8 @@
   menubar_.add("&Edit/Preferences...", 0,
                (Fl_Callback *)prefs_cb, this);
 
+  menubar_.add("&Search/Go To Line...", FL_COMMAND | 'l',
+               (Fl_Callback *)goto_line_cb, this);
   menubar_.add("&Search/Find...", FL_COMMAND | 'f',
                (Fl_Callback *)find_cb, this);
   menubar_.add("&Search/Find Next", FL_COMMAND | 'g',
@@ -172,6 +181,15 @@
   menubar_.add("&Search/Next Change", 'n',
                (Fl_Callback *)next_change_cb, this);
 
+  menubar_.add("&View/Ignore Whitespace", FL_SHIFT | FL_COMMAND | 'w',
+               (Fl_Callback *)toggle_ignoreblanks_cb, this,
+               view_.ignoreblanks() ? FL_MENU_TOGGLE | FL_MENU_VALUE
+                                    : FL_MENU_TOGGLE);
+  menubar_.add("&View/Line Numbers", FL_SHIFT | FL_COMMAND | 'l',
+               (Fl_Callback *)toggle_showlinenum_cb, this,
+               view_.showlinenum() ? FL_MENU_TOGGLE | FL_MENU_VALUE
+                                   : FL_MENU_TOGGLE);
+
   menubar_.add("&Help/Using fldiff...", FL_F + 1,
                (Fl_Callback *)using_cb, this);
   menubar_.add("&Help/About fldiff...", 0,
@@ -179,8 +197,6 @@
 
   view_.callback((Fl_Callback *)select_cb, this);
 
-  load_prefs();
-
   // Get the previous window size and resize...
   prefs_.get("window_width", W, 640);
   prefs_.get("window_height", H, 480);
@@ -662,6 +678,21 @@
 
 
 //
+// 'DiffWindow::goto_line_cb()' - Go to a numbered line in the window.
+//
+
+void
+DiffWindow::goto_line_cb(
+    Fl_Menu_Bar *m,                    // I - Menubar
+    DiffWindow  *dw)                   // I - Window
+{
+  const char *s = fl_input("Go to line:");
+
+  dw->view_.showline(atoi(s));
+}
+
+
+//
 // 'DiffWindow::handle()' - Handle UI events in the window.
 //
 
@@ -883,10 +914,9 @@
 //
 
 void
-DiffWindow::next_change_cb(Fl_Menu_Bar *m,
-                                       // I - Menubar
-                           DiffWindow  *dw)
-                                       // I - Window
+DiffWindow::next_change_cb(
+    Fl_Menu_Bar *m,                    // I - Menubar
+    DiffWindow  *dw)                   // I - Window
 {
   int  i;                              // Looping var
 
@@ -1173,10 +1203,9 @@
 //
 
 void
-DiffWindow::select_left_cb(Fl_Menu_Bar *m,
-                                       // I - Menubar
-                           DiffWindow  *dw)
-                                       // I - Window
+DiffWindow::select_left_cb(
+    Fl_Menu_Bar *m,                    // I - Menubar
+    DiffWindow  *dw)                   // I - Window
 {
   dw->view_.select(0, dw->view_.count() - 1, false);
 }
@@ -1187,10 +1216,9 @@
 //
 
 void
-DiffWindow::select_none_cb(Fl_Menu_Bar *m,
-                                       // I - Menubar
-                           DiffWindow  *dw)
-                                       // I - Window
+DiffWindow::select_none_cb(
+    Fl_Menu_Bar *m,                    // I - Menubar
+    DiffWindow  *dw)                   // I - Window
 {
   dw->view_.select(-1, -1, false);
 }
@@ -1201,16 +1229,42 @@
 //
 
 void
-DiffWindow::select_right_cb(Fl_Menu_Bar *m,
-                                       // I - Menubar
-                            DiffWindow  *dw)
-                                       // I - Window
+DiffWindow::select_right_cb(
+    Fl_Menu_Bar *m,                    // I - Menubar
+    DiffWindow  *dw)                   // I - Window
 {
   dw->view_.select(0, dw->view_.count() - 1, true);
 }
 
 
 //
+// 'DiffWindow::toggle_ignoreblanks_cb()' - Toggle diff option to ignore
+//                                          whitespace.
+//
+
+void
+DiffWindow::toggle_ignoreblanks_cb(
+    Fl_Menu_Bar *m,                    // I - Menubar
+    DiffWindow  *dw)                   // I - Window
+{
+  dw->ignoreblanks(!dw->ignoreblanks());
+}
+
+
+//
+// 'DiffWindow::toggle_showlinenum_cb()' - Toggle line numbers.
+//
+
+void
+DiffWindow::toggle_showlinenum_cb(
+    Fl_Menu_Bar *m,                    // I - Menubar
+    DiffWindow  *dw)                   // I - Window
+{
+  dw->showlinenum(!dw->showlinenum());
+}
+
+
+//
 // 'DiffWindow::using_cb()' - Show help window.
 //
 

Modified: trunk/fldiff/DiffWindow.h
===================================================================
--- trunk/fldiff/DiffWindow.h   2010-12-21 19:41:45 UTC (rev 450)
+++ trunk/fldiff/DiffWindow.h   2012-02-06 16:43:26 UTC (rev 451)
@@ -3,7 +3,7 @@
 //
 // DiffWindow widget definitions.
 //
-// Copyright 2005-2006 by Michael Sweet.
+// Copyright 2005-2012 by Michael Sweet.
 //
 // This program is free software; you can redistribute it and/or modify
 // it under the terms of the GNU General Public License v2 as published
@@ -19,7 +19,7 @@
 #  define _DiffWindow_h_
 #  include <FL/Fl.H>
 #  include <FL/Fl_Overlay_Window.H>
-#  include <FL/Fl_Menu_Bar.H>
+#  include <FL/Fl_Sys_Menu_Bar.H>
 #  include <FL/Fl_Preferences.H>
 #  include "DiffView.h"
 
@@ -59,6 +59,7 @@
   static void  find_cb(Fl_Menu_Bar *m, DiffWindow *dw);
   static void  find_next_cb(Fl_Menu_Bar *m, DiffWindow *dw);
   static DiffWindow *find_window(const char *f1, const char *f2);
+  static void  goto_line_cb(Fl_Menu_Bar *m, DiffWindow *dw);
   static void  next_change_cb(Fl_Menu_Bar *m, DiffWindow *dw);
   static void  prefs_cb(Fl_Menu_Bar *m, DiffWindow *dw);
   static void  prev_change_cb(Fl_Menu_Bar *m, DiffWindow *dw);
@@ -68,6 +69,8 @@
   static void  select_left_cb(Fl_Menu_Bar *m, DiffWindow *dw);
   static void  select_none_cb(Fl_Menu_Bar *m, DiffWindow *dw);
   static void  select_right_cb(Fl_Menu_Bar *m, DiffWindow *dw);
+  static void  toggle_ignoreblanks_cb(Fl_Menu_Bar *m, DiffWindow *dw);
+  static void  toggle_showlinenum_cb(Fl_Menu_Bar *m, DiffWindow *dw);
   static void  using_cb(Fl_Menu_Bar *m, DiffWindow *dw);
 
   public:

_______________________________________________
fltk-commit mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-commit

Reply via email to