- Subject: folding menus
- From: "John E. Davis" <davis>
- Date: Tue, 5 Mar 2002 16:36:44 -0500
Hi,
Here are some patches that put folding entries in the menus. I
think this patch illustrates a technique for adding so-called minor
modes to the menu system. The patch affects 3 files: popups.sl,
folding.sl, and menus.sl.
--- ../../release/jed/jed-B0.99-15/lib/folding.sl Mon Oct 8 00:48:16 2001
+++ folding.sl Tue Mar 5 16:22:13 2002
@@ -561,10 +561,18 @@
%}}}
+
define folding_mode () %{{{
{
variable s, s1, e, e1;
+ if (Fold_Mode_Ok == 0)
+ {
+ if (1 != get_yes_no ("Folding mode not enabled. Enable it"))
+ return;
+ Fold_Mode_Ok = 1;
+ }
+
#ifdef HAS_BLOCAL_VAR
(s, e, s1, e1) = fold_get_marks_for_mode ();
@@ -651,3 +659,39 @@
}
%}}}
+
+% Fold menu support
+
+static define fold_menu_callback (m)
+{
+#ifdef HAS_BLOCAL_VAR
+ !if (blocal_var_exists ("fold_start"))
+ {
+ menu_append_item (m, "Enable &Folding", "folding_mode");
+ return;
+ }
+#endif
+ menu_append_item (m, "&Fold Buffer", "fold_whole_buffer");
+ menu_append_item (m, "&Unfold Buffer", "fold_open_buffer");
+ menu_append_item (m, "&Enter Fold", "fold_enter_fold");
+ menu_append_item (m, "E&xit Fold", "fold_exit_fold");
+ menu_append_item (m, "&Open Fold", "fold_open_fold");
+ menu_append_item (m, "&Close Fold", "fold_close_fold");
+ menu_append_item (m, "Fold &Region", "fold_fold_region");
+ menu_append_item (m, "&Search Forward", "fold_search_forward");
+ menu_append_item (m, "S&earch Backward", "fold_search_backward");
+}
+
+
+static define install_fold_menus ()
+{
+ menu_delete_item ("Global.&Buffers.Enable &Folding");
+ menu_append_popup ("Global.&Buffers", "&Folding");
+ menu_set_select_popup_callback ("Global.&Buffers.&Folding", &fold_menu_callback);
+}
+
+if (Menu_Popups_Loaded)
+ install_fold_menus ();
+else
+ add_to_hook ("load_popup_hooks", &install_fold_menus);
+
--- ../../release/jed/jed-B0.99-15/lib/popups.sl Mon Oct 8 00:48:16 2001
+++ popups.sl Tue Mar 5 16:07:24 2002
@@ -128,6 +128,7 @@
menu_append_item ($1, "&Kill Buffer", "kill_buffer");
menu_append_item ($1, "&List Buffers", "bufed");
menu_append_popup ($1, "&Select Mode");
+menu_append_item ($1, "Enable &Folding", "folding_mode");
$1 = "Global.&Buffers.&Select Mode";
menu_append_item ($1, "&C Mode", "c_mode");
@@ -231,7 +232,7 @@
}
$1 = "Global.&Help";
-menu_append_item ($1, "A&bout Jed", &about_jed, NULL);
+menu_append_item ($1, "About &Jed", &about_jed, NULL);
#ifndef VMS
add_files_popup_with_callback ($1, "&Browse Docs",
dircat (JED_ROOT, "doc/txt"),
@@ -266,3 +267,5 @@
_jed_run_hooks ("load_popup_hooks", 1, [menubar]);
}
menu_set_select_menubar_callback ("Global", NULL);
+
+Menu_Popups_Loaded = 1;
--- ../../release/jed/jed-B0.99-15/lib/menus.sl Mon Oct 8 00:48:16 2001
+++ menus.sl Tue Mar 5 16:05:32 2002
@@ -1,3 +1,5 @@
+public variable Menu_Popups_Loaded = 0;
+
$1 = "Global";
menu_create_menu_bar ($1);
--------------------------
To unsubscribe send email to <jed-users-request@xxxxxxxxxxx> with
the word "unsubscribe" in the message body.
Need help? Email <jed-users-owner@xxxxxxxxxxx>.
[2002 date index]
[2002 thread index]
[Thread Prev] [Thread Next]
[Date Prev] [Date Next]