jed-0.99-19/0000755002657400265740000000000011311317447011472 5ustar davisdavisjed-0.99-19/COPYING0000644002657400265740000004307011311317447012531 0ustar davisdavis GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 675 Mass Ave, Cambridge, MA 02139, USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 19yy This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19yy name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. jed-0.99-19/lib/0000755002657400265740000000000011311317447012240 5ustar davisdavisjed-0.99-19/lib/info.sl0000644002657400265740000005015511311317447013541 0ustar davisdavis%_debug_info = 1; % % Info reader for JED % variable Info_This_Filename = Null_String; variable Info_This_Filedir = Null_String; #ifndef VMS % returns compression extension if file is compressed or "" if not define info_is_compressed (file) { variable exts, ext, n; exts = ".Z,.z,.gz,.bz2"; n = 0; forever { ext = extract_element(exts, n, ','); if (ext == NULL) return ""; if (1 == file_status(file + ext)) break; n++; } ext; } #endif define info_make_file_name (file) { variable n, dir, dirfile, df, df_low; variable cext = ""; % compressed extension n = 0; forever { % % Try to find requested file in remembered directory. % dirfile = expand_filename(dircat(Info_This_Filedir, file)); if (1 == file_status(dirfile)) break; dir = extract_element(Info_Directory, n, ','); if (dir == NULL) dir = ""; df = expand_filename(dircat(dir,file)); % try with first with info extension #ifdef VMS dirfile = df + "info"; % VMS adds a '.' upon expansion #else dirfile = df + ".info"; #endif if (1 == file_status(dirfile)) break; #ifndef VMS cext = info_is_compressed(dirfile); if (strlen(cext)) break; #endif df_low = expand_filename(dircat(dir,strlow(file))); #ifdef VMS dirfile = df_low + "info"; % VMS adds a '.' upon expansion #else dirfile = df_low + ".info"; #endif if (1 == file_status(dirfile)) break; #ifndef VMS cext = info_is_compressed(dirfile); if (strlen(cext)) break; #endif % try next with inf extension, since .info causes problems on FAT % In addition, Unix and VMS distributions may have been derived from % PC 8+3 distributions. % % Also Windows 95 supports long filenames. Since that OS is also % considered to be MSDOS, we need to try this for MSDOS as well % even though it has no effect under a true MSDOS system. dirfile = df_low + ".inf"; if (1 == file_status(dirfile)) break; #ifndef VMS cext = info_is_compressed(dirfile); if (strlen(cext)) break; #endif % repeat without extension dirfile = df; if (1 == file_status(dirfile)) break; #ifndef VMS cext = info_is_compressed(dirfile); if (strlen(cext)) break; #endif dirfile = df_low; if (1 == file_status(dirfile)) break; #ifdef UNIX cext = info_is_compressed(dirfile); if (strlen(cext)) break; #endif !if (strlen(dir)) error ("Info file not found: " + file); ++n; } (Info_This_Filedir, ) = parse_filename(dirfile); return (dirfile, cext); } private define make_unzip_cmd (ext) { variable unzip_cmd = "uncompress -c"; switch (ext) { case ".gz": unzip_cmd = "gzip -dc"; } { case ".bz2": unzip_cmd = "bzip2 -dc"; } return unzip_cmd; } define info_find_file (file) { variable dirfile, flags, buf, dir; variable ext; (dirfile, ext) = info_make_file_name(file); setbuf("*Info*"); set_readonly(0); widen(); erase_buffer(); #ifndef VMS if (strlen(ext)) () = run_shell_cmd (sprintf("%s %s%s", make_unzip_cmd (ext), dirfile, ext)); else #endif () = insert_file(dirfile); bob(); Info_This_Filename = dirfile; set_readonly(1); set_buffer_modified_flag(0); set_mode("Info", 1); use_keymap("Infomap"); set_status_line(" Jed Info: %f (%m%n) Press '?' for help. (%p)", 0); % The following 2 lines will cause problems when the buffer attached to % the specified file is erased from a re-only directory. %( , dir, buf, flags) = getbuf_info(); %setbuf_info(extract_filename(Info_This_Filename), dir, buf, flags); } define info_find_node_split_file(); % extern variable Info_Split_File_Buffer; Info_Split_File_Buffer = Null_String; variable Info_Split_Filename; Info_Split_Filename = Null_String; define info_search_marker(dir) { variable mark, pnt, search_fun; mark = "\x1F"; if (dir > 0) search_fun = &fsearch; else search_fun = &bsearch; push_mark(); forever { if (not(@search_fun(mark))) { pop_mark_1 (); return(0); } if (bolp()) break; pnt = _get_point (); bol(); skip_chars("\x01-\x1E "); go_right_1 (); pnt = _get_point () - pnt; if ((pnt == 1) and (eolp() or looking_at_char('\xC'))) break; if (dir > 0) eol(); else bol(); } pop_mark_0 (); return (1); } define info_find_node_this_file (the_node) { variable node, len, fnd; CASE_SEARCH = 0; node = "Node: " + the_node; len = strlen(node); widen(); bob(); forever { % some of this could/should be replaced by a regular expression: % !if (re_fsearch("^[\t ]*\x1F")) .... !if (info_search_marker(1)) { % dont give up, maybe this is a split file !if (strlen(Info_Split_File_Buffer)) error("Marker not found. " + node); setbuf(Info_Split_File_Buffer); info_find_node_split_file(the_node); return; } go_down_1 (); % bol(); --- already implicit if (ffind(node)) { % is this really it? --- go_right(len); if (eolp() or looking_at_char(',') or looking_at_char('\t')) break; } eol (); } push_mark(); if (info_search_marker(1)) go_up_1(); else eob(); narrow(); bob(); } define info_find_node_split_file (node) { variable tag, tagpos, pos, pos_len, tag_len, buf, file; variable re; buf = " *Info*"; !if (bufferp(buf), setbuf(buf)) { insbuf("*Info*"); } widen(); % make this re safe tag = str_quote_string (node, "\\^$[]*.+?", '\\'); tag = "Node: " + tag; eob(); %!if (bol_bsearch(tag)) error("tag not found."); %go_right(strlen(tag)); %skip_chars(" \t\x7F"); re = tag + "[\t \x7F]\\d+[ \t]*$"; !if (re_bsearch(re)) verror ("tag %s not found.", tag); eol (); bskip_chars(" \t"); push_mark(); bskip_chars ("0-9"); tagpos = bufsubstr(); % see comment about DOS below tag_len = strlen(tagpos); bob (); bol_fsearch("Indirect:"); pop(); push_mark(); !if (info_search_marker(1)) eob(); narrow(); bob(); forever { !if (down_1 ()) break; % bol(); --- implicit in down !if (ffind(": ")) break; go_right(2); % This will not work on DOS with 16 bit ints. Do strcmp instead. push_mark_eol(); pos = bufsubstr(); pos_len = strlen(pos); if (tag_len > pos_len) continue; if (tag_len < pos_len) break; % now == if (strcmp(tagpos, pos) < 0) break; } Info_Split_File_Buffer = Null_String; go_up_1 (); bol(); push_mark(); () = ffind(": "); widen(); file = bufsubstr(); info_find_file(file); info_find_node_this_file(node); Info_Split_File_Buffer = buf; } define info_narrow() { if (whatbuf () != "*Info*") return; push_spot(); push_spot(); () = info_search_marker(-1); go_down_1 (); push_mark(); pop_spot(); if (info_search_marker(1)) go_up_1 (); else eob(); narrow(); pop_spot(); } % stack for last position !if (is_defined ("Info_Position_Type")) { typedef struct { filename, split_filename, line_number } Info_Position_Type; } variable Info_Position_Stack = Info_Position_Type [16]; variable Info_Stack_Depth = 0; define info_push_position(file, split, line) { variable i; variable pos; if (Info_Stack_Depth == 16) { --Info_Stack_Depth; for (i = 1; i < 16; i++) Info_Position_Stack [i - 1] = @Info_Position_Stack [i]; } pos = Info_Position_Stack [Info_Stack_Depth]; pos.filename = file; pos.split_filename = split; pos.line_number = line; ++Info_Stack_Depth; } define info_record_position () { variable i, file; if (whatbuf() != "*Info*") return; widen(); file = Null_String; if (strlen (Info_Split_File_Buffer)) file = Info_Split_Filename; info_push_position(Info_This_Filename, file, what_line()); info_narrow(); } define info_find_node(node) { variable the_node, file, n, len; n = 0; % Replace \n and \t characters in name by spaces node = strcompress (node, " \t\n"); info_record_position(); ERROR_BLOCK { if (bufferp ("*Info*")) info_reader (); } len = strlen(node); % if it looks like (file)node, extract file, node if (is_substr(node, "(") == 1) n = is_substr(node, ")"); if (n) { variable save_node = "|" + node + "|"; the_node = node; node = substr(the_node, n + 1, strlen(node)); the_node = strsub(the_node, n, 0); % truncate string file = substr(the_node, 2, n-2); if (bufferp(Info_Split_File_Buffer)) delbuf(Info_Split_File_Buffer); Info_Split_File_Buffer = Null_String; info_find_file(file); } node = strtrim (node); !if (strlen(node)) node = "Top"; widen(); push_spot_bob (); !if (info_search_marker(1)) error("Marker not found."); go_down_1 (); if (looking_at("Indirect:"), pop_spot()) { Info_Split_Filename = Info_This_Filename; info_find_node_split_file(node); } else info_find_node_this_file(node); } % If buffer has a menu, point is put on line after menu marker if argument % is non-zero, otherwise leave point as is. % signals error if no menu. define info_find_menu(save) { variable menu_re = "^\\c\\* Menu:"; push_spot(); bob (); forever { !if (re_fsearch(menu_re)) { pop_spot(); error ("Node has no menu."); } go_right (7); !if (looking_at_char (':')) break; } !if (save) { pop_spot(); return; } eol(); go_right_1 (); push_mark(); pop_spot(); pop_mark_1 (); } % Move move the cursor to the start of the next nearest menu item or % note reference in this node if possible. % define info_next_xref () { push_mark (); go_right_1 (); if (re_fsearch("\\*.*:")) exchange_point_and_mark (); pop_mark_1 (); } % % Move move the cursor to the start of the previous nearest menu item or % note reference in this node if possible. % define info_prev_xref () { push_mark (); go_left_1 (); if (re_bsearch("[*].*:")) exchange_point_and_mark (); pop_mark_1 (); } % menu references define info_follow_current_xref () { variable node; push_spot(); !if (fsearch_char (':')) { pop_spot(); error ("Corrupt File?"); } if (looking_at("::")) { push_mark(); pop_spot(); node = bufsubstr(); } else { go_right_1 (); skip_white(); if (eolp()) { go_right_1 (); skip_white(); } push_mark(); if (looking_at_char('(')) () = ffind_char (')'); % comma, tab, '.', or newline terminates skip_chars ("^,.\t\n"); %skip_chars("\d032-\d043\d045\d047-\d255"); bskip_chars(" "); node = bufsubstr(()); pop_spot(); } info_find_node(node); } define info_menu () { variable node, colons, colon; node = Null_String; colon = ":"; colons = "::"; if ((LAST_CHAR == '\r') and re_looking_at ("\\C*Note[ \t\n]")) %and not(bolp ())) { go_right (5); skip_chars (" \t\n"); info_follow_current_xref (); return; } info_find_menu (0); bol (); if (looking_at("* ") and (ffind(colon))) { push_mark(); bol(); go_right(2); node = bufsubstr() + colon; bol (); } !if (strlen (node) and (LAST_CHAR == '\r')) { node = read_mini("Menu item:", node, Null_String); info_find_menu (1); } !if (bol_fsearch("* " + node)) error ("Menu Item not found."); !if (ffind(colon)) error ("Corrupt File?"); if (looking_at(colons)) { push_mark(); bol(); go_right(2); } else { go_right_1 (); skip_white(); push_mark(); if (looking_at_char('(')) { () = ffind_char (')'); } % comma, tab, '.', or newline terminates skip_chars ("^,.\t\n"); %skip_chars("\d032-\d043\d045\d047-\d255"); bskip_chars(" "); } info_find_node(bufsubstr(())); } define info_find_dir() { info_find_node ("(DIR)top"); } define info_up () { bob(); !if (ffind("Up: ")) { info_find_dir (); return; } go_right(4); push_mark(); % comma, tab, or newline terminates skip_chars ("^,.\t\n"); %skip_chars("\d032-\d043\d045-\d255"); bskip_chars(" "); info_find_node(bufsubstr(())); } define info_prev() { variable n; n = 10; bob(); !if (ffind("Previous: ")) { !if (ffind("Prev: ")) error ("Node has no PREVIOUS"); n = 6; } go_right(n); push_mark(); skip_chars ("^,.\t\n"); %skip_chars("\d032-\d043\d045-\d255"); bskip_chars(" "); info_find_node(bufsubstr(())); } define info_goto_last_position () { variable split_file, file, n; variable pos; if (Info_Stack_Depth == 0) return; --Info_Stack_Depth; pos = Info_Position_Stack [Info_Stack_Depth]; split_file = pos.split_filename; file = pos.filename; n = pos.line_number; if ((file == Info_This_Filename) and bufferp("*Info*")) { widen(); goto_line(n); bol(); info_narrow(); return; } if (strlen(split_file)) { setbuf(" *Info*"); set_readonly(0); widen(); erase_buffer(); #ifndef VMS variable ext = info_is_compressed (split_file); if (strlen(ext)) () = run_shell_cmd(sprintf("%s %s%s", make_unzip_cmd (ext), split_file, ext)); else #endif () = insert_file (split_file); Info_Split_File_Buffer = whatbuf (); setbuf ("*Info*"); } !if (strlen(file)) return; info_find_file(file); goto_line(n); bol(); info_narrow(); } define info_next () { bob(); !if (ffind("Next: ")) { info_goto_last_position (); message ("Node has no NEXT."); return; } go_right(6); push_mark(); % comma, tab, or newline terminates skip_chars ("^,.\t\n"); %skip_chars("\d032-\d043\d045-\d255"); bskip_chars(" "); info_find_node(bufsubstr(())); } define info_quick_help() { message("q:quit, h:tutorial, SPC:next screen, DEL:prev screen, m:menu, s:search"); } $2 = "Infomap"; !if (keymap_p($2)) { make_keymap($2); definekey("info_quick_help", "?", $2); definekey("info_tutorial", "h", $2); definekey("info_tutorial", "H", $2); definekey("info_menu", "^M", $2); definekey("info_menu", "M", $2); definekey("info_menu", "m", $2); definekey("info_next_xref", "\t", $2); #ifdef MSDOS MSWINDOWS definekey("info_prev_xref", "^@^O", $2); #endif definekey("info_next", "N", $2); definekey("info_next", "n", $2); definekey("info_prev", "P", $2); definekey("info_prev", "p", $2); definekey("info_up", "U", $2); definekey("info_up", "u", $2); definekey("page_down", " ", $2); definekey("page_up", "^?", $2); definekey("bob", "B", $2); definekey("bob", "b", $2); definekey("info_goto_node", "G", $2); definekey("info_goto_node", "g", $2); definekey("info_quit", "q", $2); definekey("info_quit", "Q", $2); definekey("info_goto_last_position", "l", $2); definekey("info_goto_last_position", "L", $2); definekey("info_search", "S", $2); definekey("info_search", "s", $2); definekey("info_search", "/", $2); definekey("info_follow_reference", "f", $2); definekey("info_follow_reference", "F", $2); definekey("info_find_dir", "D", $2); definekey("info_find_dir", "d", $2); _for (1, 9, 1) { $1 = (); definekey("info_menu_number", string($1), $2); } } define info_quit () { info_record_position(); widen(); delbuf("*Info*"); } define info_goto_node() { info_find_node (read_mini("Node:", Null_String, Null_String)); } define info_search () { variable this_line, this_file, str, err_str, file, wline, ifile, ext; err_str = "String not found."; str = read_mini("Re-Search:", LAST_SEARCH, Null_String); !if (strlen(str)) return; save_search_string(str); widen(); go_right_1 (); if (re_fsearch(str)) { info_narrow(); return; } % % Not found. Look to see if this is split. % !if (strlen(Info_Split_File_Buffer)) { info_narrow(); error (err_str); } this_file = Info_This_Filename; this_line = what_line(); wline = window_line(); %need this so state can be restored after a failure. setbuf(Info_Split_File_Buffer); widen(); bob(); bol_fsearch("Indirect:"); pop(); push_mark(); if (info_search_marker(1)) go_up_1 (); else eob(); narrow(); bob(); bol_fsearch(extract_filename(this_file)); pop(); ERROR_BLOCK { widen(); info_find_file (this_file); goto_line(this_line); eol(); info_narrow(); recenter(wline); } while (down_1 ()) { % bol(); --- implicit push_mark(); !if (ffind_char (':')) {pop_mark_0 (); break; } file = bufsubstr(); flush("Searching " + file); (ifile, ext) = info_make_file_name(file); #ifdef UNIX OS2 if (strlen(ext)) { variable re = str; % Not all greps support -e option. So, try this: if (re[0] == '-') re = "\\" + re; setbuf(" *Info*zcat*"); erase_buffer(); () = run_shell_cmd(sprintf("%s %s%s | grep -ci '%s'", make_unzip_cmd (ext), ifile, ext, re)); bob(); if (looking_at_char ('0')) { delbuf(whatbuf()); setbuf(Info_Split_File_Buffer); continue; } setbuf(Info_Split_File_Buffer); } else #endif !if (search_file(ifile, str, 1)) { setbuf(Info_Split_File_Buffer); continue; } info_find_file(file); pop(fsearch(str)); info_narrow(); info_push_position(this_file, Info_Split_Filename, this_line); return; } error (err_str); } define info_looking_at (ref) { variable n; variable word; push_spot (); EXIT_BLOCK { pop_spot (); } ref = strcompress (ref, " "); n = 0; while (word = extract_element (ref, n, ' '), word != NULL) { n++; skip_chars (" \t\n"); !if (looking_at (word)) return 0; go_right (strlen (word)); } 1; } define info_follow_reference () { variable colon, colons, note, err, item, node, ref; colon = ":"; colons = "::"; note = "*Note"; err = "No cross references."; push_spot(); !if (fsearch(note)) { !if (bsearch(note)) { pop_spot(); error(err); } } pop_spot(); ref = read_mini("Follow *Note", Null_String, Null_String); push_spot_bob (); forever { !if (fsearch(note)) { pop_spot(); error ("Bad reference."); } go_right (5); skip_chars (" \t\n"); % skip_white(); % if (eolp()) % { % go_right_1 (); skip_white(); % } if (info_looking_at(ref)) break; } push_mark(); pop_spot(); %info_record_position pop_mark_1 (); info_follow_current_xref (); } define info_menu_number () { variable node; node = Null_String; variable colon, colons; colons = "::"; colon = ":"; variable n; n = LAST_CHAR; if ((n < '1') or (n > '9')) return (beep()); n -= '0'; info_find_menu(1); while (n) { !if (bol_fsearch("* ")) return (beep()); if (ffind(colon)) --n; else eol(); } if (looking_at(colons)) { push_mark(); bol(); go_right(2); } else { go_right_1 (); skip_white(); push_mark(); if (looking_at_char('(')) { () = ffind_char (')'); } % comma, tab, '.', or newline terminates skip_chars ("^,.\t\n"); %skip_chars("\d032-\d043\d045\d047-\d255"); bskip_chars(" "); } info_find_node(bufsubstr(())); } define info_tutorial() { info_find_node("(info)help"); } private define start_info_reader () { variable ibuf; ibuf = "*Info*"; if (Info_Stack_Depth) info_goto_last_position (); !if (bufferp(ibuf)) info_find_dir(); pop2buf(ibuf); onewindow(); if (0 == is_defined ("info_reader_hook")) run_mode_hooks ("info_mode_hook"); else run_mode_hooks ("info_reader_hook"); } % Usage: % info_reader () % info_reader (args); % args[0] = file % args[1] = node define info_reader () { variable file, node; start_info_reader (); if (_NARGS == 0) return; variable args = (); variable nargs = length (args); local_setkey ("exit_jed", "q"); local_setkey ("exit_jed", "Q"); if (nargs > 0) { file = args[0]; #ifdef UNIX if (path_basename (file) != file) { variable dir = path_dirname (file); file = path_basename (file); Info_Directory = strcat (dir, "," + Info_Directory); } #endif % Goto top incase the requested node does not exist. info_find_node (sprintf ("(%s)top", file)); if (nargs > 1) info_find_node (sprintf ("(%s)%s", file, args[1])); } } jed-0.99-19/lib/sortmisc.sl0000644002657400265740000000137411311317447014450 0ustar davisdavis% This function sorts a region of lines of the form: % keyname % text... % delimeter string % keyname % text... % delimeter string define sort_region_internal (line_break_str, delim) { check_region (0); narrow (); bob (); do { push_mark (); !if (bol_fsearch (delim)) eob (); narrow (); ERROR_BLOCK { widen(); widen (); } bob (); while (eol(), not(eobp())) { del (); insert (line_break_str); } widen (); } while (down_1 ()); mark_buffer (); goto_column (32); ERROR_BLOCK { variable len = strlen (line_break_str); bob (); while (fsearch (line_break_str)) { deln (len); newline (); } widen (); } sort (); EXECUTE_ERROR_BLOCK; } jed-0.99-19/lib/verilog.sl0000644002657400265740000000277211311317447014257 0ustar davisdavis$1 = "VERILOG"; create_syntax_table ($1); define_syntax ("//","",'%', $1); define_syntax ("([{", ")]}", '(', $1); define_syntax ('"', '"', $1); %define_syntax ('\'', '\'', $1); define_syntax ('\$', '\\', $1); define_syntax ('\`', '\\', $1); define_syntax ("0-9a-zA-Z_", 'w', $1); % words define_syntax ("-+0-9a-FA-F.xXL", '0', $1); % Numbers define_syntax (",;.?:=<>", ',', $1); define_syntax ('#', '#', $1); define_syntax ("%-+/&*<>|!~^", '+', $1); set_syntax_flags ($1, 8); % Kikutani Makoto suggests: () = define_keywords ($1, "IFINISOFTOifinisofto", 2); () = define_keywords ($1, "ANDENDFORMAXMINOUTUSEandendformaxminoutreguse", 3); () = define_keywords ($1, "CASEELSELOOPPORTTASKTHENWAITWIREcaseelseloopporttaskthenwaitwire", 4); () = define_keywords ($1, "BEGINEVENTINOUTINPUTINOUTWHILEbegineventinoutinputwhile", 5); () = define_keywords ($1, "ASSIGNBUFFERDOWNTOENTITYMODULEREPEATRETURNSIGNALASSIGNalwaysassignbufferdowntoentitymoduleoutputrepeatreturnsignal", 6); () = define_keywords ($1, "DEFAULTENDCASEENDTASKFOREVERINITIALINTEGERNEGEDGEPOSEDGESPECIFYdefaultendcaseendtaskforeverinitialintegernegedgeposedgespecify", 7); () = define_keywords ($1, "CONSTANTFUNCTIONconstantfunction", 8); () = define_keywords ($1, "ENDMODULEPARAMETERSPECPARAMendmoduleparameterspecparam", 9); () = define_keywords ($1, "ENDSPECIFYendspecify", 10); define verilog_mode () { variable kmap = "VERILOG"; set_mode(kmap, 0x28); use_syntax_table (kmap); run_mode_hooks("verilog_mode_hook"); } jed-0.99-19/lib/iso-lat3.sl0000644002657400265740000000246611311317447014243 0ustar davisdavis%% %% Initializes upper/lowercase lookup tables for ISO Latin 3, %% defined in the ISO 8859-3 standard. %% Made by Byrial Jensen %% if (_slang_utf8_ok == 0) { . 0 64 1 { dup define_case } _for . 65 90 1 { dup 32 + define_case } _for . 91 96 1 { dup define_case } _for . 123 160 1 { dup define_case } _for . 161 177 define_case . 162 165 1 { dup dup define_case 16 + dup define_case } _for . 166 182 define_case . 167 168 1 { dup dup define_case 16 + dup define_case } _for . 169 172 1 { dup 16 + define_case } _for . 173 174 1 { dup dup define_case 16 + dup define_case } _for . 175 191 define_case . 192 222 1 { dup 32 + define_case } _for % That was too much - redefine 3 non-letter holes in the range 192-222 . 195 195 define_case 227 227 define_case . 208 208 define_case 240 240 define_case . 215 215 define_case 247 247 define_case % character 223 is german sharp s: it cannot be treated correctly . 223 223 define_case 255 255 define_case % And now the definition of a word. % I have included all ciphers, letters, hyphen, and soft hyphen (char. 173). define_word (strcat ("-0-9A-Za-z", "\d161\d177", "\d166\d182", "\d169-\d173\d185-\d188", "\d175\d191", "-\d194", "\d196-\d207", "\d209-\d214", "\d216-\d226","\d228-\d239","\d241-\d246", "\d248-\d254")); } jed-0.99-19/lib/abbrev.sl0000644002657400265740000000151611311317447014044 0ustar davisdavis !if (is_defined ("Abbrev_File")) { variable Abbrev_File; $1 = getenv ("JED_HOME"); if ($1 == NULL) { $1 = getenv ("HOME"); if ($1 == NULL) $1 = ""; } #ifdef VMS if (0 == strlen ($1)) { Abbrev_File = "SYS$LOGIN:abbrevs.sl"; } else Abbrev_File = dircat ($1, Abbrev_File); #else #ifdef UNIX Abbrev_File = ".abbrevs.sl"; #else Abbrev_File = "abbrevs.sl"; #endif Abbrev_File = dircat ($1, Abbrev_File); #endif % VMS } if (file_status (Abbrev_File) > 0) pop (evalfile (Abbrev_File)); define set_abbrev_mode (val) { if (val) _set_buffer_flag (0x800); else _unset_buffer_flag (0x800); } define abbrev_mode () { _toggle_buffer_flag (0x800); if (_test_buffer_flag (0x800)) message ("Abbrev mode ON"); else message ("Abbrev mode OFF"); } provide ("abbrev"); jed-0.99-19/lib/comments.sl0000644002657400265740000001773411311317447014441 0ustar davisdavis% Functions and variables for (un-)commenting lines and regions % taken from ide.sl % modified by GM % modified by JED custom_variable ("JED_COMMENT_COLUMN", 40); private variable Comment_Data = Assoc_Type[Struct_Type]; private define extract_major_mode (mode) { % mode can be: "major-mode (minor-mode)" return extract_element (mode, 0, ' '); } %!%+ %\function{get_comment_info} %\synopsis{Get comment information according to mode} %\usage{Struct_Type = get_comment_info ( [mode] ); } %\description % Retrieves the comment information according to the optional \exmp{mode} % argument, or for the present mode if \exmp{mode} is not present. % Every mode that wants to use this function should provide comment information % using the \sfun{set_comment_info} function. % % The returned value is a structure with the following fields: %#v+ % cbeg % begin comment string % cend % end comment string % flags % flags % column % preferred column for comments %#v- % If comment information does not exist for the mode, then \ivar{NULL} will % be returned. %\seealso{set_comment_info, comment_region, comment_line, uncomment_region} %!%- public define get_comment_info () { !if (_NARGS) get_mode_name (); variable modename = (); modename = extract_major_mode (modename); loop (2) { if (assoc_key_exists (Comment_Data, modename)) return Comment_Data[modename]; modename = strlow (modename); } return NULL; } %!%+ %\function{set_comment_info} %\synopsis{Set comment information for a mode} %\usage{set_comment_info ([mode,] cbeg, cend, flags)} %\description % This function sets comment information for a specified mode. If the % optional mode argument is not present, the current mode will be used. The % other 3 required arguments represent the comment start string (\exmp{cbeg}), % the comment end string (\exmp{cend}), and an integer flags argument that % indications how these strings are to be used by the \sfun{comment_region} % function. In particular, \exmp{flags} is a bitmapped integer whose bits % have the following meaning: %#v+ % 0x01 : Comments will start at column defined by the region start, % otherwise comments will be indented to the level of the % first line in the region. % 0x02 : Lines in the region will be padded out to the same column. % 0x04 : Blank lines will be commented. %#v- %\seealso{set_comment_info, comment_region, comment_line, uncomment_region} %!%- public define set_comment_info (cbeg, cend, flags) { if (_NARGS == 3) get_mode_name (); variable mode = (); variable s = struct { cbeg, cend, flags, column }; s.cbeg = cbeg; s.cend = cend; s.flags = flags; s.column = JED_COMMENT_COLUMN; Comment_Data[mode] = s; } public define set_comment_column (column) { if (_NARGS == 1) get_mode_name (); variable mode = (); variable s = get_comment_info (mode); if (s != NULL) s.column = column; } private define _get_comment_info () { variable m = get_mode_name (); m = extract_major_mode (m); variable s = get_comment_info (m); if (s == NULL) verror("No comment strings defined for %s mode", m); return s; } private define compute_max_column (beg_mark, end_mark) { variable max_column; goto_user_mark (end_mark); max_column = what_column (); goto_user_mark (beg_mark); forever { eol (); if (create_user_mark () >= end_mark) break; bskip_white (); if (what_column () > max_column) max_column = what_column (); go_down_1 (); } return max_column; } public define comment_region () { check_region (1); ERROR_BLOCK { pop_spot (); pop_mark_0 (); } variable info = _get_comment_info (); variable cbeg = info.cbeg; variable cend = info.cend; variable flags = info.flags; variable end_mark = create_user_mark (); exchange_point_and_mark (); variable beg_mark = create_user_mark (); variable indent_col = 1; if (beg_mark == end_mark) { pop_spot (); pop_mark_0 (); insert (cbeg); insert (cend); return; } if (flags & 0x01) { indent_col = what_column (); bskip_white (); !if (bolp()) indent_col = 1; } else { skip_chars ("\n\t "); bskip_white (); if (bolp ()) { skip_white (); if (create_user_mark () < end_mark) { indent_col = what_column (); move_user_mark (beg_mark); } } } goto_user_mark (end_mark); bskip_chars ("\n\t "); variable ok_to_pad_end = 0; if (create_user_mark () > beg_mark) { move_user_mark (end_mark); pop_mark_0 (); push_mark (); skip_white (); ok_to_pad_end = eolp (); } variable max_column = 0; if ((flags & 0x02) and strlen (cend)) max_column = compute_max_column (beg_mark, end_mark) + strlen (cbeg); goto_user_mark (beg_mark); insert (cbeg); bol (); narrow_to_region (); ERROR_BLOCK { widen_region (); pop_spot (); } eol (); if (max_column) { trim (); if (what_column () < max_column) goto_column (max_column); } insert (cend); variable comment_blank_lines = flags & 0x04; forever { if (comment_blank_lines) { !if (down_1 ()) break; skip_white (); if (eolp ()) goto_column (indent_col); } else { skip_chars ("\n\t "); if (eobp ()) break; } if (what_column () >= indent_col) goto_column (indent_col); insert (cbeg); eol (); if (max_column) { if ((create_user_mark () < end_mark ()) or ok_to_pad_end) { trim (); if (what_column () < max_column) goto_column (max_column); } } insert (cend); } widen_region (); pop_spot (); } public define uncomment_region () { check_region (1); variable end_mark = create_user_mark (); exchange_point_and_mark (); narrow_to_region (); ERROR_BLOCK { widen_region (); pop_spot (); } variable info = _get_comment_info (); variable cbeg = info.cbeg; variable cend = info.cend; variable do_trim = info.flags & 0x02; variable len_cbeg = strlen (cbeg); variable len_cend = strlen (cend); do { !if (ffind (cbeg)) continue; deln (len_cbeg); eol (); !if (bfind (cend)) continue; deln (len_cend); if (do_trim) { skip_white (); if (eolp ()) trim (); } } while (down_1 ()); widen_region (); pop_spot (); } public define comment_line () { ERROR_BLOCK { pop_spot (); } push_spot_bol (); push_mark_eol (); comment_region (); pop_spot (); } public define uncomment_line () { ERROR_BLOCK { pop_spot (); } push_spot_bol (); push_mark_eol (); uncomment_region (); pop_spot (); } public define comment_region_or_line () { if (-1 != prefix_argument (-1)) { uncomment_region_or_line (); return; } if (markp ()) return comment_region (); variable s = _get_comment_info (); push_spot (); bol_skip_white (); if (looking_at (s.cbeg)) { pop_spot (); return uncomment_line (); } pop_spot (); comment_line (); } public define uncomment_region_or_line () { if (markp ()) uncomment_region (); else uncomment_line (); } % for some modes we have comment string definitons here set_comment_info ("html", "", 0); set_comment_info ("sgml", "", 0); set_comment_info ("docbook", "", 0); set_comment_info ("C", "/* ", " */", 0); set_comment_info ("SLang", "% ", "", 0); set_comment_info ("TeX", "% ", "", 0); set_comment_info ("LaTeX", "% ", "", 0); set_comment_info ("SH", "# ", "", 0); set_comment_info ("matlab", "# ", "", 0); set_comment_info ("perl", "# ", "", 0); set_comment_info ("Fortran", "C ", "", 0); set_comment_info ("TPas", "{ ", " }", 0); set_comment_info ("PHP", "// ", "", 0); set_comment_info ("java", "/* ", " */", 0); set_comment_info ("tm", "#% ", "", 0); set_comment_info ("python", "# ", "", 0); set_comment_info ("idl", "; ", "", 0); provide ("comments"); jed-0.99-19/lib/mousex.sl0000644002657400265740000002050411311317447014121 0ustar davisdavis% mousex.sl -*- SLang -*- % % FIXME!!! % This file does not work properly when the buffer contains folds. %------------------------------------------------------------------ % % Mouse routines for use inside an XTerm % (and for Linux Console running selection/gpm?) % % Mouse actions: % LEFT: % If a region is marked, unmark it. % Move the point to this new location. % % MIDDLE: % If a region is marked, copy it to the pastebuffer. % Otherwise, paste contents of the pastebuffer at the current point. % % RIGHT: % Extend the region to this point. % % Ctrl-MIDDLE: % If a region is marked, cut it to the pastebuffer. % % Status line actions: % LEFT: switch window to a different buffer % MIDDLE: split the window % RIGHT: delete the window % % Cut/Paste Tips: % 1. LEFT click at the beginning of the region, drag to the end of the % region and release. % % 2. RIGHT click to extend the marked region. % % 3. MIDDLE click to COPY the marked region to the pastebuffer. % or % Ctrl-MIDDLE click to KILL the marked region to the pastebuffer. % % 4. MIDDLE click to paste the contents of the pastebuffer at the % current point (use Step 1 to set the current point). % % Notes: % Since XTerm normally uses Ctrl+MouseButton to activate popup menus, % you can use ^C+MouseButton to simulate a Ctrl+MouseButton event % -- i.e. press and release ^C before a mouse button event. % % To temporarily override XTerm mouse reporting -- and get the normal % mouse selection behaviour -- hold down Shift or Mod1 (Meta, Alt) while % performing the mouse action. % % Note that the mouse bindings use copy_region/kill_region/yank, while % the key bindings typically use the yankpop equivalents so, in effect, % the mouse gets its own kill buffer. % mj olesen % Someone tried to use this with Xjed. Stop that now. if (is_defined ("X_LAST_KEYSYM")) { verror ("%s should not be loaded if using Xjed", "mousex.sl"); } variable Mouse_Event_Type = 0, Mouse_X = 0, Mouse_Y = 0; variable Mouse_Button = 3; % start with ButtonRelease event setkey (".0 mouse_event", "\e[M"); % MouseButton setkey_reserved (".'c'mouse_event", "\e[M");% simulate Ctrl+MouseButton setkey (".'m'mouse_event", "\e\e[M"); % simulate Meta+MouseButton setkey (".'s'mouse_event", "\e[\e[M"); % simulate Shift+MouseButton % hooks to properly restore selection state (See $JED_ROOT/doc/mouse.txt) % The XTerm mouse protocol sends a string encoded as: % ESC [ M 'b' 'x' 'y' % Here 'b' represents the key state and button information. It is a number % equal to 32 + button-number + key-state. The left-button is button-number 0, % the middle is 1, and the right is 2. A value of 3 appears to indicate % a button release event. The key-state is: % 4 = Shift % 8 = Meta % 16 = Ctrl % 32 = double click (rxvt) % % x and y represent the 32 + column and 32 + row. % private define mousex_init_display_hook () { variable esc_seq = "\e[?1000h"; if (strncmp (getenv ("TERM"), "xterm", 5)) esc_seq = "\e[?9h"; % (X10 compatibility) NOT xterm tt_send (esc_seq); } private define mousex_reset_display_hook () { variable esc_seq = "\e[?1000l"; if (strncmp (getenv ("TERM"), "xterm", 5)) esc_seq = "\e[?9l"; % NOT xterm tt_send (esc_seq); } %hook_add_to_hook (&Reset_Display_Hook_List, &mousex_reset_display_hook); %hook_add_to_hook (&Init_Display_Hook_List, &mousex_init_display_hook); %hook_add_hook ("reset_display_hook", &mousex_reset_display_hook); %hook_add_hook ("init_display_hook", &mousex_init_display_hook); add_to_hook ("_jed_reset_display_hooks", &mousex_reset_display_hook); add_to_hook ("_jed_init_display_hooks", &mousex_init_display_hook); mousex_init_display_hook (); % a hook into mouse-based menus (someday) private define mousex_menu (x, y) { call ("select_menubar"); } private define mousex_report (status) { sprintf ("Button <%d>: ", Mouse_Button); if (status) "Status line"; else sprintf ("col,row = %d,%d Top,Rows = %d,%d", Mouse_X, Mouse_Y, window_info('t'), window_info('r')); flush (strcat ()); } % missed release -- don't redefine define mousex_3 (status) {} % modifiers: 's' = Shift (4), 'm' = Meta (8), 'c' = Control (16) define mouse_event (Mod) { variable n, status = 0; variable meta = META_CHAR; variable dec8 = DEC_8BIT_HACK; META_CHAR = -1; DEC_8BIT_HACK = 0; n = _getkey () - 040; % button number + Modifiers Mouse_X = _getkey () - 040; % Column Mouse_Y = _getkey () - 040; % Row META_CHAR = meta; dec8 = DEC_8BIT_HACK; % NB: xterm and rxvt use Shift and Meta to override mouse reporting % and xterm use Ctrl for popup menus. if ((n & 3) == 3) % release event { Mouse_Event_Type = 0; % use Mouse_Button from last ButtonPress } else { Mouse_Event_Type = 1; Mouse_Button = (n & 3); switch (Mod) % convert to logical masks { case 'c': 16;} % fake Ctrl+MouseButton { case 'm': 8;} % fake Meta+MouseButton { case 's': 4;} % fake Shift+MouseButton { 0;} % unadulterated Mod = (); Mouse_Button = Mouse_Button | Mod; } % error (sprintf ("Button <%d>: x,y: %d,%d", Mouse_Button, x, y)); n = nwindows (); while (n) { variable top = window_info('t'); variable bot = window_info('r') + top; if (Mouse_Y == bot) { status = 1; break; } else if ((Mouse_Y >= top) and (Mouse_Y < bot)) { Mouse_Y += 1 + what_line () - (top + window_line()); break; } otherwindow (); n--; } !if (n) { if (Mouse_Y == 1) % Mouse on top status line { if (Mouse_Event_Type) mousex_menu (Mouse_Event_Type, Mouse_X); return; } Mouse_Button = 3; !if (Mouse_Event_Type) error ("Mouse not in a window"); emacs_escape_x (); return; } loop (n) otherwindow (); Mouse_X += window_info('c') - 1; n = nwindows () - n; loop (n) otherwindow (); if (not(Mouse_Event_Type) or status) EXIT_BLOCK { Mouse_Button = 3; } variable fn = sprintf ("mousex_%d", Mouse_Button); !if (Mouse_Event_Type) { if (n) return; % must be the same window fn = strcat (fn, "U"); } if (is_defined (fn) > 0) { status; eval(strcat (".", fn)); % Use RPN--- no need to parse it } else { if (Mouse_Event_Type) mousex_report (status); % Unbound ... just report } } %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % service functions private define mouse_next_buffer () { variable n, buf, cbuf = whatbuf (); n = buffer_list (); % buffers on stack loop (n) { buf = (); n--; if (buf[0] == ' ') continue; if (buffer_visible (buf)) continue; sw2buf (buf); _pop_n (n); return; } message ("All buffers are visible."); } % move to a new x, y location with/without extending the region private define mouse_goto (moveto) { if (moveto) pop_mark_0 (); else !if (is_visible_mark ()) push_visible_mark (); if (Mouse_Y == what_line ()) { variable col = what_column (); % deal with going past end-of-line if (col == goto_column_best_try (Mouse_X)) % didn't move pop_mark (0); } else { goto_line (Mouse_Y); () = goto_column_best_try (Mouse_X); } } %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % normal mouse event bindings, redefine as desired. % % mouse_?, mouse_?U (`U' means UP -- Button Release) % `?' = 0-2 = None + l/m/r Button % = 4-6 = Shift + l/m/r Button % = 8-10 = Meta + l/m/r Button % = 16-18 = Ctrl + l/m/r Button % Left define mousex_0 (status) { if (status) mouse_next_buffer (); else mouse_goto (1); } % Left-Release define mousex_0U (status) { !if (status) mouse_goto (0); } % Middle define mousex_1 (status) { if (status) splitwindow (); else if (markp ()) { call ("copy_region"); flush ("region copied"); } else call ("yank"); } % Right define mousex_2 (status) { if (status) call ("delete_window"); else mouse_goto (0); } % Ctrl-Middle define mousex_17 (status) { if (status) return; else if (markp ()) { call ("kill_region"); flush ("region killed"); } } % Other possible bindings #iftrue % Ctrl-Left define mousex_16 (status) { if (status) enable_top_status_line (1); else { goto_line (Mouse_Y); recenter (0); } } % Ctrl-Right define mousex_18 (status) { if (status) enable_top_status_line (0); else mousex_report (status); } #endif jed-0.99-19/lib/modehook.sl0000644002657400265740000000735111311317447014413 0ustar davisdavis% modehook.sl -*- SLang -*- %!%+ %\variable{Enable_Mode_Hook_Eval} %\synopsis{Control the use of "eval" from a file's mode statement} %\description % When a file is read into a buffer, the editor will look for a line near the % top of the file containing \exmp{-*- TEXT -*-}, where \exmp{TEXT} usually % specifies the mode to be applied to the buffer, e.g., %#v+ % /* -*- C -*- */ %#v- % For this reason, such a line is referred to as the files mode statement. % In addition, an arbitrary \slang expression may be executed by % the mode statement through the use of \var{eval} and \var{evalfile}, e.g., %#v+ % /* -*- mode: C; eval: set_buffer_no_backup; -*- */ %#v- % This example would cause c-mode to be assigned to the buffer, and backups % for the file turned-off. Obviously this poses a security risk, since it % permits the evaluation of arbitrary \slang code. % % The \var{Enable_Mode_Hook_Eval} variable may be used to control how % \var{eval}, and other potentially risky constructs are handled by the file's % mode statement. If its value is 0, such statements will not get executed. % If the value of \var{Enable_Mode_Hook_Eval} is \NULL, then the editor will % query the user about whether to execute the statement, otherwise such % statements will get executed. The default value is \NULL, i.e., to % query the user. %\seealso{modeline_hook2, eval, evalfile, set_mode} %!%- custom_variable ("Enable_Mode_Hook_Eval", NULL); private define check_eval (checked) { if (@checked != -1) return @checked; if (Enable_Mode_Hook_Eval == NULL) { sw2buf (whatbuf ()); update (1); @checked = get_yes_no ("Allow execution of file's mode statement"); } else @checked = Enable_Mode_Hook_Eval == 1; return @checked; } %\function{modeline_hook2} %\synopsis{modeline_hook2} %\description % check for the following mode statements: %#v+ % -*- mode: NAME -*- set mode to NAME % -*- evalfile: FILE -*- evaluate file FILE % -*- eval: expression -*- evaluate expression % -*- VAR: VALUE -*- set VAR = VALUE %#v- % these statements may be combined: %#v+ % -*- mode: NAME; evalfile: FILE; VAR: VALUE -*- %#v- define modeline_hook2 () { variable keyword, value, mode = 0, tag = "-*-", modestr; if (BATCH) return 0; bob (); !if (fsearch (tag)) return 0; variable checked = -1; while (ffind (tag)) { go_right (3); #iffalse if (looking_at ("END -*-")) break; #endif push_spot (); skip_white (); !if (ffind (tag), pop_spot ()) break; % closing tag exists? forever { skip_chars (" \t;"); push_mark (); !if (ffind_char (':')) { pop_mark_0 (); break; } keyword = bufsubstr (); go_right_1 (); push_mark (); do { skip_chars ("^-;\n"); if (looking_at_char (';') or looking_at (tag)) break; } while (right (1)); value = strtrim (bufsubstr ()); push_spot (); ERROR_BLOCK { pop_spot (); } % error (sprintf ("keyword <%s> value <%s>", keyword, value)); switch (keyword) { case "mode": modestr = "_mode"; value = strlow (strtrans (value, "-", "_")); !if (is_substr (value, modestr)) value += modestr; if (value == "c++_mode") value = "c_mode"; if (is_defined(value)) { eval (value); mode++; } } { case "evalfile": if (check_eval (&checked)) evalfile (value); } { case "eval" : if (check_eval (&checked)) eval (value); } { (is_defined (keyword) < 0) and strlen(value): % set a value if (check_eval (&checked)) eval (keyword + " = " + value); } pop_spot (); } go_down_1 (); } mode; } jed-0.99-19/lib/most.sl0000644002657400265740000000726111311317447013570 0ustar davisdavis%% %% Most/more/less file viewing %% define most_edit () { set_readonly(0); getbuf_info(); pop(); pop(); pop(); file_type(); runhooks("mode_hook"); set_status_line("", 0); } variable Most_N_Windows = 1; define most_exit_most () { variable flags; most_edit (); !if (buffer_modified ()) delbuf (whatbuf ()); otherwindow (); if (Most_N_Windows == 2) onewindow (); message ("Done."); } define most_help () { message ( "SPC:pg dn, DEL:pg up, /:search forw, ?:search back, q:quit, e:edit, h:this help" ); } variable Most_Map = "Most"; !if (keymap_p (Most_Map)) { make_keymap (Most_Map); _for ('A', 'z', 1) { undefinekey (char (), Most_Map); } definekey ("page_up", char (127), Most_Map); % delete definekey ("page_down", char (' '), Most_Map); definekey ("most_exit_most", char ('q'), Most_Map); definekey ("most_edit", char ('e'), Most_Map); definekey ("most_find_f", char ('s'), Most_Map); definekey ("most_find_f", char ('S'), Most_Map); definekey ("most_find_f", char ('/'), Most_Map); definekey ("most_find_b", char ('?'), Most_Map); definekey ("most_find_n", char ('N'), Most_Map); definekey ("most_help", char ('h'), Most_Map); definekey ("eob", char ('B'), Most_Map); definekey ("bob", char ('T'), Most_Map); } %!%+ %\function{most_mode} %\synopsis{most_mode} %\description % Emulates MOST fileviewer % The following keys are defined: %#v+ % SPACE next screen % DELETE previous screen % / search_forward % ? search_backward % n find next occurrence % q quit most mode (usually kills buffer if not modified) % e edit buffer % h help summary % t Top of Buffer % b End of Buffer %#v- %!%- define most_mode () { use_keymap (Most_Map); set_readonly (1); set_mode (Most_Map, 0); set_status_line (" MOST : press 'h' for help. %b (%p)", 0); Most_N_Windows = nwindows (); } variable Most_Search_Dir = 1; define most_find_n () { variable r; !if (strlen (LAST_SEARCH)) error ("Find What?"); if (Most_Search_Dir > 0) { r = right (1); if (fsearch (LAST_SEARCH)) return; go_left (r); } else { if (bsearch (LAST_SEARCH)) return; } error ("Not Found."); } define most_find_b () { Most_Search_Dir = -1; search_backward (); } define most_find_f () { Most_Search_Dir = 1; search_forward (); } %%% Emulate MOST fileviewer. variable Most_Min_Arg, Most_Current_Arg; define run_most (arg) { Most_Min_Arg = arg; Most_Current_Arg = arg; if (arg != __argc) () = find_file (__argv[arg]); most_mode (); definekey ("most_next_file", ":N", Most_Map); definekey ("exit_jed", "q", Most_Map); definekey ("exit_jed", "Q", Most_Map); definekey ("most_exit_most", ":Q", Most_Map); help_for_help_string = "Most Mode: SPC- next screen, DEL- prev screen, Q Quit, :n next file, :Q edit"; } define most_next_file () { variable f, file, dir = 1; forever { Most_Current_Arg += dir; if (Most_Current_Arg == __argc) Most_Current_Arg = Most_Min_Arg; if (Most_Current_Arg < Most_Min_Arg) Most_Current_Arg = __argc - 1; file = __argv[Most_Current_Arg]; flush (strcat ("Next File (Use Arrow keys to select): ", file)); (,f) = get_key_binding (); if (typeof (f) == String_Type) { if (f == "previous_line_cmd") { dir = 1; continue; } if (f == "next_line_cmd") { dir = -1; continue; } break; } else beep (); } () = find_file (file); message (Null_String); most_mode (); } provide ("most"); jed-0.99-19/lib/untab.sl0000644002657400265740000000200411311317447013705 0ustar davisdavis% untabify region function define untab_convert_to_tabs () { variable c; while (fsearch_char (' ')) { c = what_column (); push_mark (); skip_white (); c = what_column () - c; if (c > 1) { del_region (); whitespace (c); } else pop_mark_0 (); } } %!%+ %\function{untab} %\synopsis{untab} %\usage{Void untab ();} %\description % This function may be used either to convert tabs to spaces or, if called % with a prefix argument, it will perform the opposite conversion from % spaces to tabs. This function operates on a region. %!%- define untab () { check_region (0); narrow (); bob (); if (-1 != prefix_argument (-1)) { untab_convert_to_tabs (); } else { while (fsearch ("\t")) { TAB; % on stack skip_white (); what_column (); % on stack bskip_chars ("\t "); () - what_column (); % on stack trim (); TAB = 0; whitespace (()); TAB = (); } } widen (); } jed-0.99-19/lib/syntax.sl0000644002657400265740000000606711311317447014137 0ustar davisdavis% syntax.sl -*- SLang -*- % The functions here are used to manipulate the syntax keyword tables % % Note: Eventually code here will need to be changed to use character semantics. % The user should not have to worry about multibyte encodings. % private define add_hash_to_syntax_table (tbl, hash, len, n) { variable i; hash = assoc_get_keys (hash); i = array_sort (hash); hash = strjoin (hash[i], ""); () = define_keywords_n (tbl, hash, len, n); hash; } %!%+ %\function{add_keywords} %\synopsis{add_keywords} %\usage{String add_keywords (String tbl, String kws, Int len, Int n);} %\description % % Adds a set of keywords `kws', each of length `len', to the already % existing syntax table `tbl'. For convenience of the user, the function % does alphabetical sorting and removes duplicate entries. % % The previous list of keywords is returned. %\seealso{define_keywords_n, create_syntax_table, add_keyword_n} %!%- define add_keywords (tbl, kws, len, n) { variable okws, a, i, j, num, idx; variable hash; % add old keywords kws += define_keywords_n (tbl, "", len, n); num = strbytelen (kws) / len; !if (num) return ""; hash = Assoc_Type[Int_Type]; _for (0, num-1, 1) { i = (); hash [substrbytes (kws, 1 + i * len, len)] = 1; } add_hash_to_syntax_table (tbl, hash, len, n); } %!%+ %\function{add_keyword_n} %\synopsis{add_keyword_n} %\usage{Void add_keyword_n (String tbl, String kw, Int n);} %\description % % Adds a single keyword `kw' to the already existing syntax table `tbl'. %\seealso{define_keywords_n, create_syntax_table, add_keywords} %!%- define add_keyword_n (tbl, kw, n) { variable len = strbytelen (kw); !if (len) return; () = add_keywords (tbl, kw, len, n); } %!%+ %\function{add_keyword} %\synopsis{add_keyword} %\usage{Void add_keyword (String_Type tbl, String_Type kw);} %\description % % Adds a single keyword `kw' to the already existing syntax table `tbl'. %\seealso{define_keywords_n, create_syntax_table, add_keyword_n} %!%- define add_keyword () { add_keyword_n (0); } %!%+ %\function{remove_keywords} %\synopsis{remove_keywords} %\usage{String remove_keywords (String tbl, String kws, Int len, Int n);} %\description % Removes a set of keywords `kws', each of length `len', from the already % existing syntax table `tbl'. % % The previous list of keywords is returned. %\seealso{add_keywords, define_keywords_n, create_syntax_table, add_keyword_n} %!%- define remove_keywords (tbl, kws, len, n) { variable okws, num, nrem, i, rm; variable hash; % the old keywords okws = define_keywords_n (tbl, "", len, n); num = strbytelen (okws) / len; nrem = strbytelen (kws) / len; !if (nrem) { () = define_keywords_n (tbl, okws, len, n); return okws; } hash = Assoc_Type[Int_Type]; _for (0, num-1, 1) { i = (); hash [substrbytes (okws, 1 + i * len, len)] = 1; } % remove unwanted entries _for (0, nrem-1, 1) { i = (); assoc_delete_key (hash, substrbytes (kws, 1 + i * len, len)); } () = add_hash_to_syntax_table (tbl, hash, len, n); okws; } jed-0.99-19/lib/buf.sl0000644002657400265740000000673611311317447013370 0ustar davisdavis%% Buffer routines for Jed. Functions included here are: %% %% save_buffers : saves buffers that are associated with a file %% with no user intervention %% recover_file : restore buffer from autosave file. %% %% %!%+ %\function{save_buffers} %\synopsis{save_buffers} %\usage{Void save_buffers ();} %\description % Save all modified buffers that are associated with a file without % user intervention. %!%- define save_buffers () { variable file, dir, flags, buf, ch; loop (buffer_list()) { buf = (); ch = int(buf); if ((ch == 32) or (ch == '*')) continue; %% internal buffer or special (file, dir,, flags) = getbuf_info (buf); !if (strlen(file)) continue; %% no file assciated with it if (flags & 1) { setbuf(buf); () = write_buffer(dircat (dir, file)); } } } %% write region to file define write_region() { variable file; !if (markp) error("Set Mark first!"); file = read_file_from_mini("File:"); write_region_to_file(file); } define append_region () { variable file; !if (markp) error("Set Mark first!"); file = read_file_from_mini("Append to File:"); if (-1 == append_region_to_file(file)) error ("Append failed."); } ;%% restores buffer from autosave file. define recover_file () { variable flags, file, dir, as, buf; (file, dir,, flags) = getbuf_info(); !if (strlen(file)) error("Buffer not associated with a file."); as = make_autosave_filename (dir, file); if (file_status(as) != 1) { error (as + " not readable."); } buf = whatbuf(); as; if (file_time_compare(as, dircat (dir, file))) { " more recent. Use it"; } else " not recent. Use it"; if (get_yes_no(() + ()) > 0) { what_line(); setbuf(buf); erase_buffer(); () = insert_file(as); goto_line(); } } %!%+ %\function{next_buffer} %\synopsis{Cycle through the list of buffers} %\usage{Void next_buffer ()} %\description % Switches to the next in the list of buffers. %\notes % (This is the same function as mouse_next_buffer in mouse.sl) %\seealso{buffer_list, list_buffers} %!%- public define next_buffer () { variable n, buf, cbuf = whatbuf (); n = buffer_list (); %/* buffers on stack */ loop (n) { buf = (); n--; if (buf[0] == ' ') % hidden buffers like " " continue; sw2buf (buf); _pop_n (n); return; } } %{{{ save_buffer_as(force_overwrite = 0) %!%+ %\function{save_buffer_as} %\synopsis{Save the buffer to a different file/directory} %\usage{Void save_buffer_as(force_overwrite=0)} %\description % Asks for a new filename and saves the buffer under this name. % Asks before overwriting an existing file, if not called with % force_overwrite=1. % Sets readonly flag to 0, becouse if we are able to write, % we can also modify. %\seealso{save_buffer, write_buffer} %!%- define save_buffer_as () { variable force_overwrite = 0; if (_NARGS) force_overwrite = (); variable file = read_file_from_mini(sprintf("Save %s to:", whatbuf())); !if (strlen(file)) return; if (file_status(file) == 2) % directory file = path_concat (file, extract_element(whatbuf(), 0, ' ')); if ((force_overwrite == 0) and (1 == file_status (file))) { if (1 != get_y_or_n (sprintf ("File \"%s\" exists, overwrite?", file))) return; } () = write_buffer(file); set_readonly(0); % if we are able to write, we can also modify } %}}} jed-0.99-19/lib/occur.sl0000644002657400265740000000277611311317447013727 0ustar davisdavis%% occur function %% $1 = "Occur"; !if (keymap_p ($1)) { make_keymap ($1); } definekey ("occur_goto_line", "g", $1); variable Occur_Buffer = Null_String; define occur_goto_line () { variable line; !if (bufferp (Occur_Buffer)) return; bol (); push_mark (); !if (ffind (":")) { pop_mark_0 (); return; } line = integer (bufsubstr ()); pop2buf (Occur_Buffer); goto_line (line); } %!%+ %\function{occur} %\synopsis{occur} %\usage{Void occur ();} %\description % This function may be used to search for all occurances of a string in the % current buffer. It creates a separate buffer called \var{*occur*} and % associates a keymap called \var{Occur} with the new buffer. In this % buffer, the \var{g} key may be used to go to the line described by the % match. %!%- define occur() { variable str, tmp, n; str = read_mini("Find All (Regexp):", LAST_SEARCH, Null_String); !if (strlen (str)) return; tmp = "*occur*"; Occur_Buffer = whatbuf(); pop2buf(tmp); erase_buffer(); pop2buf(Occur_Buffer); push_spot(); bob (); while (re_fsearch(str)) { line_as_string (); % stack-- at eol too n = what_line (); setbuf(tmp); vinsert ("%4d:", n); insert(()); newline(); setbuf(Occur_Buffer); !if (down_1 ()) %% so we do not find another occurance on same line break; } pop_spot(); setbuf(tmp); bob(); set_buffer_modified_flag(0); use_keymap ("Occur"); run_mode_hooks ("occur_mode_hook"); } jed-0.99-19/lib/mini.sl0000644002657400265740000001110311311317447013530 0ustar davisdavis% % Recall previous commands in MiniBuffer % % If -2, never store duplicates, use Least-Recently-Used strategy % If -1, store only if not equal to last entered value % If 0, never store duplicates custom_variable ("Mini_Store_Duplicates", 1); private variable Max_Num_Lines = 32; private variable Mini_Previous_Lines; private variable Mini_Last_Line; private variable Mini_First_Line; private variable Mini_Next_Line; private define initialize () { Mini_Previous_Lines = String_Type [Max_Num_Lines]; Mini_Last_Line = 0; Mini_First_Line = 0; Mini_Next_Line = 0; Mini_Previous_Lines[[:]] = ""; } initialize (); private define mini_use_this_line () { erase_buffer (); insert (Mini_Previous_Lines[Mini_Next_Line]); } define next_mini_command () { variable line; if (Mini_Next_Line == Mini_Last_Line) error ("End of list!"); Mini_Next_Line++; % if (Mini_Next_Line == Max_Num_Lines) Mini_Next_Line = 0; Mini_Next_Line = Mini_Next_Line mod Max_Num_Lines; mini_use_this_line (); } define prev_mini_command () { variable line; line = Mini_Next_Line; if (line == Mini_Last_Line) Mini_Previous_Lines [line] = line_as_string (); if (Mini_First_Line == Mini_Next_Line) error ("Top of list!"); Mini_Next_Line = (Mini_Next_Line + Max_Num_Lines - 1) mod Max_Num_Lines; mini_use_this_line (); } private define store_line (s) { if ((s == NULL) or (s == "")) return; Mini_Previous_Lines[Mini_Last_Line] = s; Mini_Last_Line++; Mini_Last_Line = Mini_Last_Line mod Max_Num_Lines; if (Mini_Last_Line == Mini_First_Line) { Mini_First_Line++; Mini_First_Line = Mini_First_Line mod Max_Num_Lines; } Mini_Next_Line = Mini_Last_Line; Mini_Previous_Lines [Mini_Last_Line] = ""; } public define mini_exit_minibuffer () { Mini_Next_Line = Mini_Last_Line; bol_skip_white (); !if (eolp ()) { variable line = line_as_string (); switch (Mini_Store_Duplicates) { case 0: % never if (any (line == Mini_Previous_Lines)) line = NULL; } { case -1: % sometimes variable i = (Mini_Next_Line + Max_Num_Lines - 1) mod Max_Num_Lines; if (Mini_Previous_Lines[i] == line) line = NULL; } { case -2: % never, use LRU variable il, delta, la = Mini_Last_Line; if (la < Mini_First_Line) la = la + Max_Num_Lines; delta = 0; il = Mini_First_Line; while (il < la) { if (Mini_Previous_Lines[il mod Max_Num_Lines] == line) delta++; if (delta) { if ((il + delta) > la) break; Mini_Previous_Lines[il mod Max_Num_Lines] = Mini_Previous_Lines[(il + delta) mod Max_Num_Lines]; } il++; } if (delta) { Mini_Last_Line = (Mini_Last_Line + Max_Num_Lines - delta) mod Max_Num_Lines; Mini_Next_Line = Mini_Last_Line; } } store_line (line); } call ("exit_mini"); } public define mini_store_lines (lines) { foreach (lines) store_line (); } public define mini_set_lines (lines) { initialize (); mini_store_lines (lines); } public define mini_get_lines (num_p) { variable n = Mini_Last_Line - Mini_First_Line; if (num_p != NULL) @num_p = Max_Num_Lines; if (n < 0) n += (Max_Num_Lines+1); variable lines = String_Type [n]; n = Mini_Last_Line - Mini_First_Line; if (n < 0) { n = Max_Num_Lines - Mini_First_Line; lines[[0:n-1]] = Mini_Previous_Lines[[Mini_First_Line:]]; lines[[n:]] = Mini_Previous_Lines[[0:Mini_Last_Line]]; return lines; } return Mini_Previous_Lines[[0:n-1]]; } % This function is called from site.sl AFTER jed.rc has been read but % before other command line arguments have been parsed. public define mini_init_minibuffer () { variable mini = "Mini_Map"; !if (keymap_p (mini)) make_keymap (mini); #ifdef IBMPC_SYSTEM definekey ("next_mini_command", "\eOr", mini); definekey ("next_mini_command", "\xE0P", mini); definekey ("prev_mini_command", "\xE0H", mini); definekey ("prev_mini_command", "\eOx", mini); #else definekey ("next_mini_command", "\e[B", mini); definekey ("prev_mini_command", "\e[A", mini); definekey ("next_mini_command", "\eOB", mini); definekey ("prev_mini_command", "\eOA", mini); #endif definekey ("mini_exit_minibuffer", "\r", mini); definekey ("exit_mini", "\e\r", mini); definekey ("mini_complete", "\t", mini); definekey ("mini_complete", " ", mini); % Now that we are initialized, remove this function eval (".() mini_init_minibuffer"); } jed-0.99-19/lib/keydefs.sl0000644002657400265740000002233211311317447014234 0ustar davisdavis% -*- mode: slang; mode: fold; -*- % This file defines symbolic constants for many function and arrow keys. % It may need some modifications on VMS as well as other systems. % originally part of ide.sl by Guido Gonzato % modified by GM % modified by JED #ifdef IBMPC_SYSTEM %{{{ variable Key_F1 = "^@;"; variable Key_F2 = "^@<"; variable Key_F3 = "^@="; variable Key_F4 = "^@>"; variable Key_F5 = "^@?"; variable Key_F6 = "^@@"; variable Key_F7 = "^@A"; variable Key_F8 = "^@B"; variable Key_F9 = "^@C"; variable Key_F10 = "^@D"; variable Key_F11 = "^@\d133"; variable Key_F12 = "^@\d134"; variable Key_Up = "\xE0H"; variable Key_Down = "\xE0P"; variable Key_Right = "\xE0M"; variable Key_Left = "\xE0K"; variable Key_Ins = "\xE0R"; variable Key_Del = "\xE0S"; variable Key_Home = "\xE0G"; variable Key_End = "\xE0O"; variable Key_PgUp = "\xE0I"; variable Key_PgDn = "\xE0Q"; variable Key_BS = _Backspace_Key; % ALT keys variable Key_Alt_F1 = "^@h"; variable Key_Alt_F2 = "^@i"; variable Key_Alt_F3 = "^@j"; variable Key_Alt_F4 = "^@k"; variable Key_Alt_F5 = "^@l"; variable Key_Alt_F6 = "^@m"; variable Key_Alt_F7 = "^@n"; variable Key_Alt_F8 = "^@o"; variable Key_Alt_F9 = "^@p"; variable Key_Alt_F10 = "^@q"; variable Key_Alt_F11 = "^@\d139"; variable Key_Alt_F12 = "^@\d140"; variable Key_Alt_Up = "^@\d152"; variable Key_Alt_Down = "^@\d160"; variable Key_Alt_Right = "^@\d157"; variable Key_Alt_Left = "^@\d155"; variable Key_Alt_Ins = "^@\d162"; variable Key_Alt_Del = "^@\d163"; variable Key_Alt_Home = "^@\d151"; variable Key_Alt_End = "^@\d159"; variable Key_Alt_PgUp = "^@\d153"; variable Key_Alt_PgDn = "^@\d161"; variable Key_Alt_BS = strcat("\e", Key_BS); % SHIFT keys variable Key_Shift_F1 = "^@T"; variable Key_Shift_F2 = "^@U"; variable Key_Shift_F3 = "^@V"; variable Key_Shift_F4 = "^@W"; variable Key_Shift_F5 = "^@X"; variable Key_Shift_F6 = "^@Y"; variable Key_Shift_F7 = "^@Z"; variable Key_Shift_F8 = "^@["; variable Key_Shift_F9 = "^@\\"; variable Key_Shift_F10 = "^@]"; variable Key_Shift_F11 = "^@\d135"; variable Key_Shift_F12 = "^@\d136"; variable Key_Shift_Up = "\xE01"; variable Key_Shift_Down = "\xE06"; variable Key_Shift_Right= "\xE04"; variable Key_Shift_Left = "\xE03"; variable Key_Shift_Ins = "\xE08"; variable Key_Shift_Del = "\xE09"; variable Key_Shift_Home = "\xE00"; variable Key_Shift_End = "\xE05"; variable Key_Shift_PgUp = "\xE02"; variable Key_Shift_PgDn = "\xE07"; variable Key_Shift_Tab = "^@^O"; variable Key_Shift_BS = "\x08"; % ?? % Ctrl keys variable Key_Ctrl_F1 = "^@^"; variable Key_Ctrl_F2 = "^@_"; variable Key_Ctrl_F3 = "^@`"; variable Key_Ctrl_F4 = "^@a"; variable Key_Ctrl_F5 = "^@b"; variable Key_Ctrl_F6 = "^@c"; variable Key_Ctrl_F7 = "^@d"; variable Key_Ctrl_F8 = "^@e"; variable Key_Ctrl_F9 = "^@f"; variable Key_Ctrl_F10 = "^@g"; variable Key_Ctrl_F11 = "^@\d137"; variable Key_Ctrl_F12 = "^@\d138"; variable Key_Ctrl_Up = "\xE0\d141"; variable Key_Ctrl_Down = "\xE0\d145"; variable Key_Ctrl_Right = "\xE0t"; variable Key_Ctrl_Left = "\xE0s"; variable Key_Ctrl_Ins = "\xE0\d146"; variable Key_Ctrl_Del = "\xE0\d147"; variable Key_Ctrl_Home = "\xE0w"; variable Key_Ctrl_End = "\xE0u"; variable Key_Ctrl_PgUp = "\xE0\d132"; variable Key_Ctrl_PgDn = "\xE0v"; variable Key_Ctrl_BS = "\e@"; % ?? %}}} #else % UNIX, VMS %{{{ private variable Is_Xjed = is_defined ("x_server_vendor"); private define setkey_via_terminfo (tc, def) { if (Is_Xjed) return def; #ifexists get_termcap_string variable s = get_termcap_string (tc); if (s != "") return s; #endif return def; } variable Key_F1 = setkey_via_terminfo ("k1", "\e[11~"); variable Key_F2 = setkey_via_terminfo ("k2", "\e[12~"); variable Key_F3 = setkey_via_terminfo ("k3", "\e[13~"); variable Key_F4 = setkey_via_terminfo ("k4", "\e[14~"); variable Key_F5 = setkey_via_terminfo ("k5", "\e[15~"); variable Key_F6 = setkey_via_terminfo ("k6", "\e[17~"); variable Key_F7 = setkey_via_terminfo ("k7", "\e[18~"); variable Key_F8 = setkey_via_terminfo ("k8", "\e[19~"); variable Key_F9 = setkey_via_terminfo ("k9", "\e[20~"); variable Key_F10 = setkey_via_terminfo ("k;", "\e[21~"); variable Key_F11 = setkey_via_terminfo ("F1", "\e[23~"); variable Key_F12 = setkey_via_terminfo ("F2", "\e[24~"); variable Key_Up = setkey_via_terminfo ("ku", "\e[A"); variable Key_Down = setkey_via_terminfo ("kd", "\e[B"); variable Key_Right = setkey_via_terminfo ("kr", "\e[C"); variable Key_Left = setkey_via_terminfo ("kl", "\e[D"); variable Key_Ins = setkey_via_terminfo ("kI", "\e[2~"); variable Key_Del = setkey_via_terminfo ("kD", "\e[3~"); variable Key_Home = setkey_via_terminfo ("kh", "\e[1~"); variable Key_End = setkey_via_terminfo ("@7", "\e[4~"); variable Key_PgUp = setkey_via_terminfo ("kP", "\e[5~"); variable Key_PgDn = setkey_via_terminfo ("kN", "\e[6~"); variable Key_BS = _Backspace_Key; % Assume that ALT keys are prefixed with ESC variable Key_Alt_F1 = strcat("\e", Key_F1); variable Key_Alt_F2 = strcat("\e", Key_F2); variable Key_Alt_F3 = strcat("\e", Key_F3); variable Key_Alt_F4 = strcat("\e", Key_F4); variable Key_Alt_F5 = strcat("\e", Key_F5); variable Key_Alt_F6 = strcat("\e", Key_F6); variable Key_Alt_F7 = strcat("\e", Key_F7); variable Key_Alt_F8 = strcat("\e", Key_F8); variable Key_Alt_F9 = strcat("\e", Key_F9); variable Key_Alt_F10 = strcat("\e", Key_F10); variable Key_Alt_F11 = strcat("\e", Key_F11); variable Key_Alt_F12 = strcat("\e", Key_F12); variable Key_Alt_Up = strcat("\e", Key_Up); variable Key_Alt_Down = strcat("\e", Key_Down); variable Key_Alt_Right = strcat("\e", Key_Right); variable Key_Alt_Left = strcat("\e", Key_Left); variable Key_Alt_Ins = strcat("\e", Key_Ins); variable Key_Alt_Del = strcat("\e", Key_Del); variable Key_Alt_Home = strcat("\e", Key_Home); variable Key_Alt_End = strcat("\e", Key_End); variable Key_Alt_PgUp = strcat("\e", Key_PgUp); variable Key_Alt_PgDn = strcat("\e", Key_PgDn); variable Key_Alt_BS = strcat("\e", Key_BS); % SHIFT keys. Do not depend upon these being available. I cannot find % any relevant terminfo entries for most of them. The default values are % appropriate for Xjed. variable Key_Shift_F1 = setkey_via_terminfo ("", "\e[11$"); variable Key_Shift_F2 = setkey_via_terminfo ("", "\e[12$"); variable Key_Shift_F3 = setkey_via_terminfo ("", "\e[13$"); variable Key_Shift_F4 = setkey_via_terminfo ("", "\e[14$"); variable Key_Shift_F5 = setkey_via_terminfo ("", "\e[15$"); variable Key_Shift_F6 = setkey_via_terminfo ("", "\e[17$"); variable Key_Shift_F7 = setkey_via_terminfo ("", "\e[18$"); variable Key_Shift_F8 = setkey_via_terminfo ("", "\e[19$"); variable Key_Shift_F9 = setkey_via_terminfo ("", "\e[20$"); variable Key_Shift_F10 = setkey_via_terminfo ("", "\e[21$"); variable Key_Shift_F11 = setkey_via_terminfo ("", "\e[23$"); variable Key_Shift_F12 = setkey_via_terminfo ("", "\e[24$"); variable Key_Shift_Up = setkey_via_terminfo ("", "\e[a"); variable Key_Shift_Down = setkey_via_terminfo ("", "\e[b"); variable Key_Shift_Right= setkey_via_terminfo ("%i", "\e[c"); variable Key_Shift_Left = setkey_via_terminfo ("#4", "\e[d"); variable Key_Shift_Ins = setkey_via_terminfo ("#3", "\e[2$"); if (Key_Shift_Ins == "\e2$") { % Work-around rxvt-terminfo bug $1 = getenv ("TERM"); if ($1 != NULL) { if (is_substr ($1, "rxvt") || is_substr ($1, "screen")) Key_Shift_Ins = "\e[2$"; } } variable Key_Shift_Del = setkey_via_terminfo ("*4", "\e[3$"); variable Key_Shift_Home = setkey_via_terminfo ("#2", "\e[1$"); variable Key_Shift_End = setkey_via_terminfo ("*7", "\e[4$"); variable Key_Shift_PgUp = setkey_via_terminfo ("", "\e[5$"); variable Key_Shift_PgDn = setkey_via_terminfo ("", "\e[6$"); variable Key_Shift_Tab = setkey_via_terminfo ("bt", "\e[Z"); % reverse-tab variable Key_Shift_BS = setkey_via_terminfo ("", "\e[16$"); % Ctrl keys variable Key_Ctrl_F1 = setkey_via_terminfo ("", "\e[11^"); variable Key_Ctrl_F2 = setkey_via_terminfo ("", "\e[12^"); variable Key_Ctrl_F3 = setkey_via_terminfo ("", "\e[13^"); variable Key_Ctrl_F4 = setkey_via_terminfo ("", "\e[14^"); variable Key_Ctrl_F5 = setkey_via_terminfo ("", "\e[15^"); variable Key_Ctrl_F6 = setkey_via_terminfo ("", "\e[17^"); variable Key_Ctrl_F7 = setkey_via_terminfo ("", "\e[18^"); variable Key_Ctrl_F8 = setkey_via_terminfo ("", "\e[19^"); variable Key_Ctrl_F9 = setkey_via_terminfo ("", "\e[20^"); variable Key_Ctrl_F10 = setkey_via_terminfo ("", "\e[21^"); variable Key_Ctrl_F11 = setkey_via_terminfo ("", "\e[23^"); variable Key_Ctrl_F12 = setkey_via_terminfo ("", "\e[24^"); variable Key_Ctrl_Up = setkey_via_terminfo ("", "\e[^A"); variable Key_Ctrl_Down = setkey_via_terminfo ("", "\e[^B"); variable Key_Ctrl_Right = setkey_via_terminfo ("", "\e[^C"); variable Key_Ctrl_Left = setkey_via_terminfo ("", "\e[^D"); variable Key_Ctrl_Ins = setkey_via_terminfo ("", "\e[2^"); variable Key_Ctrl_Del = setkey_via_terminfo ("", "\e[3^"); variable Key_Ctrl_Home = setkey_via_terminfo ("", "\e[1^"); variable Key_Ctrl_End = setkey_via_terminfo ("", "\e[4^"); variable Key_Ctrl_PgUp = setkey_via_terminfo ("", "\e[5^"); variable Key_Ctrl_PgDn = setkey_via_terminfo ("", "\e[6^"); %variable Key_Ctrl_Tab = setkey_via_terminfo ("", "\e[\t^"); variable Key_Ctrl_BS = setkey_via_terminfo ("", "\e[16^" ); % We no longer need this private define setkey_via_terminfo (); %}}} #endif % not IBMPC_SYSTEM provide ("keydefs"); jed-0.99-19/lib/bibtex.sl0000644002657400265740000004211111311317447014054 0ustar davisdavis% BIBTeX mode for JED % % Version: 1.9 % Original Author: Carsten Tinggaard Nielsen, tinggard@iesd.auc.dk % Update: 2001-04-24 % ----------------------------------------------------------------------- % History: % 1.9 24 Apr 2001 % Added user defined default values for fields. % 1.8 16 Oct 1999 % removed local_setkey statements from bibtex_mode function. % Added '&' character to mode menu. --JED % 1.7 15 October 1999 % * fixed bug where OPT would be removed from e.g. ".. optical.." in title % with bibtex_removeOPT and consequently bibtex_clean_entry % * JED recommended self_insert_cmd thingy for keypress " to normal " % * more highlight keywords % Charl P. Botha % 1.6 30 September 1999 % added syntax table % Charl P. Botha % 1.5 26 September 1999 % added mode menu for bibtex mode % Charl P. Botha % 1.4 29 May 1995 % fixed bug refering to bibtex_insert_quote: using tex_insert_quote % added usage of LaTeX font commands: ^C^F % as suggested by Franz-Josef Knelangen % 1.3 16 May 1995 % next/prev field can now position correct in "" and "{}" % changed def of next entry to ESC N / Meta N % changed def of prev entry to ESC P / Meta P % ESC p and ESC P does the same job now. % 1.2 11 May 1995 % from fjk@ruf.uni-freiburg.de (Franz-Josef Knelangen): % next field ^n % prev field ^p % next entry ESC n % prev entry ESC p % 1.1 10 May 1995 % Optimized code after suggestions by John E. Davis % 1.0 08 May 1995 % Public release to comp.editors,comp.text.tex,alt.lang.s-lang % ----------------------------------------------------------------------- % % When bibtex mode is loaded, 'bibtex_mode_hook' is called. % This hook will allow users to customize the mode. % So, in your jed.rc /.jedrc file, % add something like: % define bibtex_mode_hook () { % local_setkey ("bibtex_Article", "^C^E^A"); % } % which binds the function to Ctrl-C Ctrl-E Ctrl-A % % For customization, the 'bibtex_item_hook' is called everytime a % template is entered into the buffer. % To add your own entry, % then add something like (in your jed.rc /.jedrc file): % autoload ("bib_field", "bibtex.sl"); % define bibtex_item_hook () { % bib_field("myentry"); % } % Your additions will be placed before the note/annote field. % The variable bibtex_item_name holds current name like Article, Manual etc. %------------------------------------------------------------------------- % Load the common definitions if not already loaded. This also defines % the TeX-Mode syntax table require ("latex"); % % For customization, the 'bib_field_default_hook' is called everytime a % new field is inserted. It takes the name of the field and returns the % default value (or the empty string). Simply add to your jed.rc/.jedrc: % define bibtex_field_default_hook (fieldstr) { % switch (fieldstr) % {case "isbn" : "3-934601-";} % {case "location" : "Jena";} % {case "publisher" : "IKS Garamond";} % {case "address" : "Wildenbruchstr. 15, 07745 Jena, Germany";} % {"";} % } % %------------------------------------------------------------------------- variable bib_OPT_flag = 0; % if true then insert OPT in the field names variable bib_indent = 16; % amount of whitespace before '=' variable bibtex_item_name = Null_String; % name of current item define bib_set_OPT () { bib_OPT_flag = 1; } define bib_unset_OPT () { bib_OPT_flag = 0; } define bib_field (fieldstr) { variable sl; sl = bib_indent - strlen(fieldstr); insert(",\n "); if (bib_OPT_flag) { insert("OPT"); sl -= 3; } vinsert ("%s =", fieldstr); insert_spaces(sl); sl = ""; variable hook = __get_reference ("bibtex_field_default_hook"); if (hook != NULL) sl = @hook (fieldstr); if (fieldstr == "title") vinsert("\"{%s}\"", sl); else vinsert("\"%s\"", sl); } define bib_journal () { bib_field("journal"); } define bib_year () { bib_field("year"); } define bib_volume () { bib_field("volume"); } define bib_number () { bib_field("number"); } define bib_pages () { bib_field("pages"); } define bib_month () { bib_field("month"); } define bib_editor () { bib_field("editor"); } define bib_publisher () { bib_field("publisher"); } define bib_series () { bib_field("series"); } define bib_address () { bib_field("address"); } define bib_edition () { bib_field("edition"); } define bib_howpublished () { bib_field("howpublished"); } define bib_booktitle () { bib_field("booktitle"); } define bib_organization () { bib_field("organization"); } define bib_institution () { bib_field("institution"); } define bib_school () { bib_field("school"); } define bib_type () { bib_field("type"); } define bib_chapter () { bib_field("chapter"); } define bib_note () { bib_field("note"); } define bib_author () { bib_field("author"); } define bib_item (itemstr, use_author) { vinsert("@%s{", itemstr); bibtex_item_name = itemstr; bib_unset_OPT(); if (use_author) { bib_author();} bib_field("title"); } define bib_itemend (use_note) { bib_field("location"); bib_field("isbn"); bib_field("keywords"); run_mode_hooks("bibtex_item_hook"); if (use_note) { bib_note(); } bib_field("annote"); insert("\n}\n\n"); pop(bsearch("{,")); go_right_1 (); } define bib_cref_and_key() { bib_set_OPT(); bib_field("crossref"); bib_field("key"); } define bibtex_Article () { bib_item("Article", 1); bib_journal(); bib_year(); bib_cref_and_key(); bib_volume(); bib_number(); bib_pages(); bib_month(); bib_itemend(1); } define bibtex_Book () { bib_item("Book", 1); bib_publisher(); bib_year(); bib_cref_and_key(); bib_editor(); bib_volume(); bib_number(); bib_series(); bib_address(); bib_edition(); bib_month(); bib_itemend(1); } define bibtex_preamble () { insert("@Preamble\{\}\n"); go_left(2); } define bibtex_string () { insert("@string\{ = \"\"\}\n"); go_left(7); } define bibtex_Unpublished () { bib_item("Unpublished", 1); bib_note(); bib_cref_and_key(); bib_year(); bib_month(); bib_itemend(0); } define bibtex_TechReport () { bib_item("TechReport", 1); bib_institution(); bib_year(); bib_cref_and_key(); bib_type(); bib_number(); bib_address(); bib_month(); bib_itemend(1); } define bibtex_PhdThesis () { bib_item("PhdThesis", 1); bib_school(); bib_year(); bib_cref_and_key(); bib_address(); bib_month(); bib_type(); bib_itemend(1); } define bibtex_Proceedings () { bib_item("Proceedings", 0); bib_year(); bib_cref_and_key(); bib_editor(); bib_volume(); bib_series(); bib_publisher(); bib_organization(); bib_address(); bib_month(); bib_itemend(1); } define bibtex_Misc () { bib_item("Misc", 0); bib_cref_and_key(); bib_author(); bib_howpublished(); bib_year(); bib_month(); bib_itemend(1); } define bibtex_MastersThesis () { bib_item("MastersThesis", 1); bib_school(); bib_year(); bib_cref_and_key(); bib_address(); bib_month(); bib_type(); bib_itemend(1); } define bibtex_Manual () { bib_item("Manual", 0); bib_cref_and_key(); bib_author(); bib_organization(); bib_address(); bib_edition(); bib_year(); bib_month(); bib_itemend(1); } define bibtex_InProceedings () { bib_item("InProceedings", 1); bib_cref_and_key(); bib_editor(); bib_volume(); bib_number(); bib_series(); bib_pages(); bib_booktitle(); bib_year(); bib_organization(); bib_publisher(); bib_address(); bib_month(); bib_itemend(1); } define bibtex_InCollection () { bib_item("InCollection", 1); bib_cref_and_key(); bib_booktitle(); bib_publisher(); bib_year(); bib_editor(); bib_volume(); bib_number(); bib_series(); bib_type(); bib_chapter(); bib_pages(); bib_address(); bib_edition(); bib_month(); bib_itemend(1); } define bibtex_InBook () { bib_item("InBook", 1); bib_chapter(); bib_cref_and_key(); bib_publisher(); bib_year(); bib_editor(); bib_pages(); bib_volume(); bib_number(); bib_series(); bib_address(); bib_edition(); bib_type(); bib_month(); bib_itemend(1); } define SearchInThisLine(str) { % return 1 if str is found at current line variable thisline = what_line(); variable res = 0; bol(); if (fsearch(str)) if (thisline == what_line()) res = 1; !if (res) { goto_line(thisline); bol(); } return res; } variable bibtex_remove_value = 0; % 0:nothing removed 1:OPT 2:killed define bibtex_removeOPT () { % remove the string OPT from the current line % if there is no text in the entry then the line is deleted % ensure beginning of current line bol(); bibtex_remove_value = 0; % if current line has OPT then go on if (SearchInThisLine(" OPT")) { % first make sure that the OPT is before the = ! % get current column variable thiscolumn = what_column(); % get position of equal sign variable r = SearchInThisLine(" ="); variable esigncolumn = what_column(); % if there is an equal sign and the OPT is before the =, we can nuke it if (r and (thiscolumn < esigncolumn)) { % go back to where we were just after the initial OPT search go_left(esigncolumn - thiscolumn); % replace OPT with spaces after = go_right_1 (); deln(3); if (SearchInThisLine(" =")) { go_right(2); insert_spaces(3); } bibtex_remove_value = 1; % if the line has no information then kill it if (SearchInThisLine("\"\"")) { delete_line(); bibtex_remove_value = 2; } } } } define bibtex_clean_entry () { % remove lines where field starts with OPT and ends with "" % remove lines if the contains no information % if lines has OPT and "" then OPT is removed and % line is adjusted accordingly % the stopmark is "}" at the first position in a line or eobp(). () = bsearch_char ('@'); go_down_1(); while (looking_at_char('}') == 0) { bibtex_removeOPT(); if (bibtex_remove_value == 1) go_down(1); % removed OPT in line with content !if (bibtex_remove_value) { % did nothing, check for empty line if (SearchInThisLine("\"\"")) delete_line(); else go_down_1(); } bol(); } % there must not be a comma after the last entry go_left(2); if (looking_at_char(',')) del(); bol(); go_down(3); } define bibtex_no(whatdir, whatstr) { vmessage ("There is no %s %s", whatdir, whatstr); } define bibtex_no_next(whatstr) { bibtex_no("next", whatstr); } define bibtex_no_prev(whatstr) { bibtex_no("previous", whatstr); } define bibtex_next_entry() { % jump to the next entry: Article, Manual if (fsearch_char ('@')) { % first char of entry () = fsearch_char ('{'); % point at label go_right_1 (); } else bibtex_no_next("entry"); } define bibtex_prev_entry() { % jump to the previous entry: Article, Manual if (bsearch_char ('}')){ % last char of entry () = bsearch_char ('@'); % first char of entry () = fsearch_char ('{'); % point at label go_right_1 (); } else bibtex_no_prev("entry"); } define bibtex_go_into_field() { % A std. field is of the form "" % the title field is of the form "{}" % if the field is of the title form "{}" the % posiiton the cursor between the braces. go_right(2); if (looking_at_char ('{')) go_right_1 (); } define bibtex_next_field() { % jump to the next field: author, title if (fsearch(" \"")) bibtex_go_into_field(); else bibtex_no_next("field"); } define bibtex_prev_field() { % jump to the previous field: author,title bol(); if (bsearch(" \"")) bibtex_go_into_field(); else bibtex_no_prev("field"); } private variable bibtexName = "BibTeX"; private variable bibtexModeName = bibtexName + "-Mode"; !if (keymap_p(bibtexModeName)) { make_keymap (bibtexModeName); definekey ("tex_insert_quote", "\"", bibtexModeName); definekey ("tex_insert_quote", "'", bibtexModeName); definekey ("tex_blink_dollar", "$", bibtexModeName); % The next two conflict with other, non-emacs, bindings --JED %definekey ("bibtex_next_field", "^N", bibtexModeName); %definekey ("bibtex_prev_field", "^P", bibtexModeName); definekey ("bibtex_next_entry", "\eN", bibtexModeName); definekey ("bibtex_prev_entry", "\eP", bibtexModeName); definekey("self_insert_cmd", "\"", bibtexModeName); % These are the keys that have a ^C prefix definekey_reserved ("tex_font", "^F", bibtexModeName); definekey_reserved ("bibtex_Article", "a", bibtexModeName); definekey_reserved ("bibtex_Book", "b", bibtexModeName); definekey_reserved ("bibtex_Unpublished", "u", bibtexModeName); definekey_reserved ("bibtex_string", "s", bibtexModeName); definekey_reserved ("bibtex_TechReport", "t", bibtexModeName); definekey_reserved ("bibtex_PhdThesis", "T", bibtexModeName); definekey_reserved ("bibtex_preamble", "P", bibtexModeName); definekey_reserved ("bibtex_Proceedings", "p", bibtexModeName); definekey_reserved ("bibtex_Misc", "M", bibtexModeName); definekey_reserved ("bibtex_MastersThesis", "m", bibtexModeName); definekey_reserved ("bibtex_Manual", "^M", bibtexModeName); definekey_reserved ("bibtex_InProceedings", "I", bibtexModeName); definekey_reserved ("bibtex_InCollection", "i", bibtexModeName); definekey_reserved ("bibtex_InBook", "B", bibtexModeName); definekey_reserved ("bibtex_removeOPT", "^O", bibtexModeName); definekey_reserved ("bibtex_clean_entry", "^C", bibtexModeName); } % syntax table and keywords for bibtex stuff added by create_syntax_table (bibtexName); % comments define_syntax ("%", "", '%', bibtexName); % matching set of delimiters (for blinking) define_syntax ("{", "}", '(', bibtexName); % string (key values) define_syntax ('"', '"', bibtexName); % keywords define_syntax ("0-9a-zA-Z_@", 'w', bibtexName); % delimiter define_syntax (",", ',', bibtexName); % operator define_syntax ("=", '+', bibtexName); % keywords are case-insensitive set_syntax_flags (bibtexName, 1); () = define_keywords_n (bibtexName, "key", 3, 0); () = define_keywords_n (bibtexName, "notetypeyear", 4, 0); () = define_keywords_n (bibtexName, "monthpagestitle", 5, 0); () = define_keywords_n (bibtexName, "authoreditornumberschoolseriesvolume", 6, 0); () = define_keywords_n (bibtexName, "addresschaptereditionjournal", 7, 0); () = define_keywords_n (bibtexName, "crossref", 8, 0); () = define_keywords_n (bibtexName, "booktitlepublisher", 9, 0); () = define_keywords_n (bibtexName, "institution", 11, 0); () = define_keywords_n (bibtexName, "howpublishedorganization", 12, 0); % now for the entry types () = define_keywords_n (bibtexName, "@book@misc", 5, 1); () = define_keywords_n (bibtexName, "@inbook@manual@string", 7, 1); () = define_keywords_n (bibtexName, "@article", 8, 1); () = define_keywords_n (bibtexName, "@preamble", 9, 1); () = define_keywords_n (bibtexName, "@phdthesis", 10, 1); () = define_keywords_n (bibtexName, "@techreport", 11, 1); () = define_keywords_n (bibtexName, "@proceedings@unpublished", 12, 1); () = define_keywords_n (bibtexName, "@incollection", 13, 1); () = define_keywords_n (bibtexName, "@inproceedings@mastersthesis", 14, 1); private define init_menu (menu) { menu_append_item (menu, "&Article", "bibtex_Article"); menu_append_item (menu, "&Book", "bibtex_Book"); menu_append_item (menu, "&Unpublished", "bibtex_Unpublished"); menu_append_item (menu, "&TechReport", "bibtex_TechReport"); menu_append_item (menu, "&PhdThesis", "bibtex_PhdThesis"); menu_append_item (menu, "P&roceedings", "bibtex_Proceedings"); menu_append_item (menu, "&Misc", "bibtex_Misc"); menu_append_item (menu, "Ma&stersThesis", "bibtex_MastersThesis"); menu_append_item (menu, "Ma&nual", "bibtex_Manual"); menu_append_item (menu, "&InProceedings", "bibtex_InProceedings"); menu_append_item (menu, "In&Collection", "bibtex_InCollection"); menu_append_item (menu, "InBoo&k", "bibtex_InBook"); menu_append_separator (menu); menu_append_item (menu, "Next &Field", "bibtex_next_field"); menu_append_item (menu, "Pre&vious Field", "bibtex_prev_field"); menu_append_item (menu, "Next &Entry", "bibtex_next_entry"); menu_append_item (menu, "Previo&us Entry", "bibtex_prev_entry"); menu_append_separator (menu); menu_append_item (menu, "Rem&ove OPT", "bibtex_removeOPT"); menu_append_item (menu, "C&lean entry", "bibtex_clean_entry"); } define bibtex_mode () { use_keymap (bibtexModeName); set_mode (bibtexName, 0x1 | 0x20); set_buffer_hook ("par_sep", "tex_paragraph_separator"); set_buffer_hook ("wrap_hook", "tex_wrap_hook"); TAB = 0; % pure spaces in this mode mode_set_mode_info (bibtexName, "init_mode_menu", &init_menu); use_syntax_table(bibtexName); run_mode_hooks ("bibtex_mode_hook"); } %-----------------------------------------------------------% define bibtex_info_find_node () { variable node; node = read_mini ("Node:", Null_String, Null_String); !if (strlen (node)) return; info_reader (); info_find_node ("(bibtex)top"); info_find_node ("(bibtex)" + node); } jed-0.99-19/lib/minued.sl0000644002657400265740000002201511311317447014061 0ustar davisdavis% ------------------------------------------- -*- mode:SLang; mode:folding; -*- % % MINUED-MODE FOR JED % % $Id: minued.sl,v 2.15 2000/09/09 22:16:42 rocher Exp $ % % --------------------------------------------------------------------- %{{{ % % DESCRIPTION % 'Minued' is a MINi-bUffer EDitor with wich you can view all % previously lines entered in it. Select and modify one of them, press % press return and that line will be updated and evaluated. % % USAGE % Simply add the line: % % autoload ("minued_mode", "minued"); % % somewhere in your startup file (.jedrc or jed.rc). You can optionally % bind 'minued_mode' to "Ctrl-X Ctrl-E" (quite useful in emacs mode) with % % setkey ("minued_mode", "^X^E"); % % See the 'COLORS' section to see how you can customize colors % used by minued. % % CHANGELOG % 2000/09/09: 'minued_mode' is now called 'minued_mode' (as it should % be). Some minor changes added. % % 2000/05/30: Modified by JED for inclusion into 0.99-11. Until % Francesc's is_color has been implemented, the menu_selection colors % are used. % % AUTHOR % Francesc Rocher % Feel free to send comments, suggestions or improvements. % % ------------------------------------------------------------------------ %}}} implements ("Minued"); % PRIVATE VARIABLES %{{{ private variable minued_cbuf, % Current buffer before minued-mode was called minued_nwin, % Number of windows (before minued) minued_ncoms, % Number of commands minued_mark, minued_lnum = 1, % Line number minued_line, % Line contents minued_cnums, % Color used for numbers minued_cline, % Color used in the current line Max_Num_Lines = 32; % The same as in 'mini.sl' %}}} % USER VARIABLES %!%+ %\variable{Minued_Lines} %\synopsis{Minued_Lines} %\usage{Integer_Type Minued_Lines = 0;} %\description % This variable controls the number of lines shown in the minued % buffer. If the value of \var{Minued_Lines} is -1, then the entire % screen is used. If it is 0, the window splits vertically. A positive % value selects the exact number of lines to show. This value shouldn't % be greater than \var{SCREEN_HEIGHT}-4, and is only useful while you are % working with one window. % % Default value is 0. %\seealso{minued} %\seealso{SCREEN_HEIGHT} %!%- custom_variable ("Minued_Lines", 0); % PRIVATE FUNCTIONS private define insert_mini_commands () %{{{ { % Returns the number of inserted lines. variable l, line = mini_get_lines (NULL), n = 0; foreach (line) { l = (); if (strlen (l)) { n++; vinsert ("%3d %s\n", n, l); } } return n; } %}}} private define remove_mini_command (n) %{{{ { % Remove the n-th Mini_Previous_Line % ('n' is the n-th line from the user point of view) variable lines = mini_get_lines (NULL); variable i = [0:length (lines)-1]; mini_set_lines (lines [where (i != n-1)]); } %}}} private define update_mini_command (n, cmd) %{{{ { % Replace n-th Mini_Previous_Line with 'cmd' % ('n' is the n-th line from the user point of view) if (n > minued_ncoms) { variable c = String_Type [1]; c [0] = cmd; mini_store_lines (c); } else { variable l = mini_get_lines (NULL); l [n-1] = cmd; mini_set_lines (l); } } %}}} private define minued_eval () %{{{ { variable mtr; if (is_defined (minued_line)) { eval (minued_line); return; } mtr = strtrans (minued_line, "-", "_"); if (is_internal (mtr)) { call (mtr); return; } if (is_defined (mtr)) { eval (mtr); return; } eval (minued_line); } %}}} private define minued_get_line () %{{{ { minued_line = line_as_string (); minued_line = strtrim (minued_line [[5:]]); } %}}} private define minued_show () %{{{ { erase_buffer (); minued_ncoms = insert_mini_commands (); if (minued_ncoms == Max_Num_Lines) { minued_ncoms--; () = up (1); delete_line (); } insert ("add> "); goto_line (minued_lnum); set_column_colors (minued_cnums,1,5); set_buffer_modified_flag (0); } %}}} private define minued_adjust_window () %{{{ { if (Minued_Lines == -1) onewindow (); if (Minued_Lines) { if (Minued_Lines > SCREEN_HEIGHT-4) onewindow (); else { variable n = window_info ('r'); if (n < Minued_Lines) Minued_Lines - n; else { otherwindow (); n - Minued_Lines; } loop () enlargewin (); pop2buf ("*minued*"); } } } %}}} private define minued_update () %{{{ { update_mini_command (minued_lnum, minued_line); } %}}} private define minued_update_hook () %{{{ { minued_mark = create_line_mark (minued_cline); if (what_column () < 6) goto_column (6); if (andelse {what_line () <= minued_ncoms} {buffer_modified ()}) { push_spot (); goto_column (4); del (); insert_char ('*'); pop_spot (); set_buffer_modified_flag (0); } minued_lnum = what_line (); } %}}} % PUBLIC FUNCTIONS ------------------------------------------------------------ %!%+ %\function{minued_mode} %\synopsis{minued_mode} %\usage{Void minued_mode ();} %\description % \var{minued_mode} is a mini-buffer's contents editor with which you can view all % previously entered lines in it. Select and modify one of them. Press return % and that line will be updated in the mini-buffer and evaluated in the buffer % from which minued was called. % % All lines appears numbered, in the same order that they are stored in the % mini-buffer. Use the last line of minued if you want to add a new one. % Instead of a number, that line shows "add> ". % % The following key-bindings are defined in \var{minued_mode}: %#v+ % Return Update and evaluate the current line. % Meta-Return Evaluate the current line. % Ctrl-U Update the current line, don't leave 'minued_mode'. % Meta-R Remove the current line, don't leave 'minued_mode'. % Ctrl-C Quit. %#v- % Note: Minued cannot be invoked from the mini-buffer. %\seealso{history_load, history_save} %\seealso{Minued_Lines} %!%- public define minued_mode () %{{{ { if (MINIBUFFER_ACTIVE or (whatbuf () == "*minued*")) return; minued_nwin = nwindows (); minued_cbuf = pop2buf_whatbuf ("*minued*"); minued_adjust_window (); minued_show (); set_buffer_undo (1); set_mode ("minued", 0); use_keymap ("minued"); set_buffer_hook ("update_hook", &minued_update_hook); run_mode_hooks ("minued_mode"); } %}}} public define minued_cancel () %{{{ { setbuf ("*minued*"); set_buffer_modified_flag (0); sw2buf (minued_cbuf); delbuf ("*minued*"); if (minued_nwin == 1) onewindow (); else otherwindow (); } %}}} public define minued_eval_line () %{{{ { minued_get_line (); minued_cancel (); if (strlen (minued_line)) minued_eval (); } %}}} public define minued_remove_line () %{{{ { if (orelse {minued_lnum > minued_ncoms} {minued_ncoms == 1}) return; remove_mini_command (minued_lnum); minued_show (); } %}}} public define minued_update_line () %{{{ { if (what_line () > minued_ncoms) return; variable c = what_column (); minued_get_line (); if (strlen (minued_line)) { minued_update (); delete_line (); vinsert ("%3dU %s\n", minued_lnum, minued_line); () = up (1); goto_column (c); set_buffer_modified_flag (0); flush ("Line updated."); } } %}}} public define minued_update_eval_line () %{{{ { minued_get_line (); minued_cancel (); !if (strlen (minued_line)) return; minued_update (); minued_eval (); } %}}} % COLORS %{{{ % DISABLED while 'is_color' and 'set_color' are not available % % !if (is_color ("minued_nums")) % set_color ("minued_nums", "brightred", "black"); % % !if (is_color ("minued_line")) % set_color ("minued_line", "black", "green"); % % minued_cnums = color_number ("minued_nums"); % minued_cline = color_number ("minued_line"); % Temporary solution #iftrue minued_cline = color_number ("menu_selection"); minued_cnums = color_number ("menu_selection_char"); #else set_color_object (100, "brightred", "black"); set_color_object (101, "black", "green"); minued_cnums = 100; minued_cline = 101; #endif %}}} % KEYMAP %{{{ $0 = "minued"; !if (keymap_p ($0)) { make_keymap ($0); if ("^C" == _Reserved_Key_Prefix) { undefinekey ("^C", $0); definekey ("minued_cancel", "^C", $0); } definekey ("minued_eval_line", "\e\r", $0); definekey ("minued_remove_line", "\er", $0); definekey ("minued_update_eval_line", "\r", $0); definekey ("minued_update_line", "^U", $0); } %}}} jed-0.99-19/lib/texcom.sl0000644002657400265740000001145611311317447014106 0ustar davisdavis% The functions here are common to both TeX and LaTeX modes. $1 = "TeX-Mode"; create_syntax_table ($1); define_syntax ("%", "", '%', $1); % Comment Syntax define_syntax ('\\', '\\', $1); % Quote character define_syntax ("{[", "}]", '(', $1); % are all these needed? define_syntax ('$', '"', $1); % string define_syntax ("~^_&#", '+', $1); % operators define_syntax ("|&{}[]", ',', $1); % delimiters define_syntax ("a-zA-Z@", 'w', $1); set_syntax_flags ($1, 8); #ifdef HAS_DFA_SYNTAX %%% DFA_CACHE_BEGIN %%% private define setup_dfa_callback (name) { dfa_enable_highlight_cache ("texcom.dfa", name); dfa_define_highlight_rule ("%.*$", "comment", name); dfa_define_highlight_rule ("\\\\([A-Za-z]+|.)", "keyword0", name); dfa_define_highlight_rule ("[\\|&{}\\[\\]]", "delimiter", name); dfa_define_highlight_rule ("[~\\^_&]", "operator", name); dfa_define_highlight_rule ("#[1-9]", "operator", name); dfa_define_highlight_rule ("\\$\\$?", "string", name); dfa_define_highlight_rule (".", "normal", name); dfa_build_highlight_table (name); } dfa_set_init_callback (&setup_dfa_callback, "TeX-Mode"); %%% DFA_CACHE_END %%% #endif % This hook identifies lines containing TeX comments as paragraph separator define tex_is_comment () { bol (); while (ffind ("\\%")) go_right (2); return ffind_char ('%'); } variable Tex_Ignore_Comment = 0; % if true, line containing a comment % does not delimit a paragraph define tex_paragraph_separator () { bol_skip_white (); if (eolp () or looking_at("$$")) return 1; if (looking_at ("\\")) { if (orelse {looking_at ("\\begin")} {looking_at ("\\item")} {looking_at ("\\end")} {re_looking_at ("\\\\[sub]+section{")}) return 1; } % % look for comment % return not (Tex_Ignore_Comment) and tex_is_comment (); } define tex_wrap_hook () { variable yep; push_spot (); yep = up_1 () and tex_is_comment (); pop_spot (); if (yep) { push_spot (); bol_skip_white (); insert ("% "); pop_spot (); } indent_line (); } define tex_isolate_paragraph () { variable ic = Tex_Ignore_Comment; Tex_Ignore_Comment = 1; push_spot (); push_mark (); backward_paragraph (); narrow (); Tex_Ignore_Comment = ic; } define tex_blink_dollar () { variable pdollar = create_user_mark (); insert_char ('$'); if (blooking_at ("\\$")) return; push_spot (); EXIT_BLOCK { pop_spot (); } Tex_Ignore_Comment++; backward_paragraph (); Tex_Ignore_Comment--; variable pmatch = NULL; while (fsearch_char ('$')) { variable tmp_match = create_user_mark (); if (tmp_match >= pdollar) break; if (tex_is_comment ()) { % point left at comment start if (create_user_mark () < tmp_match) { % match in comment eol (); continue; } } goto_user_mark (tmp_match); if (blooking_at("\\")) { go_right_1 (); continue; } if (pmatch == NULL) pmatch = tmp_match; else pmatch = NULL; go_right_1 (); } if (pmatch == NULL) return; variable line = what_line (); goto_user_mark (pmatch); variable match_line = what_line (); if (line - match_line >= window_info ('r')) { message ("Matches " + line_as_string ()); } else { update_sans_update_hook(0); () = input_pending(10); } } define tex_insert_quote () { variable c; if ((LAST_CHAR != '\'') and (LAST_CHAR != '"')) { insert_char(LAST_CHAR); return; } c = '['; !if (bolp()) { go_left_1 (); c = what_char(); go_right_1 (); } if (c == '\\') { insert_char (LAST_CHAR); return; } if (is_substr("[({\t ", char(c))) { insert_char ('`'); if (LAST_CHAR == '"') insert_char ('`'); } else { insert_char ('\''); if (LAST_CHAR == '"') insert_char ('\''); } } define latex_do_environment () { variable env = Null_String; push_spot (); if (bsearch ("\\begin{")) { go_right (7); push_mark (); () = ffind_char ('}'); env = bufsubstr (); } pop_spot (); eol (); newline (); env = read_mini ("Enter Environment Name:", env, Null_String); vinsert ("\\\\begin{%s}\n\n\\\\end{%s}\n", env, env); go_up(2); } define tex_is_verbatum_environment () { variable m; EXIT_BLOCK { goto_user_mark (m); } m = create_user_mark (); !if (bsearch ("\\begin{verbatum}")) return 0; !if (fsearch ("\\end{verbatum}")) return 1; return m <= create_user_mark (); } define tex_ldots () { if (blooking_at ("..")) { !if (tex_is_verbatum_environment ()) { go_left (2); deln (2); insert ("{\\ldots} "); return; } } insert_char ('.'); } provide ("texcom"); jed-0.99-19/lib/tmpfile.sl0000644002657400265740000000552411311317447014246 0ustar davisdavis%!%+ %\function{make_tmp_file} %\synopsis{make_tmp_file} %\usage{String make_tmp_file (String base);} %\description % This function returns a unique file name that begins with \var{base}. % If \exmp{base} does not specify an absolute path, the value of % \svar{Jed_Tmp_Directory} will be used for the directory. %!%- define make_tmp_file (base) { if ((Jed_Tmp_Directory != NULL) and (path_is_absolute (base) == 0)) base = path_concat (Jed_Tmp_Directory, base); base = path_sans_extname (base); () = random (-1, 0); variable pid = getpid (); loop (1000) { variable file = sprintf ("%s%d.%d", base, random (0, 0x7FFF), pid); !if (file_status(file)) return (file); } error ("Unable to create a tmp file!"); } %}}} %!%+ %\function{open_unique_filename} %\synopsis{Generate and unique filename and open the file} %\usage{structure = open_unique_filename (base, extname)} %\description % This function generates a unique filename of the form % \exmp{baseXXXXXX.extname} and returns a structure with fields %#v+ % filename : The name of the file % fd : The FD_Type file descriptor % fp : The FP_Type file pointer %#v- % If \exmp{base} represents an absolute path, then the file % will be opened in the correspondind directory. Otherwise the value % of the \svar{Jed_Tmp_Directory} variable will be used. % % If this function fails, an exception will be thrown. %\notes % The value of the \exmp{fp} structure field is generated from the % value of the \exmp{fd} field using the \ifun{fdopen} function. See the % documentation of the \ifun{fdopen} function for the relationship of % these two types and their semantics. %\seealso{fdopen} %!%- define open_unique_filename (base, ext) { if ((Jed_Tmp_Directory != NULL) && (0 == path_is_absolute (base))) base = path_concat (Jed_Tmp_Directory, base); variable dir = path_dirname (base); if ((dir != ".") && (2 != file_status (dir))) throw IOError, "tmpfile directory $dir does not exist"$; () = random (-1, 0); variable fmt = "%s%X%s"; if (ext == NULL) ext = ""; else if (ext[0] != '.') ext = "." + ext; variable flags = O_RDWR|O_CREAT|O_EXCL; variable mode = S_IRUSR|S_IWUSR; loop (5000) { variable err; variable file = sprintf (fmt, base, random (0, 0x7FFFFFFF), ext); variable fd = open (file, flags, mode); if (fd != NULL) { variable fp = fdopen (fd, "r+"); if (fp == NULL) { err = errno_string (); () = close (fd); () = remove (file); throw IOError, "fdopen failed: $err"$; } return struct { file = file, fp = fp, fd = fd }; } if ((errno != EEXIST) && (errno != EINTR)) { err = errno_string (); throw IOError, "open failed: $err"$; } } throw IOError, "Unable to open a unique file"; } jed-0.99-19/lib/wmenu.sl0000644002657400265740000001140511311317447013734 0ustar davisdavisenable_top_status_line (0); private variable Wmenu_Modes_Popup; private define simple_menu() { variable menubar; variable file_popup, edit_popup, search_popup, buffers_popup, modes_popup, help_popup, windows_popup; w32_destroy_menubar(); file_popup = w32_create_popup_menu(); ERROR_BLOCK { w32_destroy_menu(file_popup); } w32_append_menu_item(file_popup, "Open\t^X^F", 0x1, "find_file"); w32_append_menu_item(file_popup, "Save\t^X^W", 0x2, "write_buffer"); w32_append_menu_item(file_popup, "Save Buffers\t^X^s", 0x3, "save_buffers"); w32_append_menu_item(file_popup, "Insert File\t^Xi", 0x4, "insert_file"); w32_append_separator(file_popup); w32_append_menu_item(file_popup, "Shell Cmd", 0x5, "do_shell_cmd"); w32_append_separator(file_popup); w32_append_menu_item(file_popup, "Exit\t^X^C", 0x6, "exit_jed"); edit_popup = w32_create_popup_menu(); ERROR_BLOCK { w32_destroy_menu(file_popup); w32_destroy_menu(edit_popup); } w32_append_menu_item(edit_popup, "Undo\t^Xu", 10, "undo"); w32_append_separator(edit_popup); w32_append_menu_item(edit_popup, "Cut", 11, "kill_region"); w32_append_menu_item(edit_popup, "Copy", 12, "copy_region"); w32_append_menu_item(edit_popup, "Paste", 13, "yank"); search_popup = w32_create_popup_menu(); ERROR_BLOCK { w32_destroy_menu(file_popup); w32_destroy_menu(edit_popup); w32_destroy_menu(search_popup); } w32_append_menu_item(search_popup, "Search Forward", 20, "search_forward"); w32_append_menu_item(search_popup, "Search Backward", 21, "search_backward"); w32_append_menu_item(search_popup, "Replace", 23, "replace_cmd"); buffers_popup = w32_create_popup_menu(); ERROR_BLOCK { w32_destroy_menu(file_popup); w32_destroy_menu(edit_popup); w32_destroy_menu(search_popup); w32_destroy_menu(buffers_popup); } w32_append_menu_item(buffers_popup, "Kill", 30, "kill_buffer"); w32_append_menu_item(buffers_popup, "Switch To", 31, "switch_to_buffer"); w32_append_menu_item(buffers_popup, "List Buffers", 32, "list_buffers"); Wmenu_Modes_Popup = w32_create_popup_menu(); ERROR_BLOCK { w32_destroy_menu(file_popup); w32_destroy_menu(edit_popup); w32_destroy_menu(search_popup); w32_destroy_menu(buffers_popup); w32_destroy_menu(Wmenu_Modes_Popup); } w32_append_menu_item(Wmenu_Modes_Popup, "C Mode", 40, "c_mode"); w32_append_menu_item(Wmenu_Modes_Popup, "Text Mode", 41, "text_mode"); w32_append_menu_item(Wmenu_Modes_Popup, "No Mode", 42, "no_mode"); w32_append_menu_item(Wmenu_Modes_Popup, "Fortran Mode", 43, "fortran_mode"); w32_append_popup_menu(buffers_popup, "Modes", Wmenu_Modes_Popup); windows_popup = w32_create_popup_menu(); ERROR_BLOCK { w32_destroy_menu(file_popup); w32_destroy_menu(edit_popup); w32_destroy_menu(search_popup); w32_destroy_menu(buffers_popup); w32_destroy_menu(Wmenu_Modes_Popup); w32_destroy_menu(windows_popup); } w32_append_menu_item(windows_popup, "One Window", 50, "one_window"); w32_append_menu_item(windows_popup, "Split Window", 51, "split_window"); w32_append_menu_item(windows_popup, "Other Window", 52, "other_window"); w32_append_menu_item(windows_popup, "Delete Window", 53, "delete_window"); w32_append_separator(windows_popup); w32_append_menu_item(windows_popup, "Redraw", 54, "redraw"); help_popup = w32_create_popup_menu(); ERROR_BLOCK { w32_destroy_menu(file_popup); w32_destroy_menu(edit_popup); w32_destroy_menu(search_popup); w32_destroy_menu(buffers_popup); w32_destroy_menu(Wmenu_Modes_Popup); w32_destroy_menu(windows_popup); w32_destroy_menu(help_popup); } w32_append_menu_item(help_popup, "Show Key", 60, "showkey"); w32_append_menu_item(help_popup, "Where Is Command", 61, "where_is"); menubar = w32_get_menubar(); w32_append_popup_menu(menubar, "&File", file_popup); w32_append_popup_menu(menubar, "&Edit", edit_popup); w32_append_popup_menu(menubar, "&Search", search_popup); w32_append_popup_menu(menubar, "&Buffers", buffers_popup); w32_append_popup_menu(menubar, "&Windows", windows_popup); w32_append_popup_menu(menubar, "&Help", help_popup); w32_set_init_popup_callback("_w32_init_popup"); w32_redraw_menubar(); } define _w32_init_popup(hpopup) { variable mode; if (hpopup == Wmenu_Modes_Popup) { (, mode) = what_mode(); w32_check_menu_item(Wmenu_Modes_Popup, 40, mode == 2); % C mode w32_check_menu_item(Wmenu_Modes_Popup, 41, mode == 1); % Text mode w32_check_menu_item(Wmenu_Modes_Popup, 42, mode == 0); % No mode w32_check_menu_item(Wmenu_Modes_Popup, 43, mode == 16); % Fortran mode } } simple_menu (); private define simple_menu (); % delete the function jed-0.99-19/lib/ltx-math.sl0000644002657400265740000001050011311317447014332 0ustar davisdavis% ltx-math.sl % % AUC-TeX style LaTeX-math-mode (v0.2) by Kevin Humphreys % % For JED (v0.97.9b) by John E. Davis % % Based on AUC-TeX (v9.1i) by Per Abrahamsen % Autoloaded by latex_math_mode (C-c ~) in latex.sl % CHANGES HISTORY: % Modifed for use in main jed distribution % --- v0.1-0.2 % reduce memory usage by using array (thanks to John E. Davis) variable Latex_Math_Array = String_Type [128]; _for (0, 127, 1) {$1 = (); Latex_Math_Array[$1] = Null_String; } Latex_Math_Array['a'] = "alpha"; Latex_Math_Array['b'] = "beta"; Latex_Math_Array['c'] = "mathcal{}"; Latex_Math_Array['d'] = "delta"; Latex_Math_Array['e'] = "epsilon"; Latex_Math_Array['f'] = "phi"; Latex_Math_Array['g'] = "gamma"; Latex_Math_Array['h'] = "eta"; Latex_Math_Array['k'] = "kappa"; Latex_Math_Array['l'] = "lambda"; Latex_Math_Array['m'] = "mu"; Latex_Math_Array['N'] = "nabla"; Latex_Math_Array['n'] = "nu"; Latex_Math_Array['o'] = "omega"; Latex_Math_Array['p'] = "pi"; Latex_Math_Array['q'] = "theta"; Latex_Math_Array['r'] = "rho"; Latex_Math_Array['s'] = "sigma"; Latex_Math_Array['t'] = "tau"; Latex_Math_Array['u'] = "upsilon"; Latex_Math_Array['x'] = "chi"; Latex_Math_Array['y'] = "psi"; Latex_Math_Array['z'] = "zeta"; Latex_Math_Array['D'] = "Delta"; Latex_Math_Array['G'] = "Gamma"; Latex_Math_Array['Q'] = "Theta"; Latex_Math_Array['L'] = "Lambda"; Latex_Math_Array['Y'] = "Psi"; Latex_Math_Array['P'] = "Pi"; Latex_Math_Array['S'] = "Sigma"; Latex_Math_Array['U'] = "Upsilon"; Latex_Math_Array['V'] = "Phi"; Latex_Math_Array['O'] = "Omega"; Latex_Math_Array[6] = "rightarrow"; % C-f Latex_Math_Array[2] = "leftarrow"; % C-b Latex_Math_Array[16] = "uparrow"; % C-p Latex_Math_Array[14] = "downarrow"; % C-n Latex_Math_Array['<'] = "leq"; Latex_Math_Array['>'] = "geq"; Latex_Math_Array['~'] = "tilde"; Latex_Math_Array['I'] = "infty"; Latex_Math_Array['A'] = "forall"; Latex_Math_Array['E'] = "exists"; Latex_Math_Array['!'] = "neg"; Latex_Math_Array['i'] = "in"; Latex_Math_Array['*'] = "times"; Latex_Math_Array['.'] = "cdot"; Latex_Math_Array['{'] = "subset"; Latex_Math_Array['}'] = "supset"; Latex_Math_Array['['] = "subseteq"; Latex_Math_Array[']'] = "supseteq"; Latex_Math_Array['/'] = "not"; Latex_Math_Array['\\'] = "setminus"; Latex_Math_Array['+'] = "cup"; Latex_Math_Array['-'] = "cap"; Latex_Math_Array['&'] = "wedge"; Latex_Math_Array['|'] = "vee"; Latex_Math_Array['('] = "langle"; Latex_Math_Array[')'] = "rangle"; Latex_Math_Array[5] = "exp"; % C-e Latex_Math_Array[19] = "sin"; % C-s Latex_Math_Array[3] = "cos"; % C-c Latex_Math_Array[30] = "sup"; % C-^ Latex_Math_Array[31] = "inf"; % C-_ Latex_Math_Array[4] = "det"; % C-d Latex_Math_Array[12] = "lim"; % C-l Latex_Math_Array[20] = "tan"; % C-t Latex_Math_Array['^'] = "hat"; Latex_Math_Array['v'] = "vee"; Latex_Math_Array['0'] = "emptyset"; define latex_insert_math () { variable arg = prefix_argument(-1); variable ch = getkey (); if (ch > 127) return; if (arg != -1) insert_char ('$'); insert_char ('\\'); insert (Latex_Math_Array[ch]); if (ch == 'c') % position cursor correctly for \mathcal{} { if (arg != -1) { insert_char ('$'); go_left(2); } else go_left_1 (); } else { if (arg != -1) insert_char ('$'); } } private define get_math_mode () { if (blocal_var_exists ("Latex_Math_Mode")) return get_blocal_var ("Latex_Math_Mode"); return 0; } private define set_math_mode (x) { create_blocal_var ("Latex_Math_Mode"); set_blocal_var (x, "Latex_Math_Mode"); } define latex_quoted_insert () { if (get_math_mode ()) latex_insert_math (); else call ("quoted_insert"); } private define latex_math_mode_internal () { set_math_mode (1); set_mode("LaTeX Math", 0x1 | 0x20); local_setkey ("latex_quoted_insert", "`"); run_mode_hooks ("latex_math_mode_hook"); } define latex_math_mode () { latex_mode (); latex_math_mode_internal (); } define latex_toggle_math_mode () { if (get_math_mode ()) { set_math_mode (0); latex_mode (); return; } latex_math_mode_internal (); } jed-0.99-19/lib/misc.sl0000644002657400265740000001004311311317447013531 0ustar davisdavis% misc functions that should be in site.sl but they are not because we want % jed to start up fast and they are not always needed. %!%+ %\function{make_tmp_buffer_name} %\synopsis{make_tmp_buffer_name} %\usage{String make_tmp_buffer_name (String base);} %\description % Generates a unique buffer name using the string 'base' for the beginning % of the name. The buffer name is returned. The buffer is not created. %!%- define make_tmp_buffer_name (tmp) { variable n = 0, buf; variable t = time (); tmp = strcat (tmp, time); do { buf = sprintf("%s%d", tmp, n); n++; } while (bufferp(buf)); buf; } define misc_do_write_to_file (str, file, write_function) { variable ret = -1; variable buf = make_tmp_buffer_name (Null_String); variable cbuf = whatbuf (); setbuf (buf); insert (str); set_buffer_modified_flag (0); push_mark (); bob (); #iffalse ERROR_BLOCK { _clear_error (); } #endif ret = @write_function (file); setbuf (cbuf); delbuf (buf); ret; } %!%+ %\function{append_string_to_file} %\synopsis{append_string_to_file} %\usage{Integer append_string_to_file (String str, String file);} %\description % The string 'str' is appended to file 'file'. This function returns -1 % upon failure or the number of lines written upon success. % See append_region_to_file for more information. %!%- define append_string_to_file (str, file) { misc_do_write_to_file (str, file, &append_region_to_file); } %!%+ %\function{write_string_to_file} %\synopsis{write_string_to_file} %\usage{Integer write_string_to_file (String str, String file);} %\description % The string 'str' is written to file 'file'. This function returns -1 % upon failure or the number of lines written upon success. % This function does not modify a buffer visiting the file. %!%- define write_string_to_file (str, file) { misc_do_write_to_file (str, file, &write_region_to_file); } #ifnexists glob_to_regexp define glob_to_regexp (glob) { variable regexp; #ifdef UNIX regexp = "^"; #else regexp = "^\\C"; % case-insensitive #endif foreach (glob) { variable ch = (); switch (ch) { case '.': ch = "\\."; } { case '?': ch = "."; } { case '*': ch = ".*"; } { % default ch = char (ch); if (is_substr ("[]\\^$+", ch)) ch = strcat ("\\", ch); } regexp = strcat (regexp, ch); } strcat (regexp, "$"); } #endif define list_directory () { variable pat = read_file_from_mini ("list directory"); !if (strlen (pat)) return; variable dir = path_dirname (pat); pat = path_basename (pat); !if (strlen(pat)) pat = "*"; if (file_status (dir) != 2) verror ("%s is not a directory", dir); variable files = listdir (dir); if (files == NULL) files = String_Type[0]; pat = glob_to_regexp (pat); files = files[where(array_map (Int_Type, &string_match, files, pat, 1))]; files = files[array_sort(files)]; variable cbuf = whatbuf (); pop2buf ("*directory*"); variable file, buf, flags; (file,,buf,flags) = getbuf_info (); setbuf_info (file, dir, buf, flags); erase_buffer (); if (length (files)) { array_map (Void_Type, &vinsert, "%s\n", files); buffer_format_in_columns (); } bob (); vinsert ("Directory %s\n", dir); bob (); set_buffer_modified_flag (0); pop2buf (cbuf); } define directory (dirspec) { variable buf_dir, dir; variable pattern; variable files, i; !if (strlen (dirspec)) dirspec = "*"; (,buf_dir,,) = getbuf_info (); pattern = extract_filename (dirspec); dir = substr (dirspec, 1, strlen (dirspec) - strlen (pattern)); dir = dircat (buf_dir, dir); !if (strlen (dir)) dir = "."; pattern = glob_to_regexp (pattern); files = listdir (dir); if ((files == NULL) or (length (files) == 0)) return 0; i = array_map (Int_Type, &string_match, files, pattern, 1); files = files[where (i)]; % Push them onto the stack to mimick foreach (files) ; length (files); } jed-0.99-19/lib/preparse.sl0000644002657400265740000000331211311317447014420 0ustar davisdavisvariable Preprocess_Only = 1; () = evalfile ("bytecomp.sl"); #ifdef HAS_DFA_SYNTAX define preparse_enable_highlight_cache (file, name) { create_syntax_table (name); % Make sure existing cached files are removed forever { variable dirfile = search_path_for_file (Jed_Highlight_Cache_Path, file, ','); if (dirfile == NULL) break; if (-1 == remove (dirfile)) break; } dirfile = dircat (Jed_Highlight_Cache_Dir, file); () = remove (dirfile); _dfa_enable_highlight_cache (dirfile, name); } private define create_dfa_cache (file) { file = expand_jedlib_file (file); !if (strlen (file)) return; setbuf ("*dfa-cache*"); erase_buffer (); if (-1 == insert_file_region (file, "%%% DFA_CACHE_BEGIN %%%", "%%% DFA_CACHE_END %%%")) return; bob (); !if (fsearch ("dfa_enable_highlight_cache")) return; replace ("dfa_enable_highlight_cache", "preparse_enable_highlight_cache"); eob (); !if (re_bsearch ("[ \t]*dfa_set_init_callback[ \t]*([ \t]*&[ \t]*\\([^,]+\\),[ \t]*\"\\([^\"]+\\)\"")) return; variable fun = regexp_nth_match (1); variable mode = regexp_nth_match (2); delete_line (); % Note that $1 has been unitialized because the use of $1 here is not % supported. vinsert ("()=__tmp($1); %s(\"%s\");", fun, mode); evalbuffer (); } flush ("creating DFA syntax tables..."); % List of modes for which dfa cache tables should be constructed foreach ([ "cmode.sl", "html.sl", "javamode.sl", "perl.sl", "php.sl", "preparse.sl", "pscript.sl", "pymode.sl", "shmode.sl", "slmode.sl", "tclmode.sl", "texcom.sl", "tpascal.sl" ]) { create_dfa_cache (); } #endif exit_jed(); jed-0.99-19/lib/wmark.sl0000644002657400265740000001056511311317447013730 0ustar davisdavis%--------------------------------*-SLang-*-------------------------------- % wmark.sl % Implements Windows style of marking - for Windows users % Author: Luchesar Ionkov % % Modified By JED % modified by mj olesen % % Holding down Shift key and using arrow keys selects text % Delete Key cuts the block of text. % Inserting a character will replace the block with the character. % Yanking will replace the block with the text in the yank buffer % % Note: If you are having problems with this under linux, then read the % jed/doc/txt/linux-keys.txt file. require ("keydefs"); private variable Wmark_Region_Funs = Assoc_Type[Ref_Type]; private define backward_delete_fun () { call ("kill_region"); insert ("X"); } private define forward_delete_fun () { backward_delete_fun (); go_left_1 (); } public define wmark_add_region_function (fun, region_fun) { Wmark_Region_Funs[fun] = region_fun; } wmark_add_region_function ("self_insert_cmd", &del_region); wmark_add_region_function ("yank", &del_region); wmark_add_region_function ("yp_yank", &del_region); wmark_add_region_function ("backward_delete_char_untabify", &backward_delete_fun); wmark_add_region_function ("backward_delete_char", &backward_delete_fun); wmark_add_region_function ("delete_char_cmd", &forward_delete_fun); private variable Wmark_Movement_Flag = 0; private variable Wmark_Buffer; private define before_key_hook (); private define after_key_hook (); private define end_wmark () { if (bufferp (Wmark_Buffer)) { variable cbuf = whatbuf(); setbuf (Wmark_Buffer); if (is_visible_mark ()) pop_mark_0 (); setbuf (cbuf); } remove_from_hook ("_jed_before_key_hooks", &before_key_hook); remove_from_hook ("_jed_after_key_hooks", &after_key_hook); } private define before_key_hook (fun) { if (typeof (fun) == Ref_Type) fun = "&"; if (0 == strncmp (fun, "wmark_", 6)) return; Wmark_Movement_Flag = 0; if (is_visible_mark () and assoc_key_exists (Wmark_Region_Funs, fun)) { (@Wmark_Region_Funs[fun]) (); end_wmark (); return; } } private define after_key_hook () { if (Wmark_Movement_Flag == 0) end_wmark (); } private define wmark_prefix () { !if (is_visible_mark ()) push_visible_mark (); if (Wmark_Movement_Flag == 0) { add_to_hook ("_jed_before_key_hooks", &before_key_hook); add_to_hook ("_jed_after_key_hooks", &after_key_hook); Wmark_Movement_Flag = 1; Wmark_Buffer = whatbuf (); } } private define wmark_eval (fun) { wmark_prefix (); if (typeof (fun) == Ref_Type) @fun (); else call (fun); } % the various functions define wmark_up () { wmark_eval ("previous_line_cmd"); } define wmark_down () { wmark_eval ("next_line_cmd"); } define wmark_left () { wmark_eval ("previous_char_cmd"); } define wmark_right () { wmark_eval ("next_char_cmd"); } define wmark_page_up () { wmark_eval ("page_up"); } define wmark_page_down () { wmark_eval ("page_down"); } define wmark_bol () { wmark_eval (&bol); } define wmark_eol () { wmark_eval (&eol); } define wmark_bob () { wmark_eval (&bob); } define wmark_eob () { wmark_eval (&eob); } define wmark_skip_word () { wmark_eval (&skip_word); } define wmark_bskip_word () { wmark_eval (&bskip_word); } setkey ("wmark_up", Key_Shift_Up); % S-Up setkey ("wmark_down", Key_Shift_Down); % S-Down setkey ("wmark_left", Key_Shift_Left); % S-Left setkey ("wmark_right", Key_Shift_Right); % S-Right setkey ("wmark_page_up", Key_Shift_PgUp); % S-PageUp setkey ("wmark_page_down", Key_Shift_PgDn); % S-PageDown setkey ("wmark_bol", Key_Shift_Home); % S-Home setkey ("wmark_eol", Key_Shift_End); % S-End setkey ("yank", Key_Shift_Ins); % S-Insert setkey ("kill_region", Key_Shift_Del); % S-Delete setkey ("copy_region", Key_Ctrl_Ins); % C-Insert setkey ("del_region", Key_Ctrl_Del); % C-Delete #ifndef IBMPC_SYSTEM private define wmark_reset_display_hook () { tt_send("\e[?35h"); } private define wmark_init_display_hook () { tt_send("\e[?35l"); } $1 = getenv ("TERM"); if ($1 == NULL) $1 = ""; if (string_match ($1, "^xterm.color", 1) or string_match ($1, "^rxvt", 1)) { % rxvt: bypass XTerm shift keys and allow S-Prior, S-Next, S-Insert add_to_hook ("_jed_reset_display_hooks", &wmark_reset_display_hook); add_to_hook ("_jed_init_display_hooks", &wmark_init_display_hook); setkey ("wmark_bol", "\e[7$"); % S-Home setkey ("wmark_eol", "\e[8$"); % S-End } #endif provide ("wmark"); jed-0.99-19/lib/acompile.sl0000644002657400265740000000411611311317447014373 0ustar davisdavis% Asynchronous compilation private variable Compile_Last_Compile_Cmd = ""; public variable Compile_Process_Id = -1; private define compile_set_status_line (state) { set_mode ("compile: " + state, 0); } private define compile_signal_handler (pid, flags, status) { variable str = aprocess_stringify_status (pid, flags, status); push_spot (); eob (); vinsert ("\n\nProcess no longer running: %s\n", str); pop_spot (); compile_set_status_line (str); if (flags != 2) Compile_Process_Id = -1; } private define compile_start_process (cmd) { variable dir, name, file, flags; variable shell, shopt; if (cmd == NULL) cmd = read_mini ("Compile command:", "", Compile_Last_Compile_Cmd); !if (strlen (cmd)) return; (,dir,,) = getbuf_info (); if (change_default_dir (dir)) error ("Unable to chdir."); pop2buf (Compile_Output_Buffer); set_readonly (0); erase_buffer (); (file,,name,flags) = getbuf_info (); setbuf_info (file, dir, name, flags); Compile_Line_Mark = 0; compile_set_status_line (""); insert (cmd); newline (); #ifdef WIN32 shopt = ""; shell = ""; #else shell = getenv ("SHELL"); if (shell == NULL) shell = "sh"; shopt = "-c"; #endif Compile_Process_Id = open_process (shell,shopt, cmd, 2); if (Compile_Process_Id == -1) error ("Unable to start subprocess."); compile_set_status_line ("run"); Compile_Last_Compile_Cmd = cmd; set_process (Compile_Process_Id, "signal", &compile_signal_handler); set_process (Compile_Process_Id, "output", "@"); } public define compile () { variable b, n; variable cmd = NULL; if (_NARGS == 1) cmd = (); Compile_Output_Buffer = "*compile*"; if (Compile_Process_Id != -1) { if (bufferp (Compile_Output_Buffer)) error ("A compile process is already running."); try kill_process (Compile_Process_Id); catch RunTimeError; Compile_Process_Id = -1; } b = whatbuf(); call ("save_some_buffers"); compile_start_process (cmd); pop2buf(b); %compile_parse_errors (); } jed-0.99-19/lib/menu.sl0000644002657400265740000001142011311317447013542 0ustar davisdavis% This File is OBSOLETE % % Example of menus for JED. This is designed to aid in learning % the editor since after a menu item has been chosen, the user is % informed of the keybinding of the function. % enable_top_status_line (1); if (TOP_WINDOW_ROW == 1) error ("Menu bar has been disabled. It must be present to use the menus."); define menu_build_display_string (list) { variable i = 0, cmd, s = Null_String; forever { cmd = extract_element (list, i, ','); if (cmd == NULL) break; if (i) s += ", "; s = sprintf("%s(%d)%s", s, i, cmd); ++i; } s; } define menu_list_length (list) { variable i = 0; i - 1; } variable Menu_Last_Cmd; variable Menu_Abort; Menu_Abort = 0; define menu_select_cmd (s_list, cmd_list) { variable cmd, i, s, n; i = 0; n = 0; while (NULL != extract_element(cmd_list, n, ',')) n++; n--; s = strcat ("Menu: ", menu_build_display_string(s_list)); do { Menu_Abort = 0; forever { message ("Pick a number or press Ctrl-G to abort or SPACE to go back to previous level."); set_top_status_line (s); pop (); update_sans_update_hook(1); i = getkey(); if (i == 7) call ("kbd_quit"); if (i == ' ') { Menu_Abort = 1; return; } i -= '0'; if ((i >= 0) and (i <= n)) break; beep(); flush_input(); % flush("Pick a number or press Ctrl-G to abort or SPACE to go back."); % pop(input_pending(20)); } cmd = extract_element(cmd_list, i, ','); if (cmd [0] == '@') { Menu_Last_Cmd = substr(cmd, 2, strlen(cmd)); call (Menu_Last_Cmd); } else { Menu_Last_Cmd = cmd; eval(strcat (".", cmd)); % Use RPN--- no need to parse it } } while(Menu_Abort); } define menu_window_cmds () { menu_select_cmd ("One window,Split Window,Other Window,Del Window,Redraw", "@one_window,@split_window,@other_window,@delete_window,@redraw"); } define search_replace () { menu_select_cmd ("Search Forward,Search Backward,Replace", "search_forward,search_backward,replace_cmd"); } define menu_deletion_cmd () { menu_select_cmd ("Delete Char,Delete Word", "del,delete_word"); } define menu_cut_paste () { menu_select_cmd ("Deleting,Begin Region,Cut Region,Copy Region,Paste", "menu_deletion_cmd,@set_mark_cmd,@kill_region,@copy_region,@yank"); } define menu_movement () { menu_select_cmd ("Page Up,Page Down,Top,Bottom,Page Left,Page Right", "@page_up,@page_down,@beg_of_buffer,@end_of_buffer,@scroll_right,@scroll_left"); } define menu_buffer_modes () { menu_select_cmd ("C-Mode,Text-Mode,No-Mode,Fortran-Mode", "c_mode,text_mode,no_mode,fortran"); } define menu_basics () { menu_select_cmd ("Search/Replace,Movement,Cut/Paste,Undo,Formatting", "search_replace,menu_movement,menu_cut_paste,@undo,@format_paragraph"); } define menu_buffers () { menu_select_cmd ("Kill Buffer,Switch To Buffer,List Buffers,Set buffer modes", "@kill_buffer,@switch_to_buffer,list_buffers,menu_buffer_modes"); } define menu_files () { menu_select_cmd ("Open File,Save to File,Save Buffers,Insert File", "@find_file,@write_buffer,@save_some_buffers,@insert_file"); } define menu_help () { menu_select_cmd ("Pop up help,Browse Documentation,Show Key,Where is Command", "help,info_reader,showkey,where_is"); } define menu_misc () { #ifdef UNIX VMS menu_select_cmd ("compose mail,send mail,ispell,shell command,suspend", "mail,mail_send,ispell,do_shell_cmd,@sys_spawn_cmd"); #else menu_select_cmd ("Shell command,Suspend", "do_shell_cmd,@sys_spawn_cmd"); #endif } define menu_main_cmds () { variable n, key, len, next, nlen; try { menu_select_cmd ("File,Edit,Buffers,Windows,Help,Misc,Exit", "menu_files,menu_basics,menu_buffers,menu_window_cmds,menu_help,menu_misc,@exit_jed"); } finally () = set_top_status_line (Global_Top_Status_Line); % % Show user keybinding of the function. % The problem with this is that any function which leaves a message % in the message buffer, the message will be destroyed. Here I % update screen and sleep for a second before continuing. Menus are % intrinsically inefficient anyway. % if (strlen(MESSAGE_BUFFER)) { update_sans_update_hook (0); () = input_pending(20); } if (Menu_Abort) { return; } if (n = which_key (Menu_Last_Cmd), n) { key = (); n--; len = strlen (key); loop (n) { next = (); nlen = strlen (next); if (nlen < len) { len = nlen; key = next; } } sprintf ("%s is on key %s", Menu_Last_Cmd, expand_keystring (key)); } else strcat (Menu_Last_Cmd, " is not on any keys."); message (()); } jed-0.99-19/lib/jed.sl0000644002657400265740000000743011311317447013346 0ustar davisdavis% This file contains jed's native keybindings. _Jed_Emulation = "jed"; _Reserved_Key_Prefix = "\003"; % ^C set_status_line(" : Jed %v : %b =(%m%a%n%o)= (%p) %t", 1); define left_justify_line () { push_spot(); bol_trim(); pop_spot(); } define insert_other_window() { if (2 != nwindows) return; otherwindow(); whatbuf(); otherwindow(); insbuf(()); } set_abort_char (7); % ^G unset_ctrl_keys (); setkey("query_replace_match", "\e%"); setkey("forward_paragraph", "\e]"); setkey("backward_paragraph", "\e{"); setkey("forward_paragraph", "\e}"); setkey("dabbrev", "^A"); setkey("beg_of_line", "^B"); setkey("page_down", "^D"); setkey("eol_cmd", "^E"); setkey("occur", "^FA"); setkey("search_backward", "^FB"); setkey("search_forward", "^FF"); setkey("isearch_backward", "^FIB"); setkey("isearch_forward", "^FIF"); setkey("re_search_backward", "^FWB"); setkey("re_search_forward", "^FWF"); setkey("kbd_quit", "^G"); setkey("indent_line", "\t"); setkey("yp_kill_word", "^J"); setkey("set_mark_cmd", "^K^B"); setkey("insert_file", "^K^I"); setkey("double_line", "^K^L"); setkey("bkmrk_goto_mark", "^K\r"); setkey("yp_yank", "^K^P"); setkey("replace_cmd", "^K^R"); setkey("yp_kill_region", "^K^V"); setkey("write_buffer", "^K^W"); setkey("begin_macro", "^K("); setkey("end_macro", "^K)"); setkey("goto_column_cmd", "^KC"); setkey("evaluate_cmd", "^KD"); setkey("exit_jed", "^KE"); setkey("find_file", "^KG"); setkey("yp_copy_region_as_kill","^KK"); setkey("goto_line_cmd", "^KL"); setkey("bkmrk_set_mark", "^KM"); setkey("execute_macro", "^KX"); setkey("left_justify_line", "^K^?"); setkey("yp_kill_line", "^L"); setkey("newline_and_indent", "^M"); setkey("redraw", "^R"); setkey("page_up", "^U"); setkey("delete_char_cmd", "^V"); setkey("insert_other_window", "^W\t"); setkey("one_window", "^W1"); setkey("split_window", "^W2"); setkey("other_window", "^Wo"); setkey("delete_window", "^W0"); setkey("list_buffers", "^X^B"); setkey("list_directory", "^X^D"); setkey("transpose_lines", "^X^T"); setkey("exchange", "^X^X"); setkey("evaluate_cmd", "^X\e"); setkey("set_selective_display", "^X$"); setkey("compile_parse_errors", "^X'"); setkey("changelog_add_change", "^X4a"); setkey("digraph_cmd", "^X8"); setkey("uncomment_region_or_line","^X:"); setkey("comment_region_or_line","^X;"); setkey("whatpos", "^X?"); setkey("switch_to_buffer", "^XB"); setkey("set_fill_column", "^XF"); setkey("reg_insert_register", "^XG"); setkey("kill_buffer", "^XK"); setkey("narrow_to_region", "^XN"); setkey("macro_query", "^XQ"); setkey("save_some_buffers", "^XS"); setkey("toggle_readonly", "^XT"); setkey("undo", "^XU"); setkey("widen_region", "^XW"); setkey("reg_copy_to_register", "^XX"); setkey("enlarge_window", "^X^"); #ifdef UNIX VMS setkey("mail", "^XM"); #endif setkey ("sys_spawn_cmd", "^Z"); setkey ("goto_match", "^\\"); setkey ("undo", "^_"); #ifndef IBMPC_SYSTEM setkey("bob", "^K\eOA"); setkey("bob", "^K\e[A"); setkey("eob", "^K\eOB"); setkey("eob", "^K\e[B"); setkey("scroll_left", "^K\eOC"); setkey("scroll_left", "^K\e[C"); setkey("scroll_right", "^K\eOD"); setkey("scroll_right", "^K\e[D"); setkey("next_wind_up", "^W\e[A"); setkey("next_wind_dn", "^W\e[B"); #else setkey("bob", "^K^@H"); setkey("bob", "^K\eOx"); setkey("bob", "^KàH"); setkey("eob", "^K^@P"); setkey("eob", "^K\eOr"); setkey("eob", "^KàP"); setkey("next_wind_up", "^W^@H"); setkey("next_wind_up", "^W\eOx"); setkey("next_wind_up", "^WàH"); setkey("next_wind_dn", "^W^@P"); setkey("next_wind_dn", "^W\eOr"); setkey("next_wind_dn", "^WàP"); #endif #ifdef UNIX setkey("compile_parse_errors", "^(k1)"); setkey("compile_previous_error","^(k2)"); #endif setkey("yp_yank_pop", "\ey"); setkey("yp_bkill_word", "\e^?"); runhooks ("keybindings_hook", _Jed_Emulation); jed-0.99-19/lib/regexp.sl0000644002657400265740000000322111311317447014070 0ustar davisdavis% % Interactive Regular expression searches. These highlight region matched % until next key is pressed. % require ("srchmisc"); define re_search_dir (pat, dir) { variable ret; if (dir > 0) ret = re_fsearch (pat); else ret = re_bsearch (pat); ret--; ret; } define re_search_forward() { variable pat, not_found = 1; pat = read_mini("Search (Regexp):", Null_String, Null_String); !if (strlen(pat)) return; push_mark(); ERROR_BLOCK { pop_mark (not_found); } not_found = not (search_maybe_again (&re_search_dir, pat, 1, &_function_return_1)); if (not_found) error ("Not found."); EXECUTE_ERROR_BLOCK; } define re_search_backward() { variable pat, not_found; pat = read_mini("Backward Search (Regexp):", Null_String, Null_String); !if (strlen(pat)) return; push_mark(); ERROR_BLOCK { pop_mark (not_found); } not_found = not (search_maybe_again (&re_search_dir, pat, -1, &_function_return_1)); if (not_found) error ("Not found."); EXECUTE_ERROR_BLOCK; } private define research_search_function (pat) { re_fsearch (pat) - 1; } private define re_replace_function (str, len) { !if (replace_match(str, 0)) error ("replace_match failed."); -2; } define query_replace_match() { variable pat, n, rep, prompt, doit, err, ch; err = "Replace Failed!"; pat = read_mini("Regexp:", Null_String, Null_String); !if (strlen(pat)) return; prompt = strcat (strcat ("Replace '", pat), "' with:"); rep = read_mini(prompt, Null_String, Null_String); replace_with_query (&research_search_function, pat, rep, 1, &re_replace_function); } jed-0.99-19/lib/edt.sl0000644002657400265740000003503211311317447013357 0ustar davisdavis%% EDT emulation for JED -- Application Keypad. % See doc/txt/edt.txt for information about this emulation. _Jed_Emulation = "edt"; #ifdef IBMPC_SYSTEM !if (is_defined ("NUMLOCK_IS_GOLD")) eval ("variable NUMLOCK_IS_GOLD = 0;"); if (NUMLOCK_IS_GOLD) custom_variable ("Key_Gold", "\eOP"); else custom_variable ("Key_Gold", "^@;"); % IBM F1 key #else custom_variable ("Key_Gold", "\eOP"); #endif if ((Key_Gold == NULL) or (Key_Gold == "")) Key_Gold = "\eOP"; #ifdef VMS %define_word("!-~"); #endif set_status_line("(Jed %v) EDT: %b (%m%a%n%o) %p Advance %t", 1); %% %% Escape sequences for EDT keypad: %% %% FP1 = \eOP FP2 = \eOQ FP3 = \eOR PF4 = \eOS %% 7 = \eOw 8 = \eOx 9 = \eOy - = \eOm %% 4 = \eOt 5 = \eOu 6 = \eOv , = \eOl %% 1 = \eOq 2 = \eOr 3 = \eOs %% 0 = \eOp . = \eOn enter = \eOM WANT_EOB = 1; !if (is_defined("Edt_Loaded")) { variable Edt_Loaded; variable edt_pbuf; %% a real buffer edt_pbuf = " "; whatbuf(); setbuf(edt_pbuf); sw2buf(()); } define quit() {exit_jed();} %define exit() {exit_jed();} private variable Edt_Keypad_State; private define application_keypad_mode (state) { Edt_Keypad_State = state; #ifdef UNIX VMS variable t = "ke", e = "\e>"; if (state) { t = "ks"; e = "\e="; } # ifdef UNIX variable s = get_termcap_string (t); if (strlen (s)) e = s; # endif tt_send (e); #elifdef IBMPC_SYSTEM if ((Key_Gold != "\eOP") and (Key_Gold != "^[OP")) NUMLOCK_IS_GOLD = state; #endif } define edt_togglekp () { variable on, off; #ifdef VMS UNIX off = "Numeric."; on = "Application."; #else on = "Gold ON"; off = "Gold OFF"; #endif Edt_Keypad_State = not(Edt_Keypad_State); if (Edt_Keypad_State) message (on); else message (off); application_keypad_mode (Edt_Keypad_State); } private variable EDT_Dir; EDT_Dir = 1; %!%+ %\function{edt_advance} %\synopsis{edt_advance} %\description % ADVANCE - (4) % Sets the current direction to forward for the CHAR, WORD, LINE, EOL, PAGE, % SECT, SUBS, FIND, and FNDNXT keys. ADVANCE means that movement will be % toward the end of the buffer; that is, to the right and down. %!%- define edt_advance() { EDT_Dir = 1; set_status_line("(Jed %v) EDT: %b (%m%n%o) %p Advance %t", 1); } %!%+ %\function{edt_backup} %\synopsis{edt_backup} %\description % BACKUP - (5) % Sets the cursor direction to backward for the CHAR, WORD, LINE, EOL, PAGE, % SECT, SUBS, FIND, and FNDNXT keys. BACKUP means that movement will be % toward the beginning of the buffer% that is, to the left and up. %!%- define edt_backup() { EDT_Dir = -1; set_status_line("(Jed %v) EDT: %b (%m%n%o) %p Backup %t", 1); } %% other buffers: not buffers but strings except the char buffer which is int variable edt_wbuf, edt_lbuf, edt_cbuf; edt_wbuf = Null_String; edt_lbuf = Null_String; edt_cbuf = 0; %% character (un)deletion define edt_cdel() { !if (eobp()) { edt_cbuf = what_char(); del(); } } define edt_ucdel() { if (edt_cbuf) { insert_char (edt_cbuf); go_left_1 (); } } define edt_word() { if (EDT_Dir == 1) { if (eolp()) return(go_right_1 ()); % trick-- nothing returned skip_word_chars(); skip_non_word_chars(); } else { if (bolp()) return (go_left_1 ()); bskip_non_word_chars(); bskip_word_chars(); } } %!%+ %\function{edt_wdel} %\synopsis{edt_wdel} %\description % DEL W - (-) % Deletes text from the cursor to the beginning of the next word, storing the % text in the delete word buffer. %!%- define edt_wdel() { push_mark(); edt_word(); %% use whatever edt_word does as a region edt_wbuf = bufsubstr_delete (); } %% another one from Clive Page. define edt_specins() { insert_char (integer(read_mini("char code (decimal):", "27", Null_String))); } %!%+ %\function{edt_uwdel} %\synopsis{edt_uwdel} %\description % UND W - (GOLD -) % Inserts the contents of the delete word buffer directly to the left of the % cursor. %!%- define edt_uwdel() { push_spot(); insert (edt_wbuf); pop_spot(); } %% aparantly deleol also saves what it did in buffer... define edt_deleol() { push_mark_eol(); edt_lbuf = bufsubstr_delete(); } define edt_delbol() { push_mark(); bol(); edt_lbuf = bufsubstr_delete (); } %% the line %!%+ %\function{edt_ldel} %\synopsis{edt_ldel} %\description % DEL L - (PF4) % Deletes text from the cursor position to the end of the current line, including % the line terminator. If the cursor is positioned at the beginning of a line, % the entire line is deleted. The deleted text is saved in the delete line % buffer. %!%- define edt_ldel() { mark_to_visible_eol (); go_right_1 (); edt_lbuf = bufsubstr_delete (); } %!%+ %\function{edt_uldel} %\synopsis{edt_uldel} %\description % UND L - (GOLD PF4) % Inserts the contents of the delete line buffer directly to the left of the % cursor. %!%- define edt_uldel() { push_spot(); insert (edt_lbuf); pop_spot(); } %!%+ %\function{edt_find} %\synopsis{edt_find} %\description % FIND - (GOLD PF3) % Searches for an occurrence of a string. Press the FIND key and then enter the % string using the main keyboard. End the string by pressing either the ADVANCE % or BACKUP key to set the direction of the search, or the ENTER key to search in % the current direction. %!%- define edt_find() { if (EDT_Dir == 1) search_forward (); else search_backward (); } %!%+ %\function{edt_findnxt} %\synopsis{edt_findnxt} %\description % FNDNXT - (PF3) % Searches for the next occurrence of the search string previously entered with % the FIND key. The direction of the search is the current one (ADVANCE or % BACKUP). %!%- define edt_findnxt() { variable r, found; r = 0; if (strlen(LAST_SEARCH)) { if (EDT_Dir == 1) { r = right(1); found = fsearch(LAST_SEARCH); } else found = bsearch(LAST_SEARCH); !if (found) { go_left(r); error("Not Found."); } } else error ("Find What?"); } define edt_go_down_n (n) { ERROR_BLOCK { _clear_error (); } loop (n) call ("next_line_cmd"); } define edt_go_up_n (n) { ERROR_BLOCK { _clear_error (); } loop (n) call ("previous_line_cmd"); } %!%+ %\function{edt_sect} %\synopsis{edt_sect} %\description % SECT - (8) % Moves the cursor 16 lines (one section) forward or backward, depending on the % current direction (see ADVANCE and BACKUP). The cursor is moved to the % beginning of the appropriate line. %!%- define edt_sect() { if (EDT_Dir == 1) edt_go_down_n(16); else edt_go_up_n(16); bol(); } define edt_eol() { if (EDT_Dir == 1) { if (eolp()) edt_go_down_n (1); } else edt_go_up_n (1); eol(); } define edt_line() { if (EDT_Dir > 0) edt_go_down_n (1); else if (bolp()) edt_go_up_n (1); bol(); } define edt_char() { if (EDT_Dir == 1) go_right_1 (); else go_left_1 (); } define edt_oline() { newline(); go_left_1 (); } %% reset also pops marks. define edt_reset() { edt_advance(); while(markp()) pop_mark_0 (); call ("kbd_quit"); } %% edt page searches for a form feed. However, real edt allows user to %% change this. %!%+ %\function{edt_page} %\synopsis{edt_page} %\description % PAGE - (7) % Moves the cursor to the top of a page. A page is defined by a delimiter % string, which can be set by the SET ENTITY command. The default page % delimiter is the formfeed character (CTRL/L). %!%- define edt_page() { variable ret, ff; ff = char(12); if (EDT_Dir == 1) ret = fsearch(ff); else ret = bsearch(ff); if (ret) recenter(1); } define edt_cut() { variable b; !if (dupmark()) return; b = whatbuf(); setbuf(edt_pbuf); erase_buffer(); setbuf(b); copy_region(edt_pbuf); del_region(); } define edt_paste() { insbuf(edt_pbuf); } %% Although not documented in EDT online help, this deletes the region. %!%+ %\function{edt_append} %\synopsis{edt_append} %\description % APPEND - (9) % Moves the select range to the end of the PASTE buffer. The select range is all % the text between the selected position (see SELECT) and the current cursor % position. If no SELECT has been made and the cursor is positioned on the % current search string, that string is appended. %!%- define edt_append() { variable b; b = whatbuf(); setbuf(edt_pbuf); eob(); setbuf(b); if (dupmark()) { copy_region(edt_pbuf); del_region(); } else error("No Region."); } define edt_replace() { del_region(); edt_paste(); } %% a real edt_subs function %% deletes search string, substitutes what is in the pastebuffer and finds %% the next. define edt_subs() { if (looking_at(LAST_SEARCH)) { deln (strlen(LAST_SEARCH)); edt_paste(); !if (looking_at (LAST_SEARCH)) edt_findnxt(); } else error("Select range not active."); } %% a help for the help key define edt_help() { jed_easy_help("edt.hlp"); } %% Chngcase define edt_chgcase() { variable n; !if (markp()) { push_mark(); n = strlen(LAST_SEARCH); if (n and looking_at(LAST_SEARCH)) go_right(n); else if (EDT_Dir == 1) go_right_1 (); else go_left_1 (); } xform_region('X'); } %% is this a better defn of what edt_replace should be? %!%+ %\function{edt_replace} %\synopsis{edt_replace} %\description % REPLACE - (GOLD 9) % Deletes the select range and replaces it with the contents of the PASTE % buffer. %!%- define edt_replace() { variable n; n = strlen(LAST_SEARCH); if (n and looking_at(LAST_SEARCH)) deln (n); else { !if (markp()) error("Select range not active."); del_region(); } edt_paste(); } variable EDT_Scroll_Begin = 3; define edt_check_scroll () { variable n, max_n, w_rows; w_rows = window_info('r'); if (w_rows > 2 * EDT_Scroll_Begin - 2 ) { n = window_line(); max_n = w_rows - EDT_Scroll_Begin + 1; if (n < EDT_Scroll_Begin) recenter (EDT_Scroll_Begin); if (n > max_n) recenter (max_n); } } private define GOLD(x) { return strcat (Key_Gold, x); } %% unset some of default jed keys--- lose window capability on "^W" one %% unsetkey ("^W"); %% setkey ("redraw", "^W"); %% unsetkey("^K"); unsetkey %%-- unset this, we lose kill line in emacs.sl unsetkey("^U"); %% emacs.sl rebinds this to digit-arg %% The default binding for the quote keys (", ') is 'text_smart_quote'. %% Most users do not seem to like this so it is unset here. setkey("self_insert_cmd", "\""); setkey("self_insert_cmd", "'"); %% %% In addition, if you want the ^H key to move to the beginning of line %% then uncomment the next two lines. % unsetkey("^H"); % setkey("beg_of_line", "^H"); %% beginning of line %% By default, these are bound %% to help functions (man page, etc...). %% conventional subs key definition: unsetkey (Key_Gold); setkey("edt_subs", GOLD("\eOM")); %% subs (edt style) %% Give user ability to exit via GOLD-Q, GOLD-E setkey("exit_jed", GOLD("Q")); setkey("exit_jed", GOLD("E")); setkey("edt_togglekp", GOLD(Key_Gold)); %% Gold-Gold toggles keypad % setkey("self_insert_cmd", "^I"); %% tab inserts tab. setkey("edt_delbol", "^U"); %% delete to bol setkey("edt_help", "\eOQ"); %% help setkey("edt_findnxt", "\eOR"); %% findnxt setkey("edt_ldel", "\eOS"); %% del l setkey("edt_cdel", "\eOl"); %% del c setkey("edt_wdel", "\eOm"); %% del w setkey("smart_set_mark_cmd", "\eOn"); %% select setkey("edt_line", "\eOp"); %% line setkey("edt_word", "\eOq"); %% word setkey("edt_eol", "\eOr"); %% eol setkey("edt_char", "\eOs"); %% char setkey("edt_advance", "\eOt"); %% advance setkey("edt_backup", "\eOu"); %% backup setkey("edt_cut", "\eOv"); %% cut setkey("edt_page", "\eOw"); %% page setkey("edt_sect", "\eOx"); %% sect setkey("edt_append", "\eOy"); %% append setkey("edt_help", GOLD("\eOQ")); %% help setkey("edt_find", GOLD("\eOR")); %% find setkey("edt_uldel", GOLD("\eOS")); %% udel l setkey("edt_ucdel", GOLD("\eOl")); %% udel c setkey("edt_uwdel", GOLD("\eOm")); %% udel w setkey("edt_reset", GOLD("\eOn")); %% reset setkey("edt_oline", GOLD("\eOp")); %% open line setkey("edt_chgcase", GOLD("\eOq")); %% chgcase setkey("edt_deleol", GOLD("\eOr")); %% deleol %% %% There are two possible definitions for the specins key. Let's %% choose the edt one though I prefer the other. %% setkey("edt_specins", GOLD("\eOs")); %% specins % setkey("quoted_insert", GOLD("\eOs")); %% specins setkey("eob", GOLD("\eOt")); %% bottom setkey("beg_of_buffer", GOLD("\eOu")); %% top setkey("edt_paste", GOLD("\eOv")); %% paste setkey("evaluate_cmd", GOLD("\eOw")); %% cmd setkey("format_paragraph", GOLD("\eOx")); %% fill setkey("edt_replace", GOLD("\eOy")); %% replace setkey("exit_mini", "\eOM"); %% enter %% The enter key requires some care--- it MUST be put in the %% minibuffer keymap. But this is not created until AFTER the init %% files are loaded so that it inherits user definitions. The above %% line puts it in the global map so that it behaves properly there. %% The same applies to the 'reset' command. %% %% The above comment WAS true in versions prior to 0.81. Now it is possible %% to achieve the desired effect in the startup_hook. I think it is time to %% think of a way to chain functions. That is, I would like to define a %% function that startup_hook will call without explicitly modifying startup %% hook and not destroying other hooks in the process. Thus, startup_hook %% should consist of a chain of functions to execute. if (keymap_p("Mini_Map")) { undefinekey (Key_Gold, "Mini_Map"); definekey("exit_mini", "\eOM", "Mini_Map"); %% enter definekey("edt_reset", GOLD("\eOn"),"Mini_Map"); %% reset } %% %% In EDT, a command may be repeated by GOLD number. Lets have that too %% _for (0, 9, 1) { $0 = (); setkey("digit_arg", GOLD(string($0))); } %% These are the keys on the vt220 keyboard setkey("edt_find", "\e[1~"); %%differs from vt220.sl setkey("yank", "\e[2~"); setkey("kill_region", "\e[3~"); setkey("smart_set_mark_cmd", "\e[4~"); %setkey(evaluate_cmd", "\e[29~"); setkey("emacs_escape_x", "\e[29~"); setkey("edt_help", "\e[28~"); %% %% Finally some definitions for scrolling the screen left/right %% setkey("beg_of_buffer", GOLD("\e[A")); % gold ^ setkey("eob", GOLD("\e[B")); % gold v setkey("scroll_left", GOLD("\e[C")); % gold -> setkey("scroll_right", GOLD("\e[D")); % gold <- setkey(".\"page_up\" call edt_check_scroll", "\e[5~"); setkey(".\"page_down\" call edt_check_scroll", "\e[6~"); setkey(".\"previous_line_cmd\" call edt_check_scroll", "\e[A"); setkey(".\"previous_line_cmd\" call edt_check_scroll", "\eOA"); setkey(".\"next_line_cmd\" call edt_check_scroll", "\e[B"); setkey(".\"next_line_cmd\" call edt_check_scroll", "\eOB"); application_keypad_mode (1); runhooks ("keybindings_hook", _Jed_Emulation); jed-0.99-19/lib/javamode.sl0000644002657400265740000000627111311317447014374 0ustar davisdavis% This file is due to Marko Teittinen . % Java mode is just a superset of C mode so make sure it is loaded. require ("cmode"); $1 = "java"; create_syntax_table ($1); define_syntax ("/*", "*/", '%', $1); define_syntax ("//", "", '%', $1); define_syntax ("([{", ")]}", '(', $1); define_syntax ('"', '"', $1); define_syntax ('\'', '\'', $1); define_syntax ('\\', '\\', $1); define_syntax ("0-9a-zA-Z_", 'w', $1); % words define_syntax ("-+0-9a-fA-F.xXL", '0', $1); % Numbers define_syntax (",;.?:", ',', $1); define_syntax ('#', '#', $1); define_syntax ("%-+/&*=<>|!~^", '+', $1); set_syntax_flags ($1, 4); #ifdef HAS_DFA_SYNTAX %%% DFA_CACHE_BEGIN %%% private define setup_dfa_callback (name) { dfa_enable_highlight_cache("javamode.dfa", name); dfa_define_highlight_rule("^[ \t]*#", "PQpreprocess", name); dfa_define_highlight_rule("//.*", "comment", name); dfa_define_highlight_rule("/\\*.*\\*/", "Qcomment", name); dfa_define_highlight_rule("^([^/]|/[^\\*])*\\*/", "Qcomment", name); dfa_define_highlight_rule("/\\*.*", "comment", name); dfa_define_highlight_rule("^[ \t]*\\*+([ \t].*)?$", "comment", name); dfa_define_highlight_rule("[A-Za-z_\\$][A-Za-z_0-9\\$]*", "Knormal", name); dfa_define_highlight_rule("[0-9]+(\\.[0-9]*)?([Ee][\\+\\-]?[0-9]*)?", "number", name); dfa_define_highlight_rule("0[xX][0-9A-Fa-f]*[LU]*", "number", name); dfa_define_highlight_rule("[0-9]+[LU]*", "number", name); dfa_define_highlight_rule("\"([^\"\\\\]|\\\\.)*\"", "string", name); dfa_define_highlight_rule("\"([^\"\\\\]|\\\\.)*\\\\?$", "string", name); dfa_define_highlight_rule("'([^'\\\\]|\\\\.)*'", "string", name); dfa_define_highlight_rule("'([^'\\\\]|\\\\.)*\\\\?$", "string", name); dfa_define_highlight_rule("[ \t]+", "normal", name); dfa_define_highlight_rule("[\\(\\[{}\\]\\),;\\.\\?:]", "delimiter", name); dfa_define_highlight_rule("[%\\-\\+/&\\*=<>\\|!~\\^]", "operator", name); dfa_build_highlight_table(name); } dfa_set_init_callback (&setup_dfa_callback, "java"); %%% DFA_CACHE_END %%% #endif () = define_keywords_n ($1, "doif", 2, 0); () = define_keywords_n ($1, "forintnewtry", 3, 0); () = define_keywords_n ($1, "bytecasecharelselongthisvoid", 4, 0); () = define_keywords_n ($1, "breakcatchclassfinalfloatshortsuperthrowwhile", 5, 0); () = define_keywords_n ($1, "doubleimportnativepublicreturnstaticswitchthrows", 6, 0); () = define_keywords_n ($1, "booleandefaultextendsfinallypackageprivatevirtual", 7, 0); () = define_keywords_n ($1, "abstractcontinuevolatile", 8, 0); () = define_keywords_n ($1, "interfaceprotected", 9, 0); () = define_keywords_n ($1, "implementsinstanceof", 10, 0); () = define_keywords_n ($1, "synchronized", 12, 0); () = define_keywords_n ($1, "var", 3, 1); () = define_keywords_n ($1, "castgotonullresttrue", 4, 1); () = define_keywords_n ($1, "constfalseinnerouter", 5, 1); () = define_keywords_n ($1, "future", 6, 1); () = define_keywords_n ($1, "byvaluegeneric", 7, 1); () = define_keywords_n ($1, "finalizeoperator", 8, 1); () = define_keywords_n ($1, "transient", 9, 1); define java_mode () { variable java = "java"; c_mode (); set_mode (java, 2); use_syntax_table (java); run_mode_hooks("java_mode_hook"); } jed-0.99-19/lib/tabs.sl0000644002657400265740000000265011311317447013534 0ustar davisdavis%% %% Tab routines for JED %% %% The following defines the tab stops to be 8 column: custom_variable ("Tab_Stops", [0:19] * TAB_DEFAULT + 1); define tab_to_tab_stop () { variable c, goal, i; c = what_column (); foreach (Tab_Stops) { goal = (); if (goal > c) break; } insert_spaces (goal - c); } setkey ("tab_to_tab_stop", "^I"); private variable _Tabs_Buffer; $1 = "*TabsEdit*"; !if (keymap_p($1)) { make_keymap ($1); undefinekey ("^C", $1); definekey ("tabs_install_tab_stops", "^C^C", $1); } %% emacs like edit tab stops define edit_tab_stops () { variable tbuf, i; _Tabs_Buffer = whatbuf(); tbuf = "*TabsEdit*"; sw2buf(tbuf); erase_buffer(); TAB = 0; use_keymap(tbuf); foreach (Tab_Stops) { i = (); goto_column (i); insert_char ('T'); } newline (); _for (1, 13, 1) { i = (); goto_column (10 * i); insert (string(i)); } newline (); loop (13) insert ("1234567890"); insert ("\nTo install changes, type control-c control-c."); bob (); set_buffer_modified_flag (0); set_overwrite (1); } define tabs_install_tab_stops () { variable i; bob (); _for (0, length (Tab_Stops) - 1, 1) { i = (); skip_white (); if (eolp()) break; Tab_Stops[i] = what_column (); go_right_1 (); } Tab_Stops[[i:]] = 0; set_buffer_modified_flag (0); delbuf (whatbuf ()); sw2buf ( _Tabs_Buffer); } jed-0.99-19/lib/cuamisc.sl0000644002657400265740000001333311311317447014227 0ustar davisdavis% cuamisc.sl: helper functions for the cua suite % % "Outsourced" from cua.sl, so they can be used by other emulations as well. % Author: Guenter Milde % Version 1 first public version % 1.1 repeat search opens the Search meanu if LAST_SEARCH is empty % 1.1.1 tweaked by jed for inclusion into 0.99-17 %!%+ %\function{cua_delete_word} %\synopsis{Delete the current word (or a defined region)} %\usage{ Void cua_delete_word ()} %\description % cua_delete_word is somewhat context sensitive: % * Delete from the current position to the end of a word. % * If there is just whitespace following the editing point, delete it. % * If there is any other non-word char, delete just one char. % * If a region is defined, delete it (instead of the above actions). % This way, you can do a "piecewise" deletion by repeatedly pressing % the same key-combination. %\notes % This is actually the ide_delete_word function form Guido Gonzatos % ide.sl mode, put here to be usable also with other emulations. %\seealso{delete_word, delete_cmd, cua_kill_region} %!%- public define cua_delete_word () % ^T, Key_Ctrl_Del { !if (markp) { variable m = create_user_mark (); push_mark (); skip_chars (get_word_chars()); if (create_user_mark () == m) skip_chars (" \n\t"); if (create_user_mark () == m) go_right (1); } del_region (); } % Context sensitive backwards deleting, again taken from ide.sl define cua_bdelete_word () % Key_Ctrl_BS { push_mark (); variable m = create_user_mark (); bskip_chars ("a-zA-Z0-9"); if (create_user_mark () == m) bskip_chars (" \n\t"); if (create_user_mark () == m) go_left (1); del_region (); } %!%+ %\function{repeat_search} %\synopsis{continue searching with last searchstring} %\usage{define repeat_search ()} %\seealso{LAST_SEARCH, search_forward, search_backward} %!%- public define cua_repeat_search () { %%#ifeval (_jed_version >= 9916) !if (strlen(LAST_SEARCH)) return menu_select_menu("Global.&Search"); %%#endif go_right (1); !if (fsearch(LAST_SEARCH)) error ("Not found."); } %!%+ %\function{cua_indent_region_or_line} %\synopsis{Indent the current line or (if defined) the region} %\usage{Void cua_indent_region_or_line ()} %\description % Call the indent_line_hook for every line in a region. % If no region is defined, call it for the current line. %\seealso{indent_line, set_buffer_hook, is_visible_mark} %!%- public define cua_indent_region_or_line () { !if(is_visible_mark ()) { indent_line (); return; } check_region (1); % make sure the mark comes first variable end_line = what_line (); exchange_point_and_mark(); % now point is at start of region while (what_line() <= end_line) {indent_line (); go_down_1 ();} pop_mark (0); pop_spot (); } % --- Use the ESC key as abort character (still experimental) %!%+ %\function{cua_escape_cmd} %\synopsis{Escape from a command/aktion} %\usage{cua_escape_cmd()} %\description % Undo/Stop an action. If a region is defined, undefine it. Else % call kbd_quit. %\seealso{kbd_quit} %!%- define cua_escape_cmd() { if (is_visible_mark) pop_mark(0); else call ("kbd_quit"); } %!%+ %\function{cua_escape_cmd} %\synopsis{Distinguish the ESC key from other keys starting with "\\e"} %\usage{Void cua_escape_cmd()} %\description % If there is input pending (i.e. if the keycode is multi-character), % "\\e" will be put back to the input stream. Otherwise (if the % ESC key is pressed, "\\e\\e\\e" is pushed back. With ALT_CHAR = 27, the Alt % key can be used as Meta-key as usual (i.e. press both ALT + % to get the equivalent of the ESC key sequence. %\seealso{escape_cmd, one_press_escape, kbd_quit, map_input, setkey} %!%- define cua_meta_escape_cmd () { if (input_pending(0)) ungetkey (27); else buffer_keystring("\e\e\e"); } %!%+ %\function{cua_one_press_escape} %\synopsis{Redefine the ESC key to issue "\\e\\e\\e"} %\usage{cua_one_press_escape()} %\description % Dependend on the jed-version, either x_set_keysym or % meta_escape_cmd is used to map the ESC key to "\\e\\e\\e" %\example % To let the ESC key abort functions but retain bindings for % keystrings that start with "\\e" do %#v+ % cua_one_press_escape(); % setkey ("cua_escape_cmd", "\e\e\e"); % Triple-Esc -> abort %#v- %\notes % The function is experimental and has sideeffects if not using xjed. % For not-x-jed: % % It uses the "^^" character for temporarily remapping, i.e. Ctrl-^ will % call cua_escape_cmd(). % % In order to work, it must be loaded before any mode-specific keymaps are % defined -- otherwise this modes will be widely unusable due to not % working cursor keys...! % % It breaks functions that rely on getkey() (e.g. isearch, showkey, old % wmark(pre 99.16), ...) % % It will not work in keybord macros and might fail on slow terminal links. % %\seealso{cua_escape_cmd, cua_escape_cmd, getkey, setkey, x_set_keysym} %!%- define cua_one_press_escape() { if (is_defined("x_set_keysym")) call_function ("x_set_keysym", 0xFF1B, 0, "\e\e\e"); % one-press-escape else { map_input(27, 30); % "\e" -> "^^" ("^6" on most keybords, undo in wordstar) setkey ("cua_escape_cmd", "^^"); } } %{{{ cua_save_buffer() %!%+ %\function{cua_save_buffer} %\synopsis{cua_save_buffer} %\usage{Void cua_save_buffer();} %\description % Save current buffer. %!%- define cua_save_buffer() { variable file; !if (buffer_modified()) { message("Buffer not modified."); return; } file = buffer_filename(); !if (strlen(file)) save_buffer_as(); () = write_buffer(file); } add_completion("cua_save_buffer"); %}}} provide ("cuamisc"); jed-0.99-19/lib/aprocess.sl0000644002657400265740000000041311311317447014415 0ustar davisdavisdefine aprocess_stringify_status (pid, flags, status) { variable str; switch (flags) { case 2: "stopped by signal";} { case 4: "exit";} { case 8: "killed by signal";} { "??"; } str = (); return sprintf ("%s %d", str, status); } jed-0.99-19/lib/register.sl0000644002657400265740000001016511311317447014427 0ustar davisdavis% Register facility. % % CHANGELOG % ========= % % v2.0 2002/09/04 % o Re-implemented to use an associative array so that registers can % be given meaningful names. Added reg_get/set_registers functions % for use by Francesc's register load/save functions. % % v1.0 2000/12/29 % % o Added register management from the menu bar. % % o 'register' evolved from no-mode to 'quasimode'. That is, % it behaves like 'minued' but without edition/update capabilities. % (Francesc Rocher ) % private variable Register_Buffer_Arrays = Assoc_Type[String_Type,""]; public define reg_get_registers () { return Register_Buffer_Arrays; } public define reg_set_registers (reg) { Register_Buffer_Arrays = reg; } private define get_register_name () { variable keys = assoc_get_keys (Register_Buffer_Arrays); keys = strjoin (keys, ","); variable name = read_with_completion (keys, "Register Name:", "", "", 's'); name = strtrim (name); if (name == "") name = NULL; return name; } public define reg_copy_to_register () { !if (markp ()) error ("No region defined."); variable name = get_register_name (); if (name != NULL) { Register_Buffer_Arrays [name] = bufsubstr (); } } public define reg_insert_register () { variable name = get_register_name (); if (name == NULL) return; !if (assoc_key_exists (Register_Buffer_Arrays, name)) { vmessage ("Register '%s' does not exist", name); return; } insert (Register_Buffer_Arrays[name]); vmessage ("Register '%s' inserted.", name); } private variable Reg_Mark; private variable Reg_Cline = color_number ("menu_selection"); private variable Reg_Line = 1; private variable Reg_Nwindows; private variable Reg_Cbuf; private define reg_prev () { return re_bsearch ("^[^ \t]"); } private define reg_next () { return re_fsearch ("^[^ \t]"); } private define reg_update_hook () { bol (); if (looking_at (" ")) { if (what_line () > Reg_Line) { !if (reg_next ()) () = reg_prev (); } else { !if (reg_prev ()) () = reg_next (); } } bol (); Reg_Line = what_line (); Reg_Mark = create_line_mark (Reg_Cline); } public define reg_quit () { setbuf ("*registers*"); set_buffer_modified_flag (0); sw2buf (Reg_Cbuf); delbuf ("*registers*"); %menu_set_object_available ("Global.&Edit.Re&gisters.&Insert", 0); %menu_set_object_available ("Global.&Edit.Re&gisters.Ca&ncel", 0); if (Reg_Nwindows == 1) onewindow (); else otherwindow (); } public define reg_insert () { push_mark (); eol (); bskip_white (); variable name = bufsubstr (); reg_quit (); insert (Register_Buffer_Arrays [name]); recenter (0); } public define reg_help () { message ("?: this help, q: quit mode, RET: insert register"); } $1 = "register"; !if (keymap_p ($1)) { make_keymap ($1); definekey ("reg_help", "?", $1); definekey ("reg_quit", "q", $1); definekey ("reg_insert", "\r", $1); } public define register_mode () { variable mode = "register"; if (0 == length (Register_Buffer_Arrays)) error ("There are no registers defined."); Reg_Nwindows = nwindows (); Reg_Cbuf = pop2buf_whatbuf ("*registers*"); pop2buf ("*registers*"); set_readonly (0); erase_buffer (); foreach (Register_Buffer_Arrays) using ("keys", "values") { variable key, value; (key, value) = (); variable l = what_line (); l++; insert (key); newline (); insert (value); newline (); while (what_line () > l) { go_up_1 (); bol (); whitespace (3); } eob (); } call ("backward_delete_char_untabify"); bob (); set_buffer_modified_flag (0); set_buffer_hook ("update_hook", ®_update_hook); %set_column_colors (Colorin_Left, 1, 3); toggle_readonly (); %menu_set_object_available ("Global.&Edit.Re&gisters.&Insert", 1); %menu_set_object_available ("Global.&Edit.Re&gisters.Ca&ncel", 1); use_keymap (mode); set_mode (mode, 0); run_mode_hooks ("register_mode_hook"); reg_help (); } jed-0.99-19/lib/mime.sl0000644002657400265740000000226111311317447013530 0ustar davisdavis% Parse buffer full of MIME noise % Note: This is very primitive and should be fixed define mime_parse_this_qp () { variable str; str = strcat ("0x", char (what_char ())); del (); str = strcat (str, char (what_char ())); del (); if (Integer_Type == _slang_guess_type (str)) { insert_char (integer(str)); return; } insert (str); } define mime_rfc1522_parse_buffer () { variable qpre; variable len; variable charset, str; % Look for things like =?iso-8859-1?Q?=E1end?= qpre = "=\\?\\([-_a-zA-Z0-9]+\\)\\?Q\\?\\([^ \t]+\\)\\?="; push_spot (); bob (); while (len = re_fsearch (qpre), len) { len--; charset = regexp_nth_match (1); str = regexp_nth_match (2); push_mark (); go_right (len); del_region (); push_mark (); insert (str); narrow_to_region (); bob (); replace ("_", " "); while (fsearch ("=")) { del (); mime_parse_this_qp (); } eob (); widen_region (); } pop_spot (); } define mime_qp_parse_buffer () { bob (); while (fsearch ("=")) { del (); if (eolp ()) { del (); continue; } mime_parse_this_qp (); } } jed-0.99-19/lib/mailalias.sl0000644002657400265740000001431211311317447014535 0ustar davisdavis% mailalias.sl -*- mode: slang; mode: fold -*- % % expand any aliases in the To, Cc, Bcc, From, Reply-To: lines % % - use Pine-style (TAB delimited) aliases % - use UCB Mail (space delimited) aliases % % Pine (.addressbook) style: % alias-name[TAB]Family Name(s), First Name(s)[TAB]e-mail-address % alias-name[TAB]space for name[TAB]e-mail-address % % UCB Mail (.mailrc) style % alias alias-name e-mail-address % group alias-name address1 address2 ... % % The mail entry point: mailalias_expand (); % relies on the X-Mailer: field to indicate the end of the header % % add to your mail_hook() % % define mail_hook () % { % local_setkey ("mailalias_expand", "^C^E"); % ... % } % require ("mailutils"); %{{{ Public Variables %!% where to find the [TAB] delimited mail alias list custom_variable ("Mailaliases", dircat (getenv ("HOME"), ".addressbook")); %!% where to find the [SPACE] delimited mail alias list !if (is_defined ("Mailrc")) { variable Mailrc = getenv ("MAILRC"); if (Mailrc == NULL) Mailrc = dircat (getenv ("HOME"), ".mailrc"); } %}}} %{{{ Private Variables private variable Mailalias_buf = " *mailalias*"; %}}} %{{{ Private Functions %{{{ forward reference define mailalias_xAlias(); %}}} % take a comma-delimited list of aliases and return a list of fully % expanded names and addresses define mailalias_xList (raw,space_to_comma) %{{{ { variable str, list = ""; if (strlen (Mailrc)) { if (space_to_comma) raw = strtrans (raw, " ", ","); } raw = strcompress (raw, ","); foreach (strchop (raw, ',', 0)) { str = mailalias_xAlias (strtrim (())); if (strlen (str)) { if (strlen (list)) list += ",\n\t"; list += str; } } strtrim (list); % return on the stack } %}}} % expands alias => "Full Name" % quotes any names that contain '@' to % for a [TAB] delimited field % This function is executed in the buffer containing the aliases define mailalias_xAlias (alias) %{{{ { variable name, addr = Null_String; variable name0, name1; !if (strlen (alias)) return addr; if ((is_substr (alias, "@") or is_substr (alias, "<"))) { % "" if (is_substr (alias, "<")) alias; else "<" + alias + ">"; return; } bob (); !if (right (bol_fsearch (alias + "\t"))) return alias; % hand-rolled functions, regular expressions are too inconsistent % and do not work across lines USER_BLOCK0 { push_mark (); % extract a field skip_chars ("^\t\n"); % next field bufsubstr (); % return the field on the stack go_right (1); % skip TAB char } name = X_USER_BLOCK0; % fullname or surname name0 = extract_element (name, 0, ','); name1 = extract_element (name, 1, ','); if (name1 == NULL) name1 = ""; name = strtrim (strtrim (name1) + " " + strtrim (name0)); % "quote" name in case it contains one of `,.@' name = "\"" + name + "\" "; if (looking_at_char ('(')) % distribution list (with parentheses) { name = Null_String; % ignore name of distribution list? go_right (1); push_mark (); !if (fsearch_char (')')) skip_chars ("^\t \n"); % messed-up entry? addr = mailalias_xList (bufsubstr (), 1); } else { addr = X_USER_BLOCK0; addr = "<" + addr + ">"; } name + addr; % "Full Name" } %}}} % expands alias => user@machine.domain % for a [SPACE] delimited field % This function is executed in the buffer containing the aliases define mailrc_xAlias (alias) %{{{ { variable name, addr; variable n; alias = strtrim (alias); if (not(strlen(alias)) or is_substr (alias, char ('@'))) return alias; % look for "alias name" name = "alias " + alias + " "; bob (); % Convert all tabs to spaces replace ("\t", " "); n = bol_fsearch (name); !if (n) { % look for "group name" name = "group " + alias + " "; n = bol_fsearch (name); !if (n) return alias; } go_right (n); addr = ""; % hand-rolled functions, regular expressions are too inconsistent forever { skip_white (); if (eolp ()) break; push_mark (); skip_chars ("^ \n"); % next address name = bufsubstr (); % address if (strlen (addr)) addr += ",\n\t"; addr += name; } addr; } %}}} % look for the addresses that follow FIELD and are before the next one. define mailalias_xField (field) %{{{ { variable addr, buf = whatbuf (); addr = mailutils_get_keyword_value (field); if (addr == NULL) return; setbuf (Mailalias_buf); addr = "\t" + mailalias_xList (addr, 0); sw2buf (buf); mailutils_set_keyword_value (field, addr); } %}}} %}}} %!% expands "To, Cc, Bcc" mail header fields using the aliases/addresses %!% that are defined in Mailaliases define mailalias_expand () %{{{ { %variable buf = "*mail*"; variable buf = whatbuf (); %if (strcmp (buf, whatbuf)) error ("Mail mode only"); push_spot (); setbuf (Mailalias_buf); if (insert_file (Mailaliases) > 0) { set_buffer_modified_flag (0); % mark unmodified sw2buf (buf); % order isn't important foreach (["From:", "Reply-To:", "Bcc:", "Cc:", "To:"]) { variable header = (); mailalias_xField (header); } } else { sw2buf (buf); } delbuf (Mailalias_buf); pop_spot (); } %}}} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %{{{ check that everything is okay, unload as appropriate #ifexists stat_file % If the files exist, they may be empty. Here is a quick check for that. foreach ([&Mailaliases, &Mailrc]) { $1 = (); $2 = stat_file (@$1); if ($2 != NULL) { if ($2.st_size == 0) @$1 = ""; } } #endif %verror (Mailaliases); % ~/.addressbook is okay, un-load Mailrc stuff if (1 == file_status (Mailaliases)) { eval (".()mailrc_xAlias"); Mailrc = Null_String; } % ~/.mailrc is okay, then un-load addressbook stuff & over-load definition else if (1 == file_status (Mailrc)) { eval (".(mailrc_xAlias) mailalias_xAlias"); Mailaliases = Mailrc; } % nothing seems to have worked, so get rid of everything else { eval (".()mailrc_xAlias"); eval (".()mailalias_xAlias"); eval (".()mailalias_xList"); eval (".()mailalias_xField"); eval (".()mailalias_expand"); Mailaliases = Null_String; } %}}} jed-0.99-19/lib/iso2xxx.sl0000644002657400265740000000334211311317447014226 0ustar davisdavis% Thanks to torres@upf.es for the bulk of this _debug_info = 1; private variable ISO_Latin_Chars = strcat ("\d225\d233\d237\d243\d250\d193\d201\d205\d211\d218", % "áéíóúÁÉÍÓÚ" "\d224\d232\d236\d242\d249\d192\d200\d204\d210\d217", % "àèìòùÀÈÌÒÙ" "\d226\d234\d238\d244\d251\d194\d202\d206\d212\d219", % "âêîôûÂÊÎÔÛ" "\d228\d235\d239\d246\d252\d196\d203\d207\d214\d220", % "äëïöüÄËÏÖÜ" "\d161\d191\d231\d199\d241\d209\d230\d198", % "¡¿çÇñÑæÆ" "\d248\d216\d229\d197\d223"); % "øØåÅß" private variable ISO_TeX_Chars = strcat ("\\'a,\\'e,\\'{\\i},\\'o,\\'u,\\'A,\\'E,\\'I,\\'O,\\'U,", "\\`a,\\`e,\\`{\\i},\\`o,\\`u,\\`A,\\`E,\\`I,\\`O,\\`U,", "\\^a,\\^e,\\^{\\i},\\^o,\\^u,\\^A,\\^E,\\^I,\\^O,\\^U,", "\\\"a,\\\"e,\\\"{\\i},\\\"o,\\\"u,\\\"A,\\\"E,\\\"I,\\\"O,\\\"U,", "!`,?`,\\c{c},\\c{C},\\~n,\\~N,{\\ae},{\\AE},", "{\\o},{\\O},{\\aa},{\\AA},{\\ss}"); define iso2tex () { variable i, str_old, str_new; variable save_case_search = CASE_SEARCH; CASE_SEARCH = 1; push_spot (); bob (); _for (0, strlen (ISO_Latin_Chars) - 1, 1) { i = (); str_new = extract_element (ISO_TeX_Chars, i, ','); str_old = char (ISO_Latin_Chars[i]); %bob (); --- not needed since replace does not move the point replace (str_old, str_new); } pop_spot(); CASE_SEARCH = save_case_search; } define tex2iso () { variable i, str_old, str_new; variable save_case_search = CASE_SEARCH; CASE_SEARCH = 1; push_spot (); _for (0, strlen (ISO_Latin_Chars) - 1, 1) { i = (); str_old = extract_element (ISO_TeX_Chars, i, ','); str_new = char (ISO_Latin_Chars[i]); bob (); replace (str_old, str_new); } pop_spot(); CASE_SEARCH = save_case_search; } jed-0.99-19/lib/popups.sl0000644002657400265740000002204711311317447014133 0ustar davisdavis% Main menu function autoloaded by menus.sl #ifndef VMS private define add_files_popup_with_callback (parent, popup, dir, pattern, fun) { variable files; variable i; files = listdir (dir); if (files == NULL) return; i = where (array_map (Int_Type, &string_match, files, pattern, 1)); if (length (i) == 0) return; files = files[i]; files = files[array_sort (files)]; menu_append_popup (parent, popup); popup = parent + "." + popup; foreach (files) { variable file = (); file = path_sans_extname(path_sans_extname (file)); % could have foo.txt.gz menu_append_item (popup, file, fun, file); } } private define browse_docs_callback (file) { file = dircat (JED_ROOT, "doc/txt/" + file + ".txt"); variable is_compressed = 0; if (file_status (file) != 1) { foreach ([".gz", ".bz2", ".Z"]) { variable ext = (); if (file_status (file + ext) != 1) continue; file = file + ext; is_compressed = 1; break; } } variable state; #ifdef UNIX if (is_compressed) auto_compression_mode (1, &state); #endif () = read_file (file); #ifdef UNIX if (is_compressed) auto_compression_mode (state); #endif pop2buf (whatbuf ()); most_mode (); } #endif private define close_file (clientdata) { delbuf (whatbuf ()); } $1 = "Global.&File"; menu_append_item ($1, "&Open", "find_file"); menu_append_item ($1, "&Close", &close_file, NULL); menu_append_item ($1, "&Save", "save_buffer"); menu_append_item ($1, "Save &As", "write_buffer"); menu_append_item ($1, "Save &Buffers", "save_some_buffers"); menu_append_item ($1, "&Insert File", "insert_file"); #iffalse menu_append_separator ($1); menu_append_popup ($1, "&Version Control"); #endif menu_append_separator ($1); menu_append_item ($1, "Canc&el Operation", "kbd_quit"); menu_append_item ($1, "E&xit", "exit_jed"); #iffalse $1 = "Global.&File.&Version Control"; menu_append_item ($1, "RCS &Open", "rcs_open_file"); % rcs.sl required menu_append_item ($1, "RCS &Check In/Out", "rcs_check_in_and_out"); menu_append_item ($1, "Numbered Bac&kups On", "backups_on"); menu_append_item ($1, "Numbered Back&ups Off", "backups_off"); #endif $1 = "Global.&Edit"; menu_append_item ($1, "&Begin Region/Rect", "smart_set_mark_cmd"); menu_append_item ($1, "&Cut Region", "yp_kill_region"); menu_append_item ($1, "C&opy Region", "yp_copy_region_as_kill"); menu_append_item ($1, "&Paste", "yp_yank"); menu_append_popup ($1, "Re&gion Ops"); menu_append_popup ($1, "&Rectangles"); menu_append_separator ($1); menu_append_popup ($1, "&Key Macros"); menu_append_separator ($1); menu_append_item ($1, "&Undo", "undo"); $1 = "Global.&Edit.&Key Macros"; menu_append_item ($1, "&Start Macro", "begin_macro"); menu_append_item ($1, "S&top Macro", "end_macro"); menu_append_item ($1, "Replay &Last Macro", "execute_macro"); $1 = "Global.&Edit.&Rectangles"; menu_append_item ($1, "&Cut Rectangle", "kill_rect"); menu_append_item ($1, "C&opy Rectangle", "copy_rect"); menu_append_item ($1, "&Paste Rectangle", "insert_rect"); menu_append_item ($1, "Op&en Rectangle", "open_rect"); menu_append_item ($1, "&Blank Rectangle", "blank_rect"); $1 = "Global.&Edit.Re&gion Ops"; menu_append_item ($1, "&Upper Case", ".'u' xform_region"); menu_append_item ($1, "&Lower Case", ".'d' xform_region"); menu_append_item ($1, "&Comment", "comment_region"); menu_append_item ($1, "U&ncomment", "uncomment_region"); menu_append_separator ($1); menu_append_item ($1, "&Save to File", "write_region"); menu_append_item ($1, "&Append to File", "append_region"); menu_append_separator ($1); menu_append_item ($1, "Copy To &Register", "reg_copy_to_register"); menu_append_item ($1, "&Paste From Register", "reg_insert_register"); menu_append_item ($1, "&View Registers", "register_mode"); $1 = "Global.&Search"; menu_append_item ($1, "Search &Forward", "search_forward"); menu_append_item ($1, "Search &Backward", "search_backward"); menu_append_item ($1, "R&egexp Search Forward", "re_search_forward"); menu_append_item ($1, "Re&gexp Search Backward", "re_search_backward"); menu_append_separator ($1); menu_append_item ($1, "&Replace", "replace_cmd"); menu_append_item ($1, "Regexp Re&place", "query_replace_match"); menu_append_separator ($1); menu_append_item ($1, "Se&t Bookmark", "bkmrk_set_mark"); menu_append_item ($1, "Got&o Bookmark", "bkmrk_goto_mark"); menu_append_item ($1, "&Goto Line", "goto_line_cmd"); private define change_buffer_callback (popup) { loop (buffer_list ()) { variable b = (); if (b[0] == ' ') continue; menu_append_item (popup, b, &sw2buf, b); } } $1 = "Global.&Buffers"; menu_append_popup ($1, "&Toggle"); menu_append_popup ($1, "&Change Buffer"); menu_set_select_popup_callback (strcat ($1, ".&Change Buffer"), &change_buffer_callback); 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"); menu_append_item ($1, "&S-Lang Mode", "slang_mode"); menu_append_item ($1, "&Text Mode", "text_mode"); menu_append_item ($1, "&LaTeX Mode", "latex_mode"); menu_append_item ($1, "Te&X Mode", "tex_mode"); menu_append_item ($1, "&No Mode", "no_mode"); menu_append_item ($1, "&Fortran Mode", "fortran_mode"); menu_append_item ($1, "F&90 Mode", "f90_mode"); menu_append_item ($1, "&Python Mode", "python_mode"); menu_append_item ($1, "s&h mode", "sh_mode"); $1 = "Global.&Buffers.&Toggle"; menu_append_item ($1, "&Line Numbers", "toggle_line_number_mode"); menu_append_item ($1, "&Overwrite", "toggle_overwrite"); menu_append_item ($1, "&Read Only", "toggle_readonly"); menu_append_item ($1, "&CR/NL mode", "toggle_crmode"); $1 = "Global.W&indows"; menu_append_item ($1, "&One Window", "one_window"); menu_append_item ($1, "&Split Window", "split_window"); menu_append_item ($1, "O&ther Window", "other_window"); menu_append_item ($1, "&Delete Window", "delete_window"); #ifndef VMS menu_append_separator ($1); private variable Gui_Jed; private define set_gui_color_scheme (file) { set_color_scheme (Gui_Jed + file); } menu_append_popup ($1, "&Color Schemes"); if (is_defined ("x_server_vendor")) { Gui_Jed = "Xjed/"; $2 = $1 + ".&Color Schemes"; foreach (strtok (Color_Scheme_Path, ",")) { $3 = (); add_files_popup_with_callback ($2, "&Xjed", dircat ($3, "Xjed"), "\\C^.*\\.sl$", &set_gui_color_scheme); } menu_append_separator ($2); } foreach (strtok (Color_Scheme_Path, ",")) { $2 = (); add_files_popup_with_callback ($1, "&Color Schemes", $2, "\\C^.*\\.sl$", &set_color_scheme); } #endif menu_append_separator ($1); menu_append_item ($1, "&Redraw", "redraw"); !if (_jed_secure_mode) { $1 = "Global.S&ystem"; menu_append_item ($1, "&S-Lang Command", "evaluate_cmd"); menu_append_item ($1, "S&hell Command", "do_shell_cmd"); menu_append_item ($1, "&Compile", "compile"); #ifdef UNIX #ifexists open_process autoload ("ashell", "ashell"); menu_append_item ($1, "Shell &Window", "ashell"); #else menu_append_item ($1, "Shell &Window", "shell"); #endif menu_append_item ($1, "&Ispell", "ispell"); menu_append_item ($1, "&Mail", "mail"); #else menu_append_item ($1, "Shell &Window", "shell"); #endif } menu_append_item ($1, "C&alendar", "calendar"); menu_append_item ($1, "&Function", "emacs_escape_x"); private define about_jed (unused) { variable about_doc = expand_jedlib_file ("aboutjed.hlp"); pop2buf ("*about jed*"); set_readonly (0); erase_buffer (); vinsert ("Jed Version: %s\nS-Lang Version: %s\n\n", _jed_version_string, _slang_version_string); if (about_doc != "") () = insert_file (about_doc); else insert ("aboutjed.hlp not found"); set_buffer_modified_flag (0); bob (); most_mode (); } $1 = "Global.&Help"; menu_append_item ($1, "About &Jed", &about_jed, NULL); #ifndef VMS add_files_popup_with_callback ($1, "&Browse Docs", dircat (JED_ROOT, "doc/txt"), "\\C^.*\\.txt\\.?", &browse_docs_callback); #endif menu_append_separator ($1); menu_append_item ($1, "&Describe Key Bindings", "describe_bindings"); menu_append_item ($1, "Describe &Mode", "describe_mode"); menu_append_item ($1, "Describe &Function", "describe_function"); menu_append_item ($1, "Describe &Variable", "describe_variable"); menu_append_item ($1, "&Apropos", "apropos"); menu_append_separator ($1); menu_append_item ($1, "Show &Key", "showkey"); menu_append_item ($1, "&Where Is Command", "where_is"); menu_append_separator ($1); menu_append_item ($1, "&Info Reader", "info_reader"); #ifdef UNIX menu_append_item ($1, "&Unix Man Page", "unix_man"); #endif #ifndef VMS % Delete this function since we nolonger need it private define add_files_popup_with_callback(); #endif % This function gets called by menus.sl as the select_menubar_callback. % Its purpose is to load this file. % Note: ide.sl calls this file. define menu_load_popups (menubar) { _jed_run_hooks ("load_popup_hooks", 1, [menubar]); } menu_set_select_menubar_callback ("Global", NULL); Menu_Popups_Loaded = 1; jed-0.99-19/lib/simple.hlp0000644002657400265740000000062711311317447014243 0ustar davisdavisPress Control-X to get simple menus or (^K = Control-K): ^KE exit ^D pagedown ^FF search ^K^B set mark ^V delete ^U pageup ^FB search back ^KK copy region ^E end of line ^K^W write buffer ^K^R replace ^K^P paste ^B beginning of line ^KG find file ^R redraw ^K^V cut region ^_ undo ^H^H this help ^Hi jed documentation jed-0.99-19/lib/vhdlmode.sl0000644002657400265740000002075311311317447014411 0ustar davisdavis% VHDL mode -* SLang -*- % % This is a simple vhdl mode. First it implements a highlighting scheme. % % modified by Thei Wijnen 22-nov-2001: added: xor xnor with after alias select % modified by Thei Wijnen 21-mar-2002: added: generate transport rising_edge falling_edge % Modified by Thei Wijnen 10-Aug-2003: implemented indentation style and folding. % Modified by Thei Wijnen 06-Jun-2004: indent region, added more keywords. % Modified by Thei Wijnen 03-Mar-2005: allow mixed case, added more keywords. % % Loading this file, then executing 'vhdl_mode' will start % VHDL mode on the current buffer. custom_variable ("VHDL_Comment_String", "--"); custom_variable ("VHDL_Indent_Amount", 2); % % VHDL indent routine define vhdl_indent () { variable goal = 1; % start in column 1. variable cs = CASE_SEARCH; variable ch; push_spot (); push_spot (); CASE_SEARCH = 0; % VHDL is not case sensitive while (up_1 ()) { bol_skip_white(); if (eolp() ) continue; goal = what_column (); if (goal == 1) continue; if (looking_at("do ") or looking_at("elsif ") or looking_at("elsif(") or looking_at("else") ) { goal += VHDL_Indent_Amount; } else if (looking_at("if ") or looking_at("if(")) { if (ffind("then")) { goal += VHDL_Indent_Amount; } } else if (looking_at("for") or looking_at("for(")) { if (ffind("loop")) goal += VHDL_Indent_Amount; } else if (looking_at("when")) { if (ffind("=>")) goal += VHDL_Indent_Amount; } else if (looking_at("case")) { if (ffind("is")) goal += VHDL_Indent_Amount; } else if (looking_at("begin")) { goal += VHDL_Indent_Amount; } % else if (looking_at("begin")) % { % push_spot (); % while (up_1 ()) % { % bol_skip_white(); % if (eolp() ) continue; % if (looking_at("variable ") or looking_at("process") ) % { % goal -= VHDL_Indent_Amount; % } % break; % } % pop_spot (); % } break; } pop_spot (); % now check current line bol_skip_white(); % if (looking_at("begin")) % goal += VHDL_Indent_Amount; if (looking_at("elsif") or looking_at("else") or looking_at("end") or looking_at("when") % or looking_at("end if") % or looking_at("end process") % or looking_at("end loop") ) { goal -= VHDL_Indent_Amount; } CASE_SEARCH = cs; % done getting indent bol_skip_white (); ch = char(what_char()); switch (ch) %* { %* isdigit (ch) : % label %* %* if (what_column () >= 6) %* { %* bol_trim (); %* insert_single_space (); %* } %* X_USER_BLOCK1 (); %* } { not (bolp()) or eolp (): % general case bol_trim (); goal--; insert_spaces (goal); } pop_spot (); skip_white (); } define vhdl_newline () { variable p, cont; if (bolp ()) { newline (); return; } vhdl_indent (); push_spot (); bskip_white (); trim (); pop_spot (); newline (); insert_single_space (); vhdl_indent (); } % % Look for beginning of current subroutine/function define vhdl_beg_of_subprogram () { variable cs = CASE_SEARCH; CASE_SEARCH = 0; do { bol_skip_white (); if (_get_point ()) { if (looking_at ("process") or looking_at ("switch")) break; } } while (up_1 ()); CASE_SEARCH = cs; } % % Look for end of current subroutine/function define vhdl_end_of_subprogram () { variable cs = CASE_SEARCH; CASE_SEARCH = 0; do { bol_skip_white (); if (looking_at ("end;") or looking_at ("end process")) break; % { % go_right (3); % skip_white (); % if (eolp ()) break; % } } while (down_1 ()); CASE_SEARCH = cs; } define vhdl_mark_subprogram () { vhdl_end_of_subprogram (); go_down_1 (); set_mark_cmd (); vhdl_beg_of_subprogram (); bol (); } % Indent the selected region (bound to \e^i) define vhdl_indent_region () { check_region(1); pop_mark_1 (); push_mark(); vhdl_indent(); % set initial line indentation before narrowing pop_spot(); push_spot(); go_up_1 (); narrow(); bob(); flush("Indenting region..."); while (down_1 ()) { % indent line by line (ie slowly) vhdl_indent(); % flush(Sprintf("Indenting line %d", what_line(), 1)); } flush("Indenting region... Done."); widen(); pop_spot(); } % % main entry point into the VHDL mode % % Set up syntax table $1 = "VHDL"; create_syntax_table ($1); define_syntax ("--","",'%', $1); % comments define_syntax ("([{", ")]}", '(', $1); % parentheses define_syntax ('"', '"', $1); % quoted strings %define_syntax ('\'', '\'', $1); % quoted characters (paired ') define_syntax ('\'', '\\', $1); % continuations define_syntax ("0-9a-zA-Z_", 'w', $1); % words define_syntax ("-+0-9a-fA-F.xXL", '0', $1); % numbers define_syntax (",;.?:=<>", ',', $1); % delimiters define_syntax ('#', '#', $1); % preprocessor define_syntax ("%-+/&*<>|!~^", '+', $1); % operators set_syntax_flags ($1, 8); % % Type 0 keywords () = define_keywords ($1, "ifinisofonorto", 2); () = define_keywords ($1, "absandendformapmaxminmodnornotoutremrunusexor", 3); () = define_keywords ($1, "casebodyelsefileloopnandnextopenportpurethentypewaitwhenwithxnor", 4); () = define_keywords ($1, "afteraliasbeginelsifgroupinoutlabeltraceuntilwhile", 5); () = define_keywords ($1, "accessassertassignbufferdowntoentityimpureothersrecordrejectreportreturnselectsharedsignal", 6); () = define_keywords ($1, "genericguardedlibraryliteralpackageprocesssubtype", 7); () = define_keywords ($1, "constantfunctiongenerateinertialregisterseverityvariable", 8); () = define_keywords ($1, "attributecomponentpostponedproceduretransport", 9); () = define_keywords ($1, "architecture", 12); () = define_keywords ($1, "configuration", 13); % Type 1 keywords - use for operator like keywords () = define_keywords_n ($1, "eqgegtleltne", 2, 1); () = define_keywords_n ($1, "lowposslasllsrasrlval", 3, 1); () = define_keywords_n ($1, "basehighleftnotepredsucctrue", 4, 1); () = define_keywords_n ($1, "erroreventfalseimagequietrangerightvalue", 5, 1); () = define_keywords_n ($1, "activeleftoflengthstable", 6, 1); () = define_keywords_n ($1, "delayeddrivingfailurerightofwarning", 7, 1); () = define_keywords_n ($1, "ascendingdecending", 9, 1); () = define_keywords_n ($1, "last_eventlast_value", 10, 1); () = define_keywords_n ($1, "last_activerising_edgetransaction", 11, 1); () = define_keywords_n ($1, "falling_edge", 12, 1); () = define_keywords_n ($1, "driving_valuereverse_range", 13, 1); % Type 2 keywords - use for type declarator keywords () = define_keywords_n ($1, "msnspsus", 2, 2); () = define_keywords_n ($1, "linetime", 4, 2); () = define_keywords_n ($1, "string", 6, 2); () = define_keywords_n ($1, "booleanintegernatural", 7, 2); () = define_keywords_n ($1, "unsigned", 8, 2); () = define_keywords_n ($1, "characterstd_logic", 9, 2); () = define_keywords_n ($1, "std_logic_vector", 16, 2); % Set up syntax table $1 = "VHDL"; !if (keymap_p ($1)) make_keymap ($1); definekey ("vhdl_beg_of_subprogram", "\e^A", $1); definekey ("vhdl_end_of_subprogram", "\e^E", $1); definekey ("vhdl_mark_subprogram", "\e^H", $1); definekey ("vhdl_indent_region", "\e^I", $1); %!%+ %\function{vhdl_mode} %\synopsis{vhdl_mode} %\description % Mode designed for the purpose of editing VHDL files. % After the mode is loaded, the hook 'vhdl_hook' is called. % Useful functions include % % Function: Default Binding: % vhdl_beg_of_subprogram ESC ^A % moves cursor to beginning of current function/process % vhdl_end_of_subprogram ESC ^E % moves cursor to end of current function/process % vhdl_mark_subprogram ESC ^H % mark the current function/process % % Variables include: % VHDL_Comment_String : string used by 'vhdl_comment' to % comment out a line. Default is "--". % VHDL_Indent_Amount : number of spaces to indent statements in % a block. The default is 2. %!%- define vhdl_mode () { variable mode = "VHDL"; set_mode (mode, 0x4 | 0x10); use_keymap (mode); use_syntax_table (mode); set_syntax_flags (mode, 0x01); set_buffer_hook ("indent_hook", "vhdl_indent"); set_buffer_hook ("newline_indent_hook", "vhdl_newline"); mode_set_mode_info (mode, "fold_info", "--{{{\r--}}}\r\r"); run_mode_hooks ("vhdl_mode_hook"); } jed-0.99-19/lib/modeinfo.sl0000644002657400265740000000317411311317447014405 0ustar davisdavis% These routines facilitate the manipulation of mode dependent data. private variable Mode_Info_Type = struct { fold_info, % folding.sl: beg\rend\r\beg1\r\end1 dabbrev_word_chars, % word chars for dabbrev mode init_mode_menu, chglog_get_item, use_dfa_syntax, }; private variable Mode_Info_List = Assoc_Type [Struct_Type]; private define find_mode_info (mode_name) { !if (assoc_key_exists (Mode_Info_List, mode_name)) return NULL; return Mode_Info_List[mode_name]; } define mode_set_mode_info (field_name, field_value) { variable mode_info; variable mode_name = get_mode_name (); if (_NARGS == 3) mode_name = (); mode_info = find_mode_info (mode_name); if (mode_info == NULL) { mode_info = @Mode_Info_Type; Mode_Info_List [mode_name] = mode_info; } variable fields = get_struct_field_names (mode_info); !if (any (fields == field_name)) { variable new_mode_info = @Struct_Type ([fields, field_name]); foreach (fields) { variable f = (); set_struct_field (new_mode_info, f, get_struct_field (mode_info, f)); } mode_info = new_mode_info; Mode_Info_List [mode_name] = mode_info; } set_struct_field (mode_info, field_name, field_value); } define mode_get_mode_info (field_name) { variable mode_info; if (_NARGS == 1) get_mode_name (); variable mode_name = (); mode_info = find_mode_info (mode_name); if (mode_info == NULL) return NULL; !if (any (field_name == get_struct_field_names (mode_info))) return NULL; return get_struct_field (mode_info, field_name); } jed-0.99-19/lib/mail.sl0000644002657400265740000001157211311317447013530 0ustar davisdavis% Mail for VMS and Unix systems % % On VMS, this uses callable mail interface. % For Unix, uses /usr/ucb/mail % % See also 'sendmail.sl' for an alternative interface. % % Calls mail_hook if defined. "mail_hook" can either load a file % to override some of the functions here. #ifdef UNIX !if (is_defined ("Use_MailX")) { variable Use_MailX = 0; } %%% University of California, Berkeley mail program %%% "/usr/ucb/mail" on most unix, "/usr/sbin/Mail" on others !if (is_defined("UCB_Mailer")) { variable UCB_Mailer = "/usr/ucb/mail"; if (1 != file_status(UCB_Mailer)) { UCB_Mailer = "/bin/mailx"; if (1 != file_status (UCB_Mailer)) { UCB_Mailer = "/usr/bin/mailx"; if (1 != file_status (UCB_Mailer)) { UCB_Mailer = "/usr/sbin/Mail"; if (1 != file_status (UCB_Mailer)) { error ("UCB Mail program not found!"); } } else Use_MailX = 1; } else Use_MailX = 1; } } define unix_send_mail (to, cc, subj) { variable status; subj = str_quote_string (subj, "'", '\''); if (Use_MailX == 0) { % This is a total crock. For ucb mail, we need to 'quote' lines beginning % with '~'. Lets do it now: check_region (0); () = dupmark(); narrow (); bob(); while (bol_fsearch_char ('~')) insert_single_space (); bob (); if (strlen(cc)) { push_spot (); vinsert ("~c %s\n", cc); } eob(); widen(); status = pipe_region (sprintf("%s -s '%s' '%s'", UCB_Mailer, subj, to)); if (strlen(cc)) { pop_spot (); delete_line(); } } else status = pipe_region (sprintf ("%s -s '%s' -c '%s' '%s'", UCB_Mailer, subj, cc, to)); return (not(status)); } #endif variable Mail_Previous_Buffer = Null_String; variable Mail_Previous_Windows = 1; define mail_send () { variable mail_cmd, to = Null_String, subj = Null_String; variable dir, file, cc = Null_String, sent; push_spot (); bob (); !if (bol_fsearch ("---text follows this line---")) { pop_spot (); error ("Failed to find text divider."); } push_mark (); bob (); narrow (); if (re_fsearch("^To:[ \t]*\\(.*\\)")) { to = regexp_nth_match (1); } if (re_fsearch("^Cc:[ \t]*\\(.*\\)")) { cc = regexp_nth_match (1); } if (re_fsearch("^Subject:[ \t]*\\(.*\\)")) { subj = regexp_nth_match (1); } eob(); widen (); !if (strlen(to)) { pop_spot (); error ("Bad To: field."); } #ifdef VMS if (strlen(cc)) { to += "," + cc; } #endif !if (down_1 ()) { pop_spot(); error ("No message!"); } push_mark_eob (); flush("Sending..."); #ifdef UNIX sent = unix_send_mail (to, cc, subj); #endif #ifdef VMS narrow(); sent = vms_send_mail (to, subj); widen (); #endif if (sent) { flush ("Sending...done"); set_buffer_modified_flag (0); (file, dir,,) = getbuf_info(); () = delete_file (make_autosave_filename(dir, file)); () = delete_file (dir, file); } else { message ("No message sent."); } pop_spot (); whatbuf(); if (bufferp(Mail_Previous_Buffer)) sw2buf (Mail_Previous_Buffer); if (1 == Mail_Previous_Windows) onewindow(); bury_buffer(()); } add_completion("mail_send"); define send () { mail_send (); message ("This function is obsolete. Use 'mail_send'."); } define mail_format_buffer () { variable erase, opt_headers=NULL; if (_NARGS == 2) opt_headers = (); erase = (); variable mail_map = "mail_map"; text_mode(); if (erase) { erase_buffer(); insert("To: \nCc: \nSubject: \n"); if (opt_headers != NULL) insert (opt_headers); insert ("---text follows this line---\n"); bob(); eol(); set_buffer_modified_flag(0); } set_buffer_undo(1); setbuf_info (getbuf_info () & ~(0x40)); % turn off buried buffer flag !if (keymap_p(mail_map)) make_keymap(mail_map); use_keymap(mail_map); } define mail () { variable mail_buf, old, status; mail_buf = "*mail*"; variable file, dir; variable do_format = 1; old = bufferp(mail_buf); Mail_Previous_Windows = nwindows(); Mail_Previous_Buffer = pop2buf_whatbuf(mail_buf); %% if buffer is not old, turn autosave on if (old == 0) { #ifdef VMS dir = "sys$login:"; #else dir = dircat(getenv("HOME"), Null_String); #endif file = "__jed_mail__"; setbuf_info(file, dir, mail_buf, 2); file = make_autosave_filename(dir, file); if (1 == file_status (file)) { if (get_yes_no ("An autosave file exists. Use it")) { erase_buffer (); () = insert_file (file); do_format = 0; } } } else { (,,,status) = getbuf_info(); if (status & 1) return; } mail_format_buffer (do_format); run_mode_hooks("mail_hook"); } define mail_insert_signature () { push_spot (); eob (); insert ("\n-- \n"); insert_file (expand_filename ("~/.signature")); pop_spot (); } jed-0.99-19/lib/emacsmsc.sl0000644002657400265740000000704411311317447014400 0ustar davisdavis% More emacs functions. This file is autoloaded upon demand. define find_buffer_other_window () { variable n, buf, trybuf = Null_String; variable ch; n = buffer_list(); loop (n) { buf = (); n--; ch = buf[0]; if ((ch == ' ') or (ch == '*') or not(strcmp (whatbuf (), buf))) continue; trybuf = buf; break; } loop (n) pop (); trybuf = read_with_completion ("Switch to buffer:", trybuf, Null_String, 'b'); if (strlen (trybuf)) pop2buf (trybuf); } define find_file_other_window () { variable file; file = read_file_from_mini ("Find file:"); !if (strlen(extract_filename(file))) return; !if (read_file(file)) message ("New file."); pop2buf (whatbuf()); } define find_alternate_file () { variable file; file = read_file_from_mini ("Find alternate file:"); !if (strlen(extract_filename(file))) return; delbuf (whatbuf()); !if (find_file (file)) message ("New file."); } define delete_blank_lines () { variable white = " \t\r\n"; bskip_chars(white); eol_trim(); go_down_1(); eol_trim(); bol(); if (eolp()) { go_down_1(); push_mark (); skip_chars (white); bol (); del_region (); } } define forward_sexp () { skip_chars(" \t\n"); if (looking_at_char ('(') or looking_at_char ('{') or looking_at_char ('[')) { if (find_matching_delimiter(what_char ()) == 1) go_right_1 (); return; } skip_chars("^ \t\n()[]{}"); } define backward_sexp () { bskip_chars(" \t\n"); go_left_1 (); if (looking_at_char (')') or looking_at_char ('}') or looking_at_char (']')) { () = find_matching_delimiter(0); return; } bskip_chars("^ \t\n()[]{}"); } define kill_sexp () { variable kr = "yp_kill_region"; push_mark(); forward_sexp(); go_right (eolp ()); if (is_defined (kr)) eval (kr); else call ("kill_region"); } define scroll_up_in_place () { variable m; m = window_line (); if (down_1 ()) recenter (m); bol (); } define scroll_down_in_place () { variable m; m = window_line (); if (up_1 ()) recenter (m); bol (); } define string_rectangle () { variable str = read_mini ("String to replace rectangle:", "", ""); if (str == "") return; check_region (1); exchange_point_and_mark (); variable col = what_column; variable line = what_line (); exchange_point_and_mark (); variable nlines = what_line () - line + 1; if (what_column == col) pop_mark (0); else kill_rect (); goto_line (line); loop (nlines) { goto_column (col); insert (str); go_down (1); } pop_spot (); } define list_directory () { variable pat = read_file_from_mini ("list directory"); !if (strlen (pat)) return; variable dir = path_dirname (pat); pat = path_basename (pat); !if (strlen(pat)) pat = "*"; if (file_status (dir) != 2) verror ("%s is not a directory", dir); variable files = listdir (dir); if (files == NULL) files = String_Type[0]; pat = glob_to_regexp (pat); files = files[where(array_map (Int_Type, &string_match, files, pat, 1))]; files = files[array_sort(files)]; variable cbuf = whatbuf (); pop2buf ("*directory*"); variable file, buf, flags; (file,,buf,flags) = getbuf_info (); setbuf_info (file, dir, buf, flags); erase_buffer (); if (length (files)) { array_map (Void_Type, &vinsert, "%s\n", files); buffer_format_in_columns (); } bob (); vinsert ("Directory %s\n", dir); bob (); set_buffer_modified_flag (0); pop2buf (cbuf); } jed-0.99-19/lib/sendmail.sl0000644002657400265740000001557111311317447014405 0ustar davisdavis% sendmail.sl -*- mode: slang; mode: fold -*- % % (Thanks to olesen@weber.me.queensu.ca (mj olesen) for this) % % Sendmail interface for Unix. % % Functions: % mail_send : send message % mail : initiate mail mode % mail_insert_signature : append contents of Mail_Signature_File % mail_kill_buffer : Delete mail buffer % % Variables: % Mail_Reply_To : Set this to appropriate Reply-To value % Mail_Signature_File : Filename of signature (~/.signature is default) % SendMail_Cmd : Name of sendmail program including switches % Mail_Extra_Headers : Misc headers to insert % % You might want something like the following in mail_hook % % define mail_hook () % { % local_setkey ("mail_send", "^C^C"); % local_setkey ("mailalias_expand", "^C^E"); % local_setkey ("mail_kill_buffer", "^Xk"); % } autoload ("mailalias_expand", "mailalias"); % the mail-alias package % Create a dummy function if set_line_readonly is not defined. !if (is_defined ("set_line_readonly")) eval (".(pop) set_line_readonly"); %{{{ Public Variables $1 = "~/.signature"; !if (is_defined ("Mail_Signature_File")) { variable Mail_Signature_File = expand_filename ($1); } !if (is_defined ("Mail_Header_Separator_String")) variable Mail_Header_Separator_String = "--- Do not modify this line. Enter your message below ---"; !if (is_defined ("Mail_Extra_Headers")) { variable Mail_Extra_Headers = NULL; } % The sendmail program $1 = _stkdepth (); NULL; "/usr/bin/sendmail"; % places to look "/usr/lib/sendmail"; "/usr/sbin/sendmail"; !if (is_defined ("SendMail_Cmd")) { variable SendMail_Cmd; while (SendMail_Cmd = (), SendMail_Cmd != NULL) { if (1 == file_status (SendMail_Cmd)) { SendMail_Cmd = strcat (SendMail_Cmd, " -t -oem -oi -odb"); break; } } } _pop_n (_stkdepth () - $1); !if (strlen (SendMail_Cmd)) error ("`sendmail' program not found!"); %!% always Reply-To: here instead. !if (is_defined ("Mail_Reply_To")) { variable Mail_Reply_To = Null_String; } %}}} %{{{ Private Variables private variable Mail_Previous_Buffer = Null_String; private variable Mail_Previous_Windows = 1; private variable Mail_This_Buffer = Null_String; private variable Mail_Filename = dircat (getenv ("HOME"), ".__jed_mail__"); %}}} %{{{ Private Functions define mail_sw2_prev_buf () { if (bufferp (Mail_Previous_Buffer)) sw2buf (Mail_Previous_Buffer); if (1 == Mail_Previous_Windows) onewindow (); if (bufferp (Mail_This_Buffer) and strcmp (Mail_This_Buffer, Mail_Previous_Buffer)) pop2buf (Mail_This_Buffer); } %}}} define mail_send () %{{{ { variable dir, file, sent, buf = "*mail*"; variable sep_mark, fcc_mark, fcc_file; if (buf != whatbuf ()) error ("not *mail* buffer"); flush ("Sending..."); push_spot (); bob (); !if (bol_fsearch (Mail_Header_Separator_String)) { !if (bol_fsearch ("\n")) { pop_spot (); verror ("Cannot find %s\n", Mail_Header_Separator_String); } } set_line_readonly (0); del_eol (); sep_mark = create_user_mark (); bob (); fcc_mark = NULL; if (bol_fsearch ("Fcc: ")) { push_mark_eol (); go_right_1 (); fcc_file = strtrim (substr (bufsubstr_delete (), 6, -1)); fcc_mark = create_user_mark (); } mark_buffer (); sent = not (pipe_region (SendMail_Cmd)); if (fcc_mark != NULL) { if (sent and strlen (fcc_file)) { variable user = getenv ("USER"); if (user == NULL) { user = getenv ("LOGNAME"); if (user == NULL) user = "user"; } () = append_string_to_file (sprintf ("From %s %s\n", user, time ()), fcc_file); % Make sure the buffer ends with two newline characters eob (); push_mark (); bskip_chars (" \t\n"); del_region (); newline (); newline (); mark_buffer (); () = append_region_to_file (fcc_file); } goto_user_mark (fcc_mark); vinsert ("Fcc: %s\n", fcc_file); % If the marks are on top of one another, make sure sep_mark gets % updated. I added the binary operations on User Marks just for % this purpose. if (fcc_mark == sep_mark) move_user_mark (sep_mark); } goto_user_mark (sep_mark); insert (Mail_Header_Separator_String); pop_spot (); if (sent) { set_buffer_modified_flag (0); flush ("Sending...done"); (file, dir,,) = getbuf_info (); () = delete_file (make_autosave_filename (dir, file)); file = dircat (dir, file); !if (strcmp (Mail_Filename, file)) () = delete_file (Mail_Filename); mail_sw2_prev_buf (); bury_buffer (buf); return; } flush ("Error sending message"); beep (); } add_completion ("mail_send"); %}}} define mail_format_buffer () %{{{ { variable erase, opt_headers=NULL; if (_NARGS == 2) opt_headers = (); erase = (); variable km = "mail_map"; text_mode (); setbuf_info (getbuf_info () & ~(0x40)); % turn off buried buffer flag !if (keymap_p(km)) make_keymap(km); use_keymap(km); if (erase == -1) { if (buffer_modified ()) { !if (get_yes_no("Mail already being composed. Erase it")) erase = 0; } } if (erase) { erase_buffer (); insert ("To: \nCc: \nBcc: \nSubject: \n"); if (strlen (Mail_Reply_To)) vinsert ("Reply-To: %s\n", Mail_Reply_To); if (opt_headers != NULL) { insert (opt_headers); } if (Mail_Extra_Headers != NULL) { insert (Mail_Extra_Headers); newline (); } insert (Mail_Header_Separator_String); newline (); go_up_1 (); set_line_readonly (1); bob (); eol (); set_buffer_modified_flag(0); } push_spot (); run_mode_hooks("mail_hook"); pop_spot (); set_buffer_undo(1); } %}}} define mail_kill_buffer () %{{{ { call ("kill_buffer"); mail_sw2_prev_buf (); } %}}} define mail () %{{{ { variable status, dir, file, buf = "*mail*"; variable do_format = -1; status = bufferp (buf); Mail_Previous_Windows = nwindows (); Mail_This_Buffer = whatbuf (); if (BATCH) { % Mail_Previous_Buffer = whatbuf (); sw2buf (buf); } else { Mail_Previous_Buffer = pop2buf_whatbuf (buf); } % if buffer is not old, turn autosave on if (status) { (,,,status) = getbuf_info (); if (buffer_modified ()) return; } else { (dir, file) = parse_filename (Mail_Filename); setbuf_info (file, dir, buf, 2); % autosave file = make_autosave_filename(dir, file); if (1 == file_status (file)) { if (get_yes_no ("An autosave file exists. Use it")) { erase_buffer (); () = insert_file (file); do_format = 0; } } } () = set_buffer_umask (0077); mail_format_buffer (do_format); } %}}} define mail_insert_signature () %{{{ { !if (strlen (Mail_Signature_File)) return; push_spot (); eob (); insert ("\n-- \n"); () = insert_file (Mail_Signature_File); pop_spot (); } %}}} jed-0.99-19/lib/cmisc.sl0000644002657400265740000001162411311317447013702 0ustar davisdavis% % Miscellaneous functions for C mode: % % c_make_comment () % c_format_paragraph () % c_comment_region () % c_top_of_function () % c_end_of_function () % c_mark_function () % produce a comment for C--- define c_make_comment () { variable d, cbeg, cend, file, mode; cbeg = "/*"; cend = "*/"; (, mode) = what_mode (); !if (mode & 2) return; (file,,,) = getbuf_info(); if (mode & 8) { cbeg = "%"; cend = ""; } %% search for a comment on the line eol(); if (bfind(cbeg)) { !if (bolp()) { go_left_1 (); trim(); () = ffind(cbeg); } d = C_Comment_Column - what_column; if (d > 0) whitespace(d); !if (ffind(cend)) { eol(); insert_spaces (2); insert (cend); } bfind(cbeg); pop(); go_right(strlen(cbeg) + 1); } else %/* not found */ { if (what_column() <= C_Comment_Column) { goto_column(C_Comment_Column); } else insert(" "); insert(cbeg); insert(" "); if (strlen(cend)) { insert (cend); go_left(3); } } } % This routine formats a comment in C mode. It is assumed that the standard % Jed comment format is used. private variable Cmode_Fill_Chars = ""; define c_paragraph_sep () { if (strlen (Cmode_Fill_Chars)) return 0; push_spot (); bol_skip_white (); if (looking_at ("*")) skip_chars ("*"); else if (looking_at ("//")) { go_right (2); } skip_white (); if (looking_at ("@ ")) eol (); eolp () or (-2 != parse_to_point ()); pop_spot (); } define c_format_paragraph (); define c_format_paragraph () { variable n, dwrap; % !if (is_c_mode ()) return; Cmode_Fill_Chars = ""; if (c_paragraph_sep ()) return; push_spot (); push_spot (); push_spot (); while (not(c_paragraph_sep ())) { !if (up_1 ()) break; } if (c_paragraph_sep ()) go_down_1 (); push_mark (); pop_spot (); while (not(c_paragraph_sep ())) { !if (down_1 ()) break; } if (c_paragraph_sep ()) go_up_1 (); narrow (); pop_spot (); bol (); push_mark (); skip_white (); if (looking_at ("* ")) go_right (2); else if (looking_at ("// ")) go_right (3); Cmode_Fill_Chars = bufsubstr (); dwrap = what_column (); bob (); do { bol_trim (); if (looking_at ("* ")) deln (2); else if (looking_at ("// ")) deln (3); } while (down_1 ()); WRAP -= dwrap; unset_buffer_hook ("format_paragraph_hook"); call ("format_paragraph"); set_buffer_hook ("format_paragraph_hook", &c_format_paragraph); WRAP += dwrap; bob (); do { insert (Cmode_Fill_Chars); } while (down_1 ()); bol (); go_right (strlen (Cmode_Fill_Chars)); skip_white (); if (looking_at ("*/")) { push_mark (); bol_skip_white (); del_region (); } Cmode_Fill_Chars = ""; widen (); pop_spot (); } define c_comment_region () { #iffalse return comment_region (); #else variable cbeg = "/* ", cmid = " * ", cend = " */"; variable c, c1, celm, extra; check_region (1); exchange_point_and_mark (); c = what_column (); narrow (); bob (); USER_BLOCK0 { extra = (); celm = (); bol_skip_white (); c1 = what_column (); if (c1 > c) { goto_column (c); insert (celm); trim (); whitespace (c1 - what_column () + extra); } else { if (eolp ()) goto_column (c); insert (celm); } } X_USER_BLOCK0 (cbeg, 0); while (down_1 ()) { X_USER_BLOCK0 (cmid, 1); } widen (); bol_skip_white (); if (looking_at(cmid)) { deln (3); } else { eol (); !if (right(1)) newline (); } X_USER_BLOCK0 (cend, 0); pop_spot (); #endif } define c_top_of_function () { !if (bol_bsearch_char ('{')) { error ("Top of function not found."); } } define c_end_of_function () { eol (); !if (bol_fsearch_char ('}')) error ("End of function not found"); % was: % !if (bolp () and looking_at_char ('{')) % c_top_of_function (); % call ("goto_match"); } define c_mark_function () { c_end_of_function (); push_visible_mark (); eol (); go_down_1 (); exchange_point_and_mark (); c_top_of_function (); go_up(2); bol (); } %% This function creates a C++ style comment in the same manner as %% c_make_comment. %% Written by MDJ %% I've bound this to "\e:" (c_make_comment is bound to "^e;") define c_plus_plus_make_comment() { variable d, cbeg, mode; cbeg = "//"; %% search for a comment on the line eol(); if (bfind(cbeg)) { !if (bolp()) { go_left_1 (); trim(); () = ffind(cbeg); } d = C_Comment_Column - what_column; if (d > 0) whitespace(d); bfind(cbeg); pop(); go_right(strlen(cbeg) + 1); } else %/* not found */ { if (what_column() <= C_Comment_Column) { goto_column(C_Comment_Column); } else insert("\t"); insert(cbeg); insert(" "); } } jed-0.99-19/lib/brief.sl0000644002657400265740000001413211311317447013670 0ustar davisdavis% Brief editor emulation % I do not think that this will work very well at all on non-IBMPC systems % because of the heavy dependence on keys that are meaningless. _Jed_Emulation = "brief"; % Since alt keys are used, make sure that they are enabled. ALT_CHAR = 0; set_status_line("(Jed %v) Brief: %b (%m%a%n%o) %p %t", 1); Help_File = Null_String; define brief_home () { if (bolp ()) { if (window_line () == 1) bob (); else goto_top_of_window (); } bol (); } define brief_end () { if (eolp ()) { if (window_line () == window_info ('r')) eob (); else goto_bottom_of_window (); } eol (); } define brief_line_to_eow () { recenter (window_info ('r')); } define brief_line_to_bow () { recenter (1); } define brief_line_to_mow () { recenter (window_info ('r') / 2); } define brief_set_bkmrk_cmd (n) { ungetkey (n + '0'); bkmrk_set_mark (); } define brief_delete_to_bol () { push_mark (); bol(); del_region (); } define brief_toggle_case_search () { CASE_SEARCH = not (CASE_SEARCH); } variable Brief_Regexp_Search = 0; define brief_toggle_regexp () { Brief_Regexp_Search = not (Brief_Regexp_Search); } variable Brief_Search_Forward = 1; define brief_search_cmd () { if (Brief_Search_Forward) { if (Brief_Regexp_Search) re_search_forward (); else search_forward (); } else { if (Brief_Regexp_Search) re_search_backward (); else search_backward (); } } define brief_reverse_search () { Brief_Search_Forward = not (Brief_Search_Forward); brief_search_cmd (); } define brief_line_mark () { bol (); set_mark_cmd (); eol (); } variable Brief_Use_Rectangle = 0; define brief_yank () { if (Brief_Use_Rectangle) { insert_rect (); } else call ("yank"); } define brief_copy_region () { if (Brief_Use_Rectangle) { copy_rect (); } else call ("copy_region"); } define brief_kill_region () { if (Brief_Use_Rectangle) { kill_rect (); } else call ("kill_region"); } define brief_delete () { if (markp ()) { if (Brief_Use_Rectangle) { kill_rect (); } else { del_region (); } return; } del (); } define brief_set_mark_cmd () { Brief_Use_Rectangle = 0; smart_set_mark_cmd (); } define brief_set_column_mark () { Brief_Use_Rectangle = 1; set_mark_cmd (); message ("Column mark set."); } unsetkey ("^K"); unsetkey ("^X"); unsetkey ("^W"); unsetkey ("^F"); %setkey ("bdelete_word", "^@"); % Ctrl Bksp setkey ("brief_home", "\xE0G"); % Home setkey ("brief_home", "Ow"); % Home setkey ("brief_end", "\xE0O"); % End setkey ("brief_end", "Oq"); % End setkey ("brief_line_to_bow", "^T"); setkey ("brief_line_to_mow", "^C"); setkey ("brief_line_to_eow", "^B"); setkey ("brief_delete","\xE0S"); % Delete setkey ("brief_delete","\xOn"); % Delete setkey ("undo", "\eOR"); % Keypad Star setkey ("bskip_word", "\xE0s"); % Ctrl Left setkey ("bskip_word", "^@s"); % Ctrl Left setkey ("skip_word", "\xE0t"); % Ctrl Right setkey ("skip_word", "^@t"); % Ctrl Right setkey ("bob", "\xE0\d132"); % Ctrl Pgup setkey ("bob", "^@\d132"); % Ctrl Pgup setkey ("eob", "\xE0v"); % Ctrl Pgdn setkey ("eob", "^@v"); % Ctrl Pgdn setkey ("goto_top_of_window", "\xE0w");% Ctrl Home setkey ("goto_top_of_window", "^@w");% Ctrl Home setkey ("goto_bottom_of_window", "\xE0u");% Ctrl End setkey ("goto_bottom_of_window", "^@u");% Ctrl End setkey ("brief_yank", "\xE0R"); % Insert setkey ("brief_yank", "Op"); % Insert setkey ("brief_copy_region", "\eOm"); % Keypad Plus setkey ("brief_kill_region", "\eOS"); % Keypad Minus setkey ("find_file", "^@"); % Alt E setkey ("help_prefix", "^@#"); % Alt H setkey ("write_buffer", "^@"); % Alt O setkey ("save_buffer", "^@"); % Alt W setkey ("exit_jed", "^@-"); % Alt X setkey ("replace_cmd", "^@@"); % Key F6 setkey ("brief_search_cmd", "^@?"); % Key F5 setkey ("brief_reverse_search", "^@l"); % Alt F5 setkey ("brief_search_cmd", "^@X"); % Shift F5 setkey ("brief_toggle_case_search", "^@b");% Ctrl F5 setkey ("brief_toggle_regexp", "^@c"); % Ctrl F6 setkey ("page_down", "^D"); setkey ("page_up", "^E"); setkey ("brief_delete_to_bol", "^K"); setkey ("isearch_forward", "^S"); setkey ("brief_set_mark_cmd", "^@"); % Alt A setkey ("list_buffers", "^@0"); % Alt B setkey ("brief_set_column_mark", "^@.");% Alt C setkey ("delete_line", "^@ "); % Alt D setkey ("goto_line_cmd", "^@\""); % Alt G setkey ("toggle_overwrite", "^@"); % Alt I setkey ("bkmrk_goto_mark", "^@$"); % Alt J setkey ("kill_line", "^@%"); % Alt K setkey ("set_mark_cmd", "^@2"); % Alt M setkey ("switch_to_buffer", "^@1"); % Alt N setkey ("insert_file", "^@"); % Alt R setkey ("brief_search_cmd", "^@"); % Alt S setkey ("replace_cmd", "^@"); % Alt T setkey ("undo", "^@"); % Alt U setkey ("brief_line_mark", "^@&"); % Alt L setkey (".0 brief_set_bkmrk_cmd", "^@\d129");% Alt 0 setkey (".1 brief_set_bkmrk_cmd", "^@x");% Alt 1 setkey (".2 brief_set_bkmrk_cmd", "^@y");% Alt 2 setkey (".3 brief_set_bkmrk_cmd", "^@z");% Alt 3 setkey (".4 brief_set_bkmrk_cmd", "^@{");% Alt 4 setkey (".5 brief_set_bkmrk_cmd", "^@|");% Alt 5 setkey (".6 brief_set_bkmrk_cmd", "^@}");% Alt 6 setkey (".7 brief_set_bkmrk_cmd", "^@~");% Alt 7 setkey (".8 brief_set_bkmrk_cmd", "^@");% Alt 8 setkey (".9 brief_set_bkmrk_cmd", "^@\d128");% Alt 9 setkey ("delete_word", "^@"); % Alt Bksp setkey ("goto_match", "^Q["); setkey ("goto_match", "^Q\e"); setkey ("goto_match", "^Q]"); setkey ("goto_match", "^Q^]"); % Not sure about this!!! unsetkey ("\e\e"); setkey ("end_macro", "\e\e"); % These two cannot be bound. %setkey ("scroll_left", ""); % Shift End %setkey ("scroll_right", ""); % Shift Home runhooks ("keybindings_hook", _Jed_Emulation); jed-0.99-19/lib/dabbrev.sl0000644002657400265740000003352611311317447014216 0ustar davisdavis% Complete the current word looking for similar word-beginnings % % Versions % 1 May 1994 Adrian Savage (afs@jumper.mcc.ac.uk) % Extensively modified by JED % 2.0 2003-05-01 rewrite by G.Milde % added support for scanning in a list of buffers % 2.1 added customizability % 2.2 look at last finding first % (as emacs does, tip P. Boekholt) % 2.2.1 bugfix: invalid mark when buffer of last % expansion killed (P. Boekholt) % 2.3 2003-12-01 prevent flooding the undo-buffer (using getkey for % subsequent invocations) % 2.3.1 2003-12-05 replaced unget_keystring with buffer_keystring % 2.4 2004-03-15 dabbrev() takes a prefix argument for the % buflist-scope (this is checked in dab_reset()) % clearer documentation (open_buffers -> all buffers) % (hints by J. E. Davis) % 2.4.1 2004-03-30 new custom var Dabbrev_Case_Search % added documentation for custom vars and get_buflist % 3.0 2004-04-03 Changed much of the code to permit to allow for greater % extensibility. % 3.0.1 2004-06-07 Minor bug fixes (P. Boekholt) % % % USAGE: % Put in path und bind to a key, e.g. % setkey("dabbrev", "^A"); % expand from Dabbrev_Default_Buflist % setkey("dabbrev(get_buflist(1))", "\ea"); % expand from visible buffers % % You can use any function that returns a list of buffers as argument, % make sure it is declared, e.g. with autoload("get_buflist", "dabbrev"); % % You could even define your own metafunction that does something usefull % (e.g. open a buffer) and then calls dabbrev("buf1\nbuf2\n ...") to expand % from listed buffers. % % CUSTOMIZATION % % Some custom variables can be used to tune the behaviour of dabbrev: % (The defaults are set to make dabbrev work as version 1) % % "Dabbrev_delete_tail", 0 % replace the existing completion % "Dabbrev_Default_Buflist", 0 % default to whatbuf() % "Dabbrev_Look_in_Folds", 1 % open folds when scanning for completions % --------------------------------------------------------------------------- % debug info, uncomment to trace down bugs % _traceback = 1; % _debug_info = 1; % --- Variables % %!%+ %\variable{Dabbrev_delete_tail} %\synopsis{Let completion replace word tail?} %\usage{Int_Type Dabbrev_delete_tail = 0} %\description % Should the completion replace the part of the word behind the cursor? %\seealso{dabbrev} %!%- custom_variable("Dabbrev_delete_tail", 0); %!%+ %\variable{Dabbrev_Default_Buflist} %\synopsis{Which buffers should dabbrev expand from?} %\usage{Int_Type Dabbrev_Default_Buflist = 0} %\description % The buffer-list when dabbrev is called without argument % 0 = current buffer, % 1 = visible buffers (including the current), % 2 = all buffers of same mode, % 3 = all buffers, % 4 = other visible buffers (excluding the current), % 5 = all other buffers of same mode (excluding the current), % 6 = all other buffers (excluding the current) %\seealso{dabbrev} %!%- custom_variable("Dabbrev_Default_Buflist", 0); %!%+ %\variable{Dabbrev_Look_in_Folds} %\synopsis{Scan folds for expansions} %\usage{Int_Type Dabbrev_Look_in_Folds = 1} %\description % Should dabbrev scan folded parts of the source buffer(s) % for expansions too? %\seealso{dabbrev} %!%- custom_variable("Dabbrev_Look_in_Folds", 1); %!%+ %\variable{Dabbrev_Case_Search} %\synopsis{Let dabbrev stick to case} %\usage{Int_Type Dabbrev_Case_Search = 1} %\description % Should dabbrev consider the case of words when looking for expansions? % Will be overridden by a blocal variable "Dabbrev_Case_Search" or by the % mode-info variable "dabbrev_case_search". %\seealso{dabbrev} %!%- custom_variable("Dabbrev_Case_Search", 0); % --- Functions private define get_buffer_mode_name (buf) { setbuf (buf); return get_mode_name (); } private define get_buflist(scope) { variable cbuf = whatbuf (); !if(scope) return cbuf; variable buffers = [buffer_list (), pop ()]; if (scope > 3) { buffers = buffers [where (buffers != cbuf)]; scope -= 3; } variable i; % prune hidden buffers, unless editing one if (cbuf[0] != ' ') { i = where (array_map (Int_Type, &strncmp, buffers, " ", 1)); buffers = buffers[i]; } switch (scope) { case 1: i = array_map (Int_Type, &buffer_visible, buffers); } { case 2: variable mode = get_mode_name (); i = (mode == array_map (String_Type, &get_buffer_mode_name, buffers)); setbuf (cbuf); } { case 3: i = [1:length(buffers)]; } buffers = buffers[where (i)]; return strjoin (buffers, "\n"); } % get the word tail private define dab_get_word_tail(word_chars, kill) { push_mark; skip_chars(word_chars); exchange_point_and_mark(); if (kill) return bufsubstr_delete(); else return bufsubstr(); } private variable Dab_Context_Type = struct { scan_mark, completion_list, patterns, pattern_index, buffer_list, buffer_list_index, match_methods, match_methods_index, word_chars, search_dir, start_mark, completion, prefix_mark, start_buffer, % buffer being edited and where completion is to take place }; % Switch to buf, mark position, widen if narrowed % TODO: How about hidden lines? private define enter_buffer (c, buf) { c.start_mark = create_user_mark (); setbuf (buf); push_spot(); if (count_narrows() and Dabbrev_Look_in_Folds) { push_narrow (); widen_buffer (); } if (c.scan_mark != NULL) goto_user_mark (c.scan_mark); else if (buf != c.start_buffer) % start search at EOB, otherwise a completion at the current point in this buffer may % be missed. eob (); } private define leave_buffer (c) { pop_narrow (); pop_spot (); setbuf (user_mark_buffer (c.start_mark)); goto_user_mark (c.start_mark); } private define dab_exact_match (prefix, word) { if (strncmp (prefix, word, strlen (prefix))) return NULL; return word; } private define dab_uppercase_match (prefix, word) { return strup (word); } private define dab_lowercase_match (prefix, word) { return strlow (word); } private define create_completion_context () % (buflist = whatbuf()) { % List of buffers to scan for completions variable c = @Dab_Context_Type; variable buffer_list; c.start_buffer = whatbuf(); if (_NARGS) { if (_NARGS > 1) error ("Incorrect usage of dabbrev-- one argument expected"); buffer_list = (); if (typeof (buffer_list) != String_Type) buffer_list = get_buflist (buffer_list); } else { variable buflist_scope = prefix_argument(-1); if (buflist_scope == -1) buflist_scope = Dabbrev_Default_Buflist; % buflist_scope = get_blocal("Dabbrev_Default_Buflist", % Dabbrev_Default_Buflist; buffer_list = get_buflist(buflist_scope); } if (strlen (buffer_list) == 0) c.buffer_list = String_Type[0]; else c.buffer_list = strchop (buffer_list, '\n', 0); c.buffer_list_index = 0; % get word_chars from: 1. mode_info, 2. blocal_var, 3. get_word_chars variable word_chars = mode_get_mode_info("dabbrev_word_chars"); if (word_chars == NULL) { if (blocal_var_exists("Word_Chars")) word_chars = get_blocal_var("Word_Chars"); else word_chars = "_" + get_word_chars(); } c.word_chars = word_chars; % Get patterns to expand from (keep cursor position) push_mark (); bskip_chars ("^" + word_chars); variable tmp = create_user_mark (); bskip_chars (word_chars); c.prefix_mark = create_user_mark (); exchange_point_and_mark(); variable pattern = bufsubstr (); if (tmp == c.prefix_mark) error("nothing to expand"); c.patterns = [pattern]; c.pattern_index = 0; c.completion_list = Assoc_Type[Int_Type]; c.completion_list[""] = 1; c.match_methods = [&dab_exact_match]; variable cs = NULL; if (blocal_var_exists("Dabbrev_Case_Search")) cs = get_blocal_var("Dabbrev_Case_Search"); else cs = mode_get_mode_info ("dabbrev_case_search"); if (cs == NULL) cs = Dabbrev_Case_Search; if (cs == 0) { if (strlow (pattern) == pattern) c.match_methods = [c.match_methods, &dab_lowercase_match]; if (strup (pattern) == pattern) c.match_methods = [c.match_methods, &dab_uppercase_match]; } c.match_methods_index = 0; c.search_dir = 0; return c; } private define dab_search (c, search_dir, match_method, pattern) { variable cs = CASE_SEARCH; EXIT_BLOCK { CASE_SEARCH = cs; } CASE_SEARCH = 0; variable found, word_chars = c.word_chars, prefix_mark = c.prefix_mark; forever { do { if (search_dir == 1) { go_right(1); found = fsearch (pattern); } else found = bsearch (pattern); !if (found) return NULL; % test whether at begin of a word push_spot(); bskip_chars(word_chars); variable m = create_user_mark (); pop_spot(); } while ((m != create_user_mark ()) or (m == prefix_mark)); variable len = strlen (pattern); push_spot (); push_mark (); go_right (len); %skip_chars ("^" + word_chars); skip_chars (word_chars); variable word = bufsubstr (); pop_spot (); word = (@match_method) (pattern, word); if (word != NULL) return substr (word, len+1, -1); } } private define is_completion_ok (c, completion) { if (assoc_key_exists (c.completion_list, completion)) return 0; c.completion_list[completion] = 1; return 1; } private define dab_process_buffer (c, buf, pattern) { enter_buffer (c, buf); % spot pushed EXIT_BLOCK { leave_buffer (c); } variable dir = c.search_dir; while (dir < 2) { variable match_methods_index = c.match_methods_index; variable match_methods_index_max = length (c.match_methods); while (match_methods_index < match_methods_index_max) { variable match_method = c.match_methods[match_methods_index]; variable completion = dab_search (c, dir, match_method, pattern); if (completion == NULL) { goto_spot (); % go back and start the search over match_methods_index++; continue; } if (is_completion_ok (c, completion)) { c.match_methods_index = match_methods_index; c.scan_mark = create_user_mark (); c.search_dir = dir; return completion; } } c.match_methods_index = 0; dir++; } c.search_dir = 0; c.scan_mark = NULL; return NULL; } private define dab_expand (c) { variable completion; while (c.pattern_index < length (c.patterns)) { variable pattern = c.patterns[c.pattern_index]; variable buffer_list_index = c.buffer_list_index; variable buffer_list_index_max = length (c.buffer_list); while (buffer_list_index < buffer_list_index_max) { completion = dab_process_buffer (c, c.buffer_list[buffer_list_index], pattern); if (completion != NULL) { c.buffer_list_index = buffer_list_index; return completion; } buffer_list_index++; } c.buffer_list_index = 0; c.pattern_index++; } c.pattern_index = 0; vmessage("No more completions for \"%s\" in [%s]", strjoin(c.patterns, ","), strjoin(c.buffer_list, ",")); return NULL; } % ----- main function -------------------------------------------------- %!%+ %\function{dabbrev} %\synopsis{Complete the current word looking for similar words} %\usage{dabbrev([optional_argument])} %\description % Takes the current stem (part of word before the cursor) % and scans the current buffer for words that begin with this stem. % The current word is expanded by the non-stem part of the finding. % Subsequent calls to dabbrev replace the last completion with the next % guess. % % The search for completions takes place over a list of buffers specified % by the \var{Dabbrev_Default_Buflist} variable unless \var{dabbrev} has % been called with an argument. The optional argument may either be an % integer whose value is interpreted as for \var{Dabbrev_Default_Buflist}, % or a string containing a newline separated list of buffer names to search. % % The scan proceeds as follows: %#v+ % foreach buffer in buflist % from cursor backwards to the beginning of the buffer % from cursor forwards to the end of the buffer %#v- %\example % The current buffer contains the line %#v+ % foo is better than foobar, foobase or foo %#v- % with the cursor at the end of the line. % dabbrev completes foo with foobase. % If called again (immediately) foobase is changed to foobar % If called once again, foobase is changed to foo and a message is % given: No more completions. % %\notes % You can use the optional argument to have keybindings to different % "flavours" of dabbrev. %#v+ % setkey("dabbrev", "^A"); % expand from Dabbrev_Default_Buflist % setkey("dabbrev(1)", "\ea"); % expand from visible buffers % setkey("dabbrev(\"wordlist\")","\e^A"); % expand from the buffer "wordlist" %#v- % %\seealso{Dabbrev_Default_Buflist, Dabbrev_Look_in_Folds} %!%- private variable Completion_Context = NULL; private variable Completion = NULL; private define before_key_hook (); private define before_key_hook (fun) { if (typeof (fun) == Ref_Type) fun = "&"; if ((0 == is_substr (fun, "dabbrev")) or (Completion == NULL)) { remove_from_hook ("_jed_before_key_hooks", &before_key_hook); Completion_Context = NULL; return; } push_mark(); go_left(strlen (Completion)); del_region(); } public define dabbrev() %(buflist=whatbuf()) { variable type, fun, key, args = __pop_args(_NARGS); add_to_hook ("_jed_before_key_hooks", &before_key_hook); if (Completion_Context == NULL) Completion_Context = create_completion_context (__push_args (args)); Completion = dab_expand (Completion_Context); if (Completion != NULL) insert (Completion); } jed-0.99-19/lib/tiasm.sl0000644002657400265740000000224311311317447013716 0ustar davisdavis% A simple TI asm mode $1 = "tiasm"; create_syntax_table ($1); define_syntax (";", "", '%', $1); % Comment Syntax %define_syntax ('\\', '\\', $1); % Quote character define_syntax ("{[", "}]", '(', $1); % are all these needed? define_syntax ('\'', '"', $1); % string define_syntax ("$~^_&#", '+', $1); % operators define_syntax ("|&{}[],", ',', $1); % delimiters define_syntax ("a-zA-Z0-9.", 'w', $1); set_syntax_flags ($1, 1 | 2); set_fortran_comment_chars ($1, "*"); % Type 0 keywords () = define_keywords_n ($1, "andashbuddbdldaldilshmh1noppopsti", 3, 0); () = define_keywords_n ($1, "addibeqdbledcmpildizlhu0lhu1pushretsrptbsubi", 4, 0); () = define_keywords_n ($1, "ldinzrptbd", 5, 0); % Type 1 keywords () = define_keywords_n ($1, ".if", 3, 1); () = define_keywords_n ($1, ".end", 4, 1); () = define_keywords_n ($1, ".else.text", 5, 1); () = define_keywords_n ($1, ".endif.globl", 6, 1); define tiasm_mode () { variable kmap = "tiasm"; set_mode(kmap, 4); use_syntax_table (kmap); mode_set_mode_info (kmap, "fold_info", "*{{{\r*}}}\r\r"); run_mode_hooks("tiasm_mode_hook"); } jed-0.99-19/lib/html.sl0000644002657400265740000003325211311317447013551 0ustar davisdavis% % file : html.sl % % Original Author : Raikanta Sahu, rsahu@mail.unm.edu % Substantial additions by Jim Knoble. % Modified by John E. Davis for incorporation into JED. %% %% Modified by Michael D Johnson to conform with the standards recommendation %% on capitalization. %% % Modified by Kees Serier % All lower case except for DOCTYPE (like all W3C code), html: 2 3.2 4 XHTML % Definition lists complete, tables, euro symbol and more. % 1 => html_mode wraps, like text_mode % 0 => html_mode doesn't wrap, like no_mode define html_paragraph_separator () { bol_skip_white (); eolp () or ffind_char ('>') or ffind_char ('<'); } % Movement function (JM) %!%+ %\function{html_skip_tag} %\synopsis{html_skip_tag} %\description % skip forward past html tag %!%- define html_skip_tag() { !if (fsearch_char ('>')) return; go_right_1 (); } %!%+ %\function{html_bskip_tag} %\synopsis{html_bskip_tag} %\description % skip backward past html tag %!%- define html_bskip_tag() { () = bsearch_char ('<'); } %!%+ %\function{html_mark_next_tag} %\synopsis{html_mark_next_tag} %\description % mark the next html tag forward %!%- define html_mark_next_tag() { variable taglng = 1; !if (fsearch_char ('>')) return; go_right(taglng); set_mark_cmd (); go_left(taglng); () = find_matching_delimiter (0); } %!%+ %\function{html_mark_prev_tag} %\synopsis{html_mark_prev_tag} %\description % mark the previous html tag %!%- define html_mark_prev_tag() { !if (bsearch_char ('<')) return; set_mark_cmd (); () = find_matching_delimiter(0); go_right_1 (); exchange_point_and_mark(); } % % First define some useful functions % define html_insert_pair_around_region (lfttag, rgttag) { % make sure mark is before point; % 1 => push spot first check_region(1); % put tags on appropriate sides of region, % then return to where we were exchange_point_and_mark(); insert(lfttag); exchange_point_and_mark(); insert(rgttag); pop_spot(); pop_mark_0 (); } define html_insert_move (str) { variable len; variable beg, end; len = is_substr (str, "@"); !if (len) return; len--; if (markp ()) { beg = substr (str, 1, len); end = substr (str, len + 2, strlen (str)); html_insert_pair_around_region (beg, end); return; } push_spot (); insert (str); pop_spot (); go_right (len); del (); } define html_simple_insert (str) { html_insert_move (sprintf ("<%s>@", str, str)); } define html_insert_with_newline (str) { html_insert_move (sprintf ("<%s>\n@\n", str, str)); } define html_insert_with_2newlines (str) { html_insert_move (sprintf ("<%s>\n@\n\n", str, str)); } define html_form () { html_insert_move ("
\n@\n
"); } define html_input () { insert (""); } define html_input_text () { insert (""); } define html_input_password () { insert (""); } define html_input_checkbox () { insert (""); } define html_input_radio () { insert (""); } define html_input_submit () { insert (""); } define html_input_reset () { insert (""); } define html_input_hidden () { insert (""); } define html_select () { html_insert_move (""); } define html_text_area () { html_insert_move (""); } % % Make comment % define html_comment () { html_insert_move (""); } % % insert Horizontal rule TJO % define html_horiz_rule () { insert("\n
\n") ; } define html_heading (c) { html_insert_move (sprintf ("@", c, c)); } define html_insert_eol (str) { eol (); vinsert ("<%s>", str); } define html_insert_bol (str) { bol (); vinsert ("<%s>", str); } % insert at cursor define html_insert_here (str) { vinsert ("<%s>", str); } % % Make markers for an image % define html_image () { html_insert_move ("\"\""); } % % main entry point into the html mode % commands available to keystrokes in html mode % define html_quoted_insert () { variable ch; !if (input_pending (5)) flush ("`-"); ch = getkey (); switch (ch) { case '\r': insert ("
\n"); } { case '&': insert ("&"); } { case '>': insert (">"); } { case '<': insert ("<"); } { case ' ': insert (" "); } { case 'e': insert ("€"); } { % default: The other special characters should be added. insert_char (ch); } } % Support for HTML paragraphs. MDJ 04/06/98 define html_par_insert() { insert("\n\n

\n"); } define html_read_key (hlp) { variable key; !if (input_pending (3)) flush (hlp); tolower (getkey ()); } define html_doctype () { variable key2; key2 = html_read_key ("HTML version: 2 3.2 4 Xhtml"); switch (key2) {case '2': insert ("\n");} {case '3': insert ("\n");} {case '4': insert ("\n");} {case 'x' or case 'X': insert ("\n");} { beep (); } } define html_template () { html_doctype (); html_insert_move ("\n\n\n@\n\n\n\n\n\n") ; } define html_keymap_a () { variable name = ""; variable href = ""; switch (html_read_key ("Href Name")) { case 'h': href; } { case 'n': name; } { beep (); return; } html_insert_move (()); } define html_keymap_d () { variable key; key = html_read_key ("dL dT dD"); switch (key) { case 'l': html_insert_with_newline ("dl"); } { case 't': insert ("

"); } { case 'd': insert ("
"); } { beep (); } } define html_keymap_f () { switch (html_read_key ("txtArea Chkbox Form Hidden Input Option Passw Radio Select Text Xreset Ysubmit")) {case 'a': html_text_area (); } {case 'c': html_input_checkbox (); } {case 'f': html_form (); } {case 'h': html_input_hidden (); } {case 'i': html_input (); } {case 'o': html_insert_bol("option"); } {case 'p': html_input_password (); } {case 'r': html_input_radio (); } {case 's': html_select (); } {case 't': html_input_text (); } {case 'x': html_input_reset (); } {case 'y': html_input_submit (); } { % default beep (); } } define html_keymap_h () { variable key; key = html_read_key ("h1 h2 h3 h4 h5 h6 templAte Doctype Head Body htmL Title"); switch (key) % { case 'd': html_insert_bol ("doc"); } { case 'd': html_doctype (); } { case 'h': html_insert_with_newline ("head"); } { case 'b': html_insert_with_newline ("body"); } { case 'l': html_insert_with_newline ("html"); } { case 't': html_insert_with_newline ("title"); } { case 'a': html_template (); } { (key <= '6') and (key >= '1') : html_heading (key);} { beep (); } } define html_keymap_i () { html_image (); } define html_keymap_l () { switch (html_read_key ("Dir Li Menu Ordered Un-ordered")) { case 'd': html_insert_with_newline ("dir"); } { case 'l': html_insert_here ("li"); } { case 'm': html_insert_with_newline ("menu"); } { case 'o': html_insert_with_newline ("ol"); } { case 'u': html_insert_with_newline ("ul"); } { % default beep (); } } define html_keymap_p () { switch (html_read_key ("Break Hrule Par blockQuote pRe")) { case 'b': html_insert_eol ("br"); } { case 'h': html_horiz_rule (); } { case 'p': insert ("

\n"); } { case 'q': html_insert_with_newline ("blockquote"); } { case 'r': html_insert_with_newline ("pre"); } { beep (); } } define html_keymap_s () { switch (html_read_key ("Address Bold Cite Emph Font Ital Kbd cOde Samp Tt Uline Var")) { case 'a': "address"; } { case 'b': "b"; } { case 'c': "cite"; } { case 'e': "em"; } { case 'f': "font"; } { case 'i': "i"; } { case 'k': "kbd"; } { case 'o': "code"; } { case 's': "samp"; } { case 't': "tt"; } { case 'u': "u"; } { case 'v': "var"; } { beep (); return; } html_simple_insert (()); } define html_keymap_t () { switch (html_read_key ("Table Row Header Data")) { case 't': html_insert_with_newline ("table"); } { case 'r': html_insert_with_newline ("tr"); } { case 'h': html_simple_insert ("th"); } { case 'd': html_simple_insert ("td"); } { beep (); return; } } define html_keymap () { variable key = html_read_key ("Anchors Dfnlists Forms Headings Images Lists Pstyles cStyles Tables"); switch (key) { case 2: html_bskip_tag (); } % ^B { case 6: html_skip_tag (); } % ^F { case 14: html_mark_next_tag (); } % ^N { case 16: html_mark_prev_tag (); } % ^P { case 'c': html_comment (); } { case 'a': html_keymap_a (); } { case 'd': html_keymap_d (); } { case 'f': html_keymap_f (); } { case 'h': html_keymap_h (); } { case 'i': html_keymap_i (); } { case 'l': html_keymap_l (); } { case 'p': html_keymap_p (); } { case 's': html_keymap_s (); } { case 't': html_keymap_t (); } { ungetkey (key); html_quoted_insert (); } flush (""); } $1 = "html"; !if (keymap_p ($1)) make_keymap ($1); if (_Reserved_Key_Prefix != NULL) { undefinekey (_Reserved_Key_Prefix, $1); definekey("html_keymap", _Reserved_Key_Prefix, $1); } undefinekey ("\e;", $1); definekey ("html_comment", "\e;", $1); definekey ("html_quoted_insert", "`", $1); definekey("html_par_insert", "\e^M", $1); % Neater paragraph insert (MDJ 04/06/98) create_syntax_table ($1); define_syntax ("<", ">", '(', $1); % make these guys blink match define_syntax ("<>", '<', $1); %define_syntax ("", '%', $1); % Some broken html files require this define_syntax ("", '%', $1); define_syntax ("A-Za-z&", 'w', $1); define_syntax ('#', '#', $1); #ifdef HAS_DFA_SYNTAX % The highlighting copes with comments, "ð" type things, and type % HTML tags. An unrecognised &..; construct or an incomplete <...> construct % is flagged in delimiter colour. %%% DFA_CACHE_BEGIN %%% private define setup_dfa_callback (name) { dfa_enable_highlight_cache ("html.dfa", name); dfa_define_highlight_rule ("", "Qcomment", name); dfa_define_highlight_rule ("^([^\\-]|-+[^>])*-+[ \t]*>", "Qcomment", name); dfa_define_highlight_rule ("\"]|\"[^\"]*\")*>", "keyword", name); dfa_define_highlight_rule ("<([^>\"]|\"[^\"]*\")*(\"[^\"]*)?$", "delimiter", name); dfa_define_highlight_rule ("&#[0-9]+;", "keyword1", name); dfa_define_highlight_rule ("&[A-Za-z]+;", "Kdelimiter", name); dfa_define_highlight_rule (".", "normal", name); dfa_build_highlight_table (name); } dfa_set_init_callback (&setup_dfa_callback, "html"); %%% DFA_CACHE_END %%% #endif () = define_keywords ($1, "><", 3); () = define_keywords ($1, "Ð&ð", 4); () = define_keywords ($1, strcat ( "ÄËÏÖÜ", "äëï ö"üÿ" ), 5); () = define_keywords ($1, strcat ( "ÆÂÅÊÎÔÞÛâ", "æåêîôßþû" ), 6); () = define_keywords ($1, strcat ( "ÁÀÃÇÉÈÍÌ", "ÑÓÒØÕÚÙÝ", "áàãçéèíì", "ñóòøõúùý"), 7); %!%+ %\function{html_mode} %\synopsis{html_mode} %\usage{Void html_mode ();} %\description % \var{html_mode} is a mode designed for editing HTML files. % If a region is defined (i.e., if a mark is set), many HTML % tags will insert around the region, e.g. '' and ''. % % Keybindings begin with ^C and are grouped according to function: % ^CA... Anchors (...) % ^CD... Definition lists (

...
) % ^CF... Forms (
...
) % ^CH... Headings, document type, etc. % ^CI... Images % ^CL... Lists (
    ...
) % ^CP... Paragraph styles, etc. (

,
,


,
, etc.) % ^CS... Character styles (, , , , etc.) % ^CT... Tables % Additionally, some special movement commands and miscellaneous % characters are defined: % ^C^B skip to beginning of prior HTML tag % ^C^F skip to end of next HTML tag % ^C^N mark next HTML tag from '<' to '>' % ^C^P mark prior HTML tag from '<' to '>' % ^C& insert HTML text for '&' % ^C> insert HTML text for '>' % ^C< insert HMTL text for '<' % ^C insert HMTL text for '
' % ^C insert HMTL text for NonBreakableSPace % ^Ce insert HMTL text for 'Eurosymbol' % ^CC insert HTML comment (around region, if marked) % % For a complete list of keybindings, use \var{describe_bindings}. % % This function calls \var{html_mode_hook} if it exists. %!%- define html_mode () { variable html = "html"; no_mode (); % reset set_mode(html, 1); set_buffer_hook ("par_sep", "html_paragraph_separator"); use_syntax_table (html); use_keymap (html); run_mode_hooks ("html_mode_hook"); } jed-0.99-19/lib/spicemod.sl0000644002657400265740000000207211311317447014404 0ustar davisdavis% This is a simple spice mode. It does not defined any form of indentation % style. Rather, it simply implements a highlighting scheme. $1 = "SPICE"; create_syntax_table ($1); define_syntax ("*","",'%', $1); define_syntax ("#","",'%', $1); define_syntax ("([{", ")]}", '(', $1); define_syntax ('"', '"', $1); define_syntax ('\'', '\'', $1); define_syntax ('\\', '\\', $1); define_syntax ("0-9a-zA-Z._", 'w', $1); % words define_syntax ("-+0-9F.xupXLPU", '0', $1); % Numbers define_syntax (",;?:=<>", ',', $1); define_syntax ('X', '#', $1); define_syntax ("%-+/&*<>|!~^", '+', $1); set_syntax_flags ($1, 4); () = define_keywords ($1, "LWlw", 1); () = define_keywords ($1, "ADASCDPDPSacadascdpdps", 2); () = define_keywords ($1, "ENDSDCONNMOSPMOSPOSTendsdconnmospmospost", 4); () = define_keywords ($1, "BEGINbriefnomod", 5); () = define_keywords ($1, "SUBCKTsubckt", 6); () = define_keywords ($1, "INCLUDEOPTIONSincludeoptions", 7); define spice_mode () { variable sp = "SPICE"; set_mode(sp, 0); use_syntax_table (sp); run_mode_hooks("spice_mode_hook"); } jed-0.99-19/lib/pscript.sl0000644002657400265740000001145111311317447014266 0ustar davisdavis% This is a simple PostScript mode. It just implements a highlighting % scheme. % Note that PostScript considers any set of matched parentheses to be a % valid string. This cannot easily be matched by DFA-based methods, so % the highlighting scheme here simply deals with *one* set of inner % parentheses. Hence (asd(df)df) is a valid string under these rules, % but (sdf(df(sdf)sdf)sdf) contains more nested parentheses than we can % cope with here. $1 = "PostScript"; create_syntax_table ($1); define_syntax ("%", "", '%', $1); define_syntax ("([{", ")]}", '(', $1); %define_syntax ('"', '"', $1); %ps %define_syntax ('\'', '"', $1); %ps define_syntax ('\\', '\\', $1); define_syntax ("$0-9a-zA-Z_", 'w', $1); % words define_syntax ("-+0-9a-fA-F.xXL", '0', $1); % Numbers define_syntax (",.?:", ',', $1); %define_syntax ("%-+/&*=<>|!~^", '+', $1); % define_syntax ("%-+&*=<>|!~^", '+', $1); %ps define_syntax ('/', '\\', $1); %ps define_syntax ('@', '#', $1); %set_syntax_flags ($1, 1); % case insensitive set_syntax_flags ($1, 8); %? #ifdef HAS_DFA_SYNTAX %%% DFA_CACHE_BEGIN %%% private define setup_dfa_callback (name) { dfa_enable_highlight_cache ("pscript.dfa", name); dfa_define_highlight_rule("%.*$", "comment", name); dfa_define_highlight_rule("[\\-\\+]?[0-9]*\\.?[0-9]+([Ee][\\-\\+]?[0-9]*)?", "number", name); dfa_define_highlight_rule("[0-9]+#[0-9A-Za-z]*", "number", name); dfa_define_highlight_rule(strcat("\\((\\\\.|[^\\(\\)\\\\]|", "\\(([^\\\\\\(\\)]|\\\\.)*\\))*\\)"), "string", name); dfa_define_highlight_rule(strcat("\\((\\\\.|[^\\(\\)\\\\]|\\(([^\\\\\\(\\)]|\\\\", ".)*\\))*(\\(([^\\\\\\(\\)]|\\\\.)*)?\\\\?$"), "string", name); dfa_define_highlight_rule(strcat("^(([^\\\\\\(\\)]|\\\\.)*\\))?(\\\\.|[^\\(\\)", "\\\\]|\\(([^\\\\\\(\\)]|\\\\.)*\\))*\\)"), "string", name); dfa_define_highlight_rule("<[ \t0-9a-fA-F]*>", "string", name); dfa_define_highlight_rule("<[ \t0-9a-fA-F]*$", "string", name); dfa_define_highlight_rule("^[ \t0-9a-fA-F]*>", "Qstring", name); dfa_define_highlight_rule("<~[ \t!-u]*~>", "string", name); dfa_define_highlight_rule("<~[ \t!-u]*~?$", "string", name); dfa_define_highlight_rule("^[ \t!-u]*~>", "Qstring", name); dfa_define_highlight_rule("[!-\\$&'\\*-\\.0-;=\\?-Z\\\\\\^-z\\|~]+", "Knormal", name); dfa_define_highlight_rule("//?[!-\\$&'\\*-\\.0-;=\\?-Z\\\\\\^-z\\|~]+", "normal", name); dfa_define_highlight_rule("<<|>>|\\[|\\]|{|}", "Qdelimiter", name); dfa_define_highlight_rule(".", "normal", name); dfa_build_highlight_table (name); } dfa_set_init_callback (&setup_dfa_callback, "PostScript"); %%% DFA_CACHE_END %%% #endif % All words in PostScript are of course redefinable. So we will simply % define as keywords the *really* basic ones. These are basic language % operators. ()=define_keywords ($1, "=", 1); ()=define_keywords ($1, "==eqgegtiflelnltneor", 2); ()=define_keywords ($1, strcat("absaddandcoscvicvncvrcvscvxdefdivdupendexpfor", "getlogmodmulnegnotpopputrunsinsrtsubxor"), 3); ()=define_keywords ($1, strcat("atancopycopycvrsdictexchexecexitfileidivload", "loopmarkquitrandreadrollsavestoptruetype"), 4); ()=define_keywords ($1, strcat("aloadarraybeginclearcountcvlitfalsefloorindex", "knownroundrrandsrandstackstoreundefwherewrite"), 5); ()=define_keywords ($1, "astoreforallgstateifelselengthpstackrepeatstring", 6); ()=define_keywords ($1, "ceilingrestore", 7); ()=define_keywords ($1, "truncate", 8); ()=define_keywords ($1, strcat("counttomarkcurrentfilegetintervalpackedarray", "putinterval"), 11); % And these are basic graphical operators. ()=define_keywords_n ($1, "arc", 3, 1); ()=define_keywords_n ($1, "arcnarctclipfillshow", 4, 1); ()=define_keywords_n ($1, "arctogsaveimagescale", 5, 1); ()=define_keywords_n ($1, "concateoclipeofilllinetomatrixmovetorotatestroke", 6, 1); ()=define_keywords_n ($1, "curvetonewpathrlinetormovetosetdashsetfontsetgray", 7, 1); ()=define_keywords_n ($1, "findfontgrestoremakefontrcurvetosetcolorshowpage", 8, 1); ()=define_keywords_n ($1, "closepathscalefontsetmatrixtransformtranslate", 9, 1); ()=define_keywords_n ($1, "definefontsetlinecapsetpattern", 10, 1); ()=define_keywords_n ($1, strcat("currentdashcurrentfontcurrentgraysethsbcolor", "setlinejoinsetrgbcolor"), 11, 1); ()=define_keywords_n ($1, "currentcolorsetcmykcolorsetlinewidth", 12, 1); ()=define_keywords_n ($1, "currentmatrix", 13, 1); ()=define_keywords_n ($1, "currentlinecapcurrentpattern", 14, 1); ()=define_keywords_n ($1, "currenthsbcolorcurrentlinejoincurrentrgbcolor", 15, 1); ()=define_keywords_n ($1, "currentcmykcolorcurrentlinewidth", 16, 1); define ps_mode () { variable ps = "PostScript"; set_mode(ps, 0); use_syntax_table (ps); run_mode_hooks("ps_mode_hook"); } jed-0.99-19/lib/pushmode.sl0000644002657400265740000000357611311317447014437 0ustar davisdavis% The functions push_mode and pop_mode are designed to allow one to temporarily % switch buffer modes and then restore the original mode. % It requires a version of jed with buffer local variables. % To use it, add: % % autoload ("push_mode", "pushmode"); % % to you .jedrc file. define push_mode () { variable mode, old_mode, keymap; variable var_name, try_mode; var_name = "push-mode-stack"; !if (blocal_var_exists (var_name)) define_blocal_var (var_name, ""); if (_NARGS) mode = (); else mode = strtrim (read_mini ("Push to mode:", Null_String, Null_String)); !if (strlen (mode)) return; if (is_defined (mode) <= 0) { mode += "_mode"; if (is_defined (mode) <= 0) error ("Mode is not defined."); } (old_mode,) = what_mode (); !if (strlen (old_mode)) old_mode = "no"; old_mode = strtrans (old_mode, "-", "_"); % Some modes may set modeline to two words. try_mode = strlow (strtrans (old_mode, " ", "_") + "_mode"); if (2 != is_defined (try_mode)) { try_mode = strlow (extract_element (old_mode, 0, ' ') + "_mode"); if (2 != is_defined (try_mode)) verror ("Unable to get mode. Tried %s.", try_mode); } keymap = what_keymap (); no_mode (); eval ("." + mode); % RPN form set_blocal_var (sprintf (".%s|%s,%s", try_mode, keymap, get_blocal_var (var_name)), var_name); } define pop_mode () { variable var_name = "push-mode-stack"; variable modes, keymap, mode; modes = get_blocal_var (var_name); !if (strlen (modes)) error ("mode stack is empty."); mode = extract_element (modes, 0, ','); keymap = extract_element (mode, 1, '|'); mode = extract_element (mode, 0, '|'); no_mode (); eval (mode); use_keymap (keymap); set_blocal_var (extract_element (modes, 1, ','), var_name); } jed-0.99-19/lib/perlxtra.sl0000644002657400265740000003213611311317447014446 0ustar davisdavis% this -*- SLang -*- file defines extra routines that can also be used to % run or format snippets of Perl code that exist outside of 'perl_mode' % % ------------------------------------------------------------------------ % Changes: % 2002-11-19 Mark Olesen % - perl_info and perldoc simplified % % 2002-08-29 Mark Olesen % - split off from perl.sl % - perl_exec / perl_check / perltidy now respect narrowed buffers % % 2006-08-27 Mark Olesen % - cosmetics % % 2006-11-11 JED % - Added provide statement. % % 2007-03-21 Mark Olesen % - save modified file before running perltidy/perl_exec % % ------------------------------------------------------------------------ %{{{ default values for Perl custom variables % override these default values in ~/.jedrc %!%+ %\variable{Perl_Flags} %\synopsis{Perl_Flags} %\usage{String Perl_Flags = "-w";} %\description % Extra (or 'expert') command-line options (switches) for running Perl. % eg, \var{'-I'} or \var{'-M'}. % You only need these if you know why you need these. % % Warnings are *always* enabled, regardless of what you try here. % If your code doesn't run with \var{'-w'}, re-write it so it does % or you're an expert and know which sections of code should have % warnings disabled anyhow. %!%- custom_variable("Perl_Flags", Null_String); %!%+ %\variable{Perl_Indent} %\synopsis{Perl_Indent} %\usage{Integer Perl_Indent = 4;} %\description % This value determines the number of columns the current line is indented % past the previous line containing an opening \exmp{'\{'} character. % eg., %#v+ % if (test) { % statement(); % } % else { % statement(); % } %#v- % % The default value (4) corresponds to the default for \var{perltidy} % %\seealso{C_INDENT, Perl_Continued_Offset} %!%- custom_variable("Perl_Indent", 4); %}}} static variable tmp_input = "_tmp_jedperl_", shell_output = "*shell-output*", help_buf = "*help-perl*"; % interact with perldoc information %------------------------------------------------------------------------- %!%+ %\function{perltidy} %\synopsis{Void perltidy (Void)} %\description % Runs the \var{perltidy} program on a region, buffer or narrowed buffer. % The \var{perltidy} program (available from \var{http://perltidy.sourceforge.net}) % must be installed for this to work! % % With a numerical prefix argument (eg Ctrl-U), prompts for extra flags % for \var{perltidy}. % % The following style preferences settings in \var{~/.perltidyrc} seem to % give good results: %#v+ % -et=8 # standard tabs % -nola # no outdent labels % -wba="." # break after string concatenation % -se # errors to standard error output % -sbt=2 # very tight square brackets %#v- %\seealso{perl_indent_region, perl_indent_buffer, perl_mode} %!%- define perltidy () % this function { variable cmd = "perltidy -st -q"; % command plus invariant flags variable line = what_line(); % we'll try to return here later variable opts = "-nola"; % optional flags variable file, dir, thisbuf, flags; (file, dir, thisbuf, flags) = getbuf_info(); if (change_default_dir(dir)) { error("cd '" + dir + "' failed"); } % with a prefix argument, we can add extra flags if ( -9999 != prefix_argument (-9999) ) { opts = read_mini( "perltidy flags:", Null_String, opts ); } % check if we want a tmp file % we need a tmp file for a processing % 1: a region % 2: a narrowed buffer % 3: when no file is attached variable use_tmp = markp(); % a region !if (use_tmp) { % no region, but a narrowed buffer use_tmp = count_narrows(); if (use_tmp) mark_buffer(); } !if (use_tmp) { % check if a file is attached !if (strlen(file)) use_tmp = 1; mark_buffer(); } narrow(); if (use_tmp) { file = tmp_input; % we need to use a tmp file mark_buffer(); () = write_region_to_file(file); % guess the start indentation level bob(); do { skip_white(); if (eolp()) continue; % ignore blank lines % round column number up and use to estimate the indentation level cmd += sprintf(" -sil=%d", int((what_column() + 1) / Perl_Indent)); break; } while (down_1()); } else if (flags & 0x01) { % buffer modified - save the file first () = write_buffer (dir + file); } sw2buf(shell_output); erase_buffer (); % clean-up function % unfortunately run_shell_cmd doesn't always signal an error!! ERROR_BLOCK { sw2buf(thisbuf); delbuf(shell_output); if (use_tmp) () = delete_file(file); widen(); goto_line(line); bol(); flush(Null_String); } % add flags and the file name if ( strlen(opts) ) cmd = strjoin( [ cmd, opts, file ], " " ); else cmd = strjoin( [ cmd, file ], " " ); flush(cmd); variable rc = run_shell_cmd(cmd); set_buffer_modified_flag(0); % mark as unchanged % handle errors from 'run_shell_cmd' if (rc) error("error running perltidy"); % the command apparently worked % switch back to our original buffer and update everything sw2buf(thisbuf); mark_buffer(); del_region(); % use del_region so that undo will work insbuf(shell_output); EXECUTE_ERROR_BLOCK; } % Run perl with some flags on current region if one is defined, otherwise % on the whole buffer. % % Display output in *shell-output* buffer window. % % Error messages look like this: % Missing right curly or square bracket at Foo.pl line 7, at end of line % % Thus we'll look for ' at FILENAME line ' static define do_perl (opts, prompt) { variable cmd = "perl -w"; variable args = Null_String; variable line = 0; % line offset variable file, dir, thisbuf, flags; (file, dir, thisbuf, flags) = getbuf_info(); if (change_default_dir(dir)) { error("cd '" + dir + "' failed"); } if (strlen(Perl_Flags)) opts += " " + Perl_Flags; % tack on our flags % with a prefix argument, we can edit perl flags if ( -9999 != prefix_argument (-9999) ) { opts = read_mini( "Perl flags:", Null_String, opts ); } % check if we want a tmp file % we need a tmp file for a processing % 1: a region % 2: a narrowed buffer % 3: when no file is attached variable use_tmp = markp(); % a region !if (use_tmp) { % no region, but a narrowed buffer use_tmp = count_narrows(); if (use_tmp) mark_buffer(); } !if (use_tmp) { % check if a file is attached if (strlen(prompt)) args = read_mini( prompt, Null_String, Null_String ); !if (strlen(file)) { % no file attached use_tmp = 1; mark_buffer(); } } if (use_tmp) { file = tmp_input; % we need to use a tmp file check_region(1); % canonical region & push_spot exchange_point_and_mark(); % goto start line = what_line(); % force 'strict'; % also introduces a line offset of 1 as a nice side-effect () = write_string_to_file( "use strict;\n", file ); () = append_region_to_file(file); pop_spot(); } else if (flags & 0x01) { % buffer modified - save the file first () = write_buffer (dir + file); } variable oldbuf = pop2buf_whatbuf(shell_output); erase_buffer (); % in case our system command bombs out ERROR_BLOCK { if (use_tmp) () = delete_file(file); } #ifdef OS2 UNIX args += " 2>&1"; % re-direct stderr as well #endif variable rc = run_shell_cmd(strjoin( [cmd, opts, file, args], " ")); set_buffer_modified_flag(0); % mark output as unchanged % report errors from 'run_shell_cmd' if (rc) flush("error running perl"); EXECUTE_ERROR_BLOCK; % try to restore any window that got replaced by the shell-output %% if (strlen(oldbuf) %% and (oldbuf != shell_output) %% and (oldbuf != thisbuf) ) %% { %% splitwindow(); sw2buf(oldbuf); pop2buf(shell_output); %% } eob(); % No output - close the shell-window and display message if (bobp()) { pop2buf(thisbuf); onewindow(); message("No output."); } else if ( right( bsearch( " at " + file + " line " ) ) ) { % Move to the line in source that generated the error skip_white(); % for safety's sake push_mark(); skip_chars ("0-9"); line += integer(bufsubstr()); %% flush (sprintf ("goto line %d", line)); % Debug pop2buf(thisbuf); goto_line(line); bol(); } } %!%+ %\function{perl_exec} %\synopsis{Void perl_exec (Void)} %\description % This function runs \var{perl} on a region, buffer or narrowed buffer. % With a numerical prefix argument (eg Ctrl-U), also prompts for % extra Perl flags. % Display output in *shell-output* buffer window. %\seealso{perl_check, perl_mode} %!%- define perl_exec() { % do_perl(Null_String, "perl @ARGV:"); } %!%+ %\function{perl_check} %\synopsis{Void perl_check (Void)} %\description % This function runs a perl \var{-CT} check on a region, buffer or narrowed buffer. % Display output in *shell-output* buffer window. %\seealso{perl_exec, perltidy, perl_mode} %!%- define perl_check() { do_perl("-cT", Null_String); % check with tainting on } % we seem to need this an awful lot, since we currently have no help mode % and the user may have deleted the buffer in the meantime % ... with a bit better integration in the main JED distribution, % we could reduce this overhead % static define attach_keymap (name) { !if (keymap_p(name)) { make_keymap(name); definekey("perl_help", "?", name); definekey("perl_help", "\r", name); definekey("perl_help", "^C?", name); % for consistency definekey("perl_info", "^Ci", name); } if (bufferp(name)) { variable cbuf = whatbuf(); setbuf(name); use_keymap(name); % attach keymap here setbuf(cbuf); } } % % insert the results of a shell command into the help buffer % static define perl_get_help (cmd) { variable cbuf = pop2buf_whatbuf(help_buf); erase_buffer(); attach_keymap(help_buf); flush(cmd); #ifdef UNIX () = run_shell_cmd(cmd + " 2>/dev/null"); % discard stderr #else () = run_shell_cmd(cmd); #endif bob(); set_buffer_modified_flag(0); pop2buf(cbuf); flush(Null_String); } static define help_for_perl (what) { % empty string -> translate to 'perl' (like a table-of-contents) if (orelse { what == NULL } {not(strlen (what))} ) what = "perl"; perl_get_help("perldoc -t " + what); } %% %!%+ %% %\function{extract_word} %% %\synopsis{extract_word} %% %\usage{String extract_word (String Word_Chars)} %% %\description %% % extract a word defined by \var{Word_Chars} from the current buffer %% %!%- static define extract_word (chars) { !if (markp()) { % skip leading non-word chars, including newline do { skip_chars ("^" + chars); !if (eolp()) break; } while (down (1)); bskip_chars (chars); % in case we started in the middle of a word push_mark(); skip_chars (chars); % mark the word } return bufsubstr(); } %!%+ %\function{perl_info} %\synopsis{Void perl_info (Void)} %\description % displays the perl settings \var{perl -V} in the help buffer %!%- %\seealso{perldoc, perl_help} define perl_info () { perl_get_help("perl -V"); } % %!%+ %\function{perl_help} %\synopsis{Void perl_help (Void)} %\description % extract an alphanumeric keyword (a function) and display help % via perldoc for it %!%- %\seealso{perldoc, perl_mode} define perl_help () % { variable what = extract_word(":0-9A-Z_a-z"); !if (strlen(what)) { flush("Sorry no word extracted"); return; % no string - no help } % all lower-case words treated as function names % provided they don't start with 'perl' (mostly manpages) if (strncmp(what, "perl", 4)) { if (string_match(what, "^[a-z][a-z0-9]+$", 1)) { what = strcat("-f ", what); } } help_for_perl(what); } %!%+ %\function{perldoc} %\synopsis{Void perldoc (void)} %\description % use perldoc to find information % The '-f' option is inferred for lowercase strings not starting with 'perl' % % perldoc [options] PageName|ModuleName|ProgramName... % perldoc [options] -f BuiltinFunction % perldoc [options] -q FAQRegex % % Options: % -u Display unformatted pod text % -m Display module's file in its entirety % -q Search the text of questions (not answers) in perlfaq[1-9] %\seealso{perl_help, perl_mode} %!%- define perldoc () % { !if (MINIBUFFER_ACTIVE) help_for_perl(read_mini("perldoc:", Null_String, Null_String)); } provide ("perlxtra"); % -------------------------------------------------------- [end of S-Lang] jed-0.99-19/lib/emacs.hlp0000644002657400265740000000034311311317447014035 0ustar davisdavisJED Emacs keybindings: `^' means to use Ctrl key (e.g., ^X = Ctrl-X). ^X^C exit ^V PageDn ^Xu Undo ^X^W write to file ^A beg of line ^L redraw ESC V PageUp ^D delete ^X^F open a file ^E end of line jed-0.99-19/lib/replace.sl0000644002657400265740000000270411311317447014216 0ustar davisdavis% % This function executes a query-replace across all buffers attached to % a file. % require ("search"); define replace_across_buffer_files () { variable cbuf = whatbuf (); variable n = buffer_list (); variable buf, file, flags; variable pat, rep; pat = read_mini ("Replace:", Null_String, Null_String); !if (strlen (pat)) return; rep = read_mini ("Replace with:", Null_String, Null_String); push_spot (); % save our location REPLACE_PRESERVE_CASE_INTERNAL = REPLACE_PRESERVE_CASE; if ((strlen (rep) == strlen(pat)) and not (strcmp(strlow(rep), strlow(pat)))) REPLACE_PRESERVE_CASE_INTERNAL = 0; if (-1 != prefix_argument (-1)) REPLACE_PRESERVE_CASE_INTERNAL = not (REPLACE_PRESERVE_CASE_INTERNAL); try while (n) { buf = (); n--; % skip special buffers if ((buf[0] == '*') or (buf[0] == ' ')) continue; sw2buf (buf); (file,,,flags) = getbuf_info (); % skip if no file associated with buffer, or is read only !if (strlen (file) or (flags & 8)) continue; % ok, this buffer is what we want. push_spot_bob (); ERROR_BLOCK { pop_spot (); } replace_with_query (&search_search_function, pat, rep, 1, &replace_do_replace); pop_spot (); } finally { sw2buf (cbuf); pop_spot (); _pop_n (n); % remove buffers from stack REPLACE_PRESERVE_CASE_INTERNAL = 0; } EXECUTE_ERROR_BLOCK; message ("Done."); } jed-0.99-19/lib/ispell.sl0000644002657400265740000000603411311317447014073 0ustar davisdavis%% %% Ispell interface %% %!%+ %\variable{Ispell_Program_Name} %\synopsis{spell-check program name} %\usage{variable Ispell_Program_Name = ""} %\description % The spell check command used by the \sfun{ispell} function. It must % be ispell-compatible (one of "ispell", "aspell" or "hunspell"). If % unset, the ispell program will be auto-detected by searching the % path for one of the above programs. %\seealso{ispell, search_path_for_file} %!%- custom_variable("Ispell_Program_Name", NULL); % Search for candidates: if ((Ispell_Program_Name == NULL) || (Ispell_Program_Name == "")) { Ispell_Program_Name = "ispell"; foreach $1 (["aspell", "hunspell", "ispell"]) { if (NULL != search_path_for_file(getenv("PATH"), $1)) { Ispell_Program_Name = $1; break; } } Ispell_Program_Name += " -a"; } define ispell () { variable ibuf, buf, file, letters, num_win, old_buf; variable word, cmd, p, num, n, new_word; #ifdef OS2 file = make_tmp_file("jedt"); #else file = make_tmp_file("/tmp/jed_ispell"); #endif letters = "\a"R; ibuf = " *ispell*"; buf = whatbuf(); skip_chars(letters); bskip_chars(letters); push_mark(); % push_mark(); n = _get_point (); skip_chars(letters); if (_get_point () == n) { pop_mark_0 (); %pop_mark_0 (); return; } %word = bufsubstr(); #ifdef MSDOS MSWINDOWS WIN32 () = system(sprintf("echo %s | %s > %s", bufsubstr(), Ispell_Program_Name, file)); #else if (pipe_region(sprintf ("%s > '%s'", Ispell_Program_Name, file))) error ("ispell process returned a non-zero exit status."); #endif setbuf(ibuf); erase_buffer(); () = insert_file(file); () = delete_file(file); %% %% parse output %% bob(); if (looking_at_char('@')) % ispell header { del_through_eol (); } if (looking_at_char('*') or looking_at_char('+')) { message ("Correct"); % '+' ==> is derived from bury_buffer (ibuf); return; } if (looking_at_char('#')) { bury_buffer (ibuf); return (message("No clue.")); } del(); trim(); eol_trim(); bol(); if (ffind_char (':')) { skip_chars(":\t "); push_mark(); bol(); del_region(); } insert ("(0) "); n = 1; while (ffind_char (',')) { del (); trim(); newline(); vinsert ("(%d) ", n); ++n; } bob(); num_win = nwindows(); pop2buf(buf); old_buf = pop2buf_whatbuf(ibuf); set_buffer_modified_flag(0); variable ok = 0; try { num = read_mini("Enter choice. (^G to abort)", "0", ""); if (0 == fsearch(sprintf ("(%s)", num))) throw RunTimeError, "$num is an invalid choice"$; () = ffind_char (' '); trim(); push_mark_eol(); trim(); new_word = bufsubstr(); set_buffer_modified_flag(0); sw2buf(old_buf); pop2buf(buf); ok = 1; bskip_chars(letters); push_mark(); skip_chars(letters); del_region(); insert(new_word); } finally { if (ok == 0) { sw2buf(old_buf); pop2buf(buf); } if (num_win == 1) onewindow(); bury_buffer(ibuf); } } jed-0.99-19/lib/srchmisc.sl0000644002657400265740000000637711311317447014430 0ustar davisdavis% These routines are common to both regular expression searches and ordinary % searches. define mark_next_nchars (n, dir) { variable h; ERROR_BLOCK { set_line_hidden (h); pop_mark_0 (); } h = is_line_hidden (); set_line_hidden (0); push_visible_mark (); go_right (n); if (dir < 0) exchange_point_and_mark (); update(1); ungetkey(getkey()); EXECUTE_ERROR_BLOCK; } % The search function is to return: 0 if non-match found or the length of the % item matched. % search_fun takes the pattern to search for and returns the length of the % pattern matched. If no match occurs, return -1. % rep_fun returns the length of characters replaced. define replace_with_query (search_fun, pat, rep, query, rep_fun) { variable n, prompt, doit, err, ch, pat_len; variable undo_stack_type = struct { rep_len, prev_string, user_mark, next }; variable undo_stack = NULL; variable tmp; variable replacement_length = strlen (rep); prompt = sprintf ("Replace '%s' with '%s'? (y/n/!/+/q/h)", pat, rep); while (pat_len = @search_fun (pat), pat_len >= 0) { !if (query) { %tmp = create_user_mark (); () = @rep_fun (rep, pat_len); if ((pat_len == 0) %and (tmp == create_user_mark ()) ) go_right_1 (); continue; } do { message(prompt); mark_next_nchars (pat_len, -1); ch = getkey (); if (ch == 'r') { recenter (window_info('r') / 2); } } while (ch == 'r'); switch(ch) { case 'u' and (undo_stack != NULL) : goto_user_mark (undo_stack.user_mark); push_spot (); () = @rep_fun (undo_stack.prev_string, undo_stack.rep_len); pop_spot (); undo_stack = undo_stack.next; } { case 'y' : tmp = @undo_stack_type; tmp.next = undo_stack; undo_stack = tmp; push_spot(); push_mark (); go_right (pat_len); undo_stack.prev_string = bufsubstr (); pop_spot (); undo_stack.user_mark = create_user_mark (); undo_stack.rep_len = @rep_fun (rep, pat_len); if (pat_len == 0) go_right(1); } { case 'n' : go_right_1 ();} { case '+' : () = @rep_fun (rep, pat_len); if (pat_len == 0) go_right(1); break; } { case '!' : query = 0; } { case 'q' : break; } { flush ("y:replace, n:skip, !:replace all, u: undo last, +:replace then quit, q:quit"); () = input_pending (30); } } } define search_maybe_again (fun, str, dir, match_ok_fun) { variable ch, len; while (len = @fun (str, dir), len >= 0) { if (@match_ok_fun ()) { if (EXECUTING_MACRO or DEFINING_MACRO) return 1; message ("Press RET to continue searching."); mark_next_nchars (len, -1); ch = getkey (); if (ch != '\r') { ungetkey (ch); return 1; } } if (dir > 0) go_right_1 (); } return 0; } %!%+ %\function{toggle_case_search} %\synopsis{Toggle the CASE_SEARCH variable} %\usage{Void toggle_case_search ()} %\seealso{CASE_SEARCH} %!%- public define toggle_case_search () { variable off_on = ["Off", "On"]; CASE_SEARCH = not(CASE_SEARCH); vmessage("Case Search %s for this buffer", off_on[CASE_SEARCH]); } provide ("srchmisc"); jed-0.99-19/lib/paste.sl0000644002657400265740000000100011311317447013703 0ustar davisdavisdefine paste () { flush ("Ready for data..."); if (0 == input_pending (300)) { message ("You have taken too much time"); return; } variable as = _test_buffer_flag (2); ERROR_BLOCK { if (as) _set_buffer_flag (2); } _unset_buffer_flag (2); flush ("Pasting in progress..."); while (input_pending (10)) { variable ch = _getkey (); if (ch == '\r') { ch = '\n'; } insert_byte (ch); update (0); } EXECUTE_ERROR_BLOCK; message ("Done"); } jed-0.99-19/lib/emacs.sl0000644002657400265740000001556111311317447013700 0ustar davisdavis% % Emacs like bindings for Jed. % % A subset of the emacs global map is implemented here. If you % are lacking a useful keybinding, contact davis@space.mit.edu _Jed_Emulation = "emacs"; set_status_line("(Jed %v) Emacs: %b (%m%a%n%o) %p %t", 1); Help_File = "emacs.hlp"; KILL_LINE_FEATURE = 0; #ifdef UNIX enable_flow_control(0); %turns off ^S/^Q processing (Unix only) #endif % % The default keybindings for Jed use ^W, ^F, and ^K keymaps. Emacs % does not bind these so turn them off unset_ctrl_keys (); set_abort_char (7); % ^G _Reserved_Key_Prefix = "\003"; % ^C % Jed default binding of the tab char ^I is to indent line. Here just insert % the tab % setkey("self_insert_cmd", "^I"); %% The default binding for the quote keys (", ') is 'text_smart_quote'. %% Most users do not seem to like this so it is unset here. %% setkey("self_insert_cmd", "\""); setkey("self_insert_cmd", "'"); % setkey("backward_delete_char", "^?"); setkey("backward_delete_char_untabify", "^?"); #ifdef IBMPC_SYSTEM setkey("smart_set_mark_cmd", "^@^C"); #else setkey("smart_set_mark_cmd", "^@"); #endif setkey("beg_of_line", "^A"); setkey("previous_char_cmd", "^B"); setkey("delete_char_cmd", "^D"); setkey("eol_cmd", "^E"); setkey("next_char_cmd", "^F"); setkey("kbd_quit", "^G"); if (_Backspace_Key != "\x08") setkey("help_prefix", "^H"); setkey("newline", "^J"); setkey("emacs_yp_kill_line", "^K"); setkey("emacs_recenter", "^L"); setkey("newline_and_indent", "^M"); setkey("next_line_cmd", "^N"); setkey("emacs_open_line", "^O"); setkey("previous_line_cmd", "^P"); setkey("quoted_insert", "^Q"); setkey("isearch_backward", "^R"); setkey("isearch_forward", "^S"); setkey("transpose_chars", "^T"); setkey("universal_argument", "^U"); setkey("page_down", "^V"); setkey("yp_kill_region", "^W"); % % ^X map % setkey("list_buffers", "^X^B"); setkey("exit_jed", "^X^C"); setkey("list_directory", "^X^D"); setkey("find_file", "^X^F"); setkey(".'d'xform_region", "^X^L"); setkey("delete_blank_lines", "^X^O"); setkey("toggle_readonly", "^X^Q"); setkey("find_file_read_only", "^X^R"); setkey("save_buffer", "^X^S"); setkey("transpose_lines", "^X^T"); setkey(".'u'xform_region", "^X^U"); setkey("find_alternate_file", "^X^V"); setkey("write_buffer", "^X^W"); setkey("exchange", "^X^X"); setkey("evaluate_cmd", "^X\e"); setkey("set_selective_display", "^X$"); setkey("compile_parse_errors", "^X'"); setkey("begin_macro", "^X("); setkey("end_macro", "^X)"); setkey("mark_spot", "^X/"); setkey("delete_window", "^X0"); setkey("one_window", "^X1"); setkey("split_window", "^X2"); setkey("changelog_add_change", "^X4A"); setkey("find_buffer_other_window","^X4B"); setkey("find_file_other_window","^X4F"); setkey("digraph_cmd", "^X8"); setkey("comment_region_or_line","^X;"); setkey("scroll_left", "^X<"); setkey("whatpos", "^X="); setkey("scroll_right", "^X>"); setkey("whatpos", "^X?"); setkey("switch_to_buffer", "^XB"); setkey("dired", "^XD"); setkey("execute_macro", "^XE"); setkey("set_fill_column", "^XF"); setkey("reg_insert_register", "^XG"); setkey("emacs_mark_buffer", "^XH"); setkey("insert_file", "^XI"); setkey("pop_spot", "^XJ"); setkey("kill_buffer", "^XK"); #ifdef UNIX setkey("mail", "^XM"); #endif setkey("narrow_to_region", "^XN"); setkey("other_window", "^XO"); setkey("macro_query", "^XQ"); setkey("kill_rect", "^XRK"); setkey("open_rect", "^XRO"); setkey("copy_rect", "^XRR"); setkey("insert_rect", "^XRY"); setkey("string_rectangle", "^XRT"); setkey("save_some_buffers", "^XS"); setkey("undo", "^XU"); setkey("widen_region", "^XW"); setkey("reg_copy_to_register", "^XX"); setkey("enlarge_window", "^X^"); setkey("yp_yank", "^Y"); setkey("sys_spawn_cmd", "^Z"); setkey("goto_match", "^\\"); setkey("undo", "^_"); % % The escape map % setkey("forward_sexp", "\e^F"); setkey("backward_sexp", "\e^B"); setkey("kill_sexp", "\e^K"); setkey(".bskip_white trim insert_single_space", "\e "); setkey("bskip_word", "\eb"); setkey("delete_word", "\eD"); setkey("bdelete_word", "\e^?"); setkey("skip_word", "\ef"); setkey("replace_cmd", "\e%"); setkey("beg_of_buffer", "\e<"); setkey("end_of_buffer", "\e>"); setkey("narrow_paragraph", "\eN"); setkey ("goto_line_cmd", "\eg"); setkey("scroll_down_in_place", "\ep"); setkey("scroll_up_in_place", "\en"); setkey("format_paragraph", "\eQ"); setkey("page_up", "\eV"); % see emacs_pageup below setkey("copy_region", "\ew"); setkey("trim_whitespace", "\e\\"); setkey ("forward_paragraph", "\e}"); setkey ("backward_paragraph", "\e{"); setkey ("yp_yank_pop", "\ey"); setkey ("yp_kill_word", "\eD"); setkey ("yp_bkill_word", "\e^?"); setkey ("yp_copy_region_as_kill", "\ew"); autoload ("find_file_other_window", "emacsmsc"); autoload ("find_buffer_other_window", "emacsmsc"); autoload ("find_alternate_file", "emacsmsc"); autoload ("delete_blank_lines", "emacsmsc"); autoload ("forward_sexp", "emacsmsc"); autoload ("backward_sexp", "emacsmsc"); autoload ("kill_sexp", "emacsmsc"); autoload ("scroll_up_in_place", "emacsmsc"); autoload ("scroll_down_in_place", "emacsmsc"); autoload ("string_rectangle", "emacsmsc"); %% misc functions %% #iffalse % Is this more emacs-like??? Anyone? define emacs_pageup () { variable n = prefix_argument (-1); variable m; if (n == -1) { call ("page_up"); return; } m = window_line (); go_up (n); recenter (m); } #endif define emacs_mark_buffer() { mark_buffer (); exchange_point_and_mark (); } define emacs_open_line() { newline(); go_left_1 (); } define emacs_recenter() { recenter(0); } public define emacs_yp_kill_line () { variable n = prefix_argument (-1); if (n == -1) { yp_kill_line (); return; } push_mark (); if (n != down (n)) eol (); yp_kill_region (); } define transpose_chars () { variable c, err; err = "Top of Buffer"; if (eolp()) go_left_1 (); !if (left(1)) error(err); c = what_char(); del(); go_right_1 (); insert_char(c); } %%0 9 1 { "^U" exch string strcat "digit_arg" exch setkey } _for % % Emacs Universal argument--- bound to ^U % define universal_argument () { variable n, key, count, msg, cu, force; n = 4; count = 0; cu = "C-u"; msg = cu; force = 0; forever { !if (force) !if(input_pending(10)) force = 1; if (force) { message(msg + "-"); update_sans_update_hook (0); } msg += " "; key = getkey(); switch(key) { isdigit(char(key)) : key = key - '0'; count = 10 * count + key; msg += string(key); } { case 21 : % ^U !if (count) n = 4 * n; count = 0; msg += cu; } { ungetkey(key); !if (count) count = n; count = string(count); n = strlen(count); _for (n, 1, -1) { count; exch(); ungetkey(int (substr((), (), 1))); } ungetkey(27); return; } } } runhooks ("keybindings_hook", _Jed_Emulation); jed-0.99-19/lib/mailedit.sl0000644002657400265740000002572411311317447014402 0ustar davisdavis% This particular email-editing mode borrows ideas from several other % such modes from contributers such as % % Morten Bo Johansen -> email % Paul Boekholt % Johann Botha -> muttmail % Ulli Horlacher % Abraham vd Merwe % Thomas Roessler % % To use this mode for editing a mail message from mutt, slrn, etc, set % the editor variable to: % % "jed %s -tmp --mailedit-mode" % % Variables supported by the mode include: % % MailEdit_Fcc % MailEdit_Reply_To % MailEdit_Max_Signature_Lines % MailEdit_Quote_Chars, % % The colors may be controlled by % % MailEdit_Quote_Color % MailEdit_Signature_Color % MailEdit_To_Color % MailEdit_Subject_Color % MailEdit_From_Color % MailEdit_Header_Color % % via, e.g., set_color ("MailEdit_Header_Color", "red", "black"); % % The function mailedit_mode calls mailedit_mode_hook. % require ("mailutils"); custom_variable ("MailEdit_Fcc", NULL); custom_variable ("MailEdit_Reply_To", NULL); custom_variable ("MailEdit_Max_Signature_Lines", 4); custom_variable ("MailEdit_Quote_Chars", ">:|"); custom_color ("MailEdit_Quote_Color", get_color ("string")); custom_color ("MailEdit_Signature_Color", get_color ("preprocess")); custom_color ("MailEdit_From_Color", get_color ("keyword")); custom_color ("MailEdit_To_Color", get_color ("keyword")); custom_color ("MailEdit_Subject_Color", get_color ("keyword")); custom_color ("MailEdit_Header_Color", get_color ("keyword1")); autoload ("mailalias_expand", "mailalias"); private variable Header_Color = color_number ("MailEdit_Header_Color"); private variable Quote_Color = color_number ("MailEdit_Quote_Color"); private variable Signature_Color = color_number ("MailEdit_Signature_Color"); private variable From_Color = color_number ("MailEdit_From_Color"); private variable To_Color = color_number ("MailEdit_To_Color"); private variable Subject_Color = color_number ("MailEdit_Subject_Color"); private define find_header_keyword_start () { do { bol_skip_white (); if (bolp ()) return; } while (up(1)); bol (); } % If the header does not exist, it will be created. */ private define goto_header (header) { if (-1 == mailutils_narrow_to_header ()) return -1; variable exists = bol_fsearch (header); widen_region (); if (exists == 0) { () = mailutils_find_header_separator (); % Do it this way to avoid moving the line mark go_left (1); vinsert ("\n%s ", header); return 0; } go_right (strlen (header)); skip_white (); return 0; } private define add_xxx_header (header, value) { if (value == NULL) return; variable exists = mailutils_get_keyword_value (header); if ((exists != NULL) and (exists != "")) return; push_spot (); if (0 == goto_header (header)) insert (value); pop_spot (); } % If not found, the point is left at eob private define find_signature_start () { eob (); variable line = what_line (); !if (bol_bsearch ("-- \n")) return 0; if (line - what_line () > MailEdit_Max_Signature_Lines) { eob (); return 0; } return 1; } private define in_signature () { variable m = create_user_mark (); EXIT_BLOCK { goto_user_mark (m); } !if (find_signature_start ()) return 0; return m >= create_user_mark (); } private define in_header () { variable m = create_user_mark (); variable ih = 0; if (mailutils_find_header_separator ()) ih = (m <= create_user_mark ()); goto_user_mark (m); return ih; } private define in_mail_body () { if (in_header ()) return 0; return not in_signature (); } private define line_is_quoted () { push_spot(); bol_skip_white (); variable c = what_column (); skip_chars (MailEdit_Quote_Chars); c = what_column () - c; pop_spot (); return c; } % Moves to bol, skips the quote characters leaving the point and returns their number private define count_quotes () { bol_skip_white (); variable count = 0; forever { push_mark (); skip_chars (MailEdit_Quote_Chars); variable dcount = strlen (bufsubstr ()); !if (dcount) break; count += dcount; !if (looking_at (" ")) break; go_right_1 (); } return count; } private define skip_quotes () { bol_skip_white (); skip_chars (MailEdit_Quote_Chars); } private define extract_quotes () { push_spot (); () = count_quotes (); push_mark (); bol (); bufsubstr (); % on stack pop_spot (); } % What constitutes a paragraph? private define mark_paragraph () { !if (in_mail_body ()) { push_mark (); return; } push_spot (); if (mailutils_find_header_separator ()) go_down_1 (); else bob (); variable body_start = create_user_mark (); goto_spot (); % Goto paragraph start variable nquotes = count_quotes (); while (up_1 ()) { if ( #if (_slang_version >= 20100) (create_user_mark () >= body_start) && (nquotes == count_quotes ()) #else andelse{create_user_mark () >= body_start}{nquotes == count_quotes ()} #endif ) { skip_white (); !if (eolp ()) continue; } go_down_1 (); break; } bol (); push_mark (); % Now goto end pop_spot (); eol (); while (down_1 ()) { if (nquotes == count_quotes ()) { skip_white (); !if (eolp ()) { eol (); continue; } } bol (); break; } if (in_signature ()) { () = find_signature_start (); } } private define format_paragraph_hook (); private define format_header () { push_spot (); find_header_keyword_start (); push_mark (); while (down_1 ()) { skip_white (); if (bolp ()) break; } narrow_to_region (); bob (); unset_buffer_hook ("format_paragraph_hook"); call ("format_paragraph"); set_buffer_hook ("format_paragraph_hook", &format_paragraph_hook); bob (); while (down_1 () and not (eobp ())) insert (" "); eob (); !if (bolp ()) newline (); widen_region (); pop_spot (); } private define format_paragraph_hook () { if (in_header ()) return format_header (); if (in_signature ()) return; % In the body push_spot (); variable nquotes = count_quotes (); variable quotes = extract_quotes (); mark_paragraph (); narrow_to_region (); bob (); if (nquotes) { while (nquotes == count_quotes ()) { push_mark (); bol (); del_region (); !if (down_1 ()) break; } } pop_spot (); unset_buffer_hook ("format_paragraph_hook"); call ("format_paragraph"); set_buffer_hook ("format_paragraph_hook", &format_paragraph_hook); push_spot (); eob (); if (not bolp ()) newline (); if (nquotes) { bob (); do { insert (quotes); } while (down_1 () and not (eobp ())); } pop_spot (); widen_region (); } private define is_paragraph_separator () { !if (in_mail_body ()) return 1; if (line_is_quoted ()) return 1; bol_skip_white (); return eolp (); } private define wrap_hook () { push_spot (); EXIT_BLOCK { pop_spot (); } if (in_header ()) { bol_trim (); insert (" "); trim (); } if (in_mail_body ()) { #iftrue indent_line (); #else go_up_1 (); bol_skip_white (); variable col = what_column (); go_down_1 (); bol_trim (); whitespace (col - 1); #endif return; } } private define add_fcc () { add_xxx_header ("Fcc:", MailEdit_Fcc); } private define add_replyto () { add_xxx_header ("Reply-To:", MailEdit_Reply_To); } private define mark_header_separator () { !if (mailutils_find_header_separator ()) return; %set_line_readonly (1); } private variable Header_Color_Map = Assoc_Type[Int_Type, Header_Color]; Header_Color_Map["TO"] = To_Color; Header_Color_Map["CC"] = To_Color; Header_Color_Map["BCC"] = To_Color; Header_Color_Map["SUBJECT"] = Subject_Color; Header_Color_Map["FROM"] = From_Color; private define color_header_line () { push_spot (); find_header_keyword_start (); push_mark (); () = ffind (":"); variable color = Header_Color_Map[strup (bufsubstr())]; pop_spot (); set_line_color (color); } private define color_buffer (min_line, max_line) { push_spot (); EXIT_BLOCK { pop_spot (); } % Optimization for the most common case if (min_line == max_line) { goto_line (min_line); if (in_header ()) { bol (); color_header_line (); return; } if (in_signature ()) { set_line_color (Signature_Color); return; } if (line_is_quoted ()) { set_line_color (Quote_Color); return; } set_line_color (0); return; } variable header_line, signature_line; if (mailutils_find_header_separator ()) header_line = what_line (); else header_line = 0; if (find_signature_start ()) signature_line = what_line (); else signature_line = max_line + 1; goto_line (min_line); if (max_line < header_line) header_line = max_line + 1; if (min_line <= header_line) { loop (header_line - min_line) { color_header_line (); %set_line_color (Header_Color); go_down_1 (); } % skip header go_down_1 (); min_line = header_line; min_line++; } if (max_line < signature_line) signature_line = max_line + 1; loop (signature_line - min_line) { if (line_is_quoted ()) set_line_color (Quote_Color); else set_line_color (0); go_down_1 (); } min_line = signature_line; loop (max_line - min_line + 1) { set_line_color (Signature_Color); go_down_1 (); } } private define newline_indent_hook () { if (line_is_quoted ()) { !if (bolp () or eolp ()) { variable quotes = extract_quotes (); insert ("\n\n\n"); insert (quotes); call ("format_paragraph"); go_up (2); return; } } newline (); indent_line (); } !if (keymap_p ("mailedit")) make_keymap ("mailedit"); public define mailedit_mode () { mark_header_separator (); add_fcc (); add_replyto (); variable start_mark = NULL; bob (); if (bol_fsearch ("To: ")) { go_right (3); skip_chars ("\t "); if (eolp ()) start_mark = create_user_mark (); } if (start_mark == NULL) { if (mailutils_find_header_separator ()) { go_down (2); start_mark = create_user_mark (); } } bob (); if (start_mark != NULL) goto_user_mark (start_mark); set_buffer_modified_flag (0); use_keymap ("mailedit"); set_mode ("mailedit", 1); unset_buffer_hook (""); %set_buffer_hook ("par_sep", &is_paragraph_separator); set_buffer_hook ("format_paragraph_hook", &format_paragraph_hook); set_buffer_hook ("wrap_hook", &wrap_hook); set_buffer_hook ("color_region_hook", &color_buffer); set_buffer_hook ("newline_indent_hook", &newline_indent_hook); %set_buffer_hook ("mark_paragraph_hook", &mark_paragraph); set_comment_info ("mailedit", ">", "", 0); run_mode_hooks ("mailedit_mode_hook"); } jed-0.99-19/lib/docbook.sl0000644002657400265740000011463011311317447014225 0ustar davisdavis% File: docbook.sl -*- SLang -*- % % Author: Guido Gonzato, % % Version: 1.0.0. % % Description: this mode is designed to facilitate the editing of % Docbook SGML files. It supports a large subset of Docbook % 3.1, as described in the LDP Author Guide % and % "Docbook: The Definive Guide" % Complete enough for writing Linux HOWTOs, manuals, and much % more... % For Jed 0.99.13+. % % Installation: if opening a document with .sgml extension doesn't toggle % docbook mode on, then insert these lines in your .jedrc: % % autoload ("docbook_mode", "docbook"); % add_mode_for_extension ("docbook", "sgml"); % % Last updated: 24 May 2001 WRAP_INDENTS = 1; % you really want this custom_variable ("SGML_INDENT", 2); custom_variable ("Sgml_Compile_PS_Cmd", "db2ps"); custom_variable ("Sgml_Compile_Pdf_Cmd", "db2pdf"); custom_variable ("Sgml_Compile_Html_Cmd", "db2html"); custom_variable ("Sgml_View_PS_Cmd", "gv"); custom_variable ("Sgml_View_Pdf_Cmd", "gv"); custom_variable ("Sgml_View_Html_Cmd", "netscape"); private variable NO_PUSH_SPOT = 0; private variable PUSH_SPOT = 1; private variable NO_POP_SPOT = 0; private variable POP_SPOT = 1; % buffer-local variables variable DOC_TYPE = "DOC_TYPE"; % "a" = article, "b" = book variable SECT_TYPE = "SECT_TYPE"; % "#" = sect#, "s" = section % ----- % !if (is_defined ("tex_ldots")) % read tex_insert_quote () = evalfile ("texcom"); private define sgml_insert_pair_around_region (left, right) { check_region (1); exchange_point_and_mark (); insert (left); exchange_point_and_mark (); insert (right); pop_spot (); pop_mark_0 (); } define sgml_skip_tag () % ^C^F { go_right_1 (); () = fsearch_char ('<'); } define sgml_bskip_tag () % ^C^B { () = bsearch_char ('<'); } private define sgml_insert_tags (tag1, tag2, do_push_spot, do_pop_spot) { % if a region is defined, insert the tags around it if (markp () ) { sgml_insert_pair_around_region (tag1, tag2); return; } insert (tag1); if (do_push_spot) push_spot (); insert (tag2); if (do_pop_spot) pop_spot (); } define sgml_insert_tag (tag, do_push_spot, do_pop_spot) { variable tag1, tag2; tag1 = sprintf ("<%s>", tag); tag2 = sprintf ("", tag); sgml_insert_tags (tag1, tag2, do_push_spot, do_pop_spot); } private define sgml_insert_tag_with_newline (tag, do_push_spot, do_pop_spot) { variable tag1, tag2; tag1 = sprintf ("<%s>", tag); tag2 = sprintf ("\n", tag); sgml_insert_tags (tag1, tag2, do_push_spot, do_pop_spot); } private define sgml_paragraph_separator () { variable cs = CASE_SEARCH; bol_skip_white (); CASE_SEARCH = 0; eolp () or ffind ("") or ffind (""); CASE_SEARCH = cs; } % let's start % Section stuff define sgml_para (do_push_spot) % ^CP { variable col = what_column () - 1; if (markp () ) { sgml_insert_pair_around_region ("\n", "\n"); return; } insert ("\n"); insert_spaces (col + SGML_INDENT); if (do_push_spot) push_spot (); insert ("\n"); insert_spaces (col); insert (""); } define sgml_title (tag, do_push_spot) { sgml_insert_tag_with_newline (tag, do_push_spot, NO_POP_SPOT); } private define sgml_section_skel (what_tag, do_push_spot) { variable col = what_column () - 1; vinsert ("<%s>\n", what_tag); insert_spaces (col); sgml_title ("title", do_push_spot); insert ("\n"); insert_spaces (col); sgml_para (NO_PUSH_SPOT); insert ("\n\n"); insert_spaces (col); vinsert ("", what_tag); if (do_push_spot) pop_spot (); } define sgml_chapter (do_push_spot) { sgml_section_skel ("chapter", do_push_spot); } define sgml_sidebar (do_push_spot) { sgml_section_skel ("sidebar", do_push_spot); } define sgml_appendix (do_push_spot) { sgml_section_skel ("appendix", do_push_spot); } define sgml_epigraph () { variable col = what_column () - 1; insert ("\n"); insert_spaces (col + SGML_INDENT); insert (""); push_spot (); insert ("\n"); insert_spaces (col + SGML_INDENT); sgml_para (NO_PUSH_SPOT); insert ("\n"); insert_spaces (col); insert ("\n"); pop_spot (); } define sgml_section () % ^CS { variable col = what_column () - 1; if ("#" == get_blocal_var (SECT_TYPE)) { beep (); error ("`section' not allowed in this environment!"); % !!! what about
and in Book doctype? return (); } set_blocal_var ("s", SECT_TYPE); sgml_section_skel ("section", PUSH_SPOT); } define sgml_simple_section () { sgml_section_skel ("simplesect", PUSH_SPOT); } define sgml_sect (do_push_spot, level_str) % ^CN { variable level_int; variable ok = 0; if ( ("s" == get_blocal_var (SECT_TYPE) ) and ("a" == get_blocal_var (DOC_TYPE) ) ) { beep (); error ("`sect' not allowed in this environment!"); return (); } set_blocal_var ("#", SECT_TYPE); !if (strcmp ("0", level_str) ) while (0 == ok) { level_str = read_mini ("Section level (1..5)?", Null_String, "1"); level_int = level_str [0] - '0'; if ( (level_int > 0) and (level_int < 6) ) ok = 1; !if (ok) { beep (); message ("Wrong value! Only 1..5 allowed. "); } } insert (sprintf ("\n"); sgml_title ("title", NO_PUSH_SPOT); insert ("\n"); sgml_para (NO_PUSH_SPOT); insert (sprintf ("\n\n\n", level_str)); if (do_push_spot) pop_spot (); } define sgml_formalpara () { sgml_section_skel ("formalpara", PUSH_SPOT); } % Header stuff define sgml_revision () { variable col = what_column () - 1; insert ("\n"); insert_spaces (col + SGML_INDENT); insert (""); push_spot (); % pop_spot () later insert ("\n"); insert_spaces (col + SGML_INDENT); sgml_insert_tag_with_newline ("date", NO_PUSH_SPOT, NO_POP_SPOT); insert_spaces (col + SGML_INDENT); sgml_insert_tag_with_newline ("authorinitial", NO_PUSH_SPOT, NO_POP_SPOT); insert_spaces (col + SGML_INDENT); insert ("\n"); insert_spaces (col + SGML_INDENT); insert ("\n"); insert_spaces (col + SGML_INDENT); insert ("\n"); insert_spaces (col); insert ("\n"); } define sgml_revision_history () { variable col = what_column () - 1; insert ("\n"); insert_spaces (col + SGML_INDENT); sgml_revision (); % the spot is pushed insert_spaces (col); insert (""); pop_spot (); } % Author stuff private define sgml_firstname (do_push_spot, do_pop_spot) { sgml_insert_tag_with_newline ("firstname", do_push_spot, do_pop_spot); } private define sgml_surname (do_push_spot, do_pop_spot) { sgml_insert_tag_with_newline ("surname", do_push_spot, do_pop_spot); } private define sgml_othername (do_push_spot, do_pop_spot) { sgml_insert_tag_with_newline ("othername", do_push_spot, do_pop_spot); } private define sgml_affiliation (do_push_spot, do_pop_spot) { variable col = what_column () - 1; insert ("\n"); insert_spaces (col + SGML_INDENT); sgml_insert_tag_with_newline ("shortaffil", do_push_spot, do_pop_spot); insert_spaces (col + SGML_INDENT); sgml_insert_tag_with_newline ("jobtitle", do_push_spot, do_pop_spot); insert_spaces (col + SGML_INDENT); sgml_insert_tag_with_newline ("orgname", do_push_spot, do_pop_spot); insert_spaces (col + SGML_INDENT); sgml_insert_tag_with_newline ("orgdiv", do_push_spot, do_pop_spot); insert_spaces (col); insert ("\n"); } private define sgml_honorific (do_push_spot, do_pop_spot) { sgml_insert_tag_with_newline ("honorific", do_push_spot, do_pop_spot); } define sgml_author (do_push_spot, do_pop_spot) { variable col = what_column () - 1; insert ("\n"); if (do_push_spot) push_spot (); insert_spaces (col + SGML_INDENT); sgml_honorific (do_push_spot, NO_POP_SPOT); insert_spaces (col + SGML_INDENT); sgml_firstname (do_push_spot, NO_POP_SPOT); insert_spaces (col + SGML_INDENT); sgml_othername (do_push_spot, NO_POP_SPOT); insert_spaces (col + SGML_INDENT); sgml_surname (do_push_spot, NO_POP_SPOT); insert_spaces (col + SGML_INDENT); sgml_affiliation (do_push_spot, NO_POP_SPOT); insert_spaces (col); insert ("\n"); if (do_pop_spot) pop_spot (); } define sgml_template () { variable col, ok, type, is_article = 0; col = what_column () - 1; ok = 0; while (0 == ok) { type = read_mini ("Document type (Article, Book)?", Null_String, "a"); if ( (type [0] == 'a') or (type [0] == 'b') ) ok = 1; !if (ok) { beep (); message ("Wrong! 'a' or 'b'! "); } } if (type [0] == 'a') { set_blocal_var ("a", DOC_TYPE); type = "article"; is_article = 1; } else { set_blocal_var ("b", DOC_TYPE); type = "book"; } vinsert ("", type); if (is_article) vinsert ("\n\n<%s lang=\"en\">\n<%s>\n\n", type, "artheader"); else vinsert ("\n\n<%s lang=\"en\">\n<%s>\n\n", type, "bookinfo"); insert_spaces (col + SGML_INDENT); sgml_title ("title", PUSH_SPOT); insert_spaces (col + SGML_INDENT); sgml_insert_tag_with_newline ("subtitle", NO_PUSH_SPOT, NO_POP_SPOT); insert_spaces (col + SGML_INDENT); sgml_author (NO_PUSH_SPOT, NO_POP_SPOT); insert_spaces (col + SGML_INDENT); insert ("
\n"); insert_spaces (col + 2 * SGML_INDENT); sgml_insert_tag_with_newline ("email", NO_PUSH_SPOT, NO_POP_SPOT); insert_spaces (col + SGML_INDENT); insert ("
\n"); insert_spaces (col + SGML_INDENT); sgml_insert_tag_with_newline ("pubdate", NO_PUSH_SPOT, NO_POP_SPOT); insert ("\n"); insert_spaces (col + SGML_INDENT); insert ("\n"); insert_spaces (col + 2 * SGML_INDENT); sgml_para (NO_PUSH_SPOT); insert ("\n"); insert_spaces (col + SGML_INDENT); insert ("\n"); if (is_article) { vinsert ("\n\n\n", "artheader"); insert ("\n"); } else { vinsert ("\n\n\n\n", "bookinfo"); insert ("\n\n\n"); sgml_para (NO_PUSH_SPOT); insert ("\n\n\n"); sgml_chapter (NO_PUSH_SPOT); } vinsert ("\n\n\n", type); pop_spot (); } define sgml_copyright () { variable col = what_column () - 1; insert_spaces (col); insert ("\n"); insert_spaces (col + SGML_INDENT); insert (""); push_spot (); insert ("\n"); insert_spaces (col + SGML_INDENT); insert ("\n"); insert_spaces (col); insert ("\n"); pop_spot (); } % character styles define sgml_directory () { insert (""); push_spot (); insert (""); pop_spot (); } % keys define sgml_keycombo (do_push_spot) { insert (""); if (do_push_spot) push_spot (); insert (""); if (do_push_spot) pop_spot (); } % gui/menus define sgml_menuchoice () { variable col = what_column () - 1; insert ("\n"); insert_spaces (col + SGML_INDENT); insert ("\n"); insert_spaces (col + 2 * SGML_INDENT); sgml_keycombo (NO_PUSH_SPOT); insert ("\n"); insert_spaces (col + SGML_INDENT); insert ("\n"); insert_spaces (col + SGML_INDENT); insert (""); push_spot (); insert ("\n"); insert_spaces (col + SGML_INDENT); insert ("\n"); insert_spaces (col); insert ("\n"); pop_spot (); } % computer-related define sgml_arg_plain (do_push_spot, do_pop_spot) { sgml_insert_tag ("arg", do_push_spot, do_pop_spot); } define sgml_arg (do_push_spot, do_pop_spot) { variable ch, rep, choice, tag1, tag2, sep1, sep2; choice = ""; rep = ""; sep1 = " "; sep2 = " "; flush ("Choice: Req Plain (Enter=nothing) "); ch = tolower (getkey ()); switch (ch) {case 'r': choice = "choice=req"; } {case 'p': choice = "req=plain"; } flush ("Rep: Repeat (Enter=nothing) "); ch = tolower (getkey ()); switch (ch) {case 'r': rep = "rep=repeat"; } !if (strlen(choice)) sep1= ""; !if (strlen(rep)) sep2= ""; tag1 = sprintf ("", sep1, choice, sep2, rep ); tag2 = ""; sgml_insert_tags (tag1, tag2, do_push_spot, do_pop_spot); } private define sgml_replaceable (do_push_spot, do_pop_spot) { sgml_insert_tag ("replaceable", do_push_spot, do_pop_spot); } define sgml_group () { variable col = what_column () - 1; insert ("\n"); insert_spaces (col + SGML_INDENT); sgml_arg (PUSH_SPOT, NO_POP_SPOT); insert ("\n"); insert_spaces (col); insert ("\n"); pop_spot (); } define sgml_cmdsynopsis () { variable col = what_column () - 1; insert ("\n"); insert_spaces (col + SGML_INDENT); insert (""); push_spot (); insert ("\n"); insert_spaces (col + SGML_INDENT); sgml_arg (NO_PUSH_SPOT); insert ("\n"); insert_spaces (col); insert ("\n"); pop_spot (); } % environments, sort of define sgml_blockquote () { variable col = what_column () - 1; insert ("
\n"); insert_spaces (col); insert (""); push_spot (); insert ("\n"); insert_spaces (col + SGML_INDENT); sgml_para (NO_PUSH_SPOT); insert ("\n"); insert_spaces (col); insert ("
"); pop_spot (); } define sgml_env (what) { variable col = what_column () - 1; vinsert ("<%s>\n", what); insert_spaces (col); !if (strcmp ("example", what)) { sgml_title ("title", PUSH_SPOT); insert_spaces (col + SGML_INDENT); sgml_para (NO_PUSH_SPOT); insert ("\n"); } else { insert_spaces (col + SGML_INDENT); sgml_para (PUSH_SPOT); insert ("\n"); } insert_spaces (col); vinsert ("\n", what); pop_spot (); } % links define sgml_id () { insert ("id=\""); push_spot (); insert ("\""); } define sgml_anchor () { insert (""); pop_spot (); } define sgml_url () { insert (""); pop_spot (); } define sgml_xref () { insert (""); pop_spot (); } % lists define sgml_listitem (do_push_spot) { variable col = what_column () - 1; insert ("\n"); insert_spaces (col + SGML_INDENT); sgml_para (do_push_spot); insert ("\n"); insert_spaces (col); insert (""); } define sgml_itemized_list () { variable col = what_column () - 1; insert ("\n"); insert_spaces (col + SGML_INDENT); sgml_listitem (PUSH_SPOT); insert ("\n"); insert_spaces (col); insert ("\n"); pop_spot (); } define sgml_ordered_list () { variable col = what_column () - 1; insert ("\n"); insert_spaces (col + SGML_INDENT); insert ("\n"); insert_spaces (col + 2 * SGML_INDENT); insert ("\n"); insert_spaces (col + 2 * SGML_INDENT); push_spot (); insert ("\n"); insert_spaces (col + 2 * SGML_INDENT); insert ("\n"); insert_spaces (col + SGML_INDENT); insert ("\n"); insert ("\n"); pop_spot (); } define sgml_varlistentry () { variable col = what_column () - 1; insert ("\n"); insert_spaces (col + SGML_INDENT); insert (""); push_spot (); % we'll do pop_spot () later insert ("\n"); insert_spaces (col + SGML_INDENT); insert ("\n"); insert_spaces (col + 2 * SGML_INDENT); sgml_para (NO_PUSH_SPOT); insert ("\n"); insert_spaces (col + SGML_INDENT); insert ("\n"); insert_spaces (col); insert ("\n"); } define sgml_variable_list () { variable col = what_column () - 1; insert ("\n"); insert_spaces (col + SGML_INDENT); sgml_varlistentry (); insert ("\n"); pop_spot (); } define sgml_seglistitem (do_push_spot) { variable col = what_column () - 1; insert ("\n"); insert_spaces (col + SGML_INDENT); insert (""); if (do_push_spot) push_spot (); insert ("\n"); insert_spaces (col); insert (""); } define sgml_segmented_list () { variable col = what_column () - 1; insert ("\n"); insert_spaces (col + SGML_INDENT); sgml_title ("title", push_spot); insert_spaces (col + SGML_INDENT); insert ("\n"); insert_spaces (col + SGML_INDENT); insert ("\n"); insert_spaces (col + SGML_INDENT); sgml_seglistitem (NO_PUSH_SPOT); insert ("\n"); insert_spaces (col); insert ("\n"); pop_spot (); } define sgml_step (do_push_spot) { variable col = what_column () - 1; insert ("\n"); insert_spaces (col + SGML_INDENT); sgml_para (do_push_spot); insert ("\n"); insert_spaces (col); insert (""); if (1 == do_push_spot) pop_spot (); } define sgml_procedure () { variable col = what_column () - 1; insert ("\n"); insert_spaces (col + SGML_INDENT); sgml_title ("title", PUSH_SPOT); insert_spaces (col + SGML_INDENT); sgml_step (NO_PUSH_SPOT); insert ("\n"); insert_spaces (col); insert ("\n"); pop_spot (); } % tables define sgml_table_row (table_col_int, do_push_spot) { variable i, col = what_column () - 1; insert ("\n"); for (i = 0; i < table_col_int; i++) { insert_spaces (col + SGML_INDENT); insert (""); if ( (do_push_spot) and (0 == i) ) push_spot (); insert ("\n"); } insert_spaces (col); insert (""); } define sgml_align () { variable ch, align; flush ("Align (Center cHar Justify Left Right)? "); ch = tolower (getkey ()); switch (ch) {case 'c': align = "center"; } {case 'h': align = "char"; } {case 'j': align = "justify"; } {case 'l': align = "left"; } {case 'r': align = "right"; } vinsert ("align=\"%s\"", align); } % static private variable table_columns = 4; define sgml_table (informal_table) { variable col = what_column () - 1; variable i, ch, frame, type_of_table, table_col_str, ok; if (informal_table) type_of_table = "informaltable"; else type_of_table = "table"; flush ("Frame (All, Bottom, None, Sides, Top, tOpbot)? "); ch = tolower (getkey ()); switch (ch) {case 'a': frame = "all"; } {case 'b': frame = "bottom"; } {case 'n': frame = "none"; } {case 's': frame = "sides"; } {case 't': frame = "top"; } {case 'o': frame = "topbot"; } ok = 0; while (0 == ok) { table_col_str = read_mini ("Columns?", Null_String, "4"); table_columns = table_col_str [0] - '0'; if ( (table_columns > 1) and (table_columns < 10) ) ok = 1; !if (ok) { beep (); message ("Wrong value! "); } } vinsert ("<%s frame=\"%s\">\n", type_of_table, frame); !if (informal_table) sgml_title ("title", PUSH_SPOT); else push_spot (); insert_spaces (col + SGML_INDENT); insert (sprintf ("\n\n", table_col_str)); for (i = 0; i < table_columns; i++) { insert_spaces (col + SGML_INDENT); vinsert ("\n", string (i+1) ); } !if (informal_table) { insert_spaces (col + SGML_INDENT); insert ("\n"); insert_spaces (col + SGML_INDENT); sgml_table_row (table_columns, NO_PUSH_SPOT); insert ("\n"); insert_spaces (col + SGML_INDENT); insert ("\n"); insert_spaces (col + SGML_INDENT); insert ("\n"); insert_spaces (col + SGML_INDENT); insert ("\n"); for (i = 0; i < table_columns; i++) { insert_spaces (col + 2 * SGML_INDENT); insert ("\n"); } insert_spaces (col + SGML_INDENT); insert ("\n"); insert_spaces (col + SGML_INDENT); insert ("\n"); } insert_spaces (col + SGML_INDENT); insert ("\n"); insert_spaces (col + SGML_INDENT); insert ("\n"); for (i = 0; i < table_columns; i++) { insert_spaces (col + 2 * SGML_INDENT); insert ("\n"); } insert_spaces (col + SGML_INDENT); insert ("\n"); insert_spaces (col + SGML_INDENT); insert ("\n"); insert_spaces (col + SGML_INDENT); insert ("\n"); insert_spaces (col); vinsert ("\n", type_of_table); pop_spot (); } % figures define sgml_figure () { variable i, col = what_column () - 1; insert ("
\n"); insert_spaces (col + SGML_INDENT); insert (""); push_spot (); insert ("\n"); insert_spaces (col + SGML_INDENT); insert ("\n"); for (i = 0; i < 2; i++) { insert_spaces (col + 2 * SGML_INDENT); insert ("\n"); insert_spaces (col + 3 * SGML_INDENT); insert ("\n"); insert_spaces (col + 2 * SGML_INDENT); insert ("\n"); } insert_spaces (col + 2 * SGML_INDENT); insert ("\n"); insert_spaces (col + 3 * SGML_INDENT); insert ("\n"); insert_spaces (col + 2 * SGML_INDENT); insert ("\n"); insert_spaces (col + SGML_INDENT); insert ("\n"); insert_spaces (col); insert ("
\n"); pop_spot (); } define insert_sgml_screen () { % this function is redundant, but I can't find a way to pass % Width="80" through menu_append_item sgml_insert_tags ("\n", "\n", PUSH_SPOT, NO_POP_SPOT); } define sgml_convert_to_ps () { variable mrk, cmd; mrk = create_user_mark; cmd = sprintf ("%s %s", Sgml_Compile_PS_Cmd, mrk.buffer_name); cmd = read_mini ("Convert command:", Null_String, cmd); compile (cmd); } define sgml_convert_to_pdf () { variable mrk, cmd; mrk = create_user_mark; cmd = sprintf ("%s %s", Sgml_Compile_Pdf_Cmd, mrk.buffer_name); cmd = read_mini ("Convert command:", Null_String, cmd); compile (cmd); } define sgml_convert_to_html () { variable mrk, cmd; mrk = create_user_mark; cmd = sprintf ("%s %s", Sgml_Compile_Html_Cmd, mrk.buffer_name); cmd = read_mini ("Convert command:", Null_String, cmd); compile (cmd); } define sgml_view (type) { variable mrk, cmd, tmp; mrk = create_user_mark; tmp = mrk.buffer_name; (tmp, ) = strreplace (tmp, "sgml", type, -1); switch (type) { case "ps": cmd = sprintf ("%s %s &", Sgml_View_PS_Cmd, tmp); } { case "pdf": cmd = sprintf ("%s %s &", Sgml_View_Pdf_Cmd, tmp); } { case "html": cmd = sprintf ("%s %s &", Sgml_View_Html_Cmd, tmp); } cmd = read_mini ("View with:", Null_String, cmd); #ifdef UNIX () = system (cmd); #else () = run_shell_cmd (cmd); #endif } % let's finish % defining keywords is not necessary, since all the highlighting is % done by the second and third define_syntax (). Rough, but fairly nice. $1 = "docbook"; create_syntax_table ($1); define_syntax ("\"([{<", "\")]}>", '(', $1); define_syntax ('<', '\\', $1); define_syntax ('&', '\\', $1); define_syntax ("0-9A-Za-z>/!", 'w', $1); define_syntax ("<>", '<', $1); define_syntax ("", '%', $1); % copied from html mode. #ifdef HAS_DFA_SYNTAX % The highlighting copes with comments, "ð" type things, and type % HTML tags. An unrecognised &..; construct or an incomplete <...> construct % is flagged in delimiter colour. %%% DFA_CACHE_BEGIN %%% private define setup_dfa_callback (name) { dfa_enable_highlight_cache ("docbook.dfa", name); dfa_define_highlight_rule ("", "Qcomment", name); dfa_define_highlight_rule ("^([^\\-]|-+[^>])*-+[ \t]*>", "Qcomment", name); dfa_define_highlight_rule ("\"]|\"[^\"]*\")*>", "keyword", name); dfa_define_highlight_rule ("<([^>\"]|\"[^\"]*\")*(\"[^\"]*)?$", "delimiter", name); dfa_define_highlight_rule ("&#[0-9]+;", "keyword1", name); dfa_define_highlight_rule ("&[A-Za-z]+;", "Kdelimiter", name); dfa_define_highlight_rule (".", "normal", name); dfa_build_highlight_table (name); } dfa_set_init_callback (&setup_dfa_callback, "docbook"); %%% DFA_CACHE_END %%% #endif private define init_menu (menu) { % header menu_append_popup (menu, "&Header"); variable m = sprintf ("%s.&Header", menu); menu_append_item (m, "<&ackno>", "sgml_insert_tag (\"ackno\", 1, 1)"); menu_append_item (m, "", "sgml_author (1, 1)"); menu_append_item (m, "<©right>", "sgml_copyright ()"); menu_append_item (m, "", "sgml_revision_history ()"); menu_append_item (m, "<&revision>", "sgml_revision (); pop_spot ()"); menu_append_item (m, "&Template", "sgml_template ()"); % sections menu_append_popup (menu, "&Section"); m = sprintf ("%s.&Section", menu); menu_append_item (m, "<&appendix>", "sgml_appendix (1)"); menu_append_item (m, "<&chapter>", "sgml_chapter (1)"); menu_append_item (m, "<&epigraph>", "sgml_epigraph ()"); menu_append_item (m, "<&formalpara>", "sgml_formalpara ()"); menu_append_item (m, "", "sgml_simple_section ()"); menu_append_item (m, "&numbered section", "sgml_sect (1, \"0\")"); menu_append_item (m, "<§ion>", "sgml_section ()"); menu_append_item (m, "", "sgml_sidebar (1)"); menu_append_item (m, "<&title>", "sgml_title (\"title\", 1); pop_spot ()"); menu_append_item (m, "", "sgml_title (\"subtitle\", 1); pop_spot ()"); % character menu_append_popup (menu, "&Character"); m = sprintf ("%s.&Character", menu); menu_append_item (m, "<&acronym>", "sgml_insert_tag (\"acronym\", 1, 1)"); menu_append_item (m, "<&citation>", "sgml_insert_tag (\"citation\", 1, 1)"); menu_append_item (m, "<&emphasis>", "sgml_insert_tag (\"emphasis\", 1, 1)"); menu_append_item (m, "<&firstterm>", "sgml_insert_tag (\"firstterm\", 1, 1)"); menu_append_item (m, "", "sgml_insert_tag (\"footnote\", 1, 1)"); menu_append_item (m, "<&superscript>", "sgml_insert_tag (\"superscript\", 1, 1)"); menu_append_item (m, "", "sgml_insert_tag (\"subscript\", 1, 1)"); % computer menu_append_popup (menu, "C&omputer"); m = sprintf ("%s.C&omputer", menu); menu_append_item (m, "<&application>", "sgml_insert_tag (\"application\", 1, 1)"); menu_append_item (m, "", "sgml_insert_tag (\"mousebutton\", 1, 1)"); menu_append_item (m, "<&command>", "sgml_insert_tag (\"command\", 1, 1)"); menu_append_item (m, "&directory", "sgml_directory ()"); menu_append_item (m, "<&envar>", "sgml_insert_tag (\"envar\", 1, 1)"); menu_append_item (m, "<&filename>", "sgml_insert_tag (\"filename\", 1, 1)"); menu_append_item (m, "", "sgml_insert_tag (\"function\", 1, 1)"); menu_append_item (m, "", "sgml_insert_tag (\"programlisting\", 1, 1)"); menu_append_item (m, "", "sgml_insert_tag (\"computeroutput\", 1, 1)"); menu_append_item (m, "", "sgml_insert_tag (\"constant\", 1, 1)"); menu_append_item (m, "<&prompt>", "sgml_insert_tag (\"prompt\", 1, 1)"); menu_append_item (m, "<&screen>", "insert_sgml_screen ()"); menu_append_item (m, "<&userinput>", "sgml_insert_tag (\"userinput\", 1, 1)"); menu_append_item (m, "<&varname>", "sgml_insert_tag (\"varname\", 1, 1)"); % computer: popups menu_append_popup (m, "&Menu"); menu_append_popup (m, "&Keys"); menu_append_popup (m, "CmdS&ynopsis"); % computer/menu m = sprintf ("%s.C&omputer.&Menu", menu); menu_append_item (m, "<&accel>", "sgml_insert_tag (\"accel\", 1, 1)"); menu_append_item (m, "", "sgml_menuchoice ()"); menu_append_item (m, "<&guimenu>", "sgml_insert_tag (\"guimenu\", 1, 1)"); menu_append_item (m, "", "sgml_insert_tag (\"guimenuitem\", 1, 1)"); % computer/keys m = sprintf ("%s.C&omputer.&Keys", menu); menu_append_item (m, "", "sgml_insert_tag (\"keycap\", 1, 1)"); menu_append_item (m, "", "sgml_insert_tag (\"keysym\", 1, 1)"); menu_append_item (m, "", "sgml_insert_tag (\"keycode\", 1, 1)"); menu_append_item (m, "", "sgml_keycombo (1)"); % computer/cmdsynopsis m = sprintf ("%s.C&omputer.CmdS&ynopsis", menu); menu_append_item (m, "<&arg>", "sgml_arg (1, 1)"); menu_append_item (m, "<&break>", "insert (\"\\n\")"); menu_append_item (m, "", "sgml_cmdsynopsis ()"); menu_append_item (m, "&plain ", "sgml_arg_plain (1, 1)"); menu_append_item (m, "<&group>", "sgml_group ()"); menu_append_item (m, "<&replaceable>", "sgml_insert_tag (\"replaceable\", 1, 1)"); % environment menu_append_popup (menu, "&Environment"); m = sprintf ("%s.&Environment", menu); menu_append_item (m, "<&blockquote>", "sgml_blockquote ()"); menu_append_item (m, "<&caution>", "sgml_env (\"caution\")"); menu_append_item (m, "<&example>", "sgml_env (\"example\")"); menu_append_item (m, "<&important>", "sgml_env (\"important\")"); menu_append_item (m, "<¬e>", "sgml_env (\"note\")"); menu_append_item (m, "<&tip>", "sgml_env (\"tip\")"); menu_append_item (m, "<&warning>", "sgml_env (\"warning\")"); % links menu_append_popup (menu, "Lin&k"); m = sprintf ("%s.Lin&k", menu); menu_append_item (m, "<&anchor>", "sgml_anchor ()"); menu_append_item (m, "<&email>", "sgml_insert_tag (\"email\")"); menu_append_item (m, "<&id>", "sgml_id (); pop_spot ()"); menu_append_item (m, "<&url>", "sgml_url ()"); menu_append_item (m, "<&xref>", "sgml_xref ()"); % lists menu_append_popup (menu, "&List"); m = sprintf ("%s.&List", menu); menu_append_item (m, "<&itemizedlist>", "sgml_itemized_list ()"); menu_append_item (m, "<&listitem>", "sgml_listitem (1); pop_spot ()"); menu_append_item (m, "<&orderedlist>", "sgml_ordered_list ()"); menu_append_item (m, "<&segmentedlist>", "sgml_segmented_list ()"); menu_append_item (m, "<&variablelist>", "sgml_variable_list ()"); menu_append_item (m, "", "sgml_varlistentry (); pop_spot ()"); menu_append_item (m, "", "sgml_seglistitem (1); pop_spot ()"); menu_append_item (m, "<&procedure>", "sgml_procedure ()"); menu_append_item (m, "", "sgml_step (1)"); % table menu_append_popup (menu, "&Table"); m = sprintf ("%s.&Table", menu); menu_append_item (m, "<&align>", "sgml_align ()"); menu_append_item (m, "<&informaltable>", "sgml_table (1)"); menu_append_item (m, "<&table>", "sgml_table (0)"); menu_append_item (m, "<&row>", "sgml_table_row (table_columns, 1, 1); pop_spot ()"); % paragraph menu_append_item (menu, "<¶>", "sgml_para (1); pop_spot ()"); % figure menu_append_item (menu, "<&figure>", "sgml_figure ()"); % separator menu_append_separator (menu); % convert to... menu_append_item (menu, "Convert To &PostScript", "sgml_convert_to_ps ()"); menu_append_item (menu, "Convert To P&DF", "sgml_convert_to_pdf ()"); menu_append_item (menu, "Convert To &HTML", "sgml_convert_to_html ()"); menu_append_item (menu, "&View PostScript", "sgml_view (\"ps\")"); menu_append_item (menu, "View PDF", "sgml_view (\"ps\")"); menu_append_item (menu, "V&iew HTML", "sgml_view (\"html\")"); } $1 = "docbook"; !if (keymap_p ($1)) make_keymap ($1); % various keymaps definekey_reserved ("sgml_bskip_tag", "^B", $1); definekey_reserved ("sgml_skip_tag", "^F", $1); definekey_reserved ("sgml_para (1); pop_spot ()", "p", $1); definekey_reserved ("sgml_section ()", "ss", $1); definekey_reserved ("sgml_sect (1, \"0\"))", "sn", $1); definekey_reserved ("insert (\"$\")", "$", $1); definekey_reserved ("insert (\"&\")", "&", $1); definekey_reserved ("sgml_comment", ";", $1); definekey_reserved ("insert (\"…\")", ".", $1); definekey_reserved ("insert (\"<\")", "<", $1); definekey_reserved ("insert (\">\")", ">", $1); definekey_reserved ("sgml_convert_to_ps ()", "cp", $1); definekey_reserved ("sgml_convert_to_pdf ()", "cd", $1); definekey_reserved ("sgml_convert_to_html ()", "ch", $1); definekey_reserved ("sgml_convert_to_ps ()", "cp", $1); definekey_reserved ("sgml_view (\"ps\")", "vp", $1); definekey_reserved ("sgml_view (\"pdf\")", "vd", $1); definekey_reserved ("sgml_view (\"html\")", "vh", $1); % template definekey_reserved ("sgml_insert_tag (\"ackno\", 1, 1)", "ha", $1); definekey_reserved ("sgml_author (1, 1)", "hu", $1); definekey_reserved ("sgml_copyright ()", "hc", $1); definekey_reserved ("sgml_revision_history ()", "hh", $1); definekey_reserved ("sgml_revision (); pop_spot ()", "hr", $1); definekey_reserved ("sgml_template ()", "ht", $1); % section definekey_reserved ("sgml_appendix (1)", "sa", $1); definekey_reserved ("sgml_chapter (1)", "sc", $1); definekey_reserved ("sgml_epigraph ()", "se", $1); definekey_reserved ("sgml_formalpara ()", "sf", $1); definekey_reserved ("sgml_simple_section ()", "sm", $1); definekey_reserved ("sgml_sect (1, \"0\")", "sn", $1); definekey_reserved ("sgml_sidebar (1)", "si", $1); definekey_reserved ("sgml_title (\"title\", 1); pop_spot ()", "st", $1); definekey_reserved ("sgml_title (\"subtitle\", 1); pop_spot ()", "su", $1); % character definekey_reserved ("sgml_insert_tag (\"acronym\", 1, 1)", "ca", $1); definekey_reserved ("sgml_insert_tag (\"citation\", 1, 1)", "cc", $1); definekey_reserved ("sgml_insert_tag (\"emphasis\", 1, 1)", "ce", $1); definekey_reserved ("sgml_insert_tag (\"firstterm\", 1, 1)", "cf", $1); definekey_reserved ("sgml_insert_tag (\"footnote\", 1, 1)", "cn", $1); definekey_reserved ("sgml_insert_tag (\"superscript\", 1, 1)", "cs", $1); definekey_reserved ("sgml_insert_tag (\"subscript\", 1, 1)", "cu", $1); % computer definekey_reserved ("sgml_insert_tag (\"application\", 1, 1)", "oa", $1); definekey_reserved ("sgml_insert_tag (\"mousebutton\", 1, 1)", "ob", $1); definekey_reserved ("sgml_insert_tag (\"command\", 1, 1)", "oc", $1); definekey_reserved ("sgml_directory ()", "od", $1); definekey_reserved ("sgml_insert_tag (\"envar\", 1, 1)", "oe", $1); definekey_reserved ("sgml_insert_tag (\"filename\", 1, 1)", "of", $1); definekey_reserved ("sgml_insert_tag (\"function\", 1, 1)", "on", $1); definekey_reserved ("sgml_insert_tag (\"programlisting\", 1, 1)", "ol", $1); definekey_reserved ("sgml_insert_tag (\"computeroutput\", 1, 1)", "oo", $1); definekey_reserved ("sgml_insert_tag (\"constant\", 1, 1)", "ot", $1); definekey_reserved ("sgml_insert_tag (\"prompt\", 1, 1)", "op", $1); definekey_reserved ("insert_sgml_screen ()", "os", $1); definekey_reserved ("sgml_insert_tag (\"userinput\", 1, 1)", "ou", $1); definekey_reserved ("sgml_insert_tag (\"varname\", 1, 1)", "ov", $1); % environment definekey_reserved ("sgml_blockquote ()", "eb", $1); definekey_reserved ("sgml_env (\"caution\")", "ec", $1); definekey_reserved ("sgml_env (\"example\")", "ee", $1); definekey_reserved ("sgml_env (\"important\")", "ei", $1); definekey_reserved ("sgml_env (\"note\")", "en", $1); definekey_reserved ("sgml_env (\"tip\")", "et", $1); definekey_reserved ("sgml_env (\"warning\")", "ew", $1); % links definekey_reserved ("sgml_anchor ()", "ka", $1); definekey_reserved ("sgml_insert_tag (\"email\")", "ke", $1); definekey_reserved ("sgml_id (); pop_spot ()", "ki", $1); definekey_reserved ("sgml_url ()", "ku", $1); definekey_reserved ("sgml_xref ()", "kx", $1); % lists definekey_reserved ("sgml_itemized_list ()", "li", $1); definekey_reserved ("sgml_listitem (1); pop_spot ()", "ll", $1); definekey_reserved ("sgml_ordered_list ()", "lo", $1); definekey_reserved ("sgml_segmented_list ()", "ls", $1); definekey_reserved ("sgml_variable_list ()", "lv", $1); definekey_reserved ("sgml_varlistentry (); pop_spot ()", "le", $1); definekey_reserved ("sgml_seglistitem (1); pop_spot ()", "lg", $1); definekey_reserved ("sgml_procedure ()", "lp", $1); definekey_reserved ("sgml_step (1)", "lt", $1); % table definekey_reserved ("sgml_align ()", "ta", $1); definekey_reserved ("sgml_table (1)", "ti", $1); definekey_reserved ("sgml_table (0)", "tt", $1); definekey_reserved ("sgml_table_row (table_columns, 1, 1); pop_spot ()", "tr", $1); definekey_reserved ("sgml_figure ()", "f", $1); definekey ("tex_insert_quote", "\"", $1); definekey ("tex_insert_quote", "'", $1); %!%+ %\function{docbook_mode} %\synopsis{docbook_mode} %\usage{Void docbook_mode ();} %\description % This mode is designed to facilitate the editing of Docbook 3.1 SGML files. % If a region is defined (i.e., if a mark is set), many SGML tags will % insert around the region; e.g. '' and ''. Tags are % inserted either using the Mode menu, or with a key combination resembling % the menu entry, e.g. ^Cce inserts (M&ode/&Character/<&emphasis>). % Functions that affect this mode include (Emacs mode assumed - IDE mode % uses ^Z instead of ^C): %#v+ % sgml_bskip_tag ^C^B % sgml_skip_tag ^C^F % sgml_para ^CP % sgml_section ^CS % sgml_sect ^CN % insert $ ^C$ % insert & ^C& % insert … ^C. % insert < ^C< % insert > ^C> %#v- % Variables affecting this mode include: %#v+ % Variable Default value % % SGML_INDENT 2 % Sgml_Compile_PS_Cmd "db2ps" % Sgml_Compile_Pdf_Cmd "db2pdf" % Sgml_Compile_Html_Cmd "db2html" % Sgml_View_PS_Cmd "gv" % Sgml_View_Pdf_Cmd "gv" % Sgml_View_Html_Cmd "netscape" %#v- % To change the value of a variable, define that variable in .jedrc % before loading docbook.sl. For example: %#v+ % variable SGML_INDENT = 3; %#v- % Hooks: \var{sgml_mode_hook} %!%- define docbook_mode () { variable mode = "docbook"; set_mode (mode, 1); % wrap mode use_keymap (mode); set_syntax_flags (mode, 8); use_syntax_table (mode); set_buffer_hook ("par_sep", &sgml_paragraph_separator); !if (blocal_var_exists (DOC_TYPE)) define_blocal_var (DOC_TYPE, ""); !if (blocal_var_exists (SECT_TYPE)) define_blocal_var (SECT_TYPE, ""); push_spot (); % is the document type already defined? bob (); variable cs = CASE_SEARCH; CASE_SEARCH = 0; if (fsearch ("= fold_level); if (fold_is_marker_line (start, end_of_start)) level++; else if (fold_is_marker_line (end, end_of_end)) { if (level == start_level) break; level--; } } } %}}} define fold_open_buffer () %{{{ { push_spot (); widen_buffer (); mark_buffer (); set_region_hidden (0); pop_spot (); } %}}} define fold_whole_buffer () %{{{ { variable start, end, end_of_start, end_of_end; variable level, fold_level; flush ("folding buffer..."); ERROR_BLOCK { pop_spot (); } push_spot (); fold_open_buffer (); bob (); (start, end, end_of_start, end_of_end) = fold_get_marks (); fold_level = prefix_argument (-1); if (fold_level <= 0) fold_level = 1; while (fold_find_marker_line (start, end_of_start)) { fold_this_fold (start, end, end_of_start, end_of_end, 1, fold_level); !if (down_1 ()) break; } pop_spot (); if (is_line_hidden ()) { skip_hidden_lines_backward (1); bol (); } flush ("folding buffer...done"); } %}}} private define fold_is_fold (start, end_of_start) %{{{ { push_spot (); EXIT_BLOCK { pop_spot (); } !if (fold_is_marker_line (start, end_of_start)) return 0; % Check to make sure this is not the top of the current fold by making % sure that the next line is hidden. !if (down_1 ()) return 0; return is_line_hidden (); } %}}} define fold_open_fold () %{{{ { variable start, end, end_of_start, end_of_end; (start, end, end_of_start, end_of_end) = fold_get_marks (); push_spot (); if (is_line_hidden ()) skip_hidden_lines_backward (1); if (fold_is_fold (start, end_of_start)) { fold_this_fold (start, end, end_of_start, end_of_end, 0, 1); } pop_spot (); } %}}} define fold_enter_fold () %{{{ { variable start, end, end_of_start, end_of_end; variable h; (start, end, end_of_start, end_of_end) = fold_get_marks (); push_spot (); while (fold_find_marker_line_reverse (start, end_of_start, 1)) { push_mark (); if (fold_is_fold (start, end_of_start)) { fold_this_fold (start, end, end_of_start, end_of_end, 0, 1); narrow (); bob (); } else { pop_mark_1 (); break; } goto_spot (); !if (is_line_hidden ()) break; } pop_spot (); } %}}} define fold_close_this_fold () %{{{ { variable start, end, end_of_start, end_of_end; (start, end, end_of_start, end_of_end) = fold_get_marks (); !if (fold_find_marker_line (start, end_of_start)) error ("Unable to find fold-start"); fold_this_fold (start, end, end_of_start, end_of_end, 1, 1); skip_hidden_lines_backward (1); } %}}} #iffalse define fold_close_fold () %{{{ { variable start, end, end_of_start, end_of_end; variable beg_mark, end_mark, orig_mark; variable not_in_a_fold = "Not in a fold."; variable end_line; (start, end, end_of_start, end_of_end) = fold_get_marks (); orig_mark = create_user_mark (); ERROR_BLOCK { goto_user_mark (orig_mark); } EXIT_BLOCK { fold_this_fold (start, end, end_of_start, end_of_end, 1, 1); skip_hidden_lines_backward (1); } if (fold_is_marker_line (start, end_of_start)) { !if (down_1()) return; is_line_hidden(); goto_user_mark (orig_mark); !if (()) return; } beg_mark = create_user_mark (); if (fold_is_marker_line (end, end_of_end)) go_up_1 (); end_mark = create_user_mark (); forever { goto_user_mark (end_mark); end_line = 0; if (fold_find_marker_line_reverse (end, end_of_end, 0)) { if (up_1 ()) end_line = what_line (); move_user_mark (end_mark); } goto_user_mark (beg_mark); !if (up_1 ()) break; if (fold_find_marker_line_reverse (start, end_of_start, 0)) { if (not(end_line) or (what_line () > end_line)) break; move_user_mark (beg_mark); } else error (not_in_a_fold); } } %}}} #else define fold_close_fold () %{{{ { variable start, end, end_of_start, end_of_end; variable beg_mark, end_mark; variable not_in_a_fold = "Not in a fold."; variable end_line; (start, end, end_of_start, end_of_end) = fold_get_marks (); push_spot(); if ( # if (_slang_version >= 20100) fold_is_marker_line (start, end_of_start) && down_1() # else andelse {fold_is_marker_line (start, end_of_start)}{down_1()} # endif ) { is_line_hidden(); go_up_1(); !if (()) { fold_this_fold (start, end, end_of_start, end_of_end, 1, 1); pop_spot(); return; } } beg_mark = create_user_mark (); end_mark = create_user_mark (); forever { if ( # if (_slang_version >= 20100) up_1() && fold_find_marker_line_reverse (end, end_of_end, 0) # else andelse {up_1()}{fold_find_marker_line_reverse (end, end_of_end, 0)} # endif ) { end_line = what_line (); move_user_mark (end_mark); } else end_line= 0; goto_user_mark (beg_mark); if ( # if (_slang_version >= 20100) up_1() && fold_find_marker_line_reverse (start, end_of_start, 0) # else andelse{up_1()}{fold_find_marker_line_reverse (start, end_of_start, 0)} # endif ) { move_user_mark (beg_mark); if ( what_line () > end_line) break; } else { pop_spot (); error (not_in_a_fold); } goto_user_mark (end_mark); } fold_this_fold (start, end, end_of_start, end_of_end, 1, 1); pop_spot(); goto_user_mark (beg_mark); bol(); } %}}} #endif private define fold_exit_fold_internal () %{{{ { !if (count_narrows ()) { error ("You are not in a fold."); return; } bob (); widen (); fold_close_this_fold (); } %}}} define fold_exit_fold () %{{{ { fold_exit_fold_internal (); recenter (window_info ('r') / 2); } %}}} define fold_fold_region () %{{{ { variable start, end, end_of_start, end_of_end; check_region (0); (start, end, end_of_start, end_of_end) = fold_get_marks (); % We have a canonical region with point at end. See if this line % is the start of a fold. If so, extend it to cover all of fold. if (fold_is_fold (start, end_of_start)) { skip_hidden_lines_forward (1); !if (is_line_hidden ()) go_up_1 (); } narrow (); eob (); newline (); insert (end); insert (end_of_end); newline (); bob (); % Now look at position of beginning of region. If it does not occur on % a blank line, put fold marks at end of line. skip_white (); if (eolp ()) { bol (); insert (start); push_spot (); insert (end_of_start); newline (); } else { eol (); trim (); insert_single_space (); insert (start); insert (end_of_start); bol (); push_spot (); } fold_exit_fold_internal (); pop_spot (); } %}}} %}}} define fold_parse_errors () %{{{ { variable folded; % compile_parse_errors will widen buffer the buffer. As a result, when it % returns, the buffer will be unfolded but some lines may be hidden. Simply % unhide all lines. Also take care to reenter a fold only if buffer is not % folded. compile_parse_errors (); push_spot (); eob (); skip_hidden_lines_backward (0); folded = is_line_hidden (); pop_spot (); if (folded) { push_spot (); fold_open_buffer (); fold_whole_buffer (); pop_spot (); if (is_line_hidden ()) fold_enter_fold (); } } %}}} #ifdef HAS_BLOCAL_VAR define fold_goto_bookmark_hook (mrk) %{{{ { variable folded; while (not (is_user_mark_in_narrow (mrk))) fold_exit_fold_internal (); goto_user_mark (mrk); fold_enter_fold (); } %}}} #endif define fold_bob_eob_error_hook (f) %{{{ { variable str = "Top Of Buffer."; variable start, end, end_of_start, end_of_end; if (f > 0) str = "End Of Buffer."; !if (Fold_Bob_Eob_Error_Action) error (str); !if (count_narrows () and (abs(f) == 1)) error (str); fold_exit_fold (); % The rest of this function is should be made optional, e.g., % if (Optional_Flag) return; if (Fold_Bob_Eob_Error_Action == 1) return; bol (); if (f > 0) { skip_hidden_lines_forward (1); skip_chars (" \t\n"); } else { bskip_chars (" \t\n"); skip_hidden_lines_backward (1); } (start, end, end_of_start, end_of_end) = fold_get_marks (); if (fold_is_fold (start, end_of_start)) fold_enter_fold (); } %}}} %{{{ mouse interface $1 = "mouse_goto_position"; $2 = "mouse"; !if (is_defined ($1)) autoload ($1, $2); define fold_mouse_2click (line, col, but, shift) %{{{ { variable start, end, end_of_start, end_of_end; if (but == 1) { (start, end, end_of_start, end_of_end) = fold_get_marks (); mouse_goto_position (col, line); ERROR_BLOCK { _clear_error (); } if (fold_is_fold (start, end_of_start)) fold_enter_fold (); else fold_exit_fold (); return 1; } return -1; } %}}} %}}} define fold_goto_line () { variable n = read_mini ("Goto Line:", "", ""); !if (strlen (n)) return; n = integer (n); fold_open_buffer (); goto_line (n); } %{{{ Interactive searching functions define fold_search_line_ok () %{{{ { not (is_line_hidden ()); } %}}} $1 = "search_generic_search"; $2 = "search"; !if (is_defined ($1)) autoload ($1, $2); define fold_search_backward () %{{{ { search_generic_search ("Fold search backward:", -1, &fold_search_line_ok); } %}}} define fold_search_forward () %{{{ { search_generic_search ("Fold search forward:", 1, &fold_search_line_ok); } %}}} %}}} 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 (); define_blocal_var ("fold_start", s); define_blocal_var ("fold_end_of_start", s1); define_blocal_var ("fold_end", e); define_blocal_var ("fold_end_of_end", e1); define_blocal_var ("bookmark_narrow_hook", ".fold_goto_bookmark_hook"); #endif local_setkey_reserved ("fold_whole_buffer", "^W"); local_setkey_reserved ("fold_enter_fold", ">"); local_setkey_reserved ("fold_exit_fold", "<"); local_setkey_reserved ("fold_open_buffer", "^O"); local_setkey_reserved ("fold_open_fold", "^S"); local_setkey_reserved ("fold_close_fold", "^X"); local_setkey_reserved ("fold_fold_region", "^F"); local_setkey_reserved ("fold_search_forward", "f"); local_setkey_reserved ("fold_search_backward", "b"); set_buffer_hook ("bob_eob_error_hook", "fold_bob_eob_error_hook"); #iffalse set_buffer_hook ("mouse_2click", "fold_mouse_2click"); #endif loop (which_key ("compile_parse_errors")) { local_setkey ("fold_parse_errors", exch ()); } fold_whole_buffer (); run_mode_hooks ("fold_mode_hook"); } %}}} define c_fold_buffer () %{{{ { bob (); !if (ffind ("mode: fold")) { insert ("/* -*- mode: C; mode: fold; -*- */\n"); } folding_mode (); fold_open_buffer (); while (bol_fsearch ("{")) { eol (); push_mark (); go_up_1 (); % at eol !if (re_bsearch ("^[a-z_A-Z]")) { pop_mark_1 (); continue; } if (ffind ("{{{")) { pop_mark_1 (); continue; } exchange_point_and_mark (); !if (bol_fsearch ("}")) { pop_mark_1 (); error ("Matching } at bol not found."); } go_down_1 (); trim (); !if (eolp ()) { newline (); go_up_1 (); } push_spot (); fold_fold_region (); pop_spot (); } fold_whole_buffer (); bob (); } %}}} % Fold menu support private 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"); } private 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); jed-0.99-19/lib/perl.sl0000644002657400265740000010335211311317447013546 0ustar davisdavis% this -*- SLang -*- file defines syntax/indentation for Perl programs % ------------------------------------------------------------------------ % % NB: no automatic brace '{' handling! otherwise constructs such as % '@foo = @{$arrayref}', and '%foo = %{$hashref}' are a nightmare! % % - Because of how the internal syntax highlighting is implemented % (ask John about details), it's only possible to use either % '=pod' or '=head' in the highlighting, but not both. % % Many (most) modules simply use '=head', but if you're mixing code % and documentation a lot, the '=pod' directive is extremely handy. % Although perl understands it when you start a pod chunk with any % '=foo' tag, the editor does not. % For this case use '=pod' as an introducer to trigger pod. % NB: you couldn't use '=head' here! % See perlpod(1) for more details. % % The mode tries to guess which style is being used. % When only '/^=head/' and no '/^=pod/' is found, the '=head' tag will % be used. Otherwise '=pod' will be used. % For intermixed coding styles, a periodic M-x 'perl_mode' helps. % % NB: this only affects the *syntax highlighting* ... % indentation should be fine. % % NB: since the syntax highlighting matches /=pod/ and not /^=pod/, % these patterns within the code will cause spurious highlighting! % Consider using something like /^=(pod|head|cut)/ instead. % % ------------------------------------------------------------------------ % BUGS / MIS-FEATURES: % - suppressed indentation in '< % % 2001-01-10 Mark Olesen % - modified a few keywords, added a Perl specific keymap % - indentation mode improved and now includes a POD mode % - added begin/end/mark/prev/next 'chunk' (sub or pod) % % 2002-01-27 Mark Olesen % - fixed indentation for [] array entries and references % - indentation for closing ')' or ']' lines up with opening '(', '[' % - improved indentation for code blocks within parentheses % - improved indentation for 'keyword => { ...' and '$ref = {' construct % - perl_indent_region() now handles '< % - indentation for "=>(", "=>[" and "=> {" constructs % and for "= (", "= [" and "={" constructs use 'Perl_Indent' are are % not lined up! This helps reduce panning for large tables. % - The multi-line contents of '()' are indented by 1 % - The multi-line contents of '[]' are indented by 'Perl_Continued_Offset' % % 2002-02-17 Mark Olesen % - The contents of '([{' are no longer indented to match the % opening parentheses. Instead they receive a uniform 'Perl_Indent'. % This matches the results of perltidy(1) with '-i=4 -ci=2' much better, % the code tends not to run off the end of lines as quickly, % and the results are much more consistent (less monkeying with the % code-layout to get the indent to work correctly). % - lines starting with 'grep', 'and', etc and lines following them % are now corectly indented. % Even when the previous line ended with '}'. % We can continue our lines with the perlstyle(1) suggested 'and' / 'or' % - perl_parse_to_point() now returns -3 if inside of pod. % - lines starting with '#' in the first column are left alone % - The older versions are commented out with 'PERL_INDENT_V\d+' % % 2002-02-24 Mark Olesen % - perl_mark_matching is a bit more generous with whitespace when % attempting a match % - the brain-dead PERL_INDENT_V0 (version 0) is no longer included % - included the '$@%' sigils as word characters. The '%' as modulus % operator will be incorrect, but we have many more hashes ... % % 2002-03-02 Mark Olesen % - added 'perl_exec' and 'perl_check' functions % - since I've never seen a perl program with folding marks, % I changed the folding marks from the '#{{{' and '#}}}' to % the slightly more useful '=pod' and '=cut'. % Thus you can fold your documentation out of the way. % - added interface to the 'perltidy' (sourceforge) program. % This is *extremely* handy, especially if you are a bit sloppy about % spacing around brackets etc. % % 2002-08-20 Mark Olesen % - minor S-Lang improvements % - somewhat improved documentation % % 2002-10-21 Mark Olesen % - split off some functions into perlxtra.sl % % 2006-08-28 Mark Olesen % - use '#' .. '#' construct % - cosmetics % % 2006-11-11 JED % - Use "require" instead of evalfile for loading perlxtra. % % 2007-06-20 JED % - Added find_matching_brace_ignore_fold_marks to search for a % matching delimiter ignoring fold marks. % % ------------------------------------------------------------------------ % ------------------------------------------------------------------------ % forget autoloading - always just add in perl 'extras' % we also get 'Perl_Indent' from there %% autoload ("perltidy", "perlxtra"); %% autoload ("perl_exec", "perlxtra"); %% autoload ("perl_info", "perlxtra"); %% autoload ("perl_check", "perlxtra"); %% autoload ("perl_help", "perlxtra"); %% autoload ("perldoc", "perlxtra"); require ("perlxtra"); % !if (is_defined("perldoc") and is_defined("Perl_Indent")) % () = evalfile("perlxtra"); %{{{ default values for Perl custom variables % override these default values in ~/.jedrc %!%+ %\variable{Perl_Continued_Offset} %\synopsis{Perl_Continued_Offset} %\usage{Integer Perl_Continued_Offset = 2;} %\description % This variable controls the indentation of statements that are continued % onto the next line as in the following example: %#v+ % print % "hallo ", % " world\n"; %#v- % % The default value (2) corresponds to the default for \var{perltidy} % %\seealso{C_CONTINUED_OFFSET, Perl_Indent} %!%- custom_variable("Perl_Continued_Offset", 2); %}}} % some constant strings for tracking POD documentation static variable pod_beg = "=pod", % start pod documentation (the canonical way) pod_too = "=head", % one of the alternative ways to start pod pod_end = "=cut"; % stop pod documentation %{{{ create/initialize key map $1 = "perl"; !if (keymap_p ($1)) make_keymap($1); !if (is_defined("Win_Keys") ) { % conflict with windows region copy definekey("perl_help", "^C?", $1); definekey("perl_check", "^Cc", $1); definekey("perl_exec", "^Ce", $1); definekey("perl_info", "^Ci", $1); definekey("perl_indent_region", "^C\t", $1); definekey("perltidy", "^C^T", $1); } definekey("indent_line", "\t", $1); definekey("perl_beg_chunk", "\e^A", $1); definekey("perl_end_chunk", "\e^E", $1); definekey("perl_mark_chunk", "\e^H", $1); definekey("perl_next_chunk", "\e^N", $1); definekey("perl_prev_chunk", "\e^P", $1); definekey("perl_mark_matching", "\e^M", $1); definekey("perltidy", "\e^T", $1); definekey("perl_format_paragraph", "\eq", $1); definekey("newline_and_indent", "\r", $1); % some people may like this: % definekey(".\"\\\\n\" insert", "^J", $1); definekey("perl_indent_region", "\e\t", $1); % override 'move-to-tab' %}}} key map %{{{ create/initialize syntax tables $1 = "perl"; create_syntax_table($1); define_syntax("#", "", '%', $1); % single line comment define_syntax(pod_beg, pod_end, '%', $1); % multi-line comment (POD) define_syntax("([{", ")]}", '(', $1); % matching brackets define_syntax('\'', '"', $1); % string define_syntax('"', '"', $1); % string define_syntax('\\', '\\', $1); % backslash escaping define_syntax("$%0-9@A-Z_a-z", 'w', $1); % words plus sigils define_syntax("-+.0-9_xa-fA-F", '0', $1); % numbers define_syntax(",.:;?", ',', $1); % punctuation define_syntax("!&*+-/<=>`^|~", '+', $1); % operators - leave %-sigil alone set_syntax_flags ($1, 0x10|0x80); %}}} syntax table % with DFA, the =pod/=head/=cut block is not recognized #ifdef HAS_DFA_SYNTAX_THAT_WORKS_FOR_PERL %{{{ DFA syntax tables - have these be verified?? enable_highlight_cache("perl.dfa", $1); define_highlight_rule("^#.*$", "comment", $1); define_highlight_rule("[ \t;]#.*$", "comment", $1); % normal => qr{([$%&@*]|\$#)\w+/}; % normal => qr{\$([-+_./,\"\'\`#*?\[(<>)\];!@:$%=~^|&]|\^[A-Z])} define_highlight_rule("([\\$%&@\\*]|\\$#)[A-Za-z_0-9]+", "normal", $1); define_highlight_rule("\\$([_\\./,\"\\\\#\\*\\?\\]\\[;!@:\\$<>\\(\\)" + "%=\\-~\\^\\|&`'\\+]|\\^[A-Z])", "normal", $1); % define_highlight_rule("[A-Za-z_\\$][A-Za-z0-9_]*", "Knormal", $1); define_highlight_rule("[A-Za-z_][A-Za-z0-9_]*", "Knormal", $1); define_highlight_rule("[0-9]+(\\.[0-9]+)?([Ee][\\-\\+]?[0-9]+)?", "number", $1); define_highlight_rule("0x[0-9A-Fa-f]+", "number", $1); % strings: % strange ... " abc \" def"; would appear to be invalid define_highlight_rule("\"([^\"\\\\]|\\\\.)*\"", "string", $1); define_highlight_rule("'([^'\\\\]|\\\\.)*'", "string", $1); % define_highlight_rule("[\\(\\[\\{\\<\\>\\}\\]\\),\\.:;\\?]", "delimiter", $1); define_highlight_rule("[\\-\\+!%&\\*/=<>\\|~\\^]", "operator", $1); define_highlight_rule("[A-Za-z0-9]", "keyword0", $1); % % unfortunately these rules are not robust enough and are also incomplete % eg, 's{/+}{/}g' or 's|/+|/|g'; % %fixme? define_highlight_rule("m?/([^/\\\\]|\\\\.)*/[gio]*", "string", $1); %fixme? define_highlight_rule("m/([^/\\\\]|\\\\.)*\\\\?$", "string", $1); %fixme? define_highlight_rule("s/([^/\\\\]|\\\\.)*(/([^/\\\\]|\\\\.)*)?/[geio]*", %fixme? "string", $1); %fixme? define_highlight_rule("s/([^/\\\\]|\\\\.)*(/([^/\\\\]|\\\\.)*)?\\\\?$", %fixme? "string", $1); %fixme? define_highlight_rule("tr/([^/\\\\]|\\\\.)*(/([^/\\\\]|\\\\.)*)?/[cds]*", %fixme? "string", $1); %fixme? define_highlight_rule("tr/([^/\\\\]|\\\\.)*(/([^/\\\\]|\\\\.)*)?\\\\?$", %fixme? "string", $1); define_highlight_rule(".", "normal", $1); build_highlight_table($1); %}}} DFA syntax tables #endif % keywords % ignore the functions that do special, pre-defined things including % `BEGIN', `CHECK', `INIT', `END', `AUTOLOAD', and % `DESTROY'--plus all functions mentioned in the perltie manpage. % $1 = "perl"; %{{{ Type 0 keywords - automatically generated () = define_keywords($1, "doiflcmynoqqqrqwqxtruc", 2); () = define_keywords($1, "abschrcosdieeofexpforhexintlogmapoctordourpopposrefsinsubtieusevec", 3); () = define_keywords($1, "bindcarpchopdumpeachelseevalexecexitforkgetcglobgotogrepjoinkeyskilllastlinklocknextopenpackpipepushrandreadrecvredoseeksendsizesortsqrtstattelltiedtimewaitwarn", 4); () = define_keywords($1, "alarmatan2blesschdirchmodchompchownclosecroakcryptelsiffcntlflagsflockindexioctllocallstatmkdirorderprintresetrmdirsemopshiftsleepsplitsrandstudytimesumaskundefuntieuntilutimewhilewrite", 5); () = define_keywords($1, "acceptcallerchrootdeleteexistsfilenoformatgmtimeimportlengthlistenmsgctlmsggetmsgrcvmsgsndprintfrenamereturnrindexscalarselectsemctlsemgetshmctlshmgetsocketsplicesubstrsystemunlessunlinkunpackvaluesvector", 6); () = define_keywords($1, "binmodeconfessconnectdefinedforeachgetpgrpgetppidlcfirstopendirpackagereaddirrequirereverseseekdirsetpgrpshmreadsprintfsymlinksyscallsysopensysreadsysseektelldirucfirstunshiftwaitpid", 7); () = define_keywords($1, "closedircontinueendgrentendpwentformlinegetgrentgetgrgidgetgrnamgetlogingetpwentgetpwnamgetpwuidreadlinereadlinkreadpipesetgrentsetpwentshmwriteshutdownsyswritetruncate", 8); () = define_keywords($1, "endnetentgetnetentlocaltimeprecisionprototypequotemetarewinddirsetnetentwantarray", 9); () = define_keywords($1, "endhostentendserventgethostentgetserventgetsockoptsethostentsetserventsetsockoptsocketpair", 10); () = define_keywords($1, "endprotoentgetpeernamegetprioritygetprotoentgetsocknamesetprioritysetprotoent", 11); () = define_keywords($1, "getnetbyaddrgetnetbyname", 12); () = define_keywords($1, "gethostbyaddrgethostbynamegetservbynamegetservbyport", 13); () = define_keywords($1, "getprotobyname", 14); () = define_keywords($1, "getprotobynumber", 16); %}}} Type 0 keywords - automatically generated % Type 1 keywords - use for operator-like keywords () = define_keywords_n($1, "eqgegtleltneor", 2, 1); () = define_keywords_n($1, "andcmpnotxor", 3, 1); % % returns the same as the standard parse_to_point, % except -3 if we're inside of pod private define perl_parse_to_point() { % debug-> EXIT_BLOCK { pop_spot(); dup(); vmessage("ptp=%d",()); (); } EXIT_BLOCK { pop_spot(); } push_spot(); variable ptp = parse_to_point(); % see if the current line starts with a /^=[a-z]+/ pod directive bol(); if (looking_at_char('=')) { go_right_1(); _get_point(); % leave on the stack skip_chars ("a-z"); if (_get_point() - ()) return -3; % pod! } variable here = what_line(); if (andelse {re_bsearch("^=[a-z]")} % prev /^=[a-z]/ pod command {bol_fsearch(pod_end)} % next /^=cut/ {here < what_line()} % are we in this region? ) return -3; % pod! % check for the start of a comment !if (ptp) { goto_spot(); bol_skip_white(); if (looking_at_char('#')) return -2; } return ptp; } % the usual delimiters that may occur before/after a keyword static variable delimiter = "\t $%@([{:?}])"; % % returns non-zero if looking at one of the tokens in the list % NB: if you look for a token such as '||', it must be nicely delimited % from its following neighbour. ie, write '|| foo()' instead of '||foo()' % private define perl_looking_at() { variable cs = CASE_SEARCH, rc = 0; EXIT_BLOCK { pop_spot(); CASE_SEARCH = cs; } CASE_SEARCH = 1; push_spot(); foreach (__pop_args(_NARGS)) { variable token = ().value; variable len = strlen(token); goto_spot(); if (looking_at(token)) { go_right(len); _get_point(); % leave on the stack skip_chars(delimiter); rc = (_get_point() - ()) or eolp(); if (rc) break; } } return rc; } % % returns non-zero if looking at one of the tokens in the list % NB: if you look for a token such as '||', it must be nicely delimited % from its following neighbour. ie, write '|| foo()' instead of '||foo()' % private define perl_blooking_at() { variable cs = CASE_SEARCH, rc = 0; EXIT_BLOCK { pop_spot(); CASE_SEARCH = cs; } CASE_SEARCH = 1; push_spot(); variable n = _get_point(); % check if there's room for the word foreach (__pop_args(_NARGS)) { variable token = ().value; variable len = strlen(token); if (n < len) continue; goto_spot(); go_left(len); if (looking_at(token)) { _get_point(); % leave on the stack bskip_chars(delimiter); rc = (() - _get_point()) or bolp(); if (rc) break; } } return rc; } private define find_matching_brace_ignore_fold_marks (endch); private define find_matching_brace_ignore_fold_marks (endch) { variable m = create_user_mark (); if (1 != find_matching_delimiter (endch)) return 0; !if (blooking_at ("#{{") or blooking_at ("# {{")) return 1; go_left(2); if (1 == find_matching_brace_ignore_fold_marks (endch)) return 1; goto_user_mark (m); return 0; } %!%+ %\function{perl_indent_line} %\synopsis{Void perl_indent_line (Void)} %\description % indents the line %\seealso{perl_indent_region, Perl_Indent, Perl_Continued_Offset, perl_mode} %!%- public define perl_indent_line() { variable ch; % the first character variable col = 1; % default to indent on first column variable indent_ok = 0; variable extra_indent = Perl_Indent; variable ptp; % parse-to-point results push_spot(); bol(); ch = what_char(); % the first character ptp = perl_parse_to_point(); % vmessage("ptp = %d", ptp); % do not indent POD, but do trim blank lines to avoid problems % % don't indent a line that has '#' on column 1 ... % we probably want to keep our comment there if ( (ptp == -3) or ((ptp == -2) and (ch == '#')) ) { eol_trim(); % trim blank lines to avoid problems pop_spot(); return; } skip_white(); ch = what_char(); % the first non-blank character % on exit: restore position and indent to the prescribed 'col' EXIT_BLOCK { goto_spot(); bol_skip_white(); if ( what_column != col ) { bol_trim(); col--; whitespace(col); } goto_spot(); bskip_white(); bolp(); % leave on the stack pop_spot(); if (()) bol_skip_white(); % (start of line) } variable rc, endch = ')'; rc = find_matching_delimiter(endch); !if (rc) { % enclosing '()' not found - retry with enclosing '[]' goto_spot(); bol(); endch = ']'; rc = find_matching_delimiter(endch); } if (rc == 1) { #iftrue % the latest version - uniform 'Perl_Indent' bol_skip_white(); col = what_column(); #elifdef PERL_INDENT_V1 % ----------------------------------------------------------- % inside '()' (or '[]')- indent to level of opening '(' + 1 % A solitary closing ')' gets the same indent level as the '( % Ex: % foo (bar % baz(fum % foz) % ) % ----------------------------------------------------------- col = what_column(); bskip_white(); extra_indent = 1; % bracket offset is 1 % '<<= [' and '=> [' constructs are special if ( orelse { blooking_at ("<=") } { blooking_at ("=>") } ) { bol_skip_white(); col = what_column(); extra_indent = Perl_Indent; } #endif if (ch != endch) col += extra_indent; indent_ok++; } goto_spot(); bol(); % (original position : start of line) % -------------------------------------------------------------------- % take care of indentation for '{' blocks % -------------------------------------------------------------------- endch = '}'; if (ch == '{') indent_ok++; if (find_matching_brace_ignore_fold_marks (endch)) { extra_indent = Perl_Indent; % --------------------------------------------------------------- % check for a '(' or '[' on the same line as the '{' % this covers many code-blocks such as: % % for my $var (grep { % defined $_ and /foobar/ and / % } % @list % ) % { % ... % } % % but still could use a bit of work ... % --------------------------------------------------------------- % save indent level and position of the '{' col = what_column(); bskip_white(); push_spot(); rc = 0; if ( orelse { bfind_char ('(') } { bfind_char ('[') } ) { goto_spot(); rc = find_matching_delimiter(')'); !if (rc) { % enclosing '()' not found goto_spot(); % retry with enclosing '[]' rc = find_matching_delimiter(']'); } } pop_spot(); if (rc == 1) { % matched from within an enclosing '()' or '[]' indent_ok++; } else { % check for '= {', '+{' or '=> {' constructs % and for functions taking references _get_point (); % leave on the stack bskip_chars("+<=>"); if (() - _get_point ()) { indent_ok++; } else if (perl_blooking_at("bless")) { % a naked 'bless' indent_ok++; } %% else if ( perl_blooking_at("grep", "map", "sort") ) { %% extra_indent = Perl_Continued_Offset; %% } bol_skip_white(); col = what_column(); % Indent level } if (ch != endch) col += extra_indent; % Indent to last '{' + extra else indent_ok++; % vmessage("col '%c' = %d", endch, col); } if (indent_ok) return; % we're done % find out if we're on a continued line goto_spot(); % Find previous non-comment line do { % Start of file, pretty hard to find context ;-) !if (up_1()) { bol(); break; } bol_skip_white(); !if (eolp()) go_right_1(); } while (perl_parse_to_point() <= -2); eol(); % Find last non-comment character while ( ptp = perl_parse_to_point(), (ptp <= -2) ) { !if (left(1)) break; } % vmessage("look = %c", what_char); bskip_white(); ch = ';'; % default final character !if (bolp()) { go_left_1(); if (perl_parse_to_point() >= -2) ch = what_char(); } % vmessage("end char = %c", ch); extra_indent = Perl_Continued_Offset; if ( not(is_substr (";({}", char(ch))) ) { col += extra_indent; #iftrue } else if ('}' == ch) { % started '{}' with grep/map/sort filter? () = find_matching_delimiter(ch); bskip_white(); if (perl_blooking_at("grep", "map", "sort")) { bol_skip_white(); col = what_column; } else { % ended with '}', but continued with filter or logical operator? goto_spot(); % (original position) bol_skip_white(); if (perl_looking_at("grep", "map", "sort", "and", "or", "&&", "||", "?", ":" )) col += extra_indent; } #endif } } %!%+ %\function{perl_indent_region} %\synopsis{Void perl_indent_region (Void)} %\description % indents each line in the region %\seealso{perl_indent_line, perl_indent_buffer, perltidy, perl_mode} %!%- public define perl_indent_region() { !if (markp()) { perl_indent_line(); % do this line and get out return; } check_region(1); % canonical region narrow(); variable line = 0; variable nlines = what_line(); % number of lines bob(); widen(); variable cs = CASE_SEARCH; CASE_SEARCH = 1; ERROR_BLOCK { pop_spot(); CASE_SEARCH = cs; } do { line++; eol_trim(); bol(); % skip the comment if ( orelse { looking_at (pod_beg) } { looking_at (pod_too) } ) { while (down_1()) { line++; if (looking_at(pod_end)) break; eol_trim(); } continue; } if (eolp()) continue; % skip blank lines skip_white(); % skip the comment if (looking_at_char('#')) { indent_line(); } else { % try our best to avoid indenting '< -3) beg = "sub"; % not inside of pod eol(); !if (bol_bsearch(beg)) error ("Top of '" + beg + "' not found."); } %!%+ %\function{perl_end_chunk} %\synopsis{Void perl_end_chunk (Void)} %\description % move to the end of a code chunk or to the end of a POD chunk %\seealso{perl_beg_chunk, perl_mark_chunk, perl_mode} %!%- define perl_end_chunk() { perl_beg_chunk(); variable ptp = perl_parse_to_point(); if (ptp > -3) { % not inside of pod if (fsearch_char('{')) call("goto_match"); } else { bol(); !if (bol_fsearch(pod_end)) error(pod_end + " not found"); } } %!%+ %\function{perl_mark_chunk} %\synopsis{Void perl_mark_chunk (Void)} %\description % marks the code/Pod code %\seealso{perl_beg_chunk, perl_end_chunk, perl_mode} %!%- define perl_mark_chunk() { perl_beg_chunk(); push_visible_mark(); perl_end_chunk(); eol(); exchange_point_and_mark(); } %!%+ %\function{perl_mark_matching} %\synopsis{Void perl_mark_matching (Void)} %\description % works mostly like find_matching_delimiter, except that it attempts % to be extra smart if starting out on whitespace %\seealso{find_matching_delimiter} %!%- define perl_mark_matching() { variable beg = "([{", end = ")]}"; variable ch = what_char(); ERROR_BLOCK { pop_mark_1(); } USER_BLOCK0 { variable fn = (); set_mark_cmd(); % we only want a single visible mark if (1 != find_matching_delimiter(ch)) error("matching delimiter not found"); @fn(); exchange_point_and_mark(); return; } if (is_substr (beg, char(ch))) { X_USER_BLOCK0 (&go_right_1); } else if (is_substr(end, char(ch))) { X_USER_BLOCK0 (&skip_word_chars); % actually serves as a no-op } % not on a beg/end character % look backwards for an enclosing "([{" bskip_white (); _get_point(); % leave on the stack bskip_chars(beg); if (() - _get_point()) { ch = what_char(); X_USER_BLOCK0 (&go_right_1); } % look forwards for an enclosing ")]}" skip_white (); _get_point(); % leave on the stack skip_chars(end); if (() - _get_point()) { go_left_1 (); % backup again ch = what_char(); X_USER_BLOCK0 (&skip_word_chars); % actually serves as a no-op } } static define perl_init_menu (menu) { menu_append_item(menu, "&Top of Function", "perl_beg_chunk"); menu_append_item(menu, "&End of Function", "perl_end_chunk"); menu_append_item(menu, "&Mark Function", "perl_mark_chunk"); menu_append_item(menu, "&Format Buffer", "perl_indent_buffer"); } static variable PerlMode_Comment = "# "; static variable PerlMode_CommentLen = 2; % % this is mostly really annoying when bound to '\r' % especially bad for '< { variable mode = "perl"; set_mode(mode, 4); use_keymap(mode); use_syntax_table(mode); % 2001-02-19 Mark Olesen % - changed syntax highlighting to start with /^=head/ instead % of the more correct but less common /^=pod/ as a comment. % Note that this only affects the syntax highlighting ... the % indentation continues to work as before and /^=cut/ is always the end push_spot_bob(); variable beg = pod_beg; if ( (not (bol_fsearch (beg))) and (bol_fsearch (pod_too)) ) beg = pod_too; define_syntax(beg, pod_end, '%', mode); pop_spot(); set_buffer_hook("par_sep", "perl_paragraph_sep"); set_buffer_hook("indent_hook", &perl_indent_line); #iffalse mode_set_mode_info(mode, "fold_info", "#{{{\r#}}}\r\r"); #else % more useful mode_set_mode_info(mode, "fold_info", "=pod\r=cut\r\r"); #endif mode_set_mode_info(mode, "init_mode_menu", &perl_init_menu); run_mode_hooks("perl_mode_hook"); } % -------------------------------------------------------- [end of S-Lang] % Run this code snippet thru 'perl -x' to extract the function names from % 'perlfunc' or narrow to this region and run it through 'perl_exec' % % keywords 'if', 'else', etc. added by hand % % use '#%#' for S-Lang syntax highlighting of perl comments % ------------------------------------------------------------------------ # #!/usr/bin/perl -w #%# for 'perl -x' use strict; #%# even for small programs! @ARGV = "perldoc -u perlfunc|"; while (<>) { last if /^=head2\s+Alphabetical/ } # cue up my %kw = map { $_ => length } ( #%# language elements + carp qw( if else elsif for foreach unless until while carp cluck croak confess ), #%# keywords map { /^=item\s+([a-z\d]+)/ } <>, ); delete @kw{ grep { /^dbm/ } keys %kw }; #%# remove obsolete stuff my @list; #%# store sorted keywords by length $list[$kw{$_}] .= $_ for sort keys %kw; splice @list, 0, (my $n = 2); #%# keywords are min 2 chars my $tag = "Type 0 keywords - automatically generated"; print "\%{{{ $tag\n"; for (@list) { defined and length and print qq{()=define_keywords(\$1,\n "$_",\n $n);\n}; $n++ } print "\%}}} $tag\n"; __END__ # % ---------------------------------------------------------- [end of Perl] jed-0.99-19/lib/compile.sl0000644002657400265740000002614711311317447014242 0ustar davisdavis% -*- SLang -*- % % run compiler in a subshell and/or parse error messages % % Changes made by Alexander Demenshin % Column support by Lutz Donnerhacke . % % Public functions: % compile_parse_errors parse next error % compile_previous_error parse previous error % compile_parse_buf parse current buffer as error messages % compile run program and parse it output % compile_select_compiler set compiler for parsing error messages % compile_add_compiler add a compiler to database % % Public variables: % Compile_Default_Compiler % % The file also contains a database for various compilers. %--------------------------------------------------------------------------- % These variables are public because they are used by acompile.sl variable Compile_Output_Buffer = "*shell-output*"; if (is_defined ("get_process_input")) { Compile_Output_Buffer = "*compile*"; } variable Compile_Line_Mark = 0; private variable Compile_Src_Dir = Null_String; private variable Error_Regexp; % % These variables are used when parsing GNU's Make output (directory changes). % I don't know what kind of output generated by other Make, so substitute % it if needed. % #ifdef UNIX private variable Compile_Dir_Enter = "^g?make\\[\\d+\\]: Entering directory `\\(.+\\)'"; private variable Compile_Dir_Leave = "^g?make\\[\\d+\\]: Leaving directory `\\(.+\\)'"; private define compile_parse_make_chdir () { variable beg_mark, end_mark; variable end_line; push_spot (); EXIT_BLOCK { pop_spot (); } beg_mark = create_user_mark (); end_mark = create_user_mark (); forever { goto_user_mark (end_mark); end_line = 0; if (re_bsearch (Compile_Dir_Leave)) { if (up_1 ()) end_line = what_line (); move_user_mark (end_mark); } goto_user_mark (beg_mark); !if (up_1 ()) return Null_String; if (re_bsearch (Compile_Dir_Enter)) { if (not(end_line) or (what_line () > end_line)) break; move_user_mark (beg_mark); } else return Null_String; } regexp_nth_match (1); } #endif private define compile_find_file (file, line, col) { #ifdef UNIX variable dir; dir = compile_parse_make_chdir (); if (strlen (dir) and (file[0] != '/')) file = dircat (dir, file); #endif if (1 != file_status (file)) { file = Compile_Src_Dir + file; while (1 != file_status (file)) { file = read_file_from_mini ("Find this file's errors:"); } } Compile_Src_Dir = path_dirname (file); () = find_file (file); widen_buffer (); goto_line (line); if (col > 0) goto_column_best_try (col); else bol_skip_white (); } private define compile_parse_errors_dir (next_error_fun, next_line_fun) { variable cbuf, obuf = Compile_Output_Buffer; variable line, file, col; Compile_Line_Mark = 0; !if (bufferp(obuf)) { flush ("Did you compile?"); return; } if (MINIBUFFER_ACTIVE) return; cbuf = pop2buf_whatbuf (obuf); if (@next_error_fun (&file, &line, &col)) { !if (strlen (line)) return; !if (strlen (col)) col = "0"; bol(); Compile_Line_Mark = create_line_mark (3); @next_line_fun (); line = strtrim_beg (line, " \t0"); col = strtrim_beg (col, " \t0"); compile_find_file (file, integer (line), integer (col)); cbuf = whatbuf (); sw2buf (obuf); } pop2buf (cbuf); } private define compile_find_next_error_fun (filep, linep, colp) { eol (); if (eobp ()) { message ("No more errors!"); return 0; } if (typeof (Error_Regexp) == Ref_Type) return @(Error_Regexp) (1, filep, linep, colp); bol (); !if (re_fsearch (Error_Regexp)) { eob (); return 0; } @filep = regexp_nth_match (1); % file name @linep = regexp_nth_match (2); % line number (string) @colp = regexp_nth_match (3); % column number (string) 1; } private define compile_find_prev_error_fun (filep, linep, colp) { bol (); if (bobp ()) { message ("No more errors!"); 0; } if (typeof (Error_Regexp) == Ref_Type) return @Error_Regexp (-1, filep, linep, colp); !if (re_bsearch (Error_Regexp)) { bob (); return 0; } @filep = regexp_nth_match (1); % file name @linep = regexp_nth_match (2); % line number (string) @colp = regexp_nth_match (3); % column number (string) 1; } public define compile_parse_errors () { compile_parse_errors_dir (&compile_find_next_error_fun, &go_down_1); } public define compile_previous_error () { compile_parse_errors_dir (&compile_find_prev_error_fun, &bol); } public define compile () { variable b, n; variable cmd = NULL; if (_NARGS != 0) cmd = (); b = whatbuf(); call ("save_some_buffers"); if (cmd == NULL) do_shell_cmd (); else shell_perform_cmd (cmd, 0); bob(); pop2buf(b); compile_parse_errors (); } % % Parse current buffer as error output % public define compile_parse_buf () { Compile_Output_Buffer = whatbuf(); bob (); compile_parse_errors (); } $1 = "acompile.sl"; if (is_defined ("get_process_input")) { () = evalfile ($1); } % The current implementation for the database uses an associative array. private variable Compiler_Database = Assoc_Type [Any_Type, NULL]; public define compile_select_compiler (name) { variable c; c = Compiler_Database[name]; if (c == NULL) verror ("Compiler %s is not supported. See compile.sl for more information", name); Error_Regexp = c; } public define compile_add_compiler (name, regexp) { Compiler_Database [name] = regexp; } %--------------------------------------------------------------------------- % Compiler database %--------------------------------------------------------------------------- %Borland bcc/tcc compilers %Error foo.c 4: Undefined symbol 'x' in function main %Warning foo.c 34: Possible use of 'y' before definition in function main compile_add_compiler ("bcc", "^[EW][a-r]+ \\(.+\\) \\(\\d+\\):\\(\\)"); compile_add_compiler ("tcc", "^[EW][a-r]+ \\(.+\\) \\(\\d+\\):\\(\\)"); %-------------------------------------------------------------------------- %Ultrix cc compiler %ccom: Error: t.c, line 14: LC_ALL undefined compile_add_compiler ("ultrix_cc", "[WE][ar][r][no][ir]n?g?: +\\(.+\\), line \\(\\d+\\):\\(\\)"); %-------------------------------------------------------------------------- %hp cc compiler %cc: "t.c", line 3: error 1588: "ddkldkjdldkj" undefined. compile_add_compiler ("hp_cc", "^cc: +\\\"\\(.+\\)\\\", line \\(\\d+\\):\\(\\)"); %-------------------------------------------------------------------------- %Sun acc compiler %"filename.c", line 123: error: buffer undefined %"filename.c", line 123: warning: fin not used compile_add_compiler ("sun_acc", "^\\\"\\(.+\\)\\\", line \\(\\d+\\):\\(\\)"); %-------------------------------------------------------------------------- %AIX compiler, which may be referenced under any of these names. %The Fortran compiler has the same format, so allow that too %"foo.c", line 13.4: 1506-045 (S) Undeclared identifier bar. %"foo.f", line 21.20: 1515-019 (S) Syntax is incorrect. %@aix; %@xlc; %@xlf; compile_add_compiler ("aix", "^\\\"\\(.+\\)\\\", line \\(\\d+\\)\\.\\(\\d+\\)"); compile_add_compiler ("xlc", "^\\\"\\(.+\\)\\\", line \\(\\d+\\)\\.\\(\\d+\\)"); compile_add_compiler ("xlf", "^\\\"\\(.+\\)\\\", line \\(\\d+\\)\\.\\(\\d+\\)"); %-------------------------------------------------------------------------- %The GNU compiler %cmds.adb:33:20: ';' expected. %cmds.c:33: warning: initialization of non-const * pointer... %cmds.c:1041 (cmds.o): Undefined symbol _Screen_Height referenced... %In file included from /usr/local/src/jed/src/xterm.c:10: compile_add_compiler ("gcc", "^\\([^ :]+\\):\\(\\d+\\)[^:]*:\\(\\d*\\)"); %-------------------------------------------------------------------------- %The WATCOM compiler wcc %keymap.c(71): Error! E1011: Symbol 'show_memory' has not been declared %event.c(22): Warning! W202: Symbol 'xx' has been defined, but not referenced %Warning(1028): PhGetMsgSize_ is an undefined reference %file event.o(/home/qnx/rwm/photon/event.c): undefined symbol PhAttach_ compile_add_compiler ("wcc", "^\\(.+\\)(\\(\\d+\\)): [EW].+[rg]! [EW]\\d+:\\(\\)"); %-------------------------------------------------------------------------- %The Java compiler javac %Test.java:151: Method getNumber() not found in class java.lang.String. %@javac; compile_add_compiler ("javac", "^\\(.+\\):\\(\\d+\\):\\(\\)"); %-------------------------------------------------------------------------- %Microsoft Visual C %cob.cpp(30) : warning C4091: no symbols were declared %cob.cpp(32) : error C2665: 'COBFileHeader::COBFileHeader' : none of the %2 overloads can convert parameter 1 from type 'char [34]' (new behavior; %please see help) %cob.cpp(38) : warning C4091: no symbols were declared %cob.cpp(45) : warning C4091: no symbols were declared %cob.cpp(50) : error C2239: unexpected token '{' following declaration of %'COBChunkHead' %@vc; %compile_add_compiler ("vc", "^\\(.+\\)(\\(\\d+\\)) : [ew].+:\\(\\)"); %-------------------------------------------------------------------------- %Microsoft Visual C %cob.cpp(30) : warning C4091: no symbols were declared %cob.cpp(32) : error C2665: 'COBFileHeader::COBFileHeader' : none of the %c:\work\library\terrain\lodland.h(12) : fatal error C1083: Cannot open include file: 'fallocr.h': No such file or directory %c:\work\library\terrain\lodvrtx.h(62) : see declaration of 'public: static class lodland_vertex_generator * lodvertex::gen' %@vc; compile_add_compiler ("vc", "^[ \t]*\\(.+\\)(\\(\\d+\\)) : .*"); %-------------------------------------------------------------------------- %rgbds gameboy assembler %*ERROR* GBC_Main.s(1) : %*ERROR* GBC_Main.s(10) -> GBC_Hardware.h(27) :=0D %*ERROR* : Worldsys.s(366) : Value must be 8-bit %@rgbds; compile_add_compiler ("rgbds", "^\\*ERROR\\*.*[\t ]\\(.+\\)(\\(\\d+\\))"); %--------------------------------------------------------------------------- % End of data base %--------------------------------------------------------------------------- %!%+ %\variable{Compile_Default_Compiler} %\usage{variable Compile_Default_Compiler = "gcc";} %\description % This variable specifies the default compiler to be assumed when parsing % error messages in the compile buffer. If not set, "gcc" is assumed. % Currently supported compilers include: %#v+ % gcc (GNU C Compiler) % bcc (Borland C Compiler) % tcc (Turbo C Compiler) % ultrix_cc (Ultrix C Compiler) % hp_cc (HP C compiler) % sun_acc (Sun ANSI C compiler) % aix, xlc, xlf (Various AIX C compilers) % wcc (Watcom C compiler) % javac (Java Compiler) % vc (Microsoft Visual C) %#v- %\notes % The primary purpose of this variable is to select a compiler prior to % loading compile.sl. Once compile.sl has been loaded, the value of this % variable has no effect. To switch compilers, the \var{compile_select_compiler} % function must be used. %\seealso{compile_select_compiler, compile_add_compiler} %!%- custom_variable ("Compile_Default_Compiler", "gcc"); compile_select_compiler (Compile_Default_Compiler); jed-0.99-19/lib/lisp.sl0000644002657400265740000000233411311317447013551 0ustar davisdavis% Lisp mode $1 = "LISP"; create_syntax_table ($1); define_syntax ("([", ")]", '(', $1); define_syntax (";", "", '%', $1); define_syntax ('"', '"', $1); define_syntax ('\\', '\\', $1); define_syntax ("0-9a-zA-Z_", 'w', $1); % words define_syntax ("-+0-9", '0', $1); % Numbers % define_syntax ("", ',', $1); % Delimiters define_syntax ('#', '#', $1); % preprocessor % define_syntax ("%-+/&*=<>|!~^", '+', $1); % binary operators () = define_keywords ($1, "eqifor", 2); () = define_keywords ($1, "letnot", 3); () = define_keywords ($1, "setq", 4); () = define_keywords ($1, "defunprognwhile", 5); define lisp_indent_line () { variable val, col; push_spot (); bol (); val = find_matching_delimiter (')'); col = what_column (); if (val == 1) col += 3; pop_spot (); push_spot (); bol_skip_white (); if (col != what_column ()) { bol_trim (); col--; whitespace (col); } pop_spot (); push_mark (); bskip_white (); if (bolp ()) { skip_white (); pop_mark_0 (); } else pop_mark_1 (); } define lisp_mode () { set_mode("lisp", 2); set_buffer_hook ("indent_hook", "lisp_indent_line"); use_syntax_table ("LISP"); run_mode_hooks ("lisp_mode_hook"); } jed-0.99-19/lib/emul.sl0000644002657400265740000000013011311317447013534 0ustar davisdavis% Functions in this file allow jed to work with older versions of the % slang library. jed-0.99-19/lib/backups.sl0000644002657400265740000000264311311317447014235 0ustar davisdavis% backups.sl -*- SLang -*- % % This file provides numbered backups whenever a file is saved, % in a fashion similar to Emacs. For Jed 0.99.12 upwards. % Written by Guido Gonzato % % Last updated: 5 December 2000 % % Usage: % Let's suppose that you edit a new file, foo.bar. If you save it, the % numbered backup copy foo.bar.~1~ will be created; saving again will % create foo.bar.~2~, and so on. The standard backup copy is unaffected. % Win32 users need to set the variable LFN=y to use backups. % % To enable numbered backups, put this line in your .jedrc: % backups_on (); private variable DO_BACKUPS = 1; private define numbered_backups (buf) { variable status, version; variable file; if (0 == DO_BACKUPS) return; % check whether an old copy or backup files exist version = 0; do { version++; file = sprintf ("%s.~%d~", buf, version); } while (1 == file_status (file)); % mark the whole buffer and write it to file - don't use write_buffer () push_spot (); mark_buffer (); () = write_region_to_file (sprintf ("%s.~%d~", buf, version)); pop_spot(); } % define backups_off () { DO_BACKUPS = 0; flush ("Numbered backups disabled."); } % define backups_on () { DO_BACKUPS = 1; flush ("Numbered backups enabled."); } % add_to_hook ("_jed_save_buffer_before_hooks", &numbered_backups); % % --- End of file backups.sl --- jed-0.99-19/lib/cmode.sl0000644002657400265740000011614211311317447013674 0ustar davisdavis% C-mode indentation routines % For the full list of changes, see the changes.txt file. % % 2009-02-06 % recognize ternary operators within parenthesis outdent % 2007-03-21 % Fixed off-by-one on parenthesis indent. % Promote "foam" to an indentation style % 2006-12-02 % Merged in Mark Olesen's patches dated 2006-11-21 % autoload ("c_make_comment", "cmisc"); autoload ("c_format_paragraph", "cmisc"); autoload ("c_paragraph_sep", "cmisc"); % autoload ("c_comment_region", "cmisc"); autoload ("c_top_of_function", "cmisc"); autoload ("c_end_of_function", "cmisc"); autoload ("c_mark_function", "cmisc"); autoload ("c_indent_buffer", "krconv"); %!%+ %\variable{C_Autoinsert_CPP_Comments} %\synopsis{Control insertion of C++ comments} %\description % In c-mode, if a line starts with //, then pressing return will cause the % next line to also start with //. This feature is useful for writing % multiple comment lines using C++ style comments. %\seealso{c_mode} %!%- custom_variable ("C_Autoinsert_CPP_Comments", 1); %!%+ %\variable{C_Switch_Offset} %\synopsis{Additional indentation to switch blocks} %\usage{C_Switch_Offset = 0} %\description % This function may be used to increase the indentation of code % within a \exmp{switch} block. Since this also affects the % indentation of \exmp{case} statements, \svar{C_Colon_Offset} may % need to be adjusted. %\seealso{C_Colon_Offset} %!%- custom_variable ("C_Switch_Offset", 0); %!%+ %\variable{C_Outer_Block_Offset} %\synopsis{Indentation offset for code in an outer block} %\usage{C_Outer_Block_Offset = 0} %\description % The value of this variable may be used to adjust the indentation of % code in an outer block. An outer block is one that has its opening % brace at the start of a line. The values of this variable does not % affect the indentation of C++ classes and namespaces. %\example %\notes %\seealso{} %!%- custom_variable ("C_Outer_Block_Offset", 0); %!%+ %\variable{C_Namespace_Offset} %\synopsis{C_Namespace_Offset} %\description % Integer C_Namespace_Offset = 3; % This variable may be changed to adjust the indentation of members % inside of a class declaration block. %\seealso{c_mode} %\seealso{C_BRA_NEWLINE, C_BRACE, C_Class_Offset, C_INDENT, C_Namespace_Offset} %!%- custom_variable ("C_Namespace_Offset", 3); %!%+ %\variable{C_Class_Offset} %\synopsis{C_Class_Offset} %\description % Integer C_Class_Offset = 3; % This variable may be changed to adjust the indentation of members % inside of a class declaration block. %\seealso{c_mode} %\seealso{C_BRA_NEWLINE, C_BRACE, C_INDENT, C_Namespace_Offset} %!%- custom_variable ("C_Class_Offset", 3); %!%+ %\variable{C_Param_Offset_Max} %\synopsis{Control indentation of continued parameter list} %\usage{Integer C_Param_Offset_Max = -1} %\description % This variable may be changed to adjust the indentation of parameters % in a funcion call that extends over multiple lines. % % If the value is less than 0, the feature is off, otherwise % it holds the max number of spaces to indent the parameters on % the continuation line(s). %\seealso{c_mode} %\seealso{C_BRA_NEWLINE, C_BRACE, C_INDENT} %!%- custom_variable ("C_Param_Offset_Max", -1); %!%+ %\variable{C_Macro_Indent} %\synopsis{Control indentation of pre-processor macros} %\usage{Integer C_Macro_Indent = 3} %\description % This variable may be changed to adjust the indentation of % pre-processor macros. % %\seealso{c_mode} %\seealso{C_INDENT} %!%- custom_variable ("C_Macro_Indent", 3); %!%+ %\variable{C_Bracket_Indent} %\synopsis{Control indentation within lone brackets} %\usage{Integer C_Bracket_Indent = 4} %\description % Control the alignment of within parenthetic content that start with a lone % left parenthesis. A value greater than zero uses C_INDENT to determine the % indentation level. Additionally, common operators are outdented. % % eg, % while % ( % expr1 % + expr2 % == expr3 % ) ... % % A value less than 1 turns this feature off. % %\seealso{c_mode} %\seealso{C_INDENT} %!%- custom_variable ("C_Bracket_Indent", 4); %!%+ %\variable{C_Label_Indents_Relative} %\synopsis{Set labels to indent relative to block} %\usage{C_Label_Indents_Relative = 0;} %\description % If the value of this variable is non-zero, then label statements % (goto targets) will get indented by the value of the % \svar{C_Label_Offset} variable relative to the enclosing block. % Otherwise, \svar{C_Label_Offset} will be interpreted as an absolute % offset from the beginning of the line. %\seealso{C_Label_Offset, C_Colon_Offset} %!%- custom_variable ("C_Label_Indents_Relative", 0); %!%+ %\variable{C_Label_Offset} %\synopsis{Controls the indentation of label statements} %\usage{C_Label_Offset = 0;} %\description % The value of this variable controls the indentation of (goto) label % statements. It is interpreted as an absolute or relative offset % according to the \svar{C_Label_Indents_Relative} variable. It does % not affect the indentation of \exmp{case} statements. %\seealso{C_Label_Indents_Relative, C_Colon_Offset} %!%- custom_variable ("C_Label_Offset", 0); define cmode_is_slang_mode () { variable is_slang; (, is_slang) = what_mode (); is_slang & 8; } private define blooking_at_continuation_char () { return eolp () and blooking_at ("\\") and not (blooking_at ("\\\\")); } private define bskip_all_whitespace () { forever { bskip_chars (" \f\t\n"); if (blooking_at_continuation_char ()) { go_left (1); continue; } return; } } private define skip_all_whitespace () { skip_chars (" \f\t\n"); } private define skip_identifier () { skip_chars ("a-zA-Z0-9_$"); } private define bskip_identifier () { bskip_chars ("a-zA-Z0-9_$"); } private define bextract_identifier () { push_mark (); bskip_identifier (); return bufsubstr (); } private define skip_over_comment () { variable is_slang = cmode_is_slang_mode (); forever { skip_all_whitespace (); if (eobp ()) return; if (is_slang) { !if (looking_at_char ('%')) return; eol (); continue; } if (looking_at ("/*")) { !if (fsearch ("*/")) return; go_right(2); continue; } if (looking_at ("//")) { eol (); continue; } return; } } private define extract_identifier () { push_mark (); skip_identifier (); return bufsubstr (); } % search within non-comment or non-string regions private define c_search (fun, str) { while ((@fun)(str)) { if (parse_to_point ()) { go_right_1 (); continue; } return 1; } return 0; } private define c_fsearch (str) { return c_search (&fsearch, str); } private define c_bol_fsearch (str) { return c_search (&bol_fsearch, str); } private define c_re_fsearch (str) { return c_search (&re_fsearch, str); } private define c_find_effective_eol () { bol (); while (ffind_char ('%')) { go_right_1 (); if (parse_to_point () == -2) { return; } } eol (); } private define slmode_bskip_comment (skip_pp) { forever { while (parse_to_point () == -2) { () = bfind ("%"); } bskip_white (); push_mark (); bol (); pop_mark (not(looking_at_char ('#'))); !if (bolp ()) return; !if (left (1)) return; c_find_effective_eol (); } } % This function also skips preprocessor lines define c_bskip_over_comment (skip_pp) { if (cmode_is_slang_mode ()) return slmode_bskip_comment (skip_pp); forever { bskip_all_whitespace (); if (bobp ()) return; if (skip_pp) { push_mark (); while (up_1 ()) { !if (blooking_at_continuation_char ()) { go_down_1 (); break; } } bol_skip_white (); if (looking_at_char ('#')) { pop_mark_0 (); continue; } pop_mark_1 (); } !if (blooking_at ("*/")) { push_mark (); variable ptp = -2; while (andelse{ptp == -2}{bfind ("//")}) ptp = parse_to_point (); if (ptp == 0) { % Not in a comment or string pop_mark_0 (); continue; } bol (); !if (bobp ()) { if (skip_pp and looking_at_char ('#')) { pop_mark_0 (); continue; } } pop_mark_1 (); break; } !if (bsearch ("/*")) break; } } private define c_looking_at (token) { variable cse = CASE_SEARCH, ret = 0; CASE_SEARCH = 1; if (looking_at(token)) { push_spot (); go_right(strlen(token)); _get_point (); skip_chars ("\t :({"); ret = (_get_point () - ()) or eolp(); pop_spot (); } CASE_SEARCH = cse; ret; } private define c_indent_to (n) { bol (); % Force a reindent if the line does not contain tabs followed by spaces. skip_chars ("\t"); skip_chars (" "); if ((what_column != n) or (_get_point () != (skip_white (), _get_point ()))) { bol_trim (); n--; whitespace (n); } } private define c_indent_preprocess_line () { variable col; push_spot_bol (); trim (); !if (up_1 ()) { pop_spot (); return; } !if (bol_bsearch_char ('#')) { pop_spot (); return; } go_right_1 (); skip_white (); col = what_column (); if (looking_at ("if")) col += C_Preprocess_Indent; else if (looking_at ("el")) col += C_Preprocess_Indent; pop_spot (); go_right_1 (); skip_white (); % what does all this do - looking at 'endif' perhaps ? !if (looking_at ("error")) { if (looking_at_char ('e')) col -= C_Preprocess_Indent; } if (what_column () == col) return; bskip_white (); trim (); whitespace (col - 2); } private define c_indent_continued_comment (col) { push_spot (); col++; % add 1 so that we indent under * in /* c_indent_to (col); if (looking_at_char ('*') or not (eolp ())) pop_spot (); else { insert ("* "); pop_spot (); if (what_column () <= col) { goto_column (col + 2); } } } % % detect 1 or 2 character tokens at the beginning of the line % that would appear to be operators. % this is useful for nice alignment on (space-delimited) operators % within parentheses % eg, % while % ( % expr1 % + expr2 % == expr3 % ) ... % % returns the outdent value including the space (0, -2 or -3) % private define c_outdent_operator() { variable len; push_spot(); bol_skip_white(); EXIT_BLOCK { pop_spot(); } % avoid false positives on comments and iostream if (looking_at ("/*") or looking_at ("//")) return 0; % leave iostream alone if (looking_at ("<<") or looking_at (">>")) return 0; len = _get_point (); skip_chars("-+*/!&<=>|?:"); % assignment, comparison, logicals, ternary len -= _get_point(); _get_point (); skip_white (); if ((_get_point () - ()) or eolp()) { % isolated len--; % include space-separator if ((len == -2) or (len == -3)) { return len; } } return 0; } private define c_mode_if_bol_skip_white () { push_mark (); bskip_white (); 1; if (bolp ()) { pop (); skip_white (); 0; } pop_mark (()); % take argument from stack } private define continued_statement_bol () { while (up_1 ()) { !if (blooking_at_continuation_char ()) { go_down_1 (); break; } } bol (); } #iftrue % Return true if the spot is inside of a class definition % Takes the opening brace of the enclosing block as an % argument. private define inside_class_or_namespace (bra, name) { push_spot (); EXIT_BLOCK { pop_spot (); } % Assume that class/namespace is at the beginning of a line. % We may want to change this assumption later. % This function can be expensive if the indent_line function is % called in a loop. Get out quickly if the buffer does not have % a class or namespace block. ifnot (bol_bsearch (name)) { if ((name != "class") || (0 == bol_bsearch (name))) return 0; } goto_user_mark (bra); variable re = sprintf ("\\c\\<%s\\>", name); while (re_bsearch (re)) { if (name == "class") { bskip_chars (" \t<"); % allow: template !~?.!")) extra_indent = 0; pop_spot(); } } c_indent_to (1 + extra_indent + prep_indent); pop_spot (); return; } } { case 1: % within a (...) grouping extra_indent = 0; % match found prep_indent = 0; #iftrue % starting brace was alone on its line - % indent contents like a {...} block if (C_Bracket_Indent > 0) { if (col == match_indent_column + 1) { if (C_Bracket_Indent > C_INDENT) extra_indent = C_Bracket_Indent; else extra_indent = C_INDENT; extra_indent--; % col already incremented % outdent operators, logicals and comparisons if (extra_indent >= 3) extra_indent += c_outdent_operator(); } } #endif if (C_Param_Offset_Max >= 0) if (col - match_indent_column > C_Param_Offset_Max) extra_indent = match_indent_column + C_Param_Offset_Max - col; } { case -2: % inside comment if (cmode_is_slang_mode ()) return; if (line_start_char != '\\') col++; c_indent_continued_comment (col); return; } { case 2 or case -1: % inside string or no info push_spot_bol (); trim (); pop_spot (); return; } { case -3: % inside C++ comment !if ((looking_at(notCcomment)) or not(eolp())) { goto_column(col); if (C_Autoinsert_CPP_Comments) insert(notCcomment); } return; } switch (line_start_char) { case '}': col -= C_INDENT; if (not_indenting_pp) col -= extra_indent; % counteract default addition } { case '{': col += C_BRACE; if (is_continuation) col -= C_CONTINUED_OFFSET; } col += extra_indent; push_spot (); c_indent_to (col + prep_indent); pop_spot (); } % This function returns zero if the line does not begin with "* @ " % or returns the indent column if it does. This combination of characters % will most certainly appear in a comment. See the c file jed/src/intrin.c % for examples of how it is exploited. private define c_is_comment_example () { push_spot (); bol_skip_white (); 0; if (looking_at ("* @ ")) { pop (); what_column (); } pop_spot (); } define c_newline_and_indent () { variable notCcomment = "//"; if (bolp ()) { newline (); indent_line (); return; } if (cmode_is_slang_mode ()) { variable slcom = "%"; push_spot_bol (); if (looking_at (slcom) and C_Autoinsert_CPP_Comments) { push_mark (); skip_chars ("%!"); skip_white (); slcom = bufsubstr (); pop_spot (); newline (); insert (slcom); return; } pop_spot (); notCcomment = "%%"; } variable col; variable notcomment_len = strlen (notCcomment); if (C_Autoinsert_CPP_Comments) { col = what_column (); push_spot_bol(); if (looking_at(notCcomment)) { push_mark (); go_right (notcomment_len); skip_white (); notCcomment = bufsubstr (); pop_spot (); newline(); if (col > notcomment_len) insert(notCcomment); return; } pop_spot(); } col = c_is_comment_example (); newline (); if (col) { c_indent_to (col); insert ("* @ "); } else indent_line (); } private define c_parse_to_point () { parse_to_point () or c_is_comment_example (); } define c_insert_bra () { if (c_parse_to_point ()) insert_char ('{'); else { push_spot (); c_bskip_over_comment (0); if (blooking_at (","), pop_spot ()) { insert_char ('{'); } else { push_spot (); skip_white (); if (eolp ()) { bskip_white (); if (not (bolp ()) and C_BRA_NEWLINE, pop_spot ()) newline (); push_spot (); bskip_white (); bolp (); % on stack pop_spot (); insert_char ('{'); if ( () ) indent_line (); % off stack eol (); if (C_BRA_NEWLINE) c_newline_and_indent (); } else { pop_spot (); insert_char ('{'); } } } } define c_insert_ket () { variable status = c_parse_to_point (); variable line = what_line (); push_spot (); skip_white (); push_spot (); if (status or not (eolp ()) or (1 == find_matching_delimiter ('}')) and (line == what_line ())) { pop_spot (); pop_spot (); insert_char ('}'); blink_match (); return; } pop_spot (); bskip_white (); if (bolp (), pop_spot ()) { insert_char ('}'); trim (); } else { eol (); insert ("\n}"); } indent_line (); eol (); blink_match (); if (C_BRA_NEWLINE) c_newline_and_indent (); } define c_insert_colon () { insert_char (':'); !if (c_parse_to_point ()) indent_line (); } $1 = "C"; !if (keymap_p ($1)) make_keymap ($1); definekey ("indent_line", "\t", $1); definekey ("newline_and_indent", "\r", $1); definekey ("c_insert_bra", "{", $1); definekey ("c_insert_ket", "}", $1); definekey ("c_insert_colon", ":", $1); definekey ("c_make_comment", "\e;", $1); %definekey ("c_comment_region", "^X;", $1); % definekey ("c_format_paragraph", "\eq", $1); definekey ("c_top_of_function", "\e^A", $1); definekey ("c_end_of_function", "\e^E", $1); definekey ("c_mark_function", "\e^H", $1); % Now create and initialize the syntax tables. create_syntax_table ("C"); define_syntax ("/*", "*/", '%', "C"); define_syntax ("//", "", '%', "C"); define_syntax ("([{", ")]}", '(', "C"); define_syntax ('"', '"', "C"); define_syntax ('\'', '\'', "C"); define_syntax ('\\', '\\', "C"); define_syntax ("0-9a-zA-Z_", 'w', "C"); % words define_syntax ("-+0-9a-fA-F.xXL", '0', "C"); % Numbers define_syntax (",;.?:", ',', "C"); define_syntax ('#', '#', "C"); define_syntax ("%-+/&*=<>|!~^", '+', "C"); set_syntax_flags ("C", 0x4|0x40); #ifdef HAS_DFA_SYNTAX %%% DFA_CACHE_BEGIN %%% private define setup_dfa_callback (name) { dfa_enable_highlight_cache("cmode.dfa", name); dfa_define_highlight_rule("^[ \t]*#", "PQpreprocess", name); dfa_define_highlight_rule("//.*", "comment", name); dfa_define_highlight_rule("/\\*.*\\*/", "Qcomment", name); dfa_define_highlight_rule("^([^/]|/[^\\*])*\\*/", "Qcomment", name); dfa_define_highlight_rule("/\\*.*", "comment", name); dfa_define_highlight_rule("^[ \t]*\\*+([ \t].*)?$", "comment", name); dfa_define_highlight_rule("[A-Za-z_\\$][A-Za-z_0-9\\$]*", "Knormal", name); dfa_define_highlight_rule("[0-9]+(\\.[0-9]*)?([Ee][\\+\\-]?[0-9]*)?", "number", name); dfa_define_highlight_rule("0[xX][0-9A-Fa-f]*[LlUu]*", "number", name); dfa_define_highlight_rule("[0-9]+[LlUu]*", "number", name); dfa_define_highlight_rule("\"([^\"\\\\]|\\\\.)*\"", "string", name); dfa_define_highlight_rule("\"([^\"\\\\]|\\\\.)*\\\\?$", "string", name); dfa_define_highlight_rule("'([^'\\\\]|\\\\.)*'", "string", name); dfa_define_highlight_rule("'([^'\\\\]|\\\\.)*\\\\?$", "string", name); dfa_define_highlight_rule("[ \t]+", "normal", name); dfa_define_highlight_rule("[\\(\\[{}\\]\\),;\\.\\?:]", "delimiter", name); dfa_define_highlight_rule("[%\\-\\+/&\\*=<>\\|!~\\^]", "operator", name); dfa_build_highlight_table(name); } dfa_set_init_callback (&setup_dfa_callback, "C"); %%% DFA_CACHE_END %%% #endif % Type 0 keywords (include C++ trigraphs) #iffalse () = define_keywords_n ("C", "doif", 2, 0); #else () = define_keywords_n ("C", "doifor", 2, 0); #endif () = define_keywords_n ("C", "andasmforintnewnottryxor", 3, 0); () = define_keywords_n ("C", "autoboolcasecharelseenumgotolongthistruevoid", 4, 0); #iffalse () = define_keywords_n ("C", "breakcatchclassconstfalsefloatshortthrowunionusingwhile", 5, 0); () = define_keywords_n ("C", "deletedoubleexternfriendinlinepublicreturnsignedsizeofstaticstructswitchtypeid", 6, 0); #else () = define_keywords_n ("C", "bitorbreakcatchclasscomplconstfalsefloator_eqshortthrowunionusingwhile", 5, 0); () = define_keywords_n ("C", "and_eqbitanddeletedoubleexportexternfriendinlinenot_eqpublicreturnsignedsizeofstaticstructswitchtypeidxor_eq", 6, 0); #endif () = define_keywords_n ("C", "defaultmutableprivatetypedefvirtualwchar_t", 7, 0); () = define_keywords_n ("C", "continueexplicitoperatorregistertemplatetypenameunsignedvolatile", 8, 0); () = define_keywords_n ("C", "namespaceprotected", 9, 0); () = define_keywords_n ("C", "const_cast", 10, 0); () = define_keywords_n ("C", "static_cast", 11, 0); () = define_keywords_n ("C", "dynamic_cast", 12, 0); () = define_keywords_n ("C", "reinterpret_cast", 16, 0); % Type 1 keywords (commonly used libc functions) () = define_keywords_n("C", "EOFabscosdivexplogpowsintan", 3, 1); () = define_keywords_n("C", "FILENULLacosasinatanatofatoiatolceilcosh" + "exitfabsfeoffmodfreegetcgetslabsldivmodf" + "putcputsrandsinhsqrttanhtime", 4, 1); () = define_keywords_n("C", "abortatan2clockctimediv_terrnofgetcfgets" + "floorfopenfputcfputsfreadfrexpfseekftell" + "ldexplog10qsortraisescanfsrandstdin", 5, 1); () = define_keywords_n("C", "assertatexitcallocfcloseferrorfflushfscanf" + "fwritegetenvgmtimemallocmemchrmemcmpmemcpy" + "memsetmktimeperrorprintfremoverenamerewind" + "setbufsetjmpsignalsize_tsscanfstderrstdout" + "strcatstrchrstrcmpstrcpystrlenstrspnstrstr" + "strtodstrtokstrtolsystemtime_ttmpnamungetc" + "va_argva_end", 6, 1); () = define_keywords_n("C", "asctimebsearchclock_tfgetposfprintffreopen" + "fsetposgetcharisalnumisalphaiscntrlisdigit" + "isgraphislowerisprintispunctisspaceisupper" + "jmp_buflongjmpmemmoveputcharreallocsetvbuf" + "sprintfstrcspnstrncatstrncmpstrncpystrpbrk" + "strrchrstrtoultmpfiletolowertoupperva_list" + "vprintf", 7, 1); () = define_keywords_n("C", "clearerrdifftimeisxdigitstrerror" + "strftimeva_startvfprintfvsprintf", 8, 1); () = define_keywords_n("C", "localtime", 9, 1); _debug_info = 1; private define get_function_names (names) { for (;c_bol_fsearch ("{");pop_spot (), eol ()) { push_spot (); go_left_1 (); if (blooking_at ("\\")) { % probably a macro --- skip it continue; } % get the function name c_bskip_over_comment (1); if (blooking_at (")")) { go_left_1 (); if (1 != find_matching_delimiter (')')) continue; c_bskip_over_comment (1); % In SLang you can write statements at the same level like % functions they look like functions but aren't it. variable id = bextract_identifier (); if (0 == any (id == ["for", "_for", "loop", "foreach", "while", "if", "ifnot"])) names[id] = what_line (); } } } private define get_macro_names (names) { while (c_re_fsearch ("^[ \t]*#[ \t]*define[ \t]+")) { () = ffind ("define"); go_right (6); skip_chars (" \t\\\\"); names [extract_identifier ()] = what_line (); } } private define get_typedef_names (names) { while (c_re_fsearch ("\\")) { go_right (7); skip_all_whitespace (); if (looking_at ("struct")) { go_right (6); skip_over_comment (); skip_identifier (); % struct tag skip_over_comment (); if (looking_at_char ('{')) { !if (find_matching_delimiter ('{')) continue; go_right_1 (); } } () = c_fsearch (";"); c_bskip_over_comment (1); names [bextract_identifier ()] = what_line(); } } private define process_menu_popup (popup, func) { variable names = Assoc_Type[Int_Type]; push_spot_bob (); (@func) (names); pop_spot (); variable keys = assoc_get_keys (names); keys = keys[array_sort (keys)]; foreach (keys) { variable key = (); variable line = names[key]; menu_append_item (popup, key, &goto_line, line); } } private define macros_popup_callback (popup) { process_menu_popup (popup, &get_macro_names); } private define functions_popup_callback (popup) { process_menu_popup (popup, &get_function_names); } private define typedefs_popup_callback (popup) { process_menu_popup (popup, &get_typedef_names); } public define c_init_menu (menu) { menu_append_popup (menu, "&Functions"); menu_set_select_popup_callback (strcat (menu, ".&Functions"), &functions_popup_callback); if (cmode_is_slang_mode () == 0) { menu_append_popup (menu, "M&acros"); menu_append_popup (menu, "&Typedefs"); menu_set_select_popup_callback (strcat (menu, ".M&acros"), ¯os_popup_callback); menu_set_select_popup_callback (strcat (menu, ".&Typedefs"), &typedefs_popup_callback); } menu_append_separator (menu); menu_append_item (menu, "&Comment Region", "comment_region"); menu_append_item (menu, "&Top of Function", "c_top_of_function"); menu_append_item (menu, "&End of Function", "c_end_of_function"); menu_append_item (menu, "&Mark Function", "c_mark_function"); menu_append_item (menu, "&Format Buffer", "c_indent_buffer"); } private define c_chglog_get_item () { variable m = create_user_mark (); EXIT_BLOCK { goto_user_mark (m); } ERROR_BLOCK { _clear_error (); goto_user_mark (m); return NULL; } % First check for a preprocessor macro. bol (); while (blooking_at ("\\\n")) { go_left_1 (); bol (); } skip_white (); if (looking_at_char ('#')) { go_right_1 (); skip_white (); if (looking_at ("define")) { go_right (6); skip_white (); return extract_identifier (); } } goto_user_mark (m); % check for variable bol (); skip_identifier (); if (not(bolp ()) and ffind("=")) { bskip_white (); return bextract_identifier (); } % Now try function goto_user_mark (m); c_end_of_function (); variable m_end = create_user_mark (); if (m > m_end) return NULL; c_top_of_function (); c_bskip_over_comment (1); if (blooking_at (")")) { go_left_1 (); if (1 != find_matching_delimiter (')')) return NULL; } c_bskip_over_comment (1); !if (blooking_at ("typedef struct")) return bextract_identifier (); goto_user_mark (m_end); skip_chars ("} \t\n"); return extract_identifier (); } % This function is called by slang_mode to share the keymap and some hooks define c_mode_common () { use_keymap("C"); set_buffer_hook ("indent_hook", "c_indent_line"); set_buffer_hook ("newline_indent_hook", "c_newline_and_indent"); foreach (["C", "SLang"]) { variable mode = (); mode_set_mode_info (mode, "init_mode_menu", &c_init_menu); mode_set_mode_info (mode, "chglog_get_item", &c_chglog_get_item); } } %!%+ %\function{c_mode} %\synopsis{c_mode} %\usage{Void cmode ();} %\description % This is a mode that is dedicated to facilitate the editing of C language files. % Functions that affect this mode include: %#v+ % function: default binding: % c_insert_bra { % c_insert_ket } % newline_and_indent RETURN % indent_line TAB % goto_match Ctrl-\ % c_make_comment ESC ; % c_top_of_function ESC Ctrl-A % c_end_of_function ESC Ctrl-E % c_mark_function ESC Ctrl-H %#v- % Variables affecting indentation include: %#v+ % C_INDENT % C_BRACE % C_BRA_NEWLINE % C_CONTINUED_OFFSET % C_Comment_Column (used by c_make_comment) % C_Class_Offset % C_Switch_Offset % C_Colon_Offset % C_Namespace_Offset %#v- % % Hooks: \var{c_mode_hook} %\seealso{c_set_style} %!%- define c_mode () { set_mode("C", 2); c_mode_common (); set_buffer_hook ("par_sep", "c_paragraph_sep"); set_buffer_hook ("format_paragraph_hook", &c_format_paragraph); mode_set_mode_info ("C", "fold_info", "/*{{{\r/*}}}\r*/\r*/"); mode_set_mode_info ("C", "dabbrev_case_search", 1); use_syntax_table ("C"); run_mode_hooks("c_mode_hook"); } %!%+ %\function{c_set_style} %\synopsis{Set the indentation style for C mode} %\usage{Void c_set_style (style)} %\description % This function sets the C mode indentation variables appropriate for % a common indentation style. Currently supported styles include: %#v+ % "gnu" Style advocated by GNU % "k&r" Style popularized by Kernighan and Ritchie % "bsd" Berkeley style % "foam" Derivate bsd-style used in OpenFOAM % "linux" Linux kernel indentation style % "jed" Style used by the author % "kw" The Kitware style used in ITK, VTK, ParaView, ... %#v- %\seealso{c_mode} %!%- define c_set_style (name) { switch (strlow(name)) { case "gnu": (2,2,1,2,0,2,2,2,0,0,0); } { case "k&r": (5,0,0,5,0,5,5,5,0,0,0); } { case "bsd": (4,0,0,4,0,4,4,4,0,0,0); } { case "foam": (C_Switch_Offset, C_Param_Offset_Max) = (4, -1); (4,0,0,4,0,4,0,4,0,0,0); } { case "linux": (8,0,0,8,0,8,8,8,0,0,0); } { case "jed": (3,2,1,2,1,3,3,3,0,0,0); } { case "kw": (0,2,1,2,1,2,2,2,0,0,2); } { if (is_defined ("c_set_style_hook") > 0) return eval(sprintf ("c_set_style_hook(\"%s\");", name)); } (C_INDENT, C_BRACE, C_BRA_NEWLINE, C_CONTINUED_OFFSET, C_Colon_Offset, C_Class_Offset, C_Namespace_Offset, C_Macro_Indent, C_Label_Offset, C_Label_Indents_Relative, C_Outer_Block_Offset ) = (); _C_Indentation_Style = name; } if (_C_Indentation_Style != NULL) c_set_style (_C_Indentation_Style); provide ("cmode"); jed-0.99-19/lib/shell.sl0000644002657400265740000001443311311317447013714 0ustar davisdavis% -*- mode: slang; mode: fold; -*- % % %% system specific routines if (_jed_secure_mode) %{{{ { error ("Shell not available"); } %}}} variable Shell_Last_Shell_Command = Null_String; variable Shell_Prompt; #ifdef UNIX Shell_Prompt = "% "; #endif #ifdef IBMPC_SYSTEM Shell_Prompt = "> "; #endif #ifdef VMS Shell_Prompt = "$ "; #endif #ifdef MSDOS % pass "(cmd) 2>&1" contructs to the system as "(cmd) > tmpfile 2>&1" define run_shell_cmd (cmd) %{{{ { variable msg = "Executing shell cmd..."; variable tmp, dir; dir = getenv ("TMP"); if (dir == NULL) dir = ""; if (2 != file_status (dir)) (,dir,,) = getbuf_info (); % get directory tmp = dircat (dir, "_jed_shl.cmd"); flush (msg); %% if ( is_substr (cmd, "2>&1") ) %% both; %% argv = extract_element (cmd, 1, ' '); if (system (sprintf ("%s &> %s", cmd, tmp)) < 0) error ("system failed."); () = insert_file (tmp); flush (strcat (msg, "done")); delete_file (tmp); % value returned } %}}} #endif #ifdef VMS define run_shell_cmd (cmd) %{{{ { variable cfile, file = "_jed_shell.cmd_"; variable tmpdir; tmpdir = getenv ("SYS$SCRATCH"); if (tmpdir == NULL) tmpdir = "SYS$LOGIN:"; file = dircat (tmpdir, file); cfile = expand_jedlib_file ("vms_shell.com"); !if ( strlen (cfile) ) error ("Unable to open vms_shell.com"); flush ("starting process ..."); () = system ((sprintf ("@%s/output=%s \"%s\"", cfile, file, cmd))); () = insert_file (file); delete_file (file); % value returned } %}}} #endif private define shell_set_output_buffer () %{{{ { variable dir, file, name, flags; (,dir,,) = getbuf_info (); if ( change_default_dir (dir) ) error ("Unable to chdir!"); pop2buf ("*shell-output*"); erase_buffer (); (file,,name, flags) = getbuf_info (); setbuf_info (file, dir,name, flags); } %}}} public define shell_perform_cmd (cmd, same_buf) %{{{ { variable status; !if (same_buf) shell_set_output_buffer (); push_spot (); status = run_shell_cmd (cmd); pop_spot (); !if (same_buf) set_buffer_modified_flag (0); vmessage ("Exit Status: %d", status); } %}}} public define do_shell_cmd () %{{{ { variable cmd, dir; variable same_buf = (-9999 != prefix_argument (-9999)); if (_NARGS) cmd = (); else { (,dir,,) = getbuf_info (); cmd = read_mini (sprintf ("(%s) Shell Cmd:", dir), "", Shell_Last_Shell_Command); !if ( strlen (cmd) ) return; Shell_Last_Shell_Command = cmd; } shell_perform_cmd (sprintf ( # ifdef OS2 "(%s) 2>&1", # elifdef UNIX "(%s) 2>&1 < /dev/null", # else "%s", # endif cmd), same_buf); } %}}} public define shell () %{{{ { variable dir, buf = "*shell*"; !if ( keymap_p (buf) ) { make_keymap (buf); definekey ("shell_input", "^M", buf); } (,dir,,) = getbuf_info (); % get directory if ( change_default_dir (dir) ) error ("Unable to chdir!"); pop2buf (buf); use_keymap (buf); vinsert ("\n(%s)\n%s", dir, Shell_Prompt); % no backup (0x100), no save ~(0x80), no undo ~(0x20), no autosave ~(0x2) % unmodified ~(0x1) getbuf_info (); setbuf_info ((() | 0x100) & ~(0xA3)); run_mode_hooks ("shell_mode_hook"); } %}}} %!%+ %\function{shell_builtin} %\synopsis{shell_builtin} %\description % rudimentary `builtin' shell commands: % `cd [dir]' change the default directory % `exit' exit the subshell % `pwd' Print Working Directory % % functions to eliminate some jed/shell vs. real shell problems % `clear' erase the *shell* buffer % `e' simulate ^X^F keybinding % `jed' simulate ^X^F keybinding % % % returns one of the following on the stack % Null_String - builtin dispatched, no prompt % "pwd" - builtin dispatched, give prompt % cmd - use shell to execute CMD %!%- define shell_builtin (cmd) %{{{ { variable argv, dir, buf, flag, pwd = "pwd"; variable cmd1 = strcompress (cmd, " \t"); (,dir,buf,flag) = getbuf_info (); % cwd info argv = extract_element (cmd, 0, ' '); % parse cmd switch (argv) % simple "aliases" {case pwd: argv; } % 'pwd'='pwd' (no args) #ifdef UNIX {case "dir": % 'dir'='ls -Al' [dir [dir]] () = str_replace (cmd, argv, "ls -Al"); } #endif {case "clear": erase_buffer; pwd;} % 'clear'=erase_buffer() {case "exit": % 'exit' set_buffer_modified_flag (0); delbuf (buf); Null_String; } {case "cd": % 'cd' [dir] argv = extract_element (cmd1, 1, ' '); if (argv == NULL) #ifdef MSDOS OS2 return pwd; #else argv = "~/"; #endif argv = expand_filename (argv); if ( change_default_dir (argv) ) insert ("Unable to chdir!\n"); else setbuf_info (Null_String, argv, buf, flag); pwd; % only "pwd" pending } {case "jed" or case "e": % jed argv = extract_element (cmd1, 1, ' '); if (argv != NULL) () = find_file (expand_filename (dircat (dir, argv))); Null_String; % nothing pending } {cmd;} % default = failure, cmd still pending } %}}} define shell_input () %{{{ { variable cmd, dir, tmp; bol (); skip_chars (Shell_Prompt); skip_white (); push_mark_eol (); cmd = bufsubstr (); eob (); bol (); skip_chars (Shell_Prompt); skip_white (); !if ( looking_at (cmd) ) insert (cmd); eol (); newline (); update (0); % Update now so user see that things are ok if ( strlen (cmd) ) { cmd = shell_builtin (cmd); !if ( strlen (cmd) ) { update (0); return; } (,dir,,) = getbuf_info (); % get directory if ( change_default_dir (dir) ) error ("Unable to chdir!"); if ( strcmp (cmd, "pwd") ) % not "pwd" { #ifdef VMS tmp = make_tmp_file ("sys$login:_jed_shell_."); variable file = expand_jedlib_file ("vms_shell.com"); !if ( strlen (file) ) error ("Unable to find vms_shell.com"); () = system (sprintf ("@%s/output= %s %s", file, tmp, cmd)); () = insert_file (tmp); () = delete_file (tmp); #else #ifdef MSDOS MSWINDOWS WIN32 shell_cmd (cmd); #else shell_cmd (sprintf ("(%s) 2>&1", cmd)); #endif #endif } vinsert ("\n(%s)\n%s", dir, Shell_Prompt); } else { !if ( bolp () ) newline (); insert (Shell_Prompt); } set_buffer_modified_flag (0); #ifdef OS2 update (1); % Update due to problems with Borland C #endif } %}}} %%%%%%%%%%%%%%%%%%%%%%%%%% jed-0.99-19/lib/pipe.sl0000644002657400265740000000111011311317447013526 0ustar davisdavisvariable Last_Process_Command = Null_String; define process_region () { variable cmd, tmp_file; cmd = read_mini ("Pipe to command:", Last_Process_Command, Null_String); !if (strlen (cmd)) return; Last_Process_Command = cmd; tmp_file = make_tmp_file ("/tmp/jedpipe"); cmd = strncat (cmd, " > ", tmp_file, " 2>&1", 4); !if (dupmark ()) error ("Mark not set."); if (pipe_region (cmd)) { error ("Process returned a non-zero exit status."); } del_region (); () = insert_file (tmp_file); () = delete_file (tmp_file); } jed-0.99-19/lib/rot13.sl0000644002657400265740000000076411311317447013557 0ustar davisdavis%% %% rot13.sl---- rotates text by 13 characters %% define rot13 () { variable i, j; check_region (1); % spot pushed variable a = String_Type[256]; _for ('A', 'M', 1) { i = (); a[i] = char (i + 13); % Now take care of lower case ones i = i | 0x20; a[i] = char (i + 13); } _for ('N', 'Z', 1) { i = (); a[i] = char (i - 13); % Now take care of lower case ones i = i | 0x20; a[i] = char (i - 13); } translate_region (a); pop_spot (); } jed-0.99-19/lib/bookmark.sl0000644002657400265740000000317211311317447014410 0ustar davisdavis% These routines user 'user_marks' to implement book marks. A book mark % may be placed in any buffer and returning to the mark may cause a change % of buffer. % The only functions that are considered external are 'bkmrk_set_mark' % and 'bkmrk_goto_mark'. These functions prompt for a a key '0' - '9' % or a SPACE. private variable Book_Marks = Mark_Type [10]; private variable Bkmrk_Last_Position = NULL; private define bkmrk_get_or_set_mark (get) { variable n; variable prompt; variable m; if ((Bkmrk_Last_Position != NULL) and get) get = 2; prompt = "Bookmark number:"; if (get == 2) prompt = "Bookmark number or SPACE for last position:"; n = get_mini_response (prompt); if ((get == 2) and (n == ' ')) return Bkmrk_Last_Position; n -= '0'; if ((n < 0) or (n > 9)) error ("Number must be less than 10"); if (get) return Book_Marks[n]; Book_Marks[n] = create_user_mark (); vmessage ("Bookmark %d set.", n); } define bkmrk_set_mark () { bkmrk_get_or_set_mark (0); } define bkmrk_goto_mark () { variable mrk = bkmrk_get_or_set_mark (1); if (mrk == NULL) error ("Bookmark has not been set"); Bkmrk_Last_Position = create_user_mark (); sw2buf (mrk.buffer_name); !if (is_user_mark_in_narrow (mrk)) { #ifdef HAS_BLOCAL_VAR variable fun; try { fun = get_blocal_var ("bookmark_narrow_hook"); mrk; eval (fun); } catch AnyError: throw UsageError, "Mark lies outside visible part of buffer."; #else error ("Mark lies outside visible part of buffer."); #endif } goto_user_mark (mrk); message ("done"); } jed-0.99-19/lib/fortran.sl0000644002657400265740000002521411311317447014257 0ustar davisdavis% Fortran mode -* SLang -*- % % Loading this file, then executing 'fortran_mode' will start fortran mode % on the current buffer. custom_variable ("Fortran_Continue_Char", "&"); custom_variable ("Fortran_Comment_String", "C"); custom_variable ("Fortran_Indent_Amount", 2); % Skip past labels and continuation char private define bol_skip_to_code_start () { bol (); skip_chars ("0-9 \t"); if (looking_at(Fortran_Continue_Char)) go_right_1 (); skip_white (); } private define indent_line_to_col (col) { bol_skip_white (); skip_chars ("0-9"); trim (); if (looking_at (Fortran_Continue_Char)) { insert_spaces (6 - what_column()); go_right_1 (); trim(); col += Fortran_Indent_Amount; } insert_spaces (col - what_column()); } % fortran indent routine define fortran_indent () { variable goal = 7; % at top of buffer it should be 7 n'est pas? variable cs = CASE_SEARCH; variable ch; push_spot (); push_spot (); CASE_SEARCH = 0; % Fortran is not case sensitive while (up_1 ()) { bol_skip_white(); if (eolp() or looking_at(Fortran_Continue_Char)) continue; bol_skip_to_code_start (); goal = what_column (); if (goal == 1) continue; if (looking_at("do ") or looking_at("else")) goal += Fortran_Indent_Amount; else if (looking_at("if ") or looking_at("if(")) { % We want to check for 'then' so take care of continuations push_spot (); while (down_1 ()) { bol_skip_white (); !if (looking_at (Fortran_Continue_Char)) { go_up_1 (); bol (); break; } } if (ffind ("then")) goal += Fortran_Indent_Amount; pop_spot (); } break; } % now check current line pop_spot (); push_spot (); bol_skip_to_code_start (); push_mark (); skip_chars ("a-zA-Z"); variable word = strlow (bufsubstr ()); if ((word == "end") || (word == "endif") || (word == "enddo") || (word == "continue") || (word == "else")) goal -= Fortran_Indent_Amount; CASE_SEARCH = cs; % done getting indent if (goal < 7) goal = 7; pop_spot (); bol_skip_white (); % after the label or continuation char and indent the rest to goal ch = char(what_char()); switch (ch) { isdigit (ch) : % label if (what_column () >= 6) { bol_trim (); insert_single_space (); } indent_line_to_col (goal); } { case Fortran_Continue_Char : % continuation character bol_trim (); insert_spaces (5); indent_line_to_col (goal); } { not (bolp()) or eolp (): % general case bol_trim (); goal--; insert_spaces (goal); } pop_spot (); skip_white (); } define fortran_is_comment () { bol (); skip_chars (" \t0-9"); bolp () and not (eolp()); } define fortran_newline () { variable p, cont; if (bolp ()) { newline (); return; } fortran_indent (); push_spot (); bskip_white (); trim (); if (what_column () > 72) { push_spot (); bol_skip_white(); !if (bolp()) message ("Line exceeds 72 columns."); pop_spot (); } p = _get_point (); bskip_chars("-+*=/,("); cont = (p != _get_point ()); if (fortran_is_comment ()) cont = 0; bol_skip_white (); if (looking_at("data ")) cont = 0; pop_spot (); newline (); insert_single_space (); if (cont) insert(Fortran_Continue_Char); fortran_indent (); } define fortran_continue_newline () { fortran_newline (); push_spot (); bol_skip_white (); if (looking_at(Fortran_Continue_Char)) pop_spot (); else { insert (Fortran_Continue_Char); pop_spot (); fortran_indent (); go_right_1 (); skip_white (); } } % % electric labels % define fortran_electric_label () { insert_char (LAST_CHAR); push_spot (); if (fortran_is_comment ()) pop_spot (); else { bol_skip_white (); skip_chars ("0-9"); trim (); pop_spot (); fortran_indent (); } } % fortran comment/uncomment functions define fortran_uncomment () { push_spot (); if (fortran_is_comment ()) { bol (); if (looking_at (Fortran_Comment_String)) deln (strlen (Fortran_Comment_String)); else del (); } fortran_indent (); pop_spot (); go_down_1 (); } define fortran_comment () { !if (fortran_is_comment ()) { push_spot_bol (); insert (Fortran_Comment_String); } pop_spot (); go_down_1 (); } % % Look for beginning of current subroutine/function % define fortran_beg_of_subprogram () { variable cs = CASE_SEARCH; CASE_SEARCH = 0; do { bol_skip_white (); if (_get_point ()) { if (looking_at ("program") or looking_at ("function") or looking_at ("subroutine")) break; } } while (up_1 ()); CASE_SEARCH = cs; } % % Look for end of current subroutine/function % define fortran_end_of_subprogram () { variable cs = CASE_SEARCH; CASE_SEARCH = 0; do { bol_skip_white (); if (looking_at ("end")) { go_right (3); skip_white (); if (eolp ()) break; } } while (down_1 ()); CASE_SEARCH = cs; } define fortran_mark_subprogram () { fortran_end_of_subprogram (); go_down_1 (); set_mark_cmd (); fortran_beg_of_subprogram (); bol (); } % % shows a ruler for FORTRAN source. Press any key to get rid of % define fortran_ruler () { variable c = what_column (); variable r = window_line (); bol (); push_mark (); insert (" 5 7 10 15 20 25 30 35 40 45 50 55 60 65 70\n"); insert ("{ }|{ | | | | | | | | | | | | | }\n"); goto_column (c); if (r <= 2) r = 3; recenter (r); message ("Press SPACE to get rid of the ruler."); update_sans_update_hook (1); () = getkey (); bol (); del_region (); goto_column (c); flush_input (); recenter (r); } define fortran_prev_next_statement (dirfun) { while (@dirfun ()) { bol (); skip_chars ("^0-9 \t\n"); !if (_get_point ()) break; } () = goto_column_best_try (7); } % % moves cursor to the next statement, skipping comment lines % define fortran_next_statement () { fortran_prev_next_statement (&down_1); } % % moves cursor to the previous fortran statement, skipping comments % define fortran_previous_statement () { fortran_prev_next_statement (&up_1); } % % main entry point into the fortran mode % $1 = "Fortran"; !if (keymap_p ($1)) make_keymap ($1); definekey ("fortran_comment", "\e;", $1); definekey ("fortran_uncomment", "\e:", $1); definekey ("fortran_continue_newline", "\e\r", $1); % next two really needed? not if using EDT or Emacs definekey ("self_insert_cmd", char('\''), $1); definekey ("self_insert_cmd", char('"'), $1); definekey ("fortran_beg_of_subprogram", "\e^A", $1); definekey ("fortran_end_of_subprogram", "\e^E", $1); definekey ("fortran_mark_function", "\e^H", $1); definekey_reserved ("fortran_next_statement", "^N", $1); definekey_reserved ("fortran_previous_statement", "^P", $1); definekey_reserved ("fortran_ruler", "^R", $1); _for (0, 9, 1) { $2 = (); definekey ("fortran_electric_label", string($2), $1); } % Set up syntax table $1 = "Fortran"; create_syntax_table ($1); define_syntax ("!", "", '%', $1); define_syntax ("([", ")]", '(', $1); define_syntax ('"', '"', $1); define_syntax ('\'', '"', $1); % define_syntax ('\\', '\\', $1); define_syntax ("0-9a-zA-Z_", 'w', $1); % words define_syntax ("-+0-9eEdD", '0', $1); % Numbers define_syntax (",.", ',', $1); define_syntax ('D', '#', $1); define_syntax ("-+/*=", '+', $1); set_syntax_flags ($1, 1 | 2); set_fortran_comment_chars ($1, "^0-9 \t\n"); % Fortran 77 keywords + include, record, structure, while: % backspace block % call character common complex continue % data dimension do double % else end enddo endfile endif entry equivalence exit external % format function % goto % if implicit include inquire integer intrinsic % logical % parameter pause precision program % real return rewind % save stop subroutine % then % while () = define_keywords ($1, "dogoifto", 2); () = define_keywords ($1, "end", 3); () = define_keywords ($1, "calldataelseexitgotoopenreadrealsavestopthen", 4); () = define_keywords ($1, "blockcloseenddoendifentrypauseprintwhilewrite", 5); () = define_keywords ($1, "commondoubleformatrecordreturnrewind", 6); () = define_keywords ($1, "complexendfileincludeinquireintegerlogicalprogram", 7); () = define_keywords ($1, "continueexternalfunctionimplicit", 8); () = define_keywords ($1, "backspacecharacterdimensionintrinsicparameterprecisionstructure", 9); () = define_keywords ($1, "subroutine", 10); () = define_keywords ($1, "equivalence", 11); () = define_keywords_n ($1, "eqgegtleltneor", 2, 1); () = define_keywords_n ($1, "andnot", 3, 1); () = define_keywords_n ($1, "true", 4, 1); () = define_keywords_n ($1, "false", 5, 1); %!%+ %\function{fortran_mode} %\synopsis{fortran_mode} %\description % Mode designed for the purpose of editing FORTRAN files. % After the mode is loaded, the hook 'fortran_hook' is called. % Useful functions include % % Function: Default Binding: % fortran_continue_newline ESC RETURN % indents current line, and creates a continuation line on next line. % fortran_comment ESC ; % comments out current line % fortran_uncomment ESC : % uncomments current line % fortran_electric_label 0-9 % Generates a label for current line or simply inserts a digit. % fortran_next_statement ^C^N % moves to next fortran statementm skips comment lines % fortran_previous_statement ^C^P % moves to previous fortran statement, skips comment lines % fortran_ruler ^C^R % inserts a ruler above the current line. Press any key to continue % fortran_beg_of_subprogram ESC ^A % moves cursor to beginning of current subroutine/function % fortran_end_of_subprogram ESC ^E % moves cursor to end of current subroutine/function % fortran_mark_subprogram ESC ^H % mark the current subroutine/function % % Variables include: % Fortran_Continue_Char --- character used as a continuation character. % By default, its value is "&" % Fortran_Comment_String --- string used by 'fortran_comment' to % comment out a line. The default string is "C "; % Fortran_Indent_Amount --- number of spaces to indent statements in % a block. The default is 2. %!%- define fortran_mode () { variable mode = "Fortran"; set_mode (mode, 0x4 | 0x10); use_keymap (mode); use_syntax_table (mode); set_buffer_hook ("indent_hook", "fortran_indent"); set_buffer_hook ("newline_indent_hook", "fortran_newline"); mode_set_mode_info (mode, "fold_info", "C{{{\rC}}}\r\r"); run_mode_hooks ("fortran_hook"); } jed-0.99-19/lib/README0000644002657400265740000000162111311317447013120 0ustar davisdavisMost of the files in this directory are written in the S-Lang language, which is the extension language of the editor. See for more information about the language. Please note that much of the code in these files may not be understandable to those with little exposure to S-Lang. Some of the code has been written in such a way that it byte-compiles to as few bytes as possible. For example, consider the go_down function which is used as: go_down (10); % Move down 10 lines site.sl defines this function as: define go_down() { () = down(); } which makes it appear not to take any arguments as all. However, this is equivalent to: define go_down (n) { () = down (n); } but the body of the latter version requires twice as many byte-codes. The implemented version allows the argument passed to `go_down' to stay on the stack to be picked up by the `down' function. jed-0.99-19/lib/gpg.sl0000644002657400265740000001166711311317447013370 0ustar davisdavisautoload ("open_filter_process", "syncproc"); autoload ("close_filter_process", "syncproc"); custom_variable ("GPG_Encrypt_Program", "gpg -c --batch --quiet -o - --passphrase-fd 0"); custom_variable ("GPG_Decrypt_Program", "gpg --decrypt --batch -o - --passphrase-fd 0"); private variable Passphrases = Assoc_Type[String_Type, ""]; private define check_is_encrypted (file) { variable ext = path_extname (file); if ((ext == ".gpg") or (ext == ".gpg#")) return 0; return -1; } private define read_mini_hidden (prompt, default) { if (default != NULL) { prompt += sprintf (" [** buffer default **]", default); } prompt += ":"; flush (prompt); variable s = ""; forever { variable ch = getkey (); if (ch == '\r') break; s += char (ch); } if ((s == "") and (default != NULL)) s = default; return s; } private define get_pass_phrase (path, use_blocal_phrase, set_blocal_phrase, confirm_phrase) { variable default_pass_phrase = NULL; variable file = path_basename (path); % if it's an autosave file, try to get the passphrase from the Passphrases assoc if (file[-1] == '#') { variable f = path_concat(path_dirname(path), strtrim(file, "#")); if (assoc_key_exists (Passphrases, f)) return Passphrases[f]; } if (use_blocal_phrase or set_blocal_phrase and (0 == blocal_var_exists ("_gpg_pass_phrase"))) create_blocal_var ("_gpg_pass_phrase"); if (use_blocal_phrase) default_pass_phrase = get_blocal_var ("_gpg_pass_phrase"); forever { variable p = read_mini_hidden (sprintf ("Passphrase for %s", file), default_pass_phrase); if (p == "") return NULL; if ((default_pass_phrase == NULL) and confirm_phrase) { if (p != read_mini_hidden ("Confirm Passphrase", NULL)) { flush ("Confirmation failed. Try again"); sleep (1); continue; } } if (set_blocal_phrase and (p != default_pass_phrase)) { if (1 == get_y_or_n ("Save passphrase as buffer-default")) set_blocal_var (p, "_gpg_pass_phrase"); } if (file[-1] != '#') Passphrases[path] = p; return p; } } private define _write_encrypted_region (file, append) { if (append) return 0; variable i = check_is_encrypted (file); if (i == -1) return 0; variable p = get_pass_phrase (file, 1, 1, 1); if (p == "") return 0; variable txt = bufsubstr (); variable cmd = sprintf ("%s > %s", GPG_Encrypt_Program, file); variable fp = popen (cmd, "w"); if (fp == NULL) verror ("%s failed", cmd); if (orelse {(-1 == fputs (p + "\n", fp))} {(-1 == fputs (txt, fp))} {(0 != pclose (fp))}) verror ("write to %s failed", cmd); return 1; } private define write_encrypted_region (file) { return _write_encrypted_region (file, 0); } private define parse_gpg_errors (file) { variable st = stat_file (file); if (st == NULL) return; if (0 == st.st_size) return; % For now, just insert the contents into a separate buffer. variable cbuf = whatbuf (); setbuf ("*gpg-errors*"); erase_buffer (); () = insert_file (file); % TODO: warnings such as these can probably be ignored. % gpg: CAST5 encrypted data % gpg: encrypted with 1 passphrase % gpg: WARNING: message was not integrity protected setbuf (cbuf); } private define _insert_encrypted_file (file, use_blocal_phrase, set_blocal_phrase, confirm_phrase) { variable i = check_is_encrypted (file); if (i == -1) return 0; if (1 != file_status (file)) return 0; variable stderr_filename = make_tmp_file ("gpgerr"); () = fopen (stderr_filename, "w"); () = chmod (stderr_filename, 0600); variable cmd = sprintf ("%s %s 2>%s", GPG_Decrypt_Program, file, stderr_filename); variable pid = open_filter_process (["/bin/sh", "-c", cmd], "."); send_process (pid, get_pass_phrase (file, use_blocal_phrase, set_blocal_phrase, confirm_phrase)); send_process (pid, "\n"); () = close_filter_process (pid); parse_gpg_errors (stderr_filename); () = delete_file (stderr_filename); return 1; } private define insert_encrypted_file (file) { return _insert_encrypted_file (file, 0, 0, 0); } private define read_encrypted_file (file) { if (_insert_encrypted_file (file, 0, 1, 0)) { %create_blocal_var ("Auto_Compression_Mode"); return 1; } return 0; } add_to_hook ("_jed_insert_file_hooks", &insert_encrypted_file); add_to_hook ("_jed_read_file_hooks", &read_encrypted_file); append_to_hook ("_jed_write_region_hooks", &write_encrypted_region); %append_to_hook ("_jed_append_region_hooks", &append_e); private define encrypted_set_mode_hook (ext) { variable i, file; (file,,,) = getbuf_info (); i = check_is_encrypted (file); if (i != -1) { file = file[[0:strlen(file)-strlen(ext)-2]]; mode_hook (file_type (file)); return 1; } return 0; } add_to_hook ("_jed_set_mode_hooks", &encrypted_set_mode_hook); jed-0.99-19/lib/abbrmisc.sl0000644002657400265740000000427711311317447014374 0ustar davisdavis% Miscellaneous function for the abbrev tables require ("abbrev"); define define_abbrev_for_table (table, word) { variable n = what_line (); variable use_bskip = 1; variable exg = "exchange"; variable abbrev, expans; if (markp ()) { call (exg); if (n == what_line (), call (exg)) use_bskip = 0; } push_spot (); if (use_bskip) { push_mark (); bskip_chars (word); } expans = bufsubstr (); pop_spot (); !if (strlen (expans)) { expans = read_mini("For what?", Null_String, Null_String); !if (strlen (expans)) return; } abbrev = read_mini ("Enter abbrev for '" + expans + "'", "", ""); !if (strlen (abbrev)) return; define_abbrev (table, abbrev, expans); } define define_abbreviation () { variable tbl, word; (tbl, word) = what_abbrev_table (); !if (strlen (tbl)) { tbl = "Global"; create_abbrev_table (tbl, Null_String); (tbl, word) = what_abbrev_table (); } define_abbrev_for_table (tbl, word); } private define quote_this_line () { push_spot (); while (ffind_char ('\\')) { insert_char ('\\'); go_right_1 (); } pop_spot (); push_spot (); while (ffind_char ('"')) { insert_char ('\\'); go_right_1 (); } pop_spot (); } define save_abbrevs () { variable file = read_file_from_mini ("Save abbrevs to:"); variable n, table, word; !if (strlen (extract_filename (file))) { file = dircat (file, Abbrev_File); } !if (strlen (extract_filename (file))) error ("Invalid file."); n = list_abbrev_tables (); % tables on stack !if (n) return; () = read_file (file); erase_buffer (); loop (n) { table = (); push_spot (); word = dump_abbrev_table (table); % buffer now contain abbrevs pop_spot (); vinsert("create_abbrev_table (\"%s\", \"%s\");\n", table, word); go_up_1 (); while (down_1 () and not(eobp())) { insert ("define_abbrev (\""); insert(table); insert ("\",\t\""); quote_this_line (); () = ffind_char ('\t'); trim (); insert ("\",\t\""); eol (); insert ("\");"); } } save_buffer (); delbuf (whatbuf); } jed-0.99-19/lib/colors/0000755002657400265740000000000011311317447013541 5ustar davisdavisjed-0.99-19/lib/colors/black1.sl0000644002657400265740000000350511311317447015241 0ustar davisdavis$1 = "white"; $2 = "black"; set_color("normal", $1, $2); % default fg/bg set_color("status", "yellow", "blue"); % status or mode line set_color("region", "yellow", "blue"); % for marking regions set_color("operator", $1, $2); % +, -, etc.. set_color("number", "yellow", $2); % 10, 2.71,... TeX formulas set_color("comment", "yellow", $2); % /* comment */ set_color("string", "magenta", $2); % "string" or 'char' set_color("keyword", "brightred", $2); % if, while, unsigned, ... set_color("keyword1", "green", $2); % malloc, exit, etc... set_color("delimiter", $1, $2); % {}[](),.;... set_color("preprocess", "magenta", $2);% #ifdef .... set_color("message", "brightblue", $2);% color for messages set_color("error", "brightred", $2); % color for errors set_color("dollar", "magenta", $2); % color dollar sign continuat$ set_color("...", "red", $2); % folding indicator set_color ("menu_char", "yellow", "blue"); set_color ("menu", "lightgray", "blue"); set_color ("menu_popup", "lightgray", "blue"); set_color ("menu_shadow", "blue", "black"); set_color ("menu_selection", "green", "red"); set_color ("menu_selection_char", "yellow", "red"); set_color ("cursor", "black", "red"); set_color ("cursorovr", "black", "red"); %% The following have been automatically generated: set_color("linenum", "yellow", "blue"); set_color("trailing_whitespace", "yellow", $2); set_color("tab", "yellow", $2); set_color("url", "magenta", $2); set_color("italic", $1, $2); set_color("underline", "green", $2); set_color("bold", "brightred", $2); set_color("html", "brightred", $2); set_color("keyword2", $1, $2); set_color("keyword3", $1, $2); set_color("keyword4", $1, $2); set_color("keyword5", $1, $2); set_color("keyword6", $1, $2); set_color("keyword7", $1, $2); set_color("keyword8", $1, $2); set_color("keyword9", $1, $2); jed-0.99-19/lib/colors/README0000644002657400265740000000013011311317447014413 0ustar davisdavisThis directory contains some predefined color schemes for JED. Feel free to add more. jed-0.99-19/lib/colors/blue1.sl0000644002657400265740000000357611311317447015124 0ustar davisdavis$1 = "yellow"; $2 = "blue"; set_color("normal", $1, $2); % default fg/bg set_color("status", "black", "white"); % status or mode line set_color("region", "black", "white"); % for marking regions set_color("operator", "white", $2); % +, -, etc.. set_color("number", "brightmagenta", $2); % 10, 2.71,... TeX formulas set_color("comment", "brightcyan", $2); % /* comment */ set_color("string", "brightcyan", $2); % "string" or 'char' set_color("keyword", "white", $2); % if, while, unsigned, ... set_color("keyword1", "yellow", $2); % malloc, exit, etc... set_color("delimiter", "white", $2); % {}[](),.;... set_color("preprocess", "brightgreen", $2); % #ifdef .... set_color("message", "brown", $2); % color for messages set_color("error", "brightred", $2); % color for errors set_color("dollar", "white", $2); % color dollar sign continuation set_color("...", "red", $2); % folding indicator set_color ("menu_char", "black", "white"); set_color ("menu", "blue", "white"); set_color ("menu_popup", "blue", "white"); set_color ("menu_shadow", "blue", "black"); set_color ("menu_selection", "green", "red"); set_color ("menu_selection_char", "black", "red"); set_color ("cursor", "black", "red"); set_color ("cursorovr", "black", "red"); %% The following have been automatically generated: set_color("linenum", "black", "white"); set_color("trailing_whitespace", "brightcyan", $2); set_color("tab", "brightcyan", $2); set_color("url", "brightcyan", $2); set_color("italic", $1, $2); set_color("underline", "yellow", $2); set_color("bold", "white", $2); set_color("html", "white", $2); set_color("keyword2", $1, $2); set_color("keyword3", $1, $2); set_color("keyword4", $1, $2); set_color("keyword5", $1, $2); set_color("keyword6", $1, $2); set_color("keyword7", $1, $2); set_color("keyword8", $1, $2); set_color("keyword9", $1, $2); jed-0.99-19/lib/colors/blue3.sl0000644002657400265740000000370311311317447015116 0ustar davisdavis$1 = "yellow"; $2 = "blue"; set_color("normal", $1, $2); % default fg/bg set_color("status", "black", "lightgray"); % status or mode line set_color("region", "black", "lightgray"); % for marking regions set_color("operator", "white", $2); % +, -, etc.. set_color("number", "brightcyan", $2); % 10, 2.71,... TeX formulas set_color("comment", "lightgray", $2); % /* comment */ set_color("string", "brightcyan", $2); % "string" or 'char' set_color("keyword", "white", $2); % if, while, unsigned, ... set_color("keyword1", "yellow", $2); % malloc, exit, etc... set_color("delimiter", "white", $2); % {}[](),.;... set_color("preprocess", "brightgreen", $2); % #ifdef .... set_color("message", "lightgray", $2); % color for messages set_color("error", "brightred", $2); % color for errors set_color("dollar", "brightmagenta", $2); % color dollar sign continuation set_color("...", "brightred", $2); % folding indicator set_color ("menu_char", "black", "white"); set_color ("menu", "black", "lightgray"); % menu bar set_color ("menu_popup", "blue", "white"); set_color ("menu_shadow", "blue", "black"); set_color ("menu_selection", "green", "red"); set_color ("menu_selection_char", "black", "red"); set_color ("cursor", "white", "red"); set_color ("cursorovr", "black", "brightred"); %% The following have been automatically generated: set_color("linenum", "black", "lightgray"); set_color("trailing_whitespace", "lightgray", $2); set_color("tab", "lightgray", $2); set_color("url", "brightcyan", $2); set_color("italic", $1, $2); set_color("underline", "yellow", $2); set_color("bold", "white", $2); set_color("html", "white", $2); set_color("keyword2", $1, $2); set_color("keyword3", $1, $2); set_color("keyword4", $1, $2); set_color("keyword5", $1, $2); set_color("keyword6", $1, $2); set_color("keyword7", $1, $2); set_color("keyword8", $1, $2); set_color("keyword9", $1, $2); jed-0.99-19/lib/colors/white1.sl0000644002657400265740000000330111311317447015277 0ustar davisdavis$1 = "black"; $2 = "white"; set_color("normal", $1, $2); set_color("status", "yellow", "blue"); set_color("operator", $1, $2); % +, -, etc.. set_color("number", "brightblue", $2); % 10, 2.71, etc.. set_color("comment", "black", "brightcyan");% /* comment */ set_color("region", "yellow", "brightmagenta"); set_color("string", "brightblue", $2); % "string" or 'char' set_color("keyword", "brightred", $2); % if, while, unsigned, ... set_color("keyword1", "red", $2); % if, while, unsigned, ... set_color("delimiter", $1, $2); % {}[](),.;... set_color("preprocess", "magenta", $2); set_color("message", "blue", $2); set_color("error", "brightred", $2); set_color("dollar", "brightred", $2); set_color("...", "red", $2); % folding indicator set_color ("menu_char", "yellow", "blue"); set_color ("menu", "lightgray", "blue"); set_color ("menu_popup", "lightgray", "blue"); set_color ("menu_shadow", "blue", "black"); set_color ("menu_selection", "green", "red"); set_color ("menu_selection_char", "yellow", "red"); set_color ("cursor", "black", "red"); set_color ("cursorovr", "black", "red"); %% The following have been automatically generated: set_color("linenum", "yellow", "blue"); set_color("trailing_whitespace", "black", "brightcyan"); set_color("tab", "black", "brightcyan"); set_color("url", "brightblue", $2); set_color("italic", $1, $2); set_color("underline", "red", $2); set_color("bold", "brightred", $2); set_color("html", "brightred", $2); set_color("keyword2", $1, $2); set_color("keyword3", $1, $2); set_color("keyword4", $1, $2); set_color("keyword5", $1, $2); set_color("keyword6", $1, $2); set_color("keyword7", $1, $2); set_color("keyword8", $1, $2); set_color("keyword9", $1, $2); jed-0.99-19/lib/colors/black2.sl0000644002657400265740000000352311311317447015242 0ustar davisdavis$1 = "white"; $2 = "black"; set_color("normal", $1, $2); % default fg/bg set_color("status", "yellow", "blue"); % status or mode line set_color("region", "yellow", "blue"); % for marking regions set_color("operator", $1, $2); % +, -, etc.. set_color("number", "yellow", $2); % 10, 2.71,... TeX formulas set_color("comment", "yellow", $2); % /* comment */ set_color("string", "brightgreen", $2); % "string" or 'char' set_color("keyword", "brightred", $2); % if, while, unsigned, ... set_color("keyword1", "green", $2); % malloc, exit, etc... set_color("delimiter", $1, $2); % {}[](),.;... set_color("preprocess", "magenta", $2);% #ifdef .... set_color("message", "brightblue", $2); % color for messages set_color("error", "brightred", $2); % color for errors set_color("dollar", "magenta", $2); % color dollar sign continuat$ set_color("...", "red", $2); % folding indicator set_color ("menu_char", "yellow", "blue"); set_color ("menu", "lightgray", "blue"); set_color ("menu_popup", "lightgray", "blue"); set_color ("menu_shadow", "blue", "black"); set_color ("menu_selection", "green", "red"); set_color ("menu_selection_char", "yellow", "red"); set_color ("cursor", "black", "red"); set_color ("cursorovr", "black", "red"); %% The following have been automatically generated: set_color("linenum", "yellow", "blue"); set_color("trailing_whitespace", "yellow", $2); set_color("tab", "yellow", $2); set_color("url", "brightgreen", $2); set_color("italic", $1, $2); set_color("underline", "green", $2); set_color("bold", "brightred", $2); set_color("html", "brightred", $2); set_color("keyword2", $1, $2); set_color("keyword3", $1, $2); set_color("keyword4", $1, $2); set_color("keyword5", $1, $2); set_color("keyword6", $1, $2); set_color("keyword7", $1, $2); set_color("keyword8", $1, $2); set_color("keyword9", $1, $2); jed-0.99-19/lib/colors/blue2.sl0000644002657400265740000000356311311317447015121 0ustar davisdavis$1 = "yellow"; $2 = "blue"; $3 = "white"; set_color("normal", $1, $2); % default fg/bg set_color("status", "black", $3); % status or mode line set_color("region", "black", $3); % for marking regions set_color("operator", "white", $2); % +, -, etc.. set_color("number", "brightmagenta", $2); % 10, 2.71,... TeX formulas set_color("comment", "brightcyan", $2); % /* comment */ set_color("string", "brightcyan", $2); % "string" or 'char' set_color("keyword", "white", $2); % if, while, unsigned, ... set_color("keyword1", "yellow", $2); % malloc, exit, etc... set_color("delimiter", "white", $2); % {}[](),.;... set_color("preprocess", "brightgreen", $2); % #ifdef .... set_color("message", "white", $2); % color for messages set_color("error", "brightred", $2); % color for errors set_color("dollar", "white", $2); % color dollar sign continuation set_color("...", "red", $2); % folding indicator set_color ("menu_char", "red", $3); set_color ("menu", "black", $3); set_color ("menu_popup", "black", $3); set_color ("menu_shadow", "blue", "black"); set_color ("menu_selection", "black", "cyan"); set_color ("menu_selection_char", "red", "cyan"); set_color ("cursor", "black", "red"); set_color ("cursorovr", "black", "red"); %% The following have been automatically generated: set_color("linenum", "black", $3); set_color("trailing_whitespace", "brightcyan", $2); set_color("tab", "brightcyan", $2); set_color("url", "brightcyan", $2); set_color("italic", $1, $2); set_color("underline", "yellow", $2); set_color("bold", "white", $2); set_color("html", "white", $2); set_color("keyword2", $1, $2); set_color("keyword3", $1, $2); set_color("keyword4", $1, $2); set_color("keyword5", $1, $2); set_color("keyword6", $1, $2); set_color("keyword7", $1, $2); set_color("keyword8", $1, $2); set_color("keyword9", $1, $2); jed-0.99-19/lib/colors/black3.sl0000644002657400265740000000361711311317447015247 0ustar davisdavis$1 = "white"; $2 = "black"; set_color("menu", "white", "blue"); % menu bar set_color("normal", $1, $2); % default fg/bg set_color("status", "yellow", "blue"); % status or mode line set_color("region", "yellow", "blue"); % for marking regions set_color("operator", $1, $2); % +, -, etc.. set_color("number", "yellow", $2); % 10, 2.71,... TeX formulas set_color("comment", "brightcyan", $2); % /* comment */ set_color("string", "brightgreen", $2); % "string" or 'char' set_color("keyword", "brightred", $2); % if, while, unsigned, ... set_color("keyword1", "green", $2); % malloc, exit, etc... set_color("delimiter", $1, $2); % {}[](),.;... set_color("preprocess", "magenta", $2);% #ifdef .... set_color("message", "yellow", $2); % color for messages set_color("error", "brightred", $2); % color for errors set_color("dollar", "magenta", $2); % color dollar sign continuat$ set_color("...", "red", $2); % folding indicator set_color ("menu_char", "yellow", "blue"); set_color ("menu", "lightgray", "blue"); set_color ("menu_popup", "lightgray", "blue"); set_color ("menu_shadow", "blue", "black"); set_color ("menu_selection", "white", "cyan"); set_color ("menu_selection_char", "yellow", "cyan"); set_color ("cursor", "black", "red"); set_color ("cursorovr", "black", "red"); %% The following have been automatically generated: set_color("linenum", "yellow", "blue"); set_color("trailing_whitespace", "brightcyan", $2); set_color("tab", "brightcyan", $2); set_color("url", "brightgreen", $2); set_color("italic", $1, $2); set_color("underline", "green", $2); set_color("bold", "brightred", $2); set_color("html", "brightred", $2); set_color("keyword2", $1, $2); set_color("keyword3", $1, $2); set_color("keyword4", $1, $2); set_color("keyword5", $1, $2); set_color("keyword6", $1, $2); set_color("keyword7", $1, $2); set_color("keyword8", $1, $2); set_color("keyword9", $1, $2); jed-0.99-19/lib/colors/Xjed/0000755002657400265740000000000011311317447014433 5ustar davisdavisjed-0.99-19/lib/colors/Xjed/elegant.sl0000644002657400265740000000346611311317447016423 0ustar davisdavis% elegant.sl $1 = "black"; $2 = "#E0E0E0"; % light gray $3 = "white"; $4 = "#606060"; % medium gray $5 = "#B4FFB4"; % pale green $6 = "#1010A0"; % dark blue $7 = "#B40A78"; % dark purple set_color("normal", $1, $2); % default fg/bg set_color("status", $1, $3); % status line set_color("operator", $1, $2); % +, -, etc... set_color("number", $6, $2); % 10, 2.71, etc.. set_color("comment", $1, $5); % /* comment */ set_color("region", $3, $4); % region set_color("string", $6, $2); % "string" or 'char' set_color("keyword", $7, $2); % if, while, unsigned, ... set_color("keyword1", $7, $2); % malloc, exit, etc... set_color("delimiter", "red", $2); % {}[](),.;... set_color("preprocess", "magenta", $2); % #ifdef etc... set_color("message", $6, $2); set_color("error", "red", $2); set_color("dollar", "red", $2); set_color("...", "red", $2); % folding indicator set_color ("menu_char", "red", $3); set_color ("menu", $1, "white"); set_color ("menu_popup", $1, $3); set_color ("menu_shadow", $1, $4); set_color ("menu_selection", $1, "cyan"); set_color ("menu_selection_char", "red", $3); set_color ("mouse", "blue", "blue"); set_color ("cursor", $1, "red"); set_color ("cursorovr", $1, "red"); %% The following have been automatically generated: set_color("linenum", $1, $3); set_color("trailing_whitespace", $1, $5); set_color("tab", $1, $5); set_color("url", $6, $2); set_color("italic", $1, $2); set_color("underline", $7, $2); set_color("bold", $7, $2); set_color("html", $7, $2); set_color("keyword2", $1, $2); set_color("keyword3", $1, $2); set_color("keyword4", $1, $2); set_color("keyword5", $1, $2); set_color("keyword6", $1, $2); set_color("keyword7", $1, $2); set_color("keyword8", $1, $2); set_color("keyword9", $1, $2); jed-0.99-19/lib/colors/Xjed/pastel0.sl0000644002657400265740000000443311311317447016347 0ustar davisdavisset_color("normal", "#000000", "#E0E0E0"); set_color("status", "#FFFF00", "#0000AA"); % status bar near the bottom set_color("operator", "#000000", "#E0E0E0"); % +, -, etc.. set_color("number", "#000000", "#E0E0E0"); % 10, 2.71, etc.. set_color("comment", "#008000", "#E8E8E0"); % /* comment */ set_color("region", "#FFFF99", "#666655"); % Cut & Paste set_color("string", "#000000", "#E8DCE0"); % "string" or 'char' set_color("keyword", "#0000FF", "#E0E0E0"); % basic language keywords: if, while, unsigned, ... set_color("keyword1", "#F00000", "#E0E0E0"); % extended language keywords: int, long, void, static set_color("keyword2", "#005599", "#E0E0E0"); % user defined keywords set_color("delimiter", "#000000", "#E0E0E0"); % {}[](),.; ... set_color("preprocess", "#CC00CC", "#E0E0E0"); % the C/C++ preprocessor set_color("message", "#C00000", "#E8E0E0"); % messages like "Loading ..." set_color("error", "#FFFF55", "#FF0000"); % error messages set_color("dollar", "#FFFF00", "#E8E8D8"); % line overflow set_color("...", "#FFFF00", "#FF0000"); % folding indicator set_color ("menu_char", "#FF5555", "#0000AA"); set_color ("menu", "#FFFFFF", "#0000AA"); set_color ("menu_popup", "#FFFFFF", "#0000AA"); set_color ("menu_shadow", "#000000", "#A0A0A0"); set_color ("menu_selection","#000000", "#E0E0E0"); set_color ("menu_selection_char","#FF5555", "#0000AA"); set_color ("mouse", "blue", "blue"); set_color ("cursor", "black", "red"); set_color ("cursorovr", "black", "red"); %% The following have been automatically generated: set_color("linenum", "#FFFF00", "#0000AA"); set_color("trailing_whitespace", "#008000", "#E8E8E0"); set_color("tab", "#008000", "#E8E8E0"); set_color("url", "#000000", "#E8DCE0"); set_color("italic", "#005599", "#E0E0E0"); set_color("underline", "#F00000", "#E0E0E0"); set_color("bold", "#0000FF", "#E0E0E0"); set_color("html", "#0000FF", "#E0E0E0"); set_color("keyword3", "#000000", "#E0E0E0"); set_color("keyword4", "#000000", "#E0E0E0"); set_color("keyword5", "#000000", "#E0E0E0"); set_color("keyword6", "#000000", "#E0E0E0"); set_color("keyword7", "#000000", "#E0E0E0"); set_color("keyword8", "#000000", "#E0E0E0"); set_color("keyword9", "#000000", "#E0E0E0"); jed-0.99-19/lib/colors/Xjed/night.sl0000644002657400265740000000430411311317447016105 0ustar davisdavis% night.sl % By Guido Gonzato $1 = "#EDFF00"; % flash yellow $2 = "#000050"; % very dark blue $3 = "#FF4242"; % bright red $4 = "#90FF90"; % bright green $5 = "#4FFF4F"; % green $6 = "#D1D1D1"; % whitish $7 = "#040FDD"; % blue $8 = "#400070"; % dark purple $9 = "#20b0f0"; % mid cyan set_color ("normal", $1, $2); % default fg/bg set_color ("status", "black", "white"); % status or mode line set_color ("region", "black", "white"); % for marking regions set_color ("operator", "white", $2); % +, -, etc.. set_color ("number", "red", $2); % 10, 2.71,... TeX formulas set_color ("comment", $4, $2); % /* comment */ set_color ("string", "cyan", $7); % "string" or 'char' set_color ("keyword", "white", $8); % if, while, unsigned, ... set_color ("keyword1", "cyan", $8); % malloc, exit, etc... set_color ("keyword2", $3, $8); % other keywords set_color ("delimiter", $3, $2); % {}[](),.;... set_color ("preprocess", "magenta", $2); % #ifdef .... set_color ("message", "white", $2); % color for messages set_color ("error", $2, $3); % color for errors set_color ("dollar", "white", $2); % color dollar sign continuation set_color ("...", "red", $2); % folding indicator set_color ("menu_char", "red", $6); set_color ("menu", "black", $6); set_color ("menu_popup", "black", $6); set_color ("menu_shadow", $2, "black"); set_color ("menu_selection", "black", $9); set_color ("menu_selection_char", $3, $6); set_color("cursor", "red", $5); set_color("cursorovr", "red", "green"); % End of file night.sl %% The following have been automatically generated: set_color("linenum", "black", "white"); set_color("trailing_whitespace", $4, $2); set_color("tab", $4, $2); set_color("url", "cyan", $7); set_color("italic", $3, $8); set_color("underline", "cyan", $8); set_color("bold", "white", $8); set_color("html", "white", $8); set_color("keyword3", $1, $2); set_color("keyword4", $1, $2); set_color("keyword5", $1, $2); set_color("keyword6", $1, $2); set_color("keyword7", $1, $2); set_color("keyword8", $1, $2); set_color("keyword9", $1, $2); jed-0.99-19/lib/colors/Xjed/modern.sl0000644002657400265740000000364411311317447016266 0ustar davisdavis% modern.sl % By Guido Gonzato $1 = "black"; $2 = "white"; $3 = "#E8E8E8"; % light gray $4 = "#B0B0B0"; % mid gray $5 = "#007000"; % dark green $6 = "#1010A0"; % dark blue $7 = "#B40A78"; % dark purple $8 = "#D717E7"; % purple $9 = "#606060"; % dark gray set_color ("normal", $1, $2); % default fg/bg set_color ("status", $1, $3); % status line set_color ("operator", $1, $2); % +, -, etc... set_color ("number", "brightred", $2); % numbers set_color ("comment", $9, $2); % /* comment */ set_color ("region", $1, $4); % region set_color ("string", $6, $3); % "string" or 'char' set_color ("keyword", $7, $2); % if, while, unsigned, ... set_color ("keyword1", $6, $2); % malloc, exit, etc... set_color ("keyword2", $5, $2); % other keywords set_color ("delimiter", "red", $2); % {}[](),.;... set_color ("preprocess", "magenta", $2); % #ifdef etc... set_color ("message", $6, $2); set_color ("error", $8, $2); set_color ("dollar", $8, $2); set_color ("...", $8, $2); % folding indicator set_color ("menu_char", "red", $3); set_color ("menu", $1, $3); set_color ("menu_popup", $1, $3); set_color ("menu_shadow", $1, $4); set_color ("menu_selection", $1, "cyan"); set_color ("menu_selection_char", "red", $3); set_color ("mouse", "blue", "blue"); set_color ("cursor", $1, $8); set_color ("cursorovr", $1, $8); %% The following have been automatically generated: set_color("linenum", $1, $3); set_color("trailing_whitespace", $9, $2); set_color("tab", $9, $2); set_color("url", $6, $3); set_color("italic", $5, $2); set_color("underline", $6, $2); set_color("bold", $7, $2); set_color("html", $7, $2); set_color("keyword3", $1, $2); set_color("keyword4", $1, $2); set_color("keyword5", $1, $2); set_color("keyword6", $1, $2); set_color("keyword7", $1, $2); set_color("keyword8", $1, $2); set_color("keyword9", $1, $2); jed-0.99-19/lib/colors/Xjed/black4.sl0000644002657400265740000000322011311317447016130 0ustar davisdavis% Contributed by Mark Olesen $1 = "white"; $2 = "black"; $3 = "cyan"; $4 = "red"; $5 = "magenta"; $6 = "gray75"; set_color("normal", $1, $2); % use white/blue status for console color scheme set_color("status", $1, "gray50"); set_color("region", "yellow", "blue"); set_color("operator", $3, $2); set_color("delimiter", $3, $2); set_color("number", $4, $2); set_color("string", $6, $2); set_color("keyword", "yellow", $2); set_color("keyword1", "green", $2); set_color("comment", $3, "gray25"); set_color("preprocess", $5, $2); set_color("dollar", "yellow", "gray25"); set_color("...", $5, $2); set_color("message", $3, $2); set_color("error", $4, $2); % gray menu - set_color("menu", $1, "gray50"); set_color("menu_char", "yellow", "gray50"); set_color("menu_popup", $1, "gray50"); set_color("menu_shadow", $4, "gray25"); set_color("menu_selection", $1, $2); set_color("menu_selection_char", "yellow", $2); set_color("cursor", "black", "yellow"); set_color("cursorovr", "black", "red"); set_color("mouse", "green", $2); %% some of the following have been automatically generated: set_color("linenum", "yellow", "blue"); set_color("trailing_whitespace", $3, "gray50"); set_color("tab", $3, "gray50"); set_color("url", $6, $2); set_color("italic", $1, $2); set_color("underline", "green", $2); set_color("bold", $1, $2); set_color("keyword2", $1, $2); set_color("keyword3", $1, $2); set_color("keyword4", $1, $2); set_color("keyword5", $1, $2); set_color("keyword6", $1, $2); set_color("keyword7", $1, $2); set_color("keyword8", $1, $2); set_color("keyword9", $1, $2); %% The following have been automatically generated: set_color("html", "yellow", $2); jed-0.99-19/lib/colors/black4.sl0000644002657400265740000000370511311317447015246 0ustar davisdavis% Contributed by Mark Olesen $1 = "white"; $2 = "black"; $3 = "brightcyan"; $4 = "brightred"; $5 = "brightmagenta"; $6 = "lightgray"; set_color("normal", $1, $2); % use white/gray status for Xjed color scheme set_color("status", $1, "blue"); set_color("region", "yellow", "blue"); set_color("operator", $3, $2); set_color("delimiter", $3, $2); set_color("number", $4, $2); set_color("string", $6, $2); set_color("keyword", "yellow", $2); set_color("keyword1", "green", $2); set_color("comment", $3, "gray"); set_color("preprocess", $5, $2); set_color("dollar", "yellow", "gray"); set_color("...", $5, $2); set_color("message", $3, $2); set_color("error", $4, $2); #iftrue % blue menu set_color("menu", $6, "blue"); set_color("menu_char", "yellow", "blue"); set_color("menu_popup", $6, "blue"); set_color("menu_shadow", $4, "gray"); set_color("menu_selection", $1, $2); set_color("menu_selection_char", "yellow", $2); #else % gray menu - ok except the shadow looks a bit odd % set_color("menu", "lightgray", "gray"); % set_color("menu_char", "yellow", "gray"); % set_color("menu_popup", $1, "gray"); % set_color("menu_shadow", $4, "black"); % set_color("menu_selection", $1, $2); % set_color("menu_selection_char", "yellow", $2); #endif set_color("cursor", "black", "yellow"); set_color("cursorovr", "black", "red"); set_color("mouse", "green", $2); %% some of the following have been automatically generated: set_color("linenum", "yellow", "blue"); set_color("trailing_whitespace", $3, "gray"); set_color("tab", $3, $2); set_color("url", $6, $2); set_color("italic", $1, $2); set_color("underline", "green", $2); set_color("bold", $1, $2); set_color("keyword2", $1, $2); set_color("keyword3", $1, $2); set_color("keyword4", $1, $2); set_color("keyword5", $1, $2); set_color("keyword6", $1, $2); set_color("keyword7", $1, $2); set_color("keyword8", $1, $2); set_color("keyword9", $1, $2); %% The following have been automatically generated: set_color("html", "yellow", $2); jed-0.99-19/lib/colors/update-colors0000755002657400265740000000574411311317447016262 0ustar davisdavis#!/usr/bin/env jed-script private variable Like_Color_Map = Assoc_Type[]; private define set_like_color (obj, likeobj) { Like_Color_Map[obj] = likeobj; } private define get_like_color (obj) { if (assoc_key_exists (Like_Color_Map, obj)) return Like_Color_Map[obj]; return NULL; } set_like_color ("linenum", "status"); set_like_color ("cursor", "region"); set_like_color ("cursorovr", "cursor"); set_like_color ("tab", "comment"); set_like_color ("trailing_whitespace", "comment"); set_like_color ("bold", "keyword"); set_like_color ("underline", "keyword1"); set_like_color ("italic", "keyword2"); set_like_color ("url", "string"); set_like_color ("html", "keyword"); private define build_color_list () { variable color_list = Assoc_Type[Int_Type]; () = read_file ("../../src/colors.c"); !if (fsearch ("%%% COLOR-TABLE-START %%%")) error ("Unable to find color table tag"); push_mark (); !if (fsearch ("%%% COLOR-TABLE-STOP %%%")) error ("Unable to find color table tag"); narrow (); bob (); variable i = 0; while (re_fsearch ("^[ \t]+{\"\\([^\"]+\\)\"")) { variable color = regexp_nth_match (1); color_list[color] = i; i++; eol (); } delbuf (whatbuf ()); (color_list, i) = (assoc_get_keys (color_list), assoc_get_values(color_list)); i = array_sort (i); return color_list[i]; } private define find_set_color_line (color) { bob (); return re_fsearch ("^[ \t]*set_color[ \t]*(\"" + color + "\""); } private define get_fgbg_for_color (obj, fgp, bgp) { variable like_obj; push_spot (); EXIT_BLOCK { pop_spot (); } forever { obj = get_like_color (obj); if (obj != NULL) { !if (find_set_color_line (obj)) continue; } else !if (find_set_color_line ("normal")) return -1; () = ffind (","); go_right(1); push_mark (); () = ffind (","); @fgp = strtrim (bufsubstr()); go_right (1); push_mark (); () = ffind (")"); @bgp = strtrim (bufsubstr()); return 0; } } private define process_file (file, color_list) { () = read_file (file); variable modified = 0; trim_buffer (); variable tagline = "%% The following have been automatically generated:\n"; bob (); if (bol_fsearch (tagline)) { go_down (1); push_mark (); eob (); del_region (); modified = 1; } foreach (color_list) { variable color = (); !if (find_set_color_line (color)) { eob (); if (modified == 0) { modified = 1; vinsert ("\n%s\n", tagline); } variable fg = "$1", bg = "$2"; if (-1 == get_fgbg_for_color (color, &fg, &bg)) insert ("%%>"); vinsert ("set_color(\"%s\", %s, %s);\n", color, fg, bg); } } if (buffer_modified ()) save_buffer (); delbuf (whatbuf ()); return modified; } define jedscript_main () { variable color_list = build_color_list (); foreach (__argv[[1:]]) { variable file = (); if (process_file (file, color_list)) () = fprintf (stdout, "%s\n", file); } } jed-0.99-19/lib/colors/default1.sl0000644002657400265740000000330511311317447015607 0ustar davisdavis$1 = "default"; $2 = "default"; set_color("normal", $1, $2); set_color("status", "yellow", "blue"); set_color("operator", $1, $2); % +, -, etc.. set_color("number", "brightblue", $2); % 10, 2.71, etc.. set_color("comment", "black", "brightcyan");% /* comment */ set_color("region", "yellow", "brightmagenta"); set_color("string", "brightblue", $2); % "string" or 'char' set_color("keyword", "brightred", $2); % if, while, unsigned, ... set_color("keyword1", "red", $2); % if, while, unsigned, ... set_color("delimiter", $1, $2); % {}[](),.;... set_color("preprocess", "magenta", $2); set_color("message", "blue", $2); set_color("error", "brightred", $2); set_color("dollar", "brightred", $2); set_color("...", "red", $2); % folding indicator set_color ("menu_char", "yellow", "blue"); set_color ("menu", "lightgray", "blue"); set_color ("menu_popup", "lightgray", "blue"); set_color ("menu_shadow", "blue", "black"); set_color ("menu_selection", "green", "red"); set_color ("menu_selection_char", "yellow", "red"); set_color ("cursor", "black", "red"); set_color ("cursorovr", "black", "red"); %% The following have been automatically generated: set_color("linenum", "yellow", "blue"); set_color("trailing_whitespace", "black", "brightcyan"); set_color("tab", "black", "brightcyan"); set_color("url", "brightblue", $2); set_color("italic", $1, $2); set_color("underline", "red", $2); set_color("bold", "brightred", $2); set_color("html", "brightred", $2); set_color("keyword2", $1, $2); set_color("keyword3", $1, $2); set_color("keyword4", $1, $2); set_color("keyword5", $1, $2); set_color("keyword6", $1, $2); set_color("keyword7", $1, $2); set_color("keyword8", $1, $2); set_color("keyword9", $1, $2); jed-0.99-19/lib/binary.sl0000644002657400265740000000112611311317447014064 0ustar davisdavis% It is used to read a file in binary mode. define find_binary_file () { variable file, bytes, len, pos; file = read_file_from_mini ("Find Binary File:"); try { set_file_translation (1); () = find_file (file); } finally set_file_translation (0); no_mode(); set_overwrite(1); % % set the binary file flags getbuf_info(); setbuf_info(() | 0x200); bytes = count_chars(); if (string_match(bytes, ".*of \\([0-9]+\\)$", 1)) { (pos, len) = string_match_nth(1); bytes = substr(bytes, pos + 1, len); message (bytes + " bytes."); } } jed-0.99-19/lib/latex.sl0000644002657400265740000006574211311317447013733 0ustar davisdavis% latex.sl % % AUC-TeX style LaTeX-mode (v0.18) by Kevin Humphreys % % For JED (v0.97.9b) by John E. Davis % % Based on AUC-TeX (v9.1i) by Per Abrahamsen % % Differences from AUC-TeX 9: - no shell interaction commands % - simplified insert TeX macro (C-c RET) % ------------------------------------------------------------------------ % % TO USE THIS MODE: add the line: % % add_mode_for_extension ("latex", "tex"); % % to your .jedrc file. % % To override the default values below, simply declare and initialize % the approriate variables in your .jedrc file, e.g., % % variable LaTeX_default_options = "12pt,a4paper"; % variable LaTeX_default_document_style = "article"; % % To make LaTeX209 the default set LaTeX_default_documentstyle variable to a % non-null value (e.g. "article"). % % Other variables to change in the latex mode hook include: % % variable LaTeX_default_documentclass = "article"; % for LaTeX 2e % variable LaTeX_default_options = Null_String; % variable LaTeX_default_section = "section"; % variable LaTeX_default_environment = "itemize"; % variable LaTeX_default_figure_label = "fig:"; % variable LaTeX_default_table_label = "tab:"; % variable LaTeX_default_section_label = "sec:"; % variable LaTeX_default_documentstyle = Null_String; % for LaTeX 2.09 % ------------------------------------------------------------------------ % CHANGES HISTORY: % --- v0.17-1.0 % Fix synchronization of latex_math_mode/latex_mode and made each of the modes % local to a buffer. This allows one buffer to be in latex_mode and another % to be in latex math mode. --JED % % --- v0.17-0.1? % have indentation recognize \[ \] % % PC: changed most of the '\\\\', as they were not necessary % added a newline_indent_hook % debugged the indent_calculate_last by adding LaTeX_item_indent to % the \begin, etc indent level % debugged indent_calculate by subtracting LaTeX_item_indent from % the \end, etc level % --- % Modified to work with jed0.97-5. % --- v0.17-0.18 % fixed indent_line to keep the correct cursor position % --- v0.16-0.17 % added latex_help (C-c i) using latex.texi info file (should be on C-h C-l) % added completion for documentclass/style, sections, environments % added tex_complete_symbol (M-TAB) using ltx-comp.dat file % added simple tex_insert_macro (C-c RET) with completion from ltx-comp.dat % added tex_current_env for use by tex_mark_environment etc. % --- v0.15-0.16 (released 2/11/94) % added insertions for letter class % used built-in indent_hook for indentation % added tex_embrace for font specifier insertion using region % added latex_embrace_env for environment insertion using region % added latex_change_env for C-c C-e with prefix arg % made tex_mark_environment more intuitive by doing fsearch first % --- v0.14-0.15 (released 30/10/94) % added an attempt to do indentation % --- v0.13-0.14 (released 27/10/94) % added option to use latex209 font selections and documentstyle % added C-c : for uncomment_region and made uncomment_region more robust % --- v0.12-0.13 (released 25/10/94) % always pass env to insert_env functions % fixed insert_figure_env to prompt for center environment % fixed insert_list_env to insert \item % --- v0.11-0.12 (first release 20/10/94) % added math mode % added all standard environments %------------------------------------------------------------------------- % Load the common definitions if not already loaded. This also defines % the TeX-Mode syntax table require ("texcom"); % ---------------------------------------------------------------------------- % Exported global variables % custom_variable ("LaTeX_default_documentclass", "article"); custom_variable ("LaTeX_default_options", ""); custom_variable ("LaTeX_default_section", "section"); custom_variable ("LaTeX_default_environment", "itemize"); custom_variable ("LaTeX_default_figure_label", "fig:"); custom_variable ("LaTeX_default_table_label", "tab:"); custom_variable ("LaTeX_default_section_label", "sec:"); custom_variable ("LaTeX_default_documentstyle", ""); %----------------------------------------------------------------------------- % documentclass/style symbols variable LaTeX_classes = "book,article,letter,slides,report"; % section symbols variable LaTeX_sections = "part,chapter,section,subsection,subsubsection,paragraph,subparagraph"; % environment symbols variable LaTeX_environments = "document,enumerate,itemize,list,trivlist,picture,tabular,array,eqnarray,equation,minipage,description,figure,table,thebibliography,theindex,sloppypar,tabbing,verbatim,flushright,flushleft,displaymath,math,quote,quotation,"; % problems with above line over 255 chars. LaTeX_environments += "abstract,center,titlepage,verse"; % Load LaTeX-math-mode as required autoload("latex_toggle_math_mode", "ltx-math"); autoload("latex_math_mode", "ltx-math"); $1 = "LaTeX-Mode"; !if (keymap_p($1)) make_keymap ($1); % from tex.sl definekey ("tex_insert_quote", "\"", $1); definekey ("tex_insert_quote", "'", $1); definekey ("tex_blink_dollar", "$", $1); definekey ("tex_ldots", ".", $1); % AUC-TeX bindings definekey_reserved ("tex_insert_braces", "{", $1); definekey_reserved ("tex_font", "^F", $1); definekey_reserved ("latex_environment", "^E", $1); definekey_reserved ("latex_section", "^S", $1); definekey_reserved ("latex_close_environment", "]", $1); definekey_reserved ("latex_insert_item", "^J", $1); definekey_reserved ("tex_comment_region", ";", $1); definekey_reserved ("tex_uncomment_region", ":", $1); definekey_reserved ("tex_comment_paragraph", "%", $1); definekey_reserved ("tex_mark_environment", ".", $1); definekey_reserved ("tex_mark_section", "*", $1); definekey_reserved ("latex_toggle_math_mode", "~", $1); definekey_reserved ("tex_insert_macro", "^M", $1); definekey_reserved ("latex_help", "i", $1); definekey ("tex_complete_symbol", "\e^I", $1); % indentation definekey ("latex_indent_next_line", "^J", $1); definekey_reserved ("latex_indent_region", "^Q^R", $1); definekey_reserved ("latex_indent_section", "^Q^S", $1); definekey_reserved ("latex_indent_environment", "^Q^E", $1); % Font Selection - LaTeX2e define tex_embrace (pre, post) { if (markp()) { % if region is set check_region (1); pop_mark_1 (); insert(pre); pop_spot(); insert(post); return; } % if not mid (or end of) word just insert normally go_left_1 (); if (looking_at_char(' ') or looking_at_char('\t') or looking_at_char('\n')) { go_right_1 (); insert(pre); push_spot(); } else { % surround word, including any initial '\' go_right_1 (); push_spot(); bskip_word(); go_left_1 (); !if (looking_at_char('\\')) go_right_1 (); insert(pre); skip_word(); } insert(post); pop_spot(); } define tex_insert_font (pre, post, arg) { if (arg == -1) { tex_embrace(pre, post); return; } % if prefix argument push_spot(); () = bsearch("\\"); if (looking_at ("\\text") or looking_at ("\\emph")) { delete_word(); del (); insert (pre); } pop_spot (); } define tex_delete_font () { push_spot(); () = bsearch("\\"); if (looking_at ("\\text") or looking_at ("\\emph")) { delete_word(); del (); () = fsearch_char ('}'); del (); } pop_spot (); } define tex_font () { variable arg = prefix_argument(-1); variable brace = "}"; variable ch; flush ("\\text??: b(bf) c(sc) e(em) f(sf) i(it) m(md) n r(rm) s(sl) t(tt) u(up)"); ch = getkey (); if (ch > ' ') ch = (ch | 0x20) - 96; switch (ch) { case 2 : "\\textbf{";} % C-b { case 3 : "\\textsc{";} % C-c { case 5 : "\\emph{";} % C-e { case 6 : "\\textsf{";} % C-f { case 9 : "\\textit{";} % C-i { case 13 : "\\textmd{";} % C-m { case 14 : "\\textnormal{";} % C-n { case 18 : "\\textrm{";} % C-r { case 19 : "\\textsl{";} % C-s { case 20 : "\\texttt{";} % C-t { case 21 : "\\textup{";} % C-u { case 4 : tex_delete_font (); return; } % C-d { beep (); return;} tex_insert_font ( (), brace, arg); message (Null_String); } % Command Insertion % environments: % find previous unmatched \begin statement define tex_current_env () { variable env = Null_String, count; push_mark(); bob(); narrow(); eob (); while (bsearch("\\begin{")) { count = 1; push_spot(); go_right(7); push_mark(); () = ffind_char ('}'); env = bufsubstr(); push_spot(); while (fsearch(sprintf("\\begin{%s}", env)) and down_1 ()) count++; pop_spot(); while (fsearch(sprintf("\\end{%s}", env)) and down_1 ()) count--; pop_spot(); if (count > 0) break; } widen(); return env; } define latex_embrace_env(pre, post) { if (markp()) { check_region (0); exchange_point_and_mark (); insert (pre); pop_mark_1 (); insert (post); %% This was: % check_region(1); % pop_mark_1 (); insert(pre); % pop_spot(); insert(post); return; } insert(pre); indent_line (); eol(); push_spot(); newline(); insert(post); pop_spot(); } define latex_insert_simple_env (env) { latex_embrace_env(sprintf("\\begin{%s}\n", env), sprintf("\\end{%s}\n", env)); } define latex_insert_item_env (env) { variable braces = " "; !if (strcmp(env, "description")) braces = "[]"; latex_embrace_env(sprintf("\\begin{%s}\n\\item%s", env, braces), sprintf("\\end{%s}\n", env)); () = bfind_char (']'); } define latex_insert_array_env (env) { variable position = read_mini ("Enter Position:", Null_String, "[htbp]"); variable format = read_mini ("Enter Format:", Null_String, Null_String); latex_embrace_env(sprintf("\\begin{%s}%s{%s}\n", env, position, format), sprintf("\\end{%s}\n", env)); } define latex_insert_label_env (env) { variable label = read_mini ("Enter Label:", Null_String, Null_String); if (strcmp(label, Null_String)) label = sprintf("\\label{%s}\n", label); latex_embrace_env(sprintf("\\begin{%s}\n%s", env, label), sprintf("\\end{%s}\n", env)); } define latex_insert_figure_env (env) { variable label_prefix = Null_String; switch (env) { case "figure" : label_prefix = LaTeX_default_figure_label; } { case "figure*" : label_prefix = LaTeX_default_figure_label; } { case "table" : label_prefix = LaTeX_default_table_label; } { case "table*" : label_prefix = LaTeX_default_table_label; } variable position = read_mini ("Enter Position:", Null_String, "[htbp]"); variable caption = read_mini ("Enter Caption:", Null_String, Null_String); if (strcmp(caption, Null_String)) caption = sprintf("\\caption{%s}\n", caption); variable label = read_mini ("Enter Label:", Null_String, label_prefix); if (strcmp(label, label_prefix)) label = sprintf("\\label{%s}\n", label); else label = Null_String; latex_embrace_env(sprintf("\\begin{%s}%s\n", env, position), sprintf("%s%s\\end{%s}\n", caption, label, env)); push_spot(); !if (strcmp(env, "figure") and strcmp(env, "figure*")) { if (get_y_or_n ("Center Figure")) { newline(); latex_insert_simple_env ("center"); pop_spot(); go_down(2); push_spot(); } } pop_spot(); } define latex_insert_list_env (env) { variable label = read_mini ("Enter Default Label:", Null_String, Null_String); latex_embrace_env(sprintf("\\begin{%s}{%s}{}\n\\item ", env, label), sprintf("\\end{%s}\n", env)); } define latex_insert_minipage_env (env) { variable position = read_mini ("Enter Position:", Null_String, "[htbp]"); variable width = read_mini ("Enter Width:", "4cm", Null_String); latex_embrace_env(sprintf("\\begin{%s}%s{%s}\n", env, position, width), sprintf("\\end{%s}\n", env)); } define latex_insert_picture_env (env) { variable width = read_mini ("Enter Width:", Null_String, Null_String); variable height = read_mini ("Enter Height:", Null_String, Null_String); variable x_offset = read_mini ("Enter X Offset:", "0", Null_String); variable y_offset = read_mini ("Enter Y Offset:", "0", Null_String); variable offset = Null_String; if (strcmp(x_offset, "0") or strcmp(y_offset, "0")) offset = sprintf("(%s,%s)", x_offset, y_offset); latex_embrace_env(sprintf("\\begin{%s}(%s,%s)%s\n", env, width, height, offset), sprintf("\\end{%s}\n", env)); } define latex_insert_bib_env (env) { variable label = read_mini ("Enter Label for Bibitem:", Null_String, "99"); variable blabel = read_mini ("Enter (Optional) Bibitem Label:", Null_String, Null_String); if (strlen(blabel)) blabel = sprintf("[%s]", blabel); variable key = read_mini ("Enter Key:", Null_String, Null_String); latex_embrace_env(sprintf("\\begin{%s}{%s}\n\\bibitem%s{%s}", env, label, blabel, key), sprintf("\\end{%s}\n", env)); } define latex_insert_letter_args () { push_spot (); insert ("\\address{}\n\\signature{}\n\\begin{letter}{}\n\\opening{}\n\n\n\n\\closing{}\n\\end{letter}"); pop_spot (); () = ffind_char ('}'); } define latex_insert_document_env () { variable class = read_with_completion(LaTeX_classes, "Enter Document Class:", LaTeX_default_documentclass, Null_String, 's'); variable options = read_mini ("Enter Class Options:", LaTeX_default_options, Null_String); if (strlen (options)) options = sprintf("[%s]", options); bob (); vinsert ("\\documentclass%s{%s}\n\n", options, class); insert ("\\begin{document}\n\n\n\n\\end{document}\n"); go_up(3); !if (strcmp(class, "letter")) latex_insert_letter_args(); } define latex_change_env (env) { push_spot(); variable oldenv = tex_current_env(); if (strlen(oldenv)) { () = ffind_char ('{'); go_right_1 (); push_mark(); () = ffind_char ('}'); del_region(); insert(env); goto_spot (); if (fsearch(sprintf("\\end{%s}", oldenv))) { () = ffind_char ('{'); go_right_1 (); push_mark(); () = ffind_char ('}'); del_region(); insert(env); } } pop_spot(); } % This function takes a single argument which will ride on the stack define latex_insert_env () { dup (); % 2 copies, 1 for switch and for function switch () { case "document" : pop (); latex_insert_document_env ();} { case "enumerate" : latex_insert_item_env ( () );} { case "itemize" : latex_insert_item_env ( () );} { case "list" : latex_insert_list_env ( () );} { case "trivlist" : latex_insert_item_env ( () );} { case "picture" : latex_insert_picture_env ( () );} { case "tabular" : latex_insert_array_env ( () );} { case "tabular*" : latex_insert_array_env ( () );} { case "array" : latex_insert_array_env ( () );} { case "eqnarray" : latex_insert_label_env ( () );} { case "eqnarray*" : latex_insert_label_env ( () );} { case "equation" : latex_insert_label_env ( () );} { case "minipage" : latex_insert_minipage_env ( () );} { case "description" : latex_insert_item_env ( () );} { case "figure" : latex_insert_figure_env ( () );} { case "figure*" : latex_insert_figure_env ( () );} { case "table" : latex_insert_figure_env ( () );} { case "table*" : latex_insert_figure_env ( () );} { case "thebibliography" : latex_insert_bib_env ( () );} { case "theindex" : latex_insert_item_env ( () );} { latex_insert_simple_env ( () );} } define latex_environment () { variable arg = prefix_argument(-1); variable env = LaTeX_default_environment; if (bobp) env = "document"; env = read_with_completion(LaTeX_environments, "Enter Environment Name:", env, Null_String, 's'); if (strcmp(env, "document")) LaTeX_default_environment = env; if (arg == -1) latex_insert_env (env); else latex_change_env (env); } define latex_close_environment () { push_spot (); variable env = tex_current_env(); pop_spot(); if (strlen (env)) { vinsert ("\\end{%s}\n", env); } } % sectioning define latex_section () { LaTeX_default_section = read_with_completion (LaTeX_sections, "Enter Section Level:", LaTeX_default_section, Null_String, 's'); variable name = read_mini ("Enter Section Name:", Null_String, Null_String); variable label = read_mini ("Enter Label Name:", Null_String, LaTeX_default_section_label); eol (); newline (); vinsert ("\\%s{%s}\n", LaTeX_default_section, name); if (strcmp(label, LaTeX_default_section_label)) vinsert ("\\label{%s}\n", label); newline (); } % commenting define tex_insert_comment () { variable c = "% "; insert(c); % Although this appears to be a bizarre way of coding this, I cannot % think of a more compact method. while (2 == down(2)) { go_up_1 (); bol(); insert(c); } } define tex_uncomment_region () { narrow (); push_spot_bob (); go_down_1 (); do { go_up_1 (); bol(); if (looking_at("% ")) deln(2); } while (down(2) == 2); pop_spot (); widen (); } define tex_comment_region () { if (-1 == prefix_argument (-1)) { narrow (); push_spot_bob (); tex_insert_comment (); pop_spot (); widen (); return; } tex_uncomment_region(); } define tex_comment_paragraph () { push_spot (); if (-1 == prefix_argument (-1)) { forward_paragraph (); tex_isolate_paragraph (); % pushes spot pop_spot (); bob (); go_down_1 (); tex_insert_comment (); widen (); } else { push_spot (); go_up_1 (); bol(); while (looking_at("% ")) { deln(2); go_up_1 (); bol(); } pop_spot (); while (looking_at("% ")) { deln(2); go_down_1 (); } } pop_spot (); } % marking define tex_mark_environment () { push_spot(); variable env = tex_current_env(); if (strlen (env)) { set_mark_cmd (); pop_spot(); if (fsearch(sprintf("\\end{%s}", env))) go_down_1 (); else eob(); } else pop_spot(); } define tex_mark_section () { if (re_bsearch ("\\\\[sub]*section")) { bol(); set_mark_cmd (); go_down_1 (); if (re_fsearch ("\\\\[sub]*section")) { go_up_1 ();} else eob(); } else if (bsearch ("\\chapter")) { bol(); set_mark_cmd (); go_down_1 (); if (fsearch ("\\chapter")) { go_up_1 ();} else eob(); } } % indentation variable LaTeX_indent_level = 2; variable LaTeX_item_indent = 2; variable TeX_brace_indent_level = 2; % This is a useful function that should be made either an intrinsic or % more available to other packages. define current_indentation () { % return column of first non-whitespace character push_spot(); bol_skip_white(); what_column(); % left on stack pop_spot(); () - 1; } define tex_brace_count_line () { % this will count braces even inside comments variable count = 0; push_spot_bol (); while (ffind_char ('{')) { count += TeX_brace_indent_level; go_right_1 (); } bol(); while (ffind_char ('}')) { count -= TeX_brace_indent_level; go_right_1 (); } pop_spot(); count; } define latex_indent_calculate_last () {} % need dummy to allow recursive defn. define latex_indent_calculate_last () { % return the indentation of the previous normal text bol(); if (bobp()) return 0; % ignore comments do { go_up_1 (); bol_skip_white(); } while (looking_at_char ('%') and not(bobp())); if (looking_at("\\begin{document}")) return current_indentation(); if (looking_at("\\end{verbatim")) { % skip to before start of verbatim environment if (bsearch("\\begin{verbatim")) return latex_indent_calculate_last(); else return 0; } if (looking_at("\\begin{") or looking_at("\\left") or looking_at ("\\[")) LaTeX_indent_level + LaTeX_item_indent; else if (looking_at("\\item") or looking_at("\\bibitem")) LaTeX_item_indent; else 0; () + tex_brace_count_line() + current_indentation(); } define latex_indent_calculate () { % return the indentation of the current text bol_skip_white(); % keep verbatim environments flush left if (looking_at("\\begin{verbatim") or looking_at("\\end{verbatim")) return 0; if (looking_at("\\end{") or looking_at("\\right") or looking_at ("\\]")) return latex_indent_calculate_last() - LaTeX_item_indent - LaTeX_indent_level; if (looking_at("\\item") or looking_at("\\bibitem")) return latex_indent_calculate_last() - LaTeX_item_indent; latex_indent_calculate_last(); } define latex_indent_line () { push_spot(); latex_indent_calculate(); % on stack goto_spot (); bol_trim(); whitespace( () ); pop_spot(); } define latex_newline_indent_line () { if (bolp ()) { newline (); return; } newline(); latex_indent_line(); bol_skip_white(); %eol(); } define latex_indent_next_line () { push_spot(); go_down_1 (); latex_indent_line(); pop_spot(); } define latex_indent_region () { check_region(1); pop_mark_1 (); push_mark(); latex_indent_line(); % set initial line indentation before narrowing pop_spot(); push_spot(); go_up_1 (); narrow(); bob(); while (down_1 ()) % indent line by line (ie slowly) latex_indent_line(); % a good latex_format_paragraph would be nice... widen(); pop_spot(); } define latex_indent_section () { tex_mark_section(); latex_indent_region(); } define latex_indent_environment () { tex_mark_environment(); go_down_1 (); latex_indent_region(); } % misc define tex_insert_braces () { insert ("{}"); go_left_1 (); } define latex_insert_item () { eol (); insert ("\n\\item "); latex_indent_line(); } % symbol completion define tex_complete_symbol () { variable symbol, completion; variable insertbuf = whatbuf(), searchbuf = "*ltx-comp*"; !if (bufferp(searchbuf)) { sw2buf(searchbuf); insert_file( expand_jedlib_file("ltx-comp.dat") ); bob(); set_buffer_modified_flag(0); sw2buf(insertbuf); bury_buffer(searchbuf); } push_spot(); push_mark(); bskip_word(); symbol = bufsubstr(); setbuf(searchbuf); !if (bol_fsearch(sprintf("\\%s", symbol))) bob(); % wrap to start if (bol_fsearch(sprintf("\\%s", symbol))) { go_right_1 (); go_right(strlen(symbol)); push_mark_eol(); completion = bufsubstr(); } else { setbuf(insertbuf); pop_mark_0 (); pop_spot(); error("No completion found"); } setbuf(insertbuf); goto_spot (); push_mark(); !if (ffind_char (' ')) eol(); del_region(); insert(completion); pop_spot(); } variable LaTeX_macros = Null_String; define tex_insert_macro () { variable insertbuf = whatbuf(), searchbuf = "*ltx-comp*"; !if (strcmp(LaTeX_macros, Null_String)) { !if (bufferp(searchbuf)) { sw2buf(searchbuf); insert_file( expand_jedlib_file("ltx-comp.dat") ); set_buffer_modified_flag(0); sw2buf(insertbuf); bury_buffer(searchbuf); } sw2buf(searchbuf); bob(); while (bol_fsearch("\\")) { go_right_1 (); push_mark_eol (); LaTeX_macros += bufsubstr() + ","; } sw2buf(insertbuf); } variable macro = read_with_completion (LaTeX_macros, "Enter Macro Name:", Null_String, Null_String, 's'); vinsert ("\\%s", macro); go_left_1 (); !if (looking_at_char('}')) go_right_1 (); } % info file interface variable LaTeX_help = Null_String; define latex_help () { variable info_file = "(latex)"; variable latex_buf = whatbuf(), info_buf = "*Info*"; push_spot(); variable guess = tex_current_env(); pop_spot(); !if (strcmp(guess, "document")) guess = Null_String; ERROR_BLOCK { sw2buf(latex_buf); } !if (strcmp(LaTeX_help, Null_String)) { #iffalse info_find_node(sprintf("%sList of Commands", info_file)); #else info_find_node(sprintf("%sCommands", info_file)); #endif sw2buf(info_buf); if (fsearch("* Menu:")) go_down_1 (); while (bol_fsearch("* ")) { go_right(2); push_mark_eol (); go_left(2); LaTeX_help += bufsubstr() + ","; } } sw2buf(latex_buf); push_spot(); !if (looking_at_char('\\')) { go_left_1 (); !if (looking_at_char('\\')) { goto_spot (); bskip_word(); go_left_1 (); } } if (looking_at_char('\\')) { push_mark(); skip_word(); guess = bufsubstr(); } pop_spot(); guess = read_with_completion(LaTeX_help, "Describe LaTeX command:", guess, Null_String, 's'); info_find_node(sprintf("%s%s", info_file, guess)); pop2buf(info_buf); } private define init_menu (menu) { menu_append_item (menu, "Font", "tex_font"); menu_append_item (menu, "Environment", "latex_environment"); menu_append_item (menu, "Section", "latex_section"); menu_append_item (menu, "Comment Region", "tex_comment_region"); menu_append_item (menu, "Uncomment Region", "tex_uncomment_region"); menu_append_item (menu, "Comment Paragraph", "tex_comment_paragraph"); menu_append_item (menu, "Mark Environment", "tex_mark_environment"); menu_append_item (menu, "Mark Section", "tex_mark_section"); menu_append_item (menu, "Indent Region", "latex_indent_region"); menu_append_item (menu, "Indent Section", "latex_indent_section"); menu_append_item (menu, "Indent Environment", "latex_indent_environment"); } %!%+ %\function{latex_mode} %\synopsis{latex_mode} %\usage{Void latex_mode ();} %\description % This mode is designed to facilitate the task of editing latex files. % It calls the function \var{latex_mode_hook} if it is defined. In addition, % if the abbreviation table \var{"TeX"} is defined, that table is used. % % The default key-bindings for this mode include: %#v+ % "tex_insert_braces" "^C{" % "tex_font" "^C^F" % "latex_environment" "^C^E" % "latex_section" "^C^S" % "latex_close_environment" "^C]" % "latex_insert_item" "^C^J" % "tex_comment_region" "^C;" % "tex_uncomment_region" "^C:" % "tex_comment_paragraph" "^C%" % "tex_mark_environment" "^C." % "tex_mark_section" "^C*" % "latex_toggle_math_mode" "^C~" % "tex_insert_macro" "^C^M" % "tex_complete_symbol" "\e^I" % "latex_help" "^Ci" % "latex_indent_next_line" "^J" % "latex_indent_region" "^C^Q^R" % "latex_indent_section" "^C^Q^S" % "latex_indent_environment" "^C^Q^E" %#v- %!%- define latex_mode () { variable tex = "TeX"; variable quote = "`"; use_keymap ("LaTeX-Mode"); set_mode ("LaTeX", 0x1 | 0x20); set_buffer_hook ("par_sep", "tex_paragraph_separator"); set_buffer_hook ("wrap_hook", "tex_wrap_hook"); set_buffer_hook ("indent_hook", "latex_indent_line"); set_buffer_hook ("newline_indent_hook", "latex_newline_indent_line"); % latex math mode will map this to something else. %local_unsetkey (quote); %local_setkey ("quoted_insert", quote); mode_set_mode_info ("LaTeX", "init_mode_menu", &init_menu); mode_set_mode_info ("LaTeX", "fold_info", "%{{{\r%}}}\r\r"); use_syntax_table ("TeX-Mode"); run_mode_hooks("latex_mode_hook"); } % overload alternative function definitions for LaTeX 2.09 if required if (strcmp(LaTeX_default_documentstyle, "")) () = evalfile("latex209"); provide ("latex"); jed-0.99-19/lib/ltx-comp.dat0000644002657400265740000000401211311317447014472 0ustar davisdavis\LaTeX \TeX \\[] \\*[] \addcontentsline{}{}{} \addtocontents{}{} \addtocounter{}{} \addtolength{}{} \addvspace{} \alph{} \and \arabic{} \arraystretch \author{} \bibitem[]{} \bibliography{} \bibliographystyle{} \bigskip \caption{} \centering \circle{} \circle*{} \cite[]{} \cleardoublepage \clearpage \cline{-} \dashbox{}(,)[]{} \date{} \documentclass[]{} \documentstyle[]{} \extracolsep{} \fbox{} \flushbottom \fnsymbol{} \footnote[]{} \footnotemark[] \footnotetext[]{} \frac{}{} \frame{} \framebox[][]{} \fussy \glossary{} \hline \hspace{} \hspace*{} \hyphenation{} \include{} \includeonly{} \index{} \input{} \item[] \kill \label{} \left \lefteqn{} \line(,){} \linebreak[] \linethickness{} \makebox[][]{} \makeglossary \makeindex \marginpar[]{} \markboth{}{} \markright{} \mbox{} \medskip \multicolumn{}{}{} \multiput(,)(,){}{} \newcommand{}[][]{} \newcounter{}[] \newenvironment{}[][]{}{} \newfont \newlength{} \newline \newpage \newsavebox{} \newtheorem{}[]{}[] \nocite{} \nolinebreak[] \nonumber \nopagebreak[] \normalmarginpar \numberline{}{} \onecolumn \oval[](,)[] \overbrace{} \overline{} \pagebreak[] \pagenumbering{} \pageref{} \pagestyle{} \parbox[]{}{} \poptabs \protect \pushtabs \put(,){} \raggedbottom \raggedleft \raggedright \raisebox{}[][]{} \ref{} \refstepcounter{} \renewcommand{}[][]{} \renewenvironment{}[][]{}{} \reversemarginpar \roman{} \rule[]{}{} \samepage \savebox{}[][]{} \sbox{}{} \setcounter{}{} \setlength{}{} \settowidth{}{} \shortstack[]{} \sloppy \smallskip \sqrt[]{} \stackrel{}{} \stepcounter{} \stretch{} \suppressfloats[] \thanks{} \thicklines \thinlines \thispagestyle{} \title{} \twocolumn[] \typein[]{} \typeout{} \underbrace{} \underline{} \usebox{} \usecounter{} \usepackage[]{} \value{} \vector(,){} \verb \verb* \vline \vspace{} \vspace*{} % sectioning \part[]{} \part*{} \chapter[]{} \chapter*{} \section[]{} \section*{} \subsection[]{} \subsection*{} \subsubsection[]{} \subsubsection*{} \paragraph[]{} \paragraph*{} \subparagraph[]{} \subparagraph*{} \appendix \tableofcontents \listoffigures \listoftables jed-0.99-19/lib/recent.sl0000644002657400265740000001125311311317447014062 0ustar davisdavis% File: recent.sl -*- SLang -*- % % Author: Guido Gonzato, % % Version: 1.0.1. This file provides easy access to recently % accessed files. % % Installation: to install this feature globally, load recent.sl from site.sl % and insert the following lines in defaults.sl: % % variable RECENT_FILES_LIST = ".jedrecent"; % or other % variable MAX_RECENT_FILES = 20; % ditto % % For personal customisation, insert these lines in your .jedrc: % % % WANT_RECENT_FILES_LIST = 1 % set this to 0 to disable % % RECENT_FILES_LIST = ".jedrecent"; % uncomment to customise % % MAX_RECENT_FILES = 10; % % Last updated: 17 April 2001 custom_variable ("WANT_RECENT_FILES_LIST", 1); #ifdef IBMPC_SYSTEM custom_variable ("RECENT_FILES_LIST", "_jedrcnt"); #else custom_variable ("RECENT_FILES_LIST", ".jedrecent"); #endif custom_variable ("MAX_RECENT_FILES", 15); % ----- private variable Recent_Files_Buf = " *recent files*"; private variable List_Of_Buffers = NULL; private define get_recent_file_list_name () { variable file = RECENT_FILES_LIST; % Versions of slang prior to 1.4.3 have a bug in the path_is_absolute function. if (_slang_version >= 10403) { if (path_is_absolute (file)) return file; } variable dir = Jed_Home_Directory; #ifdef IBMPC_SYSTEM if (dir == "") { dir = getenv ("TEMP"); if (dir == NULL) dir = ""; } #endif return dircat (dir, file); } % Load the list of recent files in recent_files_buf. private define load_recent_file_list () { variable file = get_recent_file_list_name (); if (bufferp (Recent_Files_Buf)) { setbuf (Recent_Files_Buf); if (file_changed_on_disk (file)) delbuf (Recent_Files_Buf); } !if (bufferp (Recent_Files_Buf)) { () = read_file (file); rename_buffer (Recent_Files_Buf); } bob (); } % Build the menu of recent files. public define recent_files_menu_callback (popup) { variable buf, tmp, i, cmd; variable menu; buf = whatbuf (); load_recent_file_list (); % load the list of recent files bob (); i = '1'; % use 1-9 first, then a-z, then A-Z, then give up and restart forever { tmp = line_as_string (); !if (strlen (tmp)) break; cmd = sprintf ("()=find_file (\"%s\")", tmp); (cmd, ) = strreplace (cmd, "\\", "\\\\", strlen (cmd)); % fix DOS menu_append_item (popup, sprintf ("&%c %s", i, tmp), cmd); go_down_1 (); % check - what should we use? switch (i) { case '9': i = 'a' - 1; } { case 'z': i = 'A' - 1; } { case 'Z': i = '1' - 1; } i++; } setbuf (buf); } % This function is called by _jed_switch_active_buffer_hooks public define append_recent_files (buf) { variable file, dir, n; variable blist; !if (WANT_RECENT_FILES_LIST) return; % find out the file name with full path (file,dir,buf,) = getbuf_info (); !if (strlen (file)) return; blist = [buffer_list (), pop ()]; file = dircat (dir, file); load_recent_file_list (); EXIT_BLOCK { sw2buf (buf); List_Of_Buffers = blist; } if (is_readonly ()) return; % no permission to modify buffer/list % Check to see if this one is already on the list bob (); if (file == line_as_string ()) return; % Only add the file to the list if it is not on the list, or it was % not in the previously checked list of buffers. if (List_Of_Buffers != NULL) { if (any (List_Of_Buffers == buf)) return; } if (bol_fsearch (file)) { go_right (strlen (file)); if (eolp ()) delete_line (); } bob (); vinsert ("%s\n", file); % are there more entries than allowed? goto_line (MAX_RECENT_FILES); if (down_1 ()) { bol (); push_mark (); eob (); del_region (); } ERROR_BLOCK { _clear_error (); } file = get_recent_file_list_name (); () = write_buffer (file); () = chmod (file, 0600); } %add_to_hook ("_jed_find_file_after_hooks", &append_recent_files); append_to_hook ("_jed_switch_active_buffer_hooks", &append_recent_files); private define add_recent_files_popup_hook (menubar) { !if (WANT_RECENT_FILES_LIST) return; variable menu = "Global.&File"; menu_append_separator (menu); menu_append_popup (menu, "&Recent Files"); menu_set_select_popup_callback (strcat (menu, ".&Recent Files"), &recent_files_menu_callback); } #ifexists _jed_run_hooks append_to_hook ("load_popup_hooks", &add_recent_files_popup_hook); #else variable Menu_Load_Popups_Hook = &add_recent_files_popup_hook; #endif provide ("recent"); % End of file recent.sl jed-0.99-19/lib/ashell.sl0000644002657400265740000001736111311317447014060 0ustar davisdavis%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % async shell for jed !if (is_defined ("Shell_Default_Shell")) { #ifdef WIN32 variable Shell_Default_Shell = getenv ("COMSPEC"); if (Shell_Default_Shell == NULL) Shell_Default_Shell = "cmd.exe"; #else variable Shell_Default_Shell = getenv ("SHELL"); if (Shell_Default_Shell == NULL) Shell_Default_Shell = "sh"; #endif } !if (is_defined ("Shell_Default_Interactive_Shell")) { #ifdef WIN32 variable Shell_Default_Interactive_Shell = ""; #else variable Shell_Default_Interactive_Shell = "-i"; #endif } variable AShell_Id = -1; private variable Current_Working_Directory = "."; public define ashell_expand_path (path) { if ((path == NULL) or (path == "~")) path = "~/"; #ifdef UNIX if (path[0] == '~') { variable user = extract_element (path, 0, '/'); if (strlen (user) > 1) { variable dir; (dir,,,,) = get_passwd_info (user[[1:]]); if (strlen (dir)) (path,) = strreplace (path, user, dir, 1); } } #endif variable cwd = getcwd (); () = chdir (Current_Working_Directory); path = expand_filename (path); () = chdir (cwd); return path; } public define ashell_getcwd () { return Current_Working_Directory; } public define ashell_chdir (dir) { dir = ashell_expand_path (dir); if (-1 == chdir (dir)) verror ("chdir %s failed: %s", dir, errno_string (errno)); Current_Working_Directory = dir; } private define builtin_cd (cmd, argc, argv) { variable arg = ashell_expand_path (argv[1]); if (0 == chdir (arg)) Current_Working_Directory = arg; return cmd; } private define builtin_edit (cmd, argc, argv) { variable dir = Current_Working_Directory; foreach (argv[[1:argc-1]]) { variable file = (); () = find_file (expand_filename (dircat (dir, file))); } return ""; } private define builtin_most (cmd, argc, argv) { ERROR_BLOCK { _clear_error (); insert ("\nUnable to read file.\n"); return ""; } if (argc < 2) return cmd; () = read_file (argv[1]); pop2buf (whatbuf ()); most_mode (); return ""; } private variable Builtin_Cmds = Assoc_Type [Ref_Type]; public define ashell_add_builtin (cmd, fun) { Builtin_Cmds[cmd] = fun; } ashell_add_builtin ("cd", &builtin_cd); ashell_add_builtin ("edit", &builtin_edit); ashell_add_builtin ("jed", &builtin_edit); ashell_add_builtin ("most", &builtin_most); ashell_add_builtin ("more", &builtin_most); ashell_add_builtin ("less", &builtin_most); private define parse_shell_cmd (cmd) { variable argv, argc; cmd = strtok (cmd); argc = length (cmd); % This has the effect of NULL terminating the argv list argv = String_Type[argc+1]; % remember that in slang1 [0:-1] picks out elements in an array indexing % context. So, only do this if argc is non-zero. slang2 has different % semantics and does not suffer from this problem. if (argc) argv[[0:argc-1]] = cmd; return (argc, argv); } private define try_builtin (cmd) { variable argc, argv; (argc, argv) = parse_shell_cmd (cmd); !if (argc) return cmd; variable fun, command; command = argv[0]; !if (assoc_key_exists (Builtin_Cmds, command)) return cmd; fun = Builtin_Cmds[command]; return @fun (cmd, argc, argv); } define ashell_send_input () { variable buf; variable this_line, mark_line; variable m, ch, prompt; m = process_mark (AShell_Id); this_line = what_line (); push_mark (); goto_user_mark (m); mark_line = what_line (); if (this_line >= mark_line) { pop_mark_0 (); push_mark_eob (); buf = bufsubstr (); } else { bskip_chars ("\t "); push_mark (); !if (bolp ()) { go_left_1 (); ch = what_char (); } bol (); prompt = bufsubstr (); pop_mark_1 (); bol (); if (looking_at (prompt)) { go_right (strlen (prompt)); } else if (ffind_char (ch)) { go_right_1 (); } push_mark_eol (); buf = bufsubstr (); eob (); insert (buf); } newline (); move_user_mark (m); buf = try_builtin (buf); #ifdef WIN32 send_process (AShell_Id, buf + "\n\r"); #else send_process (AShell_Id, buf + "\n"); #endif } define ashell_send_intr () { signal_fg_process (AShell_Id, 2); % SIGINT } define ashell_completion () { variable partial_completion; variable dir, file; push_spot (); push_mark (); bskip_chars ("^ \n\t'`\"><$"); partial_completion = bufsubstr(); pop_spot (); (dir, file) = parse_filename (partial_completion); dir = ashell_expand_path (dir); variable len = strlen (file); variable files = listdir (dir); files = files[where (0 == array_map (Int_Type, &strncmp, files, file, len))]; variable num_matches = length (files); if (num_matches == 0) { message ("No completions"); return; } variable match; variable i; _for (0, num_matches-1, 1) { i = (); match = files[i]; if (2 == file_status (path_concat (dir, match))) files[i] = path_concat (match, ""); % add / } match = files[0]; if (num_matches == 1) { insert (match[[len:]]); return; } % Complete as much as possible. By construction, the first len characters % in the matches list are the same. Start from there. _for (len, strlen (match)-1, 1) { i = (); variable try_match = match[[0:i]]; if (num_matches != length (where (0==array_map (Int_Type, &strncmp, try_match, files, i+1)))) { if (i != len) insert (match[[len:i-1]]); break; } } variable cbuf = whatbuf (); pop2buf ("*completions*"); erase_buffer (); foreach (files) { insert (()); newline(); } buffer_format_in_columns (); bob (); pop2buf (cbuf); message ("Ambiguous Completions"); } $1 = "AShellMap"; !if (keymap_p ($1)) make_keymap ($1); definekey ("ashell_send_input", "^M", $1); undefinekey ("^C", $1); definekey ("ashell_send_intr", "^C", $1); definekey ("ashell_completion", "\t", $1); define ashell_signal_handler (pid, flags, status) { variable msg; eob (); msg = aprocess_stringify_status (pid, flags, status); vinsert ("\n\n----- %s ------\n\n", msg); AShell_Id = -1; } define ashell_insert_output (pid, str) { goto_user_mark (process_mark (pid)); variable use_overwrite = not eolp (); foreach (str) using ("bytes") { variable ch = (); if (ch == '\r') { bol (); use_overwrite = 1; continue; } if (ch == 8) { ifnot (bolp ()) go_left(1); use_overwrite = 1; continue; } if (ch == '\n') { eol (); newline (); use_overwrite = 0; continue; } if (use_overwrite) del (); insert_byte (ch); } variable col = what_column (); eol_trim (); goto_column (col); move_user_mark (process_mark (pid)); } define ashell () { variable buf = "*ashell*"; variable arg, nargs = 0; if ((AShell_Id != -1) and bufferp (buf)) { pop2buf (buf); error ("Currently, only one shell process is supported."); } pop2buf (buf); (,Current_Working_Directory,,) = getbuf_info (); () = chdir (Current_Working_Directory); use_keymap ("AShellMap"); run_mode_hooks ("ashell_mode_hook"); erase_buffer (); #iffalse AShell_Id = open_process (Shell_Default_Shell, Shell_Default_Interactive_Shell, 1); #else % parse possible arguments forever { arg = extract_element (Shell_Default_Shell, nargs, ' '); if (arg == NULL) break; nargs++; arg; % push on stack } Shell_Default_Interactive_Shell; nargs;% push on stack AShell_Id = open_process (); #endif set_process (AShell_Id, "signal", "ashell_signal_handler"); set_process (AShell_Id, "output", "ashell_insert_output"); } provide ("ashell"); jed-0.99-19/lib/matlab.sl0000644002657400265740000001213511311317447014042 0ustar davisdavis% matlab.sl -*- SLang -*- % % This file provides a mode for editing Matlab/Octave files. % % Written by Guido Gonzato % Very simple, but it works. % Last updated: 19 May 1999 $1 = "matlab"; !if (keymap_p ($1)) make_keymap ($1); % very few facilities at the moment: simple syntax highlighting, % indent, and comment/uncomment. definekey ("matlab_comment", "\e;", $1); definekey ("matlab_uncomment", "\e:", $1); % Now create and initialize a simple syntax table. create_syntax_table ($1); define_syntax ("%", "", '%', $1); % comments (doesn't work) define_syntax ("#", "", '%', $1); % comments -- Octave define_syntax ("([{", ")]}", '(', $1); % parentheses define_syntax ('"', '"', $1); % strings define_syntax ('\\', '\\', $1); % escape character define_syntax ("0-9a-zA-Z_", 'w', $1); % identifiers define_syntax ("0-9a-fA-F.xXL", '0', $1); % numbers define_syntax (",;", ',', $1); % delimiters define_syntax ("!&+-.*^;<>\|~='/:", '+', $1); % operators set_syntax_flags ($1, 4); % Matalb/Octave reserved words. Are there more? () = define_keywords_n ($1, "cdifls", 2, 0); () = define_keywords_n ($1, "direndforsettrywho", 3, 0); () = define_keywords_n ($1, "caseechoelsegsethdirhelpholdloadmoresaveshowtypewhos", 4, 0); () = define_keywords_n ($1, "breakcatchcleardiaryendifgplotgshowwhichwhile", 5, 0); () = define_keywords_n ($1, "elseifendforformatglobalgsplotreturnswitch", 6, 0); () = define_keywords_n ($1, "casesenhistory", 7, 0); () = define_keywords_n ($1, "continueendwhilefunction", 8, 0); () = define_keywords_n ($1, "endswitch", 9, 0); () = define_keywords_n ($1, "all_va_argsendfunctionrun_history", 11, 0); () = define_keywords_n ($1, "edit_history", 12, 0); () = define_keywords_n ($1, "end_try_catch", 13, 0); () = define_keywords_n ($1, "unwind_protect", 14, 0); () = define_keywords_n ($1, "end_unwind_protect", 18, 0); () = define_keywords_n ($1, "unwind_protect_cleanup", 22, 0); variable Matlab_Continue_Char = "\\"; variable Matlab_Indent = 2; % Matlab indent routine. define matlab_indent () { variable goal = 1; variable cs = CASE_SEARCH; variable ch; % goto beginning of line and skip past continuation char USER_BLOCK0 { bol (); skip_chars (" \t"); if (looking_at(Matlab_Continue_Char)) go_right_1 (); skip_white (); } push_spot (); push_spot (); CASE_SEARCH = 1; % Octave is case sensitive while (up_1 ()) { bol_skip_white(); if (eolp() or looking_at(Matlab_Continue_Char)) continue; X_USER_BLOCK0 (); goal = what_column (); if (looking_at("switch")) goal += 2 * Matlab_Indent; % to account for 'case' if (looking_at ("if ") or looking_at ("if(") or looking_at ("case") or looking_at ("otherwise") or looking_at ("while") or looking_at ("for ") or looking_at ("else") or looking_at ("elseif") or looking_at ("unwind_protect_cleanup") or looking_at ("unwind_protect") or looking_at ("try") or looking_at ("catch") or looking_at ("function") ) goal += Matlab_Indent; break; } % now check the current line pop_spot (); push_spot (); X_USER_BLOCK0 (); if (looking_at ("endswitch")) goal -= 2 * Matlab_Indent; if (looking_at ("end") or looking_at ("endif") or looking_at ("case") or looking_at ("endwhile") or looking_at ("endfor") or looking_at ("end_try_catch") or looking_at ("unwind_protect_cleanup") or looking_at ("end_unwind_protect") or looking_at ("else") or looking_at ("endfunction") ) goal -= Matlab_Indent; CASE_SEARCH = cs; % done getting indent if (goal < 1) goal = 1; pop_spot (); bol_skip_white (); ch = char(what_char()); bol_trim (); goal--; insert_spaces (goal); pop_spot (); skip_white (); } % matlab_indent define matlab_newline () { if (bolp ()) { newline (); return; } matlab_indent (); newline (); matlab_indent (); } % Matlab comment routines. define matlab_is_comment () { bol (); skip_chars (" \t0-9"); bolp () and not (eolp()); } define matlab_uncomment () { push_spot (); if (matlab_is_comment ()) { bol (); if (looking_at ("%") | looking_at("#")) deln (1); else del (); } matlab_indent (); pop_spot (); go_down_1 (); } define matlab_comment () { !if (matlab_is_comment ()) { push_spot_bol (); insert ("%"); } pop_spot (); go_down_1 (); } %!%+ %\function{matlab_mode} %\synopsis{matlab_mode} %\description % Protoytype: Void matlab_mode (); % This is a mode that is dedicated to facilitate the editing of % Matlab/Octave language files. % Functions that affect this mode include: %#v+ % function: default binding: % matlab_indent RETURN %#v- % Variables affecting indentation include: % Hooks: \var{matlab_mode_hook} %!%- define matlab_mode () { variable kmap = "matlab"; set_mode(kmap, 2); use_keymap(kmap); use_syntax_table (kmap); set_buffer_hook ("indent_hook", "matlab_indent"); set_buffer_hook ("newline_indent_hook", "matlab_newline"); run_mode_hooks("matlab_mode_hook"); } % --- End of file matlab.sl --- jed-0.99-19/lib/jed.hlp0000644002657400265740000000054411311317447013512 0ustar davisdavisBasic JED Commands: `^' means to use Ctrl key (e.g., ^D = Ctrl-D) ^KE exit ^D pagedown ^FF search ^K^B set mark ^V delete ^U pageup ^FB search back ^KK copy region ^E end of line ^K^W write buffer ^K^R replace ^K^P paste ^B beginning of line ^KG find file ^R redraw ^K^V cut region jed-0.99-19/lib/vmshelp.sl0000644002657400265740000000446311311317447014265 0ustar davisdavis% Interface to VMS Help variable VMSHelp_Topic_Len = 0; variable VMS_Help_Library = "SYS$HELP:HELPLIB.HLB"; % change as necessary - routines work with any .HLB file. define vms_help () { variable curr_buf, helptopic; if (VMSHelp_Topic_Len) return; curr_buf = whatbuf(); ERROR_BLOCK { pop_mark_0 (); sw2buf(curr_buf); VMSHelp_Topic_Len = -0; } helptopic = read_mini("VMS Help Topic:", Null_String, Null_String); sw2buf ("*VMS-Help*"); % set_readonly (0); erase_buffer (); push_mark(); % This mark is popped later VMSHelp_Topic_Len = -1; vms_get_help (VMS_Help_Library, helptopic); EXECUTE_ERROR_BLOCK; } variable VMSHelp_This_Topic = Null_String; define vms_help_grab_topic () { variable word = "-/_@=:0-9a-zA-Z\277-\326\330-\336\340-\366\370-\376"; bskip_chars (word); push_mark(); skip_chars (word); VMSHelp_This_Topic = bufsubstr (); strlen (VMSHelp_This_Topic); } define vms_help_newtopic (prompt) { variable use_call, fun, ch, topic, msg; setbuf ("*VMS-Help*"); pop_mark_1 (); % set_readonly (1); VMSHelp_This_Topic = Null_String; if (VMSHelp_Topic_Len) { msg = sprintf("Hit RET for '%s', PgDn/PgUp, ", prompt); recenter (1); forever { ERROR_BLOCK { _clear_error (); } message (msg); update_sans_update_hook (1); ch = getkey (); if (ch == '\r') break; if (ch == '.') { if (vms_help_grab_topic ()) break; continue; } if (ch == 127) { use_call = 1; fun = "page_up"; } else { ungetkey (ch); (use_call, fun) = get_key_binding (); if (typeof (fun) == Ref_Type) { (@fun)(); continue; } if (fun == NULL) fun = ""; } if (fun == "self_insert_cmd") { if (ch == ' ') fun = "page_down"; else { ungetkey(ch); break; } } if (use_call) call (fun); else eval (fun); } } re_fsearch ("^[\t ]*\\cAdditional information available:"); pop(); topic = strtrim(read_mini(prompt, VMSHelp_This_Topic, Null_String)); % set_readonly (0); VMSHelp_Topic_Len = strlen (topic); if (VMSHelp_Topic_Len) eob(); push_mark(); topic; } jed-0.99-19/lib/macro.sl0000644002657400265740000000417011311317447013703 0ustar davisdavis define macro_save_macro () { variable str = get_last_macro (); variable file; variable macro_name; file = read_file_from_mini ("Macro filename:"); !if (strlen (file)) return; macro_name = read_mini ("Name of macro:", Null_String, Null_String); !if (strlen (macro_name)) return; str = sprintf ("%%%%%%MACRO NAME: %s\n@%s\n\n", macro_name, str); if (-1 == append_string_to_file (str, file)) { error ("Error appending macro to file"); } } define macro_to_function () { variable macro = get_last_macro (); variable i, imax, ch, num; variable last_was_insert = 0, f, ftype; pop2buf ("*macro*"); eob (); newline (); insert ("\ndefine macro_"); push_spot (); insert ("EDITME ()\n{\n"); imax = strlen (macro); num = 0; i = 0; % Push macro characters on stack while (i < imax) { ch = macro[i]; if (ch == '\\') { i++; ch = macro[i]; } else if (ch == '^') { i++; ch = macro[i]; ch -= '@'; } ch; % push it on stack num++; i++; } while (num) { num--; ungetkey (()); } while (input_pending (0)) { (ftype, f) = get_key_binding (); if (typeof (f) == Ref_Type) { vinsert ("(@%S)(); %%<--- Ref may be to a private function\n", f); last_was_insert = 0; continue; } if (f == "self_insert_cmd") { !if (last_was_insert) { insert (" insert (\"\"); % insert text here\n"); last_was_insert = 1; } continue; } if (ftype) { insert (sprintf (" call (\"%s\");\n", f)); } else insert (sprintf (" %s ();\n", f)); last_was_insert = 0; } insert ("}\n"); pop_spot (); } define macro_assign_macro_to_key () { variable key = Null_String; variable ch = 0; flush ("Press key to assign macro to:"); do { ch = getkey (); if (ch == 0) ch = "^@"; else ch = char (ch); key = strcat (key, ch); } while (input_pending (5)); local_setkey (strcat ("@", get_last_macro ()), key); message (strcat ("Macro set to ", expand_keystring (key))); } jed-0.99-19/lib/jedhelp.sl0000644002657400265740000000267311311317447014223 0ustar davisdavis% % This is supposed to be an easy to use help facility % $1 = " *EZhelp*"; !if (keymap_p($1)) { make_keymap($1); definekey("page_up", "^?", $1); definekey("page_up", "u", $1); definekey("page_up", "U", $1); definekey("page_down", " ", $1); definekey("page_down", "d", $1); definekey("page_down", "D", $1); definekey("search_forward", "S", $1); definekey("search_forward", "F", $1); definekey("search_forward", "f", $1); definekey("search_forward", "s", $1); definekey("search_backward", "b", $1); definekey("search_backward", "B", $1); definekey("ezhelp_quit", "q", $1); definekey("ezhelp_quit", "Q", $1); } variable EZhelp_Last_Buffer; define ezhelp_quit() { sw2buf(EZhelp_Last_Buffer); } define jed_easy_help(file) { variable c, hlpbuf, hlpfile, err, flags, dir; hlpbuf = " *EZhelp*"; !if (strcmp(hlpbuf, whatbuf())) return; EZhelp_Last_Buffer = whatbuf(); err = strcat("Help file not found: ", file); ERROR_BLOCK { ezhelp_quit(); } sw2buf(hlpbuf); (hlpfile, dir, hlpbuf, flags) = getbuf_info(); if (strcmp(hlpfile, file)) { hlpfile = expand_jedlib_file(file); !if (strlen(hlpfile)) error(err); erase_buffer(); set_readonly(0); if (insert_file(hlpfile) <= 0) error(err); setbuf_info(file, dir, hlpbuf, flags); bob(); set_readonly(1); } use_keymap(hlpbuf); set_status_line(" u:Page Up, d:Page Down, s:Search, q:Quit Help (%p)", 0); } jed-0.99-19/lib/seldisp.sl0000644002657400265740000000134211311317447014243 0ustar davisdavis#ifdef HAS_LINE_ATTR define set_selective_display () { variable c, arg, h; variable msg; c = prefix_argument (-1); % Allow the current column be used to set the indent level. if (c == -1) c = what_column (); if (c <= 1) { arg = 0; msg = "Cancelling selective display mode..."; } else { arg = 1; c--; msg = sprintf ("Hiding all lines beyond column %d...", c); } flush (msg); push_spot (); bob (); h = 0; do { bol_skip_white (); !if (eolp ()) h = arg * (what_column () > c); % Otherwise, a blank line to if the last line was hidden, then % hide this one too. set_line_hidden (h); } while (down_1 ()); pop_spot (); message (msg + "done"); } jed-0.99-19/lib/iso-latin.sl0000644002657400265740000000116111311317447014476 0ustar davisdavis%% %% Initializes upper/lowercase lookup tables for ISO Latin 1 %% Information here derived from staring at a vt420 %% if (_slang_utf8_ok == 0) { . 0 64 1 { dup define_case } _for . 65 90 1 { dup 32 + define_case } _for . 91 96 1 { dup define_case } _for . 123 191 1 { dup define_case } _for . 192 222 1 { dup 32 + define_case } _for . 215 215 define_case . 223 223 define_case . 247 247 define_case . 255 255 define_case %. "0-9a-zA-Z\d191-\d214\d216-\d222\d224-\d246\d248-\d254" define_word %. "0-9a-zA-Z\d191-\d214\d216-\d246\d248-\d255" define_word . "0-9a-zA-Z\d192-\d214\d216-\d246\d248-\d255" define_word } jed-0.99-19/lib/compress.sl0000644002657400265740000000613011311317447014433 0ustar davisdavisprivate variable Compressed_File_Exts = [".gz", ".Z", ".bz2"]; private variable Compress_File_Pgms = ["gzip", "uncompress", "bzip2"]; private variable Uncompress_File_Pgms = ["gzip -dc %s", "uncompress -c %s", "bzip2 -dc %s" ]; private variable Auto_Compression_Mode = 0; private define check_is_compressed (file) { variable ext = path_extname (file); variable i = where (ext == Compressed_File_Exts); if (length (i)) return i[0]; return -1; } private define _write_compressed_region (file, append) { !if (blocal_var_exists ("Auto_Compression_Mode") or Auto_Compression_Mode) return 0; variable i = check_is_compressed (file); if (i == -1) return 0; variable cmd = sprintf ("%s > %s", Compress_File_Pgms[i], file); if (append) cmd = sprintf ("%s >> %s", Compress_File_Pgms[i], file); variable status = pipe_region (cmd); if (status != 0) verror ("%s returned %d", cmd, status); return 1; } private define write_compressed_region (file) { return _write_compressed_region (file, 0); } private define append_compressed_region (file) { return _write_compressed_region (file, 1); } private define insert_compressed_file (file) { !if (Auto_Compression_Mode) return 0; variable i = check_is_compressed (file); if (i == -1) return 0; if (1 != file_status (file)) return 0; variable cmd = sprintf (Uncompress_File_Pgms[i], file); () = run_shell_cmd (cmd); return 1; } private define read_compressed_file (file) { if (insert_compressed_file (file)) { create_blocal_var ("Auto_Compression_Mode"); return 1; } return 0; } add_to_hook ("_jed_insert_file_hooks", &insert_compressed_file); add_to_hook ("_jed_read_file_hooks", &read_compressed_file); append_to_hook ("_jed_write_region_hooks", &write_compressed_region); append_to_hook ("_jed_append_region_hooks", &append_compressed_region); private define compressed_set_mode_hook (ext) { variable i, file; !if (Auto_Compression_Mode) return 0; (file,,,) = getbuf_info (); i = check_is_compressed (file); if (i != -1) { file = file[[0:strlen(file)-strlen(ext)-2]]; mode_hook (file_type (file)); return 1; } return 0; } add_to_hook ("_jed_set_mode_hooks", &compressed_set_mode_hook); %!%+ %\function{auto_compression_mode} %\synopsis{Toggle auto-compression-mode} %\usage{auto_compression_mode ([Int_Type state [,&prev_state]])} %\description % The \var{auto_compression_mode} function toggles the auto-compression-mode % on or off. When on, files whose names end with \exmp{.gz}, \exmp{.Z}, or % \exmp{.bz2} will automatically uncompressed when read in, and compressed % when written out. %!%- public define auto_compression_mode () { if (_NARGS) { if (_NARGS == 2) { variable prev_statep = (); @prev_statep = Auto_Compression_Mode; } Auto_Compression_Mode = (); return; } variable state = "OFF"; Auto_Compression_Mode = not Auto_Compression_Mode; if (Auto_Compression_Mode) state = "ON"; vmessage ("Auto Compression Mode: %s", state); } jed-0.99-19/lib/pymode.sl0000644002657400265740000004277511311317447014114 0ustar davisdavis% Python mode % File: pymode.sl v1.3.1 % % For editing source code written in the Python programming language. % Provides basic compatibility with Python mode under real Emacs % % Authors: Harri Pasanen % Brien Barton % % following keys have python specific bindings: % % DELETE deletes to previous indent level % TAB indents line % ^C# comments region or current line % ^C> shifts line or region right % ^C< shifts line or region left % ^C^C executes the region, or the buffer if region not marked. % ^C| executes the region % ^C\t reindents the region % : colon dedents appropriately % % See python_mode function for available hooks % % Shortcomings: does not really support triple-quoted strings in any way. % % Changes from v1.0: % % Major improvements, mostly done by Brien Barton: % % - execution of python code from JED % - DFA syntax support % - improved indent - dedent. % % Changes from v1.1: % % Minor fixes, by Tom Culliton % % - corrected a syntax error % - fixed non-DFA syntax hilighting tables to work better % - added the new assert keyword % Changes from v1.2 % - autoindent correction % Changes from v1.3 % - discard return value from run_shell_cmd % - avoid use of create_array and explicit loop for initializing it. $1 = "python"; !if (keymap_p ($1)) make_keymap ($1); definekey_reserved ("py_comment_region", "#", $1); definekey_reserved ("py_uncomment_region", "3", $1); definekey_reserved ("py_shift_region_right", ">", $1); definekey_reserved ("py_shift_region_left", "<", $1); definekey_reserved ("py_exec", "^C", $1); % Execute buffer, or region if defined definekey_reserved ("py_exec_region", "|", $1); definekey_reserved ("py_reindent_region", "\t", $1); definekey ("py_backspace_key", "^?", $1); definekey ("indent_line", "\t", $1); definekey ("py_electric_colon", ":", $1); #ifdef MSWINDOWS definekey ("py_help_on_word", "^@;", $1); #endif % Set the following to your favourite indentation level custom_variable("Py_Indent_Level", 4); private define py_whitespace(cnt) { if ( get_blocal_var("py_use_tab") ) loop (cnt / TAB) insert_char('\t'); else insert_spaces (cnt); } private define py_line_ends_with_colon() { eol(); if (bfind_char(':')) { go_right(1); skip_white(); if (eolp() or looking_at_char('#')) return 1; } return 0; } private define py_endblock_cmd() { bol_skip_white(); push_mark(); skip_chars("a-z"); return is_list_element("return,raise,break,pass,continue", bufsubstr(), ',') > 0; } private define py_line_starts_subblock() { bol_skip_white(); if (looking_at("else") or looking_at("elif") or looking_at("except") or looking_at("finally")) return 1; return 0; } private define py_line_starts_block() { bol_skip_white(); if (looking_at("if") or looking_at("try") or py_line_starts_subblock()) return 1; return 0; } private define py_indent_calculate() { % return the indentation of the previous python line variable col = 0; variable subblock = 0; EXIT_BLOCK { pop_spot (); return col; } % check if current line starts a sub-block subblock = py_line_starts_subblock(); % go to previous non blank line push_spot_bol (); !if (re_bsearch ("[^ \t\n]")) return; bol_skip_white(); col = what_column() - 1; variable indent; if ( get_blocal_var("py_use_tab") ) indent = TAB; else indent = Py_Indent_Level; if (py_line_ends_with_colon()) col += indent; if (py_endblock_cmd() or (subblock and not py_line_starts_block())) col -= indent; } define py_indent_line() { variable col; col = py_indent_calculate(); bol_trim (); py_whitespace( col ); } define py_comment_line() { bol(); insert("##"); } define py_electric_colon() { variable i; insert(":"); push_spot(); if (py_line_starts_subblock()) % Only dedents on colon { pop_spot(); i = what_column(); bol_skip_white(); i = i - what_column(); if (py_indent_calculate() < what_column()) % Ensure dedent only py_indent_line(); bol_skip_white(); goto_column( i + what_column() ); } else pop_spot(); } define py_comment_region() { variable n; check_region (1); n = what_line (); pop_mark_1 (); loop (n - what_line ()) { py_comment_line(); go_down_1 (); } pop_spot(); } define py_comment() { push_spot(); if (markp()) { py_comment_region(); } else { py_comment_line(); } pop_spot(); } define py_uncomment_line() { bol_skip_white(); while (looking_at("#")) del(); } define py_uncomment_region() { variable n; check_region (1); n = what_line (); pop_mark_1 (); loop (n - what_line ()) { py_uncomment_line(); go_down_1 (); } pop_spot(); } define py_uncomment() { push_spot(); if (markp()) { py_uncomment_region(); } else { py_uncomment_line(); } pop_spot(); } define py_backspace_key() { variable col; col = what_column(); push_spot(); bskip_white(); if (bolp() and (col > 1)) { pop_spot(); if ( blooking_at("\t") ) { go_left (1); del(); } else { bol_trim (); col--; if (col mod Py_Indent_Level == 0) col--; py_whitespace ( (col / Py_Indent_Level) * Py_Indent_Level ); } } else { pop_spot(); call("backward_delete_char_untabify"); } } define py_shift_line_right() { variable times = prefix_argument(1); bol_skip_white(); py_whitespace(Py_Indent_Level*times); } define py_shift_region_right() { variable times = prefix_argument(1); check_region (1); % spot_pushed, now at end of region variable n = what_line (); pop_mark_1 (); loop (n - what_line ()) { set_prefix_argument(times); py_shift_line_right(); go_down_1 (); } pop_spot(); } define py_shift_right() { push_spot(); if (markp()) { py_shift_region_right(); } else { py_shift_line_right(); } pop_spot(); } define py_shift_line_left() { variable times = prefix_argument(1); bol_skip_white(); if (what_column() > Py_Indent_Level*times) { if ( get_blocal_var("py_use_tab") ) { go_left (times); deln(times); } else { push_mark(); goto_column(what_column() - Py_Indent_Level*times); del_region(); } } } define py_shift_region_left() { variable times = prefix_argument(1); check_region (1); variable n = what_line (); pop_mark_1 (); loop (n - what_line ()) { set_prefix_argument (times); py_shift_line_left(); go_down_1 (); } pop_spot(); } define py_shift_left() { push_spot(); if (markp()) { py_shift_region_left(); } else { py_shift_line_left(); } pop_spot(); } define py_newline_and_indent() { newline(); py_indent_line(); } define file_path(fullname) { variable filename; filename = extract_filename(fullname); substr(fullname, 1, strlen(fullname)-strlen(filename)); } define py_exec_region() { % Run python interpreter on current region. % Display output in *shell-output* buffer window. variable oldbuf, thisbuf, file, line, start_line; variable tmpfile = "_python.tmp"; variable error_regexp = "^ File \"\\([^\"]+\\)\", line \\(\\d+\\).*"; variable py_source = buffer_filename(); change_default_dir(file_path(py_source)); thisbuf = whatbuf(); % Check if 1st line starts in column 1 exchange_point_and_mark(); bol_skip_white(); start_line = what_line(); if (what_column() > 1) { % Workaround in case block is indented write_string_to_file("if 1:\n", tmpfile); bol(); start_line--; % offset for this extra line } exchange_point_and_mark(); append_region_to_file(tmpfile); oldbuf = pop2buf_whatbuf("*shell-output*"); erase_buffer (); #ifdef UNIX ()=run_shell_cmd(sprintf("python %s 2>&1", tmpfile)); #else ()=run_shell_cmd(sprintf("python %s", tmpfile)); #endif () = delete_file(tmpfile); % try to restore any window that got replaced by the shell-output if (strlen(oldbuf) and (strcmp(oldbuf, "*shell-output*") != 0) and (strcmp(thisbuf, oldbuf) != 0)) { splitwindow(); sw2buf(oldbuf); pop2buf("*shell-output*"); } eob(); % Check for error message while (re_bsearch(error_regexp) != 0) { % Make sure error occurred in the file we were executing file = regexp_nth_match(1); line = integer(regexp_nth_match(2)); if (strcmp(file, tmpfile) == 0) { % Move to line in source that generated the error pop2buf(thisbuf); goto_line(line + start_line - 1); break; } else { % Error is in another file, try previous error message continue; } } % if there is no output, then close the shell-window and % put a message up. This is how emacs works. if( bobp() and eobp() ) { pop2buf( thisbuf ); onewindow(); message( "No output." ); } } define py_exec() { % Run python interpreter on current region if one is defined, otherwise % on the whole buffer. % Display output in *shell-output* buffer window. !if (markp()) { % create region containing entire buffer push_spot_bob (); push_mark_eob (); } py_exec_region(); } define py_reindent() { % Reindents a (correctly) indented buffer using the current % value of Py_Indent_Level. % Warning: Current version can be fooled by implicit or explicit % continuation lines. variable indent_level = Int_Type[64]; %variable indent_level = create_array('i', 64, 1); variable level = -1; variable current_indent = -1; variable errmsg, i, col, ignore, oldlevel; indent_level[*] = -1; bob(); do { bol_skip_white(); ignore = looking_at_char('#') or eolp(); if (ignore) continue; % skip comments and blank lines col = what_column() - 1; oldlevel = level; % save current level if (col > current_indent) { % indenting level++; } else if (col < current_indent) { % dedent while ((level > 0) and (indent_level[level] > col)) { indent_level[level] = -1; % clear current level setting level--; } } if ((indent_level[level] != -1) and (indent_level[level] != col)) { % Indent is wrong. Hopefully it's a continuation line. level = oldlevel; % reset level bol_trim(); py_whitespace(level * Py_Indent_Level + (col - current_indent)); } else { current_indent = col; indent_level[level] = col; bol_trim(); py_whitespace(level * Py_Indent_Level); } } while (down(1) == 1); } define py_reindent_region() { narrow(); py_reindent(); widen(); } #ifdef MSWINDOWS define py_help_on_word() { variable tag = "0-9A-Z_a-z"; push_spot (); skip_white (); bskip_chars (tag); push_mark (); skip_chars (tag); tag = bufsubstr (); % leave on the stack pop_spot (); message( strcat("Help on ", tag) ); msw_help( getenv("PYLIBREF"), tag, 0); } #endif create_syntax_table ($1); define_syntax ("#", "", '%', $1); % comments define_syntax ("([{", ")]}", '(', $1); % delimiters define_syntax ('"', '"', $1); % quoted strings define_syntax ('\'', '"', $1); % quoted strings %define_syntax ('\'', '\'', $1); % quoted characters define_syntax ('\\', '\\', $1); % continuations define_syntax ("0-9a-zA-Z_", 'w', $1); % words define_syntax ("-+0-9a-fA-FjJlLxX.", '0', $1); % Numbers define_syntax (",;.:", ',', $1); % punctuation define_syntax ("%-+/&*=<>|!~^`", '+', $1); % operators set_syntax_flags ($1, 0); % keywords ARE case-sensitive () = define_keywords ($1, "ifinisor", 2); % all keywords of length 2 () = define_keywords ($1, "anddefdelfornottry", 3); % of length 3 .... () = define_keywords ($1, "elifelseexecfrompass", 4); () = define_keywords ($1, "breakclassprintraisewhileyield", 5); () = define_keywords ($1, "assertexceptglobalimportlambdareturn", 6); () = define_keywords ($1, "finally", 7); () = define_keywords ($1, "continue", 8); % Type 1 keywords (actually these are what's in __builtins__) () = define_keywords_n ($1, "id", 2, 1); () = define_keywords_n ($1, "setsumzipabschrcmpdirhexintlenmapmaxminoctordpowstr", 3, 1); () = define_keywords_n ($1, "TruebooldictexitfilehelpiterlistquitNoneevalhashlongopenreprtypevars", 4, 1); () = define_keywords_n ($1, "Falseslicesuperapplyfloatinputrangeroundtuple", 5, 1); () = define_keywords_n ($1, "bufferinternobjectsortedunichrcoercedivmodfilterlocalsreducereloadxrange", 6, 1); () = define_keywords_n ($1, "OSErrorWarningcomplexcreditslicenseunicodeIOError__doc__compiledelattrgetattrglobalshasattrsetattr", 7, 1); () = define_keywords_n ($1, "EllipsisTabErrorpropertyreversedEOFErrorKeyError__name__callableexecfile__call__", 8, 1); () = define_keywords_n ($1, "Exception__debug__copyrightenumeratefrozensetNameErrorTypeErrorraw_input", 9, 1); () = define_keywords_n ($1, "basestringisinstanceissubclassIndexErrorSystemExitValueError__import__", 10, 1); () = define_keywords_n ($1, "LookupErrorUserWarningclassmethodAccessErrorImportErrorMemoryErrorSyntaxErrorSystemError", 11, 1); () = define_keywords_n ($1, "UnicodeErrorstaticmethodRuntimeError", 12, 1); () = define_keywords_n ($1, "FutureWarningStandardErrorStopIterationSyntaxWarningConflictErrorOverflowError", 13, 1); () = define_keywords_n ($1, "AssertionErrorNotImplementedReferenceErrorRuntimeWarningAttributeErrorAssertionError", 14, 1); () = define_keywords_n ($1, "ArithmeticErrorOverflowWarning", 15, 1); () = define_keywords_n ($1, "EnvironmentErrorIndentationError", 16, 1); () = define_keywords_n ($1, "UnboundLocalErrorKeyboardInterruptZeroDivisionError", 17, 1); () = define_keywords_n ($1, "DeprecationWarningFloatingPointErrorUnicodeDecodeErrorUnicodeEncodeError", 18, 1); () = define_keywords_n ($1, "NotImplementedError", 19, 1); () = define_keywords_n ($1, "UnicodeTranslateError", 21, 1); () = define_keywords_n ($1, "PendingDeprecationWarning", 25, 1); #ifdef HAS_DFA_SYNTAX %%% DFA_CACHE_BEGIN %%% private define setup_dfa_callback (name) { dfa_enable_highlight_cache("python.dfa", name); dfa_define_highlight_rule("\"\"\".+\"\"\"", "string", name); % long string (""") dfa_define_highlight_rule("'''.+'''", "string", name); % long string (''') dfa_define_highlight_rule("\"[^\"]*\"", "string", name); % normal string dfa_define_highlight_rule("'[^']*'", "string", name); % normal string dfa_define_highlight_rule("#.*", "comment", name); % comment dfa_define_highlight_rule("[A-Za-z_][A-Za-z_0-9]*", "Knormal", name); % identifier dfa_define_highlight_rule("[1-9][0-9]*[lL]?", "number", name); % decimal int dfa_define_highlight_rule("0[0-7]*[lL]?", "number", name); % octal int dfa_define_highlight_rule("0[xX][0-9a-fA-F]+[lL]?", "number", name); % hex int dfa_define_highlight_rule("[1-9][0-9]*\\.[0-9]*([Ee][\\+\\-]?[0-9]+)?", "number", name); % float n.[n] dfa_define_highlight_rule("0?\\.[0-9]+([Ee][\\+\\-]?[0-9]+)?", "number", name); % float [n].n dfa_define_highlight_rule("[ \t]+", "normal", name); dfa_define_highlight_rule("[\\(\\[{}\\]\\),:\\.\"`'=;]", "delimiter", name); dfa_define_highlight_rule("[\\+\\-\\*/%<>&\\|\\^~]", "operator", name); % 1 char dfa_define_highlight_rule("<<|>>|==|<=|>=|<>|!=", "operator", name); % 2 char % Flag badly formed numeric literals or identifiers. This is more effective % if you change the error colors so they stand out. dfa_define_highlight_rule("[1-9][0-9]*[lL]?[0-9A-Za-z\\.]+", "error", name); % bad decimal dfa_define_highlight_rule("0[0-7]+[lL]?[0-9A-Za-z\\.]+", "error", name); % bad octal dfa_define_highlight_rule("0[xX][0-9a-fA-F]+[lL]?[0-9A-Za-z\\.]+", "error", name); % bad hex dfa_define_highlight_rule("\\.[0-9]+([Ee][\\+\\-]?[0-9]+)?[A-Za-z]+", "error", name); % bad float dfa_define_highlight_rule("[A-Za-z_][A-Za-z_0-9]*\\.[0-9]+[A-Za-z]*", "error", name); % bad identifier dfa_build_highlight_table(name); } dfa_set_init_callback (&setup_dfa_callback, "python"); %%% DFA_CACHE_END %%% #endif %!%+ %\function{python_mode} %\synopsis{python_mode} %\usage{python_mode ()} %\description % A major mode for editing python files. % % The following keys have python specific bindings: %#v+ % DELETE deletes to previous indent level % TAB indents line % ^C# comments region or current line % ^C> shifts line or region right % ^C< shifts line or region left % ^C^C executes the region, or the buffer if region not marked. % ^C| executes the region % ^C\t reindents the region % : colon dedents appropriately %#v- % Hooks: \var{python_mode_hook} % %\seealso{Py_Indent_Level} %\seealso{set_mode, c_mode} %!%- define python_mode () { variable python = "python"; create_blocal_var("py_use_tab"); set_blocal_var(Py_Indent_Level == TAB, "py_use_tab"); push_spot(); bob(); do { skip_white(); if ( looking_at("\"\"\"") ) { go_right (1); () = fsearch("\"\"\""); } else !if (looking_at_char('#') or eolp() or what_column() == 1) { bol(); set_blocal_var(looking_at_char('\t'), "py_use_tab"); break; } } while (down(1)); pop_spot(); set_mode (python, 0x4); % flag value of 4 is generic language mode use_keymap(python); set_buffer_hook ("indent_hook", "py_indent_line"); set_buffer_hook ("newline_indent_hook", "py_newline_and_indent"); use_syntax_table (python); run_mode_hooks ("python_mode_hook"); } jed-0.99-19/lib/mailutils.sl0000644002657400265740000000667211311317447014616 0ustar davisdavis% This file contains some routines for dealing with buffers that are used for % composing email % % Public Functions: % Int_Type mailutils_find_header_separator () % Int_Type mailutils_narrow_to_header () % mailutils_get_keyword_value (kw) % mailutils_set_keyword_value (field, value) %!%+ %\function{mailutils_find_header_separator} %\synopsis{Searches for the header/body separator} %\usage{Int_Type mailutils_find_header_separator ()} %\description % This function searches for the line separating the mail headers % from the body. It returns 1 if found, and 0 otherwise. %\seealso{mailutils_narrow_to_header} %!%- public define mailutils_find_header_separator () { bob (); if (bol_fsearch ("--- Do not modify this line. Enter your message below ---\n")) return 1; !if (re_looking_at ("[-A-Za-z0-9_]+: ")) return 0; return bol_fsearch ("\n"); } %!%+ %\function{mailutils_narrow_to_header} %\synopsis{Narrow to the mail headers} %\usage{Int_Type mailutils_narrow_to_header ()} %\description % This function narrows the buffer to the mail headers. It returns 0 % if sucessful (headers were found), or -1 upon failure. %\seealso{mailutils_find_header_separator, mailutils_set_keyword_value, widen} %!%- public define mailutils_narrow_to_header () { bob (); push_mark (); if (mailutils_find_header_separator ()) { narrow_to_region (); bob (); return 0; } pop_mark (0); return -1; } private define mark_this_keywords_value () { () = ffind (":"); go_right_1 (); push_mark (); while (down (1)) { skip_chars ("\t "); if (bolp ()) break; eol (); } go_left (1); } %!%+ %\function{mailutils_get_keyword_value} %\synopsis{Obtain the value of a header keyword} %\usage{String_Type mailutils_get_keyword_value (kw)} %\description % This function returns the value of a mail header specified by the % \exmp{kw} parameter. If no such header exists, \NULL will be % returned. %\notes % This function does not preserve the editing point. %\seealso{mailutils_set_keyword_value} %!%- public define mailutils_get_keyword_value (kw) { push_spot (); EXIT_BLOCK { pop_spot (); } if (-1 == mailutils_narrow_to_header ()) return NULL; variable exists = bol_fsearch (kw); widen_region (); if (exists == 0) return NULL; mark_this_keywords_value (); return strtrim (bufsubstr ()); } %!%+ %\function{mailutils_set_keyword_value} %\synopsis{Set the value of a mail header} %\usage{mailutils_set_keyword_value (String_Type kw, String_Type val)} %\description % This function sets the value of the header keyword specified by the % \exmp{kw} argument to that of the \exmp{val} argument. If no such % header exists, one will be created. The editing point will be left % at the end of the header's value. If the header exists and has a % value, then that value will be replace. %\notes % This function does not preserve the editing point. %\seealso{mailutils_get_keyword_value, mailutils_find_header_separator} %!%- public define mailutils_set_keyword_value (field, value) { if (-1 == mailutils_narrow_to_header ()) return; variable exists = bol_fsearch (field); widen_region (); if (exists == 0) { () = mailutils_find_header_separator (); % Do it this way to avoid moving a line mark go_left (1); vinsert ("\n%s", field); bol (); } mark_this_keywords_value (); del_region (); insert (" "); insert (strtrim (value)); } provide ("mailutils"); jed-0.99-19/lib/dired.sl0000644002657400265740000004314711311317447013700 0ustar davisdavis% -*- SLang -*- dired.sl % % Simple dired mode for JED. % % % To invoke Dired, do `C-x d' or `M-x dired'. % % Moving around % ============= % % All the usual motion commands plus some extras: % % `C-n' `n' SPC % move point to the next line (at the beginning of the file name) % % `C-p' `p' % move point to the previous line (at the beginning of the file name) % % DEL % move up and unflag % % `^K' % dired_kill_line - removes a line from the dired buffer % (This must be set from the dired hook) % % ============== % % The primary use of Dired is to "flag" files for deletion and then % delete the previously flagged files. % % `d' % Flag this file for deletion. % % `u' % Remove deletion flag on this line. % % `DEL' % Move point to previous line and remove the deletion flag on that % line. % % `~' % Flag all backup files (files whose names end with `~') for deletion % % `g' % Update the entire contents of the Dired buffer % % Deleting Files % ============== % % `x' % expunge all flagged files. Displays a list of all the file names % flagged for deletion, and requests confirmation with `yes'. % After confirmation, all the flagged files are deleted and then % their lines are deleted from the Dired buffer. % % File Manipulations % ================== % % `f' % Visit the file described on the current line, like typing `C-x C-f' % and supplying that file name % % `v' % View the file described on the current line % % `r' % rename - prompts for a new name for the file on the current line % % 'm' % move - move a group of flagged files to an new directory % % `M-x dired_search' % use fsearch with the contents of LAST_SEARCH to perform a search % through the files listed in the dired buffer from the current point % forward. Since it stops in the file where the search string is % encountered, it is structured so that `M-x dired_search' from the % visited file will revert back to the dired buffer and continue the % dired_search from the next file in the list. % variable Dired_Buffer = "*dired*"; variable Dired_Current_Directory; !if (keymap_p (Dired_Buffer)) make_keymap (Dired_Buffer); definekey ("dired_find", "\r", Dired_Buffer); definekey ("dired_find", "f", Dired_Buffer); definekey ("dired_view", "v", Dired_Buffer); definekey ("dired_tag", "d", Dired_Buffer); definekey (".1 dired_untag", "u", Dired_Buffer); definekey ("dired_move", "m", Dired_Buffer); definekey ("dired_delete", "x", Dired_Buffer); definekey (".1 dired_point", "^N", Dired_Buffer); definekey (".1 dired_point", "n", Dired_Buffer); definekey (".1 dired_point", " ", Dired_Buffer); definekey (".1 chs dired_point", "^P", Dired_Buffer); definekey (".1 chs dired_point", "p", Dired_Buffer); #ifdef UNIX definekey (".1 chs dired_untag", "^?", Dired_Buffer); % DEL key #elifdef IBMPC_SYSTEM definekey (".1 chs dired_untag", "\xE0S",Dired_Buffer); % DELETE definekey (".1 chs dired_untag", "\eOn", Dired_Buffer); % DELETE #endif definekey ("dired_flag_backup", "~", Dired_Buffer); definekey ("dired_rename", "r", Dired_Buffer); definekey ("dired_reread_dir", "g", Dired_Buffer); definekey ("describe_mode", "h", Dired_Buffer); definekey ("dired_quick_help", "?", Dired_Buffer); definekey ("dired_quit", "q", Dired_Buffer); define dired_quit () { delbuf (Dired_Buffer); } #ifdef VMS % takes somthing like dev:[a.b.c] and converts it to dev:[a.b]c.dir define dired_vms_dir (dir) { variable cdir = Null_String, last = Null_String, this; variable n, file, ch; n = strlen (dir); if (int (substr (dir, n, 1)) != ']') return dir; forever { n--; !if (n) break; ch = int (substr (dir, n, 1)); if ((ch == '.') or (ch == '[')) break; } if (ch == '[') substr (dir, 1, n) + "000000]"; else substr (dir, 1, n - 1) + "]"; cdir = (); file = substr (dir, n + 1, strlen (dir)); file = substr (file, 1, strlen (file) - 1) + ".dir"; cdir + file; } #endif define dired_read_dir (dir) { variable file, flags, spaces = " "; #ifdef VMS dir = dired_vms_dir (dir); #elifdef IBMPC_SYSTEM dir = expand_filename (dir); # ifdef MSDOS MSWINDOWS dir = msdos_fixup_dirspec (dir); # endif #endif if ( file_status (dir) == 2 ) { (Dired_Current_Directory,) = parse_filename (dircat (dir, Dired_Buffer)); #ifdef VMS dir = Dired_Current_Directory; #endif } else { (Dired_Current_Directory,dir) = parse_filename (dir); } if ( change_default_dir (Dired_Current_Directory) ) error ("Failed to chdir."); sw2buf (Dired_Buffer); (file,,,flags) = getbuf_info (); setbuf_info (file, Dired_Current_Directory, Dired_Buffer, flags); set_status_line (" DIRED: %b (%m%n) (%p) | press '?' for help.", 0); set_readonly (0); erase_buffer (); use_keymap (Dired_Buffer); set_mode ("dired", 0); #ifdef UNIX shell_cmd (sprintf ("ls -al %s 2>/dev/null", dir)); #elifdef MSDOS WIN16 shell_cmd (sprintf ("dir %s /l/ogne", dir)); #elifdef WIN32 shell_cmd (sprintf ("dir %s /ogne", dir)); % shell_cmd (Sprintf ("(dir %s /l/ogne) 2>&1", dir, 1)); #elifdef OS2 shell_cmd ("dir /n " + dir); #elifdef VMS shell_cmd ("directory/size/date/prot/notrail " + dir); #endif bob (); #ifdef OS2 % kill 4 lines of header junk and 2 lines of trailer junk push_mark (); go_down (4); if ( eolp () ) go_down_1 (); del_region (); eob (); push_mark (); go_up (3); % implicit eol(); del_region (); bob (); #elifdef MSDOS MSWINDOWS push_mark (); go_down (5); del_region (); % header junk eob (); push_mark (); % trailer junk if ( bsearch ("bytes free") ) { go_down_1 (); del_region (); } else { pop_mark_0 (); } bob (); #elifdef VMS push_mark (); go_down (3); del_region (); #endif do { insert (spaces); } while (down_1 ()); bob (); #ifdef UNIX if ( looking_at (" total ")) delete_line (); #endif insert ("== "); insert (Dired_Current_Directory); newline (); set_buffer_modified_flag (0); set_readonly(1); flush (""); } variable Dired_Quick_Help; Dired_Quick_Help = "d:tag file, u:untag, x:delete tagged files, r:rename, h:more help, ?:this help"; define dired_quick_help () { message (Dired_Quick_Help); } define dired_reread_dir () { dired_read_dir (Dired_Current_Directory); } % set the point at the start of the file name define dired_point (dirn) { if (dirn > 0) go_down_1 (); else if (dirn < 0) go_up_1 (); #ifdef UNIX bol_skip_white (); if (looking_at_char ('l')) { () = ffind ("->"); bskip_white (); } else eol (); bskip_chars ("^ \n"); #elifdef OS2 eol (); if (bfind_char (' ')) go_right_1 (); #elifdef VMS MSDOS WIN16 bol (); go_right (2); #elifdef WIN32 eol (); bskip_chars ("^ \n"); #endif } #ifndef VMS define dired_kill_line () { bol (); if ( bobp () ) return; % do not remove top line set_readonly (0); push_mark (); go_down_1 (); del_region (); set_buffer_modified_flag (0); set_readonly (1); dired_point (0); } #endif % (name, type) = dired_getfile () % % name = name of file or directory % % type = 0 : nothing % type = 1 : file % type = 2 : directory % type = 3 : link define dired_getfile () { variable name, type, ext, stat_buf; bol (); type = not (bobp ()); % assume it will be a file #ifdef UNIX if (type) { go_right (2); if (looking_at_char ('l')) type = 3; else if (looking_at_char ('d')) type = 2; else { skip_white (); if ( what_column () > 3 ) type = 0; } } !if ( type ) { bol (); return (Null_String, type); } dired_point (0); if (type != 3) { push_mark_eol (); % extract the name name = bufsubstr (); % the name } else { go_right (ffind (" ->")); skip_white (); push_mark_eol (); name = bufsubstr (); stat_buf = stat_file (name); if (stat_buf != NULL) { if (stat_is ("dir", stat_buf.st_mode)) type = 2; else if (stat_is ("reg", stat_buf.st_mode)) type = 1; } } #elifdef VMS if (type) { go_right (2); if ( ffind ( ".DIR" ) ) { type = 2; } else { skip_white (); if ( what_column () > 3 ) type = 0; } } !if ( type ) { bol (); return (Null_String, type); } dired_point (0); push_mark (); () = ffind_char (';'); skip_chars (";0-9"); name = bufsubstr (); % leave on the stack #elifdef IBMPC_SYSTEM if ( type ) { go_right (2); if ( ffind ("") ) { type = 2; } else { % Following used to just be what was in the #ifndef OS2..#endif. Prolly % can be changed to just whats in the #ifdef OS2..#endif. This is a fix % for OS/2 handling MDJ 06/11/95 # ifdef OS2 if ( eolp () or what_column () > 4 ) type = 0; # else if ( eolp () or what_column () > 3 ) type = 0; # endif } } !if ( type ) { bol (); return (Null_String, type); } # ifdef OS2 eol (); bskip_white (); push_mark (); () = bfind_char (' '); go_right_1 (); % Added to fix space at start of filename MDJ 06/11/95 name = bufsubstr (); # elifdef WIN32 dired_point (0); push_mark_eol (); name = bufsubstr (); # else dired_point (0); push_mark (); % extract the name skip_chars ("^ \n"); % skip past name name = bufsubstr (); % the name skip_white (); if ( what_column () <= 12 ) { push_mark (); skip_chars ("^ \n"); % skip past ext ext = bufsubstr (); if (strlen (ext) or (type != 2)) name = sprintf ("%s.%s", name, ext); } # endif #endif dired_point (0); return (name, type); } define dired_tag () { variable type; EXIT_BLOCK { dired_point (1); } (, type) = dired_getfile (); if ( type != 1 ) return; % only files! set_readonly (0); bol (); insert_char ('D'); del (); set_buffer_modified_flag (0); set_readonly (1); } define dired_untag (dirn) { if ( dirn < 0 ) { !if ( up_1 () ) error ("Top of Buffer."); } bol (); if ( looking_at_char ('D') ) { set_readonly (0); insert_char (32); del (); set_buffer_modified_flag (0); set_readonly (1); } if ( dirn > 0 ) dired_point (1); } % perform operation on tagged files--- 4 parameters define dired_xop_tagged_files (prompt, msg, op_function) { variable lbuf = " *Deletions*"; variable stack, n, fails = Null_String; variable file; setbuf (Dired_Buffer); push_spot_bob (); stack = _stkdepth; % save stack depth ERROR_BLOCK { _pop_n ( _stkdepth - stack ); sw2buf (Dired_Buffer); set_readonly (0); bob (); while ( bol_fsearch_char ('%') ) { insert_char ('D'); del (); } pop_spot (); set_buffer_modified_flag (0); set_readonly (1); } set_readonly (0); while ( bol_fsearch_char ('D') ) { insert_char ('%'); del (); dired_getfile (); pop (); % pop type, leave name on stack } n = _stkdepth - stack; !if (n) error ("No tags!"); sw2buf (lbuf); erase_buffer (); loop (n) { insert (); % tagged files on stack newline (); } bob (); buffer_format_in_columns (); if ( get_yes_no (prompt) == 1) { sw2buf (Dired_Buffer); bob (); while ( bol_fsearch_char ('%') ) { (file,) = dired_getfile (); bol (); push_spot (); file = dircat (Dired_Current_Directory, file); if (@op_function (file) ) { pop_spot (); flush (msg + file); push_mark (); go_down_1 (); del_region (); go_left_1 (); } else { pop_spot (); fails += " " + file; insert_char (32); del (); } } } EXECUTE_ERROR_BLOCK; if ( strlen (fails) ) message ("Operation Failed:" + fails); } define dired_delete () { dired_xop_tagged_files ("Delete these files", "Deleted ", &delete_file); } variable Dired_Move_Target_Dir; define dired_do_move (file) { variable name; (name,) = dired_getfile (); name = dircat (Dired_Move_Target_Dir, name); not (rename_file (file, name)); } define dired_move () { Dired_Move_Target_Dir = read_file_from_mini ("Move to dir"); if ( file_status (Dired_Move_Target_Dir) != 2 ) error ("Expecting directory name"); "Move these to " + Dired_Move_Target_Dir; dired_xop_tagged_files ((), "Moved ", &dired_do_move); } #ifndef VMS define dired_flag_backup () { variable name, type; push_spot_bob (); set_readonly (0); while ( fsearch_char ( '~' ) ) { (name, type) = dired_getfile (); if ( (type == 1) and (string_match (name, "~", strlen(name))) ) { bol (); insert_char ('D'); del (); % is a backup file } eol (); } pop_spot (); set_buffer_modified_flag (0); set_readonly (1); } #endif define dired_rename () { variable oldf, type, len, f, n, nf, nd, od, status; (oldf, type) = dired_getfile (); !if ( type ) return; sprintf ("Rename %s to", oldf); n = read_file_from_mini (()); % % If new name is a dir, move it to the dir with oldname. % If file is not a directory and exists, signal error. % status = file_status (n); if ( status == 1 ) error ("File exists. Not renamed."); else if ( status == 2 ) n = dircat (n, oldf); % % Check to see if rename to new directory % (nd,nf) = parse_filename (n); f = dircat (Dired_Current_Directory, oldf); (od,) = parse_filename (f); if ( rename_file (f, n) ) error ("Operation Failed!"); set_readonly (0); #ifdef UNIX if ( strcmp (od, nd) ) #elifdef VMS IBMPC_SYSTEM if ( strcmp (strup (od), strup (nd)) ) #endif { delete_line (); } else { dired_point (0); push_mark (); #ifdef MSDOS MSWINDOWS go_right (12); del_region (); variable nf1 = extract_element (nf, 1, '.'); if (nf1 == NULL) nf1 = ""; vinsert ("%-8s %-3s", extract_element (nf, 0, '.'), nf1); #else go_right (strlen (oldf)); del_region (); insert (nf); #endif } dired_point (1); set_buffer_modified_flag (0); set_readonly (1); } %!%+ %\function{dired} %\synopsis{dired} %\description % Mode designed for maintaining and editing a directory. % % To invoke Dired, do \var{M-x dired} or \var{C-x d} (emacs) % % Dired will prompt for a directory name and get a listing of files in the % requested directory. % % The primary use of Dired is to "flag" files for deletion and then delete % the previously flagged files. % % \var{d} Flag this file for deletion. % \var{u} Remove deletion flag on this line. % DEL Move point to previous line and remove deletion flag. % \var{~} Flag all backup files for deletion. % % \var{x} eXpunge all flagged files. Dired will show a list of the % files tagged for deletion and ask for confirmation before actually % deleting the files. % % \var{r} Rename file on the current line; prompts for a newname % \var{m} Move tagged files to a new dir; prompts for dir name % % \var{g} Update the entire contents of the Dired buffer % % \var{f} Visit the file described on the current line, like typing % \var{M-x find_file} and supplying that file name. If current line is a % directory, runs dired on the directory and the old buffer is killed. % % \var{v} View the file described on the current line in MOST mode. % % \var{q} Quit dired mode. % % \var{M-x dired_search} % use fsearch to perform a search through the files listed in the % dired buffer from the current point forward. \var{M-x dired_search} % from the visited file will revert to the dired buffer and continue % the search from the next file in the list. % % all the usual motion commands plus some extras: % % \var{C-n} \var{n} SPC % move point to the next line (at the beginning of the file name) % % \var{C-p} \var{p} % move point to the previous line (at the beginning of the file name) % % \var{M-x dired_kill_line} \var{^K} (emacs) % removes a line from the dired buffer %!%- define dired () { dired_read_dir (read_file_from_mini ("Directory:")); dired_quick_help (); run_mode_hooks ("dired_hook"); } define dired_find () { variable name, type; (name, type) = dired_getfile (); name = dircat (Dired_Current_Directory, name); if ( type == 1 ) { !if ( read_file (name) ) error ("Unable to read file."); pop2buf (whatbuf ()); } else if ( type == 2 ) { dired_read_dir (name); } } define dired_view () { variable name, type; (name, type) = dired_getfile (); name = dircat (Dired_Current_Directory, name); if ( type == 1 ) { !if ( read_file (name) ) error ("Unable to read file."); pop2buf (whatbuf ()); most_mode (); } } #ifndef VMS define dired_search_files () { go_right_1 (); % start after this one if ( fsearch (LAST_SEARCH) ) return (1); % found - stop search if ( buffer_modified () ) error ("buffer has been modified"); delbuf (whatbuf ()); pop2buf (Dired_Buffer); return 0; } define dired_search () { variable str, name, type; !if ( bufferp (Dired_Buffer) ) error ( "*dired* not available."); if ( strcmp (Dired_Buffer, whatbuf () ) ) % continue last search { !if ( strlen (LAST_SEARCH) ) error ("No specified search string"); if ( dired_search_files () ) return; go_down_1 (); % do the next file! } else { str = read_mini ("dired_search:", Null_String, LAST_SEARCH); !if ( strlen (str) ) error ("Specify search string"); save_search_string (str); } do { (name, type) = dired_getfile (); if ( type == 1 ) % only search files { name = dircat (Dired_Current_Directory, name); !if ( read_file (name) ) error ("Unable to read file."); if ( dired_search_files () ) { pop2buf (whatbuf ()); return; } } } while ( down_1 () ); } #endif jed-0.99-19/lib/php.sl0000644002657400265740000015606511311317447013404 0ustar davisdavis% file : php.sl % author : Mikael hultgren % version : 1.4-1 % % $Id: php.sl,v 1.190 2001/10/03 13:27:08 child Exp $ % % D e s c r i p t i o n % --------------------- % % This is a mode for editing php files in jed, hence the name phpmode :) % % The reason for this mode is that the only mode i % could find for editing php files under jed was one % i found on dotfiles made by Eric Thelin. % But it didn't work as i wanted, so i grabbed what i % could from it, and started from cmode as a template. % % At the moment it does keyword highlighting and proper % indenting, plus a slew of other functionality. % % ------------------------------------------------------------------------------------------- % PHP-mode variables: % ------------------------------------------------------------------------------------------- % variable PHP_INDENT = 4; % Amount of space to indent within block. % variable PHP_BRACE = 0; % Amount of space to indent brace % variable PHP_BRA_NEWLINE = 0; % If non-zero, insert a newline first before inserting % % a '{'. % variable PHP_CONTINUED_OFFSET = 2; % This variable controls the indentation of statements % % that are continued onto the next line. % variable PHP_Colon_Offset = 1; % Controls the indentation of case inside switch statements. % variable PHP_Class_Offset = 4; % Controls the amount of indenting inside the class, % % doesn't apply to the braces % variable PHP_Switch_Offset = 0 % Controls the ammount of extra indention inside switch statements. % variable PHP_KET_NEWLINE = 0; % If non-zero, insert a newline first before inserting % % a '}'. % variable PHP_Autoinsert_Comments = 1; % -------------------------------------------------------------------------------------------- % % T h a n k s g o o u t t o % ---------------------------- % % o Eric thelin for his phpmode that got me started. % o David who pointed out that php isn't in fact a % case sensitive language when it comes to % functions ;) % o Abraham vd Merwe for his relentless bug-reporting, % feature suggestions and beta-tester. % Without him my to-do list would be % considerable shorter ;) % o cmode.sl in jed, without that this mode wouldn't be % nearly as feature rich as it is now. % o latex.sl for tips on how to do things. % % Set all variables to a default value so people who forget to add % them to their .jedrc doesnt get a error. % custom_variable( "PHP_INDENT", 4 ); custom_variable( "PHP_BRACE", 0 ); custom_variable( "PHP_BRA_NEWLINE", 0 ); custom_variable( "PHP_CONTINUED_OFFSET", 2 ); custom_variable( "PHP_Colon_Offset", 1 ); custom_variable( "PHP_Class_Offset", 4 ); custom_variable( "PHP_Switch_Offset", 0 ); custom_variable( "PHP_KET_NEWLINE", 0 ); custom_variable( "PHP_Autoinsert_Comments", 0 ); private define php_is_comment( ) %{{{ { push_spot( ); bol_skip_white( ); 0; if( looking_at( "//" ) or looking_at( "#" )) { pop( ); what_column( ); } pop_spot( ); } %}}} private define php_parse_to_point( ) %{{{ { parse_to_point( ) or php_is_comment( ); } %}}} private variable PHPmode_Fill_Chars = ""; define php_paragraph_sep( ) %{{{ { if( strlen( PHPmode_Fill_Chars )) return 0; push_spot( ); bol_skip_white( ); if( looking_at( "* " ) or looking_at( "// " ) or looking_at( "# " )) { go_right( 2 ); skip_white( ); if( looking_at( "@ " )) eol( ); } eolp( ) or ( -2 != parse_to_point( ) ); pop_spot( ); } %}}} define php_format_paragraph( ) %{{{ { variable n, dwrap; PHPmode_Fill_Chars = ""; if( php_paragraph_sep( ) ) return; push_spot( ); push_spot( ); push_spot( ); while( not( php_paragraph_sep( ) )) { !if( up_1( ) ) break; } if( php_paragraph_sep( ) ) go_down_1( ); push_mark( ); pop_spot( ); while( not( php_paragraph_sep( ) )) { !if( down_1( ) ) break; } if( php_paragraph_sep( ) ) go_up_1( ); narrow( ); pop_spot( ); bol( ); push_mark( ); skip_white( ); if( looking_at( "* " )) go_right( 2 ); else if( looking_at( "// " )) go_right( 3 ); else if( looking_at( "# " )) go_right( 2 ); PHPmode_Fill_Chars = bufsubstr( ); dwrap = what_column( ); bob( ); do { bol_trim( ); if( looking_at( "* " )) deln( 2 ); else if( looking_at( "// " )) deln( 3 ); else if( looking_at( "# " )) deln( 2 ); } while( down_1( ) ); WRAP -= dwrap; call( "format_paragraph" ); WRAP += dwrap; bob( ); do { insert( PHPmode_Fill_Chars ); } while( down_1( ) ); bol( ); go_right( strlen( PHPmode_Fill_Chars )); skip_white( ); if( looking_at( "*/" )) { push_mark( ); bol_skip_white( ); del_region( ); } PHPmode_Fill_Chars = ""; widen( ); pop_spot( ); } %}}} define php_in_block( ) %{{{ { variable begin = 0, end = 0; variable delim_start = ""; variable delim_ASP_start = "<%"; variable delim_ASP_end = "%>"; variable test; push_spot( ); if( bolp( ) ) { if( looking_at( delim_start ) or looking_at( delim_end ) or looking_at( delim_ASP_start ) or looking_at( delim_ASP_end )) { pop_spot( ); return( 1 ); } } if( looking_at( ">" )) { go_left( 1 ); if( looking_at( "?" ) or looking_at( "%" )) { pop_spot( ); return( 1 ); } } forever { if( bsearch( delim_start ) or bsearch( delim_ASP_start )) { if( php_parse_to_point( ) == 0 ) { begin = what_line( ); break; } continue; } else { break; } } pop_spot( ); push_spot( ); forever { if( bsearch( delim_end ) or bsearch( delim_ASP_end )) { if( php_parse_to_point( ) == 0 ) { end = what_line( ); break; } continue; } else { break; } } pop_spot( ); if( end < begin ) { return( 1 ); } return( 0 ); } %}}} define php_top_of_function( ) %{{{ { push_spot( ); variable current,end,start_brace; current = what_line; !if( re_bsearch( "function[ \t]+[a-zA-Z_0-9]+[ \t]?\(.*\)") ) { error( "Cant find top of function" ); } % Check to see if were in a comment if( php_parse_to_point( ) ) { pop_spot( ); error( "Cant find top of function" ); } !if( fsearch( "{") ) { error( "Missing beginning brace of function." ); } start_brace = what_line; if( start_brace > current ) { pop_spot( ); error( "Missing beginning brace of function." ); } find_matching_delimiter( '{' ); end = what_line; if( end < current ) { pop_spot( ); error( "Not in function" ); } find_matching_delimiter( '}' ); } %}}} define php_end_of_function( ) %{{{ { !if( bolp( ) and looking_at_char( '{' )) php_top_of_function( ); call( "goto_match" ); } %}}} define php_mark_function( ) %{{{ { php_end_of_function( ); push_visible_mark( ); eol( ); exchange_point_and_mark( ); php_top_of_function( ); bol_skip_white( ); if( looking_at( "{") ) { go_up( 1 ); } bol( ); } %}}} define php_mark_matching( ) %{{{ { push_spot( ); if( find_matching_delimiter( 0 )) { % Found one pop_spot( ); push_visible_mark( ); find_matching_delimiter( 0 ); exchange_point_and_mark( ); } else { pop_spot( ); } } %}}} define php_bskip_over_comment( ) %{{{ { forever { bskip_chars (" \t\n"); if( bobp( ) ) return; push_mark( ); while( up_1( ) ) { go_down_1( ); break; } bol_skip_white( ); if( looking_at( "" ) or looking_at( "<%" ) or looking_at( "%>" )) { pop_mark_0( ); continue; } pop_mark_1( ); !if( blooking_at( "*/" )) { push_mark( ); variable found = 0; forever { if( bfind( "//" ) or bfind( "#" )) { found = 1; } else { break; } } if( 0 == parse_to_point( ) and found != 0 ) { % Not in a comment or string pop_mark_0( ); continue; } bol( ); !if( bobp( ) ) { if( looking_at( "" ) or looking_at( "<%" ) or looking_at( "%>" )) { pop_mark_0( ); continue; } } pop_mark_1( ); break; } !if( bsearch( "/*" )) break; } } %}}} private define php_looking_at( token ) %{{{ { variable cse = CASE_SEARCH, ret = 0; CASE_SEARCH = 1; if( looking_at( token )) { push_spot( ); go_right( strlen( token )); _get_point( ); skip_chars( "\t :({" ); ret = ( _get_point( ) - ( )) or eolp( ); pop_spot( ); } CASE_SEARCH = cse; ret; } %}}} private define php_indent_to( n ) %{{{ { bol( ); % Force a reindent if the line does not contain tabs followed by spaces. skip_chars( "\t" ); skip_chars( " " ); if( ( what_column != n ) or ( _get_point( ) != ( skip_white( ), _get_point( )))) { bol_trim( ); n--; whitespace( n ); } } %}}} private define php_indent_continued_comment( col ) %{{{ { push_spot( ); col++; % add 1 so the we indent under * in /* php_indent_to( col ); if( looking_at( "*" ) or not( eolp( ) )) pop_spot( ); else { insert( "* " ); pop_spot( ); if( what_column( ) <= col ) { goto_column( col + 2 ); } } } %}}} private define php_mode_if_bol_skip_white( ) %{{{ { push_mark( ); bskip_white( ); 1; if( bolp( ) ) { pop( ); skip_white( ); 0; } pop_mark( ( ) ); % take argument from stack } %}}} %#iftrue % Return true if the spot is inside of a class definition % Takes the opening brace of the enclosing block as an % argument. private define inside_class( bra ) %{{{ { push_spot( ); EXIT_BLOCK { pop_spot( ); } goto_user_mark( bra ); % Assume that class is at the beginning of a line. We may want to % change this assumption later. while( re_bsearch( "^\\c[ \t]*\\" )) { if( 0 == parse_to_point( ) ) { while( fsearch( "{" )) { if( 0 != parse_to_point( ) ) { go_right_1( ); continue; } if ( bra == create_user_mark( ) ) return 1; break; } return 0; } !if( left( 1 )) break; } return 0; } %}}} %#endif define php_indent_line( ) %{{{ { variable val, col, extra_indent = 0; variable prep_line = 0; variable match_char, match_indent, this_char, match_line; variable match_mark; variable is_continuation = 0; % Check whetever we are in a php block or not if( php_in_block( ) ) { push_spot( ); bol_skip_white( ); % Store the character we are standing on this_char = what_char( ); if( -2 == parse_to_point( ) ) { % In a c comment. Indent it at level of matching /* string ( ) = bsearch( "/*" ); col = what_column( ); pop_spot( ); php_indent_continued_comment( col ); php_mode_if_bol_skip_white( ); return; } EXIT_BLOCK { php_mode_if_bol_skip_white( ); } if( orelse { php_looking_at( "case" ) } { php_looking_at( "default" ) } ) { if( ffind_char( ':' )) { extra_indent -= PHP_INDENT; extra_indent += PHP_Colon_Offset; %message(string(extra_indent)); } bol( ); } else { forever { php_bskip_over_comment( ); !if( orelse { blooking_at( ";" ) } { blooking_at( "{" ) } { blooking_at( "}" ) } { blooking_at( ")," ) } { blooking_at( "}," ) } { blooking_at( ":" ) } { bobp( ) } ) { % This needs to be here to make sure were still in the phpblock if( php_in_block( ) ) { % message("hej2"); if( is_continuation ) { % message("hej"); extra_indent += PHP_CONTINUED_OFFSET; } else { % message("hej3"); push_spot( ); bol_skip_white( ); % fsearch( "{" ); % !if( blooking_at( ")" ) extra_indent += PHP_CONTINUED_OFFSET; pop_spot( ); } % extra_indent += PHP_CONTINUED_OFFSET; is_continuation++; % is_continuation++; } } !if( blooking_at( ")" )) break; push_mark( ); go_left_1( ); if( 1 != find_matching_delimiter( ')' )) { pop_mark_1( ); break; } php_bskip_over_comment( ); push_spot( ); if( ( 1 == find_matching_delimiter( ')' )), pop_spot( ) ) { pop_mark_1( ); break; } pop_mark_0( ); bol ( ); } } val = find_matching_delimiter( ')' ); match_mark = create_user_mark( ); match_char = what_char( ); match_line = what_line( ); if( ( val < 0 ) and looking_at( "/*" )) val = -2; else if( val == 1 ) { go_right( 1 ); skip_white( ); } col = what_column( ); bol_skip_white( ); match_indent = what_column( ); if( what_line( ) < prep_line ) { match_char = 0; } pop_spot( ); switch( val ) { case 0: % mismatch if( match_char == '{' ) { push_spot( ); goto_user_mark( match_mark ); bskip_chars( "\n\t " ); if( blooking_at( ")" )) { variable same_line = ( what_line == match_line ); go_left_1( ); if( 1 == find_matching_delimiter( ')' )) { bol_skip_white( ); if( same_line ) match_indent = what_column( ); % NOTE: This needs work. if( ( this_char != '}' ) and looking_at( "switch" )) match_indent += PHP_Switch_Offset; } } pop_spot( ); col = match_indent; #ifexists PHP_Class_Offset if( this_char == '}' ) col += PHP_INDENT; else if( inside_class( match_mark )) col += PHP_Class_Offset; else col += PHP_INDENT; #else col += PHP_INDENT; #endif } else if( match_char == '[' ) { push_spot( ); php_indent_to( col + 1 ); pop_spot( ); return; } else { push_spot( ); bol_skip_white( ); if( looking_at_char( '{' )) extra_indent = PHP_BRACE; extra_indent++; php_indent_to( extra_indent ); pop_spot( ); return; } } { case 1: extra_indent = 0; % match found } { case -2: % inside comment if( this_char != '\\' ) col++; php_indent_continued_comment( col ); return; } { case 2: push_spot_bol( ); trim( ); pop_spot( ); return; } switch( this_char ) { case '}': col -= PHP_INDENT; } { case '{': col += PHP_BRACE; if( is_continuation ) col -= PHP_CONTINUED_OFFSET; col += extra_indent; } { col += extra_indent; } push_spot( ); php_indent_to( col ); pop_spot( ); } } %}}} define php_indent_region_or_line( ) %{{{ { !if( is_visible_mark ) { if( php_in_block( ) ) php_indent_line( ); else insert( "\t" ); } else { variable now,start,stop; check_region( 1 ); stop = what_line( ); pop_mark_1( ); start = what_line( ); push_mark( ); forever { now = what_line( ); if( now >= stop ) break; php_indent_line( ); down_1( ); } pop_spot( ); } } %}}} define php_indent_buffer( ) %{{{ { variable col, max_line; push_spot( ); eob( ); max_line = what_line( ); bob( ); do { bol_skip_white( ); indent_line( ); } while( down_1( ) ); trim_buffer( ); flush( sprintf( "processed %d/%d lines.", what_line( ), max_line )); pop_spot( ); } %}}} define php_newline_and_indent( ) %{{{ { variable PhpCcComment = "//"; variable PhpBashComment = "#"; if( bolp ( ) ) { newline( ); php_indent_line( ); return; } variable col; variable PhpCcComment_len = strlen( PhpCcComment ); variable PhpBashComment_len = strlen( PhpBashComment ); if( PHP_Autoinsert_Comments ) { col = what_column( ); push_spot_bol( ); if( looking_at( PhpCcComment )) { push_mark( ); go_right( PhpCcComment_len ); skip_white( ); PhpCcComment = bufsubstr( ); pop_spot( ); newline( ); if( col > PhpCcComment_len ) insert( PhpCcComment ); return; } else if( looking_at( PhpBashComment )) { push_mark( ); go_right( PhpBashComment_len ); skip_white( ); PhpBashComment = bufsubstr( ); pop_spot( ); newline( ); if( col > PhpBashComment_len ) insert( PhpBashComment ); return; } pop_spot( ); } col = php_is_comment( ); newline( ); if( col ) { php_indent_to( col ); insert( "" ); } else php_indent_line( ); } %}}} define php_insert_bra( ) %{{{ { if( php_parse_to_point( ) ) insert_char( '{' ); else { push_spot( ); php_bskip_over_comment( 0 ); if( blooking_at( "," ), pop_spot( ) ) { insert_char( '{' ); } else { push_spot( ); skip_white( ); if( eolp( ) ) { bskip_white( ); if( not( bolp( ) ) and PHP_BRA_NEWLINE, pop_spot( ) ) newline( ); push_spot( ); bskip_white( ); bolp( ); % on stack pop_spot( ); insert_char( '{' ); if( ( ) ) php_indent_line( ); % off stack eol( ); if( PHP_BRA_NEWLINE ) php_newline_and_indent( ); } else { pop_spot( ); insert_char( '{' ); } } } } %}}} define php_insert_ket( ) %{{{ { variable status = php_parse_to_point( ); variable line = what_line( ); push_spot( ); skip_white( ); push_spot( ); if( status or not( eolp( ) ) or( 1 == find_matching_delimiter( '}' )) and( line == what_line( ) )) %or (bol_skip_white ( ), looking_at_char ('{')), pop_spot ( )) { pop_spot( ); pop_spot( ); if( PHP_KET_NEWLINE ) { insert( "\n}" ); php_indent_line( ); } else insert( "}" ); blink_match( ); return; } pop_spot( ); bskip_white( ); if( bolp( ), pop_spot( ) ) { insert_char( '}' ); trim( ); } else { eol( ); if( PHP_KET_NEWLINE ) insert( "\n}" ); else insert( "}" ); } php_indent_line( ); eol( ); blink_match( ); if( PHP_BRA_NEWLINE ) php_newline_and_indent( ); } %}}} define php_insert_colon( ) %{{{ { insert_char( ':' ); !if( php_parse_to_point( ) ) php_indent_line( ); } %}}} define php_getname( tellstring ) %{{{ { variable gname = read_mini( tellstring, Null_String, Null_String ); return gname; } %}}} define php_ins_tn( str ) %{{{ { insert( str ); php_indent_line( ); insert( "\n" ); } %}}} define php_insert_function( ) %{{{ { variable name = php_getname( "function:" ); php_ins_tn( sprintf( "function %s ( )", name )); php_ins_tn( "{" ); php_ins_tn( "" ); php_ins_tn( "}" ); bsearch( ")" ); } %}}} define php_insert_class( ) %{{{ { variable name = php_getname( "class:" ); php_ins_tn(sprintf( "class %s", name )); php_ins_tn( "{" ); php_ins_tn( "" ); php_ins_tn( "}" ); } %}}} define php_insert_tab( ) %{{{ { insert( "\t" ); } %}}} private define php_init_menu( menu ) %{{{ { menu_append_item( menu, "&Top of function", "php_top_of_function" ); menu_append_item( menu, "&End of function", "php_end_of_function" ); menu_append_item( menu, "&Mark function", "php_mark_function" ); menu_append_item( menu, "&Mark matching", "php_mark_matching" ); menu_append_separator( menu ); menu_append_item( menu, "&Indent buffer", "php_indent_buffer" ); menu_append_separator( menu ); menu_append_item( menu, "&Insert class", "php_insert_class" ); menu_append_item( menu, "&Insert function", "php_insert_function" ); menu_append_item( menu, "&Insert brace", "php_insert_bra" ); menu_append_item( menu, "&Insert ket", "php_insert_ket" ); menu_append_item( menu, "&Insert colon", "php_insert_colon" ); menu_append_separator( menu ); menu_append_item( menu, "&Format paragraph", "php_format_paragraph" ); menu_append_item( menu, "&Goto Match", "goto_match" ); menu_append_item( menu, "&Insert TAB", "php_insert_tab" ); } %}}} $1 = "PHP"; !if( keymap_p( $1 )) make_keymap( $1 ); %{{{ definekey( "indent_line", "\t", $1 ); definekey( "php_top_of_function", "\e^A", $1 ); definekey( "php_end_of_function", "\e^E", $1 ); definekey( "php_mark_function", "\e^H", $1 ); definekey( "php_mark_matching", "\e^M", $1 ); definekey( "php_insert_bra", "{", $1 ); definekey( "php_insert_ket", "}", $1 ); definekey( "php_insert_colon", ":", $1 ); definekey( "php_format_paragraph", "\eq", $1 ); definekey( "php_newline_and_indent", "\r", $1 ); definekey_reserved( "php_indent_region", "^R", $1 ); definekey_reserved( "php_indent_buffer", "^B", $1 ); definekey_reserved( "php_insert_class", "^C", $1 ); definekey_reserved( "php_insert_function", "^F", $1 ); definekey_reserved( "php_insert_tab","^I", $1 ); %}}} % Now create and initialize the syntax tables. %{{{ create_syntax_table( $1 ); define_syntax( "/*", "*/", '%', $1 ); % comments define_syntax( "#", "", '%', $1 ); % comments define_syntax( "//", "", '%', $1 ); % comments %define_syntax ("<>", '<', $1); define_syntax( "([{", ")]}", '(', $1 ); % parentheses define_syntax( '"', '"', $1 ); % strings define_syntax( '\'', '\'', $1 ); % strings define_syntax( '\\', '\\', $1 ); % escape character define_syntax( "0-9a-zA-Z_", 'w', $1 ); % words define_syntax( "-+0-9a-fA-F.xXL", '0', $1 ); % numbers define_syntax( ",;.:", ',', $1 ); % delimiters define_syntax( "+-*/%=.&|^~<>!?@`", '+', $1 ); % operators set_syntax_flags( $1, 0x05 ); %}}} #ifdef HAS_DFA_SYNTAX %{{{ %%% DFA_CACHE_BEGIN %%% private define setup_dfa_callback( name ) { dfa_enable_highlight_cache( "php.dfa", name ); dfa_define_highlight_rule( "<%", "Qpreprocess", name ); % Asp style start tag dfa_define_highlight_rule( "%>", "Qpreprocess", name ); % Asp style end tag dfa_define_highlight_rule( "<\\?|<\\?php", "preprocess", name ); % Php style start tag dfa_define_highlight_rule( "\\?>", "Qpreprocess", name ); % Php style end tag dfa_define_highlight_rule ("", "Qcomment", name); % HTML comments dfa_define_highlight_rule ("", "comment", name); % HTML comments dfa_define_highlight_rule( "//.*", "comment", name ); % C++ style comment dfa_define_highlight_rule( "#.*", "comment", name ); % Shell style comment dfa_define_highlight_rule( "/\\*.*\\*/", "Qcomment", name ); % C style comment dfa_define_highlight_rule( "^([^/]|/[^\\*])*\\*/", "Qcomment", name ); % C style comment dfa_define_highlight_rule( "/\\*.*", "comment", name ); % C style comment dfa_define_highlight_rule( "^[ \t]*\\*+([ \t].*)?$", "comment", name ); % C style comment dfa_define_highlight_rule( "[A-Za-z_\\$][A-Za-z_0-9\\$]*", "Knormal", name ); dfa_define_highlight_rule( "[ \t]+", "normal", name ); dfa_define_highlight_rule( "[0-9]+(\\.[0-9][LlUu]*)?([Ee][\\+\\-]?[0-9]*)?","number", name ); dfa_define_highlight_rule( "0[xX][0-9A-Fa-f]*[LlUu]*", "number", name ); dfa_define_highlight_rule( "[\\(\\[{}\\]\\),;\\.:]", "delimiter", name ); dfa_define_highlight_rule( "[%@\\?\\.\\-\\+/&\\*=<>\\|!~\\^]", "operator", name ); dfa_define_highlight_rule( "\"([^\"\\\\]|\\\\.)*\"", "string", name ); dfa_define_highlight_rule( "\"([^\"\\\\]|\\\\.)*\\\\?$", "string", name ); dfa_define_highlight_rule( "'([^'\\\\]|\\\\.)*'", "string", name ); dfa_define_highlight_rule( "'([^'\\\\]|\\\\.)*\\\\?$", "string", name ); dfa_build_highlight_table( name ); } dfa_set_init_callback( &setup_dfa_callback, $1 ); %%% DFA_CACHE_END %%% #endif %}}} % Type 0 keywords (keywords and constants) %{{{ () = define_keywords_n ($1, "asdoifor", 2,0); () = define_keywords_n ($1, "andfornewvarxor", 3,0); () = define_keywords_n ($1, "argcargvcaseelsetrue", 4,0); () = define_keywords_n ($1, "breakclassfalsewhile", 5,0); () = define_keywords_n ($1, "elseifglobalphp_osswitch", 6,0); () = define_keywords_n ($1, strcat( "defaulte_errore_parseextendsforeach", "globals" ), 7,0); () = define_keywords_n ($1, strcat( "continuee_notice__file__function", "__line__php_self" ),8,0); () = define_keywords_n ($1, "e_warning", 9,0); () = define_keywords_n ($1, "php_version", 11,0); () = define_keywords_n ($1, "php_errormsg", 12,0); () = define_keywords_n ($1, "http_get_vars", 13,0); () = define_keywords_n ($1, "http_post_vars", 14,0); () = define_keywords_n ($1, "http_cookie_vars", 16,0); %}}} % Type 1 keywords (functions) %{{{ () = define_keywords_n ($1, "dlpi", 2,1); () = define_keywords_n ($1, strcat( "abschrcosdieendexpkeylogmaxmd5minordpos", "powsintan" ),3,1); () = define_keywords_n ($1, strcat( "acosasinatanbindceilchopcopydateeach", "echoeregevalexecexitfeoffilejoinleaklink", "listmailmsqlnextpackprevrandreadsortsqrt", "stattimetrim" ),4,1); () = define_keywords_n ($1, strcat( "arrayasortatan2bcaddbcdivbcmodbcmul", "bcpowbcsubchdirchgrpchmodchownclosecount", "crc32cryptemptyeregifgetcfgetsflockfloor", "flushfopenfputsfreadfseekfstatftellgzeof", "hw_cphw_mviconvissetksortlog10lstatltrim", "mhashmkdirnl2brpopenprintrangeresetrmdir", "roundrsortrtrimsleepsplitsrandstrtrtouch", "umaskunsetusortwrite" ),5,1); () = define_keywords_n ($1, strcat( "arsortassertbccompbcsqrtbindecbzopen", "bzreadchrootdblistdecbindechexdecoctdefine", "deletefclosefflushfgetssfscanffwritegetcwd", "getenvgmdategmp_orgzfilegzgetcgzgetsgzopen", "gzputsgzreadgzseekgztellheaderhebrevhexdec", "hw_whoifx_dointvalis_diris_intkrsortlisten", "mktimeoctdecora_dopclosepg_ttyprintfputenv", "recoderenamerewindsizeofsocketsplitisscanf", "strchrstrcmpstrlenstrposstrrevstrspnstrstr", "strtokstrvalsubstrsyslogsystemuasortuksort", "uniqidunlinkunpackusleepxmldoc" ),6,1); () = define_keywords_n ($1, strcat( "bcscalebin2hexbzclosebzerrnobzerror", "bzflushbzwritecom_getcompactcom_setconnect", "currentdbmopendefineddeg2raddirnameexplode", "extractfgetcsvfileproftp_getftp_putftp_pwd", "getdategetmxrrgettextgettypegmp_absgmp_add", "gmp_andgmp_cmpgmp_divgmp_gcdgmp_modgmp_mul", "gmp_neggmp_powgmp_subgmp_xorgzclosegzgetss", "gzwritehebrevchw_infohw_rootimagesximagesy", "implodeincludeini_getini_setip2longis_bool", "is_fileis_linkis_longis_nullis_reallong2ip", "mt_randnatsortodbc_doopendiropenlogpdf_arc", "pdf_newpg_execpg_hostpg_portphpinfoprint_r", "rad2degreaddirrequiresem_getsettypeshuffle", "snmpgetsnmpsetsoundexsprintfstrcollstrcspn", "stristrstrncmpstr_padstrrchrstrrposswffill", "swffontswftextsymlinktempnamtmpfileucfirst", "ucwordsvirtualxmltreeyp_next" ),7,1); () = define_keywords_n ($1, strcat( "basenamebzerrstrclosedircloselog", "com_loadconstantcpdf_arcdba_opendba_sync", "dbmclosedbmfetchdbx_sortdgettextfdf_open", "fdf_savefilesizefiletypefloatvalftp_cdup", "ftp_fgetftp_fputftp_mdtmftp_pasvftp_quit", "ftp_siteftp_sizegetmypidgetmyuidgmmktime", "gmp_factgmp_initgmp_powmgmp_signgmp_sqrt", "gzencodegzrewindhw_closehw_errorhw_mapid", "imagearcimagegifimagepngimap_uidin_array", "ircg_msgis_arrayis_floatjdtounixldap_add", "linkinfomt_srandob_startocierrorocifetch", "ocilogonociparseora_bindora_execora_open", "passthrupathinfopdf_arcnpdf_clippdf_fill", "pdf_openpdf_rectpdf_savepdf_showpdf_skew", "pg_closepg_tracereadfilereadlinereadlink", "realpathsnmpwalkstrerrorstrftimeswfmorph", "swfmovieswfshapeudm_findunixtojdvar_dump", "wordwrapxslt_runyaz_hitsyaz_scanyaz_sort", "yaz_waityp_firstyp_matchyp_orderzip_open", "zip_read" ),8,1); () = define_keywords_n ($1, strcat( "array_maparray_padarray_poparray_sum", "checkdatecpdf_clipcpdf_fillcpdf_opencpdf_rect", "cpdf_savecpdf_showcpdf_textcurl_execcurl_init", "dba_closedba_fetchdba_popendbmdeletedbmexists", "dbminsertdbx_closedbx_errordbx_querydcgettext", "doublevalerror_logfdf_closefileatimefilectime", "filegroupfileinodefilemtimefileownerfileperms", "fpassthrufsockopenftp_chdirftp_loginftp_mkdir", "ftp_nlistftp_rmdirftruncatefunctionsget_class", "getrusagegmp_div_qgmp_div_rgmp_scan0gmp_scan1", "gzdeflategzinflatehw_insdochw_unlockicap_open", "ifx_closeifx_errorifx_queryimagecharimagecopy", "imagefillimagejpegimagelineimagewbmpimap_8bit", "imap_bodyimap_mailimap_openimap_pingimap_sort", "imap_utf8ini_alteriptcparseircg_joinircg_kick", "ircg_nickircg_partis_doubleis_objectis_scalar", "is_stringlcg_valueldap_bindldap_listldap_read", "localtimemb_strcutmb_strlenmb_strposmb_substr", "mcal_openmetaphonemicrotimeocicancelocicommit", "ocilogoffocinlogonociplogonociresultodbc_exec", "ora_closeora_errorora_fetchora_logonora_parse", "parse_strparse_urlpdf_closepdf_scalepg_dbname", "pg_loopenpg_loreadpg_resultphp_unamepreg_grep", "quotemetarewinddirserializesetcookiesetlocale", "strnatcmpstrtotimeswfactionswfbitmapswfbutton", "swf_orthoswf_scaleswfspriteudm_errnoudm_error", "urldecodeurlencodexml_parsexslt_freeyaz_close", "yaz_errnoyaz_erroryaz_rangeyp_masterzip_close" ),9,1); () = define_keywords_n ($1, strcat( "addslashesarray_diffarray_flip", "array_keysarray_pusharray_randarray_walk", "aspell_newbzcompresscheckdnsrrcom_addref", "com_invokecpdf_closecpdf_scalecurl_close", "dba_deletedba_existsdba_insertdbase_open", "dbase_packdbmnextkeydbmreplacedbplus_add", "dbplus_aqldbplus_sqldbplus_tclezmlm_hash", "fdf_createfdf_set_apfrenchtojdftp_delete", "ftp_renamegetlastmodgetmyinodegetrandmax", "gmp_clrbitgmp_div_qrgmp_gcdextgmp_intval", "gmp_invertgmp_jacobigmp_randomgmp_setbit", "gmp_sqrtrmgmp_strvalgmstrftimegzcompress", "gzpassthruhw_connecthw_gettexthw_inscoll", "icap_closeimagetypesimap_checkimap_close", "imap_msgnoircg_topicircg_whoisis_integer", "is_numericjdtofrenchjdtojewishjdtojulian", "jewishtojdjuliantojdldap_closeldap_errno", "ldap_errorlocaleconvmb_strrposmcal_close", "mcal_popenmcrypt_cbcmcrypt_cfbmcrypt_ecb", "mcrypt_ofbmsql_closemsql_errormsql_query", "ocicollmaxociexecuteociloadlobocinumcols", "ocisavelobodbc_closeodbc_errorora_commit", "ora_logoffora_plogonpdf_circlepdf_concat", "pdf_deletepdf_linetopdf_movetopdf_rotate", "pdf_strokepfpro_initpfsockopenpg_connect", "pg_loclosepg_lowritepg_numrowspg_options", "pg_untracephpcreditsphpversionposix_kill", "preg_matchpreg_quotepreg_splitpspell_new", "readgzfilesem_removesession_idshm_attach", "shm_detachshmop_openshmop_readshmop_size", "shm_removestrcasecmpstrip_tagsstr_repeat", "strtolowerstrtoupperswf_lookatswf_nextid", "swf_ortho2swf_rotatetextdomainuser_error", "xmldocfilexpath_evalxslt_errnoxslt_error", "yaz_recordyaz_searchyaz_syntax" ),10,1); () = define_keywords_n ($1, strcat( "addcslashesapache_notearray_merge", "array_shiftarray_slicechunk_splitcom_propget", "com_propputcom_propsetcom_releasecount_chars", "cpdf_circlecpdf_linetocpdf_movetocpdf_rotate", "cpdf_strokectype_alnumctype_alphactype_cntrl", "ctype_digitctype_graphctype_lowerctype_print", "ctype_punctctype_spacectype_uppercurl_setopt", "dba_nextkeydba_replacedbase_closedbmfirstkey", "dbplus_currdbplus_finddbplus_infodbplus_last", "dbplus_nextdbplus_opendbplus_prevdbplus_rzap", "dbplus_undodbx_comparedbx_connectdebugger_on", "domxml_rooteaster_dateeaster_daysfbsql_close", "fbsql_errnofbsql_errorfbsql_queryfdf_set_opt", "file_existsftp_connectftp_rawlistftp_systype", "get_browserget_cfg_vargmp_hamdisthw_children", "hw_edittexthw_errormsghw_identifyhw_pconnect", "ibase_closeibase_queryibase_transicap_snooze", "ifx_connectifx_prepareimagecharupimagecreate", "imagepsbboximagepstextimagestringimap_alerts", "imap_appendimap_base64imap_binaryimap_delete", "imap_errorsimap_headerimap_qprintimap_reopen", "imap_searchimap_statusini_get_allini_restore", "ircg_noticeis_readableis_resourceis_writable", "jddayofweekjdmonthnameldap_deleteldap_dn2ufn", "ldap_get_dnldap_modifyldap_renameldap_search", "ldap_unbindlevenshteinmb_languagemb_strwidth", "mcal_reopenmcal_snoozemhash_countmsql_dbname", "msql_dropdbmsql_resultmssql_closemssql_query", "mysql_closemysql_errnomysql_errormysql_query", "natcasesortocicollsizeocicolltrimocifreedesc", "ocirollbackocirowcountodbc_commitodbc_cursor", "odbc_resultodbc_tablesora_numcolsora_numrows", "pdf_curvetopdf_endpathpdf_restorepdf_setdash", "pdf_setflatpdf_setfontpdf_setgraypdf_show_xy", "pg_end_copypg_fieldnumpg_locreatepg_loexport", "pg_loimportpg_lounlinkpg_pconnectpg_put_line", "posix_timesposix_unamerecode_filesem_acquire", "sem_releasesesam_queryshm_get_varshmop_close", "shmop_writeshm_put_varshow_sourcesnmpwalkoid", "sql_regcasestrncasecmpstr_replaceswfgradient", "swf_setfontunserializeutf8_decodeutf8_encode", "xslt_createyaz_addinfoyaz_connectyaz_element", "yaz_present" ),11,1); () = define_keywords_n ($1, strcat( "array_filterarray_reducearray_search", "array_splicearray_uniquearray_valuesascii2ebcdic", "aspell_checkbase_convertbzdecompressclass_exists", "cpdf_curvetocpdf_newpathcpdf_restorecpdf_rlineto", "cpdf_rmovetocpdf_setdashcpdf_setflatcpdf_setgray", "cpdf_show_xyctype_xdigitcurl_versiondba_firstkey", "dba_optimizedbase_createdbplus_chdirdbplus_close", "dbplus_errnodbplus_firstdbplus_flushdbplus_rkeys", "dbplus_ropendebugger_offebcdic2asciiereg_replace", "fbsql_commitfbsql_resultfdf_get_filefdf_set_file", "func_get_arggetimagesizegettimeofdaygmp_divexact", "gmp_legendregmp_popcountgzuncompressheaders_sent", "htmlentitieshw_getobjecthw_getremoteibase_commit", "ibase_errmsgifx_errormsgifx_get_blobifx_get_char", "ifx_getsqlcaifx_num_rowsifx_pconnectimagecolorat", "imagedestroyimageellipseimagepolygonimagesettile", "imagettfbboximagettftextimap_expungeimap_headers", "imap_num_msginclude_onceingres_closeingres_query", "is_writeableldap_compareldap_connectldap_err2str", "ldap_mod_addldap_mod_delmb_parse_strmb_send_mail", "mcal_expungemsql_connectmsql_drop_dbmsql_listdbs", "msql_numrowsmsql_regcasemssql_resultmysql_result", "ob_end_cleanob_end_flushob_gzhandlerocifetchinto", "ocinewcursorodbc_binmodeodbc_columnsodbc_connect", "odbc_executeodbc_prepareold_functionopenssl_open", "openssl_sealopenssl_signora_commitonora_rollback", "ovrimos_execpdf_add_notepdf_end_pagepdf_findfont", "pdf_get_fontpdf_open_gifpdf_open_pdipdf_open_png", "pdf_setcolorpdf_set_fontpdf_set_infopg_cmdtuples", "pg_fetch_rowpg_fieldnamepg_fieldsizepg_fieldtype", "pg_loreadallpg_numfieldsposix_getcwdposix_getgid", "posix_getpidposix_getsidposix_getuidposix_isatty", "posix_mkfifoposix_setgidposix_setsidposix_setuid", "preg_replaceprinter_listprinter_openpspell_check", "rawurldecoderawurlencoderequire_oncesesam_commit", "session_nameshmop_deletesimilar_textstripslashes", "substr_countswf_addcolorswf_endshapeswf_fontsize", "swf_getframeswf_mulcolorswf_openfileswf_posround", "swf_setframeswf_shapearcswftextfieldswf_viewport", "sybase_closesybase_queryudm_cat_listudm_cat_path", "udm_free_resxslt_openlogxslt_processyaz_ccl_conf", "yaz_databasezend_version" ),12,1); () = define_keywords_n ($1, strcat( "array_reversearray_unshiftbase64_decode", "base64_encodecpdf_end_textcpdf_finalizecpdf_set_font", "dbplus_rquerydbplus_updatediskfreespaceeregi_replace", "fbsql_connectfbsql_drop_dbfbsql_stop_dbfdf_get_value", "fdf_set_flagsfdf_set_valuefunc_get_argsfunc_num_args", "getallheadersgethostbyaddrgethostbynameget_meta_tags", "getservbynamegetservbyportgregoriantojdhw_getanchors", "hw_getandlockhw_getparentsibase_connectibase_execute", "ibase_prepareibase_timefmtifx_copy_blobifx_fetch_row", "ifx_free_blobifx_free_charimagecolorsetimageloadfont", "imagesetbrushimagesetpixelimagesetstyleimagestringup", "imap_undeleteingres_commitircg_pconnectis_executable", "jdtogregorianmb_http_inputmb_strimwidthmethod_exists", "msql_createdbmsql_fieldlenmsql_list_dbsmsql_num_rows", "msql_pconnectmsql_selectdbmssql_connectmt_getrandmax", "mysql_connectmysql_db_namemysql_drop_dbnumber_format", "ob_get_lengthocibindbynameocicollassignocicolumnname", "ocicolumnsizeocicolumntypeocifreecursorodbc_errormsg", "odbc_num_rowsodbc_pconnectodbc_rollbackora_commitoff", "ora_errorcodeora_getcolumnovrimos_closepdf_closepath", "pdf_close_pdipdf_get_valuepdf_open_filepdf_open_jpeg", "pdf_open_tiffpdf_setmatrixpdf_set_valuepdf_translate", "pfpro_cleanuppfpro_processpfpro_versionpg_freeresult", "pg_getlastoidphp_logo_guidphp_sapi_nameposix_ctermid", "posix_getegidposix_geteuidposix_getpgidposix_getpgrp", "posix_getppidposix_setpgidposix_ttynameprinter_abort", "printer_closeprinter_writereadline_inforecode_string", "sesam_connectsesam_execimmsession_startsession_unset", "stripcslashesstrnatcasecmpswf_closefileswf_endbutton", "swf_endsymbolswf_fontslantswf_polarviewswf_popmatrix", "swf_showframeswf_textwidthswf_translatesybase_result", "trigger_errorwddx_add_varsxslt_closelogyaz_ccl_parse", "yaz_itemorder" ),13,1); () = define_keywords_n ($1, strcat( "accept_connectaspell_suggest", "assert_optionsbindtextdomaincall_user_func", "clearstatcachecpdf_closepathcpdf_page_init", "cpdf_set_titlecpdf_translatecybercash_decr", "cybercash_encrdbplus_errcodedbplus_getlock", "dbplus_lockreldbplus_rchpermdbplus_rcreate", "dbplus_resolvedbplus_rrenamedbplus_runlink", "dbplus_saveposdbplus_tremovedomxml_dumpmem", "escapeshellargescapeshellcmdfbsql_db_query", "fbsql_list_dbsfbsql_num_rowsfbsql_pconnect", "fbsql_rollbackfbsql_start_dbfbsql_warnings", "fdf_get_statusfdf_set_statusget_class_vars", "gethostbynamelgetprotobynamegmp_prob_prime", "highlight_filehw_childrenobjhw_docbyanchor", "hw_getusernameibase_pconnectibase_rollback", "ifx_fieldtypesifx_nullformatifx_num_fields", "imagecopymergeimagefilledarcimagefontwidth", "imageinterlaceimagerectangleimap_fetchbody", "imap_get_quotaimap_mail_copyimap_mail_move", "imap_set_quotaimap_subscribeingres_connect", "is_subclass_ofmb_http_outputmcrypt_decrypt", "mcrypt_encryptmcrypt_genericmsql_create_db", "msql_data_seekmsql_fetch_rowmsql_fieldname", "msql_fieldtypemsql_numfieldsmsql_select_db", "msql_tablenamemssql_num_rowsmssql_pconnect", "mysql_db_querymysql_list_dbsmysql_num_rows", "mysql_pconnectocicollgetelemocicolumnscale", "ocisavelobfileocisetprefetchodbc_close_all", "odbc_fetch_rowodbc_field_lenodbc_field_num", "odbc_setoptionopenssl_verifyora_columnname", "ora_columnsizeora_columntypeora_fetch_into", "ovrimos_commitovrimos_cursorovrimos_result", "pdf_begin_pagepdf_get_bufferpdf_open_ccitt", "pdf_open_imagepdf_setlinecappdf_show_boxed", "pg_fetch_arraypg_fieldisnullpg_fieldprtlen", "posix_getgrgidposix_getgrnamposix_getlogin", "posix_getpwnamposix_getpwuidpreg_match_all", "pspell_suggestread_exif_datasesam_errormsg", "sesam_rollbacksesam_seek_rowsession_decode", "session_encodeset_time_limitshm_remove_var", "substr_replaceswf_actionplayswf_actionstop", "swf_definefontswf_definelineswf_definepoly", "swf_definerectswf_definetextswfdisplayitem", "swf_labelframeswf_pushmatrixswf_startshape", "sybase_connectudm_free_agentxml_set_object", "xslt_transformzend_logo_guidzip_entry_name", "zip_entry_openzip_entry_read" ),14,1); () = define_keywords_n ($1, strcat( "array_intersectarray_multisort", "cpdf_begin_textcpdf_setlinecapcreate_function", "dbase_numfieldsdbplus_freelockdbplus_rcrtlike", "dbplus_setindexdbplus_unselectdbplus_xlockrel", "domxml_add_rootdomxml_childrenerror_reporting", "fbsql_create_dbfbsql_data_seekfbsql_db_status", "fbsql_fetch_rowfbsql_field_lenfbsql_insert_id", "fbsql_select_dbfbsql_tablenamefunction_exists", "get_object_varshw_array2objrechw_deleteobject", "hw_getchildcollhw_insertobjecthw_modifyobject", "hw_new_documenthw_objrec2arrayhw_pipedocument", "ibase_fetch_rowifx_create_blobifx_create_char", "ifx_free_resultifx_update_blobifx_update_char", "ifxus_free_slobifxus_open_slobifxus_read_slob", "ifxus_seek_slobifxus_tell_slobimagecolorexact", "imagedashedlineimagefontheightimagepsfreefont", "imagepsloadfontimap_headerinfoimap_last_error", "imap_num_recentingres_num_rowsingres_pconnect", "ingres_rollbackircg_disconnectircg_ignore_add", "ircg_ignore_delldap_explode_dnldap_get_option", "ldap_get_valuesldap_next_entryldap_set_option", "mb_convert_kanamb_detect_ordermcal_date_valid", "mcal_event_initmcal_time_validmsql_fieldflags", "msql_field_seekmsql_fieldtablemsql_freeresult", "msql_listfieldsmsql_listtablesmsql_num_fields", "mssql_data_seekmssql_fetch_rowmssql_select_db", "mysql_create_dbmysql_data_seekmysql_fetch_row", "mysql_field_lenmysql_insert_idmysql_select_db", "mysql_tablenameob_get_contentsocicolumnisnull", "ocidefinebynameodbc_autocommitodbc_fetch_into", "odbc_field_nameodbc_field_typeodbc_num_fields", "odbc_proceduresodbc_result_allodbc_statistics", "ovrimos_connectovrimos_executeovrimos_prepare", "pdf_add_outlinepdf_add_pdflinkpdf_add_weblink", "pdf_attach_filepdf_close_imagepdf_end_pattern", "pdf_fill_strokepdf_place_imagepdf_set_leading", "pdf_setlinejoinpdf_setpolydashpdf_setrgbcolor", "pdf_stringwidthpg_errormessagepg_fetch_object", "posix_getgroupsposix_getrlimitprinter_end_doc", "sesam_fetch_rowsession_destroyset_file_buffer", "swf_enddoactionswf_getfontinfoswf_oncondition", "swf_perspectiveswf_placeobjectswf_shapelineto", "swf_shapemovetoswf_startbuttonswf_startsymbol", "sybase_num_rowssybase_pconnectudm_alloc_agent", "udm_api_versionwddx_packet_endxml_parser_free", "yaz_scan_resultzip_entry_close" ),15,1); () = define_keywords_n ($1, strcat( "aspell_check_rawcall_user_method", "cpdf_add_outlinecpdf_fill_strokecpdf_import_jpeg", "cpdf_set_creatorcpdf_set_leadingcpdf_setlinejoin", "cpdf_setrgbcolorcpdf_set_subjectcpdf_stringwidth", "cybermut_testmacdbase_add_recorddbase_get_record", "dbase_numrecordsdbplus_getuniquedbplus_rcrtexact", "dbplus_rsecindexdbplus_unlockreldisk_total_space", "domxml_new_childextension_loadedfbsql_autocommit", "fbsql_field_namefbsql_field_seekfbsql_field_type", "fbsql_num_fieldsfdf_set_encodingfilepro_retrieve", "filepro_rowcountget_current_userget_defined_vars", "get_parent_classgetprotobynumberhighlight_string", "htmlspecialcharshw_document_sizehw_free_document", "hw_getanchorsobjhw_getparentsobjhw_incollections", "ibase_field_infoibase_free_queryibase_num_fields", "icap_fetch_eventicap_list_alarmsicap_list_events", "icap_store_eventifxus_close_slobifxus_write_slob", "imagecolorstotalimagecopyresizedimagepsslantfont", "imap_fetchheaderimap_listmailboximap_scanmailbox", "imap_unsubscribeimap_utf7_decodeimap_utf7_encode", "ingres_fetch_rowircg_html_encodeircg_set_current", "is_uploaded_fileldap_first_entryldap_free_result", "ldap_get_entriesldap_mod_replacemcal_day_of_week", "mcal_day_of_yearmcal_fetch_eventmcal_list_alarms", "mcal_list_eventsmcal_store_eventmcrypt_create_iv", "mdecrypt_genericmhash_keygen_s2kmsql_fetch_array", "msql_fetch_fieldmsql_free_resultmsql_list_fields", "msql_list_tablesmssql_field_namemssql_field_seek", "mssql_field_typemssql_num_fieldsmysql_field_name", "mysql_field_seekmysql_field_typemysql_num_fields", "ob_iconv_handlerocicolumntyperawocifreestatement", "ociinternaldebugocinewcollectionocinewdescriptor", "ociserverversionocistatementtypeodbc_field_scale", "odbc_foreignkeysodbc_free_resultodbc_gettypeinfo", "odbc_longreadlenodbc_primarykeysopenssl_free_key", "ovrimos_num_rowsovrimos_rollbackpdf_add_bookmark", "pdf_end_templatepdf_get_fontnamepdf_get_fontsize", "pdf_initgraphicspdf_set_durationpdf_setgray_fill", "pdf_setlinewidthpdf_set_text_posprinter_draw_bmp", "printer_draw_pieprinter_end_pagesesam_diagnostic", "sesam_disconnectsesam_field_namesesam_num_fields", "session_registerswf_actiongeturlswf_definebitmap", "swf_fonttrackingswf_modifyobjectswf_removeobject", "swf_shapecurvetoswf_shapefilloffsybase_data_seek", "sybase_fetch_rowsybase_select_dbwddx_deserialize", "xml_error_string" ),16,1); () = define_keywords_n ($1, strcat( "apache_lookup_uriconnection_status", "cpdf_save_to_filecpdf_setgray_fillcpdf_set_keywords", "cpdf_setlinewidthcpdf_set_text_posdbplus_freerlocks", "dbplus_restoreposdbplus_xunlockreldomxml_attributes", "domxml_new_xmldocfbsql_change_userfbsql_fetch_array", "fbsql_fetch_assocfbsql_fetch_fieldfbsql_field_flags", "fbsql_field_tablefbsql_free_resultfbsql_list_fields", "fbsql_list_tablesfbsql_next_resultfilepro_fieldname", "filepro_fieldtypeget_class_methodsget_resource_type", "hw_docbyanchorobjhw_insertdocumentibase_free_result", "icap_delete_eventifx_affected_rowsifx_byteasvarchar", "ifx_textasvarcharifxus_create_slobignore_user_abort", "imagecolorclosestimagecolorresolveimagefilltoborder", "imagegammacorrectimagepsencodefontimagepsextendfont", "imagesetthicknessimap_getmailboxesimap_mail_compose", "imap_setflag_fullingres_autocommitingres_field_name", "ingres_field_typeingres_num_fieldsircg_channel_mode", "mb_output_handlermcal_append_eventmcal_date_compare", "mcal_delete_eventmcal_is_leap_yearmcrypt_list_modes", "msql_fetch_objectmssql_fetch_arraymssql_fetch_field", "mssql_free_resultmssql_next_resultmysql_change_user", "mysql_fetch_arraymysql_fetch_assocmysql_fetch_field", "mysql_field_flagsmysql_field_tablemysql_free_result", "mysql_list_fieldsmysql_list_tablesob_implicit_flush", "ocicollassignelemocifetchstatementocifreecollection", "ociwritelobtofileopenssl_x509_freeopenssl_x509_read", "ovrimos_fetch_rowovrimos_field_lenovrimos_field_num", "pdf_add_locallinkpdf_add_thumbnailpdf_begin_pattern", "pdf_continue_textpdf_get_parameterpdf_get_pdi_value", "pdf_makespotcolorpdf_open_pdi_pagepdf_setmiterlimit", "pdf_set_parameterpdf_set_text_risepfpro_process_raw", "printer_create_dcprinter_delete_dcprinter_draw_line", "printer_draw_textprinter_start_docpspell_new_config", "sesam_fetch_arraysesam_field_arraysesam_free_result", "session_save_pathset_error_handlersocket_get_status", "swf_getbitmapinfoswf_shapecurveto3swf_startdoaction", "sybase_field_seeksybase_num_fieldsudm_get_doc_count", "udm_get_res_fieldudm_get_res_paramwddx_packet_start", "xml_parser_createxpath_new_contextxslt_fetch_result" ),17,1); () = define_keywords_n ($1, strcat( "array_count_valuesconnection_aborted", "connection_timeoutconvert_cyr_stringcpdf_continue_text", "cpdf_finalize_pagecpdf_output_buffercpdf_setmiterlimit", "cpdf_set_text_risedbplus_undopreparefbsql_fetch_object", "filepro_fieldcountfilepro_fieldwidthget_included_files", "get_required_filesgmp_perfect_squarehw_getchildcollobj", "hw_getchilddoccollhw_getsrcbydestobjhw_output_document", "ibase_fetch_objecticonv_get_encodingiconv_set_encoding", "ifx_htmltbl_resultimagealphablendingimagecolorallocate", "imagecopymergegrayimagecopyresampledimagecreatefromgif", "imagecreatefrompngimagefilledellipseimagefilledpolygon", "imap_createmailboximap_deletemailboximap_getsubscribed", "imap_renamemailboxingres_fetch_arrayingres_field_scale", "ircg_is_conn_aliveldap_count_entriesmb_detect_encoding", "mcal_days_in_monthmcal_event_set_endmcrypt_generic_end", "mcrypt_get_iv_sizemcrypt_module_openmove_uploaded_file", "msql_affected_rowsmssql_fetch_objectmssql_field_length", "mysql_fetch_objectocicolumnprecisionopenssl_pkcs7_sign", "openssl_x509_parseovrimos_fetch_intoovrimos_field_name", "ovrimos_field_typeovrimos_num_fieldsovrimos_result_all", "pdf_add_annotationpdf_add_launchlinkpdf_begin_template", "pdf_close_pdi_pagepdf_place_pdi_pagepdf_setgray_stroke", "pg_client_encodingprinter_create_penprinter_delete_pen", "printer_draw_chordprinter_get_optionprinter_select_pen", "printer_set_optionprinter_start_pagepspell_config_mode", "pspell_config_replsesam_fetch_resultsession_unregister", "socket_set_timeoutswf_shapefillsolidswf_shapelinesolid", "sybase_fetch_arraysybase_fetch_fieldsybase_free_result", "xml_get_error_codezip_entry_filesize" ),18,1); () = define_keywords_n ($1, strcat( "cpdf_add_annotationcpdf_setgray_stroke", "dbase_delete_recorddbplus_freealllocksfbsql_affected_rows", "fbsql_fetch_lengthsfdf_next_field_nameget_extension_funcs", "hw_document_bodytaghw_document_contenthw_getobjectbyquery", "ifx_blobinfile_modeifx_fieldpropertiesimagecolorsforindex", "imagecreatefromjpegimagecreatefromwbmpimap_clearflag_full", "imap_fetch_overviewimap_fetchstructureimap_listsubscribed", "imap_mailboxmsginfoingres_fetch_objectingres_field_length", "ldap_get_attributesldap_get_values_lenldap_next_attribute", "mb_convert_encodingmcrypt_generic_initmcrypt_get_key_size", "mhash_get_hash_namemysql_affected_rowsmysql_escape_string", "mysql_fetch_lengthsmysql_get_host_infoodbc_specialcolumns", "ovrimos_free_resultovrimos_longreadlenpdf_get_image_width", "pdf_open_image_filepdf_set_border_dashpdf_set_text_matrix", "printer_create_fontprinter_delete_fontprinter_draw_elipse", "printer_select_fontpspell_new_personalsesam_affected_rows", "session_module_namesession_write_closesocket_set_blocking", "swf_actiongotoframeswf_actiongotolabelswf_actionnextframe", "swf_actionprevframeswf_actionsettargetswf_addbuttonrecord", "sybase_fetch_objectudm_set_agent_paramwddx_serialize_vars" ),19,1); () = define_keywords_n ($1, strcat( "call_user_func_array", "cpdf_set_text_matrixdbase_replace_record", "domxml_get_attributedomxml_set_attribute", "get_declared_classesget_magic_quotes_gpc", "hw_getremotechildrenimagecolordeallocate", "imagecolorexactalphaimagecreatetruecolor", "imagefilledrectangleircg_fetch_error_msg", "ldap_first_attributemb_convert_variables", "mb_decode_mimeheadermb_encode_mimeheader", "mb_internal_encodingmcal_create_calendar", "mcal_delete_calendarmcal_event_set_alarm", "mcal_event_set_classmcal_event_set_start", "mcal_event_set_titlemcal_next_recurrence", "mcal_rename_calendarmcrypt_enc_self_test", "mhash_get_block_sizemysql_get_proto_info", "odbc_field_precisionodbc_tableprivileges", "openssl_error_stringopenssl_pkcs7_verify", "pdf_closepath_strokepdf_get_image_height", "pdf_set_border_colorpdf_set_border_style", "pdf_set_char_spacingpdf_setrgbcolor_fill", "pdf_set_word_spacingprinter_create_brush", "printer_delete_brushprinter_select_brush", "pspell_clear_sessionpspell_config_create", "pspell_config_ignorepspell_save_wordlist", "readline_add_historysesam_settransaction", "snmp_get_quick_printsnmp_set_quick_print", "sybase_affected_rowsudm_add_search_limit", "udm_free_ispell_dataudm_load_ispell_data", "wddx_serialize_valuexslt_set_sax_handler" ),20,1); () = define_keywords_n ($1, strcat( "array_merge_recursive", "cpdf_closepath_strokecpdf_set_char_spacing", "cpdf_set_current_pagecpdf_setrgbcolor_fill", "cpdf_set_word_spacingget_defined_constants", "get_defined_functionsget_loaded_extensions", "hw_getchilddoccollobjimagecolortransparent", "imagecreatefromstringingres_field_nullable", "mcrypt_get_block_sizemysql_get_client_info", "mysql_get_server_infoodbc_columnprivileges", "odbc_procedurecolumnsopenssl_get_publickey", "openssl_pkcs7_decryptopenssl_pkcs7_encrypt", "pdf_get_pdi_parameterpdf_open_memory_image", "pdf_set_horiz_scalingpreg_replace_callback", "pspell_add_to_sessionreadline_list_history", "readline_read_historyrestore_error_handler", "session_cache_limitersession_is_registered", "xml_parse_into_structxml_parser_get_option", "xml_parser_set_optionyp_get_default_domain" ),21,1); () = define_keywords_n ($1, strcat( "call_user_method_array", "cpdf_set_horiz_scalinghw_document_attributes", "hw_document_setcontenthw_getobjectbyqueryobj", "imagecolorclosestalphaimagecolorresolvealpha", "ingres_field_precisionmb_preferred_mime_name", "mcrypt_enc_get_iv_sizemcrypt_get_cipher_name", "mcrypt_list_algorithmsmssql_get_last_message", "mysql_unbuffered_queryopenssl_get_privatekey", "pdf_setrgbcolor_strokepdf_set_text_rendering", "pg_set_client_encodingprinter_draw_rectangle", "printer_draw_roundrectpspell_add_to_personal", "pspell_config_personalreadline_clear_history", "readline_write_historyregister_tick_function", "satellite_exception_idswf_actionwaitforframe" ),22,1); () = define_keywords_n ($1, strcat( "cpdf_place_inline_image", "cpdf_set_page_animationcpdf_setrgbcolor_stroke", "cpdf_set_text_renderingcybercash_base64_decode", "cybercash_base64_encodecybermut_creerreponsecm", "dbplus_setindexbynumberdefine_syslog_variables", "fbsql_database_passwordhw_getobjectbyquerycoll", "imagetruecolortopaletteimap_mime_header_decode", "java_last_exception_getmb_decode_numericentity", "mb_encode_numericentitymb_substitute_character", "mcal_event_set_categorymcrypt_enc_get_key_size", "mcrypt_module_self_testpspell_config_save_repl", "quoted_printable_decodeswf_actiontogglequality", "swf_shapefillbitmapclipswf_shapefillbitmaptile", "sybase_get_last_messageudm_clear_search_limits", "xml_set_default_handlerxml_set_element_handler" ),23,1); () = define_keywords_n ($1, strcat( "get_magic_quotes_runtime", "mcal_event_add_attributemcrypt_enc_is_block_mode", "mssql_min_error_severitypspell_store_replacement", "session_set_save_handlerset_magic_quotes_runtime", "unregister_tick_functionxslt_output_endtransform", "zip_entry_compressedsize" ),24,1); () = define_keywords_n ($1, strcat( "fdf_set_javascript_action", "imap_rfc822_parse_adrlistimap_rfc822_parse_headers", "imap_rfc822_write_addressjava_last_exception_clear", "mcal_event_set_recur_nonemcrypt_enc_get_block_size", "mcrypt_enc_get_modes_nameopenssl_x509_checkpurpose", "pdf_closepath_fill_strokepspell_config_runtogether", "satellite_exception_valuesession_get_cookie_params", "session_set_cookie_paramssybase_min_error_severity" ),25,1); () = define_keywords_n ($1, strcat( "cpdf_closepath_fill_stroke", "cybermut_creerformulairecmfdf_set_submit_form_action", "get_html_translation_tablehw_getobjectbyquerycollobj", "mcal_event_set_descriptionmcal_event_set_recur_daily", "mssql_min_message_severityprinter_logical_fontheight", "register_shutdown_functionsatellite_caught_exception", "sybase_min_client_severitysybase_min_server_severity", "xml_get_current_byte_indexxslt_output_begintransform" ),26,1); () = define_keywords_n ($1, strcat( "dbase_get_record_with_names", "ircg_lookup_format_messagesmcal_event_set_recur_weekly", "mcal_event_set_recur_yearlymcrypt_module_is_block_mode", "sybase_min_message_severityxml_get_current_line_number", "zip_entry_compressionmethod" ),27,1); () = define_keywords_n ($1, "readline_completion_function", 28,1); () = define_keywords_n ($1, strcat( "ircg_register_format_messages", "mcrypt_enc_is_block_algorithmxml_get_current_column_number", "xml_set_notation_decl_handler" ),29,1); () = define_keywords_n ($1, strcat( "mcrypt_enc_get_algorithms_name", "xml_set_character_data_handler" ),30,1); () = define_keywords_n ($1, strcat( "cpdf_global_set_document_limits", "mcal_fetch_current_stream_eventmcrypt_module_get_algo_key_size" ),31,1); () = define_keywords_n ($1, "mcrypt_module_is_block_algorithm", 32,1); () = define_keywords_n ($1, strcat( "mcal_event_set_recur_monthly_mday", "mcal_event_set_recur_monthly_wdaymcrypt_module_get_algo_block_size" ),33,1); () = define_keywords_n ($1, strcat( "mcrypt_enc_get_supported_key_sizes", "mcrypt_enc_is_block_algorithm_mode" ),34,1); () = define_keywords_n ($1, "xml_set_external_entity_ref_handler", 35,1); () = define_keywords_n ($1, "xml_set_unparsed_entity_decl_handler", 36,1); () = define_keywords_n ($1, "mcrypt_module_is_block_algorithm_mode", 37,1); () = define_keywords_n ($1, "xml_set_processing_instruction_handler", 38,1); () = define_keywords_n ($1, "mcrypt_module_get_algo_supported_key_sizes", 42,1); %}}} %!%+ %\function{php_mode} %\synopsis{php_mode} %\usage{Void php_mode ();} %\description % This is a mode that is dedicated to faciliate the editing of PHP language files. % It calls the function \var{php_mode_hook} if it is defined. It also manages % to recognice whetever it is in a php block or in a html block, for those people % that doesnt seperate function from form ;) % % Functions that affect this mode include: %#v+ % function: default binding: % php_top_of_function ESC Ctrl-A % php_end_of_function ESC Ctrl-E % php_mark_function ESC Ctrl-H % php_mark_matching ESC Ctrl-M % php_indent_buffer Ctrl-C Ctrl-B % php_insert_class Ctrl-C Ctrl-C % php_insert_function Ctrl-C Ctrl-F % php_insert_bra { % php_insert_ket } % php_insert_colon : % php_format_paragraph ESC q % indent_line TAB % newline_and_indent RETURN % goto_match Ctrl-\ % php_insert_tab Ctrl-C Ctrl-I %#v- % Variables affecting indentation include: %#v+ % PHP_INDENT % PHP_BRACE % PHP_BRA_NEWLINE % PHP_KET_NEWLINE % PHP_Colon_Offset % PHP_CONTINUED_OFFSET % PHP_Class_Offset % PHP_Autoinsert_Comments % PHP_Switch_Offset %#v- % Hooks: \var{php_mode_hook} %!%- define php_mode( ) { variable kmap = "PHP"; set_mode( kmap, 2 ); use_keymap( kmap ); use_syntax_table( kmap ); set_buffer_hook( "par_sep", "php_paragraph_sep" ); set_buffer_hook( "indent_hook", "php_indent_region_or_line" ); set_buffer_hook( "newline_indent_hook", "php_newline_and_indent" ); mode_set_mode_info( "PHP", "fold_info", "//{{{\r//}}}\r\r" ); mode_set_mode_info( "PHP", "init_mode_menu", &php_init_menu ); run_mode_hooks( "php_mode_hook" ); } provide( "php_mode" ); jed-0.99-19/lib/hooks.sl0000644002657400265740000000374311311317447013732 0ustar davisdavis% This interface is obsolete. New code should use the add_to_hook function private variable Hooks = NULL; private define add_hook_function (name, main_hook) { variable h; h = struct { hook_name, next, main_hook_function, list_of_hooks }; h.hook_name = name; h.main_hook_function = main_hook; h.next = Hooks; Hooks = h; } private define find_hook (name) { variable h; #iftrue foreach (Hooks) { h = (); if (name == h.hook_name) return h; } return NULL; #endif } define hook_add_hook (hook_name, hook_function) { variable h; variable list; switch (hook_name) { case "save_buffer_hook": add_to_hook ("_jed_write_buffer_before_hooks", hook_function); return; } { case "init_display_hook": add_to_hook ("_jed_init_display_hooks", hook_function); return; } { case "reset_display_hook": add_to_hook ("_jed_reset_display_hooks", hook_function); return; } h = find_hook (hook_name); if (h == NULL) verror ("hook %s unknown to this interface", hook_name); list = struct { hook_function, next }; list.hook_function = hook_function; list.next = h.list_of_hooks; h.list_of_hooks = list; } % This function just runs the hooks with arguments assuming that the % hook returns nothing private define do_simple_hook (name) { variable args, h; args = __pop_args (_NARGS - 1); h = find_hook (name); if (h == NULL) return; foreach (h.list_of_hooks) { h = (); @h.hook_function (__push_args(args)); } } define save_buffer_hook (file, mode) { do_simple_hook (file, mode, _function_name ()); } add_hook_function ("save_buffer_hook", &save_buffer_hook); define init_display_hook () { do_simple_hook (_function_name ()); } add_hook_function ("init_display_hook", &init_display_hook); define reset_display_hook () { do_simple_hook (_function_name ()); } add_hook_function ("reset_display_hook", &reset_display_hook); jed-0.99-19/lib/lua.sl0000644002657400265740000003254711311317447013374 0ustar davisdavis% Lua mode % File: lua.sl v1.02 % % For editing source code written in the Lua programming language. % % Authors: Reuben Thomas % % Adapted from Python mode (pymode 1.2) by: % Harri Pasanen % Brien Barton % % % following keys have lua specific bindings: % % DELETE deletes to previous indent level % TAB indents line % ^C# comments region or current line % ^C> shifts line or region right % ^C< shifts line or region left % ^C^C executes the region, or the buffer if region not marked. % ^C| executes the region % ^C\t reindents the region % % See lua_mode function for available hooks % % Shortcomings: a rough hack at the moment. % $1 = "Lua"; !if (keymap_p ($1)) make_keymap ($1); definekey ("lua_backspace_key", "^?", $1); !if (is_defined ("Win_Keys")) { % Ctrl-C conflicts with windows region copy. definekey_reserved ("lua_comment_region", "#", $1); definekey_reserved ("lua_uncomment_region", "3", $1); definekey_reserved ("lua_shift_region_right",">", $1); definekey_reserved ("lua_shift_region_left", "<", $1); definekey_reserved ("lua_exec", "^C",$1); % Execute buffer, or region if defined definekey_reserved ("lua_exec_region", "|", $1); definekey_reserved ("lua_reindent_region", "\t",$1); definekey ("indent_line", "\t", $1); } #ifdef MSWINDOWS definekey ("lua_help_on_word", "^@;", $1); #endif % Set the following to your favourite indentation level custom_variable ("Lua_Indent_Level", 4); private define lua_endblock_cmd() { if (looking_at("end") or looking_at("until")) return 1; return 0; } private define lua_line_starts_block() { if (blooking_at("do") or blooking_at("then") or blooking_at("else") or blooking_at("repeat")) return 1; return 0; } private define lua_indent_calculate() { % return the indentation of the previous lua line variable col = 0; variable end_block = 0; EXIT_BLOCK { pop_spot (); return col; } % check if current line ends a block bol_skip_white(); if (lua_endblock_cmd()) end_block = 1; % go to previous non blank line push_spot_bol (); !if (re_bsearch ("[^ \t\n]")) return; bol_skip_white(); col = what_column() - 1; if (looking_at("function") or (eol(), lua_line_starts_block())) col += Lua_Indent_Level; if (end_block) col -= Lua_Indent_Level; } define lua_indent_line() { variable col; col = lua_indent_calculate(); bol_trim (); whitespace( col ); } define lua_comment_line() { bol(); insert("--"); } define lua_comment_region() { variable n; check_region (1); n = what_line (); pop_mark_1 (); loop (n - what_line ()) { lua_comment_line(); go_down_1 (); } pop_spot(); } define lua_comment() { push_spot(); if (markp()) { lua_comment_region(); } else { lua_comment_line(); } pop_spot(); } define lua_uncomment_line() { bol_skip_white(); while (looking_at_char('-')) del(); } define lua_uncomment_region() { variable n; check_region (1); n = what_line (); pop_mark_1 (); loop (n - what_line ()) { lua_uncomment_line(); go_down_1 (); } pop_spot(); } define lua_uncomment() { push_spot(); if (markp()) { lua_uncomment_region(); } else { lua_uncomment_line(); } pop_spot(); } define lua_backspace_key() { variable col; col = what_column(); push_spot(); bskip_white(); if (bolp() and (col > 1)) { pop_spot(); bol_trim (); col--; if (col mod Lua_Indent_Level == 0) col--; whitespace ( (col / Lua_Indent_Level) * Lua_Indent_Level ); } else { pop_spot(); call("backward_delete_char_untabify"); } } define lua_shift_line_right() { bol_skip_white(); whitespace(Lua_Indent_Level); } define lua_shift_region_right() { variable n; check_region (1); % spot_pushed, now at end of region n = what_line (); pop_mark_1 (); loop (n - what_line ()) { lua_shift_line_right(); go_down_1 (); } pop_spot(); } define lua_shift_right() { push_spot(); if (markp()) { lua_shift_region_right(); } else { lua_shift_line_right(); } pop_spot(); } define lua_shift_line_left() { bol_skip_white(); if (what_column() > Lua_Indent_Level) { push_mark(); goto_column(what_column() - Lua_Indent_Level); del_region(); } } define lua_shift_region_left() { variable n; check_region (1); n = what_line (); pop_mark_1 (); loop (n - what_line ()) { lua_shift_line_left(); go_down_1 (); } pop_spot(); } define lua_shift_left() { push_spot(); if (markp()) { lua_shift_region_left(); } else { lua_shift_line_left(); } pop_spot(); } define lua_newline_and_indent() { push_spot(); lua_indent_line(); pop_spot(); newline(); lua_indent_line(); } define file_path(fullname) { variable filename; filename = extract_filename(fullname); substr(fullname, 1, strlen(fullname)-strlen(filename)); } define lua_exec_region() { % Run lua interpreter on current region. % Display output in *shell-output* buffer window. variable oldbuf, thisbuf, file, line, start_line; variable tmpfile = "_lua.tmp"; variable error_regexp = "^ File \"\\([^\"]+\\)\", line \\(\\d+\\).*"; variable lua_source = buffer_filename(); change_default_dir(file_path(lua_source)); thisbuf = whatbuf(); % Check if 1st line starts in column 1 exchange_point_and_mark(); bol_skip_white(); start_line = what_line(); if (what_column() > 1) { % Workaround in case block is indented write_string_to_file("if 1:\n", tmpfile); bol(); start_line--; % offset for this extra line } exchange_point_and_mark(); append_region_to_file(tmpfile); oldbuf = pop2buf_whatbuf("*shell-output*"); erase_buffer (); #ifdef UNIX run_shell_cmd(sprintf("lua %s 2>&1", tmpfile)); #else run_shell_cmd(sprintf("lua %s", tmpfile)); #endif () = delete_file(tmpfile); % try to restore any window that got replaced by the shell-output if (strlen(oldbuf) and (strcmp(oldbuf, "*shell-output*") != 0) and (strcmp(thisbuf, oldbuf) != 0)) { splitwindow(); sw2buf(oldbuf); pop2buf("*shell-output*"); } eob(); % Check for error message while (re_bsearch(error_regexp) != 0) { % Make sure error occurred in the file we were executing file = regexp_nth_match(1); line = integer(regexp_nth_match(2)); if (strcmp(file, tmpfile) == 0) { % Move to line in source that generated the error pop2buf(thisbuf); goto_line(line + start_line - 1); break; } else { % Error is in another file, try previous error message continue; } } } define lua_exec() { % Run lua interpreter on current region if one is defined, otherwise % on the whole buffer. % Display output in *shell-output* buffer window. !if (markp()) { % create region containing entire buffer push_spot_bob (); push_mark_eob (); } lua_exec_region(); } define lua_reindent() { % Reindents a (correctly) indented buffer using the current % value of Lua_Indent_Level. % Warning: Current version can be fooled by implicit or explicit % continuation lines. variable indent_level = Int_Type[64]-1; variable level = -1; variable current_indent = -1; variable errmsg, i, col, ignore, oldlevel; bob(); do { bol_skip_white(); ignore = looking_at_char('-') or eolp(); if (ignore) continue; % skip comments and blank lines col = what_column() - 1; oldlevel = level; % save current level if (col > current_indent) { % indenting level++; } else if (col < current_indent) { % dedent while ((level > 0) and (indent_level[level] > col)) { indent_level[level] = -1; % clear current level setting level--; } } if ((indent_level[level] != -1) and (indent_level[level] != col)) { % Indent is wrong. Hopefully it's a continuation line. level = oldlevel; % reset level bol_trim(); whitespace(level * Lua_Indent_Level + (col - current_indent)); } else { current_indent = col; indent_level[level] = col; bol_trim(); whitespace(level * Lua_Indent_Level); } } while (down(1)); } define lua_reindent_region() { narrow(); lua_reindent(); widen(); } create_syntax_table ($1); define_syntax ("--", "", '%', $1); % comments define_syntax ("([{", ")]}", '(', $1); % delimiters define_syntax ('"', '"', $1); % quoted strings define_syntax ('\'', '\'', $1); % quoted characters define_syntax ("0-9a-zA-Z_", 'w', $1); % words define_syntax ("-+0-9.eE", '0', $1); % Numbers define_syntax (",;.", ',', $1); % punctuation define_syntax ("%-+/*=<>!^", '+', $1); % operators set_syntax_flags ($1, 0); % keywords ARE case-sensitive () = define_keywords ($1, "doifinor", 2); % all keywords of length 2 () = define_keywords ($1, "andendfornilnot", 3); % of length 3 ... () = define_keywords ($1, "elsethen", 4); () = define_keywords ($1, "breaklocaluntilwhile", 5); () = define_keywords ($1, "elseifrepeatreturn", 6); () = define_keywords ($1, "function", 8); % Type 1 keywords (basic library functions) () = define_keywords_n ($1, "tag", 3, 1); () = define_keywords_n ($1, "callgetnnextsorttype", 4, 1); () = define_keywords_n ($1, "errorprint", 5, 1); () = define_keywords_n ($1, "_ALERTassertdofilenewtagrawgetrawsetsettag", 6, 1); () = define_keywords_n ($1, "foreachglobalstinserttremove", 7, 1); () = define_keywords_n ($1, "dostringforeachitonumbertostring", 8, 1); () = define_keywords_n ($1, "getglobalsetglobal", 9, 1); () = define_keywords_n ($1, "gettagmethodsettagmethod", 12, 1); () = define_keywords_n ($1, "collectgarbagecopytagmethods", 14, 1); % Type 2 keywords (string, math, I/O, debug library & system functions % and variables) () = define_keywords_n ($1, "PI", 2, 2); () = define_keywords_n ($1, "abscosdegexplogmaxminmodradsintan", 3, 2); () = define_keywords_n ($1, "acosasinatanceildateexitgsubreadseeksqrt", 4, 2); () = define_keywords_n ($1, "atan2clockfloorflushfrexpldexplog10write", 5, 2); () = define_keywords_n ($1, "_INPUT_STDINformatgetenvrandomremoverenamestrlenstrrepstrsub", 6, 2); () = define_keywords_n ($1, "_OUTPUT_STDERR_STDOUTexecutegetinfostrbytestrcharstrfindtmpnamewriteto", 7, 2); () = define_keywords_n ($1, "appendtogetlocalopenfilereadfromsetlocalstrlowerstrupper", 8, 2); () = define_keywords_n ($1, "closefilesetlocale", 9, 2); () = define_keywords_n ($1, "randomseed", 10, 2); () = define_keywords_n ($1, "setcallhooksetlinehook", 11, 2); #ifdef HAS_DFA_SYNTAX %%% DFA_CACHE_BEGIN %%% private define setup_dfa_callback (name) { dfa_enable_highlight_cache("lua.dfa", name); dfa_define_highlight_rule("\\[\\[.+\\]\\]", "string", name); % long string ([[ ]]) dfa_define_highlight_rule("\"([^\"\\\\]|\\\\.)*\"", "string", name); % normal string dfa_define_highlight_rule("'([^\'\\\\]|\\\\.)*'", "string", name); % normal string dfa_define_highlight_rule("^#.*", "comment", name); % #! comment dfa_define_highlight_rule("--.*", "comment", name); % comment dfa_define_highlight_rule("[A-Za-z_][A-Za-z_0-9]*", "Knormal", name); % identifier dfa_define_highlight_rule("[0-9]+", "number", name); % decimal int dfa_define_highlight_rule("[0-9]+\\.[0-9]*([Ee][\\+\\-]?[0-9]+)?", "number", name); % float n.[n] dfa_define_highlight_rule("0?\\.[0-9]+([Ee][\\+\\-]?[0-9]+)?", "number", name); % float [n].n dfa_define_highlight_rule("[ \t]+", "normal", name); dfa_define_highlight_rule("[\\(\\[{}\\]\\),\\.\\;]", "delimiter", name); dfa_define_highlight_rule("\\.\\.\\.", "delimiter", name); dfa_define_highlight_rule("[\\+\\-\\*/%<>=]", "operator", name); % 1 char dfa_define_highlight_rule("==|<=|>=|~=|\\.\\.", "operator", name); % >1 char % Flag badly formed numeric literals or identifiers. This is more effective % if you change the error colors so they stand out. dfa_define_highlight_rule("[0-9]+[0-9A-Za-z\\.]+", "error", name); % bad decimal dfa_define_highlight_rule("\\.[0-9]+([Ee][\\+\\-]?[0-9]+)?[A-Za-z]+", "error", name); % bad float dfa_build_highlight_table(name); } dfa_set_init_callback (&setup_dfa_callback, "Lua"); %%% DFA_CACHE_END %%% #endif %!%+ %\function{lua_mode} %\synopsis{lua_mode} %\usage{lua_mode ()} %\description % A major mode for editing lua files. % % The following keys have lua specific bindings: %#v+ % DELETE deletes to previous indent level % TAB indents line % ^C# comments region or current line % ^C> shifts line or region right % ^C< shifts line or region left % ^C^C executes the region, or the buffer if region not marked. % ^C| executes the region % ^C\t reindents the region %#v- % Hooks: \var{lua_mode_hook} % %\seealso{Lua_Indent_Level} %\seealso{set_mode, c_mode} %!%- define lua_mode () { variable lua = "Lua"; TAB = 8; set_mode (lua, 0x4); % flag value of 4 is generic language mode use_keymap(lua); set_buffer_hook ("indent_hook", "lua_indent_line"); set_buffer_hook ("newline_indent_hook", "lua_newline_and_indent"); use_syntax_table (lua); run_mode_hooks ("lua_mode_hook"); } jed-0.99-19/lib/jed.conf0000644002657400265740000000050611311317447013652 0ustar davisdavis% -*- slang -*- % This is a sample jed.conf that the user may put in /etc or /usr/local/etc % to setup some defaults for all users. _Jed_Default_Emulation = "ide"; _Jed_Default_Color_Scheme = "blue2"; Info_Directory = "/usr/info,/usr/share/info"; auto_compression_mode (1); enable_dfa_syntax_for_mode ("PostScript", "TCL"); jed-0.99-19/lib/dos437.sl0000644002657400265740000000175211311317447013630 0ustar davisdavis#ifdef IBMPC_SYSTEM % Initializes upper/lowercase lookup tables for DOS code page 437. % 437 is the original DOS character table. So if your DOS version % does not support code pages, use this table. 437 is also the % default code page for USA, United Kingdom, and International English. % It is the alternate code page for Belgium, Brazil, Finland, France, % Germany, Italy, Latin America, Netherlands, Spain, Sweden, and % Switzerland. % Information from MSDOS 5.0 manual % . 0 64 1 { dup define_case } _for . 65 90 1 { dup 32 + define_case } _for . 91 96 1 { dup define_case } _for . 123 255 1 { dup define_case } _for . 128 135 define_case . 142 132 define_case . 143 134 define_case . 144 130 define_case . 146 145 define_case . 153 148 define_case . 154 129 define_case . 165 164 define_case % % Now define a word. This IS NOT based on above % . "0-9a-zA-Z\d128-\d167\d224-\d235" define_word % Marko thinks: . "0-9a-zA-Z\d128-\d154\d160-\d165\d224-\d235" define_word #endif jed-0.99-19/lib/digraph.sl0000644002657400265740000000746711311317447014234 0ustar davisdavis% digraph.sl -*- Slang -*- % % This is digraph.sl. It allows for easy input of accented characters and % other 8-bit characters. It is an alternative to the mutekeys.sl package. % I wrote it because I don't like mutekeys. I added a lot of characters not % found in mutekeys.sl. % % Usage: put this file in $JED_ROOT/lib and add a line % % autoload ("digraph_cmd", "digraph"); setkey ("digraph_cmd", "\ek"); % % to your ~/.jedrc file, restart jed so that this setkey takes effect before % any other keymaps are defined. The digraphs are now available by typing % Esc-K 'accent' 'letter'. % % Thanks to John Davis for reducing the number of case statements in the % original code and for adding the user-friendly interface (don't type too % fast, otherwise you can't read it). % % DONE: This does not work yet under MSDOS and OS2 . Any volunteers? % % Ronald Rietman, 1995/03/05 %%% % - added MSDOS, OS/2 digraphs % - changed key for British Pounds from $ to # (pounds) so that it occurs in % the same place as a UK keyboard % - added European-style double quotes % - moved inverted punctuation marks to use a period accent and added DOS % line-drawing characters to the same. Letters for lines correspond to % curses ACS (Alternate Character Set), except 'P' invented to == `Plus' % % Mark Olesen 16 Aug 1995 % Modified by JED, Feb 2006. % This function has the effect of converting an ISO-Latin string UTF-8 if in % UTF-8 mode. It does not work on DOS/Windows. #ifndef IBMPC_SYSTEM private define convert_string (str) { variable new_str = ""; _for (0, strbytelen (str)-1, 1) { variable i = (); new_str = strcat (new_str, char (str[i])); } return new_str; } #endif define digraph_cmd () { variable i, accent, letters; #iffalse EXIT_BLOCK { message (Null_String); } #endif switch (get_mini_response ("Enter an accent character: [/`'^\"~,.:]")) { case '/': #ifdef IBMPC_SYSTEM "aAeEs#yc"; "\d134\d143\d145\d146\d225\d156\d157\d155"; #else "aAdDeEoOstT#yc"; "\d229\d197\d240\d208\d230\d198\d248\d216\d223\d254\d222\d163\d165\d162"; #endif } { case '"': #ifdef IBMPC_SYSTEM "`aAeioOsuUy'"; %"\d174\d132\d142\d137\d139\d148\d153\d129\d225\d154\d152\d175"; "\d174\d132\d142\d137\d139\d148\d153\d225\d129\d154\d152\d175"; #else "`aAeEiIoOsuU'"; "\d171\d228\d196\d235\d203\d239\d207\d246\d214\d223\d252\d220\d187"; #endif } { case '\'': #ifdef IBMPC_SYSTEM "aeEiou'"; "\d160\d130\d144\d161\d162\d163\d175"; #else "aAeEiIoOuU'"; "\d225\d193\d233\d201\d237\d205\d243\d211\d250\d218\d187"; #endif } { case '`': #ifdef IBMPC_SYSTEM "`aeiou"; "\d174\d133\d138\d141\d149\d151"; #else "`aAeEiIoOuU"; "\d171\d224\d192\d232\d200\d236\d204\d242\d210\d249\d217"; #endif } { case '^': #ifdef IBMPC_SYSTEM "aeiou"; "\d131\d136\d140\d147\d150"; #else "aAeEiIoOuU"; "\d226\d194\d234\d202\d238\d206\d244\d212\d251\d219"; #endif } { case '~': #ifdef IBMPC_SYSTEM "nN"; "\d164\d165"; #else "aAnNoO"; "\d227\d195\d241\d209\d245\d213"; #endif } { case ',': "cC"; #ifdef IBMPC_SYSTEM "\d135\d128"; #else "\d231\d199"; #endif } { case '.': #ifdef IBMPC_SYSTEM "!?aAjJkKlLmMpPqQtTuUvVwWxX"; "\d173\d168\d177\d178\d217\d188\d191\d187\d218\d201\d192\d200\d197\d206\d196\d205\d195\d204\d180\d185\d194\d203\d193\d202\d179\d186"; #else "!?1/"; "\d161\d191\d161\d191"; #endif } { case ':': #ifdef IBMPC_SYSTEM return; #else "aAeEiIoOuU"; "\d228\d196\d235\d203\d239\d207\d246\d214\d252\d220"; #endif } { return; } % default (letters, accent) = (); #ifndef IBMPC_SYSTEM accent = convert_string (accent); #endif i = is_substr (letters, char (get_mini_response (sprintf ("Enter [%s] to get [%s]", letters, accent)))); !if (i) { beep (); return; } insert (substr (accent, i, 1)); } jed-0.99-19/lib/mouse.sl0000644002657400265740000001235211311317447013733 0ustar davisdavisunsetkey ("\e^@"); setkey ("mouse_cmd", "\e^@"); custom_variable ("Mouse_Wheel_Scroll_Lines", 3); %!%+ %\variable{Mouse_Selection_Word_Chars} %\synopsis{Characters that delimit double-click selections} %\usage{String_Type Mouse_Selection_Word_Chars} %\description % The value of this variable represents a set of characters that serve % to delimit double-click selections. The default value of this % variable is %#v+ % Mouse_Selection_Word_Chars = "^ \n\"%&'()*,;<=>?@[]^`{|}"; %#v- % If the value of this variable is NULL, the word characters % associated with the buffer will be used. %\seealso{define_word} %!%- custom_variable ("Mouse_Selection_Word_Chars","^ \n\"%&'()*,;<=>?@[]^`{|}"); private variable Mouse_Drag_Mode = 0; private variable Mouse_Save_Point_Mark; private variable Mouse_Buffer = " *Mouse buffer*"; private variable Mouse_Delete_Region = 0; define mouse_goto_position (col, line) { goto_line (line); () = goto_column_best_try (col); } define mouse_yank_from_jed () { if (bufferp(Mouse_Buffer)) insbuf(Mouse_Buffer); } define copy_kill_to_mouse_buffer () { variable cbuf = whatbuf (); variable pnt, n; % % We are not going to copy to the pastebuffer if the region is nil % n = what_line(); pnt = _get_point (); push_spot(); pop_mark_1 (); if ((what_line() == n) and (_get_point () == pnt)) { pop_spot(); return; } push_mark(); pop_spot(); setbuf(Mouse_Buffer); erase_buffer (); setbuf (cbuf); if (Mouse_Delete_Region) () = dupmark(); () = dupmark(); %/* for cut buffer */ x_copy_region_to_selection (); copy_region(Mouse_Buffer); if (Mouse_Delete_Region) { Mouse_Delete_Region = 0; del_region(); } } define mouse_down_hook (line, col, but, shift) { variable l; if (but == 8) { l = window_line(); loop (Mouse_Wheel_Scroll_Lines) skip_hidden_lines_backward (1); bol(); recenter(l); return 0; } if (but == 16) { l = window_line(); loop (Mouse_Wheel_Scroll_Lines) skip_hidden_lines_forward (1); bol(); recenter(l); return 0; } if (shift == 0) { if (but == 2) { mouse_set_current_window (); () = x_insert_selection (); return 0; } if (is_visible_mark ()) { if (but == 1) { pop_mark (0); return 0; } if (but == 4) Mouse_Delete_Region = 1; copy_kill_to_mouse_buffer (); return 0; } Mouse_Drag_Mode = 0; Mouse_Save_Point_Mark = create_user_mark (); mouse_goto_position (col, line); return 0; } if (shift == 1) { if (but == 2) { mouse_set_current_window (); mouse_yank_from_jed (); return 0; } } return -1; } define mouse_up_hook (line, col, but, shift) { if (shift == 0) { if (but == 1) { if (Mouse_Drag_Mode) { Mouse_Drag_Mode = 0; copy_kill_to_mouse_buffer (); if (whatbuf () == Mouse_Save_Point_Mark.buffer_name) goto_user_mark (Mouse_Save_Point_Mark); return 0; } return 1; } if (but == 4) { Mouse_Drag_Mode = 0; return 1; } } return -1; } define mouse_drag_hook (line, col, but, shift) { variable top, bot; variable y; !if (Mouse_Drag_Mode) { !if (is_visible_mark ()) { push_visible_mark (); } Mouse_Drag_Mode = 1; } mouse_goto_position (col, line); % only warp if pointer is outside window. top = window_info ('t'); bot = top + window_info ('r'); (,y, ) = mouse_get_event_info (); if ((y < top) or (y > bot)) x_warp_pointer (); return 0; } define mouse_next_buffer () { variable n, buf, cbuf = whatbuf (); n = buffer_list (); %/* buffers on stack */ loop (n) { buf = (); n--; if (buf[0] == ' ') continue; sw2buf (buf); loop (n) pop (); return; } } define mouse_status_up_hook (line, col, but, shift) { if (shift == 2) { if (but == 1) { delbuf (whatbuf ()); return 0; } } return -1; } define mouse_status_down_hook (line, col, but, shift) { if (shift == 0) { if (but == 1) mouse_next_buffer (); else if (but == 2) splitwindow (); else call ("delete_window"); return 0; } if (shift == 1) { try { if (but == 1) call ("page_down"); else if (but == 4) call ("page_up"); } catch AnyError; return 0; } return -1; } define mouse_2click_hook (line, col, but, shift) { variable word_chars = Mouse_Selection_Word_Chars; if (word_chars == NULL) word_chars = get_word_chars (); if (but == 1) { mouse_goto_position (col, line); push_spot (); bskip_chars (word_chars); push_visible_mark (); skip_chars (word_chars); update_sans_update_hook (1); usleep (500); copy_kill_to_mouse_buffer (); pop_spot (); return 0; } return -1; } mouse_set_default_hook ("mouse_2click", "mouse_2click_hook"); mouse_set_default_hook ("mouse_up", "mouse_up_hook"); mouse_set_default_hook ("mouse_down", "mouse_down_hook"); mouse_set_default_hook ("mouse_drag", "mouse_drag_hook"); mouse_set_default_hook ("mouse_status_down", "mouse_status_down_hook"); mouse_set_default_hook ("mouse_status_up", "mouse_status_up_hook"); jed-0.99-19/lib/filter.sl0000644002657400265740000000122211311317447014062 0ustar davisdavisdefine filter_region () { variable cmd, file; check_region (1); % spot pushed () = dupmark (); ERROR_BLOCK { pop_mark (0); pop_spot (); } do { cmd = read_mini ("Filter command:", Null_String, Null_String); } while (not (strlen (cmd))); file = make_tmp_file ("/tmp/jedfilter"); ERROR_BLOCK { pop_spot (); () = delete_file (file); } () = pipe_region (sprintf ("%s > %s", cmd, file)); push_spot (); if (-1 == insert_file (file)) { pop_spot (); error ("Error encountered running filter."); } pop_spot (); del_region (); EXECUTE_ERROR_BLOCK; } jed-0.99-19/lib/compat.sl0000644002657400265740000000263311311317447014067 0ustar davisdavisdefine create_array () { variable n, dims, type; variable i, size, dim; variable a; n = (); dims = Integer_Type [n]; i = n; size = 1; while (i) { i--; dim = (); dims[i] = dim; size = size * dim; } type = (); switch (type) { case 'i': a = Integer_Type [size]; } #ifdef SLANG_DOUBLE_TYPE { case 'f': a = Double_Type [size]; } #endif { case 's': a = String_Type [size]; } { case 128: a = Mark_Type [size]; } { % default verror ("create_array: Type %d not supported.", type); } reshape (a, dims); return a; } %{{{ strncat (n) %!%+ %\function{strncat} %\synopsis{strncat} %\usage{Void strncat (String a, String b, ..., Integer n);} %\description % Returns concatenated string "abc..." %\notes % This function is obsolete. %!%- define strncat (n) { ""; _stk_roll (n + 1); create_delimited_string (n); } define info_mode () { info_reader (); } % These are function to archive backward compatibiliy and give third % party mode time to migrate to slang load path. define get_jed_library_path() { variable t = get_slang_load_path (); (t,) = strreplace(t, char(path_get_delimiter()), ",", strlen(t)); return t; } define set_jed_library_path(path) { variable t; (t,) = strreplace(path, ",", char(path_get_delimiter()), strlen(path)); set_slang_load_path(t); } jed-0.99-19/lib/rcs.sl0000644002657400265740000001044311311317447013371 0ustar davisdavis% File: rcs.sl -*- SLang -*- % % Author: Guido Gonzato, . Contributions by JED. % % Version: 1.0.1. This file provides an interface to RCS a la % Emacs (sort of). % % Installation: unless rcs.sl is already loaded from site.sl (check), % insert this line in your .jedrc: % % () = evalfile ("rcs.sl"); % % or, better, insert autoload lines in your defaults.sl % like this: % % autoload ("rcs_open_file", "rcs.sl"); % autoload ("rcs_check_in_and_out", "rcs.sl"); % autoload ("rcs_read_log", "rcs.sl"); % % Usage: rcs_open_file () -- open an RCS file % rcs_check_in_and_out () -- check in/out an RCS file % rcs_read_log () -- read the change history % % you might want to set these key bindings in your .jedrc: % % setkey_reserved ("rcs_open_file", "vf"); % setkey_reserved ("rcs_check_in_and_out", "vv"); % setkey_reserved ("rcs_read_log", "vl"); % % % Last updated: 23 February 2001 %_debug_info = 1; private variable Last_Comment = ""; % Build a file name like "/home/guido/RCS/file.txt,v" private define build_rcs_filename (file) { variable dir; (dir, file) = parse_filename (file); return dircat (dircat (dir, "RCS"), strcat (file, ",v")); } private define checkout (file) { variable cmd, dir, name; flush (sprintf ("Checking out %s...", file)); (dir, name) = parse_filename (file); cmd = sprintf ("cd %s; co -l %s > /dev/null 2>&1", dir, name); if (0 != system (cmd)) verror ("Error checking out %s!", file); flush (sprintf ("Checking out %s...done.", file)); } private define checkin (file, msg) { variable dir, name, cmd; () = write_buffer (file); (dir, name) = parse_filename (file); Last_Comment = read_mini (msg, "", Last_Comment); cmd = sprintf ("cd %s; echo \"%s\" | ci %s > /dev/null 2>&1", dir, Last_Comment, name); if (0 != system (cmd)) verror ("Error checking in %s!", file); set_readonly (1); setbuf_info (getbuf_info () | 0x8); flush ("Note: file is write protected."); } define rcs_open_file () % Emacs uses ^X-v-f { variable rcs_file, dir, file; file = read_file_from_mini ("RCS open file:"); file = file [[:-3]]; % remove ",v" (dir, file) = parse_filename (file); file = dircat (dir [[:-5]], file); % remove "RCS/" checkout (file); () = find_file (file); } define rcs_check_in_and_out () % Emacs uses ^X-v-v { variable file, dir, flags; % check if the current buffer is attached to an RCS file. (file, dir,, flags) = getbuf_info(); file = dircat (dir, file); % if it doesn't exist, then create the RCS dir, check in, and exit if (0 == file_status (build_rcs_filename (file))) { dir = dircat (dir, "RCS"); if (0 == file_status (dir)) { if (0 != mkdir (dir, 0777)) verror ("Error creating RCS directory %s!", dir); } checkin (file, "RCS file description:"); return; } % the RCS file exists; if the buffer is read only, then check it out if (flags & (1 shl 3)) { % readonly checkout (file); delbuf (whatbuf()); () = find_file (file); return; } % Otherwise, check it in checkin (file, "Enter a change comment:"); } private variable rlog_buf = "*rlog*"; define close_rlog_buffer () { variable cbuf = whatbuf (); setbuf (rlog_buf); set_buffer_modified_flag (0); setbuf (cbuf); delbuf (rlog_buf); } define rcs_read_log () { variable rcs_file, dir, file, cmd, tmp_file; variable rlog_map= "rlog_map"; file = read_file_from_mini ("rlog of RCS file:"); file = file [[:-3]]; % remove ",v" (dir, file) = parse_filename (file); file = dircat (dir [[:-5]], file); % remove "RCS/" tmp_file = make_tmp_file ("/tmp/jedrlog"); cmd = sprintf ("rlog %s > %s", file, tmp_file); % exec rlog if (0 != system (cmd)) verror ("Error rlogging %s!", file); sw2buf (rlog_buf); insert_file (tmp_file); delete_file (tmp_file); most_mode (); !if (keymap_p (rlog_map)) { make_keymap (rlog_map); definekey ("close_rlog_buffer", "q", rlog_map); } use_keymap (rlog_map); set_readonly (1); } provide ("rcs"); % --- End of file rcs.sl --- jed-0.99-19/lib/keycode.sl0000644002657400265740000001073111311317447014225 0ustar davisdavis% -*- SLang -*- % % Display the key codes returned for a particular keystroke, including % most Alt keys and Control-keypad keys. % % The appended key codes were determined from an IBM XT and are useful % for defining keys. % % example: define Alt-1 to goto top of buffer (bob): % % setkey ("bob", "^@x"); % NB: the NUL character "^@" should be entered as '^' and '@' separately. define keycode () { variable ch, key = "", timeout; #ifdef XWINDOWS variable fmt = "Press any key %s: `%s' (keysym 0x%X)"; #else variable fmt = "Press any key %s: `%s'"; #endif variable to_exit=""; variable last_was_return = 0; forever { timeout = 100; % 5 second delay #ifdef XWINDOWS flush (sprintf (fmt, key, to_exit, X_LAST_KEYSYM)); #else flush (sprintf (fmt, to_exit, key)); #endif key = ""; while (input_pending (timeout)) { timeout = 2; % 1/5 second ch = getkey (); switch (ch) { case 0: "^@"; } { case 27: "\\e"; } #ifdef IBMPC_SYSTEM { case 224: "\\xE0"; } #endif { case '\r': if (last_was_return) { message (""); return; } char(ch); } { % Eventually I should use \u{XXXX} for unicode if (ch > 127) "\\d" + string (ch); else char (ch); } ch = (); key += ch; } last_was_return = (key == "\r"); if (last_was_return) to_exit = "(RETURN to exit)"; else to_exit = ""; } } %% Key codes returned for most Alt keys and Control-keypad keys %% The ALT key definitions assume that the global variable ALT_CHAR is 0. % Alt-1 ^@x % Alt-2 ^@y % Alt-3 ^@z % Alt-4 ^@{ % Alt-5 ^@| % Alt-6 ^@} % Alt-7 ^@~ % Alt-8 ^@ % Alt-A ^@^^ % Alt-B ^@0 % Alt-C ^@. % Alt-D ^@ SPACE % Alt-E ^@^R % Alt-F ^@! % Alt-G ^@\" % Alt-H ^@# % Alt-I ^@^W % Alt-J ^@$ % Alt-K ^@% % Alt-L ^@& % Alt-M ^@2 % Alt-N ^@1 % Alt-O ^@^X % Alt-P ^@^Y % Alt-Q ^@^P % Alt-R ^@^S % Alt-S ^@^_ % Alt-T ^@^T % Alt-U ^@^V % Alt-V ^@/ % Alt-W ^@^Q % Alt-X ^@- % Alt-Y ^@^U % Alt-Z ^@, % % These are the 6 keys on the small keypad + 4 Arrow keys below % Key No-modifier Ctrl Shift Alt % ------------------------------------------------------------- % End \xE0O \xE0u \xE0O ^@\d159 % Insert \xE0R \xE0\d146 \xE0R ^@\d162 % Home \xE0G \xE0w \xE0G ^@\d151 % Delete \xE0S \xE0\d147 \xE0S ^@\d163 % PgUp \xE0I \xE0\d132 \xE0I ^@\d153 % PgDn \xE0Q \xE0v \xE0Q ^@\d161 % Left \xE0K \xE0s \xE0K ^@\d155 % Right \xE0M \xE0t \xE0M ^@\d157 % Up \xE0H \xE0\d141 \xE0H ^@\d152 % Down \xE0P \xE0\d145 \xE0P ^@\d160 % These keys are located on the numeric keypad % Key No-modifier Ctrl Shift Alt % ------------------------------------------------------------- % End Oq ^@u % Insert Op ^@\d146 % Home Ow ^@w % Delete On ^@\d147 % PgUP Oy ^@\d132 % PgDn Os ^@v % Left Ot ^@s % Right Ov ^@t % Up Ox ^@\d141 % Down Or ^@\d145 % Five Ou ^@\d143 % Slash OQ ^@\d149 OQ ^@\d164 % Star OR ^@\d150 OR ^@7 % Minus OS ^@\d142 OS ^@J % Plus Om ^@\d144 Om ^@N % Enter OM OM ^@\d166 % % % Key No-modifier Ctrl Shift Alt % ------------------------------------------------------------- % F1: ^@; ^@^ ^@T ^@h % F2: ^@< ^@_ ^@U ^@i % F3: ^@= ^@` ^@V ^@j % F4: ^@> ^@a ^@W ^@k % F5: ^@? ^@b ^@X ^@l % F6: ^@@ ^@c ^@Y ^@m % F7: ^@A ^@d ^@Z ^@n % F8: ^@B ^@e ^@[ ^@o % F9: ^@C ^@f ^@\ ^@p % F10: ^@D ^@g ^@] ^@q % F11: ^@\d133 ^@\d137 ^@\d135 ^@\d139 % F12: ^@\d134 ^@\d136 ^@\d136 ^@\d140 jed-0.99-19/lib/textmode.sl0000644002657400265740000000406411311317447014435 0ustar davisdavis%!%+ %\function{text_indent_relative} %\synopsis{Indent to next indentation point} %\description % The \var{text_indent_relative} function inserts enough whitespace to move % the editing point to the next indentation level defined by the whitespace % pattern of the previous non-blank line. If the current point is beyond % the last indentation level of the reference line, then a literal TAB will % be inserted into the buffer. %\seealso{set_buffer_hook, newline_and_indent} %!%- public define text_indent_relative () { variable c0, c; push_spot (); c0 = what_column (); bol (); bskip_chars ("\n\t "); if (bobp ()) { pop_spot (); insert ("\t"); return; } c = goto_column_best_try (c0); skip_white (); if (c == what_column ()) { skip_chars ("^ \t\n"); skip_white (); } c = what_column (); pop_spot (); if (c <= c0) { insert ("\t"); return; } whitespace (c - c0); } define text_newline_and_indent_relative () { push_spot (); bol_skip_white (); variable skip_indent = bolp (); pop_spot (); newline (); if (skip_indent) return; indent_line (); } $1 = "Text"; !if (keymap_p ($1)) make_keymap ($1); definekey ("indent_line", "\t", $1); %!%+ %\function{text_mode} %\synopsis{text_mode} %\description % Mode for indenting and wrapping text % Functions that affect this mode include: % %#v+ % Function: Default Binding: % text_indent_relative TAB % newline_and_indent RETURN % format_paragraph ESC Q % narrow_paragraph ESC N %#v- % %\seealso{no_mode, c_mode, set_buffer_hook} %\seealso{WRAP_INDENTS, WRAP, TAB, TAB_DEFAULT} %!%- public define text_mode() { variable mode = "Text"; no_mode (); set_mode(mode, 1); use_keymap (mode); %set_buffer_hook ("indent_hook", "text_indent_relative"); %set_buffer_hook ("newline_indent_hook", "text_newline_and_indent_relative"); unset_buffer_hook ("indent_hook"); unset_buffer_hook ("newline_indent_hook"); run_mode_hooks ("text_mode_hook"); } jed-0.99-19/lib/history.sl0000644002657400265740000001335111311317447014304 0ustar davisdavis% % history.sl % Store/Recall mini-buffer lines % % $Id: history.sl,v 1.16 2000/09/10 15:39:32 rocher Exp $ % private variable Max_Num_Lines = 32; % The same as in 'mini.sl' %!%+ %\variable{History_File} %\synopsis{History_File} %\usage{String_Type History_File = "jed.his";} %\description % The variable \var{History_File} is used by the function \var{history_save} % to know the file name in which to store all non-blank lines of the % mini-buffer. Its default value is "~/.jed-history" under Unix and % "~/jed.his" on other platforms. %\seealso{history_load, history_save} %!%- custom_variable ("History_File", #ifdef UNIX expand_filename ("~/.jed-history") #elifdef VMS "sys$login:jed.his" #else expand_filename ("~/jed.his") #endif ); %!%+ %\function{history_load} %\synopsis{history_load} %\usage{Void_Type history_load ();} %\description % This function reads a history file, i.e. each line of the file is % stored in the mini-buffer, but not evaluated. By default, historical % records are kept in a file whose name is stored in the \var{History_file} % variable. This file is written in the current working directory % associated with jed, i.e. the directory from which you started the jed % process. For example, to read your history file every time you start % jed and give an alternative name to the history file, put: %#v+ % variable History_File; % if (BATCH == 0) % { % () = evalfile ("history"); % History_File = ".my-jed-history"; % history_load (); % } %#v- % in your .jedrc (or jed.rc) file. The \var{History_File} variable can be % assigned either a file name or an absolute path+filename. In the first % case, a file will be saved in the current working directory (the one % you were in when you started jed), so you will find a history file in % every directory you work in. In the second one, only one file will be % created, but you can handle 'local' history files easily (see % \var{history_local_save} to know how to do it). %\seealso{history_save, history_local_save, minued_mode} %\seealso{History_File} %!%- define history_load () { % First look at the current working directory variable fp = fopen (path_concat (getcwd (), path_basename (History_File)), "r"); % If this didn't work, try using History_File. if (fp == NULL) fp = fopen (History_File, "r"); if (fp == NULL) return; variable lines = fgetslines (fp); if (lines == NULL) return; % remove trailing newline lines = array_map (String_Type, &strtrim_end, lines, "\n"); if (length (lines) > 1) mini_set_lines (lines[[1:]]); } %!%+ %\function{history_save} %\synopsis{history_save} %\usage{Int_Type history_save ()} %\description % This function saves the contents of the mini-buffer (see \var{history_load} % for more information) to the file specified by the variable \var{History_File} % or to the local history file (see \var{history_local_save} for more % information). It returns -1 upon failure, or 0 upon success. %\notes % When history.sl is loaded, \var{history_save} will automatically get attached % to the editors exit hooks. As a result, it is really not necessary to call % this function directly. %\seealso{history_load, history_local_save} %\seealso{History_File} %!%- define history_save () { variable lines = mini_get_lines (NULL), not_blank; variable fp = NULL, file, st; if (_NARGS) { file = (); fp = fopen (file, "w"); if (fp == NULL) { verror ("Unable to open `%s' for writing.", file); return -1; } } else { file = path_concat (getcwd (), path_basename (History_File)); st = stat_file (file); if (st != NULL) fp = fopen (file, "w"); if (fp == NULL) { file = History_File; fp = fopen (file, "w"); if (fp == NULL) { verror ("Unable to open `%s' for writing.", file); return -1; } } } () = chmod (file, 0600); () = fprintf (fp, "%% JED: File generated by 'history_save' on %s\n", time ()); not_blank = where (array_map (Integer_Type, &strlen, lines) > 0); foreach (lines [not_blank]) { variable line = (); () = fprintf (fp, "%s\n", line); } return 0; } %!%+ %\function{history_local_save} %\synopsis{history_local_save} %\usage{Void_Type history_local_save ()} %\description % This function saves the contents of the mini-buffer at some arbitrary file. % If you give the same filename as in \var{History_File} but use a different % path, then \var{history_load} will load this file into the mini-buffer every % time you start jed from that (and only from that) directory. This behavior is % only useful when the value of \var{History_File} is an absoulte filename % and you want a local history when you start jed from some specific directory. %\seealso{history_load, history_save} %\seealso{History_File} %!%- define history_local_save () { variable file, st; file = read_with_completion ("Save local history as:", "", path_basename (History_File), 'f'); st = stat_file (file); if (st != NULL) { variable yn = get_y_or_n ("File `" + file + "' already exists, overwrite it"); if (yn <= 0) error ("history_local_save canceled."); } !if (history_save (file)) flush (sprintf ("History saved in '%s'", file)); } private define save_history_at_exit () { variable e; try (e) { () = history_save (); return 1; } catch AnyError: { beep (); flush (sprintf ("Unable to save history: %S", e.message)); sleep (2); return 1; } } add_to_hook ("_jed_exit_hooks", &save_history_at_exit); jed-0.99-19/lib/site.sl0000644002657400265740000022527411311317447013560 0ustar davisdavis% -*- mode: slang; mode: fold; -*- % Note: This file has been folded. %_traceback = 1; %_boseos_info = 3; %{{{ Description of site.sl file % % This file must be present in $JED_ROOT/lib. JED loads it first--- even % before reading command line arguments. The command line arguments are then % passed to a hook declared in this file for further processing. % % In addition to some hooks, this file declares some autoloads for various % functions and defines utility functions. Any user specific stuff should be % placed in the jed.rc (.jedrc) user startup file. Only put here what you % believe EVERY user on your system should get! % % The best way to make changes in this file is to put all your changes in a % separate file, defaults.sl. defaults.sl is NOT distributed with JED. Code % at the end of this file checks for the existence of `defaults.sl' and loads % it if found. Functions occuring in this file (site.sl) may be overloaded in % defaults.sl. Making changes this way also makes it easier to upgrade to % future JED versions. % %}}} %{{{ Special note on syntax of some functions % -------------------------------------------------------------------------- % Note: Some of the small routines here have been written in such a way that % the stack based nature of the language is exploited. That is, instead of % writing: % define sum (a, b) { return a + b; } % I use: % define sum () { () + (); } % The former parses to the bytecode: =b =a a b + return % where as the latter parses to: + % which is 6 times faster and 6 times more memory efficient! % -------------------------------------------------------------------------- %}}} %{{{ Global Variables public variable _Jed_Emulation = NULL; public variable _Jed_Default_Emulation = "emacs"; public variable Default_Jedrc_Startup_File = "jed.rc"; public variable _Jed_Color_Scheme = NULL; public variable _Jed_Default_Color_Scheme = "black3"; %!%+ %\variable{Tab_Always_Inserts_Tab} %\synopsis{Configure the tab key} %\description % If this variable is non-zero, then the tab key will insert tab characters % into the buffer. It is possible to override this setting via a mode hook. %\seealso{local_setkey} %!%- public variable Tab_Always_Inserts_Tab = 0; variable _C_Indentation_Style = NULL; % This function will get overloaded by cmode.sl define c_set_style () { _C_Indentation_Style = (); } variable Null_String = ""; %!%+ %\variable{Info_Directory} %\synopsis{Info_Directory} %\description % A comma-separated list of info directories to search. %!%- variable Info_Directory; variable Jed_Bin_Dir; %!%+ %\variable{Jed_Highlight_Cache_Path} %\synopsis{Search path for DFA syntax tables} % A comma-separated list of directories to search for cached DFA syntax % highlighting tables. If a table is not found, it will be created on the % fly and then cached in the directory specified by the % \var{Jed_Highlight_Cache_Dir} variable. %\seealso{Jed_Highlight_Cache_Dir, use_dfa_syntax} %!%- variable Jed_Highlight_Cache_Path; % search paths for EXISTING files %!%+ %\variable{Jed_Highlight_Cache_Dir} %\synopsis{Directory where newly created DFA syntax tables are placed} % If the caching of DFA syntax tables is enabled, the newly created tables % will be saved in the directory specified by this variable. %\seealso{Jed_Highlight_Cache_Path, use_dfa_syntax} %!%- variable Jed_Highlight_Cache_Dir; % dir where NEW files kept %!%+ %\variable{C_CONTINUED_OFFSET} %\synopsis{C_CONTINUED_OFFSET} %\usage{Integer C_CONTINUED_OFFSET = 2;} %\description % This variable controls the indentation of statements that are continued % onto the next line as in the following example: %#v+ % if (something) % continued_statement (); % else % another_continued_statement (); %#v- %\seealso{C_BRA_NEWLINE, C_BRACE, C_INDENT, C_Colon_Offset} %!%- variable C_CONTINUED_OFFSET = 2; %!%+ %\variable{C_Colon_Offset} %\synopsis{C_Colon_Offset} %\description % Integer C_Colon_Offset = 1; % This variable may be changed to adjust the indentation of \var{case} statements % in C-Mode. %\seealso{c_mode} %\seealso{C_BRA_NEWLINE, C_BRACE, C_INDENT, C_Colon_Offset} %!%- variable C_Colon_Offset = 1; %!%+ %\variable{C_Preprocess_Indent} %\synopsis{C_Preprocess_Indent} %\usage{Integer C_Preprocess_Indent = 1;} %\description % This variable controls the indentation of preprocessor directives in % C-mode. %\seealso{c_mode} %\seealso{C_BRA_NEWLINE, C_BRACE, C_INDENT, C_Colon_Offset} %!%- variable C_Preprocess_Indent = 1; %!%+ %\variable{C_Comment_Column} %\synopsis{C_Comment_Column} %\description % Column to begin a C comment--- used by c_make_comment %!%- variable C_Comment_Column = 40; %!%+ %\variable{C_INDENT} %\synopsis{C_INDENT} %\usage{Integer C_INDENT = 3;} %\description % This value determines the number of columns the current line is indented % past the previous line containing an opening \exmp{'\{'} character. %\seealso{C_BRACE, C_BRA_NEWLINE.} %!%- variable C_INDENT = 3; %!%+ %\variable{C_BRACE} %\synopsis{C_BRACE} %\usage{Integer C_BRACE = 2;} %\description % This is a C-mode variable that specifies how much an opening brace % should be indented compared its surrounding block. %\seealso{C_INDENT, C_BRA_NEWLINE} %!%- variable C_BRACE = 2; %!%+ %\variable{C_BRA_NEWLINE} %\synopsis{C_BRA_NEWLINE} %\usage{Integer C_BRA_NEWLINE = 1;} %\description % This variable is used by the indentation routines for the C langauge. % If it is non-zero, the \exmp{'\{'} character will be placed on a line by % itself when one presses the \exmp{'\{'} character. For K&R indentation style, % set this variable to zero. %\seealso{C_INDENT, C_BRACE} %!%- variable C_BRA_NEWLINE = 1; variable compile_parse_error_function = "gcc"; % These are for compatibility variable REPLACE_PRESERVE_CASE = 0; variable LAST_SEARCH = Null_String; %!%+ %\function{custom_variable} %\synopsis{custom_variable} %\usage{Integer_Type custom_variable (String_Type name, Any_Type value)} %\description % This function is used to create a new public global variable called % \var{name}, initialized to \var{value}, unless it exists. If the variable % already exists but is not initialized, then it is initialized to % \var{value}. This is quite useful for slang files with user configurable % variables. These variables can be defined and initialized by users % before evaluating the file, or can be defined and initialized to % a default value in a file using this function. % % This function returns 2 if the variable \var{name} has been defined and % initialized, or 1 if it has only been intialized. If the variable % \var{name} has already been defined and initialized, this function does % nothing and returns 0. If \var{name} is an invalid variable name, this % function does nothing and returns -1. % % This function should be only used by slang programmers, not users. %\seealso{custom_color} %!%- public define custom_variable (name, value) { variable t; variable r; r = __get_reference (name); if (r == NULL) { eval (sprintf (".[%s]", name)); r = __get_reference (name); @r = value; return; } if (is_defined (name) != -2) return; if (__is_initialized (r)) return; @r = value; } %}}} %{{{ Some useful functions that are independent of jed intrinsics %{{{ str_replace_all (str, old, new) %!%+ %\function{str_replace_all} %\synopsis{str_replace_all} %\usage{String str_replace_all (str, old, new);} %\description % Replace all occurances of \var{old} in \var{str} with \var{new} and return the % result. %\seealso{str_replace, replace_cmd} %!%- define str_replace_all (str, old, new) { (str,) = strreplace (str, old, new, strlen (str)); return str; } %}}} %}}} %{{{ Compatibility functions #ifnexists strbytelen define strbytelen (s) { return strlen (s); } define substrbytes (s, n, len) { return substr (s, n, len); } #endif #ifnexists any define any (x) { return length (where (x)); } #endif define define_keywords () { define_keywords_n (0); } define save_search_string () { LAST_SEARCH = (); } % define this now so lib files can refer to it. define compile_parse_errors (); %}}} %{{{ Utility functions required below (dircat, etc) %{{{ vinsert %!%+ %\function{vinsert} %\synopsis{vinsert} %\usage{Void vinsert (String, fmt,...);} %\description % This function is like \var{insert} except that it takes a variable number % of arguments and a format string. %\seealso{insert, sprintf, insert_char} %!%- define vinsert () { _NARGS-1; Sprintf; insert; } %}}} %{{{ dircat %!%+ %\function{dircat} %\synopsis{Merge a directory name and file name} %\usage{String_Type = dircat (String_Type a, String_Type b);} %\description % The \var{dircat} function may be used to obtain the path name of a file with % filename \var{b} in directory \var{a}. It performs this function in an % operating system dependent manner. %!%- define dircat(dir, file) { % Many functions assume dir = NULL is ok, e.g., dircat (getenv (...)); if (dir == NULL) dir = ""; if (file == NULL) file = ""; variable n = strlen(dir); if (n) { #ifdef IBMPC_SYSTEM variable slash = "\\"; if (dir[-1] != '\\') dir += slash; #endif #ifdef UNIX variable slash = "/"; if (dir[-1] != '/') dir += slash; %if (strcmp(substr(dir, n, 1), slash)) dir = strcat(dir, slash); #endif #ifdef VMS % assume dir = d:[dir]a.dir;1 % convert a.dir;1 to [.a] first variable f1, d1; dir = extract_element(dir, 0, ';'); % dir = d:[dir]a.dir d1 = extract_element(dir, 0, ']'); % d1 = d:[dir f1 = extract_element(dir, 1, ']'); % f1 = a.dir if (f1 != NULL) { if (strlen (f1)) d1 += "." + extract_element(f1, 0, '.'); % d1 = d:[dir.a } n = strlen (dir); if (n) { if (dir [-1] != ':') d1 += "]"; } % if (':' != int(substr(dir, strlen(dir), 1))) d1 += "]"; dir = d1; #endif } return expand_filename (dir + file); } %}}} %{{{ bol_skip_white () %!%+ %\function{bol_skip_white} %\synopsis{bol_skip_white} %\usage{Void bol_skip_white ();} %\description % This function combines the two functions \var{bol} and \var{skip_white} into a % single operation. That is, it moves the point to the beginning of the % line and then skips over whitespace to the first non-whitespace character. %\seealso{bol, skip_white, skip_chars} %!%- define bol_skip_white () { bol (); skip_white (); } %}}} %{{{ bskip_white () %!%+ %\function{bskip_white} %\synopsis{bskip_white} %\usage{Void bskip_white ();} %\description % This function skips backward over whitespace. % Note: it does not cross lines. %\seealso{skip_white, bskip_chars} %!%- define bskip_white () { bskip_chars ("\t "); } %}}} %{{{ buffer_filename () %!%+ %\function{buffer_filename} %\synopsis{buffer_filename} %\usage{String_Type buffer_filename ([String_Type bufname])} %\description % When called with no arguments, this function returns the name of the % file associated with the current buffer. If called with a string % argument representing the name of a buffer, it will return the name % of the file associated with that buffer. If no file is associated % with the specified buffer, the empty string will be returned. %\seealso{getbuf_info} %!%- define buffer_filename () { variable args = __pop_args (_NARGS); variable file, dir; (file, dir, , ) = getbuf_info(__push_args (args)); !if (strlen (file)) dir = ""; return dir + file; } %}}} %{{{ path2list(path) %% Convert Unix- or OS/2- style path to comma-delimited list define path2list () { % path is on stack #ifndef VMS strtrans ( (), # ifdef UNIX ":", # else ";", # endif ","); #endif } %}}} %{{{ file_type(file) %!%+ %\function{file_type} %\synopsis{file_type} %\description % returns type of file. e.g., /usr/a.b/file.c --> c %\seealso{path_extname} %!%- define file_type(file) { file = path_extname (file); if (strlen (file)) file = file [[1:]]; file; } %}}} %!%+ %\function{search_path_for_file} %\synopsis{search_path_for_file} %\usage{String_Type search_path_for_file (path, file [,delim])} %\description % The \var{search_path_for_file} function searches the directories % specified by the delimiter-separated set of directories \var{path} % for the filename \var{file}. If the file exists, it returns the % expanded filename, otherwise it returns \NULL. The optional % parameter may be used to specify the path delimiter. The default % delimiter is system-dependent and is the same as that returned by % the \ifun{path_get_delimiter} function. %!%- define search_path_for_file () { variable path, f, delim = path_get_delimiter (); if (_NARGS == 3) delim = (); (path, f) = (); if (path == NULL) return NULL; foreach (strtok (path, char(delim))) { variable dir = (); variable file = dircat(dir, f); if (file_status(file) == 1) return file; } return NULL; } %{{{ expand_jedlib_file (f) %!%+ %\function{expand_jedlib_file} %\synopsis{expand_jedlib_file} %\description % Search for FILE in jed lib search directories and return % expanded pathname if found or the Null string otherwise. %!%- define expand_jedlib_file (f) { f = search_path_for_file (get_slang_load_path (), f); if (f == NULL) return ""; f; } %}}} %{{{ find_jedlib_file(file) %!%+ %\function{find_jedlib_file} %\synopsis{find_jedlib_file} %\description % find a file from JED_LIBRARY, returns number of lines read or 0 if not % found. %!%- define find_jedlib_file(file) { file = expand_jedlib_file(file); !if (strlen(file)) return(0); find_file(file); } %}}} %{{{ parse_filename(fn) %!%+ %\function{parse_filename} %\synopsis{parse_filename} %\usage{(dir, file) = parse_filename(fn)} %\description % breaks a filespec into dir filename--- % this routine returns dir and filename such that a simple strcat will % suffice to put them together again. For example, on unix, /a/b/c % returns /a/b/ and c %!%- define parse_filename(fn) { return (path_dirname (fn), path_basename (fn)); } %}}} %}}} %{{{ Jed library path, info, and bin directories #ifndef VMS % Add the current directory to the search path. %set_jed_library_path (strcat (get_jed_library_path (), ",.")); #endif #ifdef VMS Info_Directory = JED_ROOT + "[info]"; Jed_Bin_Dir = JED_ROOT + "[bin]"; #else Info_Directory = dircat (JED_ROOT, "info"); Jed_Bin_Dir = dircat (JED_ROOT, "bin"); #endif Jed_Highlight_Cache_Path = get_slang_load_path (); Jed_Highlight_Cache_Dir = extract_element (Jed_Highlight_Cache_Path, 0, path_get_delimiter()); private define dir_exists (dir) { variable s = stat_file (dir); if (s == NULL) return 0; return stat_is ("dir", s.st_mode); } %!%+ %\function{prepend_to_slang_load_path} %\synopsis{Prepend a directory to the load-path} %\usage{prepend_to_slang_load_path (String_Type dir)} %\description % This function adds a directory to the beginning of the interpreter's % load-path. %\seealso{append_to_slang_load_path, set_slang_load_path} %!%- public define prepend_to_slang_load_path (p) { if (dir_exists (p)) set_slang_load_path (sprintf ("%s%c%s", p, path_get_delimiter (), get_slang_load_path ())); } %!%+ %\function{append_to_slang_load_path} %\synopsis{Append a directory to the load-path} %\usage{append_to_slang_load_path (String_Type dir)} %\description % This function adds a directory to the end of the interpreter's % load-path. %\seealso{prepend_to_slang_load_path, set_slang_load_path} %!%- public define append_to_slang_load_path (p) { if (dir_exists (p)) set_slang_load_path (sprintf ("%s%c%s", get_slang_load_path (), path_get_delimiter (), p)); } variable Jed_Doc_Files = ""; define jed_append_doc_file (file) { if (Jed_Doc_Files == "") Jed_Doc_Files = file; else Jed_Doc_Files = strcat (Jed_Doc_Files, ",", file); variable cur_files = get_doc_files(); set_doc_files([ cur_files[where(cur_files != file)], file ]); } define jed_insert_doc_file (file) { if (Jed_Doc_Files == "") Jed_Doc_Files = file; else Jed_Doc_Files = strcat (file, ",", Jed_Doc_Files); variable cur_files = get_doc_files(); set_doc_files( [file, cur_files[ where(cur_files != file) ]] ); } #ifdef VMS $1 = JED_ROOT; #else $1 = dircat (JED_ROOT, "doc/hlp"); #endif foreach (["jedfuns.hlp", "libfuns.hlp"]) { $2 = (); #ifdef VMS $2 = "[doc.hlp]" + $2; #endif jed_append_doc_file (dircat ($1, $2)); } #ifexists _slang_doc_dir if (strlen(_slang_doc_dir) > 0) $1 = _slang_doc_dir; # ifdef VMS else $1 = path_concat ($1, "[doc.txt]"); # endif jed_append_doc_file (path_concat ($1, "slangfun.txt")); #endif __uninitialize (&$1); __uninitialize (&$2); #ifdef UNIX Info_Directory += ",/usr/info,/usr/share/info,/usr/local/info"; #endif $1 = getenv("INFOPATH"); if ($1 != NULL) Info_Directory = path2list($1); %}}} %{{{ Some key definitions define unset_ctrl_keys () { foreach ("ABCDEFGJKLNOPQRSTUVWXYZ")% does not include ^I, ^H, ^M { variable ch = (); unsetkey (char (ch - '@')); } } setkey("skip_word", "\e\e[C"); %escape right arrow. setkey("bskip_word", "\e\e[D"); %escape left arrow setkey("upcase_word", "\eu"); setkey("downcase_word", "\el"); setkey("capitalize_word", "\ec"); setkey("emacs_escape_x", "\ex"); setkey("help_prefix", "\e?"); if (_Backspace_Key != "\x08") setkey ("help_prefix", "^H"); setkey("do_shell_cmd", "\e!"); setkey("ctags_popup_tag", "\e."); setkey("dabbrev", "\e/"); #ifdef UNIX OS2 setkey("ispell", "\e$"); #endif #ifdef IBMPC_SYSTEM setkey(" /", "\eOQ"); setkey(" *", "\eOR"); setkey(" +", "\eOm"); setkey(" -", "\eOS"); setkey("toggle_overwrite", "\xE0R"); %/* insert key */ setkey("toggle_overwrite", "\eOp"); %/* insert key */ #endif %}}} %{{{ Autoloads $0 = _stkdepth (); _autoload("mode_get_mode_info", "modeinfo", "mode_set_mode_info", "modeinfo", "text_mode", "textmode", "c_mode", "cmode", "slang_mode", "slmode", "java_mode", "javamode", "find_binary_file", "binary", "jed_easy_help", "jedhelp", "query_replace_match", "regexp", "re_search_forward", "regexp", "re_search_backward", "regexp", "dired", "dired", "calendar", "cal", % "menu_main_cmds", "menu", "trim_buffer", "util", "occur", "occur", "info_reader", "info", "info_find_node", "info", "list_buffers", "bufed", "append_region", "buf", "write_region", "buf", "save_buffers", "buf", "recover_file", "buf", "next_buffer", "buf", "save_buffer_as", "buf", "most_mode", "most", "run_most", "most", "compile", "compile", "compile_select_compiler", "compile", "compile_add_compiler", "compile", "sort", "sort", "sort_using_function", "sort", "untab", "untab", "fortran_mode", "fortran", "sh_mode", "shmode", "ps_mode", "pscript", "python_mode", "pymode", "rot13", "rot13", "search_forward", "search", "search_backward", "search", "replace_cmd", "search", "replace_across_buffer_files","replace", "isearch_forward", "isearch", "isearch_backward", "isearch", "shell", "shell", "mute_set_mute_keys", "mutekeys", "html_mode", "html", "do_shell_cmd", "shell", "shell_perform_cmd", "shell", "ctags_backward", "ctags", "ctags_forward", "ctags", "ctags_popup_tag", "ctags", "ctags_find", "ctags", "find_tag", "ctags", "apropos", "help", "expand_keystring", "help", "describe_bindings", "help", "describe_function", "help", "describe_variable", "help", "help_for_function", "help", "where_is", "help", "showkey", "help", "describe_mode", "help", "format_paragraph_hook", "tmisc", "dabbrev", "dabbrev", "tex_mode", "tex", "bibtex_mode", "bibtex", "latex_mode", "latex", "bkmrk_goto_mark", "bookmark", "bkmrk_set_mark", "bookmark", "add_keyword", "syntax", "lisp_mode", "lisp", "perl_mode", "perl", "vhdl_mode", "vhdlmode", "spice_mode", "spicemod", "verilog_mode", "verilog", "tcl_mode", "tclmode", "lua_mode", "lua", "hook_add_hook", "hooks", % obsolete "changelog_add_change", "chglog", %% %% By default, tabs are every TAB columns (default 8). Calling this function %% will allow the user to set the tabs arbitrarily and bind the TAB key %% appropriately. "edit_tab_stops", "tabs", "tab_to_tab_stop", "tabs", "append_string_to_file", "misc", "write_string_to_file", "misc", "make_tmp_buffer_name", "misc", "open_unique_filename", "tmpfile", "make_tmp_file", "tmpfile", #ifnexists glob_to_regexp "glob_to_regexp", "misc", #endif "list_directory", "misc", "directory", "misc", #ifexists abbrev_table_p "abbrev_mode", "abbrev", "set_abbrev_mode", "abbrev", "save_abbrevs", "abbrmisc", "define_abbreviation", "abbrmisc", #endif #ifdef VMS "mail", "mail", % See also sendmail.sl "mail_format_buffer", "mail", "dcl_mode", "dcl", "vms_help", "vmshelp", #endif #ifdef UNIX OS2 "unix_man", "man", "ispell", "ispell", #endif #ifdef UNIX "rmail", "rmail", "mail", "sendmail", "mail_format_buffer", "sendmail", % "gdb_mode", "gdb", #endif "mailedit_mode", "mailedit", #ifdef VMS UNIX "f90_mode", "f90", #endif "idl_mode", "idl", "nroff_mode", "nroff", "modeline_hook2", "modehook", "digraph_cmd", "digraph", "bufed", "bufed", "push_mode", "pushmode", "set_selective_display", "seldisp", "sgml_mode", "sgml", "docbook_mode", "docbook", "matlab_mode", "matlab", #ifndef VMS "backups_on", "backups", "backups_off", "backups", #endif % Compatibility functions "create_array", "compat", "strncat", "compat", "info_mode", "compat", "get_jed_library_path", "compat", "set_jed_library_path", "compat", "tiasm_mode", "tiasm", "set_comment_info", "comments", "comment_region", "comments", "uncomment_region", "comments", "comment_line", "comments", "uncomment_line", "comments", "uncomment_region_or_line", "comments", "comment_region_or_line", "comments", "yp_copy_region_as_kill", "yankpop", "yp_kill_region", "yankpop", "yp_kill_line", "yankpop", "yp_yank", "yankpop", "yp_yank_pop", "yankpop", "yp_bkill_word", "yankpop", "yp_kill_word", "yankpop", #ifdef UNIX "rcs_check_in_and_out", "rcs", "rcs_open_file", "rcs", "auto_compression_mode", "compress", #endif "history_load", "history", (_stkdepth () - $0) / 2); % matches start of _autoload $0 = _stkdepth (); _autoload("reg_insert_register", "register", "reg_copy_to_register", "register", "register_mode", "register", "php_mode", "php", "tm_mode", "tmmode", "vrun_program", "runpgm", "paste", "paste", "toggle_case_search", "srchmisc", "xform_region", "xformreg", "require", "require", "provide", "require", (_stkdepth () - $0) / 2); % matches start of _autoload %}}} %{{{ More Utility functions %{{{ Simple editing and movement functions %!%+ %\function{go_up} %\synopsis{go_up} %\usage{Void go_up (Integer n);} %\description % Move up 'n' lines. %\seealso{up, go_down} %!%- define go_up() { () = up(); } %!%+ %\function{up_1} %\synopsis{up_1} %\usage{Void up_1 ();} %\description % Move up 1 line. If successful, returns 1 otherwise it returns 0. %\seealso{up, go_down, go_up, go_up_1} %!%- define up_1() { up(1); } %!%+ %\function{go_up_1} %\synopsis{go_up_1} %\usage{Void go_up_1 ();} %\description % Move up exactly 1 line if possible. %\seealso{up, go_down} %!%- define go_up_1 () { () = up_1(); } %!%+ %\function{go_down} %\synopsis{go_down} %\usage{Void go_down (Integer n);} %\description % Move down 'n' lines. %\seealso{go_up, down} %!%- define go_down() { () = down(); } %!%+ %\function{down_1} %\synopsis{down_1} %\usage{Int_Type down_1 ();} %\description % Move down exactly one line. If sucessful, 1 is returned otherwise % zero is returned. %\seealso{go_up, down, go_down_1} %!%- define down_1 () { down (1); } %!%+ %\function{go_down_1} %\synopsis{go_down_1} %\usage{Void go_down_1 ();} %\description % Move down one lines. %\seealso{go_up, down} %!%- define go_down_1 () { () = down_1(); } %!%+ %\function{go_left} %\synopsis{go_left} %\usage{Void go_left (Integer n);} %\description % Move backward 'n' characters. %\seealso{left, go_right} %!%- define go_left() { () = left();} %!%+ %\function{go_right} %\synopsis{go_right} %\usage{Void go_right (Integer n);} %\description % Move forward 'n' characters. %\seealso{right, go_left} %!%- define go_right() { () = right();} %!%+ %\function{go_right_1} %\synopsis{go_right_1} %\usage{Void go_right_1 ();} %\description % Move forward 1 characters. %\seealso{right, go_left} %!%- define go_right_1() { go_right (1); } %!%+ %\function{go_left_1} %\synopsis{go_left_1} %\usage{Void go_left_1 ();} %\description % Move forward 1 characters. %\seealso{left, go_left} %!%- define go_left_1() { go_left (1); } %!%+ %\function{newline} %\synopsis{newline} %\usage{Void newline (Void);} %\description % insert a newline in the buffer at point. %\seealso{insert, insert_char} %!%- define newline () { insert_char('\n'); } %!%+ %\function{insert_single_space} %\synopsis{insert_single_space} %\description % insert a single space into the buffer. %!%- define insert_single_space () { insert_char(' '); } %!%+ %\function{looking_at_char} %\synopsis{looking_at_char} %\usage{Integer looking_at_char (Integer ch);} %\description % This function returns non-zero if the character at the current editing % point is 'ch' otherwise it retuns zero. This function performs a case % sensitive comparison. %!%- define looking_at_char () { what_char () == (); } %}}} %!%+ %\function{local_setkey} %\synopsis{local_setkey} %\usage{Void local_setkey (String fun, String key);} %\description % This function is like 'setkey' but unlike 'setkey' which operates on the % global keymap, 'local_setkey' operates on the current keymap which may or % may not be the global one. %\seealso{setkey, definekey, local_unsetkey} %!%- define local_setkey () { definekey((), (), what_keymap()); } %!%+ %\function{local_unsetkey} %\synopsis{local_unsetkey} %\usage{Void local_unsetkey (String key);} %\description % This function is like 'unsetkey' but unlike 'unsetkey' which unsets a key % from the global keymap, 'local_unsetkey' operates on the current keymap % which may or may not be the global one. %\seealso{unsetkey, undefinekey, local_setkey} %!%- define local_unsetkey () { undefinekey( (), what_keymap()); } variable _Reserved_Key_Prefix = NULL; private define make_reserved_key (key) { if (_Reserved_Key_Prefix == NULL) return ""; strcat (_Reserved_Key_Prefix, key); } define definekey_reserved (fun, key, kmap) { definekey (fun, make_reserved_key(key), kmap); } define undefinekey_reserved (key, kmap) { undefinekey (make_reserved_key (key), kmap); } define local_setkey_reserved (fun, key) { local_setkey (fun, make_reserved_key (key)); } define local_unsetkey_reserved (key) { local_unsetkey (make_reserved_key (key)); } define setkey_reserved (fun, key) { setkey (fun, make_reserved_key (key)); } define unsetkey_reserved (key) { unsetkey (make_reserved_key (key)); } define get_mode_name () { what_mode (); pop (); } define global_mode_hook (hook) { } %!%+ %\function{call_function} %\synopsis{Call a function with arguments} %\usage{call_function (String_Type f, [optional args...])} %!%- define call_function () { variable args = __pop_args (_NARGS - 1); variable func = (); if (typeof (func) != Ref_Type) func = __get_reference (func); if (func != NULL) (@func) (__push_args (args)); } %!%+ %\function{runhooks} %\synopsis{runhooks} %\usage{Void runhooks (String_Type hook, [optional args...]);} %!%- define runhooks () { variable args = __pop_args (_NARGS); call_function (__push_args (args)); } %!%+ %\function{run_mode_hooks} %\synopsis{Run the user's mode hooks for the specified mode} %\usage{run_mode_hooks (mode_hook_name)} %\description % This function should be called at the end of the mode setting % function to allow the user to hook into the function. It takes a % single parameter: the name of the mode hook. Prior to call the % specified user-hook, this function calls \sfun{global_mode_hook}. %\seealso{runhooks, global_mode_hook} %!%- define run_mode_hooks (hook) { if (Tab_Always_Inserts_Tab) { local_unsetkey ("\t"); local_setkey ("self_insert_cmd", "\t"); } global_mode_hook (hook); runhooks (hook); % This is called after the hook to give the hook a chance to load the % abbrev table. #ifexists abbrev_table_p if (abbrev_table_p (get_mode_name ())) use_abbrev_table (get_mode_name ()); #endif } % This is for backwards compatibility in case the user has exit_hook private define run_user_exit_hook () { runhooks ("exit_hook"); return 1; } add_to_hook ("_jed_exit_hooks", &run_user_exit_hook); %!%+ %\variable{Jed_Tmp_Directory} %\synopsis{Directory used to hold temporary files} %\usage{Jed_Tmp_Directory = "/tmp";} %\description % This variable is used by the \sfun{make_tmp_file} function to create % temporary filenames. %\seealso{make_tmp_file, make_tmp_buffer_name, open_unique_filename} %!%- variable Jed_Tmp_Directory = NULL; #ifdef UNIX Jed_Tmp_Directory = "/tmp"; #endif %{{{ More functions %!%+ %\function{pop_mark_0} %\synopsis{pop_mark_0} %\usage{Void pop_mark_0 ();} %\description % Since \var{pop_mark} is used so often with an argument of \var{0}, this function % is simply equivalent to \var{pop_mark(0)}. %\seealso{pop_mark, pop_mark_1} %!%- define pop_mark_0 () { pop_mark (0); } %!%+ %\function{pop_mark_1} %\synopsis{pop_mark_1} %\usage{Void pop_mark_1 ();} %\description % Since \var{pop_mark} is used so often with an argument of \var{1}, this function % is simply equivalent to \var{pop_mark(1)}. %\seealso{pop_mark, pop_mark_0} %!%- define pop_mark_1 () { pop_mark (1); } %!%+ %\function{goto_spot} %\synopsis{goto_spot} %\usage{Void goto_spot ();} %\description % This function returns to the position of the last pushed spot. The spot % is not popped. %\seealso{push_spot, pop_spot, create_user_mark} %!%- define goto_spot () { pop_spot (); push_spot (); } %!%+ %\function{push_spot_bob} %\synopsis{push_spot_bob} %\usage{Void push_spot_bob ();} %\description % The function sequence \var{push_spot (); bob ();} occurs so often that % it makes sense to have a single function that performs this task. %\seealso{push_spot, bob, pop_spot, push_spot_bol} %!%- define push_spot_bob () { push_spot (); bob (); } %!%+ %\function{push_spot_bol} %\synopsis{push_spot_bol} %\usage{Void push_spot_bol ();} %\description % The function sequence \var{push_spot (); bol ();} occurs so often that % it makes sense to have a single function that performs this task. %\seealso{push_spot, bol, pop_spot, push_spot_bob} %!%- define push_spot_bol () { push_spot (); bol (); } %!%+ %\function{push_mark_eol} %\synopsis{push_mark_eol} %\usage{Void push_mark_eol ();} %\description % The function sequence \var{push_mark (); eol ();} occurs so often that % it makes sense to have a single function that performs this task. %\seealso{push_mark, eol, pop_mark, push_mark_eob} %!%- define push_mark_eol () { push_mark (); eol (); } %!%+ %\function{push_mark_eob} %\synopsis{push_mark_eob} %\usage{Void push_mark_eob ();} %\description % The function sequence \var{push_mark (); eob ();} occurs so often that % it makes sense to have a single function that performs this task. %\seealso{push_mark, eob, pop_mark, push_mark_eob} %!%- define push_mark_eob () { push_mark (); eob (); } %!%+ %\function{mark_buffer} %\synopsis{mark_buffer} %\usage{mark_buffer ();} %\description % This function marks the whole buffer leaving the point at the end % of the buffer. %\seealso{push_mark, pop_mark, bob, eob} %!%- define mark_buffer () { bob (); push_mark_eob (); } %!%+ %\function{bufsubstr_delete} %\synopsis{bufsubstr_delete} %\usage{String bufsubstr_delete ()} %\description % This functions returns the contents of a region defined my the mark % and the current point. The region will be deleted. %\seealso{bufsubstr} %!%- define bufsubstr_delete () { () = dupmark (); bufsubstr (); % on stack del_region (); } %!%+ %\function{del_eol} %\synopsis{del_eol} %\usage{Void del_eol ();} %\description % This function deletes from the current position to the end of the line. %\seealso{del, delete_line, del_through_eol} %!%- define del_eol () { push_mark_eol (); del_region (); } %!%+ %\function{del_through_eol} %\synopsis{del_through_eol} %\usage{del_through_eol ();} %\description % This function deletes all text from the current point through the end of % the line. %\seealso{del, del_eol, del_region} %!%- define del_through_eol () { del_eol (); !if (eobp ()) del (); } %!%+ %\function{line_as_string} %\synopsis{line_as_string} %\usage{String line_as_string ()} %\description % This function returns the current line as a string. This does not include % the newline character at the end of the line. The editing point is left % at the end of the line. That is, this function does not preserve the point. %\seealso{bufsubstr} %!%- define line_as_string () { bol (); push_mark_eol (); bufsubstr (); } %!%+ %\function{double_line} %\synopsis{Duplicate the current line} %\description % This function inserts a line into the buffer at the position of the % current line that is a copy of the current line. If the position of % the editing point was originally one line N column C, then the % editing point will be left on line (N+1) column C. %\seealso{line_as_string} %!%- define double_line () { _get_point (); line_as_string (); % on stack newline(); insert(()); _set_point (()); } %!%+ %\function{bol_trim} %\synopsis{bol_trim} %\usage{Void bol_trim ();} %\description % Move to beginning of line and remove whitespace. %\seealso{bol, trim} %!%- define bol_trim () { bol (); trim (); } %!%+ %\function{eol_trim} %\synopsis{eol_trim} %\usage{Void eol_trim ();} %\description % Move to end of line and remove whitespace. %\seealso{eol, trim} %!%- define eol_trim () { eol (); trim (); } define re_looking_at (re) { push_spot (); push_mark_eol (); go_right_1 (); % make sure newline is included 1 == string_match (bufsubstr (), re, 1); % on stack pop_spot (); } define enable_xmouse () { #ifndef IBMPC_SYSTEM if (BATCH or is_defined ("X_LAST_KEYSYM")) % Xjed return; variable term = getenv ("TERM"); if (term == NULL) return; if (strncmp (term, "xterm", 5)) return; () = evalfile ("mousex"); #endif } #ifdef HAS_BLOCAL_VAR %!%+ %\function{get_blocal_var} %\synopsis{Return the value of a buffer-local variable} %\usage{value = get_blocal_var (String name, [default])} %\description % This function returns the value of the buffer-local variable % specified by \exmp{name}. If the the optional \exmp{default} % argument is given, it will be returned if no local variable of the % specified name exists. Otherwise an error will be thrown. %\example %#v+ % if (get_blocal_var("foo", 0)) % message("this buffer is fooish"); %#v- % will print the message if \exmp{foo} is a buffer-local variable % with a nonzero value. %\seealso{define_blocal_var, blocal_var_exists} %!%- define get_blocal_var () { variable name, value; if (_NARGS == 2) { (name, value) = (); !if (blocal_var_exists (name)) return value; } else name = (); return _get_blocal_var (name); } %!%+ %\function{define_blocal_var} %\synopsis{Create and initialize a buffer local variable} %\usage{define_blocal_var (name, value)} %\description % This function may be used to create a buffer-local variable named % \exmp{name} and set it to \exmp{value}. A buffer-local variable is a % variable whose value is local to the current buffer. %\notes % The order of the \var{name} and \var{value} arguments to this % function are the reverse from that of the \ifun{set_blocal_var} % function. %\seealso{get_blocal_var, create_blocal_var, set_blocal_var} %!%- define define_blocal_var (name, value) { create_blocal_var (name); set_blocal_var (value, name); } #endif %}}} %{{{ Backup and autosave functions #ifdef MSDOS OS2 WIN32 IBMPC_SYSTEM # ifdef MSDOS WIN32 variable MSDOS_Has_Long_File_Names = 0; # endif define pc_system_support_long_filenames (dir) { # ifdef OS2 return IsHPFSFileSystem(dir); # else MSDOS_Has_Long_File_Names; # endif } #endif variable No_Backups = 0; % returns backup filename. Arguments to function are dir and file. define make_backup_filename(dir, file) { #ifdef VMS return ""; #elifdef UNIX if (dir == "/tmp/") return ""; if (path_extname (file) == ".tmp") return ""; #elifdef IBMPC_SYSTEM variable type; !if (pc_system_support_long_filenames (dir)) { % There are several things to worry about. Here just break up the % filename and truncate type to 2 chars and paste it back. % note that this takes a name like file.c and produces file.c~ % Also, note that if the type is empty as in 'file', it produces % 'file.~' type = path_extname (file); !if (strlen (type)) type = "."; type = substr (type, 1, 3); file = strcat (path_sans_extname (file), type); } #endif strcat (dir, file, "~"); } % returns autosave filename. Arguments to function are dir and file. define make_autosave_filename(dir, file) { #ifdef VMS sprintf ("%s_$%s;1", dir, file); #elifdef UNIX file = expand_symlink (path_concat (dir, file)); return path_concat (path_dirname (file), sprintf ("#%s#", path_basename (file))); #else # ifdef IBMPC_SYSTEM if (pc_system_support_long_filenames (dir)) file += "#"; else file = strcat (substr(path_sans_extname (file), 1, 7), path_extname (file)); # endif dir + "#" + file; #endif } %}}} %{{{ Some interactive functions (goto_line, column, M-x) %{{{ emacs_escape_x() define emacs_escape_x() { variable f = Null_String, i = 0; variable mx_prompt; variable pa, exec_fun; if (MINIBUFFER_ACTIVE) { call("evaluate_cmd"); return; } mx_prompt = "M-x"; pa = prefix_argument (-1); if (pa != -1) mx_prompt = "ESC-" + string(pa) + " M-x"; EXIT_BLOCK { set_prefix_argument (pa); (@exec_fun)(f); % If prefix argument still set, then use it as a repeat factor if (pa == prefix_argument (-1)) loop (pa - 1) (@exec_fun) (f); set_prefix_argument (-1); } forever { % Look for a namespace signature if (is_substr (f, "->")) { if (is_defined(f)) { exec_fun = &eval; return; } } f = strtrans (f, "-", "_"); if (is_internal(f)) { exec_fun = &call; return; } if (is_defined(f)) { exec_fun = &eval; return; } !if (EXECUTING_MACRO or DEFINING_MACRO) { if (i == 1) ungetkey(13); ungetkey(' '); ++i; } f = read_with_completion(mx_prompt, "", f, 'F'); } } %}}} define goto_line_cmd() { read_mini("Goto line:", Null_String, Null_String); goto_line(integer(())); } define goto_column_cmd() { read_mini("Goto Column:", Null_String, Null_String); goto_column(integer(())); } %;; scroll other window macros-- bind them yourself define next_wind_up() { otherwindow(); call("page_up"); loop (nwindows() - 1) otherwindow(); } define next_wind_dn() { otherwindow(); call("page_down"); loop (nwindows() - 1) otherwindow(); } %!%+ %\function{whatpos} %\synopsis{whatpos} %\description % display row and column information in minibuffer %!%- define whatpos () { variable max_lines; push_spot (); eob (); max_lines = what_line (); pop_spot (); vmessage ("%s, Line %d of %d lines, Column %d", count_chars (), what_line(), max_lines, what_column ()); } define goto_top_of_window () { loop (window_line()-1) skip_hidden_lines_backward (1); bol (); } define goto_bottom_of_window () { loop (window_info ('r') - window_line ()) skip_hidden_lines_forward (1); } %!%+ %\function{redo} %\synopsis{Undo the last undo} %\usage{redo()} %\description % Undo the last undo. This works only one step, however % as any undo is appended to the end of the undo buffer, you can % actually roll the whole history back. %\seealso{undo} %!%- public define redo () { try call("kbd_quit"); catch UserBreakError: { call("undo"); message ("Undo will now perform the action of redo"); }; } %}}} %{{{ Mode functions and settings %!%+ %\function{no_mode} %\synopsis{no_mode} %\description % Generic mode not designed for anything in particular. % Related Functions: \var{text_mode}, \var{c_mode} %!%- define no_mode () { use_syntax_table (Null_String); set_mode(Null_String, 0); use_keymap("global"); unset_buffer_hook (""); run_mode_hooks ("no_mode_hook"); } % Function prototypes % These 'functions' are only here to initialize function pointers. define _function_pop_0 (x) {0;} define _function_return_1 () {1;} %!%+ %\variable{Mode_Hook_Pointer} %\synopsis{Mode_Hook_Pointer} %\description % called from mode_hook. Returns 0 if it is desired that control return % to mode_hook or 1 if mode hook should exit after calling mode_hook_ptr %!%- variable Mode_Hook_Pointer = &_function_pop_0; variable Default_Mode = &text_mode; % Emacs allows a mode definition on the first line of a file % -*- mode: MODENAME; VAR: VALUE; ... -*- % which can also include values of local variables %!%+ %\function{modeline_hook} %\synopsis{modeline_hook} %\description % check first line for the simplest Emacs mode statement % -*- modename -*- %!%- define modeline_hook() { variable mode = Null_String, extra_hook; push_spot_bob (); go_down (4); #iffalse () = bsearch ("-*- END -*-"); #endif push_mark (); bob (); narrow (); % #!/bin/sh, #!/usr/local/bin/perl, #!/bin/csh -f ... #ifdef 0 if (looking_at("#!")) mode = "sh"; #endif if (re_fsearch("^\\(#! ?/[^ ]+/\\([^ \t]+\\)\\)")) { mode = regexp_nth_match (2); % Check for #! /usr/bin/env PGM args... if (mode == "env") { go_right (strlen (regexp_nth_match (1))); skip_white (); push_mark (); skip_chars ("^ \t\n"); mode = bufsubstr (); } !if (is_defined (mode + "_mode")) { if (is_list_element ("bash,ksh,ash,zsh,csh", mode, ',')) mode = "sh"; else if (is_list_element ("slsh,jdl,jed-script,jdl-script", mode, ',')) mode = "slang"; } } if (re_fsearch ("-\\*- *\\([-A-Za-z_+0-9]+\\) *-\\*-")) mode = strlow (regexp_nth_match (1)); bob (); % -*- mode: VALUE -*- or -*- eval: VALUE -*- extra_hook = re_fsearch ("-\\*- *.+:.+ *-\\*-"); widen (); EXIT_BLOCK { mode = (); if (extra_hook) (mode + modeline_hook2 ()); else mode; pop_spot (); % restore place } if ( strlen(mode) ) { variable mstr = "_mode"; mode = strtrans (mode, "-", "_"); !if (is_substr (mode, mstr)) mode += "_mode"; %mode = strcat (mode, "_mode" ); if (mode == "c++_mode") mode = "c_mode"; if (is_defined(mode)) { eval (mode); 1; % mode was defined return; } } 0; } variable Mode_List_Exts = "h,cc,cpp,hpp,hh,sl,txt,doc,f,for,pro,1,pl,pm,v,verilog,vhd,vhdl,vt,sp,cir,py,cxx,m,bib"; variable Mode_List_Modes = "c,c,c,c,c,slang,text,text,fortran,fortran,idl,nroff,perl,perl,verilog,verilog,vhdl,vhdl,vhdl,spice,spice,python,c,matlab,bibtex"; #ifdef MSDOS OS2 IBMPC_SYSTEM Mode_List_Exts += ",rc,bat,htm"; % resource file Mode_List_Modes += ",c,no,html"; #endif #ifdef VMS UNIX Mode_List_Exts += ",com,htm,shtml,sgml"; % resource file Mode_List_Modes += ",dcl,html,html,docbook"; #endif #ifdef UNIX Mode_List_Exts += ",cshrc,tcshrc,login,profile,conf"; Mode_List_Modes += ",sh,sh,sh,sh,sh"; Mode_List_Exts += ",letter,article,followup,jedrc"; Mode_List_Modes += ",text,text,text,slang"; #endif %!%+ %\function{add_mode_for_extension} %\synopsis{add_mode_for_extension} %\usage{Void add_mode_for_extension (String mode, String ext);} %\description % This function modifies Mode_List in such a way that when a file with % filename extension `ext' is read in, function strcat (mode, "_mode") % will be called to set the mode. That is, the first parameter 'mode' % is the name of a mode without the '_mode' added to the end of it. %!%- define add_mode_for_extension (mode, ext) { Mode_List_Modes = __tmp(mode) + "," + Mode_List_Modes; Mode_List_Exts = __tmp(ext) + "," + Mode_List_Exts; } %!%+ %\function{mode_hook} %\synopsis{mode_hook} %\description % This is a hook called by find_file routines to set the mode % for the buffer. This function takes one parameter, the filename extension % and returns nothing. %!%- define mode_hook (ext) { variable n, mode; #ifdef VMS ext = extract_element(ext, 0, ';'); #endif #ifndef UNIX ext = strlow (ext); #endif #ifdef UNIX % Strip off final ~ if (ext[-1] == '~') { if (strlen (ext) > 1) ext = ext[[:strlen(ext)-2]]; } #endif if (@Mode_Hook_Pointer(ext)) return; if (modeline_hook ()) return; n = is_list_element (Mode_List_Exts, ext, ','); if (n) { n--; mode = extract_element (Mode_List_Modes, n, ',') + "_mode"; if (is_defined(mode) > 0) { eval (mode); return; } } mode = strcat (strlow (ext), "_mode"); if (is_defined (mode) > 0) { eval (mode); return; } !if (strncmp (strup (extract_filename (buffer_filename ())), "READ", 4)) { text_mode (); return; } @Default_Mode (); } %}}} %{{{ Buffer flags and related functions define _test_buffer_flag (x) { variable flags; (,,,flags) = getbuf_info (); flags & x; } define _set_buffer_flag (x) { getbuf_info (); () | x; setbuf_info (()); } define _unset_buffer_flag (x) { getbuf_info (); () & ~x; setbuf_info (()); } % Usage: set_or_unset_buffer_flag (set, flag) define _set_or_unset_buffer_flag () { exch (); % (set,flag) ===> (flag,set) if (()) _set_buffer_flag (()); else _unset_buffer_flag (()); } define _toggle_buffer_flag (f) { setbuf_info(getbuf_info() xor f); } %!%+ %\function{set_buffer_modified_flag} %\synopsis{set_buffer_modified_flag} %\description % sets buf modified flag. If argument is 1, mark % buffer as modified. If argument is 0, mark buffer as unchanged. %!%- define set_buffer_modified_flag () { _set_or_unset_buffer_flag ((), 0x1); } %!%+ %\function{buffer_modified} %\synopsis{buffer_modified} %\usage{Int_Type buffer_modified ()} %\description % returns non-zero if the buffer modified flag is set. It returns zero % if the buffer modified flag is not been set. This works on the % current buffer. See also 'set_buffer_modified_flag'. %!%- define buffer_modified () { _test_buffer_flag (0x01); } %!%+ %\function{set_buffer_undo} %\synopsis{set_buffer_undo} %\description % set undo mode for buffer. If argument is 1, undo is on. 0 turns it off %!%- define set_buffer_undo () { _set_or_unset_buffer_flag ((), 0x20); } %!%+ %\function{set_readonly} %\synopsis{set_readonly} %\description % Takes 1 parameter: 0 turn off readonly % 1 turn on readonly %!%- define set_readonly () { _set_or_unset_buffer_flag ((), 0x08); } %!%+ %\function{is_readonly} %\synopsis{Test whether or not the buffer is in read-only mode} %\usage{Int_Type is_readonly ()} %\description % This function returns a non-zero value if the buffer is read-only; % otherwise it returns 0. %\seealso{set_readonly, getbuf_info, setbuf_info} %!%- define is_readonly () { _test_buffer_flag (0x08); } %!%+ %\function{is_overwrite_mode} %\synopsis{Checks whether or not the buffer is in overwrite mode} %\usage{Int_Type is_overwrite_mode ()} %\description % This function returns a non-zero value if the buffer is in overwrite-mode; % otherwise it returns 0. %\seealso{toggle_overwrite, getbuf_info, setbuf_info} %!%- define is_overwrite_mode () { _test_buffer_flag (0x10); } %!%+ %\function{set_overwrite} %\synopsis{set_overwrite} %\usage{set_overwrite (Int_Type x)} %\description % If the parameter \var{x} is non-zero, the buffer will be put in overwrite % mode; otherwise it will be ut in insert mode. %\seealso{toggle_overwrite, is_overwrite_mode, getbuf_info, setbuf_info} %!%- define set_overwrite () { _set_or_unset_buffer_flag ((), 0x10); } %!%+ %\function{toggle_crmode} %\synopsis{Toggle the buffer line endings between CRLF and LF} %\usage{toggle_crmode ()} %\description % The \var{toggle_crmode} function causes the line endings of the buffer to % alternate between CRLF and LF characters. %\seealso{getbuf_info, setbuf_info} %!%- define toggle_crmode () { _toggle_buffer_flag (0x400); set_buffer_modified_flag (1); } %!%+ %\function{toggle_readonly} %\synopsis{Toggle the readonly status of the buffer} %\usage{toggle_readonly ()} %\description % The \var{toggle_readonly} function toggles the read-only status of the % current buffer. %\seealso{set_readonly, is_readonly, getbuf_info, setbuf_info} %!%- define toggle_readonly() { _toggle_buffer_flag (0x08); } %!%+ %\function{toggle_overwrite} %\synopsis{Toggle the overwrite mode of the buffer} %\usage{toggle_overwrite ()} %\description % The \var{toggle_overwrite} function toggles the overwrite mode of the % current buffer. %\seealso{set_overwrite, is_overwrite_mode, getbuf_info, setbuf_info} %!%- define toggle_overwrite() { _toggle_buffer_flag (0x10); } %!%+ %\function{toggle_undo} %\synopsis{Toggle the undo mode of the buffer} %\usage{toggle_undo ()} %\description % The \var{toggle_undo} function toggles the undo mode of the % current buffer. %\seealso{getbuf_info, setbuf_info} %!%- define toggle_undo() { _toggle_buffer_flag (0x20); } %!%+ %\function{set_buffer_no_backup} %\synopsis{set_buffer_no_backup} %\usage{Void set_buffer_no_backup ();} %\description % %!%- define set_buffer_no_backup () { _set_buffer_flag (0x100); } %!%+ %\function{set_buffer_no_autosave} %\synopsis{set_buffer_no_autosave} %\usage{Void set_buffer_no_autosave ();} %\description % %!%- define set_buffer_no_autosave () { _unset_buffer_flag (0x02); } %}}} %!%+ %\function{toggle_line_number_mode} %\synopsis{toggle_line_number_mode} %\usage{Void toggle_line_number_mode ();} %\description % This function toggles the line number display state on or off. %\seealso{set_line_number_mode} %!%- define toggle_line_number_mode () { set_line_number_mode (-1); } add_completion ("toggle_line_number_mode"); % Make this a wrapper around _set_color to allow the user to give it a more % sophisticated definition. define set_color (){_set_color;} % Comma separated list of directories public variable Color_Scheme_Path = ""; foreach (strtok (get_slang_load_path (), char(path_get_delimiter()))) { $1 = (); Color_Scheme_Path = dircat ($1, "colors"); if (2 == file_status (Color_Scheme_Path)) break; } define set_color_scheme (scheme) { variable file; if (scheme == NULL) return; scheme = string (scheme); % for back-compatability, file may be an integer file = search_path_for_file (Color_Scheme_Path, scheme + ".sl", ','); if (file == NULL) { % Try .slc file file = search_path_for_file (Color_Scheme_Path, scheme + ".slc", ','); if (file == NULL) { vmessage ("Color scheme %S is not supported", scheme); return; } } % strip .sl[c] to get pre-parsed version _Jed_Color_Scheme = path_sans_extname (file); () = evalfile (_Jed_Color_Scheme); } %!%+ %\function{custom_color} %\synopsis{Create a color object to be customized by the user} %\usage{custom_color (color, fg, bg)} %\description % This function may be used to create a specified color object. If the object % does not already exist, it will be given the specified foreground and % background colors. %\seealso{custom_variable} %!%- define custom_color (color, fg, bg) { if (-1 != color_number (color)) return; add_color_object (color); set_color (color, fg, bg); } private variable Email_Address = NULL; define get_emailaddress () { if (Email_Address != NULL) return Email_Address; return strcat (get_username (), "@", get_hostname ()); } define set_emailaddress (s) { Email_Address = s; } %{{{ Help stuff %!%+ %\variable{help_for_help_string} %\synopsis{help_for_help_string} %\description % string to display at bottom of screen upon JED startup and when % user executes the help function. %!%- variable help_for_help_string; help_for_help_string = #ifdef VMS "-> Help:H Menu:? Info:I Apropos:A Key:K Where:W Fnct:F VMSHELP:M Var:V"; #elifdef IBMPC_SYSTEM "-> Help:H Menu:? Info:I Apropos:A Key:K Where:W Fnct:F Var:V Mem:M"; #else "-> Help:H Menu:? Info:I Apropos:A Key:K Where:W Fnct:F Var:V Man:M"; #endif %% %% help function %% %!%+ %\variable{Help_File} %\synopsis{Help_File} %\description % name of the file to load when the help function is called. %!%- variable Help_File = "jed.hlp"; %% other modes will override this. %{{{ help() %!%+ %\function{help} %\synopsis{help} %\usage{Void help ([String_Type help_file])} %\description % This function pops up a window containing the specified help file. If the % function was called with no arguments, the the file given by the \var{Help_File} % variable will be used. %!%- define help () { variable hlp = "*help*", buf, rows; % optional argument with default variable help_file=Help_File; if (_NARGS) help_file = (); if (help_file == NULL) help_file = ""; !if (strlen(help_file)) help_file = "generic.hlp"; help_file = expand_jedlib_file(help_file); !if (buffer_visible (hlp)) { buf = whatbuf(); onewindow(); rows = window_info('r'); setbuf(hlp); set_readonly(0); erase_buffer(); () = insert_file(help_file); pop2buf(hlp); eob(); bskip_chars("\n"); rows = rows / 2 - (what_line() + 1); bob(); set_buffer_modified_flag(0); set_readonly(1); pop2buf(buf); loop (rows) enlargewin(); } update_sans_update_hook (1); message(help_for_help_string); } %}}} variable Global_Top_Status_Line = " *** To activate menus, press `ESC ? ?'. For help, press `ESC ? h'. ***"; () = set_top_status_line (Global_Top_Status_Line); %{{{ help_prefix() define help_prefix() { variable c; !if (input_pending(7)) flush (help_for_help_string); c = toupper (getkey()); switch (c) { case 8 or case 'H': help (); } { case 'A' : apropos (); } { case 'B' : describe_bindings (); } { case 'I' : info_reader (); } { case '?' : call ("select_menubar");} { case 'F' : describe_function ();} { case 'V' : describe_variable ();} { case 'W' : where_is ();} { case 'C' or case 'K': showkey ();} { case 'M' : #ifdef UNIX OS2 unix_man(); #else # ifdef VMS vms_help (); # endif #endif #ifdef MSDOS MSWINDOWS call("coreleft"); #endif } { beep(); clear_message ();} } %}}} %}}} %{{{ Mini-Buffer related stuff % Load minibuffer routines now before any files are loaded. % This will reduce fragmentation on PC. % Make sure this is defined even in batch mode. public define mini_init_minibuffer (); !if (BATCH) () = evalfile("mini"); %{{{ Reading from Mini-Buffer functions %for compatability with older versions %!%+ %\function{read_file_from_mini} %\synopsis{read_file_from_mini} %\usage{String read_file_from_mini (String p);} %\description % This function prompts the user for a file name using \var{p} as a prompt. % It reads a filename with completion from the mini-buffer and returns % it. %\seealso{read_with_completion, read_mini} %!%- define read_file_from_mini () { read_with_completion( () , "", "", 'f'); } %!%+ %\function{read_string_with_completion} %\synopsis{read_string_with_completion} %\usage{String read_string_with_completion (prompt, dflt, list)} %\description % This function takes 3 String parameters and returns a String. The % first parameter is used as the prompt, the second parameter is the % default value to be returned and the third parameter is a list to be used % for completions. This list is simply a comma separated list of strings. %!%- define read_string_with_completion (prompt, dflt, list) { read_with_completion (list, prompt, dflt, Null_String, 's'); } %}}} %}}} %{{{ Startup hook %!%+ %\variable{Startup_With_File} %\synopsis{Startup_With_File} %\description % If non-zero, startup by asking user for a filename if one was % not specified on the command line. %!%- variable Startup_With_File = 0; %% startup hook %!%+ %\function{jed_startup_hook} %\synopsis{jed_startup_hook} %\description % Function that gets executed right before JED enters its main editing % loop. This is for last minute modifications of data structures that % did not exist when startup files were loaded. %!%- define jed_startup_hook() { variable n, hlp, ok = 0, file; variable scratch = "*scratch*"; % turn on Abort character processing IGNORE_USER_ABORT = 0; runhooks ("startup_hook"); try { ifnot ((whatbuf != scratch) || buffer_modified()) { try { () = insert_file (expand_jedlib_file("cpright.hlp")); set_buffer_modified_flag (0); bob(); file = ""; message (""); if (Startup_With_File > 0) { forever { file = read_file_from_mini ("Enter Filename:"); if (strlen(extract_filename(file))) break; } } else ifnot (Startup_With_File) { do { update_sans_update_hook (1); } while (not (input_pending(600))); % 1 minute } } finally { setbuf (scratch); erase_buffer (); set_buffer_modified_flag (0); } if (file != "") () = find_file(file); } } finally eval (".()jed_startup_hook"); } add_to_hook ("_jed_startup_hooks", &jed_startup_hook); %}}} #ifdef VMS %{{{ resume_hook() %% This resume hook is need for VMS when returning from spawn. %% In fact, it is NEEDED for certain JED functions on VMS so declare it. private define vms_resume_hook () { variable file = getenv("JED_FILE_NAME"); if (file != NULL) !if (find_file(file)) error("File not found!"); } %}}} add_to_hook ("_jed_resume_hooks", &vms_resume_hook); #endif VMS %{{{ find_file_hook(file) % called AFTER a file is read in to a buffer. FILENAME is on the stack. private define find_file_hook () { variable dir, a, f, m; (f, dir,,) = getbuf_info (); #ifndef VMS if (file_status(dir) != 2) { verror ("Directory %s is invalid", dir); } #endif if (No_Backups) set_buffer_no_backup (); a = make_autosave_filename(dir, f); if (file_time_compare(a, dircat (dir, f)) > 0) { m = sprintf ("Autosave file is newer. Use ESC-X recover_file. (%s)", f); flush(m); () = input_pending(30); message(m); } runhooks ("user_find_file_hook"); } %}}} add_to_hook ("_jed_find_file_after_hooks", &find_file_hook); %{{{ Completions % % completions -- everything here must be predefined % I just push the strings onto the stack and loop 'add_completion' over them % $0 = _stkdepth(); _add_completion ("toggle_undo", "calendar", "trim_buffer", #ifexists abbrev_table_p "abbrev_mode", "define_abbreviation", "save_abbrevs", #endif "occur", "append_region", "write_region", "replace_across_buffer_files", "recover_file", "compile", "sort", "untab", "fortran_mode", "save_buffers", "isearch_forward", "isearch_backward", "shell", "edit_tab_stops", "c_mode", "toggle_crmode", "text_mode", "no_mode", "goto_line_cmd", "goto_column_cmd", "describe_mode", "evalbuffer", "open_rect", "kill_rect", "insert_rect", "copy_rect", "blank_rect", "dired", "re_search_forward", "re_search_backward", "query_replace_match", "bufed", "describe_bindings", "search_backward", "search_forward", "replace_cmd", "find_binary_file", "latex_mode", "sh_mode", #ifdef UNIX VMS "mail", #endif #ifdef UNIX OS2 "ispell", #endif #ifdef UNIX "auto_compression_mode", % "gdb_mode", #endif "slang_mode", "python_mode", _stkdepth - $0); % matches _add_completion %}}} %{{{ save_buffer() %!%+ %\function{save_buffer} %\synopsis{save_buffer} %\usage{Void save_buffer ();} %\description % Save current buffer. %!%- define save_buffer() { variable file; !if (buffer_modified ()) { message("Buffer not modified."); return; } file = buffer_filename (); !if (strlen(file)) file = read_file_from_mini ("Save to file:"); !if (strlen(file)) error ("File name not specified"); () = write_buffer (file); } add_completion("save_buffer"); %}}} %{{{ insert_buffer() define insert_buffer() { variable buf = read_with_completion("Insert Buffer:", "", "", 'b'); push_spot(); try insbuf(buf); finally pop_spot (); } add_completion("insert_buffer"); %}}} %{{{ Word movement and processing functions %% %% word movement definitions. Since these vary according to editors, %% they are S-Lang routines. %% define skip_word () { while (skip_non_word_chars(), eolp()) { if (1 != right(1)) break; } skip_word_chars(); } define bskip_word() { while (bskip_non_word_chars(), bolp()) { !if (left(1)) break; } bskip_word_chars(); } define delete_word() { push_mark(); skip_word(); del_region(); } define bdelete_word () { push_mark(); bskip_word(); del_region(); } define xform_word () % parameter on stack { while (skip_non_word_chars(), eolp()) { if (1 != right(1)) break; } push_mark(); skip_word(); xform_region(()); } define capitalize_word() { xform_word('c'); } define upcase_word() { xform_word('u'); } define downcase_word() { xform_word('d'); } %}}} %{{{ smart_set_mark_cmd () %!%+ %\function{push_visible_mark} %\synopsis{push_visible_mark} %\usage{Void push_visible_mark ();} %\description % This function is performs the same task as \var{push_mark} except that the % region between this mark and the cursor position will be highlighted. % Such a mark is said to be a visible mark. %\seealso{push_mark, pop_mark, set_mark_cmd} %!%- define push_visible_mark () { push_mark (); call ("set_mark_cmd"); } %!%+ %\function{set_mark_cmd} %\synopsis{set_mark_cmd} %\usage{Void set_mark_cmd ();} %\description % If a mark is already set, and that mark is a visible mark, then this % function will remove that mark. It will then push a visible mark onto % the mark stack. %\seealso{push_visible_mark, pop_mark, smart_set_mark_cmd} %!%- define set_mark_cmd () { if (is_visible_mark ()) pop_mark_0 (); push_visible_mark (); } %!%+ %\function{smart_set_mark_cmd} %\synopsis{smart_set_mark_cmd} %\usage{Void smart_set_mark_cmd ();} %\description % If the top mark is a visible mark, this function will remove that mark; % otherwise it will push a visible mark onto the mark stack. Use of % this function has the effect of toggling a highlighted region. %\seealso{set_mark_cmd, push_mark, push_visible_mark} %!%- define smart_set_mark_cmd () { if (is_visible_mark ()) { pop_mark_0 (); return; } set_mark_cmd (); } %}}} %{{{ buffer_format_in_columns() %!%+ %\function{buffer_format_in_columns} %\synopsis{buffer_format_in_columns} %\description % Prototype Void buffer_format_in_columns(); % takes a buffer consisting of a sigle column of items and converts the % buffer to a multi-column format. %!%- define buffer_format_in_columns() { push_spot_bob (); forever { _for (0,4,1) { goto_column(() * 14 + 1); if (eolp()) { if (eobp()) { pop_spot(); return; } insert_single_space; del(); } } !if (down_1 ()) break; % bol (); % this is a side effect of going down } pop_spot(); } %}}} %{{{ delete_line() define delete_line() { bol(); push_mark_eol (); go_right_1 (); del_region(); } %}}} %{{{ set_fill_column () define set_fill_column () { push_spot(); eol(); WRAP = what_column (); pop_spot(); vmessage ("WRAP column at %d.", WRAP); } %}}} %{{{ rename_buffer(name) %!%+ %\function{rename_buffer} %\synopsis{Rename the current buffer} %\usage{rename_buffer (String_Type new_name)} %\description % This function may be used to change the name of the current buffer to the % one specified by the \var{new_name} parameter. %\seealso{setbuf_info, whatbuf} %!%- define rename_buffer (name) { variable flags = getbuf_info(); pop(); setbuf_info(name, flags); } %}}} %{{{ deln (n) %!%+ %\function{deln} %\synopsis{deln} %\usage{Void deln (Integer n);} %\description % delete the next 'n' characters. %!%- define deln (n) { push_mark (); go_right(n); del_region (); } %}}} %{{{ insert_spaces (n) define insert_spaces (n) { loop (n) insert_single_space (); } %}}} %{{{ blooking_at (str) define blooking_at (str) { variable n = strlen (str); EXIT_BLOCK { pop_spot (); } push_spot (); if (n != left(n)) return 0; return looking_at (__tmp(str)); } %}}} %{{{ exchange_point_and_mark () define exchange_point_and_mark () { call ("exchange"); } %}}} %{{{ str_split (str, n) % This ought to be a slang intrinsic!!! define str_split (str, n) { substr (str, 1, n - 1); substr (str, n, -1); } %}}} #ifndef VMS %{{{ expand_file_hook (file) define expand_file_hook (file) { variable changed = 0; variable envvar; variable pos, len, name, dir; variable file0, file1, file2; file2 = file; file = Null_String; % Check for environment variable of form $(variable) while ( #if (_slang_version >= 20100) strlen (file2) && string_match (file2, "\\$[^/$]+", 1) #else andelse {strlen (file2)}{string_match (file2, "\\$[^/$]+", 1)} #endif ) { changed++; (pos, len) = string_match_nth (0); pos++; (file0, file1) = str_split (file2, pos); (file1, file2) = str_split (file1, len + 1); envvar = getenv (substr (file1, 2, len - 1)); if (envvar == NULL) envvar = ""; file += file0 + envvar; } file += file2; # ifdef UNIX % Now look for things like: /~name/... pos = string_match (file, "^~", 1); !if (pos) pos = -string_match (file, "/~", 1); if (pos) { if (pos < 0) { pos = -pos; pos++; } # iffalse pos++; file = substr (file, pos, strlen (file)); # else file = file[[pos:]]; # endif pos = is_substr (file, "/"); if (pos) { (name, file) = str_split (file, pos); } else { name = file; file = Null_String; } !if (strlen (name)) return 0; if (file[0] == '/') (, file) = str_split (file, 2); (dir,,,,) = get_passwd_info (name); file = dircat (dir, file); changed++; } # endif if (changed) { file; } changed; } set_expansion_hook ("expand_file_hook"); %}}} #endif VMS define find_file_read_only () { call ("find_file"); set_readonly (1); } %!%+ %\function{enable_dfa_syntax_for_mode} %\synopsis{Use DFA syntax highlighting for one or more modes} %\usage{enable_dfa_syntax_for_mode (String_Type mode, ...)} %\description % This function may be used to enable the use of DFA syntax highlighting % for one or more specified modes. Each of the String_Type arguments must % be the name of a mode. The name of a buffer's mode is usually displayed on % the status line. %\example % To enable DFA syntax highlighting for perl and postscript modes, use %#v+ % enable_dfa_syntax_for_mode ("perl", "PostScript"); %#v- %\seealso{disable_dfa_syntax_for_mode, use_dfa_syntax} %!%- define enable_dfa_syntax_for_mode () { loop (_NARGS) { variable mode = (); mode_set_mode_info (mode, "use_dfa_syntax", 1); } } %!%+ %\function{disable_dfa_syntax_for_mode} %\synopsis{Use DFA syntax highlighting for one or more modes} %\usage{disable_dfa_syntax_for_mode (String_Type mode, ...)} %\description % This function may be used to disable the use of DFA syntax highlighting % for one or more specified modes. Each of the String_Type arguments must % be the name of a mode. The name of a buffer's mode is usually displayed on % the status line. %\example % To disable DFA syntax highlighting for C and S-Lang modes, use %#v+ % disable_dfa_syntax_for_mode ("C", "SLang"); %#v- %\seealso{enable_dfa_syntax_for_mode, use_dfa_syntax} %!%- define disable_dfa_syntax_for_mode () { loop (_NARGS) mode_set_mode_info ((), "use_dfa_syntax", 0); } % This fixes some bug in OS2 dealing with 'dir' issued non-interactively. #ifdef OS2 if (NULL != getenv("DIRCMD")) putenv("DIRCMD=/ogn"); #endif () = evalfile ("os.sl"); %}}} %--------------------------------------------------------------------------- %!%+ %\variable{Jed_Home_Directory} %\synopsis{User's jed home directory} %\description % The value of this variable specifies the user's so-called home directory % where personal jed-related files are assumed to be found. Normally, this % corresponds to the user's home directory unless the user has specified % an alternate directory via the \var{JED_HOME} environment variable. %!%- public variable Jed_Home_Directory; #ifdef VMS Jed_Home_Directory = "SYS$LOGIN:"; if (NULL != getenv("JED_HOME")) Jed_Home_Directory = "JED_HOME:"; #else Jed_Home_Directory = getenv ("JED_HOME"); if (Jed_Home_Directory == NULL) Jed_Home_Directory = getenv("HOME"); #endif if (Jed_Home_Directory == NULL) { #ifdef IBMPC_SYSTEM % on ms systems, try USERPROFILE (win32), if not set, use C:\. Jed_Home_Directory = getenv("USERPROFILE"); if (Jed_Home_Directory == NULL) Jed_Home_Directory = "C:\\"; #else Jed_Home_Directory = ""; #endif } private define patch_cmdline_file (file) { #ifdef UNIX variable ch = file[0]; file = strcompress (file, "/"); if (ch == '/') file = strcat ("/", file); return file; #else file; #endif } % This is the command line hook function that is called from main define command_line_hook () %{{{ { variable n, i, file, depth, next_file, tmp; variable init_file; n = __argc; --n; i = 1; % skip argv[0] if (BATCH) { if ((__argv[i] == "--help") or (__argv[i] == "-help")) () = evalfile ("jedusage"); --n; ++i; % -batch - 1st arg is not used } init_file = dircat (Jed_Home_Directory, #ifdef UNIX ".jedrc" #else "jed.rc" #endif ); if (1 != file_status (init_file)) init_file = Default_Jedrc_Startup_File; % if first argument is -n then do NOT load init file while (n) { file = __argv[i]; if ((file == "-a") and (n > 1)) { i++; n--; init_file = __argv[i]; if (1 != file_status (init_file)) { flush (strcat ("File does not exist: ", init_file)); usleep (2000); } i++; n--; break; } if ((file == "-e") and (n > 1)) { i++; n--; _Jed_Default_Emulation = __argv[i]; i++; n--; continue; } if (file == "-n") { init_file = NULL; i++; n--; continue; } break; } if (init_file != NULL) { if (file_status (init_file) != 1) { init_file = Default_Jedrc_Startup_File; if (file_status (init_file) != 1) init_file = "jed.rc"; % pick up the one distributed with jed } depth = _stkdepth (); () = evalfile (init_file); depth = _stkdepth () - depth; if (depth) { flush ("Excess junk left on stack by " + init_file); usleep (1000); _pop_n (depth); } } % Set up defaults in case user did not do it. !if (BATCH) { if (_Jed_Emulation == NULL) { () = evalfile (_Jed_Default_Emulation); enable_menu_keys (); } if (_Jed_Color_Scheme == NULL) set_color_scheme (_Jed_Default_Color_Scheme); } mini_init_minibuffer (); #ifdef UNIX if (strchop (__argv[0], '/', 0)[-1] == "info") { info_reader (__argv[[1:]]); return; } #endif !if (n) return; % % Is JED to emulate most? % if ("-most" == __argv[i]) { run_most (i + 1); return; } if ("-info" == __argv[i]) { info_reader (__argv[[i+1:]]); return; } while (n > 0) { file = __argv[i]; --n; ++i; if (n) { next_file = __argv[i]; variable next_file_arg = patch_cmdline_file (next_file); } switch (file) {case "-f" and n : eval(next_file_arg);} {case "-g" and n : goto_line(integer(next_file_arg));} {case "-s" and n : () = fsearch(next_file); save_search_string(next_file); } {case "-l" and n : () = evalfile(next_file_arg); } {case "-i" and n : () = insert_file(next_file_arg);} {case "-2" : splitwindow(); ++n; --i;} {case "-tmp": set_buffer_no_backup (); set_buffer_no_autosave (); ++n; --i; } #iftrue {case "-hook" and n: % run user hook variable hookfun = __get_reference (next_file); if (hookfun != NULL) { i++; % skip next_file (@hookfun)(__argv[[i:]]); return; } } #endif { tmp = strtrans (substr (file, 3, -1), "-", "_"); (not (strncmp (file, "--", 2)) && is_defined (tmp)) : eval (tmp); ++n; --i; } { (n && (file[0] == '+') && (Int_Type == _slang_guess_type (file)) && (atoi (file) >= 0)) : () = find_file (next_file_arg); goto_line (atoi(file)); } { flush ("Reading " + file); () = find_file(patch_cmdline_file (file)); ++n; --i; } --n; ++i; } } %}}} #ifdef UNIX if (getenv ("COLORTERM") == "rxvt") TERM_BLINK_MODE = 1; % allow high-intensity bg colors #endif %--------------------------------------------------------------------------- #ifndef VMS % FIXME for VMS define get_executable_path (pgm) { variable dir = path_dirname (pgm); if (path_is_absolute (dir)) return dir; # ifdef IBMPC_SYSTEM if (path_extname (pgm) == "") pgm += ".exe"; # endif if ((0 == is_substr (pgm, "/")) # ifdef IBMPC_SYSTEM && (0 == is_substr (pgm, "\\")) # endif ) { pgm = search_path_for_file (getenv ("PATH"), pgm); if (pgm == NULL) return NULL; dir = path_dirname (pgm); % The PATH could contain "." if (path_is_absolute (dir)) return dir; } % Relative to the CWD variable cwd = getcwd (); if (cwd == NULL) return NULL; return path_concat (cwd, dir); } % If jed is located in /some/install/prefix/bin/, return /some/install/prefix private variable Jed_Install_Prefix; private define guess_jed_install_prefix () { if (0 == __is_initialized (&Jed_Install_Prefix)) { Jed_Install_Prefix = get_executable_path (__argv[0]); if (NULL != Jed_Install_Prefix) Jed_Install_Prefix = path_dirname (Jed_Install_Prefix); } return Jed_Install_Prefix; } foreach ([ # ifexists _slang_install_prefix _slang_install_prefix, # endif guess_jed_install_prefix () ]) { $1 = (); if ($1 == NULL) continue; $2 = path_concat ($1, "share/slsh"); if (2 != file_status ($2)) continue; append_to_slang_load_path ($2); $2 = path_concat ($2, "help"); if (2 == file_status ($2)) jed_append_doc_file ($2); $2 = path_concat ($1, "share/slsh/local-packages"); if (2 == file_status ($2)) { append_to_slang_load_path ($2); $2 = path_concat ($2, "help"); if (2 == file_status ($2)) jed_append_doc_file ($2); } break; } #endif % !VMS % % This code fragment looks for the existence of "defaults.sl" and loads % it. This file IS NOT distributed with JED. % if (strlen(expand_jedlib_file("defaults.sl"))) () = evalfile("defaults"); #ifdef UNIX else { % Map /install/prefix/bin/jed to /install/prefix/etc/ $1 = getenv ("JED_CONF_DIR"); if ($1 == NULL) { $1 = guess_jed_install_prefix (); if ($1 != NULL) { $1 = path_concat ($1, "etc"); if (($1 == "/usr/etc") and (0 == file_status ($1))) $1 = "/etc"; } } if ($1 != NULL) { $1 = path_concat ($1, "jed.conf"); if (1 == file_status ($1)) () = evalfile ($1); } } #endif %require ("profile"); %_boseos_info = 0; %enable_profiling (); jed-0.99-19/lib/cal.sl0000644002657400265740000001472211311317447013345 0ustar davisdavis% % calender for JED % % It was written to test a mixture of S-Lang RPN and infix notation. % % It pops up a buffer like: % Jun 1993 Jul 1993 Aug 1993 % S M Tu W Th F S S M Tu W Th F S S M Tu W Th F S % 1 2 3 4 5 1 * 3 1 2 3 4 5 6 7 % 6 7 8 9 10 11 12 4 5 6 7 8 9 10 8 9 10 11 12 13 14 %13 14 15 16 17 18 19 11 12 13 14 15 16 17 15 16 17 18 19 20 21 %20 21 22 23 24 25 26 18 19 20 21 22 23 24 22 23 24 25 26 27 28 %27 28 29 30 25 26 27 28 29 30 31 29 30 31 % % The asterisk denotes the current day. % The actual computational part of the code presented here is a % translation of cal.el included with the GNU Emacs distribution. % (suitably modified to work with 16 bit integers) % % Changes: % 2000-09-30 by Eero Tamminen: % - month can be given either as a localized month name or a number % - configurability, month / day names & prompt can be changed % - day of the week, on which day week starts, can be configured % (US week starts on Sunday, european on Monday) % - some readability cleanup & more comments %---------------------------------------------------------------------- % country specific customization variable CalDays, CalMonths, CalStartWeek, CalPrompt; public define calendar_months(months) { CalMonths = months; } public define calendar_days(days) { CalDays = days; } public define calendar_start_week(day) { CalStartWeek = day; } public define calendar_prompt(prompt) { CalPrompt = prompt; } % set US defaults % each month name may be at max. 15 characters calendar_months(["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]); % each day is two characters, separated with space calendar_days(" S M Tu W Th F S"); % sunday=0, monday=1... calendar_start_week(0); % string with month & year calendar_prompt("Month Year:"); % return nonzero if yearnum is a leap year private define cal_leap_year_p (year) { return ((not(year mod 4) and (year mod 100)) or (not (year mod 400))); } % calculate nth day of year for given date private define cal_day_number(month, day, year) { variable d; d = 31 * ( month - 1 ) + day; if (month > 2) { d = d - (month * 4 + 23) / 10; if (cal_leap_year_p (year)) d++; } return d; } % calculate day of week for given date private define cal_day_of_week(month, day, year) { variable c, delta, n, a, b; n = cal_day_number(month, day, year); --year; a = n + year + year/4; c = year/100 * 3; b = 0; if (c mod 4) b = 1; return (a - (b + c/4) - CalStartWeek) mod 7; } % output given month to buffer private define cal_make_month (indent, month, year, day, highlight) { variable month_name, first, nm, ny, max, i, istr; % get days in month first = cal_day_of_week(month, 1, year); nm = month + 1; ny = year; if (nm == 13) max = 31; else max = cal_day_number(nm, 1, ny) - cal_day_number(month, 1, year); ++indent; bob(); % output month/year line month_name = CalMonths[month - 1]; goto_column(indent + (strlen(CalDays) - strlen(month_name) - 5) / 2); insert(month_name); insert_single_space(); insert(string(year)); !if (down_1 ()) newline(); % output days line goto_column(indent); insert(CalDays); !if (down_1()) newline (); % output day numbers in 7 columns goto_column(first * 3 + indent); for (i = 1; i <= max; ++i) { if (first == 7) { !if (down_1()) { eol(); newline (); } goto_column(indent); first = 0; } % highlight current day if ((day == i) and highlight) { if (day < 10) insert (" * "); else insert ("** "); } else vinsert ("%2d ", i); ++first; } } % return current (year, month day) as integers (from date string) private define cal_get_date() { variable t, n, m, months, month, month_name, day, year; t = time (); month_name = extract_element(t, 1, ' '); % have to be same as time() returns months = "Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec"; for (m = 0; m < 12; ++m) { month = extract_element(months, m, ' '); !if (strcmp(month_name, month)) { month = m + 1; break; } } day = extract_element(t, 2, ' '); n = 0; % Some systems display the time as: Tue Jul 06 16:31:18 1993 % while others use: Tue Jul 6 16:31:18 1993 if (strlen(day) == 0) { day = extract_element(t, 3, ' '); n = 1; } year = extract_element(t, 4 + n, ' '); return integer(year), month, integer(strtrim_beg(day, "0")); } % convert month number or localized name string into integer private define cal_convert_month (month_name) { variable m; month_name = strlow(month_name); m = where (month_name == array_map (String_Type, &strlow, CalMonths)); if (length(m)) return m[0] + 1; % presume it's an integer return integer(month_name); } % output three month calendar into separate buffer public define calendar () { variable t, month, year, nlines, wlines, obuf, default; variable this_day, this_month, this_year; run_mode_hooks("calendar_mode_hook"); obuf = whatbuf; % ask user for month / year (this_year, this_month, this_day) = cal_get_date(); default = sprintf ("%s %d", CalMonths[this_month-1], this_year); t = strtrim (read_mini (CalPrompt, default, Null_String)); month = cal_convert_month(extract_element(t, 0, ' ')); year = integer(extract_element(t, 1, ' ')); pop2buf("*calendar*"); set_readonly(0); erase_buffer(); % output three months --month; if (month == 0) { month = 12; --year; } cal_make_month (0, month, year, this_day, ((month == this_month) and (year == this_year))); ++month; if (month == 13) { month = 1; ++year; } cal_make_month (25, month, year, this_day, ((month == this_month) and (year == this_year))); ++month; if (month == 13) { month = 1; ++year; } cal_make_month (50, month, year, this_day, ((month == this_month) and (year == this_year))); % fix window size if (nwindows == 2) { eob(); bskip_chars("\n\t "); nlines = what_line() - window_info('r'); if (nlines > 0) { loop (nlines) {call("enlarge_window");} } else { call("other_window"); loop(- nlines) {call("enlarge_window");} call("other_window"); } bob(); } set_readonly(1); set_buffer_modified_flag(0); bob(); pop2buf(obuf); % what the heck, give current time message(time); } jed-0.99-19/lib/win1250.sl0000644002657400265740000000245111311317447013707 0ustar davisdavis% Initializes upper/lowercase lookup tables for Windows 1250 code page. % Derived from dos852.sl by the code conversion utility. % 852 is the default code page for Czech in DOS, 1250 is the equivalent % for Windows (ask Microsoft why the encoding is different). % not complete! - Czech only (Petr Peringer ) % . 0 64 1 { dup define_case } _for . 65 90 1 { dup 32 + define_case } _for . 91 96 1 { dup define_case } _for . 123 255 1 { dup define_case } _for %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% . 0xC1 0xE1 define_case % \'A --> \'a . 0xC8 0xE8 define_case % \v{C} --> etc. in TeX sequences . 0xCF 0xEF define_case % \v{D} . 0xCC 0xEC define_case % \v{E} . 0xC9 0xE9 define_case % \'E . 0xCD 0xED define_case % \'I . 0xD2 0xF2 define_case % \v{N} . 0xD3 0xF3 define_case % \'O . 0xD8 0xF8 define_case % \v{R} . 0x8A 0x9A define_case % \v{S} . 0x8D 0x9D define_case % \v{T} . 0xD9 0xF9 define_case % \r{U} . 0xDA 0xFA define_case % \'U . 0xDD 0xFD define_case % \'Y . 0x8E 0x9E define_case % \v{Z} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% . "0-9a-zA-Z_\xC1\xE1\xC8\xE8\xCF\xEF\xCC\xEC\xC9\xE9\xCD\xED\xD2\xF2\xD3\xF3\xD8\xF8\x8A\x9A\x8D\x9D\xD9\xF9\xDA\xFA\xDD\xFD\x8E\x9E" . define_word jed-0.99-19/lib/ctags.sl0000644002657400265740000002161011311317447013701 0ustar davisdavis% tags.sl -*- SLang -*- % % read a tags file produced by ctags/etags programs % % Public Functions: % ctags_forward % Go forward to the previous tag % ctags_backward % Go back to the previous position % ctags_find % Lookup a tag in the tags file and jump to the indicated position % ctags_popup_tag % Like ctags_find, except popup in a separate window % % Public Variables: % % Tags_file: The name of the tags file to use. The default is % "tags". % % Buffer Local Variables: % Tags_File: The name of the tag file to use % Word_Chars: The characters that make up a word custom_variable ("Tags_File", "tags"); private variable Position_Stack = NULL; private variable Position_Stack_Ptr = NULL; private define create_position () { variable s = struct { file, line, mark, next, prev }; s.mark = create_user_mark (); s.file = buffer_filename (); s.line = what_line (); return s; } private define save_position (s) { if (Position_Stack_Ptr != NULL) { Position_Stack_Ptr.next = s; s.prev = Position_Stack_Ptr; } else Position_Stack = s; Position_Stack_Ptr = s; } private define goto_position () { variable s = Position_Stack_Ptr; variable buf; EXIT_BLOCK { sw2buf (buf); } try { buf = user_mark_buffer (s.mark); goto_user_mark (s.mark); return; } catch AnyError; () = read_file (s.file); goto_line (s.line); s.mark = create_user_mark (); buf = whatbuf (); } private define back_position () { if (Position_Stack_Ptr == NULL) verror ("Can't go back more"); variable s = Position_Stack_Ptr.prev; if (s == NULL) verror ("Can't go back more"); Position_Stack_Ptr = s; goto_position (); } private define forw_position () { if (Position_Stack_Ptr == NULL) verror ("Can't go forward"); variable s = Position_Stack_Ptr.next; if (s == NULL) verror ("Can't go forward"); Position_Stack_Ptr = s; goto_position (); } % ctags format: % function-name\tfilename\t/^function-prototype/ % typedef-name\tfilename\tline-number % Note: an extended format file will look like: % function-name\tfilename\t/^function-prototype$/;"TAB... private define _ctags_find (tag, sinfo) { variable n, file, proto; !if ((n = re_fsearch (strcat ("\\c^", tag, "\t+\\([^\t]+\\)\t+"))), n) return NULL; file = regexp_nth_match (1); variable dir; (,dir,,) = getbuf_info (); sinfo.file = dircat (dir, file); n--; go_right (n); if (looking_at ("/^")) { go_right (2); push_mark (); !if (ffind ("/;\"\t")) { eol (); bskip_chars ("\\\\$/"); } if (blooking_at ("$")) go_left (1); #ifexists strreplace proto = str_replace_all (bufsubstr (), "\\/", "/"); #else % Versions of slang prior to 1.4.1 do not have strreplace and % str_replace_all will fail unless something is done to trick it. proto = str_replace_all (bufsubstr (), "\\/", "\001\002\x7f"); proto = str_replace_all (proto, "\001\002\x7f", "/"); #endif sinfo.line = proto; } else { push_mark (); eol (); sinfo.line = atoi (bufsubstr ()); } return sinfo; } % etags format: % ^L % filename,some-number % [function-type] function-name ^?line-name,some-number private define etags_find (tag) { variable file, line, tmptag, msg = "Tag file needs updated?"; % we do the re_fsearch in order of preference: user->function->array tmptag = strcat ("[: ]", tag); !if (re_fsearch (strcat (tmptag, "[\t ]+\x7F\\(\\d+\\),"))) !if (re_fsearch (strcat (tmptag, "[\t \\(]+\x7F\\(\\d+\\),"))) !if (re_fsearch (strcat (tmptag, "[\t \\[]+\x7F\\(\\d+\\),"))) error (msg); line = integer (regexp_nth_match (1)); () = bol_bsearch (char (014)); % previous ^L go_down_1 (); push_mark (); skip_chars ("^,\n"); file = bufsubstr (); !if (read_file (file)) error ("File not found."); goto_line (line); } private define goto_tag (s, tag) { () = read_file (s.file); variable line = s.line; if (String_Type == typeof (line)) { bob (); if (0 == bol_fsearch (line)) { () = fsearch (tag); message ("Your tags file needs to be updated"); } } else goto_line (line); } private define tags_find (find_method, tag) { variable s = Struct_Type[0]; forever { variable s1 = struct { file, line }; s1 = (@find_method) (tag, s1); if (s1 == NULL) break; s = [s, s1]; } if (length (s) == 0) verror ("Unable to find %s. Perhaps your tags file needs updated.", tag); return s; } private define locate_tags_file (tags_file) { variable dir; if (path_is_absolute (tags_file)) { if (1 == file_status (tags_file)) return tags_file; return NULL; } (,dir,,) = getbuf_info (); forever { variable file = dircat (dir, tags_file); if (1 == file_status (file)) return file; % This may need modified for non-Unix systems... #ifdef UNIX dir = expand_filename (dircat (dir, "../")); if (dir == "/") break; #elifdef IBMPC_SYSTEM dir = expand_filename (dircat (dir, "..\\")); if ((dir == "/") or (dir == "\\")) break; if (strlen (dir) == 3) { if (dir[1] == ':') break; } #elifdef VMS % Does this work? dir = expand_filename (dircat (dir, "[-]")); #endif } return NULL; } private define find_tags_file () { variable file, dir, dir1; variable tbuf = " *tags*"; file = get_blocal_var("Tags_File", Tags_File); file = locate_tags_file (file); if (file == NULL) error ("Unable to find a tags file"); (dir1,) = parse_filename (file); if (bufferp (tbuf)) { (,dir,,) = getbuf_info (tbuf); if (dir == dir1) return; } setbuf (tbuf); erase_buffer (); if (insert_file (file) < 0) error ("File tags not found!"); variable flags; (file,,tbuf,flags) = getbuf_info (); setbuf_info (file,dir1,tbuf,flags); } private define get_word_at_point (word_chars) { push_spot (); skip_white (); bskip_chars (word_chars); push_mark (); skip_chars (word_chars); variable tag = bufsubstr (); pop_spot (); return tag; } private define get_tag_at_point () { #ifexists _slang_utf8_ok variable word_chars = "\\w_"; #else variable word_chars = "0-9A-Za-z_"; #endif #ifdef VMS word_chars = strcat (word_chars, "$"); #endif word_chars = get_blocal_var ("Word_Chars", word_chars); return read_mini ("Find tag:", get_word_at_point (word_chars), ""); } define ctags_find () { variable tag; if (_NARGS == 1) tag = (); else tag = get_tag_at_point (); tag = strtrim (tag); !if (strlen (tag)) return; variable cbuf = whatbuf (); variable cpos = create_position (); find_tags_file (); bob (); variable find_method = &_ctags_find; if (looking_at_char (014)) % if first char is ^L (etags) find_method = &etags_find; variable s = tags_find (find_method, tag); goto_tag (s[0], tag); save_position (cpos); variable tag_pos = create_position (); save_position (tag_pos); sw2buf (whatbuf ()); } define ctags_forward () { forw_position (); } define ctags_backward () { back_position (); } % This function pops up a window containing a specified position but % leaves the point in the current window/buffer. private define popup_window_containing_buffer_position (m1) { variable m0 = create_user_mark (); variable m0buf = user_mark_buffer (m0); variable m1buf = user_mark_buffer (m1); variable cwindow = window_info ('t'); if (m0buf == m1buf) { % We may need to split this window if it is the only one % containing m0buf variable nwin = 0; loop (nwindows ()) { if (m0buf == whatbuf ()) nwin++; otherwindow (); } variable total_windows = nwindows (); if (MINIBUFFER_ACTIVE) total_windows--; if (nwin == 1) { if (total_windows == 1) splitwindow (); else loop (nwindows ()) { if ((whatbuf () != m0buf) and (whatbuf() != " ")) { sw2buf (m0buf); break; } otherwindow (); } } } pop2buf (m1buf); goto_user_mark (m1); % Now go back to the original window. % If there are several windows that contain m0buf, find the one we % started from. loop (nwindows ()) { otherwindow (); if ((window_info ('t') == cwindow) and (m0 == create_user_mark ())) return; } % We could not find the window _and_ mark, so just look for the mark loop (nwindows ()) { if (m0 == create_user_mark ()) return; otherwindow (); } % Should not get here } define ctags_popup_tag () { variable m0 = create_user_mark (); ctags_find (); variable m1 = create_user_mark (); if (m0 == m1) return; % Restore the previous position sw2buf (user_mark_buffer (m0)); goto_user_mark (m0); % Popup a window containing the new position. popup_window_containing_buffer_position (m1); } % Compatibility define find_tag () { ctags_popup_tag (); } jed-0.99-19/lib/latex209.sl0000644002657400265740000000441111311317447014150 0ustar davisdavis% latex209.sl % % AUC-TeX style LaTeX209-mode (v0.3) by Kevin Humphreys % % For JED (v0.97.9b) by John E. Davis % % Based on AUC-TeX (v7.3) by Per Abrahamsen % Loaded from latex.sl if LaTeX_default_documentstyle is non-null % (If you don't use LaTeX209 you don't need this file) % CHANGES HISTORY: % Modified for integration into the main jed distribution. % --- v0.2-0.3 % added call to read_with_completion for documentstyle % --- v0.1-0.2 % added insertions for letter style % call tex_embrace for font specifier insertion define latex_insert_document_env () { variable class = read_with_completion(LaTeX_classes, "Enter Document Class:", LaTeX_default_documentstyle, Null_String, 's'); variable options = read_mini ("Enter Style Options:", LaTeX_default_options, Null_String); if (strlen (options)) options = sprintf("[%s]", options); bob (); vinsert ("\\\\documentstyle%s{%s}\n\n", options, class); insert ("\\begin{document}\n\n\n\n\\end{document}\n"); go_up(3); !if (strcmp(class, "letter")) latex_insert_letter_args(); } % Font Selection - LaTeX209 define tex_insert_font (pre, post, arg) { if (arg == -1) tex_embrace(pre, post); else % if prefix argument { push_spot(); bsearch("{\\"); pop(); delete_word(); del (); insert (pre); () = fsearch_char ('}'); del (); go_left(2); if (looking_at("\\/")) del (); else go_right(2); insert(post); pop_spot (); } } define tex_delete_font () { push_spot(); () = bsearch("{\\"); delete_word(); del (); () = fsearch_char ('}'); del (); go_left(2); if (looking_at("\\/")) deln(2); pop_spot (); } define tex_font () { variable arg = prefix_argument(-1); switch (getkey()) { case 2 : tex_insert_font ("{\\bf ", "}", arg);} % C-b { case 3 : tex_insert_font ("{\\sc ", "}", arg);} % C-c { case 5 : tex_insert_font ("{\\em ", "\\/}", arg);} % C-e { case 9 : tex_insert_font ("{\\it ", "\\/}", arg);} % C-i { case 18 : tex_insert_font ("{\\rm ", "}", arg);} % C-r { case 19 : tex_insert_font ("{\\sl ", "\\/}", arg);} % C-s { case 20 : tex_insert_font ("{\\tt ", "}", arg);} % C-t { case 4 : tex_delete_font ();} % C-d } jed-0.99-19/lib/idl.sl0000644002657400265740000001276311311317447013361 0ustar davisdavis% idl mode $1 = "IDL"; create_syntax_table ($1); define_syntax (";", "", '%', $1); define_syntax ("([{", ")]}", '(', $1); %define_syntax ('"', '"', $1); define_syntax ('\'', '"', $1); define_syntax ('\\', '\\', $1); define_syntax ("$0-9a-zA-Z_", 'w', $1); % words define_syntax ("-+0-9a-fA-F.xXL", '0', $1); % Numbers define_syntax (",.?:", ',', $1); define_syntax ("%-+/&*=<>|!~^", '+', $1); define_syntax ('@', '#', $1); set_syntax_flags ($1, 1); % case insensitive % These are IDL reserved words () = define_keywords ($1, "$", 1); () = define_keywords ($1, "doeqgegtifleltneofor", 2); () = define_keywords ($1, "andendformodnotproxor", 3); () = define_keywords ($1, "caseelsegotothen", 4); () = define_keywords ($1, "beginendifuntilwhile", 5); () = define_keywords ($1, "commonendforendrependwhirepeatreturn", 6); () = define_keywords ($1, "endcaseendelse", 7); () = define_keywords ($1, "endwhilefunctionon_error", 8); () = define_keywords ($1, "endrepeat", 9); () = define_keywords ($1, "on_ioerror", 10); ()=define_keywords_n ($1,"abscoseofexpfixhdrmaxminsintan", 3, 1); ()=define_keywords_n ($1,"alogplotsavesizesortsqrtstopuniqwset", 4, 1); ()=define_keywords_n ($1,"closefloatflooropenropenwplotsprintranksreadfreadsreadurebinspawntotalwherewshow", 5, 1); ()=define_keywords_n ($1,"alog10dblarrdoublefinitefltarrindgenintarrlonarrprintfstrarrstringstrlenstrmidstrposstrputwriteuwindow", 6, 1); ()=define_keywords_n ($1,"defsysvdindgenexecutefindgenget_lunintegerrandomnrandomustr_sepstretchstrtrim", 7, 1); ()=define_keywords_n ($1,"findfilefree_lunn_params", 8, 1); ()=define_keywords_n ($1,"histogramimaginaryreplicatestrupcasetranspose", 9, 1); ()=define_keywords_n ($1,"n_elementsstrlowcasestrmessage", 10, 1); ()=define_keywords_n ($1,"keyword_setstrcompress", 11, 1); % idl indentation routines define idl_find_effective_eol () { bol (); while (ffind_char (';')) { go_right_1 (); if (parse_to_point () == -2) { go_left_1 (); return; } } eol (); } define idl_beginning_of_statement () { variable n = 0; bol_skip_white (); if (looking_at ("pro ") or looking_at ("function ")) { return 0; } while (up_1 ()) { idl_find_effective_eol (); bskip_white (); !if (blooking_at ("$")) { #iffalse if (bolp ()) { skip_white (); if (looking_at_char (';')) continue; } #endif go_down_1 (); break; } n++; } bol_skip_white (); return n; } define idl_indent_to (col) { push_spot (); bol_skip_white (); if (col != what_column ()) { col--; bol_trim (); whitespace (col); } pop_spot (); } define idl_looking_at_block (word, begin) { !if (looking_at (word)) return 0; EXIT_BLOCK { pop_spot (); } push_spot (); go_right (strlen (word)); if (ffind (begin)) return 1; do { idl_find_effective_eol (); bskip_white (); !if (blooking_at ("$")) break; } while (down (1)); bol (); return ffind(begin); } define idl_is_block_beginnning () { push_spot (); bol_skip_white (); orelse {idl_looking_at_block ("if ", " begin")} {idl_looking_at_block ("while", " begin")} {idl_looking_at_block ("else ", " begin")} {idl_looking_at_block ("for ", " begin")} {idl_looking_at_block ("case ", " of")} {idl_looking_at_block ("endif else", " begin")} {idl_looking_at_block ("repeat", " begin")} {looking_at ("function ")} {looking_at ("pro ")} { idl_find_effective_eol (), bskip_chars ("$ \t"), blooking_at ("BEGIN") and bfind(":") }; pop_spot (); } custom_variable ("Idl_Indent_Amount", 2); define idl_indent_line () { variable len = 0, extra_indent = 0; variable word; push_spot (); EXIT_BLOCK { pop_spot (); idl_indent_to (len + extra_indent); push_mark (); bskip_white (); pop_mark (not(bolp ()), skip_white ()); } if (idl_beginning_of_statement ()) { push_mark (); pop_spot (); push_spot (); bol (); if (1 == find_matching_delimiter (')')) { len = what_column (); pop_mark_0 (); len++; return; } pop_mark_1 (); if (looking_at ("pro ") or looking_at ("function ")) { () = ffind_char (' '); skip_white (); } skip_chars ("A-Za-z$_!"); len = what_column () + Idl_Indent_Amount; return; } if (looking_at_char ('@')) return; if (looking_at ("end")) extra_indent = -Idl_Indent_Amount; else if (looking_at ("else")) { go_right (4); skip_white (); if (not(looking_at_char (':'))) { extra_indent = -Idl_Indent_Amount; } } !if (up_1 ()) { len = 0; return; } do { bol_skip_white (); !if (eolp () or looking_at_char (';') or looking_at_char ('@')) break; } while (up_1 ()); () = idl_beginning_of_statement (); len = what_column (); if (idl_is_block_beginnning ()) { len += Idl_Indent_Amount; } } define idl_newline_and_indent () { if (idl_is_block_beginnning ()) idl_indent_line (); bskip_white (); if (blooking_at (",")) insert (" $"); newline (); idl_indent_line (); } $1 = "IDL"; !if (keymap_p ($1)) { make_keymap ($1); definekey ("newline_and_indent", "\r", $1); definekey ("indent_line", "\t", $1); } define idl_mode () { variable idl = "IDL"; set_mode (idl, 0); use_syntax_table (idl); use_keymap (idl); set_buffer_hook ("indent_hook", "idl_indent_line"); set_buffer_hook ("newline_indent_hook", "idl_newline_and_indent"); run_mode_hooks ("idl_mode_hook"); } jed-0.99-19/lib/dos850.sl0000644002657400265740000000246311311317447013627 0ustar davisdavis% Initializes upper/lowercase lookup tables for DOS code page 850. % 850 is the default code page for Belgium, Brazil, Denmark, % Finland, France, Germany, Italy, Latin America, Netherlands, % Norway, Portugal, Spain, Sweden, and Switzerland. % It is the alternate code page for Canadian-French, % Czechoslovakia, Hungary, International English, Poland, United % Kingdom, USA, and (ex-)Yugoslavia % Information from MSDOS 5.0 manual % Thanks marko@cs.umd.edu . 0 64 1 { dup define_case } _for . 65 90 1 { dup 32 + define_case } _for . 91 96 1 { dup define_case } _for . 123 255 1 { dup define_case } _for % . 128 135 define_case . 154 129 define_case . 144 130 define_case . 142 132 define_case . 183 133 define_case . 143 134 define_case . 211 137 define_case . 212 138 define_case . 216 139 define_case . 215 140 define_case . 222 141 define_case . 146 145 define_case . 153 148 define_case . 227 149 define_case . 234 150 define_case . 235 151 define_case . 157 155 define_case . 181 160 define_case . 214 161 define_case . 224 162 define_case . 233 163 define_case . 165 164 define_case . 199 198 define_case . 209 208 define_case . 229 228 define_case . 232 231 define_case . 237 236 define_case . "0-9a-zA-Z\d128-\d155\d157\d160-\d165\d181-\d183\d198\d199\d208\d212\d214-\d216\d222\d224-\d237" . define_word jed-0.99-19/lib/jed.rc0000644002657400265740000002311311311317447013330 0ustar davisdavis% User Initialization file for the JED editor -*- slang -*- % If a user does not have a startup file in the user's home directory, % JED will automatically load this from JED_ROOT/lib. Thus it is easier % for a system manager to make defaults for all users. % Do not edit this file directly. Instead, copy it to your home % directory (sys$login:jed.rc on VMS or $HOME/.jedrc on Unix) and edit % the resulting file. % To uncomment a line, simply remove any leading '%' characters. % This file is divided into various sections. The first section pertains % to keybindings (e.g., Wordstar, Emacs, EDT, etc...) and the following % sections pertain to user preferences such as default TAB sizes, line % and column numbers on status line, colors, indentation style, etc... if (BATCH == 0) { %---------------------------------------------------------------------- % Keybindings (not loaded for batch processes) % % Default bindings are Emacs-like with EDT emulation on Unix and VMS. % For the PC, only Emacs is enabled by default. If you do not want EDT % bindings, simply coment out the appropriate line. % % For Wordstar like bindings, comment out EDT and Emacs lines and % uncomment Wordstar line. A similar statement applies for BRIEF, % and for Borland IDE-like bindings. % % () = evalfile("emacs"); % Emacs-like bindings % () = evalfile("edt"); % EDT emulation % () = evalfile ("ide"); % Borland IDE (see also doc/ide-mode.txt) % () = evalfile ("brief"); % Brief Keybindings (MSDOS only!!) % () = evalfile("wordstar"); % obsolete --- use ide instead) % () = evalfile ("cua"); % CUA-like key bindings % Note: For EDT emulation, jed386.exe requires that the GOLD.COM TSR % be loaded. This TSR is available from space.mit.edu:/pub/davis/jed. % Some of the above emulations may set keys that conflict with access to % the menubars. For example, emacs uses ESC-f to move by words. The % next line causes the keys to activate the menus. Comment this out % to preserve the emulation. enable_menu_keys (); % If you use jed inside an XTerminal, you can use the mouse to access the % menus and move the cursor by uncommenting the next line: % enable_xmouse (); % What should the Ctrl-H key do?? % % setkey ("bol", "^H"); % causes ^H to go to beg of line (EDT) % setkey ("help_prefix", "^H"); % Uncomment to have Ctrl-H as help #ifdef XWINDOWS % See xjed.txt for information regarding the delete key under X Windows. % x_set_keysym (0xFFFF, 0, "\e[3~"); % setkey ("delete_char_cmd", "\e[3~"); #endif % !!!! ^S/^Q flow control problems !!!! % if you experience problems with JED suddenly going into search mode % for some reason then you are a victim of the emacs emulation's % binding of the ^S key to the search function. % TO prevent this from happening, either find out how to % prevent unwanted ^S/^Q characters or uncomment the next line: #ifdef UNIX %enable_flow_control (1); #endif %---------------------------------------------------------------------- % Initial help screen --- comment out to disable. % Note that for the help to be valid, it must occur AFTER bindings are % loaded. % help(); % Pops up a help window } %Batch %%%%%%%%%%%%%%%% top menu bar %%%%%%%%%%%%%%% % To disable it, uncomment the next line. Note that menus will still be % available but the menubar will be hidden when not in use. % enable_top_status_line (0); %--------------------------------------------------------------------------- % User Information (used by some modes, automatically determined on Unix) %--------------------------------------------------------------------------- % set_realname ("John Doe"); % set_username ("jd"); % set_hostname ("no.where.com"); % set_emailaddress ("jd@no.where.com"); %---------------------------------------------------------------------- % JED global variables --- defaults shown % #ifdef VMS UNIX %USE_ANSI_COLORS = 1; % if non-zero, JED will display colors on a color % terminal (Unix and VMS only) See doc/color.txt % for more discussion and look below for setting % the colors. #endif No_Backups = 0; % If non-zero, backup files will not be created. Startup_With_File = 1; % if greater then zero, force JED to prompt for a file % if none is specified on the command line. If % negative, inhibit startup message. DISPLAY_TIME = 1; % non-zero enables the time to be displayed on % status line, zero disables it. If this value % is -1, 24 hour time will be used. HIGHLIGHT = 1; % non-zero for region highlighting WANT_SYNTAX_HIGHLIGHT = 1; % Highlight syntax in C, Fortran, and TeX modes. % See section on colors % below for choosing how to highlight. On Unix and % VMS systems, USE_ANSI_COLORS must also be non-zero. HORIZONTAL_PAN = 20; % if zero, no automatic panning. If positive, only % the current line is panned. If negative, pan window. #ifdef IBMPC_SYSTEM HORIZONTAL_PAN = -1; % For msdos, panning window might be better: #endif #ifdef IBMPC_SYSTEM LINENUMBERS = 2; % A value of zero means do NOT display line number on #else % status line line. A value of 1, means to display LINENUMBERS = 1; % the linenumber. A value greater than 1 will also #endif % display column number information. I recommend a % value of 2 only at high baud rates BLINK = 1; % if non zero, blink matching parenthesis TAB_DEFAULT = 8; % Tab size (also try edit_tab_stops) USE_TABS = 1; % Use tabs when generating whitespace. Tab_Always_Inserts_Tab = 0; % Set this to 1 if you want the tab key to insert % tabs. WRAP_DEFAULT = 72; % wrap column ADD_NEWLINE = 1; % add newline to file when writing if one not present IGNORE_BEEP = 3; % Beep terminal during error messages--- % 1 == sound only, 2 = visible bell only, 3 = both _traceback = 0; % Non zero means dump traceback on S-Lang errors WRAP_INDENTS = 0; % Non zero indents next line after wrapping current. % Make this a 1 if you want indented text mode. %KILL_LINE_FEATURE = 0; % If non-zero, kill line will kill through end of the % line if Point is at the beginning of the line. For % emacs-like behavior, set this to zero. %--------------------------------------------------------------------------- % C-mode indentation style %--------------------------------------------------------------------------- c_set_style ("jed"); % or "linux", "gnu", "bsd", "k&r" #ifdef IBMPC_SYSTEM % If non-zero, treat file names as case sensitive Case_Sensitive_Filenames = 0; #endif %--------------------------------------------------------------------------- #ifdef MSDOS XWINDOWS MSWINDOWS % Alt-key handling. Setting this variable controls how the % Alt key is handled. By default it is set to 27 (Ascii ESCAPE). This means % that any key pressed in conjunction with the alt key produces ESCAPE % followed by the key itself. If ALT-X is pressed, an ESCAPE-X is generated. % Set it to zero to turn off Alt key processing. On XWindow systems, setting % this to zero will cause the high bit to be set on the character. %ALT_CHAR = 27; #endif % Mute (dead or accent) keys % Valid Mute keys are: % ^, ~, ', `, \d168 (ISO Diaeresis), \d180 (ISO Acute), and \". % This means pressing this key then the key you want to accent yields % the accented character. If you do not know what this is, you do not % need them. By default, they are turned off. %mute_set_mute_keys (" ^ ~ ' ` \d168 \d180 \" "); % choose all or subset META_CHAR = -1; % All chars with hi bit set will self insert #ifdef IBMPC_SYSTEM % DISPLAY_EIGHT_BIT = 128; #else % DISPLAY_EIGHT_BIT = 160; % Other systems assume ISO Latin 1 #endif % Color Settings % Look at jed/lib/colors/README for a description of predefined color % schemes. %set_color_scheme ("black3"); %set_color_scheme ("blue2"); #ifdef UNIX % % Terminal type. By default, on Unix termcap is used. However, some % (if not all) termcaps do not include AL, DL strings for vtxxx terminals. % % True blue vt100 terminals cannot insert and delete lines so the AL and DL % termcap entries are not appropriate for them. However, almost no one % uses a true vt100 terminal anymore but they set their TERM variable to % vt100 just the same. If you do not like the way your terminal scrolls, % and it is more than a vt100, either set your TERM variable appropriately % or add vt100 to the list below. % if (0) { $1 = "vt102 vt200 vt220 vt300 vt320 vt420 xterms"; if (is_substr($1, getenv("TERM"))) set_term_vtxxx(0); } #endif % Compiler interface --- uncomment one of the following: % % variable Compile_Default_Compiler = "gcc"; % GNU compiler % variable Compile_Default_Compiler = "Ultrix_cc"; % cc on Ultrix % variable Compile_Default_Compiler = "bcc"; % Borlands BCC % variable Compile_Default_Compiler = "sun_acc"; % SunOS C++ and ACC % variable Compile_Default_Compiler = "hp_cc"; % HPUX cc #ifdef WIN32 variable W32shell_Perform_Globbing = 0; #endif % % Hooks: read jed/doc/hooks.sl for more information % define global_mode_hook (hook_name) { % if (hook_name != "c_mode_hook") % local_setkey ("self_insert_cmd", "\t"); } define dired_hook () { %local_unsetkey ("^K"); %local_setkey ("dired_kill_line", "^K"); } jed-0.99-19/lib/shmode.sl0000644002657400265740000000453211311317447014063 0ustar davisdavis% This is a simple shell mode. It does not defined any form of indentation % style. Rather, it simply implements a highlighting scheme. $1 = "SH"; create_syntax_table ($1); define_syntax ("#", "", '%', $1); define_syntax ("([{", ")]}", '(', $1); % Unfortunately, the editor cannot currently correctly deal with multiple % string characters. So, inorder to handle something like: % echo "I'd rather be home" % make the '"' character the actual string character but also give '\'' % a string syntax. However, this will cause '"' to give problems but % usually, '"' characters will be paired. define_syntax ('\'', '"', $1); define_syntax ('"', '"', $1); define_syntax ('\\', '\\', $1); define_syntax ("-0-9a-zA-Z_", 'w', $1); % words define_syntax ("-+0-9", '0', $1); % Numbers define_syntax (",;:", ',', $1); define_syntax ("%-+/&*=<>|!~^", '+', $1); #ifdef HAS_DFA_SYNTAX %%% DFA_CACHE_BEGIN %%% private define setup_dfa_callback (name) { dfa_enable_highlight_cache ("shmode.dfa", name); dfa_define_highlight_rule ("\\\\.", "normal", name); dfa_define_highlight_rule ("#.*$", "comment", name); dfa_define_highlight_rule ("\"([^\\\\\"]|\\\\.)*\"", "string", name); dfa_define_highlight_rule ("\"([^\\\\\"]|\\\\.)*$", "string", name); dfa_define_highlight_rule ("'[^']*'", "string", name); dfa_define_highlight_rule ("'[^']*$", "string", name); dfa_define_highlight_rule ("[\\|&;\\(\\)<>]", "Qdelimiter", name); dfa_define_highlight_rule ("[\\[\\]\\*\\?]", "Qoperator", name); dfa_define_highlight_rule ("[^ \t\"'\\\\\\|&;\\(\\)<>\\[\\]\\*\\?]+", "Knormal", name); dfa_define_highlight_rule (".", "normal", name); dfa_build_highlight_table (name); } dfa_set_init_callback (&setup_dfa_callback, "SH"); %%% DFA_CACHE_END %%% #endif () = define_keywords ($1, "cddofiifin", 2); () = define_keywords ($1, "forletpwdset", 3); () = define_keywords ($1, "casedoneechoelifelseesacevalexitifeqreadtestthentype", 4); () = define_keywords ($1, "aliasbreakendifendswifdefifneqlocalshiftumaskunsetuntilwhile", 5); () = define_keywords ($1, "exportifndefreturnsetenvsourceswitch", 6); () = define_keywords ($1, "breaksw", 7); () = define_keywords ($1, "continuefunction", 8); define sh_mode () { set_mode("SH", 0); use_syntax_table ("SH"); mode_set_mode_info ("SH", "fold_info", "#{{{\r#}}}\r\r"); run_mode_hooks("sh_mode_hook"); } jed-0.99-19/lib/maple.sl0000644002657400265740000000422011311317447013674 0ustar davisdavis%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% custom_variable ("Maple_Program", "maple"); custom_variable ("Maple_Prompt_Regexp", "^[a-zA-Z]*>"); variable Maple_Pid = -1; define maple_send_input () { variable buf; variable this_line, mark_line; variable m, len; m = process_mark (Maple_Pid); this_line = what_line (); push_mark (); goto_user_mark (m); mark_line = what_line (); if (this_line >= mark_line) { % Cursor is after point of last output. Just send everything % from last output to end of buffer. pop_mark_0 (); push_mark_eob (); buf = bufsubstr (); } else { % it looks like user wants to re-run this line. Fine. pop_mark_1 (); eol (); push_mark (); len = re_bsearch (Maple_Prompt_Regexp); !if (len) { pop_mark_0 (); return; } go_right (len - 1); buf = bufsubstr (); eob (); insert (buf); } newline (); move_user_mark (m); send_process (Maple_Pid, strcat (buf, "\n")); } $1 = "MapleMap"; !if (keymap_p ($1)) make_keymap ($1); definekey ("maple_send_input", "^M", $1); define maple_signal_handler (pid, flags, status) { variable msg; eob (); msg = aprocess_stringify_status (pid, flags, status); vinsert ("\n\n----- %s ------\n\n", msg); if (flags != 2) Maple_Pid = -1; } define maple_insert_output (pid, str) { eob (); push_spot (); insert (str); pop_spot (); bol (); replace ("\r", Null_String); eob (); move_user_mark (process_mark (pid)); } define maple () { variable buf = "*maple*"; variable arg, nargs = 0; if ((Maple_Pid != -1) and bufferp (buf)) { error ("Currently, only one maple process is supported."); } pop2buf (buf); use_keymap ("MapleMap"); run_mode_hooks ("maple_mode_hook"); erase_buffer (); % parse possible arguments forever { arg = extract_element (Maple_Program, nargs, ' '); if (arg == NULL) break; nargs++; arg; % push on stack } nargs - 1; % push on stack Maple_Pid = open_process (); set_process (Maple_Pid, "signal", "maple_signal_handler"); set_process (Maple_Pid, "output", "maple_insert_output"); } jed-0.99-19/lib/rmail.sl0000644002657400265740000011253211311317447013710 0ustar davisdavis% See jed/doc/rmail.txt for more information. % Mark Olesen's patches added. %!% variable that controls the location of the mailbox for new mail !if (is_defined("Rmail_Spool_Mailbox_File")) { variable Rmail_Spool_Mailbox_File = getenv ("MAIL"); if (NULL == Rmail_Spool_Mailbox_File) { Rmail_Spool_Mailbox_File = "/var/spool/mail"; if (2 != file_status (Rmail_Spool_Mailbox_File)) { Rmail_Spool_Mailbox_File = "/usr/mail"; % HP-UX } Rmail_Spool_Mailbox_File = dircat (Rmail_Spool_Mailbox_File, getenv ("USER")); } } %!% where the JED mail reader should put the mail !if (is_defined("Rmail_Directory")) { variable Rmail_Directory = dircat(getenv("HOME"), "Mail"); } %!% temporary mailbox where newmail is moved to before parsed and converted. variable Rmail_Tmp_Mbox = dircat(Rmail_Directory, "#NewMail#"); variable Rmail_Master_Index_File = dircat(Rmail_Directory, "_Root_Index.index"); variable Rmail_Folder_Buffer = Null_String; variable Rmail_Folder_Name = Null_String; variable Rmail_Newmail_Folder = "New-Mail"; variable Rmail_Root_Buffer = "Rmail: Folder List"; variable Rmail_Mail_Buffer_Name = Null_String; !if (is_defined("Rmail_Dont_Reply_To")) { % comma separated list of name to not reply to. variable Rmail_Dont_Reply_To; $1 = getenv("USER"); if ($1 == NULL) $1 = ""; $2 = getenv("HOST"); if ($2 == NULL) $2 = ""; Rmail_Dont_Reply_To = $1; if (strlen($1) and strlen ($2)) Rmail_Dont_Reply_To = sprintf("%s,%s@%s", $1, $1, $2); else Rmail_Dont_Reply_To = $1; } Rmail_Dont_Reply_To = strlow (Rmail_Dont_Reply_To); variable Rmail_Message_Number = Null_String; %/* this is a string!! */ % check for existence of Rmail directory. Create it if it does not exist. !if (file_status(Rmail_Directory)) { if (mkdir(Rmail_Directory, 0700)) error("Unable to create " + Rmail_Directory); if (chmod(Rmail_Directory, 0700)) error ("chmod failed!"); } !if (is_defined ("Rmail_Ask_About_Cc")) { variable Rmail_Ask_About_Cc = 0; } define rmail_buffer_name(folder) { "Rmail: " + folder; } !if (is_defined ("mime_rfc1522_parse_buffer")) { autoload ("mime_rfc1522_parse_buffer", "mime"); autoload ("mime_qp_parse_buffer", "mime"); } define rmail_folder_file(folder) { dircat (Rmail_Directory, folder) + ".index"; } % set buffer flags so that autosave is off but save anyway is on. % This way it gets saved in case of a power failure or something. define rmail_set_buffer_flags() { variable flags = getbuf_info(); flags = (flags | 0x80) & ~(0x2); % turn off autosave, turn on save flags = flags & ~(0x20); % turn off undo flags = flags | 0x100; % No backup file. setbuf_info(flags); () = set_buffer_umask (0077); } define rmail_save_buffer_secure () { variable dir, file, flags; (file, dir,,flags) = getbuf_info(); !if (buffer_modified () and strlen (file)) return; file = dircat(dir, file); () = write_buffer(file); () = chmod(file, 0600); } define rmail_update_master_index (folder, n, total, n_unread) { variable cbuf = whatbuf(), f, fline; fline = sprintf("Folder:\t%20s\t(%d/%d) messages. %d unread.\n", folder, n, total, n_unread); variable flags; () = read_file(Rmail_Master_Index_File); rmail_set_buffer_flags(); push_spot_bob (); % only save if necessary. !if (bol_fsearch(fline)) { !if (bol_fsearch(sprintf("Folder:\t%20s\t(", folder))) eob(); set_readonly(0); delete_line(); insert(fline); set_readonly(1); } rmail_save_buffer_secure(); % only if modified. pop_spot(); setbuf(cbuf); } define rmail_save_folder (folder, delit) { !if (bufferp(Rmail_Folder_Buffer)) return; variable file = rmail_folder_file(folder), n; variable total, n_ok, n_unread; setbuf(Rmail_Folder_Buffer); set_readonly(0); n = string(what_line()); % This is a good place to update the master index. % calculate total messages and number of deleted ones. eob(); bskip_chars(" \t\n"); total = what_line(); if (bobp ()) { total = 0; n = "0"; } bob(); n_ok = total; n_unread = 0; forever { switch (what_char ()) { case 'D': n_ok--; } { case '-': n_unread++; } !if (down_1 ()) break; bol(); } rmail_update_master_index(folder, n_ok, total, n_unread); widen(); bob(); go_down_1 (); if (n != line_as_string ()) { delete_line(); insert(n); newline(); } rmail_save_buffer_secure(); if (delit) { delbuf(whatbuf()); return; } % % narrow it back % bob(); () = bol_fsearch("\x1F\xC\n"); go_down_1 (); push_mark_eob (); narrow(); } define rmail_find_folder (folder) { variable file = rmail_folder_file(folder); rmail_save_folder(Rmail_Folder_Name, 1); Rmail_Folder_Buffer = rmail_buffer_name(folder); () = find_file(file); rmail_set_buffer_flags(); rename_buffer(Rmail_Folder_Buffer); Rmail_Folder_Name = folder; % make sure buffer is properly formatted. Routines expect this to be % widened. widen(); bob(); if (eobp()) { % new, format it insert("0\n1\n\x1F\xC\n"); } } define rmail_get_header (header, continue_flag, multi_flag) { variable h, dh; bob(); if (strlow (header) == "date: ") { % special treatment for date. It always looks like: % Wed, 11 jun 1993 % or: Sun Dec 04, 1994 11:05:52 GMT % The day and , are somtimes missing and 1993 may be just 93. if (re_fsearch("^Date:[ \t]+[a-zA-Z,]* *0?\\([1-3]?\\d\\) +\\([a-zA-Z]+\\) +")) return sprintf("%s-%s", regexp_nth_match(1), regexp_nth_match(2)); if (re_fsearch("^Date:[ \t]+[a-zA-Z]+ \\([a-zA-Z]+\\) +0?\\([1-3]?\\d\\)[ ,]+")) return sprintf("%s-%s", regexp_nth_match(2), regexp_nth_match(1)); return Null_String; } h = ""; while (bol_fsearch(header)) { go_right (strlen(header)); skip_white(); push_mark (); eol (); if (continue_flag) { while (down_1 ()) { skip_white (); if (bolp ()) { go_left_1 (); break; } } } dh = bufsubstr(); if (strlen (h)) h += ","; h += dh; !if (multi_flag) break; } return strtrim (strtrans (h, "\n", " ")); } define rmail_narrow_to_headers () { bob (); push_mark (); !if (bol_fsearch("\n")) eob(); narrow(); bob (); } define rmail_extract_headers () { variable from = Null_String, date = Null_String, subject = Null_String; push_spot (); rmail_narrow_to_headers (); from = rmail_get_header("From: ", 0, 0); !if (strlen(from)) from = rmail_get_header("From ", 0, 0); date = rmail_get_header("Date: ", 0, 0); subject = rmail_get_header("Subject: ", 0, 0); widen(); pop_spot(); % RAFE (flags, the - means it has not been read.) % The 'from' string may have multibyte characters, which will not % will not be handled properly via the printf width specifier. So % pad it outside the printf call. variable width = 25; variable len = strwidth (from); if (len > width) { variable ch, new_from = ""; foreach ch (from) using ("chars") { ch = char (ch); if (strwidth (new_from + ch) > width) break; new_from += ch; } from = new_from; len = strwidth (from); } loop (width-len) from += " "; sprintf(" %6s %s %s\n", date, from, subject); % Note: The column widths may not be correct when UTF-8 characters are % present. } % This routine assumes that the buffer is narrow. define rmail_make_filename() { variable cbuf = whatbuf(), n; setbuf(Rmail_Folder_Buffer); bob(); push_mark_eol (); n = bufsubstr_delete(); if (strlen(n)) n = integer(n); else n = 0; ++n; n = string(n); bob(); insert(n); if (eobp()) { insert("\n1\n\x1F\xC\n"); } setbuf(cbuf); return n; } define rmail_create_folder(folder) { variable dir = dircat(Rmail_Directory, folder); if (file_status(dir)) return dir; if (mkdir(dir, 0700)) error ("Unable to create folder directory."); () = chmod(dir, 0700); rmail_update_master_index(folder, 0, 0, 0); return (dir); } define rmail_parse_mime () { variable h; push_spot (); rmail_narrow_to_headers (); if (fsearch ("?Q?")) mime_rfc1522_parse_buffer (); h = rmail_get_header ("Content-Transfer-Encoding: ", 1, 0); eob (); widen (); if (is_substr (strlow (h), "quoted-printable")) { push_mark (); eob (); narrow (); mime_qp_parse_buffer (); widen (); } pop_spot (); } define rmail_output_newmail() { variable headers; variable cbuf = whatbuf(); variable n = rmail_make_filename(), file; file = rmail_create_folder (Rmail_Folder_Name); file = dircat(file, n); bob(); push_mark(); skip_chars("\n \t"); del_region(); push_mark_eob(); () = write_region_to_file(file); % () = chmod(file, 0600); rmail_parse_mime (); headers = rmail_extract_headers(); setbuf(Rmail_Folder_Buffer); eob(); % If this format is changed, change it in xpunge as well. vinsert ("-%3s", n); insert(headers); setbuf(cbuf); } define rmail_newmail_narrow (from) { variable content_length = 0; push_mark_eol (); !if (bol_fsearch_char ('\n')) eob (); narrow (); if (re_bsearch ("^\\CContent-Length:[ \t]+\\(\\d+\\)$")) content_length = integer (regexp_nth_match (1)); bob (); widen (); push_mark_eol (); if (content_length) { if (bol_fsearch_char ('\n')) { content_length++; if ((content_length == right (content_length)) and (skip_chars ("\n"), (re_looking_at (from) or eobp ()))) { !if (eobp ()) go_up_1 (); narrow (); return; } } pop_mark_1 (); push_mark_eol (); } forever { if (re_fsearch (from)) { if (blooking_at ("\n\n")) { go_up_1 (); break; } eol (); continue; } eob (); break; } narrow(); } private define rmail_process_newmail (mbox, newmail_folder) { variable n = 0, from = "^\\cFrom "; rmail_find_folder(newmail_folder); eob(); push_spot(); setbuf(" *rmail-newmail*"); erase_buffer(); if (insert_file(mbox) <= 0) error ("File not inserted."); bob(); push_mark(); if (0 == re_fsearch(from)) { message ("New mail with no messages!"); pop_mark_1 (); pop_spot (); return 0; } del_region(); () = set_buffer_umask (0077); forever { rmail_newmail_narrow (from); ++n; flush (sprintf ("Processing %d messages...", n)); rmail_output_newmail(); erase_buffer(); widen(); if (eobp()) break; del(); } % pop back to beginning of the newest messages in the folder. % in addition, save_folder expects the buffer to be narrowed. whatbuf(); setbuf(Rmail_Folder_Buffer); bob(); () = bol_fsearch("\x1F\xC\n"); go_down_1 (); push_mark_eob(); narrow(); pop_spot(); setbuf(()); rmail_save_folder(newmail_folder, 1); return n; } define rmail_get_newmail_from_file (file, tmp_mbox, folder) { variable n, st; variable nomail, cmd; variable getmail = dircat(Jed_Bin_Dir, "getmail"); nomail = sprintf ("No new mail in %s", file); st = stat_file (file); if ( #if (_slang_version >= 20100) (st == NULL) || (st.st_size <= 0) #else orelse{NULL == st}{st.st_size <= 0} #endif ) { message (nomail); return (0); } flush("Getting new mail..."); if (file_status(getmail) != 1) { error (getmail + " not found!"); } cmd = sprintf("%s %s %s", getmail, file, tmp_mbox); push_mark(); if (pipe_region(cmd)) error ("getmail returned error."); n = rmail_process_newmail (tmp_mbox, folder); % delete_file(Rmail_Tmp_Mbox); return n; } define rmail_get_newmail () { rmail_get_newmail_from_file (Rmail_Spool_Mailbox_File, Rmail_Tmp_Mbox, Rmail_Newmail_Folder); } define rmail_folder_mode() { variable flags; () = find_file(Rmail_Master_Index_File); set_readonly(1); rmail_set_buffer_flags(); rename_buffer(Rmail_Root_Buffer); bob(); use_keymap("Rmail-Folder"); } define rmail_exit_folder () { rmail_save_folder(Rmail_Folder_Name, 1); if (bufferp(Rmail_Root_Buffer)) pop2buf(Rmail_Root_Buffer); else rmail_folder_mode(); onewindow(); if (bufferp(Rmail_Mail_Buffer_Name)) { delbuf(Rmail_Mail_Buffer_Name); Rmail_Message_Number = Null_String; } Rmail_Mail_Buffer_Name = Null_String; clear_message (); } variable Rmail_Headers_Hidden = 0; define rmail_unhide_headers () { variable mark = "\x1F\xC\n"; Rmail_Headers_Hidden = 0; set_readonly(0); widen(); bob(); push_mark(); !if (bol_fsearch("\n")) eob(); narrow(); bob(); % make a mark if not found if (bol_fsearch(mark)) { go_down_1 (); push_spot(); % delete visible headers push_mark_eob(); del_region(); % restore old ones bob(); push_mark(); () = bol_fsearch(mark); bufsubstr(); eob(); insert(); pop_spot(); } else { insert(mark); push_mark_eob(); bskip_chars("\n"); bufsubstr(); bob(); insert(); newline(); go_down(2); } push_mark(); widen(); eob(); narrow(); bob(); set_readonly(1); } define rmail_hide_headers() { variable ok_headers = "From,Subj,Cc,Organ,In-Reply,Date,Reply-To,To"; variable header; rmail_unhide_headers(); Rmail_Headers_Hidden = 1; widen(); bob(); push_mark(); !if (bol_fsearch("\n")) eob(); narrow(); bob(); !if (bol_fsearch("\x1F\xC\n")) error ("Unable to find marker."); set_readonly(0); push_spot(); % Unwrap lines forever { eol (); trim (); !if (looking_at ("\n ") or looking_at ("\n\t")) break; del (); trim (); insert_single_space (); } goto_spot (); % mark ok lines foreach (strtok (ok_headers, ",")) { header = (); while (bol_fsearch(header)) { insert("\xFF"); } #ifnfalse while (down_1 () and not (skip_white (), bolp ())) { bol (); insert ("\xFF"); } #endif goto_spot (); } pop_spot(); eol(); go_right_1 (); % delete unmarked lines while(not(eobp())) { bol(); if (looking_at("\xFF")) { del(); eol(); go_right_1 (); continue; } push_mark_eol(); skip_chars("\n"); del_region(); eol(); } %newline(); widen(); bob(); () = bol_fsearch("\x1F\xC\n"); go_down_1 (); push_mark_eob(); narrow(); bob(); } % This routines returns the file number of current summary line as a string. % If the line is invalid, it returns the null string. define rmail_extract_file_number() { bol(); go_right_1 (); skip_white(); push_mark(); skip_chars("0-9"); bufsubstr(); } define rmail_add_flag(flag) { variable n = 13, flags = "RFE"; flag = char(flag); n += is_substr(flags, flag); goto_column(n); !if (looking_at(flag)) { insert(flag); del(); } } % this routine returns 0 if line does not contain a valid message % 1 if the message is already in the window, 2 if not but it exists, -1 % if it had to be read in. define rmail_get_message(flag) { variable buf, file, n, n1, pop_buf, ret; !if (bufferp(Rmail_Folder_Buffer)) return (0); pop2buf(Rmail_Folder_Buffer); file = rmail_extract_file_number (); !if (strlen(file)) return 0; Rmail_Message_Number = file; set_readonly(0); bol(); if (looking_at_char ('-')) { del(); insert_single_space (); } if (flag) rmail_add_flag(flag); set_readonly(1); buf = sprintf("Rmail: %s(%s)", Rmail_Folder_Name, file); pop_buf = buf; ret = 2; if ((buf != Rmail_Mail_Buffer_Name) or not(bufferp(buf))) { % % we have to read it in. % ret = -1; if (bufferp(Rmail_Mail_Buffer_Name)) { pop_buf = Rmail_Mail_Buffer_Name; } } if (buffer_visible(pop_buf)) { pop2buf(pop_buf); if (ret == 2) ret = 1; } else { % I want summary window at top. There is no nice way to do it % at present. onewindow(); n = window_info('r'); pop2buf(pop_buf); if (TOP_WINDOW_ROW == window_info('t')) { pop2buf(Rmail_Folder_Buffer); sw2buf(pop_buf); } n1 = window_info('r'); % we want n to be 4 lines % now it is: n -= n1 + 1; loop (n - 4) enlargewin(); pop2buf(Rmail_Folder_Buffer); pop2buf(pop_buf); } if (ret != -1) return ret; () = set_buffer_umask (077); set_readonly(0); widen(); erase_buffer(); Rmail_Mail_Buffer_Name = buf; file = dircat(dircat(Rmail_Directory, Rmail_Folder_Name), file); n = insert_file(file); ERROR_BLOCK { set_readonly(1); set_buffer_modified_flag(0); } if (n < 0) { mark_buffer (); () = write_region_to_file (file); error ("File not found!"); } bob(); rename_buffer(buf); #iftrue rmail_parse_mime (); #endif rmail_hide_headers(); EXECUTE_ERROR_BLOCK; return (ret); } define rmail_toggle_headers() { !if (rmail_get_message(0)) return; if (Rmail_Headers_Hidden) { rmail_unhide_headers(); } else rmail_hide_headers(); set_buffer_modified_flag(0); set_readonly(1); pop2buf(Rmail_Folder_Buffer); } define rmail_scroll_forward () { ERROR_BLOCK { pop2buf(Rmail_Folder_Buffer); } if (rmail_get_message(0) == 1) { update_sans_update_hook(0); call("page_down"); } EXECUTE_ERROR_BLOCK; } define rmail_skip_quotes () { variable str = "^ *[>:|=]"; ERROR_BLOCK { pop2buf(Rmail_Folder_Buffer); } if (1 == rmail_get_message (0)) { update(0); goto_top_of_window (); go_down_1 (); if (re_fsearch (str)) { while ( #if (_slang_version >= 20100) (push_mark (), narrow (), bol (), re_fsearch (str), widen ()) || (skip_white (), eolp ()) #else orelse { push_mark (), narrow (), bol (), re_fsearch (str), widen () } { skip_white (), eolp ()} #endif ) { !if (down_1 ()) break; } recenter (1); } } EXECUTE_ERROR_BLOCK; } define rmail_scroll_backward() { ERROR_BLOCK { pop2buf(Rmail_Folder_Buffer); } if (rmail_get_message(0) == 1) { update(0); call("page_up"); } EXECUTE_ERROR_BLOCK; } define rmail_format_mail_buffer () { variable opt_headers = NULL; if (_NARGS == 1) opt_headers = (); pop2buf (Rmail_Folder_Buffer); mail(); %onewindow(); if (buffer_modified ()) { !if (get_yes_no("Mail already being composed. Erase it")) return 0; } mail_format_buffer (1, opt_headers); 1; } define rmail_forward_message () { variable cbuf, subj; !if (rmail_get_message('F')) { beep(); return; } cbuf = whatbuf (); push_spot (); bob (); subj = "Fwd: "; if (bol_fsearch ("Subject: ")) { go_right (9); push_mark (); eol (); subj = sprintf ("Fwd: [%s]", bufsubstr ()); } pop_spot (); !if (rmail_format_mail_buffer ()) return; eob(); insert ("----Begin Forwarded Message----\n"); insbuf(cbuf); insert ("----End Forwarded Message----\n"); bob(); if (bol_fsearch ("Subject: ")) { eol (); insert (subj); } bob (); eol(); } % This function assumes that the buffer has been narrowed about the headers. define rmail_unfold_headers () { variable flags; flags = getbuf_info (); setbuf_info (0); push_spot (); bob (); do { while (eol (), (looking_at ("\n ") or looking_at ("\n\t"))) del (); } while (down_1 ()); () = getbuf_info (); setbuf_info (flags); pop_spot (); } define rmail_insert_attribution (from, date, cc) { variable you = "you"; if (strlen (cc) and strlen(from)) you = from; if (strlen (date)) vinsert ("On %s, %s said:\n", date, you); else vinsert ("%s said:\n", you); } define rmail_parse_email_address (from) { variable pos, len; % First try to remove comments. We have 2 forms to consider: % "not@a.comment, This is a comment , this@is_not (This is)" % Knock out parenthesis form. Try to handle nested ones while (pos = string_match (from, "\\(([^()]*)\\)", 1), pos) { (pos, len) = string_match_nth (1); from = substrbytes (from, 1, pos) + substrbytes (from, pos + len + 1, -1); } % Remove double quote type comments from = str_uncomment_string (from, "\"", "\""); % Now try to get rid of ", This is a comment bla" form % In general, we must handle commas: % 1. "not comment,is comment is comment, not comment" % So we do the following: % (However, we still incorrectly handle commas in comments!) while (pos = string_match (from, ",?\\([^,]*<\\([^>]*\\)>[^,]*\\)", 1), pos) { variable pos1, len1; (pos, len) = string_match_nth (1); (pos1, len1) = string_match_nth (2); from = substrbytes (from, 1, pos) + substrbytes (from, pos1 + 1, len1) + substrbytes (from, pos + len + 1, -1); } % Now replace all space, tab, and newline by commas return strcompress (strtrans (strcompress(from, " \t\n") , " ", ","), ","); } define rmail_apply_dont_reply_to (from) { variable sub_f, n, num; % add to list, see if any part of it is in the list. ","; % delimiter for create_delimited_string n = 0; num = 0; from = strlow (from); while (sub_f = extract_element (from, n, ','), sub_f != NULL) { n++; variable pats; variable matches; pats = "^" + strchop (Rmail_Dont_Reply_To, ',', '\\') + "$"; matches = array_map (Int_Type, &string_match, sub_f, pats, 1); !if (any (matches)) { sub_f; num++; } } create_delimited_string (num); } define rmail_reply () { !if (rmail_get_message('R')) { beep(); return; } variable subj, cc, to, replyto, from, msgid=NULL; variable date = ""; variable cbuf = whatbuf (); push_spot (); variable headers_hidden = Rmail_Headers_Hidden; rmail_unhide_headers (); rmail_narrow_to_headers (); set_buffer_modified_flag(0); set_readonly(1); replyto = rmail_get_header ("Reply-To: ", 1, 0); !if (strlen (replyto)) replyto = rmail_get_header ("From: ", 1, 0); to = rmail_get_header ("To: ", 1, 1); subj = rmail_get_header ("Subject: ", 1, 0); !if (strlen (subj)) subj = "(No Subject)"; msgid = rmail_get_header ("Message-ID: ", 1, 0); cc = rmail_get_header ("Cc:", 1, 1); if (Rmail_Ask_About_Cc and strlen (cc)) { ERROR_BLOCK { cc = ""; _clear_error (); } !if (get_yes_no ("Include the cc: header")) cc = Null_String; } cc += "," + to; cc = rmail_apply_dont_reply_to (rmail_parse_email_address (cc)); replyto = rmail_parse_email_address (replyto); from = rmail_get_header ("From: ", 1, 0); eob (); % get the date for the attribution string if (re_bsearch("^Date:[ \t]*\\(.*\\)$")) date = regexp_nth_match (1); widen(); if (headers_hidden) { rmail_hide_headers (); set_buffer_modified_flag(0); set_readonly(1); } pop_spot(); variable opt_headers = NULL; if (msgid != "") opt_headers = sprintf ("In-Reply-To: %s\n", msgid); !if (rmail_format_mail_buffer (opt_headers)) return; bob(); do { if (looking_at("To:")) { eol (); insert (replyto); } else if (looking_at("Cc:")) { eol (); insert (cc); } else if (looking_at("Subject:")) { eol (); push_spot (); insert (subj); pop_spot (); !if (looking_at("Re:")) insert ("Re: "); } } while (down_1 () and not (looking_at ("X-Mailer:"))); eob(); if (bol_bsearch ("-- \n")) % find signature up_1 (); push_mark(); narrow(); % This trick allows a single undo to remove the later insertion: erase_buffer(); insbuf(cbuf); bob(); rmail_insert_attribution (from, date, cc); push_spot (); do { bol(); insert_char ('>'); } while (down_1 ()); newline(); pop_spot (); widen(); !if (strlen (to)) { bob(); eol(); } } define rmail_edit () { variable file; !if (get_y_or_n ("Are you sure you want to edit")) return; !if (rmail_get_message ('E')) return; % Now we are in the message buffer. The global variable Rmail_Message_Number % should be correct. file = dircat(dircat(Rmail_Directory, Rmail_Folder_Name), Rmail_Message_Number); if (1 != file_status (file)) verror ("Unable to read %s", file); set_buffer_modified_flag (0); delbuf (whatbuf ()); () = find_file (file); text_mode (); set_buffer_no_backup (); } define rmail_find_next_message () { push_mark(); while (down_1 () and looking_at_char ('D')); if (eobp()) { pop_mark_1 (); message("No more undeleted messages."); return 0; } pop_mark_0 (); 1; } define rmail_find_prev_message() { push_mark(); while (up_1 (), bol(), () and looking_at_char ('D')); if (bobp() and looking_at_char ('D')) { pop_mark_1 (); message("No more undeleted messages."); return 0; } pop_mark_0 (); 1; } define rmail_delete_cmd () { bol(); if (eolp()) return beep(); !if (looking_at_char ('D')) { set_readonly(0); del(); insert_char ('D'); set_readonly(1); } } define rmail_delete_backward () { rmail_delete_cmd (); () = rmail_find_prev_message (); } define rmail_delete_forward () { rmail_delete_cmd (); () = rmail_find_next_message(); } define rmail_undelete () { push_mark_eol(); if (bol_bsearch_char ('D')) { set_readonly(0); del(); insert_single_space (); set_readonly(1); pop_mark_0 (); return; } pop_mark_1 (); beep(); } define rmail_next_message() { if (rmail_find_next_message()) { rmail_scroll_forward(); } } define rmail_prev_message() { if (rmail_find_prev_message()) { rmail_scroll_forward(); } } define rmail_select_folder (folder) { variable n; rmail_find_folder(folder); bob(); go_down_1 (); n = integer(line_as_string ()); () = bol_fsearch("\x1F\xC\n"); go_down_1 (); push_mark_eob(); narrow(); pop2buf(whatbuf()); goto_line(n); bol(); use_keymap("Rmail-Read"); set_status_line("Jed %b Folder. (%p) %t", 0); set_readonly(1); run_mode_hooks ("rmail_folder_hook"); } define rmail_build_folder_list () { variable slist = Null_String; variable cbuf = whatbuf (); setbuf (Rmail_Root_Buffer); push_spot_bob (); while (bol_fsearch("Folder:\t")) { go_right (8); skip_white (); push_mark (); () = ffind ("\t"); slist += "," + bufsubstr (); } pop_spot (); setbuf (cbuf); slist; } private define folder_exists (folder) { folder = dircat(Rmail_Directory, folder); return file_status(folder) == 2; } private define query_create_folder (default_folder) { variable folder, new_dir; folder = read_string_with_completion ("Move to folder:", default_folder, rmail_build_folder_list ()); if (not (strlen (folder))) return NULL; if (folder == Rmail_Folder_Name) return folder; if (0 == folder_exists (folder)) { if (1 != get_yes_no(sprintf("Folder %s does not exist, create it", folder))) return NULL; () = rmail_create_folder(folder); } return folder; } define rmail_folder_newmail () { variable n; variable file = Rmail_Spool_Mailbox_File; variable folder; folder = Rmail_Newmail_Folder; if (-1 != prefix_argument (-1)) { file = read_file_from_mini ("Input MailBox:"); !if (strlen (file)) return; folder = query_create_folder (folder); if (folder == NULL) return; } n = rmail_get_newmail_from_file (file, Rmail_Tmp_Mbox, folder); if (n) { flush(sprintf("%d new messages.", n)); rmail_select_folder(folder); } } variable Rmail_Last_Folder = Null_String; % This routine deletes buffer containing message n if it exists % it returns 1 if is exists and is visible otherwise it returns 0. define rmail_validate_message () { variable vis = 0; variable buf = sprintf("Rmail: %s(%s)", Rmail_Folder_Name, Rmail_Message_Number); if (bufferp(buf)) { vis = buffer_visible(buf); delbuf(buf); } return vis; } define rmail_update_folder_and_save () { variable new_n; eob (); bskip_chars ("\n \t"); bol (); new_n = rmail_extract_file_number (); !if (strlen(new_n)) new_n = "0"; widen(); bob(); push_mark_eol(); if (bufsubstr() != new_n) { delete_line(); insert(new_n); newline(); } () = bol_fsearch("\x1F\xC\n"); go_down_1 (); push_mark_eob(); narrow(); pop_mark_1 (); rmail_save_folder(Rmail_Folder_Name, 0); } define rmail_resequence_folder () { variable n, file, new_file, dir, new_n = "0"; variable update_message = 0; variable res_fmt = "Resequencing folder [%d/%d]..."; variable nmax; ERROR_BLOCK { rmail_update_folder_and_save (); pop_spot (); } push_spot(); set_readonly(0); dir = dircat(Rmail_Directory, Rmail_Folder_Name); n = 0; eob (); nmax = what_line () - 1; bob(); flush (sprintf (res_fmt, n, nmax)); while (file = rmail_extract_file_number (), strlen(file)) { n++; new_n = string(n); !if (n mod 10) flush (sprintf (res_fmt, n, nmax)); if (file != new_n) { file = dircat(dir, file); new_file = dircat(dir, new_n); if (file_status (new_file)) verror ("File %s exists. Cannot rename %s to it.", new_file, file); if (rename_file(file, new_file)) error ("Error renaming ", file); bol(); go_right_1 (); push_mark(); skip_white(); skip_chars("0-9"); del_region(); vinsert ("%3s", new_n); if (new_n == Rmail_Message_Number) { update_message = rmail_validate_message (); } } !if (down_1 ()) break; } % update the last file number rmail_update_folder_and_save (); pop_spot(); eol (); bskip_chars("\n"); bol (); set_readonly(1); if (update_message or (integer(new_n) < integer(Rmail_Message_Number))) { Rmail_Message_Number = Null_String; rmail_scroll_forward (); } message("done."); } define rmail_output_to_folder() { variable folder = NULL, header, old_n, new_n, new_file, old_file; variable old_folder = Rmail_Folder_Name; variable buf, vis; if (_NARGS) folder = (); variable new_dir, old_dir = dircat(Rmail_Directory, Rmail_Folder_Name); old_n = rmail_extract_file_number (); !if (strlen(old_n)) return; if ( #if (_slang_version >= 20100) (folder == NULL) || (0 == folder_exists (folder)) #else orelse {(folder == NULL)}{0 == folder_exists (folder)} #endif ) folder = query_create_folder (Rmail_Last_Folder); if (folder == NULL) return; new_dir = dircat(Rmail_Directory, folder); % lets get this header header = line_as_string (); rmail_find_folder (folder); % % generate a new filename % new_n = rmail_make_filename(); new_file = dircat(new_dir, new_n); old_file = dircat(old_dir, old_n); if (rename_file(old_file, new_file)) { rmail_select_folder(old_folder); error("Unable to rename file."); } eob(); insert(header); bol(); go_right_1 (); push_mark(); skip_white(); skip_chars("0-9"); del_region(); vinsert ("%3s", new_n); Rmail_Last_Folder = folder; % Now narrow it so next routine can process it bob(); () = bol_fsearch("\x1F\xC\n"); go_down_1 (); push_mark_eob(); narrow(); rmail_select_folder(old_folder); set_readonly(0); bob(); () = bol_fsearch(header); delete_line(); rmail_resequence_folder(); } define rmail_unhide_deleted () { push_spot (); mark_buffer (); set_region_hidden (0); pop_spot (); } define rmail_hide_deleted () { push_spot (); rmail_unhide_deleted (); bob (); while (bol_fsearch_char ('D')) { set_line_hidden (1); eol (); } pop_spot (); } % This function is assumed to be called from within a folder. It REALLY % deletes files marked with the D. define rmail_xpunge_deletions () { variable file, dir, n, new_file; % variable old_n = Null_String; flush("Expunging messages..."); push_mark(); ERROR_BLOCK { rmail_resequence_folder (); pop_mark_0 (); set_readonly(1); } set_readonly(0); dir = dircat(Rmail_Directory, Rmail_Folder_Name); bob(); while (bol_fsearch_char ('D')) { file = rmail_extract_file_number(); !if (strlen(file)) continue; % !if (strcmp(file, Rmail_Message_Number)) % { % old_n = file; % } file = dircat(dir, file); if (1 != file_status(file)) error ("Unable to access ", file); !if (delete_file(file)) error ("Unable to delete ", file); delete_line (); } pop_mark_1 (); rmail_resequence_folder (); } $1 = "Rmail-Read"; !if (keymap_p($1)) { make_keymap($1); _for (' ', 127, 1) { $2 = char(()); undefinekey($2, $1); } definekey("rmail_skip_quotes", "\t", $1); definekey("rmail_delete_backward", "D", $1); definekey("rmail_delete_forward", "d", $1); definekey("rmail_exit_folder", "q", $1); definekey("rmail_exit_folder", "Q", $1); definekey("rmail_folder_newmail", "g", $1); definekey("rmail_folder_newmail", "G", $1); definekey("rmail_next_message", "n", $1); definekey("rmail_next_message", "N", $1); definekey("rmail_prev_message", "p", $1); definekey("rmail_prev_message", "P", $1); definekey("rmail_toggle_headers", "t", $1); definekey("rmail_toggle_headers", "T", $1); definekey("rmail_scroll_forward", " ", $1); definekey("rmail_scroll_forward", "\r", $1); definekey("rmail_scroll_backward", "^?", $1); definekey("rmail_xpunge_deletions", "x", $1); definekey("rmail_xpunge_deletions", "X", $1); definekey("rmail_reply", "r", $1); definekey("rmail_reply", "R", $1); definekey("rmail_forward_message", "f", $1); definekey("rmail_forward_message", "F", $1); definekey("rmail_output_to_folder", "o", $1); definekey("rmail_undelete", "u", $1); definekey("rmail_undelete", "U", $1); definekey("rmail_edit", "E", $1); definekey("mail", "m", $1); definekey("mail", "M", $1); } define rmail_select_this_folder () { bol(); !if (looking_at("Folder:\t")) return beep(); () = ffind("\t"); skip_white(); push_mark(); !if (ffind("\t(")) { pop_mark(0); beep(); return; } rmail_select_folder (bufsubstr()); } $1 = "Rmail-Folder"; !if (keymap_p($1)) { make_keymap($1); _for (' ', 127, 1) { $2 = char(()); undefinekey($2, $1); } definekey("rmail_folder_newmail", "g", $1); definekey("rmail_folder_newmail", "G", $1); definekey("rmail_quit_rmail", "q", $1); definekey("rmail_quit_rmail", "Q", $1); definekey("rmail_select_this_folder", " ", $1); definekey("rmail_select_this_folder", "\r", $1); definekey("mail", "m", $1); definekey("mail", "M", $1); } % if parameter is 0, unlock it if it is ours. Otherwise, lock or steal it. % it returns 1 if the lock was made, 0 if not. define rmail_check_lock_file(lck) { variable lpid, this_pid = string(getpid()), do_del; variable lfn = "___LOCKED___"; variable lock_file = dircat (Rmail_Directory, lfn); variable ret = 0, write_it = 0; variable errbuf; variable ourhost = getenv ("HOST"); if (ourhost == NULL) ourhost = ""; variable lockhost = Null_String; variable lock_buffer; variable flags; lock_buffer = " " + lfn; ERROR_BLOCK { if (bufferp (lock_buffer)) { setbuf (lock_buffer); set_buffer_modified_flag(0); delbuf (lock_buffer); } } EXECUTE_ERROR_BLOCK; () = read_file(lock_file); clear_message (); (,flags) = getbuf_info (); setbuf_info (lock_buffer, flags); set_buffer_no_backup (); % extract the pid, it will be null if file was created bob(); push_mark(); if (ffind_char (':')) { lockhost = bufsubstr (); go_right_1 (); push_mark (); } eol(); lpid = bufsubstr(); delete_line(); vinsert ("%s:%s", ourhost, this_pid); if (lck) { if (strlen (lockhost)) { if (lockhost != ourhost) { verror ("Pid %s on host %s is locking the mail file. Sorry.", lpid, lockhost); } } % check existence of pid if (kill(integer (lpid), 0)) lpid = ""; if (strlen (lpid) and (lpid != this_pid)) { verror ("Pid %s is locking mail directory. Sorry.", lpid); } save_buffer (); % Now that we have created a lock file, we use a trick to unlock it % in case jed is exited ungracefully. erase_buffer (); rmail_set_buffer_flags (); return 1; } % We get here if we are unlocking the file. #iffalse if ((lockhost != ourhost) or (lpid != this_pid)) return 0; () = delete_file(lock_file); #else if ((lockhost == ourhost) and (lpid == this_pid)) () = delete_file(lock_file); #endif if (bufferp (lock_buffer)) { setbuf(lock_buffer); set_buffer_modified_flag (0); delbuf (lock_buffer); } return 0; } define rmail_quit_rmail() { rmail_exit_folder(); % This puts us at the root again so save and get out. rmail_save_buffer_secure(); delbuf(Rmail_Root_Buffer); () = rmail_check_lock_file(0); % deletes the lock file. } define rmail () { variable n; !if (rmail_check_lock_file(1)) return; rmail_save_folder(Rmail_Folder_Name, 1); Rmail_Folder_Buffer = Null_String; rmail_folder_mode(); n = rmail_get_newmail(); if (n) { flush(sprintf("%d new messages.", n)); rmail_select_folder(Rmail_Newmail_Folder); } } jed-0.99-19/lib/ide.sl0000644002657400265740000005512211311317447013346 0ustar davisdavis% Borland-like IDE Mode for JED -*- SLang -*- % % Put the line: () = evalfile ("ide.sl"); % in your jed.rc startup file. % % Written by Guido Gonzato ; % based on John E. Davis' original wordstar.sl. % Contributions by J\o ergen Larsen , % and John Fattaruso % % This file makes jed a jolly good 99% compatible with the true-blue % WordStar, jstar, the DOS editor, and the good old Borland IDE. % Some Emacs compatibility is maintained: blocks are actually "regions" % as in Emacs mode. % % Please send me requests and bug reports, should you find any. % % Version 1.3.4; for jed B0.99.13 upwards. % Last modified: 2 April 2003 % Version 1.3.4a: Changed static declarations to private ones for % 0.99.19 release (JED) Help_File = "ide.hlp"; require ("keydefs"); require ("rcs"); _Reserved_Key_Prefix = "\032"; % ^Z _Jed_Emulation = "ide"; % users can tailor the way skip_word works custom_variable ("Ide_Skippable_Chars", "\n\t !\"#$%&'()*+,-./:;<=>?@[\]^`{|}~"); #ifndef IBMPC_SYSTEM private variable Key_BS_Del = "^?"; private variable Key_Alt_BS_Del = strcat("\e", Key_BS_Del); #endif private variable Ide_Bookmark_Exist = 1; set_status_line (" Jed %v: %b (%m%n) (%p %c) %t", 1); unset_ctrl_keys (); unsetkey (Key_F1); % prevent EDT error in xterm unsetkey (Key_F2); unsetkey (Key_F3); unsetkey (Key_F4); unsetkey (Key_Del); unsetkey (Key_Up); % arrows keys are redefined to add the unsetkey (Key_Down); % "goto previous position" feature unsetkey (Key_Left); unsetkey (Key_Right); unsetkey (Key_PgUp); unsetkey (Key_PgDn); set_abort_char (7); % ^G. Note - wordstar.sl uses ^^. setkey ("kbd_quit", "^G"); % % Basic commands: cursor movement, delete, search & replace, etc. % setkey ("begin_macro", "\e("); setkey ("compile", Key_F9); setkey ("backward_delete_char", Key_BS); setkey ("dabbrev", "^V"); setkey ("delete_char_cmd", "\eg"); % ^G is used for break setkey ("delete_char_cmd", Key_Del); setkey ("delete_line", "^Y"); setkey ("end_macro", "\e)"); setkey ("execute_macro", "\er"); setkey ("format_paragraph", "^B"); setkey ("ide_better_help", Key_F1); setkey ("ide_toggle_overwrite", Key_Ins); setkey ("undo", "^U"); setkey ("kbd_quit", "\e\e\e"); setkey ("ide_bdelete_word", Key_Alt_BS); setkey ("list_buffers", "\e0"); #ifndef IBMPC_SYSTEM setkey ("ide_bdelete_word", Key_Alt_BS_Del); #endif setkey ("ide_bdelete_word", "\et"); % ESC-o is used for Mode menu setkey ("ide_bskip_word", "^A"); setkey ("ide_delete_word", "^T"); setkey ("ide_next_char_cmd", "^D"); setkey ("ide_next_char_cmd", Key_Right); setkey ("ide_next_line_cmd", "^X"); setkey ("ide_next_line_cmd", Key_Down); setkey ("ide_page_down", "^C"); setkey ("ide_page_down", Key_PgDn); setkey ("ide_page_up", "^R"); setkey ("ide_page_up", Key_PgUp); setkey ("ide_previous_char_cmd", "^S"); setkey ("ide_previous_char_cmd", Key_Left); setkey ("ide_previous_line_cmd", "^E"); setkey ("ide_previous_line_cmd", Key_Up); setkey ("ide_repeat_search", "^L"); setkey ("ide_skip_word", "^F"); setkey ("other_window", "^KO"); setkey ("other_window", "^K^O"); setkey ("ide_window_up", "^W"); setkey ("ide_window_down", "\eZ"); setkey ("ide_insert_any_char", "^P"); % % Control-Q keys --- hope you figure out how to pass ^Q/^S through system % In case you *cannot* figure out how, you can use ESC+^key instead of ^Q; % for instance, ESC-^Y acts as ^Q-Y. Twisted, but some terminals need it. % There's an exception: use ESC + ESC + digit to mimick ^Q + digit; this is % to avoid overriding the ESC + number + operation feature. % setkey (".0 ide_goto_mark_n", "^Q0"); setkey (".1 ide_goto_mark_n", "^Q1"); setkey (".2 ide_goto_mark_n", "^Q2"); setkey (".3 ide_goto_mark_n", "^Q3"); setkey (".4 ide_goto_mark_n", "^Q4"); setkey (".5 ide_goto_mark_n", "^Q5"); setkey (".6 ide_goto_mark_n", "^Q6"); setkey (".7 ide_goto_mark_n", "^Q7"); setkey (".8 ide_goto_mark_n", "^Q8"); setkey (".9 ide_goto_mark_n", "^Q9"); #ifndef MSDOS WIN32 setkey (".0 ide_goto_mark_n", "\e\e0"); setkey (".1 ide_goto_mark_n", "\e\e1"); setkey (".2 ide_goto_mark_n", "\e\e2"); setkey (".3 ide_goto_mark_n", "\e\e3"); setkey (".4 ide_goto_mark_n", "\e\e4"); setkey (".5 ide_goto_mark_n", "\e\e5"); setkey (".6 ide_goto_mark_n", "\e\e6"); setkey (".7 ide_goto_mark_n", "\e\e7"); setkey (".8 ide_goto_mark_n", "\e\e8"); setkey (".9 ide_goto_mark_n", "\e\e9"); #endif setkey ("kill_line", "^QY"); setkey ("kill_line", "^Q^Y"); setkey ("quoted_insert", "^Q^Q"); setkey ("ide_bob", "^QR"); setkey ("ide_bob", "^Q^R"); setkey ("ide_bol", "^QS"); setkey ("ide_bol", "^Q^S"); setkey ("ide_bol", Key_Home); setkey ("ide_eob", "^QC"); setkey ("ide_eob", "^Q^C"); setkey ("ide_eol", "^QD"); setkey ("ide_eol", "^Q^D"); setkey ("ide_eol", Key_End); setkey ("ide_goto_begin_block", "^QB"); setkey ("ide_goto_begin_block", "^Q^B"); setkey ("ide_goto_bottom_of_window", "^QX"); setkey ("ide_goto_bottom_of_window", "^Q^X"); setkey ("ide_goto_end_block", "^QK"); setkey ("ide_goto_end_block", "^Q^K"); setkey ("ide_goto_line_cmd", "^QI"); setkey ("ide_goto_line_cmd", "^Q^I"); setkey ("ide_goto_middle_of_window", "^QM"); setkey ("ide_goto_prev", "^QP"); setkey ("ide_goto_top_of_window", "^QE"); setkey ("ide_goto_top_of_window", "^Q^E"); setkey ("ide_replace_cmd", "^QA"); setkey ("ide_replace_cmd", "^Q^A"); setkey ("ide_search_forward", "^QF"); setkey ("ide_search_forward", "^Q^F"); setkey ("ide_toggle_case", "^QT"); setkey ("ide_toggle_case", "^Q^T"); #ifndef MSDOS WIN32 setkey ("kill_line", "\e^Y"); setkey ("ide_bob", "\e^R"); setkey ("ide_bol", "\e^S"); setkey ("ide_eob", "\e^C"); setkey ("ide_eol", "\e^D"); setkey ("ide_goto_begin_block", "\e^B"); setkey ("ide_goto_bottom_of_window", "\e^X"); setkey ("ide_goto_end_block", "\e^K"); setkey ("ide_goto_line_cmd", "\e^I"); setkey ("ide_goto_prev", "\e^P"); setkey ("ide_goto_top_of_window", "\e^E"); setkey ("ide_replace_cmd", "\e^A"); setkey ("ide_search_forward", "\e^F"); setkey ("ide_toggle_case", "\e^T"); #endif % % Control-K map % setkey (".0 ide_set_mark_n", "^K0"); setkey (".1 ide_set_mark_n", "^K1"); setkey (".2 ide_set_mark_n", "^K2"); setkey (".3 ide_set_mark_n", "^K3"); setkey (".4 ide_set_mark_n", "^K4"); setkey (".5 ide_set_mark_n", "^K5"); setkey (".6 ide_set_mark_n", "^K6"); setkey (".7 ide_set_mark_n", "^K7"); setkey (".8 ide_set_mark_n", "^K8"); setkey (".9 ide_set_mark_n", "^K9"); setkey ("exit_jed", "^KX"); setkey ("exit_jed", "^K^X"); setkey ("find_file", "^KE"); setkey ("find_file", "^K^E"); setkey ("find_file", Key_F3); setkey ("kill_buffer", "^KQ"); setkey ("kill_buffer", "^K^Q"); setkey ("kill_buffer", Key_Alt_F3); setkey ("split_window", Key_Alt_F5); setkey ("one_window", "^KI"); setkey ("one_window", "^K^I"); setkey ("one_window", Key_F5); setkey ("save_buffer", "^KD"); setkey ("save_buffer", "^K^D"); setkey ("save_buffer", Key_F2); setkey ("suspend", "^KZ"); setkey ("suspend", "^K^Z"); setkey ("ide_next_buffer (0)", "^KP"); % next setkey ("ide_next_buffer (0)", "^K^P"); setkey ("ide_next_buffer (1)", "^KN"); % previous setkey ("ide_next_buffer (1)", "^K^N"); setkey ("ide_next_buffer (1)", Key_F6); setkey ("ide_begin_block", "^KB"); % set mark setkey ("ide_begin_block", "^K^B"); setkey ("ide_copy_block", "^KC"); % yank setkey ("ide_copy_block", "^K^C"); setkey ("ide_delete_block", "^KY"); % cut setkey ("ide_delete_block", "^K^Y"); setkey ("comment_region", "^K;"); setkey ("uncomment_region", "^K:"); setkey_reserved ("comment_line", ";"); setkey_reserved ("uncomment_line", ":"); setkey ("ide_filter_region", "^K/"); setkey ("ide_open_file_at_cursor", "\e^M"); setkey ("ide_insert_file", "^KR"); setkey ("ide_insert_file", "^K^R"); setkey ("ide_lowercase_region", "^KL"); setkey ("ide_lowercase_region", "^K^L"); setkey ("ide_save_buffer", "^KS"); setkey ("ide_save_buffer", "^K^S"); setkey ("ide_select_word", "^KT"); setkey ("ide_select_word", "^K^T"); setkey ("ide_void_block", "^KK"); setkey ("ide_void_block", "^K^K"); setkey ("ide_clear_block", "^KH"); % copy to the clipboard setkey ("ide_clear_block", "^K^H"); setkey ("ide_uppercase_region", "^KU"); setkey ("ide_uppercase_region", "^K^U"); setkey ("write_region", "^KW"); setkey ("write_region", "^K^W"); setkey ("reg_insert_register", "^KJ"); % registers are something like setkey ("reg_insert_register", "^K^J"); % a multiple clipboard setkey ("reg_copy_to_register", "^KG"); setkey ("reg_copy_to_register", "^K^G"); % compiler/debugger interface setkey ("compile_parse_errors", Key_Alt_F8); % was ^X' setkey_reserved ("compile_parse_errors", "'"); setkey ("compile_previous_error", Key_Alt_F7); % was ^X, setkey_reserved ("compile_previous_error", ","); setkey ("ispell", Key_F7); % % Now let's implement the damn thing % $1 = 13; % bookmarks 0..9 are for the user; bookmark 10 is used by some of the % following functions; bookmark 11 and 12 mark the beginning and end of % the block (used by ^QB and ^QK) private variable _Ide_Bookmarks = Mark_Type[$1]; % ide_set_bookmark () and ide_goto_bookmark () are implemented to provide % a more Borland-ish way of copying and moving blocks, and of moving % around generally. define ide_set_bookmark () { _Ide_Bookmarks[10] = create_user_mark (); Ide_Bookmark_Exist = 1; } define ide_goto_bookmark () { variable mrk = _Ide_Bookmarks[10]; ide_set_bookmark (); sw2buf (mrk.buffer_name); goto_user_mark (mrk); } % % Basic commands: cursor movement, delete, search & replace, etc. % define ide_execute_macro () % ESC-R { ide_set_bookmark (); call ("execute_macro"); } define ide_previous_char_cmd () % Key_Left { ide_set_bookmark (); call ("previous_char_cmd"); } define ide_next_char_cmd () % Key_Right { ide_set_bookmark (); call ("next_char_cmd"); } define ide_next_line_cmd () % Key_Down { ide_set_bookmark (); call ("next_line_cmd"); } define ide_previous_line_cmd () % Key_Up { ide_set_bookmark (); call ("previous_line_cmd"); } define ide_page_down () % Key_PgDn { ide_set_bookmark (); call ("page_down"); } define ide_page_up () % Key_PgUp { ide_set_bookmark (); call ("page_up"); } define ide_bob () % ^QR { ide_set_bookmark (); bob (); } define ide_eob () % ^QC { ide_set_bookmark (); eob (); } define ide_bol () % Key_Home { ide_set_bookmark (); bol (); } define ide_eol () % Key_End { ide_set_bookmark (); eol (); } define ide_goto_bottom_of_window () % ^QX { ide_set_bookmark (); goto_bottom_of_window (); } define ide_goto_top_of_window () % ^QE { ide_set_bookmark (); goto_top_of_window (); } define ide_goto_middle_of_window () % ^QM { % incorrect if the buffer has fewer lines % than the windows that contains it. Duh. goto_top_of_window (); go_down (window_info ('r') / 2); } define ide_window_up () % ^W - J.F. { variable current,bottom; current = window_line (); bottom = window_info ('r'); ide_set_bookmark (); if (current == bottom) { ide_previous_line_cmd (); recenter (bottom); } else recenter (current + 1); } define ide_window_down () % \eZ J.F. { variable current = window_line (); ide_set_bookmark (); if (current == 1) { ide_next_line_cmd (); recenter (1); } else recenter (current - 1); } define ide_goto_line_cmd () % ^QI { ide_set_bookmark (); goto_line_cmd (); } define ide_replace_cmd () % ^QA { ide_set_bookmark (); replace_cmd (); } define ide_search_forward () % ^QF { ide_set_bookmark (); search_forward (); } define ide_toggle_case () % ^QT { variable on_off; CASE_SEARCH = not(CASE_SEARCH); if (CASE_SEARCH == 1) on_off = "On"; else on_off = "Off"; vmessage ("Case search is %s ", on_off); } define ide_toggle_overwrite () { toggle_overwrite (); if (is_overwrite_mode ()) message ("Overwrite"); else message ("Insert"); } define ide_repeat_search () % ^L { ide_set_bookmark (); go_right_1 (); !if (fsearch(LAST_SEARCH)) error ("Not found."); } define ide_bdelete_word () % M-O { variable p = _get_point (); ide_set_bookmark (); push_mark (); bskip_chars ("a-zA-Z0-9"); if (_get_point () == p) bskip_chars (" \n\t"); if (_get_point () == p) go_left (1); del_region (); } define ide_bskip_word () % ^A { variable p = _get_point (); ide_set_bookmark (); push_mark (); bskip_chars (Ide_Skippable_Chars); bskip_chars ("^" + Ide_Skippable_Chars); pop_mark_0 (); } define ide_delete_word () % ^T { variable p = _get_point (); push_mark (); skip_chars ("a-zA-Z0-9"); if (_get_point () == p) skip_chars (" \n\t"); if (_get_point () == p) go_right (1); del_region (); } define ide_skip_word () % ^F { variable p = _get_point (); ide_set_bookmark (); push_mark (); skip_chars ("^" + Ide_Skippable_Chars); if (_get_point () == p) { skip_chars (Ide_Skippable_Chars); skip_chars ("^" + Ide_Skippable_Chars); } pop_mark_0 (); } define ide_insert_any_char () % ^P { variable i, ch = 0, c, msg = ""; message ("ASCII-"); update_sans_update_hook (0); for (i = 100; i > 0; i = i / 10) { vmessage ("ASCII-%s", msg); update_sans_update_hook (0); do { c = getkey (); } while ( (c < '0') or (c > '9')); ch = ch + i * (c - '0'); msg += sprintf ("%c", c); vmessage ("ASCII-%s", msg); update_sans_update_hook (0); } insert_char (ch); vmessage ("ASCII-%s", msg); } define ide_next_buffer (previous) % Key_F6 | ^KN | Key_Alt_F6 | ^KP { variable n, buf; n = buffer_list (); % get the buffers on the stack if (previous) _stk_reverse (n-1); loop (n) { buf = (); n--; if (buf[0] == ' ') continue; sw2buf (buf); _pop_n (n); return; } } % Blocks: ^K-something % % blocks are no longer as in wordstar.sl. We don't cheat anymore. Rather, % blocks are implemented a la Emacs to maintain compatibility with most .sl % files (e.g., latex.sl, cmode.sl, etc) private variable IDE_Block_Buffer = "*ide-clipboard*"; private variable IDE_Block_Buffer_Empty = 1; define ide_copy_block_to_buffer () % paste the new region to the clipboard, then delete the old stuff { setbuf(IDE_Block_Buffer); erase_buffer (); call ("yank"); } define ide_begin_block () % ^KB { _Ide_Bookmarks[11] = create_user_mark (); call ("set_mark_cmd"); } define ide_end_block () { _Ide_Bookmarks[12] = create_user_mark (); exchange_point_and_mark (); } define ide_copy_block () % ^KC { ide_set_bookmark (); insbuf (IDE_Block_Buffer); ide_goto_bookmark (); } define ide_goto_begin_block () % ^QB { variable mrk = _Ide_Bookmarks[11]; ide_set_bookmark (); sw2buf (mrk.buffer_name); ide_set_bookmark (); goto_user_mark (mrk); } define ide_goto_end_block () % ^QK { variable mrk = _Ide_Bookmarks[12]; ide_set_bookmark (); sw2buf (mrk.buffer_name); ide_set_bookmark (); goto_user_mark (mrk); } define ide_void_block () % ^KK { pop_mark_0 (); error ("Obsolete - use ^KH instead."); } define ide_clear_block () % ^KH { ide_end_block (); call ("copy_region"); % copy region to internal buffer ide_copy_block_to_buffer (); IDE_Block_Buffer_Empty = 0; ide_goto_end_block (); } define ide_delete_block () % ^KY { ide_clear_block (); % copy the region to the clipboard, then ide_goto_begin_block (); % redefine the region and delete it. Rather ide_begin_block (); % twisted, but that's the way I like it! ide_goto_end_block (); ide_end_block (); call ("kill_region"); } define ide_goto_prev () % ^QP { if (Ide_Bookmark_Exist != 1) error ("No previous location!"); ide_goto_bookmark (); } define ide_open_file_at_cursor () % Alt-Return, J.L. { push_spot (); % Find the substring which could be a file name. - % The following method assumes reasonably standard file names. #ifdef UNIX bskip_chars ("-0-9a-zA-Z_!%+~./"); % left limit push_mark (); skip_chars ("-0-9a-zA-Z_!%+~./"); % right limit #else % DOS is supposed here: % DOS path names have backslashes and may contain a drive spec. bskip_chars ("-0-9a-zA-Z_!%+~./\\:"); % left limit push_mark (); skip_chars ("-0-9a-zA-Z_!%+~./\\:"); % right limit #endif variable fn = bufsubstr (); % the file name pop_mark_0 (); pop_spot (); !if (1 == file_status (fn)) error(strcat("File ",fn," not found")); () = find_file (fn); } define ide_insert_file () % ^KR { variable file = read_with_completion ("File:", Null_String, Null_String, 'f'); push_spot (); () = insert_file (file); pop_spot (); } define ide_select_word () % ^KT, Borland IDE facility { ide_skip_word (); ide_bskip_word (); ide_begin_block (); ide_skip_word (); ide_end_block (); message ("Word selected."); } #ifndef IBMPC_SYSTEM private variable Last_Process_Command = Null_String; define ide_filter_region () % ^K/, Joe extension { variable cmd, tmp_file; ide_end_block (); cmd = read_mini ("Pipe to command:", Last_Process_Command, Null_String); !if (strlen (cmd)) return; Last_Process_Command = cmd; ide_set_bookmark (); tmp_file = make_tmp_file ("/tmp/jedpipe"); cmd = strcat (cmd, " > ", tmp_file, " 2>&1"); if (pipe_region (cmd)) { error ("Process returned a non-zero exit status."); } () = insert_file (tmp_file); ide_begin_block (); ide_goto_end_block (); ide_end_block (); call ("kill_region"); () = delete_file (tmp_file); } #endif define ide_uppercase_region() % ^KU { ide_end_block (); xform_region('u'); ide_goto_end_block (); } define ide_lowercase_region() % ^KL { ide_end_block (); xform_region('d'); ide_goto_end_block (); } % % These are the predefined bookmarks 0..9, a la Wordstar. % define ide_goto_mark_n (n) { variable mrk = _Ide_Bookmarks[n]; if (mrk == NULL) error ("Bookmark not set!"); ide_set_bookmark (); sw2buf (mrk.buffer_name); goto_user_mark (mrk); message ("done."); } define ide_set_mark_n (n) % ^K0..9 { _Ide_Bookmarks[n] = create_user_mark (); vmessage ("Bookmark %d set.", n); } define ide_save_buffer () % ^KS { variable file = read_file_from_mini ("Save to file:"); if (file == "") return; () = write_buffer (file); } define ide_better_help () { variable file = expand_jedlib_file (Help_File); () = read_file (file); pop2buf (whatbuf ()); most_mode (); call ("one_window"); set_readonly (1); } % Menu Interface. Use existing menu definitions in most cases, but % change definitions in others. private define ide_load_popups_hook () { variable m; m = "Global.&File"; menu_delete_items (m); menu_append_item (m, "&Open", "find_file"); menu_append_item (m, "&Close", ".whatbuf delbuf"); menu_append_item (m, "&Save", "save_buffer"); menu_append_item (m, "Save &As", "ide_save_buffer"); menu_append_item (m, "Save &Buffers", "save_some_buffers"); menu_append_item (m, "&Insert File", "ide_insert_file"); menu_append_popup (m, "&Versions"); menu_append_separator (m); menu_append_item (m, "Cance&l Operation", "kbd_quit"); menu_append_item (m, "S&hell", "shell"); menu_append_item (m, "E&xit", "exit_jed"); m = "Global.&File.&Versions"; menu_append_item (m, "RCS &Open File", "rcs_open_file"); menu_append_item (m, "&Check In/Out", "rcs_check_in_and_out"); menu_append_item (m, "RCS Read &Log", "rcs_read_log"); menu_append_item (m, "Backups &On", "backups_on"); menu_append_item (m, "Backups O&ff", "backups_off"); m = "Global.&Edit"; menu_delete_items (m); menu_append_item (m, "&Begin Region/Rect", "ide_begin_block"); menu_append_item (m, "&Cut", "ide_delete_block"); menu_append_item (m, "C&opy", "ide_clear_block"); menu_append_item (m, "&Paste", "ide_copy_block"); menu_append_separator (m); menu_append_popup (m, "&Rectangles"); menu_append_popup (m, "Bloc&ks"); menu_append_popup (m, "&Advanced"); menu_append_separator (m); menu_append_item (m, "Re&format", "format_paragraph"); menu_append_item (m, "&Undo", "undo"); m = "Global.&Edit.&Advanced"; menu_append_item (m, "&Compose Character", "ide_insert_any_char"); if (is_defined ("digraph_cmd")) menu_append_item (m, "S&pecial Character", "digraph_cmd"); menu_append_item (m, "Toggle &Abbrev Mode", "abbrev_mode"); if (is_defined ("toggle_auto_ispell")) menu_append_item (m, "Toggle Auto &Ispell", "toggle_auto_ispell"); menu_append_item (m, "&Ispell", "ispell"); menu_append_item (m, "Co&mpletion", "dabbrev"); menu_append_item (m, "C&enter Line", "center_line"); menu_append_separator (m); menu_append_item (m, "&Start Macro", "begin_macro"); menu_append_item (m, "S&top Macro", "end_macro"); menu_append_item (m, "&Replay Last Macro", "execute_macro"); m = "Global.&Edit.&Rectangles"; menu_append_item (m, "&Cut Rectangle", "kill_rect"); menu_append_item (m, "C&opy Rectangle", "copy_rect"); menu_append_item (m, "&Paste Rectangle", "insert_rect"); menu_append_item (m, "Op&en Rectangle", "open_rect"); menu_append_item (m, "&Blank Rectangle", "blank_rect"); m = "Global.&Edit.Bloc&ks"; menu_append_item (m, "&Write to File", "write_region"); menu_append_item (m, "&Filter", "ide_filter_region"); menu_append_item (m, "&Sort", "sort"); menu_append_item (m, "&Upper Case", "ide_uppercase_region"); menu_append_item (m, "&Lower Case", "ide_lowercase_region"); menu_append_item (m, "Copy To &Register", "reg_copy_to_register"); menu_append_item (m, "&Paste From Register", "reg_insert_register"); menu_append_item (m, "&Comment", "comment_region"); menu_append_item (m, "U&ncomment", "uncomment_region"); m = "Global.&Search"; menu_append_item (m, "Search &Forward", "ide_search_forward"); menu_append_item (m, "Repeat &Last Search", "ide_repeat_search"); menu_append_item (m, "&Replace", "ide_replace_cmd"); menu_append_item (m, "Search &Match", "goto_match"); m = "Global.&Buffers"; % menu_append_separator (m); menu_append_item (m, "C&ompile", "compile"); menu_append_item (m, "&Next Error", "compile_parse_errors"); menu_append_item (m, "&Previous Error", "compile_previous_error"); if (is_defined ("gdb_mode")) menu_append_item (m, "Debug with &gdb", "gdb_mode"); m = "Global.&Help"; % menu_append_separator (m); menu_append_item (m, "Describe ID&E Mode", "ide_better_help"); } add_to_hook ("load_popup_hooks", &ide_load_popups_hook); runhooks ("keybindings_hook", _Jed_Emulation); % --- End of file ide.sl --- jed-0.99-19/lib/f90.sl0000644002657400265740000004124111311317447013200 0ustar davisdavis% -*- mode: slang; mode: fold -*- % Free/Fixed format source F90 mode custom_variable ("F90_Continue_Char", "&"); custom_variable ("F90_Comment_String", "!"); custom_variable ("F90_Indent_Amount", 2); custom_variable ("F90_Default_Format", "free"); % or "fixed" private define get_format_mode () { if (blocal_var_exists ("F90_Mode_Format")) return get_blocal_var ("F90_Mode_Format"); return 0; } private define set_format_mode (x) { x = (strlow(x) == "free"); create_blocal_var ("F90_Mode_Format"); set_blocal_var (x, "F90_Mode_Format"); } %{{{ Free Format Functions private define free_f90_indent () { variable goal = 1; % at top of buffer it should be 1 n'est pas? variable cs = CASE_SEARCH; variable ch; % goto beginning of line and skip past tabs and spaces USER_BLOCK0 { bol (); skip_chars (" \t"); skip_white (); } push_spot (); push_spot (); CASE_SEARCH = 0; % F90 is not case sensitive while (up_1 ()) { bol_skip_white(); if (eolp() or looking_at("!") or looking_at("&") or looking_at("#") ) continue; X_USER_BLOCK0 (); goal = what_column (); % if (goal == 1) continue; skip_chars (" \t1234567890"); if (looking_at("do ") or looking_at("else") or looking_at("function") or looking_at("subroutine") or looking_at("case") or looking_at("interface") or looking_at("recursive") or looking_at("program") or looking_at("where") ) goal += F90_Indent_Amount; else if (looking_at("select") ) goal += F90_Indent_Amount * 2; else if (looking_at("if ") or looking_at("if(")) { % We want to check for 'then' so take care of continuations push_spot (); while (down_1 ()) { bol_skip_white (); !if (looking_at (F90_Continue_Char)) { go_up_1 (); bol (); break; } } if (ffind ("then")) goal += F90_Indent_Amount; pop_spot (); } else if (looking_at("type ") or looking_at("module ")) { if (not (ffind ("::"))) goal += F90_Indent_Amount; } break; } % now check current line pop_spot (); push_spot (); X_USER_BLOCK0 (); if (looking_at("end") ) { if (ffind ("select")) goal -= F90_Indent_Amount * 2; else goal -= F90_Indent_Amount; } else if ( looking_at("continue") or looking_at("case") or looking_at("else")) goal -= F90_Indent_Amount; CASE_SEARCH = cs; % done getting indent if (goal < 1) goal = 1; pop_spot (); bol_skip_white (); % after the label or continuation char and indent the rest to goal USER_BLOCK1 { %skip_chars ("0-9"); trim (); if (looking_at (F90_Continue_Char)) { go_right_1 (); trim(); goal += F90_Indent_Amount; } insert_spaces (goal - what_column()); } ch = char(what_char()); switch (ch) { case F90_Continue_Char : % continuation character bol (); trim (); X_USER_BLOCK1 (); } { not (bolp()) or eolp (): % general case bol (); trim (); goal--; insert_spaces (goal); } pop_spot (); skip_white (); } private define free_f90_is_comment () { bol (); looking_at("!"); } private define free_f90_newline () { variable p, cont , cont1; if (bolp ()) { newline (); return; } free_f90_indent (); push_spot (); bskip_white (); trim (); if (what_column () > 72) { push_spot (); bol_skip_white(); !if (bolp()) message ("Line exceeds 72 columns."); pop_spot (); } p = _get_point (); bskip_chars("-+*=/,(&<>"); cont = (p != _get_point ()); cont1 = cont; if ( cont ) { if ( looking_at( "&" ) ) { cont1 = 0; } } if (free_f90_is_comment ()) cont = 0; bol_skip_white (); if (looking_at("data ")) cont = 0; pop_spot (); if (cont1) { insert( " " ); insert(F90_Continue_Char); } newline (); if ( cont ) { insert(F90_Continue_Char); insert( " " ); } insert_single_space (); free_f90_indent (); } %}}} %{{{ Fixed Format Functions define fixed_f90_indent () { variable goal = 7; % at top of buffer it should be 7 n'est pas? variable cs = CASE_SEARCH; variable ch; % goto beginning of line and skip past continuation char USER_BLOCK0 { bol (); skip_chars ("0-9 \t"); if (looking_at(F90_Continue_Char)) go_right_1 (); skip_white (); } push_spot (); push_spot (); CASE_SEARCH = 0; % F90 is not case sensitive while (up_1 ()) { bol_skip_white(); if (eolp() or looking_at(F90_Continue_Char)) continue; X_USER_BLOCK0 (); goal = what_column (); if (goal == 1) continue; if (looking_at("do ") or looking_at("else") or looking_at("subroutine") or looking_at("interface") or looking_at("program") ) goal += F90_Indent_Amount; else if (looking_at("if ") or looking_at("if(")) { if (ffind ("then")) goal += F90_Indent_Amount; } else if (looking_at("type ") or looking_at("module ")) { if (not (ffind ("::"))) goal += F90_Indent_Amount; } break; } % now check current line pop_spot (); push_spot (); X_USER_BLOCK0 (); if (looking_at("end") or looking_at("continue") or looking_at("else")) goal -= F90_Indent_Amount; CASE_SEARCH = cs; % done getting indent if (goal < 7) goal = 7; pop_spot (); bol_skip_white (); % after the label or continuation char and indent the rest to goal USER_BLOCK1 { skip_chars ("0-9"); trim (); if (looking_at (F90_Continue_Char)) { insert_spaces (6 - what_column()); go_right_1 (); trim(); goal += F90_Indent_Amount; } insert_spaces (goal - what_column()); } ch = char(what_char()); switch (ch) { isdigit (ch) : % label if (what_column () >= 6) { bol (); trim (); insert_single_space (); } X_USER_BLOCK1 (); } { case F90_Continue_Char : % continuation character bol (); trim (); insert (" "); X_USER_BLOCK1 (); } { not (bolp()) or eolp (): % general case bol (); trim (); goal--; insert_spaces (goal); } pop_spot (); skip_white (); } define fixed_f90_is_comment () { bol (); skip_chars (" \t0-9"); bolp () and not (eolp()); } define fixed_f90_newline () { variable p, cont; if (bolp ()) { newline (); return; } fixed_f90_indent (); push_spot (); bskip_white (); trim (); if (what_column () > 72) { push_spot (); bol_skip_white(); !if (bolp()) message ("Line exceeds 72 columns."); pop_spot (); } p = _get_point (); bskip_chars("-+*=/,("); cont = (p != _get_point ()); if (fixed_f90_is_comment ()) cont = 0; bol_skip_white (); if (looking_at("data ")) cont = 0; pop_spot (); newline (); insert_single_space (); if (cont) insert(F90_Continue_Char); fixed_f90_indent (); } %}}} private define dispatch_f90_function (free, fixed) { if (get_format_mode ()) { (@free) (); return; } (@fixed) (); } define f90_indent () { dispatch_f90_function (&free_f90_indent, &fixed_f90_indent); } define f90_is_comment () { dispatch_f90_function (&free_f90_is_comment, &fixed_f90_is_comment); } define f90_newline () { dispatch_f90_function (&free_f90_newline, &fixed_f90_newline); } define f90_continue_newline () { f90_newline (); push_spot (); bol_skip_white (); if (looking_at(F90_Continue_Char)) pop_spot (); else { insert (F90_Continue_Char); pop_spot (); f90_indent (); go_right_1 (); skip_white (); } } % % electric labels % define f90_electric_label () { insert_char (LAST_CHAR); if (get_format_mode ()) return; % free-format push_spot (); if (f90_is_comment ()) pop_spot (); else { bol_skip_white (); skip_chars ("0-9"); trim (); pop_spot (); f90_indent (); } } % f90 comment/uncomment functions define f90_uncomment () { push_spot (); if (f90_is_comment ()) { bol (); if (looking_at (F90_Comment_String)) deln (strlen (F90_Comment_String)); else del (); } f90_indent (); pop_spot (); go_down_1 (); } define f90_comment () { !if (f90_is_comment ()) { push_spot (); bol (); insert (F90_Comment_String); } pop_spot (); go_down_1 (); } % % Look for beginning of current subroutine/function % define f90_beg_of_subprogram () { variable cs = CASE_SEARCH; CASE_SEARCH = 0; do { bol_skip_white (); if (_get_point ()) { if (looking_at ("program") or looking_at ("function") or looking_at ("subroutine")) break; } } while (up_1 ()); CASE_SEARCH = cs; } % % Look for end of current subroutine/function % define f90_end_of_subprogram () { variable cs = CASE_SEARCH; CASE_SEARCH = 0; do { bol_skip_white (); if (looking_at ("end")) { go_right (3); skip_white (); if (eolp ()) break; } } while (down_1 ()); CASE_SEARCH = cs; } define f90_mark_subprogram () { f90_end_of_subprogram (); go_down_1 (); push_mark (); call ("set_mark_cmd"); f90_beg_of_subprogram (); bol (); } % % shows a ruler for F90 source. Press any key to get rid of % define f90_ruler () { variable c = what_column (); variable r = window_line (); bol (); push_mark (); insert (" 5 7 10 15 20 25 30 35 40 45 50 55 60 65 70\n"); insert ("{ }|{ | | | | | | | | | | | | | }\n"); goto_column (c); if (r <= 2) r = 3; recenter (r); message ("Press SPACE to get rid of the ruler."); update_sans_update_hook (1); () = getkey (); bol (); del_region (); goto_column (c); flush_input (); recenter (r); } private define f90_prev_next_statement (dirfun) { while (@dirfun ()) { bol (); skip_chars ("^0-9 \t\n"); !if (_get_point ()) break; } variable col = 7; if (get_format_mode ()) col = 1; () = goto_column_best_try (col); } % % moves cursor to the next statement, skipping comment lines % define f90_next_statement () { f90_prev_next_statement (&down_1); } % % moves cursor to the previous f90 statement, skipping comments % define f90_previous_statement () { f90_prev_next_statement (&up_1); } % % main entry point into the f90 mode % $1 = "F90"; !if (keymap_p ($1)) make_keymap ($1); definekey ("f90_comment", "\e;", $1); definekey ("f90_uncomment", "\e:", $1); definekey ("f90_continue_newline", "\e\r", $1); definekey ("self_insert_cmd", "'", $1); definekey ("self_insert_cmd", "\"", $1); definekey ("f90_beg_of_subprogram", "\e^A", $1); definekey ("f90_end_of_subprogram", "\e^E", $1); definekey ("f90_mark_function", "\e^H", $1); definekey_reserved ("f90_next_statement", "^N", $1); definekey_reserved ("f90_previous_statement", "^P", $1); definekey_reserved ("f90_ruler", "^R", $1); _for (0, 9, 1) { $2 = (); definekey ("f90_electric_label", string($2), $1); } % Set up syntax table foreach (["F90_free", "F90_fixed"]) { $1 = (); create_syntax_table ($1); define_syntax ("!", "", '%', $1); define_syntax ("([", ")]", '(', $1); define_syntax ('"', '"', $1); define_syntax ('\'', '\'', $1); % define_syntax ('\\', '\\', $1); define_syntax ("0-9a-zA-Z_", 'w', $1); % words define_syntax ("-+0-9eEdD", '0', $1); % Numbers define_syntax (",.", ',', $1); define_syntax ('#', '#', $1); define_syntax ("-+/*=", '+', $1); % F77 keywords + include, record, structure, while: % backspace block % call character common complex continue % data dimension do double % else end enddo endfile endif entry equivalence exit external % format function % goto % if implicit include inquire integer intrinsic % logical % parameter pause precision program % real return rewind % save stop subroutine % then % while % % Extensions for Fortran 90: % allocatable % allocate % case % contains % cycle % deallocate % elsewhere % endblockdata % endfunction % endinterface % endmodule % endprogram % endselect % endsubroutine % endtype % endwhere % intent % interface % kind % module % moduleprocedure % namelist % nullify % optional % pointer % private % public % recursive % select % selectcase % sequence % target % type % use % where % () = define_keywords ($1, "dogoifto", 2); () = define_keywords ($1, "enduse", 3); () = define_keywords ($1, "callcasedataelseexitgotokindopenreadrealsavestopthentype", 4); () = define_keywords ($1, "blockclosecycleenddoendifentrypauseprintwherewhilewrite", 5); () = define_keywords ($1, "commondoubleformatintentmodulepublicrecordreturnrewindselecttarget", 6); () = define_keywords ($1, "complexendfileendtypeincludeinquireintegerlogicalnullifypointerprivateprogram", 7); () = define_keywords ($1, "allocatecontainscontinueendwhereexternalfunctionimplicitnamelistoptionalsequence", 8); () = define_keywords ($1, "backspacecharacterdimensionelsewhereendmoduleendselectinterfaceintrinsicparameterprecisionrecursivestructure", 9); () = define_keywords ($1, "deallocateendprogramselectcasesubroutine", 10); () = define_keywords ($1, "allocatableendfunctionequivalence", 11); () = define_keywords ($1, "endblockdataendinterface", 12); () = define_keywords ($1, "endsubroutine", 13); () = define_keywords ($1, "moduleprocedure", 15); () = define_keywords_n ($1, "eqgegtleltneor", 2, 1); () = define_keywords_n ($1, "absallandanycosdimexpintiorlenlgelgtllelltlogmaxminmodnotsinsumtan", 3, 1); () = define_keywords_n ($1, "acosaintasinatancharcoshdblehugeiandieorkindnintpackrealscansignsinhsizesqrttanhtinytrimtrue", 4, 1); () = define_keywords_n ($1, "aimaganintatan2btestcmplxconjgcountdprodfalseflooribclribitsibseticharindexishftlog10mergeradixrangescaleshape", 5, 1); () = define_keywords_n ($1, "cshiftdigitsiacharishftclboundmatmulmaxlocmaxvalminlocminvalmodulomvbitsrepeatspreaduboundunpackverify", 6, 1); () = define_keywords_n ($1, "adjustladjustrceilingeoshiftepsilonlogicalnearestpresentproductreshapespacing", 7, 1); () = define_keywords_n ($1, "bit_sizeexponentfractionlen_trimtransfer", 8, 1); () = define_keywords_n ($1, "allocatedprecisionrrspacingtranspose", 9, 1); () = define_keywords_n ($1, "associated", 10, 1); () = define_keywords_n ($1, "dot_productmaxexponentminexponentrandom_seed", 11, 1); () = define_keywords_n ($1, "set_exponentsystem_clock", 12, 1); () = define_keywords_n ($1, "date_and_timerandom_number", 13, 1); () = define_keywords_n ($1, "selected_int_kind", 17, 1); () = define_keywords_n ($1, "selected_real_kind", 18, 1); } set_syntax_flags ("F90_free", 1); set_syntax_flags ("F90_fixed", 1|2); set_fortran_comment_chars ("F90_fixed", "^0-9 \t\n"); private define setup_f90_mode (format) { variable mode = "F90"; set_mode (sprintf ("%s-%s", mode, format), 0x4 | 0x10); use_keymap (mode); set_buffer_hook ("indent_hook", "f90_indent"); set_buffer_hook ("newline_indent_hook", "f90_newline"); set_format_mode (format); use_syntax_table (strcat ("F90_", format)); } public define f90_free_format_mode () { setup_f90_mode ("free"); run_mode_hooks ("f90_free_format_mode_hook"); } public define f90_fixed_format_mode () { setup_f90_mode ("fixed"); run_mode_hooks ("f90_fixed_format_mode_hook"); } %!%+ %\function{f90_mode} %\synopsis{f90_mode} %\description % Mode designed for the purpose of editing F90 files. % After the mode is loaded, the hook 'f90_hook' is called. % Useful functions include: %#v+ % Function: Default Binding: % f90_continue_newline ESC RETURN % indents current line, and creates a continuation line on next line. % f90_comment ESC ; % comments out current line % f90_uncomment ESC : % uncomments current line % f90_electric_label 0-9 % Generates a label for current line or simply inserts a digit. % f90_next_statement ^C^N % moves to next f90 statementm skips comment lines % f90_previous_statement ^C^P % moves to previous f90 statement, skips comment lines % f90_ruler ^C^R % inserts a ruler above the current line. Press any key to continue % f90_beg_of_subprogram ESC ^A % moves cursor to beginning of current subroutine/function % f90_end_of_subprogram ESC ^E % moves cursor to end of current subroutine/function % f90_mark_subprogram ESC ^H % mark the current subroutine/function %#v- % Variables include: %#v+ % F90_Continue_Char --- character used as a continuation character. % By default, its value is ">" % F90_Comment_String --- string used by 'f90_comment' to % comment out a line. The default string is "C "; % F90_Indent_Amount --- number of spaces to indent statements in % a block. The default is 2. % F90_Default_Format --- Either "fixed" or "free". %#v- %!%- public define f90_mode () { setup_f90_mode (strlow (F90_Default_Format)); run_mode_hooks ("f90_mode_hook"); } provide ("f90"); jed-0.99-19/lib/xformreg.sl0000644002657400265740000000313711311317447014435 0ustar davisdavisprivate define skip_chars_to_mark (chars, mark) { skip_chars (chars); if (create_user_mark () > mark) goto_user_mark (mark); } private define skip_word_chars_to_mark (mark) { skip_word_chars (); if (create_user_mark () > mark) goto_user_mark (mark); } private define chgcase_reg () { check_region (0); variable end = create_user_mark (); pop_mark_1 (); while (create_user_mark () < end) { push_mark (); skip_chars_to_mark ("^\\u", end); insert (strup (bufsubstr_delete ())); push_mark (); skip_chars_to_mark ("^\\l", end); insert (strlow (bufsubstr_delete ())); } } private define cap_region () { check_region (0); variable end = create_user_mark (); pop_mark_1 (); while (create_user_mark () < end) { skip_non_word_chars (); if (create_user_mark () >= end) break; variable wch = what_char (); % The insertion must be done before the deletion to handle a single % character word. This is because the "end" mark follows the character % and if the deletion took place first, the insertion would happen % AFTER the mark, which is not what is wanted. insert (strup (char (wch))); del (); push_mark (); skip_word_chars_to_mark (end); insert (strlow (bufsubstr_delete ())); } } public define xform_region (how) { check_region (0); variable f; switch (how) { case 'u': f = &strup; } { case 'd': f = &strlow; } { case 'c': return cap_region (); } { % default return chgcase_reg (); } dupmark (); variable reg = (@f)(bufsubstr ()); del_region (); insert (reg); } jed-0.99-19/lib/menus.sl0000644002657400265740000000447211311317447013736 0ustar davisdavispublic variable Menu_Popups_Loaded = 0; $1 = "Global"; menu_create_menu_bar ($1); menu_append_popup ($1, "&File"); menu_append_popup ($1, "&Edit"); menu_append_popup ($1, "M&ode"); % mode-specific menu_append_popup ($1, "&Search"); menu_append_popup ($1, "&Buffers"); menu_append_popup ($1, "W&indows"); % Emacs uses ESC-w for yank. Keep it !if (_jed_secure_mode) menu_append_popup ($1, "S&ystem"); menu_append_popup ($1, "&Help"); menu_set_menu_bar_prefix ($1, "F10 key ==> "); #ifndef IBMPC_SYSTEM setkey ("select_menubar", "\e[21~"); % F10 # ifdef UNIX _for (0, 9, 1) { % Bind keys F0-F9 to select_menubar. $1 = (); setkey ("select_menubar", sprintf ("^(k%d)", $1)); } #endif #endif private define unset_setkey (fun, key) { unsetkey (key); setkey (fun, key); } define enable_menu_keys () { #ifdef UNIX unset_setkey ("select_menubar", "^(k;)"); #else # ifdef IBMPC_SYSTEM unset_setkey ("select_menubar", "^@D"); # endif #endif unset_setkey ("select_menubar", "\em"); unset_setkey ("@\emF", "\ef"); unset_setkey ("@\emE", "\ee"); unset_setkey ("@\emo", "\eo"); % Mode menu unset_setkey ("@\emS", "\es"); unset_setkey ("@\emB", "\eb"); unset_setkey ("@\emi", "\ei"); unset_setkey ("@\emH", "\eh"); unset_setkey ("@\emy", "\ey"); #ifdef IBMPC_SYSTEM unset_setkey ("@\emF", "^@!"); % Alt-F unset_setkey ("@\emE", "^@^R"); % Alt-E unset_setkey ("@\emo", "^@^X"); % Alt-O unset_setkey ("@\emS", "^@^_"); % Alt-S unset_setkey ("@\emB", "^@0"); % Alt-B unset_setkey ("@\emi", "^@^W"); % Alt-I unset_setkey ("@\emH", "^@#"); % Alt-H unset_setkey ("@\emy", "^@^U"); % Alt-Y #endif } enable_menu_keys (); private variable Active_Mode = NULL; private define init_mode_callback (menu) { variable fun; variable mode; mode = get_mode_name (); if (mode == Active_Mode) return; Active_Mode = mode; menu += ".M&ode"; menu_delete_items (menu); fun = mode_get_mode_info ("init_mode_menu"); if (fun == NULL) { menu_set_object_available (menu, 0); return; } menu_set_object_available (menu, 1); @fun (menu); } autoload ("menu_load_popups", "popups"); menu_set_init_menubar_callback ("Global", &init_mode_callback); menu_set_select_menubar_callback ("Global", &menu_load_popups); jed-0.99-19/lib/sccs.sl0000644002657400265740000001054011311317447013533 0ustar davisdavis% sccs.sl -*- slang -*- % [stolen from rcs.sl] % [sccs.sl rev 0.6, by Phil Brown] % % This file provides an interface to SCCS % Unfortunately, not as complete as the emacs version, but % its a start % I would really like to know how to show the in/out status of the % file on the status line, and also show it is controlled by SCCS, % like emacs does % % RCS version Written by Guido Gonzato % Modified by JED on 20 Nov 1999. % Modified by Phil Brown, phil@bolthole.com on Jun 1 2001. % % The interface provides two functions that you care about: % sccs_open_file: -- open an SCCS file % sccs_check_in_and_out: -- check in or out an SCCS file % % To use this facility, put this in your .jedrc: % require ("sccs.sl"); % % You may bind these functions in your .jedrc file similar to the following: % % setkey ("sccs_check_in_and_out", "^S^C"); % setkey ("sccs_open_file", "^S^F"); % private variable Last_Comment = ""; % Build a file name like "/home/guido/SCCS/s.file" private define build_sccs_filename (file) { variable dir; (dir, file) = parse_filename (file); return dircat (dircat (dir, "SCCS"), strcat ("s.",file)); } % probably .... cause I dont understand what it is doing private define execute_sccs_cmd (cmd) { variable cbuf, buf; buf = "*SCCS Message*"; cbuf = whatbuf (); setbuf (buf); erase_buffer (); if (0 != run_shell_cmd (cmd)) { pop2buf (buf); return -1; } bury_buffer (buf); setbuf (cbuf); return 0; } private define checkout (file) { variable cmd; variable dir; variable name; flush (sprintf ("Checking out %s...", file)); (dir, name) = parse_filename (file); cmd = sprintf ("cd %s; sccs edit %s 2>&1", dir, name); if (0 != execute_sccs_cmd (cmd)) verror ("Error checking out %s!", file); flush (sprintf ("Checking out %s...done.", file)); } private define checkin (file) { variable dir, name, cmd; () = write_buffer (file); (dir, name) = parse_filename (file); Last_Comment = read_mini ("Enter a change comment:", "", Last_Comment); cmd = sprintf ("cd %s; echo \"%s\" | sccs delget %s > /dev/null 2>&1", dir, Last_Comment, name); if (0 != execute_sccs_cmd (cmd)) verror ("Error checking in %s!", file); set_readonly (1); flush ("Note: file is write protected."); } % calls "sccs create" on file. Note that this normally % leaves a dropping in the form of ",filename" private define sccs_create (file) { variable dir, name, cmd; () = write_buffer (file); flush (sprintf ("Creating %s...",file)); (dir, name) = parse_filename (file); cmd = sprintf ("cd %s; sccs create %s > /dev/null 2>&1", dir, name); if (0 != execute_sccs_cmd (cmd)) { verror ("Error doing initial sccs-create for %s!", file); return; } set_readonly (1); flush ("Note: file is write protected."); } % If it is checked out, check it it. % If it is not checked out, check it out define sccs_check_in_and_out () %^S^C { variable dir, file; % check if the current buffer is attached to an SCCS file. (file, dir,,) = getbuf_info(); file = dircat (dir, file); % If "p-file" doesn't exist, then create the SCCS file % Otherwise check in/out normally. if (0 == file_status (build_sccs_filename (file))) { sccs_create (file); return; } % the SCCS file for current buffer exists; % if the buffer is read only, then check it out if (is_readonly ()) { checkout (file); delbuf (whatbuf()); () = find_file (file); return; } % Otherwise, check it in checkin (file); } % This checks out a file that we dont have loaded, but % is under SCCS control. File must already exist, and be controlled define sccs_open_file () % ^X^F { variable sccs_file, file; file = read_file_from_mini ("SCCS open file:"); % check whether the file exists; load it if it does % if not, try the SCCS version if (1 == file_status (file)) { () = find_file (file); if(is_readonly()){ sccs_check_in_and_out (); } return; } sccs_file = build_sccs_filename (file); % now check if this file exists if (0 == file_status (sccs_file)) { verror ("SCCS file %s not found.", sccs_file); return; } checkout (file); () = find_file (file); } % This function works on a file/buffer you already have loaded. % --- End of file sccs.sl --- jed-0.99-19/lib/slmode.sl0000644002657400265740000001577411311317447014101 0ustar davisdavis% S-Lang mode is just a superset of C mode so make sure it is loaded. require ("cmode"); $1 = "SLANG"; create_syntax_table ($1); define_syntax ("%", "", '%', $1); define_syntax ("([{", ")]}", '(', $1); define_syntax ('"', '"', $1); define_syntax ('`', '"', $1); define_syntax ('\'', '\'', $1); define_syntax ('\\', '\\', $1); define_syntax ("0-9a-zA-Z_$", 'w', $1); % words define_syntax ("-+0-9a-fA-F.xX", '0', $1); % Numbers define_syntax (",;:.", ',', $1); define_syntax ('#', '#', $1); define_syntax ("%-+/&*=<>|!~^", '+', $1); #ifdef HAS_DFA_SYNTAX %%% DFA_CACHE_BEGIN %%% private define setup_dfa_callback (name) { dfa_enable_highlight_cache ("slmode.dfa", name); dfa_define_highlight_rule("^[ \t]*#", "PQpreprocess", name); dfa_define_highlight_rule("%.*$", "comment", name); dfa_define_highlight_rule("[A-Za-z_\\$][A-Za-z_0-9\\$]*", "Knormal", name); dfa_define_highlight_rule("[0-9]+(\\.[0-9]*)?([Ee][\\+\\-]?[0-9]*)?", "number", name); dfa_define_highlight_rule("0[xX][0-9A-Fa-f]*", "number", name); dfa_define_highlight_rule("\"([^\"\\\\]|\\\\.)*\"", "string", name); dfa_define_highlight_rule("\"([^\"\\\\]|\\\\.)*\\\\?$", "string", name); dfa_define_highlight_rule("'([^'\\\\]|\\\\.)*'", "string", name); dfa_define_highlight_rule("'([^'\\\\]|\\\\.)*\\\\?$", "string", name); dfa_define_highlight_rule("[ \t]+", "normal", name); dfa_define_highlight_rule("[\\(\\[{}\\]\\),;\\.\\?:]", "delimiter", name); dfa_define_highlight_rule("[%\\-\\+/&\\*=<>\\|!~\\^]", "operator", name); dfa_define_highlight_rule("!if", "keyword0", name); dfa_build_highlight_table(name); } dfa_set_init_callback (&setup_dfa_callback, "SLANG"); %%% DFA_CACHE_END %%% #endif () = define_keywords ($1, "doifor", 2); () = define_keywords ($1, "andchsformodnotpopshlshrsqrtryxor", 3); () = define_keywords ($1, "NULL_forcaseelseexchloopmul2signthen", 4); () = define_keywords ($1, "__tmpbreakcatchifnotthrowusingwhile", 5); () = define_keywords ($1, "defineorelsepublicreturnstaticstructswitch", 6); () = define_keywords ($1, "andelsefinallyforeachforeverprivatetypedef", 7); () = define_keywords ($1, "continuevariable", 8); () = define_keywords ($1, "EXIT_BLOCK", 10); () = define_keywords ($1, "ERROR_BLOCK", 11); () = define_keywords ($1, "EXECUTE_ERROR_BLOCK", 19); % Exceptions -- keyword1 () = define_keywords_n ($1, "IOErrorOSError", 7, 1); () = define_keywords_n ($1, "AnyError", 8, 1); () = define_keywords_n ($1, "DataErrorMathErrorOpenErrorReadErrorUTF8Error", 9, 1); () = define_keywords_n ($1, "IndexErrorParseErrorStackErrorUsageErrorWriteError", 10, 1); () = define_keywords_n ($1, "DomainErrorImportErrorMallocErrorSyntaxError", 11, 1); () = define_keywords_n ($1, "NumArgsErrorRunTimeErrorUnicodeErrorUnknownError", 12, 1); () = define_keywords_n ($1, "InternalErrorReadOnlyError", 13, 1); () = define_keywords_n ($1, "NamespaceErrorUserBreakError", 14, 1); () = define_keywords_n ($1, "ApplicationErrorInvalidParmError", 16, 1); () = define_keywords_n ($1, "DivideByZeroErrorTypeMismatchError", 17, 1); () = define_keywords_n ($1, "ArithOverflowErrorLimitExceededErrorStackOverflowErrorUndefinedNameError", 18, 1); () = define_keywords_n ($1, "ArithUnderflowErrorNotImplementedErrorStackUnderflowError", 19, 1); () = define_keywords_n ($1, "DuplicateDefinitionError", 24, 1); () = define_keywords_n ($1, "VariableUninitializedError", 26, 1); % Format paragraph hook private define skip_comment_whitespace () { skip_white (); skip_chars ("%"); skip_white (); } private define is_empty_comment_line () { bol (); skip_comment_whitespace (); return eolp (); } private define mark_comment_whitespace () { bol (); push_mark (); skip_comment_whitespace (); } private define is_para_sep () { bol_skip_white (); !if (looking_at ("%")) return 1; if (is_empty_comment_line ()) return 1; % Now look for special documentation marks. The embedded tm docs begin % with %!%+ and end with %!%- bol (); if (looking_at ("%!%")) return 1; % Something like %\function{foo} if (looking_at ("%\\")) return 1; return 0; } private define wrapok_hook () { push_spot (); EXIT_BLOCK { pop_spot (); } bol_skip_white (); return (what_char () == '%'); } private define wrap_hook () { push_spot (); go_up_1 (); mark_comment_whitespace (); variable prefix = bufsubstr (); go_down_1 (); insert (prefix); pop_spot (); } private define format_paragraph_hook (); private define format_paragraph_hook () { push_spot (); EXIT_BLOCK { pop_spot (); } eol (); if (parse_to_point () != -2) return; bol_skip_white (); !if (looking_at ("%")) return; bol(); push_mark (); skip_white (); skip_chars ("%"); variable prefix = bufsubstr (); skip_white (); if (eolp ()) return; variable indent_column = what_column (); % Find start while (up_1 ()) { if (is_para_sep ()) { go_down_1 (); break; } } bol (); push_mark (); % Find comment end while (down_1 ()) { if (is_para_sep ()) { up_1 (); break; } } narrow (); bob (); do { mark_comment_whitespace (); del_region (); whitespace (indent_column-1); } while (down_1 ()); bob (); unset_buffer_hook ("format_paragraph_hook"); call ("format_paragraph"); set_buffer_hook ("format_paragraph_hook", &format_paragraph_hook); bob (); variable prefix_len = strlen (prefix); do { insert (prefix); deln (prefix_len); } while (down_1 ()); widen (); return; } % This function attempts to implement some form of wrapping mode in the % presence of comments. However, the embedded documentation comment style % (using text-macro) means that this will need to be modified to be more % sophisticated. Basically the modifications would require analysing the % text-macro context. For example, wrapping is not appropriate in verbatim % sections. #ifntrue define slmode_insert_space () { variable cstr; if (is_overwrite_mode ()) { call ("self_insert_cmd"); return; } EXIT_BLOCK { insert_single_space (); } % The following code attempts a wrapping mode in the presence of comments !if (cmode_is_slang_mode ()) return; if (not (eolp ()) or (what_column () <= WRAP)) return; % we are at the end of line. cstr = "%!% "; bol (); !if (looking_at (cstr), eol ()) return; !if (bfind_char (' ')) return; trim (); newline (); insert (cstr); eol (); } #endif define slang_mode () { set_mode("SLang", 2 | 8); c_mode_common (); use_syntax_table ("SLANG"); %local_setkey ("slmode_insert_space", " "); mode_set_mode_info ("SLang", "fold_info", "%{{{\r%}}}\r\r"); mode_set_mode_info ("SLang", "dabbrev_case_search", 1); set_buffer_hook ("format_paragraph_hook", &format_paragraph_hook); set_buffer_hook ("wrap_hook", &wrap_hook); set_buffer_hook ("wrapok_hook", &wrapok_hook); unset_buffer_hook ("par_sep"); run_mode_hooks("slang_mode_hook"); } jed-0.99-19/lib/mutekeys.sl0000644002657400265740000000631411311317447014452 0ustar davisdavis% Mute (Dead or accent) keys for JED. % % To use this package, put a line like the following in your jed.rc % % mute_set_mute_keys ("`'^"); % % Here, the keys `, ', and ^ will be mute keys. That is, pressing one of % these followed by the character to accent will insert an accented % character in the buffer. This affects only the local keymap. % % Valid Mute keys are: % ^, ~, ', `, \d168 (ISO Diaeresis), \d180 (ISO Acute), and ". % % To permit unicode characters > 255, it may be necessary to use an integer % array of the character values instead of a string array. define mute_insert_accent (ok_chars, maps_to) { variable pos, ch; ch = maps_to[0]; !if (input_pending (10)) { vmessage ("%c-", ch); update_sans_update_hook (0); } ch = getkey (); pos = is_substr (ok_chars, char (ch)); if (pos) { insert_char (maps_to[pos-1]); } else { insert_char (maps_to[0]); ungetkey (ch); } } define mute_set_mute_keys (str) { variable i; _for (0, strlen(str) - 1, 1) { i = (); switch (str[i]) { case '"': local_setkey ("mute_keymap_34", "\""); } { case '\'': local_setkey ("mute_keymap_39", "'"); } { case '^': local_setkey ("mute_keymap_94", "^"); } { case '`': local_setkey ("mute_keymap_96", "`"); } { case '~': local_setkey ("mute_keymap_126", "~"); } %% ISOLatin 1 diaeresis would be better, if included in keyboard { case '\d168': local_setkey ("mute_keymap_168", "\d168"); } %% Asciitilde would be better to acute accent, if included in keyboard { case '\d180': local_setkey ("mute_keymap_180", "\d180"); } } } define mute_keymap_39 () % ' map { #ifdef IBMPC_SYSTEM "'Eeaiou"; "'\d144\d130\d160\d161\d162\d163"; #else "'AEIOUYaeiouy?!/1Cc"; "'\d193\d201\d205\d211\d218\d221\d225\d233\d237\d243\d250\d253\d191\d161\d191\d161\d199\d231"; #endif mute_insert_accent (); } define mute_keymap_180 () % \d180 map { #ifdef IBMPC_SYSTEM "'Eeaiou"; "'\d144\d130\d160\d161\d162\d163"; #else "\d180AEIOUYaeiouy"; "\d180\d193\d201\d205\d211\d218\d221\d225\d233\d237\d243\d250\d253"; #endif mute_insert_accent (); } define mute_keymap_94 () % ^ map { #ifdef IBMPC_SYSTEM "^aeiou"; "^\d131\d136\d140\d147\d150"; #else "^aeiou"; "^\d226\d234\d238\d244\d251"; #endif mute_insert_accent (); } define mute_keymap_96 () % ` map { #ifdef IBMPC_SYSTEM "`aeiou"; "`\d133\d138\d141\d149\d151"; #else "`AEIOUaeiou"; "`\d192\d200\d204\d210\d217\d224\d232\d236\d242\d249"; #endif mute_insert_accent (); } define mute_keymap_126 () % ~ map { #ifdef IBMPC_SYSTEM "~Nn"; "~\d165\d164"; #else "~NnAOao"; "~\d209\d241\d195\d213\d227\d245"; #endif mute_insert_accent (); } define mute_keymap_34 () % \" map { #ifdef IBMPC_SYSTEM "\"uaAeioyOU"; "\"\d129\d132\d142\d137\d139\d148\d152\d153\d154"; #else "\"AEIOUaeiouys"; "\"\d196\d203\d207\d214\d220\d228\d235\d239\d246\d252\d255\d223"; #endif mute_insert_accent (); } define mute_keymap_168 () % \d168 map { #ifdef IBMPC_SYSTEM "\"uaAeioyOU"; "\"\d129\d132\d142\d137\d139\d148\d152\d153\d154"; #else "\d168AEIOUaeiouy"; "\d168\d196\d203\d207\d214\d220\d228\d235\d239\d246\d252\d255"; #endif mute_insert_accent (); } jed-0.99-19/lib/dos852.sl0000644002657400265740000000222111311317447013621 0ustar davisdavis% Initializes upper/lowercase lookup tables for DOS code page 852. % 852 is the default code page for Czech, ... % not complete! - Czech only (Petr Peringer ) % . 0 64 1 { dup define_case } _for . 65 90 1 { dup 32 + define_case } _for . 91 96 1 { dup define_case } _for . 123 255 1 { dup define_case } _for %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% . 0xB5 0xA0 define_case % \'A --> \'a . 0xAC 0x9F define_case % \v{C} --> etc. in TeX sequences . 0xD2 0xD4 define_case % \v{D} . 0xB7 0xD8 define_case % \v{E} . 0x90 0x82 define_case % \'E . 0xD6 0xA1 define_case % \'I . 0xD5 0xE5 define_case % \v{N} . 0xE0 0xA2 define_case % \'O . 0xFC 0xFD define_case % \v{R} . 0xE6 0xE7 define_case % \v{S} . 0x9B 0x9C define_case % \v{T} . 0xDE 0x85 define_case % \r{U} . 0xE9 0xA3 define_case % \'U . 0xED 0xEC define_case % \'Y . 0xA6 0xA7 define_case % \v{Z} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% . "0-9a-zA-Z_\xB5\xA0\xAC\x9F\xD2\xD4\xB7\xD8\x90\x82\xD6\xA1\xD5\xE5\xE0\xA2\xFC\xFD\xE6\xE7\x9B\x9C\xDE\x85\xE9\xA3\xED\xEC\xA6\xA7" . define_word jed-0.99-19/lib/yankpop.sl0000644002657400265740000000435711311317447014272 0ustar davisdavis% Note the functions used here are not available on 16 bit systems. private variable Kill_Buffer_Number = -1; private variable Kill_Buffer_Yank_Number = -1; private variable Kill_Buffer_Max_Number = -1; % Instead of using a new user mark, I should probably set aside a bookmark % to allow the user to goto it. private variable Kill_Buffer_User_Mark; private define append_or_prepend_copy_as_kill (fun) { variable kill_fun = "%kill%"; if (strcmp (LAST_KBD_COMMAND, kill_fun)) { Kill_Buffer_Number++; if (Kill_Buffer_Number == KILL_ARRAY_SIZE) { Kill_Buffer_Number = 0; } if (Kill_Buffer_Number > Kill_Buffer_Max_Number) Kill_Buffer_Max_Number = Kill_Buffer_Number; copy_region_to_kill_array (Kill_Buffer_Number); Kill_Buffer_Yank_Number = Kill_Buffer_Number; } else { @fun (Kill_Buffer_Number); } set_current_kbd_command (kill_fun); } define yp_copy_region_as_kill () { append_or_prepend_copy_as_kill (&append_region_to_kill_array); } define yp_kill_region () { () = dupmark (); yp_copy_region_as_kill (); del_region (); } define yp_prepend_copy_region_as_kill () { append_or_prepend_copy_as_kill (&prepend_region_to_kill_array); } define yp_prepend_kill_region () { () = dupmark (); yp_prepend_copy_region_as_kill (); del_region (); } define yp_kill_line () { variable one; variable kill_fun = "%kill%"; one = eolp () or (KILL_LINE_FEATURE and bolp ()); mark_to_visible_eol (); go_right (one); yp_kill_region (); } define yp_yank () { Kill_Buffer_User_Mark = create_user_mark (); insert_from_kill_array (Kill_Buffer_Yank_Number); set_current_kbd_command ("%yank%"); } define yp_yank_pop () { if (strcmp (LAST_KBD_COMMAND, "%yank%")) { error ("The last command must be a yank one."); } Kill_Buffer_Yank_Number--; if (Kill_Buffer_Yank_Number < 0) { Kill_Buffer_Yank_Number = Kill_Buffer_Max_Number; } % Delete the previous yank push_mark (); goto_user_mark (Kill_Buffer_User_Mark); del_region (); yp_yank (); } define yp_kill_word () { push_mark(); skip_word(); yp_kill_region (); } define yp_bkill_word () { push_mark(); bskip_word(); yp_prepend_kill_region (); } provide ("yankpop"); jed-0.99-19/lib/ff90.sl0000644002657400265740000000007011311317447013341 0ustar davisdavisvariable F90_Default_Format = "fixed"; require ("f90"); jed-0.99-19/lib/syncproc.sl0000644002657400265740000000720211311317447014441 0ustar davisdavis% synchronous process support %_debug_info = 1; private variable Filter_Processes = NULL; private define find_filter_process (pid) { variable s = Filter_Processes; while (s != NULL) { if (s.pid == pid) break; s = s.next; } return s; } private define delete_filter_process (s) { if (Filter_Processes == NULL) return; if (Filter_Processes == s) { Filter_Processes = s.next; s.next = NULL; return; } variable prev = Filter_Processes; variable next = prev.next; while (next != s) { if (next == NULL) return; prev = next; next = next.next; } prev.next = next.next; s.next = NULL; } private define process_signal_handler (pid, flags, status) { if (flags == 1) return; variable s = find_filter_process (pid); if (s == NULL) return; if (flags == 4) s.exit_status = status; else s.exit_status = -1; } private define allocate_filter_process (pid) { variable s = struct { pid, exit_status, next }; s.pid = pid; s.next = Filter_Processes; Filter_Processes = s; return s; } %!%+ %\function{open_filter_process} %\synopsis{Open a subprocess as a filter} %\usage{Int_Type pid = open_filter_process (String_Type argv[], String_Type output)} %\description % The \var{open_filter_process} function may be used to open an interactive % synchronous process. The first argument should be an array of strings % representing the program to be run in the subprocess, and the command line % parameters passed to it. The second argument specifies what to do with the % output generated by the process. It can be any value supported by the % "output" option of the \var{set_process} function. The process should be % closed using the \var{close_filter_process} function. %\seealso{close_filter_process, send_process, call_process_region} %!%- public define open_filter_process (argv, output) { if (typeof (argv) != Array_Type) argv = [argv]; variable nargs = length (argv); foreach (argv) ; variable args = __pop_args (nargs); variable pgm = argv[0]; variable pid = open_process_pipe (__push_args (args), nargs-1); if (-1 == pid) verror ("failed to execute %s", pgm); variable s = allocate_filter_process (pid); set_process (pid, "signal", &process_signal_handler); set_process (pid, "output", output); return pid; } %!%+ %\function{close_filter_process} %\synopsis{Close a filter process and return its status} %\usage{Int_Type close_filter_process (Int_Type pid)} %\description % The \var{close_filter_process} function waits for the specified process % to terminate and returns the exit status of the process. The process must % have been previously opened via the \var{open_filter_process} function. %\seealso{open_filter_process, send_process, get_process_input} %!%- public define close_filter_process (pid) { variable s = find_filter_process (pid); if (s == NULL) return -1; %send_process_eof (pid); get_process_input (0); variable next_signal = 2; while (s.exit_status == NULL) { update (0); ERROR_BLOCK { signal_process (pid, next_signal); if (next_signal != 9) _clear_error (); next_signal = 9; } get_process_input (5); } variable status = s.exit_status; delete_filter_process (s); return status; } public define call_process_region (cmd, output) { variable str = bufsubstr (); variable pid = open_filter_process (cmd, output); if (pid == -1) return; send_process (pid, str); send_process_eof (pid); vmessage ("Process returned %d", close_filter_process (pid)); } jed-0.99-19/lib/bytecomp.sl0000644002657400265740000000653711311317447014435 0ustar davisdavis% bytecomp.sl -*- SLang -*- % % !! WARNING: It is not a good idea to invoke this file directly. % Instead load it via preparse.sl. This may be performed % in batch mode as: % % jed -batch -n -l preparse % % !if (is_defined ("Preprocess_Only")) { variable Preprocess_Only = 0; } define jed_byte_compile_file (f) { variable file; file = expand_jedlib_file(f); if (strlen (file)) { % flush (strcat ("Processing ", file)); byte_compile_file (file, Preprocess_Only); } else flush (strcat (f, " not found")); } #ifnexists __load__bytecomp__only__ $0 = _stkdepth (); % list of file to byte compile: # ifdef UNIX VMS "mail.sl"; "iso-latin.sl"; % "dispesc.sl"; # endif # ifdef UNIX "rmail.sl"; "sendmail.sl"; "mailalias.sl"; "mime.sl"; "perl.sl"; "perlxtra.sl"; "compress.sl"; # endif # ifdef IBMPC_SYSTEM "dos437.sl"; "dos850.sl"; "dos852.sl"; "brief.sl"; "win1250.sl"; # endif # ifdef XWINDOWS MOUSE "mouse.sl"; # endif # ifdef HAS_LINE_ATTR "folding.sl"; # endif #ifdef VMS "vmshelp.sl"; #endif if (is_defined ("KILL_ARRAY_SIZE")) { "yankpop.sl"; "register.sl"; } "sccs.sl"; "rcs.sl"; "minued.sl"; "history.sl"; "chglog.sl"; "wmark.sl"; "occur.sl"; "javamode.sl"; "modehook.sl"; "hooks.sl"; "nroff.sl"; "html.sl"; "docbook.sl"; "idl.sl"; "shmode.sl"; "mousex.sl"; "abbrev.sl"; "abbrmisc.sl"; "dabbrev.sl"; "mutekeys.sl"; "bookmark.sl"; "replace.sl"; "srchmisc.sl"; "texcom.sl"; "tex.sl"; "bibtex.sl"; "latex.sl"; "latex209.sl"; "ltx-math.sl"; "binary.sl"; "isearch.sl"; "rot13.sl"; "tabs.sl"; "untab.sl"; "jedhelp.sl"; "ctags.sl"; "compile.sl"; "menu.sl"; "dired.sl"; "util.sl"; "syntax.sl"; "tmisc.sl"; "cmisc.sl"; "misc.sl"; "help.sl"; "cal.sl"; "man.sl"; "fortran.sl"; "dcl.sl"; "shell.sl"; "most.sl"; "info.sl"; "ispell.sl"; "sort.sl"; "regexp.sl"; "wordstar.sl"; "buf.sl"; "emacsmsc.sl"; "ide.sl"; "cmode.sl"; "php.sl"; "slmode.sl"; "search.sl"; %"linux.sl"; "textmode.sl"; "modeinfo.sl"; "comments.sl"; "keydefs.sl"; "jed.sl"; "jedusage.sl"; if (is_defined ("menu_create_menu_bar") == 1) % intrinsic fun { "menus.sl"; "popups.sl"; } "mini.sl"; "edt.sl"; "emacs.sl"; "site.sl"; $0 = _stkdepth () - $0; loop ($0) { jed_byte_compile_file (()); } $0 = _stkdepth (); "tclmode.sl"; "ashell.sl"; "bufed.sl"; "macro.sl"; "filter.sl"; %"keycode.sl"; "wmenu.sl"; "lisp.sl"; "pscript.sl"; "acompile.sl"; "digraph.sl"; "cua.sl"; "cuamisc.sl"; "f90.sl"; "ff90.sl"; "iso-lat2.sl"; "iso-lat3.sl"; "iso2xxx.sl"; "krconv.sl"; "maple.sl"; "pipe.sl"; "pushmode.sl"; "pymode.sl"; "seldisp.sl"; "sortmisc.sl"; "verilog.sl"; "spicemod.sl"; "vhdlmode.sl"; "tiasm.sl"; "backups.sl"; "matlab.sl"; "recent.sl"; "tpascal.sl"; "aprocess.sl"; "tmmode.sl"; "xformreg.sl"; "gpg.sl"; "paste.sl"; "syncproc.sl"; "tmpfile.sl"; $0 = _stkdepth () - $0; loop ($0) { jed_byte_compile_file (()); } % Now do color schemes # ifndef VMS _debug_info = 1; private define do_color_schemes () { foreach (strtok (Color_Scheme_Path, ",")) { variable dir = (); variable files = listdir (dir); variable file; variable i; if (files == NULL) continue; i = where (array_map (Int_Type, &string_match, files, "\\.sl$", 1)); !if (length (i)) continue; foreach (files[i]) { file = (); byte_compile_file (dircat (dir, file), Preprocess_Only); } } } do_color_schemes (); # endif #endif % __load__bytecomp__only__ jed-0.99-19/lib/cpright.hlp0000644002657400265740000000107411311317447014407 0ustar davisdavis This is a scratch buffer. It is NOT saved when you exit. To access the menus, press F10 or ESC-m and the use the arrow keys to navigate. Latest version information is available on the web from . Other sources of JED information include the usenet newsgroups comp.editors and alt.lang.s-lang. To subscribe to the jed-users mailing list, see . Copyright (C) 1994, 2000-2009 John E. Davis Email comments or suggestions to . jed-0.99-19/lib/generic.hlp0000644002657400265740000000020711311317447014360 0ustar davisdavisNo help file available for this mode. Press 'ESC-X describe_bindings' for a list of keybindings. Also press Ctrl-H ? for simple menus. jed-0.99-19/lib/wordstar.hlp0000644002657400265740000000161511311317447014615 0ustar davisdavisJED Wordstar keybindings: `^' means to use Ctrl key (e.g., ^X = Ctrl-X). Press ^KI to close this window. Use ^6 to quit the command line. CURSOR GO TO BLOCK DELETE MISC EXIT ^S left ^D right ^R prev.screen ^KB begin ^G char ^B reformat ^KX save ^E up ^X down ^C next screen ^KK end ^Y line ^K0..9 set ^KZ shell ^A word ^QS beg.of line ^KV move ^T >word bookmark FILE SEARCH ^QD end of line ^KC copy ^[o line window ^KR insert ^QF find text ^QC end of file ^KY del ^U undo ALT-X cmd ^KQ kill ^QA replace ^Q0..9 bookmark ^KT word line ^KD save ^L find next ^QI to line No. ^K/ filter ^KS s.new ^QP previous ^KU upcase ^KP switch jed-0.99-19/lib/ide.hlp0000644002657400265740000000240511311317447013507 0ustar davisdavisJED IDE mode 1.3.4. ^ = Ctrl (e.g., ^X = Ctrl-X); M = Alt (M-X = Alt-X) Press `q' to quit this help screen; F6 or ^KP to switch to the next buffer CURSOR GO TO BLOCK DELETE EXIT ^S left ^D right ^R prev. screen ^KB begin M-G char ^KX save ^E up ^X down ^C next screen ^KY cut ^Y line ^KZ shell ^A word ^QS beg. of line ^KH copy ^T >word ^QD end of line ^KC paste M-BS line ^KE new ^QF find text ^QX screen end ^KT word ^U undo ^KR insert ^QA replace ^QR top of file ^K/ filter ^KQ kill ^L find next ^QC end of file ^KG to reg. MACRO ^KD save ^QT toggle case ^Q0-9 bookmark ^KJ from reg. ESC-( beg. ^KS save as ^QI line No. ^KU up. case ESC-) end ^KN next MISC ^QP prev.position ^KL lo. case M-R run ^KP prev. ^B reformat ^K0-9 set bookmark ^KI one window ^V completion ^P compose char Press M-X or ESC-X to issue commands; press ^G to quit the command line Press F10 to activate the menus. Please read the documentation! jed-0.99-19/lib/runpgm.sl0000644002657400265740000000126311311317447014112 0ustar davisdavis#ifdef XWINDOWS custom_variable ("XTerm_Pgm", "xterm"); define _jed_run_program_hook (s) { s = strtrim_end (s, " \t&"); return system (sprintf ("%s -e %s &", XTerm_Pgm, s)); } #endif #ifdef WIN32 custom_variable("W32shell_Perform_Globbing", 0); define _win32_get_helper_app_name () { variable s, h; s = getenv ("COMSPEC"); if (s == NULL) s = "cmd.exe"; if (W32shell_Perform_Globbing) h = dircat (Jed_Bin_Dir, "w32/g32shell.exe"); else h = dircat (Jed_Bin_Dir, "w32/w32shell.exe"); sprintf ("%s %s /c", h, s); } #endif public define vrun_program () { variable args = __pop_args (_NARGS); return run_program (sprintf (__push_args (args))); } jed-0.99-19/lib/mswmouse.sl0000644002657400265740000001573411311317447014471 0ustar davisdavis% % JED mouse interface % % These routines assume a 2 button mouse % % left : set point to mouse point % right : paste from cut buffer moving point to mouse point % drag left : mark a region and copy it to cut buffer % shift left : split window mouse is in % control left : delete window mouse is in % % Other buttons are undefined. % setkey ("mouse_set_point_open", "\e^@Dl"); % left button down setkey ("mouse_set_point_close", "\e^@Ul"); % left button up setkey ("mouse_yank_cutbuffer", "\e^@Dm"); % middle down setkey ("mouse_yank_cutbuffer", "\e^@Dr"); % right down setkey ("mouse_null", "\e^@Um"); % middle up setkey ("mouse_null", "\e^@Ur"); % right up % dragging setkey ("mouse_drag", "\e^@^@l"); % left dragging setkey ("mouse_drag", "\e^@^@r"); % right dragging setkey ("mouse_null", "\e^@^@^L"); % C-left dragging setkey ("mouse_drag", "\e^@^@^R"); % C-right dragging setkey ("mouse_null", "\e^@^@L"); % S-left dragging setkey ("mouse_null", "\e^@^@R"); % S-right dragging % shifted setkey ("mouse_split_window", "\e^@DL"); % Shift-left button down setkey ("mouse_null", "\e^@UL"); % left button up setkey ("mouse_yank_from_jed", "\e^@DM"); % middle down setkey ("mouse_yank_from_jed", "\e^@DR"); % right down setkey ("mouse_null", "\e^@UR"); % right up setkey ("mouse_null", "\e^@UM"); % middle up % ctrl setkey ("mouse_delete_window", "\e^@D^L"); % left button down setkey ("mouse_null", "\e^@U^L"); % left button up setkey ("mouse_null", "\e^@D^M"); % middle down setkey ("mouse_null", "\e^@D^R"); % middle down setkey ("mouse_null", "\e^@U^M"); % middle up setkey ("mouse_null", "\e^@U^R"); % middle up define mouse_null (); % loop through windows moving the point to the mouse point % if same_window is false, and mouse is on status line, call status_fun % It returns zero if the status function was used, otherwise, it returns 1 define mouse_point_mouse (force, same_window, push, status_fun) { variable n = nwindows (); variable top, bot, dy, col, want_col; while (n) { top = window_info('t'); bot = window_info('r') + top; if ((MOUSE_Y >= top) and (MOUSE_Y < bot)) { if (push) push_visible_mark (); dy = MOUSE_Y - (top - 1 + window_line()); if (dy > 0) { dy -= down(dy); eol(); if (force) loop (dy) newline(); } else go_up(- dy); eol(); col = what_column (); want_col = window_info('c') + MOUSE_X - 1; !if (force or (want_col <= col)) want_col = col; () = goto_column_best_try(want_col); return 1; } if (same_window) { if (push) push_visible_mark (); if (MOUSE_Y >= bot) { go_down(MOUSE_Y - bot + 1); } else { go_up(top - MOUSE_Y); } x_warp_pointer (); return 1; } if ((bot == MOUSE_Y) and (use_status_fun != NULL)) { @status_fun (); return 0; } otherwindow(); n--; } error ("Mouse not in a window."); } variable Mouse_Drag_Mode = 0; variable Mouse_Buffer = " *Mouse buffer*"; variable Mouse_Delete_Region = 0; define copy_kill_to_mouse_buffer () { variable cbuf = whatbuf (); variable pnt, n; % % We are not going to copy to the pastebuffer if the region is nil % n = what_line(); pnt = _get_point (); push_spot(); pop_mark_1 (); if ((what_line() == n) and (_get_point () == pnt)) { pop_spot(); return; } push_mark(); pop_spot(); setbuf(Mouse_Buffer); erase_buffer (); setbuf (cbuf); if (Mouse_Delete_Region) () = dupmark(); () = dupmark(); %/* for cut buffer */ x_copy_region_to_cutbuffer (); copy_region(Mouse_Buffer); if (Mouse_Delete_Region) { Mouse_Delete_Region = 0; del_region(); } message ("region copied."); } define mouse_next_buffer () { variable n, buf, cbuf = whatbuf (); n = buffer_list (); %/* buffers on stack */ loop (n) { =buf; n--; if (buf[0] == ' ') continue; if (buffer_visible (buf)) continue; sw2buf (buf); loop (n) pop (); return; } error ("All buffers are visible."); } custom_variable ("Mouse_Save_Point_Mode", 1); %!%+ %\variable{Mouse_Save_Point_Mode} %\synopsis{Mouse_Save_Point_Mode} %\usage{Integer Mouse_Save_Point_Mode = 1;} %\description % If this variable is non-zero, the editing point will be restored to its % original position when the left button is used to copy a region to the % cutbuffer. If the variable is zero, the current point is left at the % end of the copied region. %!%- private variable Mouse_Save_Point_Window; private variable Mouse_Save_Point_Mark; define mouse_set_point_open () { Mouse_Drag_Mode = 0; Mouse_Save_Point_Window = window_info ('t'); Mouse_Save_Point_Mark = create_user_mark (); if (Mouse_Save_Point_Mode) Mouse_Save_Point_Mode = -1; if (mouse_point_mouse (0, 0, 0, &mouse_next_buffer) and Mouse_Save_Point_Mode) { Mouse_Save_Point_Mode = 1; } } define mouse_set_point_close () { if (Mouse_Drag_Mode) { copy_kill_to_mouse_buffer (); Mouse_Drag_Mode = 0; if ((MOUSE_BUTTON == 1) and (Mouse_Save_Point_Mode > 0)) { loop (nwindows ()) { if (window_info ('t') == Mouse_Save_Point_Window) { if (whatbuf () == Mouse_Save_Point_Mark.buffer_name) goto_user_mark (Mouse_Save_Point_Mark); break; } otherwindow (); } Mouse_Save_Point_Mode = -1; } } else if (MOUSE_BUTTON == 3) { dupmark(); pop(); copy_kill_to_mouse_buffer (); pop_mark_1 (); } } define mouse_yank_from_jed () { () = mouse_point_mouse (0, 0, 0, NULL); if (bufferp(Mouse_Buffer)) insbuf(Mouse_Buffer); } define mouse_yank_cutbuffer () { variable w = window_info ('t'); variable max_loops = nwindows (); variable m = create_user_mark (); if (mouse_point_mouse (0, 0, 1, &splitwindow)) { pop_mark_1 (); % since we set it in the function call while (max_loops and (w != window_info ('t'))) { otherwindow (); max_loops--; } if (max_loops) { goto_user_mark (m); () = x_insert_cutbuffer (); } } } define delete_window () { call("delete_window"); } define mouse_mark_and_copy () { Mouse_Drag_Mode = 0; () = mouse_point_mouse (0, 0, 1, &delete_window); } define mouse_drag () { !if (Mouse_Drag_Mode) { push_visible_mark (); Mouse_Drag_Mode = 1; } () = mouse_point_mouse (0, 1, 0, NULL); update_sans_update_hook (not(input_pending(0))); } define mouse_kill_region () { Mouse_Delete_Region = 1; mouse_mark_and_copy (0, 0, 1); } define mouse_split_window () { () = mouse_point_mouse (0, 0, 0, NULL); splitwindow(); } define mouse_delete_window () { () = mouse_point_mouse (0, 0, 0, NULL); delete_window (); } jed-0.99-19/lib/man.sl0000644002657400265740000000346111311317447013357 0ustar davisdavis%% %% execute man then remove backspaces %% %!%+ %\function{man_clean_manpage} %\synopsis{man_clean_manpage} %\description % remove _^H and ^H combinations and multiple blank lines (man page) %!%- define man_clean_manpage () { variable clean = "Cleaning man page..."; push_spot_bob (); flush (clean); % I do not know what man on debian etch or lenny is doing, but it % is producing this combination: \xE2\x88\x{2212} for a -. Note that % \xE2\x88 are the leading bytes of \u{2212}. For some reason, % these are getting doubled. So replace the entire combination replace ("\xE2\x88\x{2212}", "-"); replace ("\xE2\x80\x{2010}", "-"); % Convert other unicode versions of - to ascii -. replace ("\x{2212}", "-"); replace ("\x{2010}", "-"); replace ("\x{00AD}", "-"); replace ("_\010", ""); % remove _^H underscores while ( fsearch ("\010") ) { del (); del (); } % remove overstrike % Now removed SGR sequences such as ESC[1m, ESC[m, etc.... bob (); while (re_fsearch ("\e\\[\\d*m")) () = replace_match ("", 0); trim_buffer (); % remove multiple blank lines pop_spot (); flush (strcat (clean, "done")); } %!%+ %\function{unix_man} %\synopsis{unix_man} %\description % retrieve a man page entry and use clean_manpage to clean it up %!%- define unix_man () { variable subj, buf = "*manual-entry*", msg = "Getting man page..."; subj = read_mini ("man", Null_String, Null_String); !if ( strlen (subj) ) return; pop2buf (buf); set_readonly (0); erase_buffer (); flush (msg); #ifdef OS2 () = run_shell_cmd (sprintf ("man %s 2> nul", subj)); #else () = run_shell_cmd (sprintf ("man %s 2> /dev/null", subj)); #endif man_clean_manpage (); bob (); set_buffer_modified_flag (0); most_mode (); set_readonly (1); } jed-0.99-19/lib/util.sl0000644002657400265740000000104211311317447013552 0ustar davisdavis%% %% utility functions which Must be available (e.g., autoload) %% %% %% A routine that trims the buffer by: removing excess whitespace at the %% end of lines and removing excess newlines %% define trim_buffer() { push_spot(); bob(); do { eol_trim(); bol(); if (eolp()) { go_down_1 (); while (eol_trim(), bol(), eolp() and not(eobp())) del(); } } while (down_1 ()); bob(); eol_trim(); bol(); if (eolp() and not(eobp ())) del(); pop_spot(); !if (BATCH) message ("done."); } jed-0.99-19/lib/edt.hlp0000644002657400265740000000314711311317447013526 0ustar davisdavis+-----------------------------------+ +--------+--------+--------+-------+ | ^ | DOWN | | | | | | FNDNXT | DEL L | | | | | | <---- | ----> | | *GOLD | HELP | | | | | | | | LEFT | RIGHT | | | | *FIND | *UND L| | UP | v | | | +--------+--------+--------+-------+ +-----------------------------------+ | PAGE | SECT | APPEND | DEL W | DELETE Delete character | | | | | LINEFEED Delete to beginning of word |*COMMAND| *FILL |*REPLACE|*UND W | BACKSPACE Backup to beginning of line +--------+--------+--------+-------+ CTRL/R Refresh screen | ADVANCE| BACKUP | CUT | DEL C | GOLD-Q Quit | | | | | GOLD-E Quit |*BOTTOM | *TOP |*PASTE |*UND C | +--------+--------+--------+-------+ | WORD | EOL | CHAR | | | | | | ENTER | More help follows below. |*CHGCASE|*DEL EOL|*SPECINS| | +--------+--------+--------+ | | LINE | SELECT | | | | | *SUBS | | *OPEN LINE | *RESET | | +-----------------+--------+-------+ jed-0.99-19/lib/tclmode.sl0000644002657400265740000002472111311317447014235 0ustar davisdavis% tcl mode 0.5 (derived from shmode.sl, cmode.sl and latex.sl) % by David Schweikert (dwschwei@stud.ee.ethz.ch) % % ChangeLog % --------- % 0.1 18 Aug 97 Initial version % 0.2 25 Aug 97 The indenting is much better. Small bug fixes. % Escaped braces correctly parsed. % 0.3 31 Aug 97 Syntax highlighting reworked. Now only Tcl/Tk % commands are highlighted. % Highlighting of command options added. % Syntax Check added. % 0.4 27 Sep 97 Little bugfix in indenting. % 0.5 24 Feb 98 Integrated into the JED distribution. % Added syntax highlighting for numbers. % % Description % ----------- % JED-mode for the syntax-highlighting and automatic indentation of % Tcl/Tk programs. % % Notes % ----- % - This mode only does DFA syntax-highlighting and a very % rough automatic indentation (assumes that the previous line % is correctly indented) % - How to highlight is very personal... Modify the code to match your % preference! % - I am very disponible for comments, suggestions,... (via e-mail) % % Keybindings % ----------- % ^C^Q tcl_indent_region % { tcl_insert_bra % } tcl_insert_ket % # tcl_insert_comment % % Syntax Check % ------------ % This mode does recognise evident syntax-errors which are common % to beginners (I am a beginner :-)): % % - The open brace should be opened on the same line of the command % it belongs to and not on a line by itself as many do in C: % Wrong: Right: % if {$a == 1} if {$a == 1} { % { set b 2 % set b 2 } % } % Note that the open-brace at the beginning of a line could be % correct but isn't certainly common. % % - The comment is also a sort of command in Tcl, so you can't just add % comments on the right of some statement. You have to add % a command separator if you want to: % # this is right % set a 2 # this is wrong % set b 3 ;# this is right % % If tclmode recognises such an error, it displays a "Warning: ...". % You can disable the Syntax Check by setting 'Tcl_Check_Syntax' to 0. % % Syntax-highlighting % ------------------- % The syntax-coloring-types of jed aren't very adequate for tcl, % so, I used them as follows: % % - normal: as expected % - comment: as expected % - delimiter: as expected % - string: as expected (plus "$variable") % - keyword: as expected (tcl: type 0, tk: type 1) % - number: as expected % - preprocess: proc definition (first line) % - operator: command option (for example '-font') % % ToDo % ---- % - More syntax-checks (ideas?). % - Interaction with tclsh/wish (difficult). % - Smarter indenting. % - More commands from incr Tcl, BLT, ... % - tcl_comment_region. % - syntax highlighting without DFA. variable Tcl_Check_Syntax = 1; % --- $1 = "TCL"; create_syntax_table ($1); #ifdef HAS_DFA_SYNTAX %%% DFA_CACHE_BEGIN %%% private define setup_dfa_callback (name) { dfa_enable_highlight_cache ("tclmode.dfa", name); dfa_define_highlight_rule ("^[ \\t]*#.*$", "comment", name); dfa_define_highlight_rule (";[ \\t]*#.*$", "comment", name); dfa_define_highlight_rule ("\"([^\\\\\"]|\\\\.)*\"", "string", name); dfa_define_highlight_rule ("[{}\\[\\]]", "Qdelimiter", name); dfa_define_highlight_rule("[0-9]+(\\.[0-9]*)?([Ee][\\+\\-]?[0-9]*)?","number", name); dfa_define_highlight_rule (".", "normal", name); dfa_define_highlight_rule("[A-Za-z_\\.:]+", "Knormal", name); dfa_define_highlight_rule ("\\$[a-zA-Z0-9_:]+", "string", name); dfa_define_highlight_rule ("\\${.*}", "Qstring", name); dfa_define_highlight_rule ("^[ \\t]*proc.*$", "Qpreprocess", name); dfa_define_highlight_rule (" -[a-z]+ ", "operator", name); dfa_build_highlight_table (name); } dfa_set_init_callback (&setup_dfa_callback, "TCL"); %%% DFA_CACHE_END %%% #endif % Keywords (machine generated) % Tcl commands $2 = 0; () = define_keywords_n ($1, "cdif", 2, $2); () = define_keywords_n ($1, "eofforpidpwdset", 3, $2); () = define_keywords_n ($1, "caseelseevalexecexitexprfilegetsglobincrinfojoinlistloadopenprocputsreadscanseektelltime", 4, $2); () = define_keywords_n ($1, "afterarraybreakcatchclockcloseerrorfcopyflushlsortsplitsubsttraceunsetupvarvwaitwhile", 5, $2); () = define_keywords_n ($1, "appendbinaryconcatformatglobalinterplindexlrangeregexpregsubrenamereturnsocketsourcestringswitch", 6, $2); () = define_keywords_n ($1, "consoleforeachhistorylappendlinsertllengthlsearchunknownuplevel", 7, $2); () = define_keywords_n ($1, "continuefblockedlreplace", 8, $2); () = define_keywords_n ($1, "fileevent", 9, $2); % Tk commands $2 = 1; () = define_keywords_n ($1, "tkwm", 2, $2); () = define_keywords_n ($1, "bellbindfontgrabgridmenupacksendtext", 4, $2); () = define_keywords_n ($1, "entryeventfocusframeimagelabellowerplaceraisescalewinfo", 5, $2); () = define_keywords_n ($1, "buttoncanvasoptiontkwaitupdate", 6, $2); () = define_keywords_n ($1, "destroylistboxmessagetkerror", 7, $2); () = define_keywords_n ($1, "bindtagstk_popuptoplevel", 8, $2); () = define_keywords_n ($1, "clipboardscrollbarselectiontk_bisquetk_dialog", 9, $2); () = define_keywords_n ($1, "menubutton", 10, $2); () = define_keywords_n ($1, "checkbuttonradiobutton", 11, $2); () = define_keywords_n ($1, "tk_focusNexttk_focusPrev", 12, $2); () = define_keywords_n ($1, "tk_messageBoxtk_setPalette", 13, $2); () = define_keywords_n ($1, "tk_chooseColortk_getOpenFiletk_getSaveFiletk_optionsMenu", 14, $2); define tcl_indent_line (); % forward declaration % Indentation and Syntax Check define tcl_newline_and_indent () { newline (); tcl_indent_line (); } define tcl_indent_to (n) { bol_skip_white (); if (what_column != n) { bol_trim (); n--; whitespace (n); } } % Counts unmatched braces define tcl_count_braces () { variable c, open_count = 0, close_count = 0; variable escaped = 0; push_spot(); for(bol (); not(eolp()); go_right_1()) { c = what_char (); switch(c) { case '\\': !if(escaped) escaped = 2; }{ case '{': !if(escaped) open_count++; }{ case '}': !if(escaped) { if (open_count) open_count--; else close_count++; } } if(escaped) escaped--; } pop_spot(); return(open_count, close_count); } % Search for a valid previous line and go to it. define tcl_go_up () { forever { if (up_1 ()) { bol_skip_white (); if (eolp ()) continue; if (what_char () != '#') return(1); } else return(0); } } % Is the next line the continuation of this one? define tcl_is_continued_line () { eol(); bskip_white (); if (blooking_at ("\\")) 1; else 0; return; } % How much indenting based on the previous line? define tcl_prev_line_rule () { variable indent = 0, open_count; push_spot (); if(tcl_go_up ()) { % It is assumed that this line is correctly aligned. indent = what_column (); % If we find first an unmatched '{', then the next line should be indented. (open_count, ) = tcl_count_braces (); indent += open_count * C_INDENT; % Is the next a continuation line? if (tcl_is_continued_line ()) indent += C_CONTINUED_OFFSET; if (tcl_go_up() and tcl_is_continued_line()) indent -= C_CONTINUED_OFFSET; } pop_spot (); return (indent); } % How much indenting based on the current line? define tcl_cur_line_rule () { variable indent = 0, close_count = 0; % If we find an unmatched '}', then this line should be unindented. (, close_count) = tcl_count_braces (); indent -= close_count * C_INDENT; return (indent); } % Indent the current line. define tcl_indent_line () { variable cursor, oldindent; variable indent; % ---- Could be skipped in tcl_indent_region! cursor = what_column (); bol_skip_white (); oldindent = what_column (); % ---- indent = tcl_prev_line_rule (); indent += tcl_cur_line_rule (); % message(Sprintf("%d : %d", indent_prev, indent_cur, 2)); tcl_indent_to (indent); goto_column (cursor + indent - oldindent); % Could be skipped in tcl_indent_region! } % Indent the selected region (bound to ^C^Q) define tcl_indent_region () { check_region(1); pop_mark_1 (); push_mark(); tcl_indent_line(); % set initial line indentation before narrowing pop_spot(); push_spot(); go_up_1 (); narrow(); bob(); flush("Indenting region..."); while (down_1 ()) { % indent line by line (ie slowly) tcl_indent_line(); % flush(Sprintf("Indenting line %d", what_line(), 1)); } flush("Indenting region... Done."); widen(); pop_spot(); } define tcl_syntax_warning (msg) { flush ("Warning: " + msg); } define tcl_insert_ket () { insert("}"); tcl_indent_line(); blink_match (); } define tcl_insert_bra () { if(Tcl_Check_Syntax) { push_spot(); bskip_white(); if(bolp()) { tcl_syntax_warning("'{' shouldn't be on a separate line"); } pop_spot(); } insert("{"); } define tcl_insert_comment () { if(Tcl_Check_Syntax) { push_spot(); bskip_white(); !if (bolp() or blooking_at (";")) { tcl_syntax_warning("'#' should be on a separate line or after a ';'"); } pop_spot(); } insert("#"); } $1 = "TCL"; !if (keymap_p ($1)) { make_keymap ($1); definekey("tcl_insert_bra", "{", $1); definekey("tcl_insert_ket", "}", $1); definekey("tcl_insert_comment", "#", $1); definekey_reserved("tcl_indent_region", "^Q", $1); definekey("indent_line", "\t", $1); } %!%+ %\function{tcl_mode} %\synopsis{tcl_mode} %\description % Protoytype: Void tcl_mode (); % This is a mode that is dedicated to facilitate the editing of Tcl language files. % See the source (tclmode.sl) for more info. % Functions that affect this mode include: %#v+ % function: default binding: % tcl_insert_bra { % tcl_insert_ket } % tcl_insert_comment # % newline_and_indent RETURN % indent_line TAB % tcl_indent_region Ctrl-C Ctrl-Q %#v- % Variables affecting indentation include: %#v+ % C_INDENT % C_CONTINUED_OFFSET %#v- % Hooks: \var{tcl_mode_hook} %!%- define tcl_mode () { variable mode = "TCL"; set_mode(mode, 4); use_keymap(mode); use_syntax_table (mode); set_buffer_hook ("indent_hook", "tcl_indent_line"); set_buffer_hook ("newline_indent_hook", "tcl_newline_and_indent"); run_mode_hooks("tcl_mode_hook"); } jed-0.99-19/lib/chglog.sl0000644002657400265740000000624611311317447014053 0ustar davisdavis% Maintain ChangeLog files custom_variable ("ChangeLog_Filename", #ifdef VMS "$CHANGE_LOG$.TXT" #else "ChangeLog" #endif ); custom_variable ("ChangeLog_User", sprintf ("%s <%s>", get_realname (), get_emailaddress ())); custom_variable ("ChangeLog_Indent_Amount", 8); private define get_changelog_date () { variable tm, day, month, year; tm = localtime (_time ()); sprintf ("%d-%0d-%0d", 1900 + tm.tm_year, 1+tm.tm_mon, tm.tm_mday); } private define format_changelog_heading () { variable date = get_changelog_date (); return sprintf ("%s %s", date, ChangeLog_User); } private define locate_changelog_file () { variable file, dir; (,dir,,) = getbuf_info (); forever { file = dircat (dir, ChangeLog_Filename); if (1 == file_status (file)) return file; % This may need modified for non-Unix systems... #ifdef UNIX dir = expand_filename (dircat (dir, "../")); if (dir == "/") break; #elifdef IBMPC_SYSTEM dir = expand_filename (dircat (dir, "..\\")); if ((dir == "/") or (dir == "\\")) break; if (strlen (dir) == 3) { if (dir[1] == ':') break; } #elifdef VMS % Does this work? dir = expand_filename (dircat (dir, "[-]")); #endif } verror ("Unable to find a ChangeLog file"); } private define get_changelog_file_item () { variable dir, file; (file, dir,,) = getbuf_info (); !if (strlen (file)) return ""; if (file == ChangeLog_Filename) return ""; return dircat (dir, file); } private define get_changelog_function () { variable fun = mode_get_mode_info ("chglog_get_item"); if (fun != NULL) fun = @fun (); if (fun == NULL) return ""; return fun; } private define wrap_hook () { push_spot (); bol_trim (); whitespace (ChangeLog_Indent_Amount + 2); pop_spot (); } public define changelog_add_change () { variable heading = format_changelog_heading (); variable file = get_changelog_file_item (); variable function = get_changelog_function (); variable changelog = locate_changelog_file (); if (strlen (file)) { % Make it with respect to the changelog directory variable i = 0; while (changelog[i] == file[i]) % can this fail in practice? i++; file = file [[i:]]; } () = read_file (changelog); set_buffer_no_backup (); pop2buf (whatbuf ()); text_mode (); set_buffer_hook ("wrap_hook", &wrap_hook); bob (); !if (bol_fsearch (heading)) { vinsert ("%s\n\n", heading); bob (); } eol (); variable m = create_user_mark (); skip_chars (" \t\n*"); variable create_new_entry = 1; if (looking_at (file)) { go_right (strlen (file)); _get_point (); % on stack skip_chars (" :"); create_new_entry = (() == _get_point ()); } if (create_new_entry) { goto_user_mark (m); insert ("\n\n"); whitespace (ChangeLog_Indent_Amount); vinsert ("* %s ", file); } else { !if (re_fsearch ("^[ \t]*$")) { eob (); } trim (); newline (); go_up_1 (); whitespace (8); } if (strlen (function)) vinsert ("(%s): ", function); else if (create_new_entry and strlen (file)) { trim (); insert (": "); } } jed-0.99-19/lib/nroff.sl0000644002657400265740000000213711311317447013715 0ustar davisdavis% nroff.sl -*- SLang -*- % % Primitive nroff editing mode -- just enough to define paragraphs % to prevent CMD from wrapping % define nroff_parsep () { bol (); (looking_at_char('.') or looking_at_char('\\') or (skip_white(), eolp())); } $1 = "nroff"; create_syntax_table ($1); define_syntax ("'\\\"", "", '%', $1); % Comment Syntax define_syntax ('.', '\\', $1); % Quote character define_syntax ("({[", ")]}", '(', $1); % are all these needed? define_syntax ("{}[]<>()", ',', $1); % delimiters define_syntax (".a-zA-Z", 'w', $1); % A few standard keywords -- uppercase only, nothing fancy () = define_keywords ($1, ".B.I", 2); () = define_keywords ($1, ".BR.DT.IP.PP.RB.RI.RE.RS.SB.SH.TH.TP.fi.nf", 3); %!%+ %\function{nroff_mode} %\synopsis{nroff_mode} %\description % Protoytype: Void nroff_mode (); % A primitive mode for editing nroff/troff files. % mostly to define the paragraph separator %!%- define nroff_mode () { variable nroff = "nroff"; set_mode (nroff, 1); use_syntax_table (nroff); set_buffer_hook ("par_sep", "nroff_parsep"); run_mode_hooks ("nroff_mode_hook"); } jed-0.99-19/lib/linux.sl0000644002657400265740000000147111311317447013742 0ustar davisdavis% % Special file for Linux systems. % % This file sets up the console keys pgup/dn, etc. % To use it, simply rename it to defaults.sl. % The directory where info files are kept. Modify this appropriately. See % 'install.all' for a discussion of this. %Info_Directory = ??? $1 = getenv ("TERM"); if ($1 == NULL) $1 = ""; if (is_list_element ("linux,console,con80x25,con80x28", $1, ',')) { USE_ANSI_COLORS = 1; % uncomment if your console is a color one! OUTPUT_RATE = 0; TERM_CANNOT_SCROLL = -1; % Truth is, linux console does not scroll well. setkey("bol", "\e[1~"); % home setkey("toggle_overwrite", "\e[2~"); % insert setkey("delete_char_cmd", "\e[3~"); % delete setkey("eol", "\e[4~"); % end setkey("page_up", "\e[5~"); setkey("page_down", "\e[6~"); } jed-0.99-19/lib/tex.sl0000644002657400265740000000463111311317447013404 0ustar davisdavis% % simple TeX mode for JED % % When tex mode is loaded, 'tex_mode_hook' is called. This hook will allow % users to customize the mode. In particular, certain functions here have % no keybindings, e.g., 'latex_do_environment'. So, in your jed.rc file, % add something like: % define tex_mode_hook () { % local_setkey ("latex_do_environment", "^C^E"); % } % which binds the function to Ctrl-C Ctrl-E. % Load the common definitions if not already loaded. require ("texcom"); $1 = "TeX-Mode"; !if (keymap_p($1)) { make_keymap ($1); definekey ("tex_insert_quote", "\"", $1); definekey ("tex_insert_quote", "'", $1); definekey ("tex_blink_dollar", "$", $1); definekey ("tex_ldots", ".", $1); } %!%+ %\function{tex_mode} %\synopsis{tex_mode} %\description % Mode useful for editing TeX and LaTeX modes. % Useful bindings: %#v+ % '"' : tex_insert_quote % '\'' : tex_insert_quote % '$' : tex_blink_dollar % '.' : tex_ldots. Inserts a '.' except if preceeded by two dots. In % this case, the dots are converted to \ldots. %#v- % When tex mode is loaded, 'tex_mode_hook' is called. This hook will allow % users to customize the mode. In particular, certain functions here have % no keybindings, e.g., 'latex_do_environment'. So, in your jed.rc file, % add something like: %#v+ % define tex_mode_hook () { % local_setkey ("latex_do_environment", "^C^E"); % } %#v- % which binds the function to Ctrl-C Ctrl-E. %!%- define tex_mode () { variable mode = "TeX"; variable texmode = "TeX-Mode"; use_keymap (texmode); set_mode (mode, 0x1 | 0x20); set_buffer_hook ("par_sep", "tex_paragraph_separator"); set_buffer_hook ("wrap_hook", "tex_wrap_hook"); unset_buffer_hook ("indent_hook"); unset_buffer_hook ("newline_indent_hook"); use_syntax_table (texmode); mode_set_mode_info (mode, "fold_info", "%{{{\r%}}}\r\r"); run_mode_hooks ("tex_mode_hook"); % This is called after the hook to give the hook a chance to load the % abbrev table. %if (abbrev_table_p (mode)) use_abbrev_table (mode); %(Now handled in run_mode_hooks) } %-----------------------------------------------------------% #ifdef 0 define tex_info_find_node () { variable node; node = read_mini ("Node:", Null_String, Null_String); !if (strlen (node)) return; info_reader (); info_find_node ("(latex)top"); info_find_node ("(latex)" + node); } #endif jed-0.99-19/lib/iso-lat2.sl0000644002657400265740000000170311311317447014233 0ustar davisdavis%% %% Initializes upper/lowercase lookup tables for ISO Latin 2 %% if (_slang_utf8_ok == 0) { . 0 64 1 { dup define_case } _for . 65 90 1 { dup 32 + define_case } _for . 91 96 1 { dup define_case } _for . 123 160 1 { dup define_case } _for . 161 177 define_case . 162 162 define_case . 163 179 define_case . 164 164 define_case . 165 166 1 { dup 16 + define_case } _for . 167 168 1 { dup define_case } _for . 169 172 1 { dup 16 + define_case } _for . 173 173 define_case . 174 175 1 { dup 16 + define_case } _for . 176 176 define_case . 178 178 define_case . 180 180 define_case . 183 183 define_case . 184 184 define_case . 189 189 define_case . 192 222 1 { dup 32 + define_case } _for . 215 215 define_case . 223 223 define_case . 247 247 define_case . 255 255 define_case define_word (strcat ("0-9a-zA-Z\d161\d163\d165-\d166\d169-\d172", "\d174\d175\d177\d179\d181\d182\d185-\d188", "\d190-\d214\d216-\d222\d224-\d246\d248-\d254")); } jed-0.99-19/lib/aboutjed.hlp0000644002657400265740000000037411311317447014546 0ustar davisdavisCopyright (C) 1994, 1999, 2000-2007 John E. Davis Email comments or suggestions to jed@jedsoft.org. Jed Home Page: http://www.jedsoft.org/jed/ Newsgroups: alt.lang.s-lang comp.editors Mailing lists: http://www.jedsoft.org/jed/mailinglists/ jed-0.99-19/lib/isearch.sl0000644002657400265740000001732111311317447014222 0ustar davisdavis% Here is a new version of isearch.sl reworked by John Burnell . % This one is said to be more emacs-like. % % %% with modifications and comments by Guenter Milde (G.Milde web.de) % %% Further modifications by Lloyd Zusman %% as well as JED to get rid of marks which were riding on the stack. %% isearch.sl %% Routines here perform incremental forward/backward searches %% %% Default bindings: %% %% ESCAPE quits the search %% ^G aborts the search (returns to starting point) %% ESCAPE or ENTER as first char: switch to non incremental search %% with the last isearch match as default %% BACKSPACE deletes last character entered and returns to previous point %% ^S finds next match (and switches to forward search) %% ^R finds previous match (and switches to backward search) %% %% You may use the following variables to change this behaviour, %% either here or (better!) in your keybinding defining file (e.g. ".jedrc") %% %% This code fragment checks to see what the isearch keys are bound to require ("srchmisc"); custom_variable ("Isearch_Highlight", 1); private define get_bound_key (search_func, default) { foreach (["", which_key (search_func), pop()]) { variable key = (); if (strlen (key) == 2) { if (key [0] == '^') return (key [1] - '@'); } } return default; } custom_variable ("Isearch_Forward_Char", get_bound_key ("isearch_forward", 19)); custom_variable ("Isearch_Backward_Char", get_bound_key ("isearch_backward", 18)); custom_variable ("Isearch_Quit_Char", '\e' ); custom_variable ("Isearch_Abort_Char", 7 ); % ^G %% Cause isearch_{forward,backward} to behave in the traditional %% manner by default. Otherwise, wrap around to the start/end %% of the buffer and keep going after a forward/reverse search %% fails. custom_variable("SEARCH_WRAP", 0); variable Isearch_Last_Search = ""; private variable Last_Search_Failed = 0; private define isearch_simple_search (dir) { Last_Search_Failed = 0; if (dir < 0) search_backward (); else search_forward (); Isearch_Last_Search = LAST_SEARCH; } private define perform_search (str, dir) { variable cs = CASE_SEARCH; if (strlow (str) != str) CASE_SEARCH = 1; if (dir > 0) dir = fsearch (str); else dir = bsearch (str); CASE_SEARCH = cs; return dir; } private variable Position_Stack; private define push_position (attached_to_char) { variable s = struct { mark, attached_to_char, next }; s.mark = create_user_mark (); s.attached_to_char = attached_to_char; s.next = Position_Stack; Position_Stack = s; } private define delete_position_stack () { Position_Stack = NULL; } private define isearch_del (str) { variable attached_to_char = 1; if (Position_Stack != NULL) { variable s = Position_Stack; Position_Stack = s.next; attached_to_char = s.attached_to_char; goto_user_mark (s.mark); } if (attached_to_char) { variable n = strlen (str); if (n) str = substr (str, 1, n-1); } return str; } define isearch_dir (dir) { variable prompt, str = ""; variable c, first = 1; variable len = 0; delete_position_stack (); variable start_mark = create_user_mark (); EXIT_BLOCK { delete_position_stack (); Last_Search_Failed = 0; } ERROR_BLOCK { delete_position_stack (); Last_Search_Failed = 0; } forever { variable prompt_prefix; variable prompt_suffix; variable h = is_line_hidden (); set_line_hidden (0); if (Last_Search_Failed) { prompt_prefix = "Failed: i"; if (strlen(str) > 0) prompt_suffix = ": "; else prompt_suffix = ""; } else { prompt_prefix = "I"; prompt_suffix = ": "; } if (dir > 0) prompt = prompt_prefix + "search forward" + prompt_suffix; else prompt = prompt_prefix + "search backward" + prompt_suffix; message (prompt + str); push_spot (); IGNORE_USER_ABORT++; if (Isearch_Highlight) { if (looking_at (str) and (Last_Search_Failed == 0)) mark_next_nchars (strlen(str), dir); } else { if ((dir > 0) and looking_at (str)) go_right (strlen (str)); } update_sans_update_hook (0); pop_spot (); #ifexists AnyError try { #endif c = getkey(); #ifexists AnyError } finally #endif IGNORE_USER_ABORT--; set_line_hidden (h); switch (c) { case Isearch_Quit_Char and first : isearch_simple_search (dir); break; } { case Isearch_Forward_Char : % ^S push_position (0); if (dir < 0) { % Clear 'failed' indicator if we've changed direction. Last_Search_Failed = 0; dir = 1; } else { go_right_1 (); !if (strlen (str)) { str = Isearch_Last_Search; len = strlen (str); } } } { case Isearch_Backward_Char : %^R push_position (0); if (dir > 0) { % Clear 'failed' indicator if we've changed direction. Last_Search_Failed = 0; dir = -1; c = ' '; % use this to fool test (*) below } else { !if (strlen (str)) str = Isearch_Last_Search; } } { case 127 : % Clear 'failed' indicator. Last_Search_Failed = 0; str = isearch_del (str); continue; } { case Isearch_Abort_Char : % ^G go back to start goto_user_mark (start_mark); beep (); return; } { case '\r' and first: if (dir > 0) return search_forward (); else return search_backward (); } { case '\e': if (input_pending (3)) ungetkey (c); break; } #ifdef IBMPC_SYSTEM { case 0xE0: ungetkey (c); break; } #endif { c < 32 : if (c != '\r') ungetkey (c); break; % terminate search } { str += char (c); % any other char push_position (1); % Clear 'failed' indicator. Last_Search_Failed = 0; } first = 0; if (Last_Search_Failed and (SEARCH_WRAP > 0)) { % The _next_ C-s or C-r after a previous C-s or C-r that failed % will now redo the search from either the beginning or end of % the buffer, depending on whether we've been going forwards or % backwards. Last_Search_Failed = 0; push_mark (); if (dir > 0) bob(); else eob(); pop_mark (not (perform_search (str, dir))); continue; } % test (*), see ^R switch above % NOTE: This test used to include a check to make sure that the % position stack was not empty. Does it matter? --JED if ((dir < 0) and looking_at (str) and (c >= ' ')) continue; if (perform_search (str, dir)) len = strlen (str); else { variable msg; if (c == Isearch_Forward_Char) go_left_1(); if (strlen(str) > 0) msg = strcat (str, " not found."); else msg = "No search string."; flush (msg); % Only beep if we're not wrapping. if (SEARCH_WRAP < 1) beep (); () = input_pending (10); % str = isearch_del (str); if (EXECUTING_MACRO) error ("Not found."); % This piece of state information needs to be set as late % as possible after a failed search attempt. Last_Search_Failed = 1; } } EXECUTE_ERROR_BLOCK; if (strlen (str)) Isearch_Last_Search = str; if (dir > 0) go_right (strlen (str) - len); message ("Done."); } define isearch_forward() { %variable save_abort = IGNORE_USER_ABORT; %IGNORE_USER_ABORT = 1; isearch_dir (1); %IGNORE_USER_ABORT = save_abort; } define isearch_backward() { %variable save_abort = IGNORE_USER_ABORT; %IGNORE_USER_ABORT = 1; isearch_dir (-1); %IGNORE_USER_ABORT = save_abort; } jed-0.99-19/lib/tmisc.sl0000644002657400265740000000151511311317447013721 0ustar davisdavis% % Miscellaneous text functions % define text_justify_line () { variable min, max, r, count; count = 100; push_spot(); bol_skip_white(); if (eolp) {pop_spot(); return; } min = what_column(); eol_trim(); max = what_column(); while ((max < WRAP) and count) { r = random(0, max); --count; if (r < min) continue; goto_column(r); skip_white(); if (ffind_char (' ')) { insert_single_space(); ++max; eol();} } pop_spot(); } define format_paragraph_hook() { variable n; push_spot(); backward_paragraph(); n = what_line(); forward_paragraph (); go_up(2); if (n - what_line() > 0) {pop_spot(); return; } push_mark(); backward_paragraph(); if (what_line() != 1) go_down_1 (); narrow(); bob(); do text_justify_line (); while (down_1 ()); widen(); pop_spot(); } jed-0.99-19/lib/jedusage.sl0000644002657400265740000000170711311317447014374 0ustar davisdavisprivate define p(x) { () = fprintf (stdout, "%s\n", x); } p("Jed usage forms:"); p(""); p("0. jed [--version | --help]"); p("1. jed [--batch] [-n] [-e emulation] [-a alt-jedrc-file] \\"); p(" [file ...] \\ % edit files"); p(" [-g linenumber] \\ % goto line"); p(" [-s search-string] \\ % performa search"); p(" [-l file-to-load] \\ % load slang file"); p(" [-f function] \\ % execute function"); p(" [-i file-to-insert] \\ % insert file"); p(" [-2] \\ % split window"); p(" [-tmp] \\ % do not backup buffer"); p(" [-hook funct (argv)] \\ % exec funct with rest of argv parameters"); p(" [--ANYTHING] % execute ANYTHING as a function"); p(""); p("2. jed -script FILE [arg ...]"); p(""); p("3. jed-script FILE [arg ...]"); p(" This form sets __argv[0] to FILE, __argv[1] to arg, ..."); p(""); quit_jed (); jed-0.99-19/lib/dcl.sl0000644002657400265740000001136611311317447013351 0ustar davisdavis% dcl mode-- Special mode to facilitate editing of DCL files on VMS systems. % . ( [goal] 3 =goal . push_spot . {up_1} . { . eol_trim . bol_skip_white . '$' looking_at_char . { "$\t " skip_chars . '!' looking_at_char {what_column =goal break} !if . } . { . '!' looking_at_char . { % This takes care of running text following something % like type sys$input . push_spot . up_1 eol bolp not and . {trim go_left_1 . '-' looking_at_char . { pop_spot what_column =goal break} !if . } if . pop_spot . } !if . } else . } . while . {"then" looking_at {2 +=goal 1} {0} else} . {"else" looking_at {2 +=goal 1} {0} else} . orelse pop % orelse puts final value on stack . pop_spot . bol "$\t " skip_chars . {"else" looking_at {2 -=goal 1} {0} else} . {"endif" looking_at {2 -=goal 1} {0} else} . orelse pop . goal 1 > {goal}{3} else . ) dcl_get_ind . ( . [goal] . push_spot . dcl_get_ind =goal . push_spot . up_1 {eol_trim bolp {1 go_left '-' looking_at_char {2 +=goal} if} !if} if . pop_spot . bol "\t $" skip_chars . '!' looking_at_char . { "\t " bskip_chars trim goal what_column - whitespace} . !if . pop_spot . skip_white . ) dcl_indent . ( [cont p] 0 =cont . bobp bolp '$' looking_at_char and or {"$ \n" insert 1 left pop return} if . trim . push_spot % If line does not start with '$', assume something like % type sys$input going on and do not give dollar . push_spot bol . '$' looking_at_char not up_1 and . { . bolp eol_trim . 1 go_left . what_char '-' != =cont . } . if . pop_spot . cont { . _get_point =p "sys$input" bfind . { 9 right pop . ':' what_char == {1 right pop} if . _get_point p == =cont . } if . p _set_point . } !if . bolp {1 left pop . '-' looking_at_char { 1 =cont} if . } . !if . pop_spot . newline . cont {'$' insert_char} !if . dcl_indent . ) dcl_newline create_syntax_table("dcl"); #ifdef HAS_DFA_SYNTAX %%% DFA_CACHE_BEGIN %%% private define setup_dfa_callback (name) { dfa_define_highlight_rule("!.*$", "comment", name); dfa_define_highlight_rule("\"[^\"]*\"", "string", name); dfa_define_highlight_rule("/[a-zA-Z][_a-zA-Z0-9\\-]*", "keyword2", name); dfa_define_highlight_rule("\\.([gG]|[lL]|[nN])[eE][sS]?\\.", "preprocess", name); dfa_define_highlight_rule("\\.([gG]|[lL])[tT][sS]?\\.", "preprocess", name); dfa_define_highlight_rule("\\.[eE][qQ][sS]?\\.", "preprocess", name); dfa_define_highlight_rule("\\.[nN][oO][tT]\\.", "preprocess", name); dfa_define_highlight_rule("\\.[aA][nN][tT]\\.", "preprocess", name); dfa_define_highlight_rule("\\.[oO][rR]\\.", "preprocess", name); dfa_define_highlight_rule("[a-zA-Z][\\$a-zA-Z0-9_\\-]*", "Knormal", name); dfa_define_highlight_rule("@", "keyword", name); dfa_define_highlight_rule("[0-9]+", "number", name); dfa_build_highlight_table(name); } dfa_set_init_callback (&setup_dfa_callback, "dcl"); %%% DFA_CACHE_END %%% #endif set_color ("keyword2","blue","black"); () = define_keywords_n ("dcl", "ifon", 2, 0); () = define_keywords_n ("dcl", "eodmcrrunset", 3, 0); () = define_keywords_n ("dcl", "callelseexitgotoopenreadshowthenwait", 4, 0); () = define_keywords_n ("dcl", "closeendifgosubspawnwrite", 5, 0); () = define_keywords_n ("dcl", "assigndefinereturn", 6, 0); () = define_keywords_n ("dcl", "deassign", 8, 0); () = define_keywords_n ("dcl", "subroutine", 10, 0); () = define_keywords_n ("dcl", "endsubroutine", 13, 0); () = define_keywords_n ("dcl", "f$faof$pid", 5, 1); () = define_keywords_n ("dcl", "f$csidf$cvsif$cvuif$editf$filef$modef$timef$typef$user", 6, 1); () = define_keywords_n ("dcl", "f$parse", 7, 1); () = define_keywords_n ("dcl", "f$cvtimef$devicef$getdvif$getenvf$getjpif$getquif$getsyif$lengthf$locatef$searchf$setprvf$stringf$trnlnmf$verify", 8, 1); () = define_keywords_n ("dcl", "f$contextf$elementf$extractf$integerf$messagef$process", 9, 1); () = define_keywords_n ("dcl", "f$directoryf$privilege", 11, 1); () = define_keywords_n ("dcl", "f$identifier", 12, 1); () = define_keywords_n ("dcl", "f$environment", 13, 1); () = define_keywords_n ("dcl", "f$file_attributes", 17, 1); !if (keymap_p ("DCL")) { make_keymap ("DCL"); definekey ("dcl_newline", "^M", "DCL"); definekey ("newline_and_indent", "\e^M", "DCL"); definekey ("dcl_indent", "^I" , "DCL"); definekey ("self_insert_cmd", "\"", "DCL"); definekey ("self_insert_cmd", "'", "DCL"); } define dcl_mode () { set_syntax_flags ("dcl",0x81); use_syntax_table("dcl"); use_dfa_syntax(1); use_keymap ("DCL"); set_mode ("dcl", 4); run_mode_hooks("dcl_mode_hook"); } jed-0.99-19/lib/wordstar.sl0000644002657400265740000003713311311317447014454 0ustar davisdavis% % Wordstar Mode for JED % % Put the line: () = evalfile ("wordstar.sl"); % in your jed.rc startup file. % % Additions and changes by Guido Gonzato, guido@ibogfs.df.unibo.it % Now the wordstar mode is more compatible with the true-blue WordStar, % the Turbo IDE editor, and jstar. % Some features still missing: % % o hilighted blocks a la WordStar % o move block across buffers not implemented yet (tip: setbuf()) % % Please send me requests and bug reports, should you find any. % % Last modified: 5 June 1997 Help_File = "wordstar.hlp"; _Reserved_Key_Prefix = NULL; _Jed_Emulation = "wordstar"; CASE_SEARCH = 1; % I prefer this way variable Ws_Bookmark_Exist = 1; % internal use set_status_line (" Jed %v : %b (%m%n) (%p) %t", 1); set_abort_char (30); % ^^ (Control 6 on most keyboards) % Note, the above command BREAKS ^G emacs abort. unsetkey("^B"); unsetkey("^F"); unsetkey("^K"); unsetkey("^U"); unsetkey("^W"); unsetkey("^X"); % % Basic commands: cursor movement, delete, search & replace, etc. % setkey ("begin_macro","\e("); setkey ("delete_char_cmd","^G"); setkey ("delete_line","^Y"); setkey ("end_macro","\e)"); setkey ("execute_macro","\eE"); setkey ("execute_macro","\ee"); setkey ("format_paragraph", "^B"); setkey ("next_char_cmd","^D"); setkey ("previous_char_cmd","^S"); setkey ("ws_previous_line_cmd","^E"); setkey ("undo", "^U"); setkey ("ws_bdelete_word","\eo"); setkey ("ws_bskip_word","^A"); setkey ("ws_delete_word","^T"); setkey ("ws_insert_last_block", "^P"); setkey ("ws_next_line_cmd","^X"); setkey ("ws_page_down","^C"); setkey ("ws_page_up","^R"); setkey ("ws_repeat_search","^L"); setkey ("ws_skip_word","^F"); setkey ("ws_window_down","^Z"); setkey ("ws_window_up","^W"); % % Control-Q keys --- hope you figure out how to pass ^Q/^S through system % % In case you _cannot_ figure that out, you can use ESC instead of ^Q; % for instance, ESC-A instead of ^Q-A. For wordstar bookmarks, use % ESC-ESC-digit. % ESC-X is not bound, for it's already pretty useful... use ESC-^X instead. % setkey (".0 ws_goto_mark_n","\e\e0"); setkey (".0 ws_goto_mark_n","^Q0"); setkey (".1 ws_goto_mark_n","\e\e1"); setkey (".1 ws_goto_mark_n","^Q1"); setkey (".2 ws_goto_mark_n","\e\e2"); setkey (".2 ws_goto_mark_n","^Q2"); setkey (".3 ws_goto_mark_n","\e\e3"); setkey (".3 ws_goto_mark_n","^Q3"); setkey (".4 ws_goto_mark_n","\e\e4"); setkey (".4 ws_goto_mark_n","^Q4"); setkey (".5 ws_goto_mark_n","\e\e5"); setkey (".5 ws_goto_mark_n","^Q5"); setkey (".6 ws_goto_mark_n","\e\e6"); setkey (".6 ws_goto_mark_n","^Q6"); setkey (".7 ws_goto_mark_n","\e\e7"); setkey (".7 ws_goto_mark_n","^Q7"); setkey (".8 ws_goto_mark_n","\e\e8"); setkey (".8 ws_goto_mark_n","^Q8"); setkey (".9 ws_goto_mark_n","\e\e9"); setkey (".9 ws_goto_mark_n","^Q9"); setkey ("ws_goto_begin_block", "\eB"); setkey ("ws_goto_begin_block", "^QB"); setkey ("ws_goto_begin_block", "^Q^B"); setkey ("ws_goto_end_block", "\eK"); setkey ("ws_goto_end_block", "^QK"); setkey ("ws_goto_end_block", "^Q^K"); setkey ("kill_line","\eY"); setkey ("kill_line","^QY"); setkey ("kill_line","^Q^Y"); setkey ("ws_bob","\eR"); setkey ("ws_bob","^QR"); setkey ("ws_bob","^Q^R"); setkey ("ws_bol","\eS"); setkey ("ws_bol","^QS"); setkey ("ws_bol","^Q^S"); setkey ("ws_eob","\eC"); setkey ("ws_eob","^QC"); setkey ("ws_eob","^Q^C"); setkey ("ws_eol","\eD"); setkey ("ws_eol","^QD"); setkey ("ws_eol","^Q^D"); setkey ("ws_goto_bottom_of_window","\e^X"); % M-X is already reserved! setkey ("ws_goto_bottom_of_window","^QX"); setkey ("ws_goto_bottom_of_window","^Q^X"); setkey ("ws_goto_line_cmd","\eI"); setkey ("ws_goto_line_cmd","^QI"); setkey ("ws_goto_line_cmd","^Q^I"); setkey ("ws_goto_prev","^QP"); setkey ("ws_goto_top_of_window","^QE"); setkey ("ws_goto_top_of_window","^Q^E"); setkey ("ws_goto_top_of_window","^\eE"); setkey ("ws_replace_cmd","\eA"); setkey ("ws_replace_cmd","^QA"); setkey ("ws_replace_cmd","^Q^A"); setkey ("ws_search_forward","\eF"); setkey ("ws_search_forward","^QF"); setkey ("ws_search_forward","^Q^F"); setkey ("ws_toggle_case","^QT"); setkey ("ws_toggle_case","^Q^T"); % % Control-K map % setkey (".0 ws_set_mark_n","^K0"); setkey (".1 ws_set_mark_n","^K1"); setkey (".2 ws_set_mark_n","^K2"); setkey (".3 ws_set_mark_n","^K3"); setkey (".4 ws_set_mark_n","^K4"); setkey (".5 ws_set_mark_n","^K5"); setkey (".6 ws_set_mark_n","^K6"); setkey (".7 ws_set_mark_n","^K7"); setkey (".8 ws_set_mark_n","^K8"); setkey (".9 ws_set_mark_n","^K9"); setkey ("exit_jed","^KX"); setkey ("exit_jed","^K^X"); setkey ("find_file", "^KE"); setkey ("find_file", "^K^E"); setkey ("kill_buffer","^KQ"); setkey ("kill_buffer","^K^Q"); setkey ("one_window", "^KI"); setkey ("one_window", "^K^I"); setkey ("save_buffer","^KD"); setkey ("save_buffer","^K^D"); setkey ("suspend", "^KZ"); setkey ("suspend", "^K^Z"); setkey ("switch_to_buffer","^KP"); setkey ("switch_to_buffer","^K^P"); setkey ("ws_begin_block","^KB"); setkey ("ws_begin_block","^K^B"); setkey ("ws_comment_block", "^K;"); setkey ("ws_copy_block","^KC"); setkey ("ws_copy_block","^K^C"); setkey ("ws_delete_block","^KY"); setkey ("ws_delete_block","^K^Y"); setkey ("ws_end_block","^KK"); setkey ("ws_end_block","^K^K"); setkey ("ws_filter_region","^K/"); setkey ("ws_insert_file","^KR"); setkey ("ws_insert_file","^K^R"); setkey ("ws_lowercase_region","^KL"); setkey ("ws_lowercase_region","^K^L"); setkey ("ws_move_block", "^KV"); setkey ("ws_move_block", "^K^V"); setkey ("ws_save_buffer","^KS"); setkey ("ws_save_buffer","^K^S"); setkey ("ws_select_word","^KT"); setkey ("ws_select_word","^K^T"); setkey ("ws_uppercase_region","^KU"); setkey ("ws_uppercase_region","^K^U"); setkey ("ws_write_region","^KW"); setkey ("ws_write_region","^K^W"); % % Implementation % !if (is_defined("_Ws_Bookmarks")) { % user marks are of type 128 $1 = 13; % bookmarks 0..9 are for the user; bookmark 10 is used by some of the % following functions; bookmark 11 and 12 mark the beginning and end of % the block (used by ^QB and ^QK) variable _Ws_Bookmarks = Mark_Type [$1]; variable _Ws_Bookmarks_Exist = Integer_Type [$1]; variable i; for (i = 0; i < $1; i++) _Ws_Bookmarks_Exist [i] = -1; % not initialized } % ws_set_bookmark () and ws_goto_bookmark () are implemented to provide % a more Wordstar-ish way of copying and moving blocks, and of moving % around generally. define ws_set_bookmark () { _Ws_Bookmarks[10] = create_user_mark (); Ws_Bookmark_Exist = 1; } define ws_goto_bookmark () { variable mrk = _Ws_Bookmarks[10]; sw2buf (user_mark_buffer (mrk)); goto_user_mark (mrk); } % % Basic commands: cursor movement, delete, f&r, etc. % define ws_execute_macro () { ws_set_bookmark (); call ("execute_macro"); } define ws_next_line_cmd () { ws_set_bookmark (); call ("next_line_cmd"); } define ws_previous_line_cmd () { ws_set_bookmark (); call ("previous_line_cmd"); } define ws_page_down () { ws_set_bookmark (); call ("page_down"); } define ws_page_up () { ws_set_bookmark (); call ("page_up"); } define ws_bob () { ws_set_bookmark (); bob (); } define ws_eob () { ws_set_bookmark (); eob (); } define ws_bol () { ws_set_bookmark (); bol (); } define ws_eol () { ws_set_bookmark (); eol (); } define ws_goto_bottom_of_window () { ws_set_bookmark (); goto_bottom_of_window (); } define ws_goto_top_of_window () { ws_set_bookmark (); goto_top_of_window (); } define ws_window_up () % ^W { recenter (window_line() + 1); } define ws_window_down () % ^Z { recenter (window_line() + 1); } define ws_goto_line_cmd () % ^QI { ws_set_bookmark (); goto_line_cmd (); } define ws_replace_cmd () { ws_set_bookmark (); replace_cmd (); } define ws_search_forward () { ws_set_bookmark (); search_forward (); } define ws_toggle_case () { CASE_SEARCH = not(CASE_SEARCH); vmessage ("Case search is %d ", CASE_SEARCH); } define ws_repeat_search () % ^L { ws_set_bookmark (); go_right_1 (); !if (fsearch(LAST_SEARCH)) error ("Not found."); } % !"#$%&'()*+,-./:;<=>?@[\]^`{|}~ , but not _ % define ws_delete_word () % ^T % { % variable p = _get_point (); % push_mark (); % skip_chars ("\n\t !\"#$%&'()*+,-./:;<=>?@[\]^`{|}~"); % if (_get_point () == p) { % skip_chars ("^\n\t !\"#$%&'()*+,-./:;<=>?@[\]^`{|}~"); % } % del_region (); % } define ws_delete_word () % ^T { variable p = _get_point (); push_mark (); skip_chars ("a-zA-Z0-9"); if (_get_point() == p) skip_chars (" \n\t"); if (_get_point() == p) go_right_1 (); del_region (); } define ws_bdelete_word () % ESC-O { variable p = _get_point (); push_mark (); bskip_chars ("a-zA-Z0-9"); if (_get_point () == p) bskip_chars (" \n\t"); if (_get_point () == p) go_left_1 (); del_region (); } define ws_skip_word () % ^F { variable p = _get_point (); push_mark (); skip_chars ("^\n\t !\"#$%&'()*+,-./:;<=>?@[\]^`{|}~"); if (_get_point () == p) { skip_chars ("\n\t !\"#$%&'()*+,-./:;<=>?@[\]^`{|}~"); skip_chars ("^\n\t !\"#$%&'()*+,-./:;<=>?@[\]^`{|}~"); } pop_mark_0 (); } define ws_bskip_word () % ^A { variable p = _get_point (); push_mark (); bskip_chars ("\n\t !\"#$%&'()*+,-./:;<=>?@[\]^`{|}~"); bskip_chars ("^\n\t !\"#$%&'()*+,-./:;<=>?@[\]^`{|}~"); pop_mark_0 (); } % Blocks: ^K-something % % Not implemented: % ^K^H - Hide or unhide the currently selected block % % the blocks are very different. Here we cheat. Two marks are pushed-- % One at beginning of block and one at end. Assumption is that the spots % we see are the ones we put. variable WS_Mark_Pushed = 0; define ws_begin_block () { loop (WS_Mark_Pushed) pop_mark_0 (); WS_Mark_Pushed = 1; push_mark(); push_mark (); call ("set_mark_cmd"); _Ws_Bookmarks[11] = create_user_mark (); message ("Begin Block."); } % copies block to internal buffer-- preserves block variable WS_Block_Buffer = " *ws-internal*"; define ws_copy_block_to_buffer () { if (WS_Mark_Pushed < 2) error ("Block Not defined."); push_spot (); pop_mark_1 (); % end of block dupmark(); pop(); % dup beginning because we want to keep it whatbuf (); setbuf (WS_Block_Buffer); erase_buffer (); setbuf(()); copy_region (WS_Block_Buffer); push_mark (); pop_spot (); } define ws_end_block () { if (WS_Mark_Pushed != 1) { loop (WS_Mark_Pushed) pop_mark_0 (); WS_Mark_Pushed = 0; error ("Begin Block First!"); } !if (markp()) { WS_Mark_Pushed = 0; error ("Wordstar Error."); } WS_Mark_Pushed = 2; pop_mark_0 (); % pops visible mark from begin block push_mark (); ws_copy_block_to_buffer (); _Ws_Bookmarks[12] = create_user_mark (); message ("Block Defined."); } define ws_delete_block () { ws_copy_block_to_buffer (); pop_mark_1 (); del_region (); } define ws_write_region () { ws_copy_block_to_buffer (); pop_mark_1 (); write_region (); } define ws_copy_block () { ws_set_bookmark (); % we will return to this location afterwards insbuf (WS_Block_Buffer); ws_goto_bookmark (); message ("Block Copied."); } define ws_comment_region () { variable cbeg, cmid, cend; variable c, c1, celm, extra, smode, mode; if (WS_Mark_Pushed != 2) { error ("Block Undefined!"); } (smode, mode) = what_mode (); !if (strcmp(smode,"Text")) { % Text mode return; } !if (strcmp(smode,"TeX")) { % TeX mode cbeg = "% "; cmid = "% "; cend = Null_String; } !if (strcmp(smode,"html")) { % html mode cbeg = ""; } !if (strcmp(smode,"C")) { % C mode cbeg = "/* "; cmid = " * "; cend = " */"; } !if (strcmp(smode,"SL")) { % Slang mode cbeg = "% "; cmid = "% "; cend = Null_String; } !if (strcmp(smode,"Fortran")) { % Fortran mode cbeg = "C "; cmid = "C "; cend = Null_String; } % the remaining is almost the same as c_comment_region () check_region (1); exchange_point_and_mark (); c = what_column (); narrow (); bob (); USER_BLOCK0 { extra = (); celm = (); bol_skip_white (); c1 = what_column (); if (c1 > c) { goto_column (c); insert (celm); trim (); whitespace (c1 - what_column () + extra); } else { if (eolp ()) goto_column (c); insert (celm); } } X_USER_BLOCK0 (cbeg, 0); while (down_1 ()) { if (down_1 ()) { % check for last but one up_1 (); X_USER_BLOCK0 (cmid, 0); % 1 } } widen (); if (looking_at(cmid)) { deln (3); } X_USER_BLOCK0 (cend, 0); pop_spot (); } define ws_comment_block () % ^K; { ws_set_bookmark (); pop_mark_1 (); ws_comment_region (); ws_goto_bookmark (); message ("Block Commented."); } define ws_move_block () % ^KV % Warning - doesn't work across buffers { ws_copy_block_to_buffer (); ws_set_bookmark (); insbuf (WS_Block_Buffer); ws_delete_block (); ws_goto_bookmark (); message ("Block Moved."); } define ws_insert_file () % ^KR { variable file = read_with_completion ("File:", Null_String, Null_String, 'f'); ws_set_bookmark (); insert_file (file); ws_goto_bookmark (); message ("File inserted."); } define ws_select_word () % ^KT, Borland IDE facility { ws_set_bookmark (); % afterwards, we return to this location loop (WS_Mark_Pushed) pop_mark_0 (); WS_Mark_Pushed = 1; ws_skip_word (); ws_bskip_word (); push_mark(); push_mark (); call ("set_mark_cmd"); ws_skip_word (); WS_Mark_Pushed = 2; pop_mark_0 (); % pops visible mark from begin block push_mark (); ws_copy_block_to_buffer (); ws_goto_bookmark (); message ("Word Selected."); } define ws_insert_last_block () { if (bufferp(WS_Block_Buffer)) insbuf (WS_Block_Buffer); } variable Last_Process_Command = Null_String; define ws_filter_region () % ^K/, Joe extension { variable cmd, tmp_file; cmd = read_mini ("Pipe to command:", Last_Process_Command, Null_String); !if (strlen (cmd)) return; Last_Process_Command = cmd; ws_copy_block_to_buffer (); pop_mark_1 (); tmp_file = make_tmp_file ("/tmp/jedpipe"); cmd = strcat (cmd, " > ", tmp_file, " 2>&1"); !if (dupmark ()) error ("Mark not set."); if (pipe_region (cmd)) { error ("Process returned a non-zero exit status."); } del_region (); () = insert_file (tmp_file); () = delete_file (tmp_file); } define ws_uppercase_region() % ^KU { ws_copy_block_to_buffer (); pop_mark_1 (); xform_region('u'); } define ws_lowercase_region() % ^KL { ws_copy_block_to_buffer (); pop_mark_1 (); xform_region('d'); } % % These are predefined bookmarks 0..9, a la Wordstar. % define ws_goto_mark_n (n) { variable mrk; if (_Ws_Bookmarks_Exist[n] != 1) error ("Bookmark not set!"); ws_set_bookmark (); mrk = _Ws_Bookmarks[n]; sw2buf (user_mark_buffer (mrk)); goto_user_mark (mrk); message ("done."); } define ws_set_mark_n (n) % ^K0 { _Ws_Bookmarks[n] = create_user_mark (); _Ws_Bookmarks_Exist[n] = 1; vmessage ("Bookmark %d set.", n); } define ws_save_buffer () % !!! buggy !!! { variable file, dir, flags; (file, dir, , flags) = getbuf_info (); file = read_file_from_mini ("Save to file:"); () = write_buffer (file); } % % These are ^QB and ^QK % define ws_goto_begin_block () % ^QB { variable mrk = _Ws_Bookmarks[11]; sw2buf (user_mark_buffer (mrk)); ws_set_bookmark (); goto_user_mark (mrk); } define ws_goto_end_block () % ^QK { variable mrk = _Ws_Bookmarks[12]; sw2buf (user_mark_buffer (mrk)); ws_set_bookmark (); goto_user_mark (mrk); } define ws_goto_prev () % ^QP { if (Ws_Bookmark_Exist != 1) error ("No previous location!"); ws_goto_bookmark (); } runhooks ("keybindings_hook", _Jed_Emulation); % --- End of file wordstar.sl --- jed-0.99-19/lib/help.sl0000644002657400265740000003053011311317447013531 0ustar davisdavis%% help.sl require ("keydefs"); autoload ("glob", "glob"); %!%+ %\variable{Help_Describe_Bindings_Show_Synopsis} %\synopsis{Used to control the searching of synopsis strings} %\usage{variable Help_Describe_Bindings_Show_Synopsis = 0;} %\description % If the value of this variable is non-zero, the % \sfun{describe_bindings} function will search through the % documentation for synopsis strings and display the resulting strings % along with the key bindings. Since this can be a time consuming % process for slow computers or slow filesystems, this feature is % turned off by default. %\example % variable Help_Describe_Bindings_Show_Synopsis = 1; %!%- custom_variable ("Help_Describe_Bindings_Show_Synopsis", 0); % Convert all controls chars in key and return ^ form. (\e --> ^[) private define convert_keystring (key) { variable new_key = ""; variable i = 1, n = strlen (key); while (i <= n) { variable the_key = substr (key, i, 1); i++; if (the_key[0] < ' ') the_key = strcat ("^", char (the_key[0] + '@')); new_key = strcat (new_key, the_key); } return new_key; } private define make_key_name_table () { variable key_vars = _apropos ("Global", "\\c^Key_", 8); variable a = Assoc_Type[String_Type]; foreach (key_vars) { variable key_name = (); variable vref = __get_reference (key_name); if (vref == NULL) continue; if (0 == __is_initialized (vref)) continue; variable value = @vref; if (typeof (value) != String_Type) continue; if (value == "") continue; key_name = strtrans (substr (key_name, 5, -1), "_", "-"); value = convert_keystring (value); a[value] = key_name; } return a; } private variable Key_Name_Table = make_key_name_table (); private define make_key_name_table (); % nolonger needed % a definition for a lonely Alt character causes problems, because no % Alt-XY is recognized $1 = __get_reference ("ALT_CHAR"); if ($1 != NULL) { $1 = @$1; if ($1 != 0) assoc_delete_key (Key_Name_Table, convert_keystring(char($1))); } % the definition of Key_Space is missing, but it is useful !if (assoc_key_exists(Key_Name_Table, " ")) Key_Name_Table[" "] = "Space"; private define keyeqs (seq, key) { variable n = strbytelen (key); if (strnbytecmp (seq, key, n)) return 0; return n; } %!%+ %\function{expand_keystring} %\synopsis{expand_keystring} %\usage{String expand_keystring (String key)} %\description % This function takes a key string that is suitable for use in a 'setkey' % definition and expands it to a human readable form. % For example, it expands ^X to the form "Ctrl-X", ^[ to "ESC", % ^[[A to "UP", etc... %\seealso{setkey} %!%- define expand_keystring (seq) { variable alt_char = 0; if (is_defined ("ALT_CHAR")) alt_char = @__get_reference ("ALT_CHAR"); seq = convert_keystring (seq); if (assoc_key_exists (Key_Name_Table, seq)) return Key_Name_Table[seq]; variable key_seqs = assoc_get_keys (Key_Name_Table); variable key_name, expanded_key = ""; forever { variable n = strbytelen (seq); if (n == 0) break; variable dn = 0; foreach (key_seqs) { variable key_seq = (); dn = keyeqs (seq, key_seq); if (dn) { key_name = Key_Name_Table[key_seq]; break; } } variable append_space = 1; if (dn == 0) { if ((seq[0] == '^') and (n > 1)) { variable ch = seq[1]; switch (ch) { case 'I': "TAB";} { case 'M': "RET";} { case '[': if ((alt_char == 27) and (seq[2] != '\0')) { append_space = 0; "Alt-"; } else "ESC"; } { % default "Ctrl-" + char (seq[1]); } key_name = (); dn = 2; } else { key_name = substr (seq, 1, 1); dn = strbytelen (key_name); } } expanded_key = strcat (expanded_key, key_name); if (append_space) expanded_key = strcat (expanded_key, " "); seq = substrbytes (seq, dn+1, -1); } if (strlen (expanded_key)) return substr (expanded_key, 1, strlen(expanded_key) - 1); return expanded_key; } %% show key public define showkey () { variable f, type; flush("Show Key: "); (type, f) = get_key_binding (); if (f == NULL) { vmessage ("Key \"%s\" is undefined.", expand_keystring (LASTKEY)); return; } variable ks = expand_keystring (LASTKEY); switch (type) { case 0: if (1 == is_defined (f)) vmessage ("Key \"%s\" runs the intrinsic function \"%s\".", ks, f); else vmessage ("Key \"%s\" runs the S-Lang function \"%s\".", ks, f); } { case 1: vmessage ("Key \"%s\" runs the internal function \"%s\".", ks, f); } { case 2: vmessage ("Key \"%s\" runs the keyboard macro \"%s\".", ks, f); } { case 3: vmessage ("Key \"%s\" inserts \"%s\".", ks, f); } { case 4: vmessage ("Key \"%s\" is a reference %S", ks, f); } } %% apropos function define apropos () { variable n, cbuf, s, a; if (MINIBUFFER_ACTIVE) return; s = read_mini("apropos:", "", ""); a = _apropos("Global", s, 0xF); vmessage ("Found %d matches.", length (a)); a = a[array_sort (a)]; cbuf = whatbuf(); pop2buf("*apropos*"); erase_buffer(); foreach (__tmp(a)) { insert(()); newline(); } buffer_format_in_columns(); bob(); set_buffer_modified_flag(0); pop2buf(cbuf); } define where_is () { variable n, cmd; if (MINIBUFFER_ACTIVE) return; cmd = read_with_completion ("Where is command:", "", "", 'F'); !if (strlen (cmd)) return; n = which_key (cmd); !if (n) return message ("Not on any keys."); message (expand_keystring ()); --n; loop (n) pop (); } define help_get_doc_string (f) { variable file; variable n, str; n = 0; str = NULL; do { file = extract_element (Jed_Doc_Files, n, ','); if (file == NULL) break; if (2 == file_status (file)) { foreach (glob (path_concat (file, "*.hlp"))) { file = (); str = get_doc_string_from_file (file, f); if (str != NULL) break; } } else str = get_doc_string_from_file (file, f); n++; } while (str == NULL); return (file, str); } define help_for_function (f) { variable cbuf = whatbuf (); variable tmp = " *jed-help*"; variable help = "*function-help*"; variable doc_str, file; variable value; variable str = ""; % For variables such as TAB, whose value depends upon the buffer, % evaluate the variable in the current buffer. if (is_defined (f) < 0) { % __get_reference cannot return NULL since f is defined value = __get_reference (f); if (__is_initialized (value)) str = sprintf ("%S %s: value = %S\n", typeof (@value), f, @value); else str = ("%s: \n", f); } else if (is_internal (f)) str = (f + ": internal function\n"); pop2buf (help); set_readonly (0); erase_buffer (); vinsert (str); (file, doc_str) = help_get_doc_string (f); if (doc_str != NULL) vinsert ("%s[Obtained from file %s]", doc_str, file); else if (is_internal (f)) % this block can be removed { % once internal funs are documented vinsert ("\nUse call (\"%s\") to access from slang\n\n", f); insert (strcat ("You might bind an internal function to a key ", "using setkey() or definekey()\n")); } else { vinsert ("%s: Undocumented ", f); switch (is_defined (f)) { case 1: insert ("intrinsic function"); } { case 2: insert ("slang function"); } { insert (" and unknown"); } } insert ("\n-----------------------------------\n"); bob (); set_buffer_modified_flag (0); pop2buf (cbuf); } define help_do_help_for_object (prompt, flags) { variable n, objs; if (MINIBUFFER_ACTIVE) return; #ifntrue n = _apropos ("", flags); objs = ""; loop (n) { objs = () + "," + objs; } #else objs = _apropos ("Global", "", flags); objs = objs[array_sort (objs)]; objs = strjoin (objs, ","); #endif help_for_function (read_string_with_completion (prompt, "", objs)); } define describe_function () { help_do_help_for_object ("Describe Function:", 0x3); } define describe_variable () { help_do_help_for_object ("Describe Variable:", 0xC); } define describe_mode () { variable flags, modstr; (modstr, flags) = what_mode (); modstr = extract_element (modstr, 0, ' '); !if (strlen (modstr)) modstr = "no"; !if (is_defined (modstr)) { modstr = strlow (modstr); !if (is_defined (modstr)) { modstr += "_mode"; !if (is_defined (modstr)) error ("Mode is not defined: " + modstr); } } help_for_function (modstr); } define describe_bindings () { flush("Building bindings.."); variable map = what_keymap (); variable buf = whatbuf (); pop2buf("*KeyBindings*"); variable cse = CASE_SEARCH; CASE_SEARCH = 1; erase_buffer (); dump_bindings (map); if (map != "global") { variable dump_end_mark = create_user_mark(); insert("\nInherited from the global keymap:\n"); push_spot(); dump_bindings("global"); pop_spot(); variable global_map = Assoc_Type[String_Type, ""]; while ( not eobp() ) { push_mark(); () = ffind("\t\t\t"); variable key = bufsubstr(); go_right (3); push_mark(); % Could have a newline here if (not fsearch("\t\t\t")) eob (); go_up_1(); () = dupmark(); global_map[key] = bufsubstr(); del_region (); delete_line (); } bob(); forever { push_mark(); () = ffind("\t\t\t"); key = bufsubstr(); if (key == "") break; variable global_map_key = global_map[key]; go_right (3); if (global_map_key != "") { push_mark(); () = fsearch("\t\t\t"); if (create_user_mark() > dump_end_mark) goto_user_mark(dump_end_mark); go_up_1(); () = dupmark(); if (bufsubstr() == global_map_key) { del_region (); delete_line (); push_spot(); eob(); (global_map_key,) = strreplace (global_map_key, "\n", "\\n", strlen(global_map_key)); vinsert ("%s\t\t\t%s\n", key, global_map_key); pop_spot(); } else { pop_mark_0(); go_down_1 (); } } else { () = fsearch ("\t\t\t"); bol (); } } } else { bob(); while ( not eobp() ) { if (not ffind("\t\t\t")) { go_up_1(); insert("\\n"); del(); } if (0 == down_1()) break; } } bob(); do { push_mark (); if (not (ffind("\t\t\t"))) { pop_mark(0); continue; } key = bufsubstr(); variable old_len = strlen(key); (key,) = strreplace(key, "ESC", "\e", strlen(key)); key = str_delete_chars(key, " "); (key,) = strreplace(key, "SPACE", " ", strlen(key)); (key,) = strreplace(key, "DEL", "\x7F", strlen(key)); (key,) = strreplace(key, "TAB", "\t", strlen(key)); bol(); () = replace_chars(old_len, expand_keystring(key)); if (what_column () <= TAB) insert_char('\t'); else { if ( what_column() <= TAB*4 ) deln( (what_column()-1)/TAB - 1 ); else deln(3); } } while (down_1 ()); bob(); EXIT_BLOCK { bob(); CASE_SEARCH = cse; set_buffer_modified_flag(0); pop2buf (buf); message ("done"); } if (Help_Describe_Bindings_Show_Synopsis == 0) return; variable synopsis = Assoc_Type[String_Type]; flush ("Looking up key descriptions..."); while (fsearch ("\t\t\t")) { go_right (3); if ( looking_at_char('@') or looking_at_char(' ') ) continue; if ( looking_at_char('.') ) { eol(); bskip_chars("a-zA-Z_"); } push_mark(); !if ( ffind_char('(') ) eol(); variable fun = bufsubstr(); variable dsc; if (assoc_key_exists(synopsis, fun)) dsc = synopsis[fun]; else { (,dsc) = help_get_doc_string(fun); if (dsc == NULL) dsc = ""; synopsis[fun] = dsc; } if (dsc != "") { eol(); dsc = substr(dsc, is_substr(dsc, "\n SYNOPSIS\n ")+12, strlen(dsc)); whitespace( 48 - what_column() ); insert(substr(dsc, 1, is_substr(dsc, "\n")-1) ); } eol (); } } jed-0.99-19/lib/vms_shell.com0000644002657400265740000000041511311317447014734 0ustar davisdavis$! $! This is used by JED to execute a command in the shell. I do $! it this way because not every command takes a /output qualifier $! $ define/user/nolog sys$error sys$output $ define/user/nolog sys$input nl: $ 'p1' 'p2' 'p3' 'p4' 'p5' 'p6' 'p7' 'p8' 'p9' $ exit jed-0.99-19/lib/tpascal.sl0000644002657400265740000001341611311317447014234 0ustar davisdavis% TurboPascal Mode for the jed editor % jed097b9 and later % % Version: minimal % Update : 06 apr 1995 % Author : Carsten Tinggaard Nielsen, tinggard@iesd.auc.dk % variable tpas_objname = "*UnDef ObjectName*"; variable tpas_indent = 2; variable tpas_tab_save = 0; define tpas_is_comment() { return 0; } define tpas_getname(tellstring) { variable gname = read_mini(tellstring, Null_String, Null_String); return gname; } % -------------------------------------------------------------- % Utility routines define ins_snlp (pos, str) { % insert str, newline and indent to pos % note that str must be formatted with Sprintf insert(str); insert("\n"); if (pos > 0) loop(pos) insert_single_space(); } define tpas_pos() { return what_column() - 1;} define tpas_paspf(p, name) { ins_snlp(p, "(* "); ins_snlp(p, " * "); ins_snlp(p, " *)"); ins_snlp(p, "BEGIN"); insert("END; (* "); insert(name); ins_snlp(p, " *)"); } define tpas_delim_string() { return "--------------------------------------------------"; } define tpas_prog_unit_start() { variable s = tpas_delim_string(); vinsert("(* %s\n", s); insert(" * Author : Carsten Tinggaard Nielsen\n"); insert(" * Project: \n"); insert(" * Module : \n * \n"); insert(" * $Revision$ $Date$\n"); insert(" * $Locker$ $Source$\n"); vinsert(" * %s *)\n", s); insert("(*$I-,V-,B+*)\n"); } define tpas_prog_unit_end() { insert("\n USES\n DOS;\n\n"); insert("BEGIN\n"); insert("END.\n"); insert("(* History:\n * --------\n * $Log$\n *)\n"); } define tpas_main() { variable progname = tpas_getname("Name of program:"); bob(); vinsert ("PROGRAM %s;\n", progname); tpas_prog_unit_start(); insert("(*$M 16000, 128000, 512000 *)\n"); tpas_prog_unit_end(); bob(); } define tpas_unit() { variable unitname = tpas_getname("Name of unit:"); bob(); vinsert ("UNIT %s;\n", unitname); insert("INTERFACE\n\n USES\n DOS;\n\n"); insert("IMPLEMENTATION\n"); tpas_prog_unit_start(); tpas_prog_unit_end(); bob(); } define tpas_proc() { variable p = tpas_pos(); variable name = tpas_getname("Procedure:"); ins_snlp(p, sprintf("PROCEDURE %s();", name)); tpas_paspf(p, name); bsearch(");"); } define tpas_func() { variable p = tpas_pos(); variable name = tpas_getname("Function:"); ins_snlp(p, sprintf("FUNCTION %s() : ;", name)); tpas_paspf(p, name); bsearch(") :"); } define tpas_wrap_hook() { variable p; push_spot(); go_up_1 (); bol_skip_white(); p = _get_point (); if (looking_at("BEGIN")) { go_down_1 (); skip_white (); p = what_column (); bol_trim (); whitespace (p + tpas_indent); } pop_spot(); } % -------------------------------------------------------------- % keymap definiiton % !if (keymap_p("TPas")) { make_keymap("TPas"); %undefinekey ("^C"); definekey_reserved ("tpas_main", "m", "TPas"); definekey_reserved ("tpas_unit", "u", "TPas"); definekey_reserved ("tpas_proc", "p", "TPas"); definekey_reserved ("tpas_func", "f", "TPas"); definekey ("self_insert_cmd", "\t", "TPas"); } create_syntax_table("TPas"); define_syntax("(*", "*)", '%', "TPas"); define_syntax ("([", ")]", '(', "TPas"); define_syntax ('\'', '\'', "TPas"); define_syntax ("0-9a-zA-Z_", 'w', "TPas"); % words define_syntax ("-+0-9a-FA-F.", '0', "TPas"); % Numbers define_syntax (",;.?:", ',', "TPas"); define_syntax ("@$()[]%-+/*=<>^", '+', "TPas"); set_syntax_flags ("TPas", 5); % case insensitive + C-mode #ifdef HAS_DFA_SYNTAX %%% DFA_CACHE_BEGIN %%% private define setup_dfa_callback (name) { dfa_enable_highlight_cache("tpascal.dfa", name); dfa_define_highlight_rule("\\(\\*.*\\*\\)", "Qcomment", name); dfa_define_highlight_rule("^([^\\(]|\\([^\\*])*\\*\\)", "Qcomment", name); dfa_define_highlight_rule("\\(\\*.*", "comment", name); dfa_define_highlight_rule("{.*}", "Qcomment", name); dfa_define_highlight_rule("^[^{]*}", "Qcomment", name); dfa_define_highlight_rule("{.*", "comment", name); dfa_define_highlight_rule("^[ \t]*\\*+([ \t].*)?$", "comment", name); dfa_define_highlight_rule("[A-Za-z_][A-Za-z_0-9]*", "Knormal", name); dfa_define_highlight_rule("[0-9]+(\\.[0-9]+)?([Ee][\\+\\-]?[0-9]*)?", "number", name); dfa_define_highlight_rule("\\$[0-9A-Fa-f]*", "number", name); dfa_define_highlight_rule("'[^']*'", "string", name); dfa_define_highlight_rule("'[^']*$", "string", name); dfa_define_highlight_rule("#($[0-9A-Fa-f]+|[0-9]+)", "string", name); dfa_define_highlight_rule("[ \t]+", "normal", name); dfa_define_highlight_rule("[\\(\\[\\]\\),;\\.\\?:]", "delimiter", name); dfa_define_highlight_rule("[@\\-\\+/\\*=<>\\^]", "operator", name); dfa_build_highlight_table(name); } dfa_set_init_callback (&setup_dfa_callback, "TPas"); %%% DFA_CACHE_END %%% #endif () = define_keywords ("TPas", "doifofto", 2); () = define_keywords ("TPas", "endfornewnilsetvar", 3); () = define_keywords ("TPas", "bytecasecharelseexitfilehaltrealtextthentypeunituseswithword", 4); () = define_keywords ("TPas", "arraybeginconstuntilwhile", 5); () = define_keywords ("TPas", "downtoinlineobjectrecordrepeatstring", 6); () = define_keywords ("TPas", "booleanintegerlongintpointerprogram", 7); () = define_keywords ("TPas", "functionshortint", 8); () = define_keywords ("TPas", "interfaceotherwiseprocedure", 9); () = define_keywords ("TPas", "implementation", 14); define tpas_par_sep_hook() { variable p; push_spot(); pop_spot(); } % -------------------------------------------------------------- % Main entry % define tpas_mode () { set_mode("TPas", 2); use_keymap("TPas"); use_syntax_table("TPas"); set_buffer_hook("wrap_hook", "tpas_wrap_hook"); set_buffer_hook("par_sep", "tpas_par_sep_hook"); %tpas_set_localkeys(); run_mode_hooks("tpas_mode_hook"); } jed-0.99-19/lib/krconv.sl0000644002657400265740000000357411311317447014113 0ustar davisdavis%enable_profiling (); private define fixup_line () { variable col; !if (parse_to_point ()) { col = what_column (); bol_skip_white (); if (col != what_column ()) { goto_column (col); indent_line (); if (C_BRA_NEWLINE) newline (); } go_right_1 (); trim (); !if (eolp () or looking_at_char (',') or looking_at_char (';')) { indent_line (); newline (); } } go_right_1 (); } define c_indent_buffer () { variable line = -50, max_line; push_spot (); eob (); max_line = what_line (); bob (); do { bol_skip_white (); if (looking_at ("/*")) { % skip the comment () = fsearch ("*/"); continue; } eol (); if (blooking_at ("\\")) { indent_line (); % skip all continuation lines. while (down (1)) { eol (); !if (blooking_at ("\\")) break; } continue; } trim (); bol_skip_white (); !if (looking_at_char ('{')) { variable this_line = what_line (); % I do not want to touch constructs such as x = {1, 3}; while (ffind_char ('{') and parse_to_point ()) go_right_1 (); if (looking_at_char ('{')) { variable m = create_user_mark (); if (find_matching_delimiter ('{') and (this_line == what_line ())) { eol (); indent_line (); continue; } goto_user_mark (m); } bol (); while (ffind_char ('}')) fixup_line (); bol (); while (ffind_char ('{')) fixup_line (); } indent_line (); if (line + 50 < what_line ()) { line = what_line (); flush (sprintf ("processed %d/%d lines.", line, max_line)); } %update_sans_update_hook (1); } while (down_1 ()); trim_buffer (); flush (sprintf ("processed %d/%d lines.", what_line (), max_line)); pop_spot (); } jed-0.99-19/lib/search.sl0000644002657400265740000000504311311317447014047 0ustar davisdavis% % forward and backward search functions. These functions can search across % lines. % require ("srchmisc"); define search_across_lines (str, dir) { variable n, s, s1, fun, len; len = strlen (str); fun = &fsearch; if (dir < 0) fun = &bsearch; n = is_substr (str, "\n"); !if (n) { if (@fun (str)) return len; return -1; } s = substr (str, 1, n); s1 = substr (str, n + 1, strlen(str)); n = strlen(s); push_mark (); while (@fun(s)) { % we are matched at end of the line. go_right (n); if (looking_at(s1)) { go_left(n); pop_mark_0 (); return len; } if (dir < 0) go_left (n); } pop_mark_1 (); -1; } private define setup_case_search (pat) { variable cs = CASE_SEARCH; if (strlow (pat) != pat) { CASE_SEARCH = 1; } return cs; } define search_generic_search (prompt, dir, line_ok_fun) { variable str, not_found = 1; str = read_mini(prompt, LAST_SEARCH, Null_String); !if (strlen(str)) return; push_mark (); variable cs = setup_case_search (str); ERROR_BLOCK { pop_mark (not_found); CASE_SEARCH = cs; } if ((dir > 0) and looking_at(str)) go_right_1 (); save_search_string (str); not_found = not (search_maybe_again (&search_across_lines, str, dir, line_ok_fun)); if (not_found) verror ("%s: not found.", str); EXECUTE_ERROR_BLOCK; } define search_forward () { search_generic_search ("Search forward:", 1, &_function_return_1); } define search_backward () { search_generic_search ("Search backward:", -1, &_function_return_1); } define replace_do_replace (str, len) { replace_chars (len, str); % returns strlen (str) #iffalse push_mark (); go_right(len); del_region (); insert (str); strlen (str); #endif } define search_search_function (pat) { variable cs = setup_case_search (pat); EXIT_BLOCK { CASE_SEARCH = cs; } variable len = strlen (pat); if (search_across_lines (pat, 1) > 0) return len; return -1; } define replace_cmd () { variable pat, prompt, rep; variable has_prefix; pat = read_mini("Replace:", Null_String, Null_String); !if (strlen (pat)) return; prompt = strcat (strcat ("Replace '", pat), "' with:"); rep = read_mini(prompt, "", ""); variable cs = setup_case_search (pat); ERROR_BLOCK { CASE_SEARCH = cs; } replace_with_query (&search_search_function, pat, rep, 1, &replace_do_replace); EXECUTE_ERROR_BLOCK; message ("done."); } provide ("search"); jed-0.99-19/lib/sort.sl0000644002657400265740000000222611311317447013571 0ustar davisdavisdefine sort_using_function (sort_fun) { variable end_line, n, index, i, beg, begc, endc, keys; check_region(0); endc = what_column(); end_line = what_line(); pop_mark_1 (); beg = what_line(); n = end_line - beg; ++n; %/* number of lines */ begc = what_column(); if (endc < begc) { endc; endc = begc; begc = (); } keys = String_Type [n]; % % extract keys and fill array % goto_line(beg); for (i = 0; i < n; ++i) { goto_column(begc); push_mark_eol(); if (what_column() > endc) goto_column(endc); keys[i] = bufsubstr(); go_down_1 (); } index = array_sort(keys, sort_fun); % % arrange region % goto_line (end_line); !if (down_1 ()) { eol(); newline(); } push_spot(); for(i = 0; i < n; ++i) { goto_line(index[i] + beg); line_as_string (); % on stack-- also we are at eol now pop_spot(); bol(); insert(()); newline(); push_spot(); } pop_spot(); goto_line(beg); bol(); push_mark(); goto_line(end_line + 1); bol(); del_region(); } define sort () { sort_using_function (&strcmp); %flush("Done."); } jed-0.99-19/lib/cua.sl0000644002657400265740000001710711311317447013356 0ustar davisdavis%% CUA (Windows/Mac/CDE/KDE-like) bindings for Jed. %% %% Reuben Thomas (rrt@sc3d.org) %% modified by Guenter Milde %% %% Versions: %% 1 first version by Guenter Milde %% 1.1 05/2003 triple (optional single) ESC-keypress aborts functions %% fixed missing definition of Key_Ins %% Key_Ctrl_Del calls cua_delete_word (was delete_word) %% F3 bound to repeat_search (tip by Guido Gonzato) %% removed definitions for F4...F10 (cua-compatible suggestions?) %% ^Q exits without asking for confirmation %% %% USAGE: %% %% put somewhere in your path and uncomment the line %% % () = evalfile ("cua"); % CUA-like key bindings %% in your .jedrc/jed.rc file %% %% ESC-problem: unfortunately, some function keys return "\e\e" %% as keystring. To have a single ESC-press aborting, insert %% autoload("cua_one_press_escape", "cuamisc"); %% cua_one_press_escape(); %% into your .jedrc. !! Attention, except for xjed, this is an experimental %% feature that can cause problems with functions that use getkey(), %% (e.g. showkey(), wmark.sl (before jed 99.16), ...) %% %% Enhancements (optional helper modes from http://jedmodes.sf.net/): %% cuamouse.sl: cua-like mouse bindings %% cuamark.sl: cua-like marking/copy/paste using yp_yank.sl (a ring of %% kill-buffers) %% numbuf.sl: fast switch between buffers via ALT + Number %% print.sl: printing %% ch_table.sl: popup_buffer with character table (special chars) % --- Requirements ------------------------------------------------------ require("cuamisc"); % "Outsourced" helper functions require("keydefs"); % Key definitions for Unix and DOS/Windos if(strlen(expand_jedlib_file("cuamark.sl"))) % non standard mode require("cuamark"); else require("wmark"); % cua-like marking, standard version require("recent"); % save a list of recent files % --- Variables -------------------------------------------------------- set_status_line(" %b mode: %m %n (%p) %t ", 1); menu_set_menu_bar_prefix ("Global", " "); Help_File = "cua.hlp"; %--- Keybindings -------------------------------------------------------- % This key will be used by the extension modes (e.g. c_mode.sl) to bind % additional functions to _Reserved_Key_Prefix = "^E"; % Extended functionality :-) % ESC (unfortunately, some special keys return "\e\e") % see USAGE at top for workaround setkey ("cua_escape_cmd", "\e\e\e"); % Triple-Esc -> abort definekey ("exit_menubar", "\e\e\e", "menu"); % close menus % Function keys setkey("menu_select_menu(\"Global.&Help\")", Key_F1); %setkey("context_help", Key_Shift_F1); % with hyperhelp mode setkey("cua_save_buffer", Key_F2); setkey("write_buffer", Key_Shift_F2); % save as setkey("repeat_search", Key_F3); % setkey("menu_select_menu(\"Global.&Search\")", Key_F3); % open Search menu % The "named" keys setkey("backward_delete_char_untabify", Key_BS); setkey("delete_char_cmd", Key_Del); setkey("toggle_overwrite", Key_Ins); setkey("beg_of_line", Key_Home); setkey("eol_cmd", Key_End); setkey("page_up", Key_PgUp); setkey("page_down", Key_PgDn); setkey("cua_bdelete_word", Key_Ctrl_BS); setkey("cua_delete_word", Key_Ctrl_Del); setkey("beg_of_buffer", Key_Ctrl_Home); setkey("eob; recenter(window_info('r'));", Key_Ctrl_End); setkey("bskip_word", Key_Ctrl_Left); setkey("skip_word", Key_Ctrl_Right); setkey("forward_paragraph", Key_Ctrl_Up); setkey("backward_paragraph", Key_Ctrl_Down); %setkey("pop_mark(0)", Key_Ctrl_Up); %setkey("push_mark", Key_Ctrl_Down); % define region % The Control Chars unset_ctrl_keys(); % unset to get a clear start #ifdef UNIX enable_flow_control(0); %turns off ^S/^Q processing (Unix only) #endif setkey("mark_buffer", "^A"); % mark All %setkey("dabbrev", "^A"); % abbreviation expansion %setkey("format_paragraph", "^B"); % (ide default) setkey("smart_set_mark_cmd", "^B"); % Begin region setkey("yp_copy_region_as_kill","^C"); % Copy (cua default) set_abort_char(0x04); % "logout" % ^E == _Reserved_Key_Prefix Extra functionality % ^F map: Find setkey("search_backward", "^FB"); setkey("isearch_backward", "^F^B"); setkey("toggle_case_search", "^FC"); setkey("re_search_forward", "^FE"); % rEgexp search setkey("search_forward", "^FF"); setkey("isearch_forward", "^F^F"); setkey("re_search_backward", "^FG"); setkey("isearch_forward", "^FI"); % Incremental search setkey("occur", "^FO"); % find all Occurences setkey("query_replace_match", "^FP"); % regexp rePlace setkey("replace_cmd", "^FR"); setkey("goto_line_cmd", "^G"); % Goto line % set_abort_char(''); % Jed Default, now on ^D % ^H map: Help ... setkey("apropos", "^HA"); setkey("describe_function", "^HF"); setkey("help", "^HH"); setkey("info_reader", "^HI"); setkey("showkey", "^HK"); setkey("describe_mode", "^HM"); setkey ("unix_man", "^HU"); setkey("describe_variable", "^HV"); setkey("where_is", "^HW"); setkey("select_menubar", "^H?"); setkey("indent_region_or_line", "^I"); % Key_Tab: indent_line % setkey("self_insert_cmd", "^I"); % setkey("", "^J"); % Free! setkey("del_eol", "^K"); % Kill line setkey("cua_repeat_search", "^L"); % ^M = Key_Return setkey("next_buffer", "^N"); % Next buffer setkey("find_file", "^O"); % Open file (cua default) %setkey ("print_buffer", "^P"); % Print (with print.sl) %setkey("exit_with_query", "^Q"); % Quit (ask for confirmation) setkey("exit_jed", "^Q"); % Quit (without asking) % ^R: Rectangles setkey("copy_rect", "^RC"); setkey("insert_rect", "^RV"); setkey("kill_rect", "^RX"); % delete and copy to rect-buffer setkey("open_rect", "^R "); % ^R Space: insert whitespace setkey("blank_rect", "^RY"); % delete (replace with spaces) setkey("blank_rect", "^R" + Key_Del); setkey("cua_save_buffer", "^S"); % Save %setkey("transpose_chars", "^T"); % ^T % still free setkey("yp_yank", "^V"); % insert/paste setkey("delbuf(whatbuf)", "^W"); setkey("yp_kill_region", "^X"); % cut setkey("redo", "^Y"); setkey("undo", "^Z"); runhooks ("keybindings_hook", "cua"); % eventual modifications % --- menu additions -------------------------------------------------- private define cua_load_popup_hook (menubar) { menu_delete_item ("Global.&File.&Close"); menu_insert_item("&Save", "Global.&File", "&Close", "delbuf(whatbuf)"); if(strlen(expand_jedlib_file("print.sl"))) % non standard mode { menu_insert_item("Canc&el Operation", "Global.&File", "&Print", "print_buffer"); menu_insert_separator("Canc&el Operation", "Global.&File"); } menu_insert_item (3, "Global.&Search", "&Incremental Search Forward", "isearch_forward"); menu_insert_item (4, "Global.&Search", "I&ncremental Search Backward", "isearch_backward"); menu_insert_item ("&Replace", "Global.&Search", "Toggle &Case Search", "toggle_case_search"); menu_insert_separator ("&Replace", "Global.&Search"); } append_to_hook ("load_popup_hooks", &cua_load_popup_hook); % signal the success in loading the cua emulation: _Jed_Emulation = "cua"; jed-0.99-19/lib/os.sl0000644002657400265740000001034611311317447013225 0ustar davisdavis% This file should not be byte-compiled. % It is loaded from site.sl and permits various flavors of jed to share the % same set of S-Lang files. Much of it is written in RPN for efficiency. #ifdef SUBPROCESSES autoload ("aprocess_stringify_status", "aprocess"); #endif #ifdef XWINDOWS autoload ("_jed_run_program_hook", "runpgm"); #endif #ifdef WIN32 autoload ("_win32_get_helper_app_name", "runpgm"); # ifexists set_import_module_path $1 = path_concat (JED_ROOT, "slsh"); set_slang_load_path (strcat (get_slang_load_path (), char(path_get_delimiter()), $1)); % set the library path for modules. set_import_module_path(path_concat($1, "modules")); # endif #endif #ifndef OS2 UNIX WIN32 autoload ("run_shell_cmd", "shell"); #endif #ifdef MSWINDOWS XWINDOWS MOUSE #ifnexists x_insert_selection define x_insert_selection () {x_insert_cutbuffer();} define x_copy_region_to_selection () {x_copy_region_to_cutbuffer();} #endif . "mouse" evalfile pop #endif #ifdef WINGUI . 1 =Simulate_Graphic_Chars . 4 2 mouse_map_buttons % map Right to Middle . 2 4 mouse_map_buttons % map Middle to Right %. "menus" evalfile pop % Uncomment to enable text menus . "wmenu.sl" evalfile pop % Uncomment to enable GUI menus #else # ifexists menu_create_menu_bar . "menus" evalfile pop # endif #endif #ifnexists menu_create_menu_bar define menu_create_menu_bar () { _pop_n (_NARGS); } define menu_append_item () { _pop_n (_NARGS); } define menu_append_separator () { _pop_n (_NARGS); } define menu_append_popup () { _pop_n (_NARGS); } define menu_use_menu_bar () { _pop_n (_NARGS); } #endif #ifnexists enable_menu_keys define enable_menu_keys (); #endif #ifdef XWINDOWS . "HOST" getenv =$1 % . $1 NULL != { "XJed@" $1 strcat x_set_window_name } if . "skip_word" "\e[c" setkey %/* shift-right */ . "bskip_word" "\e[d" setkey %/* shift-left */ . "goto_top_of_window" "\e[a" setkey %/* shift-up */ . "goto_bottom_of_window" "\e[b" setkey %/* shift-down */ . "beg_of_line" "\e[1~" setkey % Home . "eol_cmd" "\e[4~" setkey % End . 0xFFFF '$' "\e[3$" x_set_keysym % Key_Shift_Del . 0xFFFF '^' "\e[3^" x_set_keysym % Key_Ctrl_Del . 0xFF08 '$' "\e[16$" x_set_keysym % Key_Shift_BS . 0xFF08 '^' "\e[16^" x_set_keysym % Key_Ctrl_BS . 0xFF09 '$' "\e[Z" x_set_keysym % Key_Shift_Tab (reverse tab) #endif % For compatability define shell_cmd () { () = run_shell_cmd (); } define goto_visible_eol () { #ifdef HAS_LINE_ATTR if (down_1 ()) { if (is_line_hidden ()) skip_hidden_lines_forward (1); go_left_1 (); } #endif eol (); } define mark_to_visible_eol () { push_mark (); goto_visible_eol (); } define transpose_lines () { bol (); push_mark (); #ifdef HAS_LINE_ATTR mark_to_visible_eol (); bufsubstr (); % on stack go_right_1 (); del_region(); skip_hidden_lines_backward (1); bol(); insert(()); newline(); skip_hidden_lines_forward (1); % goes to bol #else line_as_string (); % on stack go_right_1 (); del_region(); go_up_1 (); bol(); insert(()); newline(); go_down_1 (); % goes to bol #endif } #ifdef HAS_LINE_ATTR autoload ("folding_mode", "folding"); add_completion ("folding_mode"); variable Fold_Mode_Ok = 0; define fold_mode () { if (Fold_Mode_Ok) folding_mode (); } #endif #ifdef HAS_DFA_SYNTAX define dfa_enable_highlight_cache (file, name) { variable dirfile = search_path_for_file (Jed_Highlight_Cache_Path, file, ','); if (dirfile == NULL) dirfile = dircat (Jed_Highlight_Cache_Dir, file); _dfa_enable_highlight_cache (dirfile, name); } define use_syntax_table_hook (t) { variable x = mode_get_mode_info ("use_dfa_syntax"); if (x == NULL) x = 0; use_dfa_syntax (x); } #else % dummy functions that enable jed to work in mixed environments define dfa_enable_highlight_cache (x, y); define dfa_define_highlight_rule (x,y,z); define dfa_build_highlight_table (x); define dfa_set_init_callback (x,y); #endif #ifdef WIN32 MSDOS_Has_Long_File_Names = 1; variable W32shell_Perform_Globbing; #else # ifdef MSDOS # ifdef 16_BIT_SYSTEM MSDOS_Has_Long_File_Names = 0; # else $1 = getenv ("LFN"); if ($1 == NULL) $1 = "N"; MSDOS_Has_Long_File_Names = ("Y" == strup ($1)); # endif # endif #endif jed-0.99-19/lib/tmmode.sl0000644002657400265740000000400611311317447014065 0ustar davisdavis% This is a text-macro mode designed to edit text using user defined macros. % Create a syntax table. Basically \ is a quote and {} are matching delimiters. $1 = "tm"; create_syntax_table ($1); define_syntax ("#%+", "#%-", '%', $1); % Comment Syntax define_syntax ("#%", "", '%', $1); % Comment Syntax define_syntax ('\\', '\\', $1); % Quote character define_syntax ("{", "}", '(', $1); % nothing else matches define_syntax ("-+a-zA-Z_0-9#", 'w', $1); %define_syntax ('#', '#', $1); set_syntax_flags ($1, 8); () = define_keywords_n ($1, "#d#i#p#v", 2, 1); () = define_keywords_n ($1, "#p+#p-#s+#s-#v+#v-", 3, 1); define textmac_paragraph_separator () { bol (); if (looking_at ("#") or looking_at ("\\")) return 1; skip_white (); eolp (); } define textmac_wrap_hook () { push_spot (); EXIT_BLOCK { pop_spot (); } go_up_1 (); % at eol trim (); bol (); if (looking_at ("#% ")) { go_down_1 (); insert ("#% "); return; } if (looking_at_char ('#')) { eol (); !if (blooking_at ("\\")) { insert_single_space (); insert_char ('\\'); } } go_down_1 (); indent_line (); } private define in_verbatim () { variable m = create_user_mark (); EXIT_BLOCK { goto_user_mark (m); } !if (bol_bsearch ("#v+")) return 0; !if (bol_fsearch ("#v-")) return 1; return (create_user_mark () >= m); } define tm_insert_quote () { if (in_verbatim ()) { insert ("\""); return; } call ("text_smart_quote"); } $1 = "tm"; !if (keymap_p ($1)) make_keymap ($1); definekey ("tm_insert_quote", "\"", $1); define tm_mode () { no_mode (); % reset variable mode = "tm"; use_keymap (mode); set_mode (mode, 0x1 | 0x20); set_buffer_hook ("par_sep", "textmac_paragraph_separator"); set_buffer_hook ("wrap_hook", "textmac_wrap_hook"); use_syntax_table (mode); mode_set_mode_info (mode, "fold_info", "#%{{{\r#%}}}\r\r"); TAB = 0; run_mode_hooks ("tm_mode_hook"); } jed-0.99-19/lib/bufed.sl0000644002657400265740000001531111311317447013666 0ustar davisdavis% -*- SLang -*- bufed.sl % % Simple JED `bufed' mode by Mark Olesen % % Bufed is a simple buffer manager -- patterned somewhat after dired. % Provides easy, interactive switching, saving and killing of buffers. % % To invoke Bufed, do `M-x bufed'. % Or re-bind to the key sequence which is normally bound to the % `list_buffers' function `C-x C-b' (emacs) % % ------------------------------------------------------------------------ % TO USE THIS MODE: add the line % % autoload ("bufed", "bufed"); to ~/.jedrc % % and optionally re-bind to the `C-x C-b' (emacs) key sequence % % setkey ("bufed", "^X^B"); % ------------------------------------------------------------------------ variable Bufed_buf = "*BufferList*"; % as used by `list_buffers' (buf.sl) % save the buffer define bufed_savebuffer (buf) { variable file, dir, flags, ch, this_buf; ch = int (buf); if ((ch == 32) or (ch == '*')) return; % internal buffer or special this_buf = whatbuf (); (file,dir,,flags) = getbuf_info (buf); if (strlen (file) and (flags & 1)) % file assciated with it { setbuf (buf); ERROR_BLOCK { setbuf (this_buf); } () = write_buffer (dircat (dir, file)); } } % extract the buffer name associated with the current line % Note: The details of this routine will depend upon how buf.sl formats % the line. Currently, this looks like: % ----------- 0000 "*scratch*" /aluche/h1/davis/src/jed/lib/ define bufed_get () { variable buf; push_spot_bol (); EXIT_BLOCK { pop_spot (); } !if (ffind_char ('"')) return Null_String; go_right_1 (); push_mark (); !if (ffind_char ('"')) { pop_mark_1 (); return Null_String; } buf = bufsubstr (); !if (bufferp (buf)) buf = ""; return buf; } define list_buffers () { variable i, j, tmp, this, name, flags, flag_chars, skip; variable umask; variable name_col, dir_col, mode_col; name_col = 21; mode_col = 13; dir_col = 45; skip = 0; if (prefix_argument(-1) == -1) skip = 1; tmp = "*BufferList*"; this = whatbuf(); pop2buf(tmp); set_readonly(0); erase_buffer(); TAB = 8; flag_chars = "CBKN-UORDAM"; insert (" Flags"); goto_column (mode_col); insert ("umask"); goto_column (name_col); insert ("Buffer Name"); goto_column(dir_col); insert("Dir/File\n"); loop (buffer_list()) { name = (); if (skip and (int(name) == ' ')) continue; %% internal buffers begin with a space flags = getbuf_info (name); % more on stack umask = set_buffer_umask (-1); bol(); i = 0x400; j = 0; while (i) { if (flags & i) flag_chars[j]; else '-'; insert_char (()); i = i shr 1; j++; } goto_column (mode_col); vinsert ("0%03o", umask); goto_column (name_col); % Since the buffername may contain whitespace, enclose it in quotes insert_char ('"'); insert(()); %% buffer name insert_char ('"'); goto_column(dir_col); !if (eolp()) { eol(); insert_single_space(); } insert(()); insert(()); %% dir/file newline(); } insert("\nU:Undo O:Overwrite R:Readonly D:Disk File Changed, A:Autosave, M:Modified\n"); insert("C:CRmode, B:Binary File, K:Not backed up, N:No autosave"); bob (); set_buffer_modified_flag (0); set_readonly (1); pop2buf(this); } private variable Line_Mark; private define update_bufed_hook () { Line_Mark = create_line_mark (color_number ("menu_selection")); } define bufed_list () { Line_Mark = NULL; check_buffers (); list_buffers (); pop2buf (Bufed_buf); set_buffer_hook ("update_hook", &update_bufed_hook); set_readonly (0); bob(); insert ("Press '?' for help. Press ENTER to select a buffer.\n\n"); set_readonly (0); set_buffer_modified_flag(0); go_down (1); %goto_column (21); } % kill a buffer, if it has been modified then pop to it so it's obvious define bufed_kill () { variable file, dir, flags, buf = bufed_get (); variable line; !if (strlen (buf)) return; line = what_line (); (file,dir,,flags) = getbuf_info (buf); if (flags & 1) % modified { pop2buf (buf); update (1); } delbuf (buf); if (strcmp (buf, Bufed_buf)) bufed_list (); goto_line (line); } define bufed_save () { variable buf = bufed_get (); !if (int (buf)) return; bufed_savebuffer (buf); } % try to re-load the file from disk define bufed_update () { variable file, dir, flags; (file,dir,,flags) = getbuf_info (); if (flags & 2) % file on disk modified? { !if (find_file (dircat (dir, file))) error ("Error reading file"); } } define bufed_pop2buf () { variable buf = bufed_get (); !if (int (buf)) return; % if the buffer is already visible, scroll down buffer_visible (buf); % leave on the stack pop2buf (buf); if (() and not(eobp ())) call ("page_down"); bufed_update (); pop2buf (Bufed_buf); } define bufed_sw2buf (one) { variable buf = bufed_get (); !if (int (buf)) return; sw2buf (buf); bufed_update (); if (one) onewindow (); } define bufed_exit () { delbuf (whatbuf ()); } variable Bufed_help; Bufed_help = "k:kill, s:save, g:refresh, SPC,f:pop2buf, CR,TAB:sw2buf, q:quit, h:help, ?:this help"; define bufed_help () { message (Bufed_help); } $1 = "bufed"; !if (keymap_p ($1)) make_keymap ($1); definekey ("bufed_list", "g", $1); definekey ("describe_mode", "h", $1); definekey ("bufed_kill", "k", $1); definekey ("bufed_save", "s", $1); definekey ("bufed_pop2buf", "f", $1); definekey ("bufed_pop2buf", " ", $1); definekey (".0 bufed_sw2buf", "\r", $1); definekey (".1 bufed_sw2buf", "\t", $1); definekey ("bufed_exit", "q", $1); definekey ("bufed_help", "?", $1); % Also possible, % U toggle_undo % O toggle_overwrite % R toggle_readonly % C toggle_crmode %!%+ %\function{bufed} %\synopsis{bufed} %\description % Mode designed to aid in navigating through multiple buffers % patterned somewhat after dired. % % To invoke Bufed, do \var{M-x bufed} or bind to \var{C-x C-b} (emacs) % % \var{g} Update the buffer listing. % % \var{k} Kill the buffer described on the current line, like typing % \var{M-x kill_buffer} and supplying that buffer name. % % \var{s} Save the buffer described on the current line. % % \var{f}, \var{SPC}, \var{CR}, \var{TAB} % Visit the buffer described on the current line. % \var{f} and \var{SPC} will create a new window if required. % \var{CR} will use the current window. % \var{TAB} will revert to a single window. % % \var{Q} Quit bufed mode. %!%- define bufed () { variable mode = "bufed"; variable this_buf; this_buf = sprintf ("\"%s\"", whatbuf ()); bufed_list (); () = fsearch (this_buf); bufed_help (); use_keymap (mode); set_mode (mode, 0); run_mode_hooks ("bufed_hook"); } jed-0.99-19/lib/cua.hlp0000644002657400265740000000060111311317447013512 0ustar davisdavisBasic Commands in CUA mode: File: Region: Search/Replace: Edit: Emergency: ^Q exit ^C copy ^FF find forward ^A mark all ^H/F1 help ^O open ^X kill ^L/F3 find next ^B format paragraph ^Z undo ^S/F2 save ^V paste ^FE regexp search ^K kill line ^D abort ^P print ^FR replace ^J goto line jed-0.99-19/info/0000755002657400265740000000000011311317447012425 5ustar davisdavisjed-0.99-19/info/dir.info0000644002657400265740000000177311311317447014070 0ustar davisdavisThis is the file, dir, which contains the topmost node of the Info hierarchy. The first time you invoke Info you start off looking at that node, which is (dir)Top.  File: dir Node: Top This is the top of the INFO tree This (the Directory node) gives a menu of major topics. Typing "d" returns here, "q" exits, "?" lists all INFO commands, "h" gives a primer for first-timers, "mTexinfo" visits Texinfo topic, etc. --- PLEASE ADD DOCUMENTATION TO THIS TREE. (See INFO topic first.) --- * Menu: The list of major topics begins on the next line. * Info: (info). Documentation browsing system. (From GNU Emacs) * JED: (jed). JED editor documentation. * Latex: (latex). latex ------------------------------------------------------------------ The following info directories may not exist on all systems. ------------------------------------------------------------------ * /usr/info: (/usr/info/dir). Additional info topics. * /usr/local/info: (/usr/local/info/dir). Additional info topics. jed-0.99-19/info/jed.info0000644002657400265740000000304111311317447014042 0ustar davisdavisSTART-INFO-DIR-ENTRY * JED: (jed). The JED editor END-INFO-DIR-ENTRY  Indirect: jed.1in: 83 jed.2in: 24234 jed.3in: 49114  Tag Table: (Indirect) Node: Top83 Node: Introduction709 Node: Installing JED1313 Node: Startup Files3430 Node: Starting JED4438 Node: Emulating Other Editors6529 Node: Emacs Emulation7026 Node: EDT Emulation7590 Node: Wordstar Emulation9907 Node: File Types and Sizes10279 Node: Backup and Autosave Files10894 Node: Status line and Windows12656 Node: MiniBuffer13580 Node: Command Line Completion14501 Node: File Names16808 Node: Buffer Name and File Name Completion19290 Node: Basic Editing20155 Node: Undo21943 Node: Marking Text (Point and Mark)22967 Node: Tab Issues.24234 Node: Searching27481 Node: Rectangles29905 Node: Sorting30926 Node: Modes33018 Node: Wrap Mode33723 Node: Formatting paragraphs34040 Node: Smart Quotes35827 Node: C Mode36987 Node: Fortran Mode38152 Node: Keyboard Macros38869 Node: Shells and Shell Commands40843 Node: Getting Help42061 Node: Editing Binary Files42866 Node: Dired43608 Node: Mail45714 Node: Customization47963 Node: Setting Keys49114 Node: Predefined Variables52820 Node: Hooks54172 Node: S-Lang Programming Hints (Debugging)57163 Node: Eight Bit Clean Issues61244 Node: Displaying Characters with the High Bit Set61539 Node: Inputting Characters with the High Bit Set62645 Node: Upper Case - Lower Case Conversions64483 Node: Miscellaneous66739 Node: Abort Character66919 Node: Input Translation67632 Node: Display Sizes68904  End Tag Table jed-0.99-19/info/info.info0000644002657400265740000006521711311317447014250 0ustar davisdavisThis file documents the Info program. -*-Text-*- The H command of Info goes to the node Help in this file. I have borrowed it from the GNU emacs distribution.  File: info Node: Top Up: (DIR) Next: Expert Info is a program for reading documentation, which you are using now. To learn how to use Info, type the command "h". It will bring you to a programmed instruction sequence. * Menu: * Expert:: Advanced Info commands: g, s, e, and 1 - 5. * Add:: Describes how to add new nodes to the hierarchy. Also tells what nodes look like. * Menus:: How to add to or create menus in Info nodes. * Cross-refs:: How to add cross-references to Info nodes. * Tags:: How to make tag tables for Info files. * Checking:: How to check the consistency of an Info file. * Texinfo: (texinfo). How to generate an Info file and a printed manual from the same source file.  File: info Node: Help-Small-Screen Next: Help Since your terminal has an unusually small number of lines on its screen, it is necessary to give you special advice at the beginning. If you see the text "--All----" at near the bottom right corner of the screen, it means the entire text you are looking at fits on the screen. If you see "--Top----" instead, it means that there is more text below that does not fit. To move forward through the text and see another screen full, press the Space bar. To move back up, press the key labeled Rubout or Delete or DEL. Here are 40 lines of junk, so you can try Spaces and Rubout and see what they do. At the end are instructions of what you should do next. This is line 17 This is line 18 This is line 19 This is line 20 This is line 21 This is line 22 This is line 23 This is line 24 This is line 25 This is line 26 This is line 27 This is line 28 This is line 29 This is line 30 This is line 31 This is line 32 This is line 33 This is line 34 This is line 35 This is line 36 This is line 37 This is line 38 This is line 39 This is line 40 This is line 41 This is line 42 This is line 43 This is line 44 This is line 45 This is line 46 This is line 47 This is line 48 This is line 49 This is line 50 This is line 51 This is line 52 This is line 53 This is line 54 This is line 55 This is line 56 If you have managed to get here, go back to the beginning with Rubout, and come back here again, then you understand Space and Rubout. So now type an "n"--just one character; don't type the quotes and don't type a Return afterward-- to get to the normal start of the course.  File: info Node: Help Next: Help-P Previous: Help-Small-Screen You are talking to the program Info, for reading documentation. Right now you are looking at one "Node" of Information. A node contains text describing a specific topic at a specific level of detail. This node's topic is "how to use Info". The top line of a node is its "header". This node's header (look at it now) says that it is the node named "Help" in the file "info". It says that the Next node after this one is the node called "Help-P". An advanced Info command lets you go to any node whose name you know. Besides a "Next", a node can have a "Previous" or an "Up". This node has a "Previous" but no "Up", as you can see. Now it's time to move on to the Next node, named "Help-P". >> Type "n" to move there. Type just one character; don't type the quotes and don't type a Return afterward. ">>" in the margin means it is really time to try a command.  File: info Node: Help-P Next: Help-^L Previous: Help This node is called "Help-P". The "Previous" node, as you see, is "Help", which is the one you just came from using the "N" command. Another "N" command now would take you to the Next node, "Help-^L". >> But don't do that yet. First, try the "p" command, which takes you to the Previous node. When you get there, you can do an "n" again to return here. This all probably seems insultingly simple so far, but DON'T be led into skimming. Things will get more complicated soon. Also, don't try a new command until you are told it's time to. Otherwise, you may make Info skip past an important warning that was coming up. >> Now do an "n" to get to the node "Help-^L" and learn more.  File: info Node: Help-^L Next: Help-M Previous: Help-P Space, Rubout, B and ^L commands. This node's header tells you that you are now at node "Help-^L", and that "P" would get you back to "Help-P". The line starting "Space," is a "Title", saying what the node is about (most nodes have titles). This is a big node and it doesn't all fit on your display screen. You can tell that there is more that isn't visible because you can see the string "--Top-----" rather than "--All-----" near the bottom right corner of the screen. The Space, Rubout and B commands exist to allow you to "move around" in a node that doesn't all fit on the screen at once. Space moves forward, to show what was below the bottom of the screen. Rubout moves backward, to show what was above the top of the screen (there isn't anything above the top until you have typed some spaces). >> Now try typing a Space (afterward, type a Rubout to return here). When you type the space, the two lines that were at the bottom of the screen appear at the top, followed by more lines. Rubout takes the two lines from the top and moves them to the bottom, USUALLY, but if there are not a full screen's worth of lines above them they may not make it all the way to the bottom. If you type a Space when there is no more to see, it will ring the bell and otherwise do nothing. The same goes for a Rubout when the header of the node is visible. If your screen is ever garbaged, you can tell Info to print it out again by typing C-l (Control-L, that is--hold down "Control" and type an "L" or "l"). >> Type C-l now. To move back to the beginning of the node you are on, you can type a lot of Rubouts. You can also type simply "b" for beginning. >> Try that now. (I have put in enough verbiage to make sure you are not on the first screenful now). Then come back, with Spaces. You have just learned a considerable number of commands. If you want to use one but have trouble remembering which, you should type a "?" which will print out a brief list of commands. When you are finished looking at the list, make it go away by typing a Space. >> Type a "?" now. After it finishes, type a Space. From now on, you will encounter large nodes without warning, and will be expected to know how to use Space and Rubout to move around in them without being told. Since not all terminals have the same size screen, it would be impossible to warn you anyway. >> Now type "n" to see the description of the "m" command.  File: info Node: Help-M Next: Help-Adv Previous: Help-^L Menus and the "m" command With only the "n" and "p" commands for moving between nodes, nodes are restricted to a linear sequence. Menus allow a branching structure. A menu is a list of other nodes you can move to. It is actually just part of the text of the node formatted specially so that Info can interpret it. The beginning of a menu is always identified by a line which starts with "* Menu:". A node contains a menu if and only if it has a line in it which starts that way. The only menu you can use at any moment is the one in the node you are in. To use a menu in any other node, you must move to that node first. After the start of the menu, each line that starts with a "*" identifies one subtopic. The line will usually contain a brief name for the subtopic (followed by a ":"), the name of the node that talks about that subtopic, and optionally some further description of the subtopic. Lines in the menu that don't start with a "*" have no special meaning - they are only for the human reader's benefit and do not define additional subtopics. Here is an example: * Foo: FOO's Node This tells about FOO The subtopic name is Foo, and the node describing it is "FOO's Node". The rest of the line is just for the reader's Information. [[ But this line is not a real menu item, simply because there is no line above it which starts with "* Menu:".]] When you use a menu to go to another node (in a way that will be described soon), what you specify is the subtopic name, the first thing in the menu line. Info uses it to find the menu line, extracts the node name from it, and goes to that node. The reason that there is both a subtopic name and a node name is that the node name must be meaningful to the computer and may therefore have to be ugly looking. The subtopic name can be chosen just to be convenient for the user to specify. Often the node name is convenient for the user to specify and so both it and the subtopic name are the same. There is an abbreviation for this: * Foo:: This tells about FOO This means that the subtopic name and node name are the same; they are both "Foo". >> Now use Spaces to find the menu in this node, then come back to the front with a "b". As you see, a menu is actually visible in its node. If you can't find a menu in a node by looking at it, then the node doesn't have a menu and the "m" command is not available. The command to go to one of the subnodes is "m" - but DON'T DO IT YET! Before you use "m", you must understand the difference between commands and arguments. So far, you have learned several commands that do not need arguments. When you type one, Info processes it and is instantly ready for another command. The "m" command is different: it is incomplete without the NAME OF THE SUBTOPIC. Once you have typed "m", Info tries to read the subtopic name. Now look for the line containing many dashes near the bottom of the screen. There is one more line beneath that one, but usually it is blank If it is empty, Info is ready for a command, such as "n" or "b" or Space or "m". If that line contains text ending in a colon, it mean Info is trying to read the ARGUMENT to a command. At such times, commands won't work, because Info will try to use them as the argument. You must either type the argument and finish the command you started, or type Control-g to cancel the command. When you have done one of those things, the line will become blank again. The command to go to a subnode via a menu is "m". After you type the "m", the line at the bottom of the screen says "Menu item: ". You must then type the name of tye subtopic you want, and end it with a Return. You can abbreviate the subtopic name. If the abbreviation is not unique, the first matching subtopic is chosen. Some menus will put the shortest possible abbreviation for each subtopic name in capital letters, so you can see how much you need to type. It does not matter whether you use upper case or lower case when you type the subtopic. You should not put any spaces at the end, or inside of the item name, except for one space where a space appears in the item in the menu. Here is a menu to give you a chance to practice. * Menu: The menu starts here. This menu givs you three ways of going to one place, Help-FOO. * Foo: Help-FOO A node you can visit for fun * Bar: Help-FOO Strange! two ways to get to the same place. * Help-FOO:: And yet another! >> Now type just an "m" and see what happens: Now you are "inside" an "m" command. Commands can't be used now; the next thing you will type must be the name of a subtopic. You can change your mind about doing the "m" by typing Control-g. >> Try that now; notice the bottom line clear. >> Then type another "m". >> Now type "BAR", the item name. Don't type Return yet. While you are typing the item name, you can use the Rubout character to cancel one character at a time if you make a mistake. >> Type one to cancel the "R". You could type another "R" to replace it. You don't have to, since "BA" is a valid abbreviation. >> Now you are ready to go. Type a Return. After visiting Help-FOO, you should return here. >> Type "n" to see more commands.  File: info Node: Help-FOO Up: Help-M The "u" command Congratulations! This is the node Help-FOO. Unlike the other nodes you have seen, this one has an "Up": "Help-M", the node you just came from via the "m" command. This is the usual convention-- the nodes you reach from a menu have Ups that lead back to the menu. Menus move Down in the tree, and Up moves Up. Previous, on the other hand, is usually used to "stay on the same level but go backwards". You can go back to the node Help-M by typing the command "u" for "Up". That will put you at the FRONT of the node - to get back to where you were reading you will have to type some Spaces. >> Now type "u" to move back up to Help-M.  File: info Node: Help-Adv Next: Help-Q Previous: Help-M Some advanced Info commands The course is almost over, so please stick with it to the end. If you have been moving around to different nodes and wish to retrace your steps, the "l" command ("l" for "last") will do that, one node at a time. If you have been following directions, an "l" command now will get you back to Help-M. Another "l" command would undo the "u" and get you back to Help-FOO. Another "l" would undo the M and get you back to Help-M. >> Try typing three "l"'s, pausing in between to see what each "l" does. Then follow directions again and you will end up back here. Note the difference between "l" and "p": "l" moves to where YOU last were, whereas "p" always moves to the node which the header says is the "Previous" node (from this node, to Help-M). The "d" command gets you instantly to the Directory node. This node, which is the first one you saw when you entered Info, has a menu which leads (directly, or indirectly through other menus), to all the nodes that exist. >> Try doing a "d", then do an "l" to return here (yes, DO return). Sometimes, in Info documentation, you will see a cross reference. Cross references look like this: *Note Cross: Help-Cross. That is a real, live cross reference which is named "Cross" and points at the node named "Help-Cross". If you wish to follow a cross reference, you must use the "f" command. The "f" must be followed by the cross reference name (in this case, "Cross"). You can use Rubout to edit the name, and if you change your mind about following any reference you can use Control-g to cancel the command. Completion is available in the "f" command; you can complete among all the cross reference names in the current node. >> Type "f", followed by "Cross", and a Return. To get a list of all the cross references in the current node, you can type "?" after an "f". The "f" continues to await a cross reference name even after printing the list, so if you don't actually want to follow a reference you should type a Control-g to cancel the "f". >> Type "f?" to get a list of the footnotes in this node. Then type a Control-g and see how the "f" gives up. >> Now type "n" to see the last node of the course.  File: info Node: Help-Cross This is the node reached by the cross reference named "Cross". While this node is specifically intended to be reached by a cross reference, most cross references lead to nodes that "belong" someplace else far away in the structure of Info. So you can't expect the footnote to have a Next, Previous or Up pointing back to where you came from. In general, the "l" (el) command is the only way to get back there. >> Type "l" to return to the node where the cross reference was.  File: info Node: Help-Q Previous: Help-Adv Up: Top To get out of Info, back to what you were doing before, type "q" for "Quit". This is the end of the course on using Info. There are some other commands that are not essential or meant for experienced users; they are useful, and you can find them by looking in the directory for documentation on Info. Finding them will be a good exercise in using Info in the usual manner. >> Type "d" to go to the Info directory node; then type "mInfo" and Return, to get to the node about Info and see what other help is available.  File: info, Node: Expert, Up: Top, Previous: Top, Next: Add Some Advanced Info Commands ("g", "s", "1" - "5", and "e"). If you know a node's name, you can go there by typing "g", the name, and Return. Thus, "gTop" would go to the node called Top in this file (its directory node). "gExpert" would come back here. Unlike "m", "g" does not allow the use of abbreviations. To go to a node in another file, you can include the filename in the node name by putting it at the front, in parentheses. Thus, "g(dir)Top" would go to the Info Directory node, which is node Top in the file dir. The node name "*" specifies the whole file. So you can look at all of the current file by typing "g*" or all of any other file with "g(FILENAME)". The "s" command allows you to search a whole file for a string. It will switch to the next node if and when that is necessary. You type "s" followed by the string to search for, terminated by Return. To search for the same string again, just "s" followed by Return will do. The file's nodes will be scanned in the order they are in in the file, which has no necessary relationship to the order that they may be in in the tree structure of menus and next's. But normally the two orders will not be far different. In any case, you can always do a "b" to find out what node you have reached, if the header isn't visible (this can happen, because "S" puts your cursor at the occurrence of the string, not at the beginning of the node). If you grudge the system each character of type-in it requires, you might like to use the commands "1", "2", "3", "4", and "5". They are short for the "m" command together with an argument. "1" goes through the first item in the current node's menu; "2" goes through the second item, etc. Note that numbers larger than 5 are not allowed. If the item you want is that far down, you are better off using an abbreviation for its name than counting. The Info command "e" changes from Info mode to an ordinary Emacs editing mode, so that you can edit the text of the current node. Type C-c C-c to switch back to Info. The "e" command is allowed only if the variable Info-enable-edit is non-nil.  File: info, Node: Add, Up: Top, Previous: Expert, Next: Menus To add a new topic to the list in the directory, you must 1) create a node, in some file, to document that topic. 2) put that topic in the menu in the directory. *Note Menu: Menus. The new node can live in an existing documentation file, or in a new one. It must have a ^_ character before it (invisible to the user; this node has one but you can't see it), and it ends with either a ^_, a ^L, or the end of file. Note: If you put in a ^L to end a new node, be sure that there is a ^_ after it to start the next one, since ^L can't START a node. Also, a nicer way to make a node boundary be a page boundary as well is to put a ^L RIGHT AFTER the ^_. The ^_ starting a node must be followed by a newline or a ^L newline, after which comes the node's header line. The header line must give the node's name (by which Info will find it), and state the names of the Next, Previous, and Up nodes (if there are any). As you can see, this node's Up node is the node Top, which points at all the documentation for Info. The Next node is "Menus". The keywords "Node", "Previous", "Up" and "Next", may appear in any order, anywhere in the header line, but the recommended order is the one in this sentence. Each keyword must be followed by a colon, spaces and tabs, and then the appropriate name. The name may be terminated with a tab, a comma, or a newline. A space does not end it; node names may contain spaces. The case of letters in the names is insignificant. A node name has two forms. A node in the current file is named by what appears after the "Node: " in that node's first line. For example, this node's name is "Add". A node in another file is named by "(FILENAME)NODE-WITHIN-FILE", as in "(info)Add" for this node. If the file name is relative, it is taken starting from the standard Info file directory of your site. The name "(FILENAME)Top" can be abbreviated to just "(FILENAME)". By convention, the name "Top" is used for the "highest" node in any single file - the node whose "Up" points out of the file. The Directory node is "(dir)". The Top node of a document file listed in the Directory should have an "Up: (dir)" in it. The node name "*" is special: it refers to the entire file. Thus, g* will show you the whole current file. The use of the node * is to make it possible to make old-fashioned, unstructured files into nodes of the tree. The "Node:" name, in which a node states its own name, must not contain a filename, since Info when searching for a node does not expect one to be there. The Next, Previous and Up names may contain them. In this node, since the Up node is in the same file, it was not necessary to use one. Note that the nodes in this file have a File name in the header line. The File names are ignored by Info, but they serve as comments to help identify the node for the user.  File: info, Node: Menus, Previous: Add, Up: Top, Next: Cross-refs How to Create Menus: Any node in the Info hierarchy may have a MENU--a list of subnodes. The "m" command searches the current node's menu for the topic which it reads from the terminal. A menu begins with a line starting with "* Menu:". The rest of the line is a comment. After the starting line, every line that begins with a "* " lists a single topic. The name of the topic--the arg that the user must give to the "m" command to select this topic-- comes right after the star and space, and is followed by a colon, spaces and tabs, and the name of the node which discusses that topic. The node name, like node names following Next, Previous and Up, may be terminated with a tab, comma, or newline; it may also be terminated with a period. If the node name and topic name are the same, than rather than giving the name twice, the abbreviation "* NAME::" may be used (and should be used, whenever possible, as it reduces the visual clutter in the menu). It is considerate to choose the topic names so that they differ from each other very near the beginning--this allows the user to type short abbreviations. In a long menu, it is a good idea to capitalize the beginning of each item name which is the minimum acceptable abbreviation for it (a long menu is more than 5 or so entries). The node's listed in a node's menu are called its "subnodes", and it is their "superior". They should each have an "Up:" pointing at the superior. It is often useful to arrange all or most of the subnodes in a sequence of Next's/Previous's so that someone who wants to see them all need not keep revisiting the Menu. The Info Directory is simply the menu of the node "(dir)Top"--that is, node Top in file .../info/dir. You can put new entries in that menu just like any other menu. The Info Directory is NOT the same as the file directory called "info". It happens that many of Info's files live on that file directory, but they don't have to; and files on that directory are not automatically listed in the Info Directory node. Also, although the Info node graph is claimed to be a "hierarchy", in fact it can be ANY directed graph. Shared structures and pointer cycles are perfectly possible, and can be used if they are appropriate to the meaning to be expressed. There is no need for all the nodes in a file to form a connected structure. In fact, this file has two connected components. You are in one of them, which is under the node Top; the other contains the node Help which the "h" command goes to. In fact, since there is no garbage collector, nothing terrible happens if a substructure is not pointed to, but such a substructure will be rather useless since nobody will ever find out that it exists.  File: info, Node: Cross-refs, Previous: Menus, Up: Top, Next: Tags Creating Cross References: A cross reference can be placed anywhere in the text, unlike a menu item which must go at the front of a line. A cross reference looks like a menu item except that it has "*note" instead of "*". It CANNOT be terminated by a ")", because ")"'s are so often part of node names. If you wish to enclose a cross reference in parentheses, terminate it with a period first. Here are two examples of cross references pointers: *Note details: commands. (See *note 3: Full Proof.) They are just examples. The places they "lead to" don't really exist!  File: info, Node: Tags, Previous: Cross-refs, Up: Top, Next: Checking Tag Tables for Info Files: You can speed up the access to nodes of a large Info file by giving it a tag table. Unlike the tag table for a program, the tag table for an Info file lives inside the file itself and will automatically be used whenever Info reads in the file. To make a tag table, go to a node in the file using Info and type M-x Info-tagify. Then you must use C-x C-s to save the file. Once the Info file has a tag table, you must make certain it is up to date. If, as a result of deletion of text, any node moves back more than a thousand characters in the file from the position recorded in the tag table, Info will no longer be able to find that node. To update the tag table, use the Info-tagify command again. An Info file tag table appears at the end of the file and looks like this: ^_ Tag Table: File: info, Node: Cross-refs21419 File: info, Node: Tags22145 ^_ End Tag Table Note that it contains one line per node, and this line contains the beginning of the node's header (ending just after the node name), a rubout character, and the character position in the file of the beginning of the node.  File: info, Node: Checking, Previous: Tags, Up: Top Checking an Info File: When creating an Info file, it is easy to forget the name of a node when you are making a pointer to it from another node. If you put in the wrong name for a node, this will not be detected until someone tries to go through the pointer using Info. Verification of the Info file is an automatic process which checks all pointers to nodes and reports any pointers which are invalid. Every Next, Previous, and Up is checked, as is every menu item and every cross reference. In addition, any Next which doesn't have a Previous pointing back is reported. Only pointers within the file are checked, because checking pointers to other files would be terribly slow. But those are usually few. To check an Info file, do M-x Info-validate while looking at any node of the file with Info.  Tag table: File: info, Tad :able: File: info, eoden ChecNing2T7g6Fil7: iifo, Node: Tags245s9-Fele:2i9f6, Nlde: Cfoss-refs23926 File: info, Node: Menus21121 File: info, Node: Add18186 File: info, Node: Expert15972 File: info Node: Help-Q15421 File: info Node: Help-Cross14907 File: info Node: Help-Adv12631 File: info Node: Help-FOO11930 File: info Node: Help-M6648L4141 File: info Node: Help-P3393 File: info Node: Help2444 File: info Node: Help-Small-Screen816 File: info Node: Top111  End tag table jed-0.99-19/info/jed.3in0000644002657400265740000005003111311317447013601 0ustar davisdavis File: jed.info, Node: Setting Keys, Next: Predefined Variables, Up: Customization Setting Keys ------------ Defining a key to invoke a certain function is accomplished using the `setkey' function. This function takes two arguments: the function to be executed and the key binding. For example, suppose that you want to bind the key  to cause the cursor to go to the beginning of the current line. The JED function that causes this is `bol' (See the JED Programmer's Manual for a complete list of functions). Putting the line: "bol" "^A" setkey in the startup file `jed.rc' (`.jedrc') file will perform the binding. Here `^A' consists of the two characters `^' and `A' which JED will interpret as the single character `Ctrl-A'. For more examples, see either of the S-Lang files `emacs.sl' or `edt.sl'. In addition to being able to define keys to execute functions, it is also possible to define a key to directly insert a string of characters. For example, suppose that you want to define a key to insert the string `int main(int argc, char **argv)' whenever you press the key `ESC m'. This may be accomplished as follows: " int main(int argc, char **argv)" "\em" setkey Notice two things. First of all, the key sequence `ESC m' has been written as `"\em"' where `\e' will be interpreted by JED as ESC. The other salient feature is that the first argument to `setkey', the "function" argument, begins with a space. This tells JED that it is not be be interpreted as the name of a function; rather, the characters following the space are to be inserted into the buffer. Omitting the space character would cause JED to to execute a function called `int main(int argc, char **argv)' which would fail and generate an error. Finally, it is possible to define a key to execute a series of keystrokes similar to a keyboard macro. This is done by prefixing the "function" name with the `@' character. This instructs JED to interpret the characters following the `@' character as characters entered from the keyboard and execute any function that they are bound to. For example, consider the following key definition which will generate a C language comment to comment out the the current line of text. In C, this may be achieved by inserting symbol `"/*"' at the beginning of the line and inserting `"*/"' at the end of the line. Hence, the sequence is clear (Emacs keybindings): 1. Goto the beginning of the line:  or decimal `"\001"'. 2. Insert `"/*"'. 3. Goto end of the line:  or decimal `"\005"' 4. Insert `"*/"'. To bind this sequence of steps to the key sequence `ESC ;', simply use "@\001/*\005*/" "\e;" setkey Again, the prefix `@' lets JED know that the remaining characters will carry out the functions they are currently bound to. Also pay particular attention to the way  and  have been written. Do not attempt to use the ^ to represet "control". It does not have the same meaning in the first argument to the `setkey' function as it does in the second argument. To have control characters in the first argument, you must enter them as `\xyz' where xyz is a three digit decimal number coinciding with the ASCII value of the character. In this notation, the ESC character could have been written as `\027'. See the S-Lang Programmer's Reference Manual for further discussion of this notation. The `setkey' function sets a key in the `global' keymap from which all others are derived. It is also possible to use the function `local_setkey' which operates only upon the current keymap which may or may not be the `global' map.  File: jed.info, Node: Predefined Variables, Next: Hooks, Prev: Setting Keys, Up: Customization Predefined Variables -------------------- JED includes some predefined variables which the user may change. By convention, predefined variables are in uppercase. The variables which effect all modes include: `BLINK' (1) if non-zero, blink matching parenthesis. `TAB_DEFAULT' (8) sets default tab setting for newly created buffers to specified number of columns. `TAB' Value of tab setting for current buffer. `ADD_NEWLINE' (1) adds newline to end of file if needed when writing it out to the disk. `META_CHAR' (-1) prefix for chars with high bit set (see section on eight bit clean issues for details) `DISPLAY_EIGHT_BIT' see section on eight bit clean issues. `COLOR' (23) IBMPC background color (see `jed.rc' for meaning) `LINENUMBERS' (0) if 1, show current line number on status line `WANT_EOB' (0) if 1, [EOB] denotes end of buffer. `TERM_CANNOT_INSERT' (0) if 1, do not put the terminal in insert mode when writing to the screen. `IGNORE_BEEP' (0) do not beep the terminal when signalling errors In addition to the above, there are variables which affect only certain modes. See the section on modes for details.  File: jed.info, Node: Hooks, Next: S-Lang Programming Hints (Debugging), Prev: Predefined Variables, Up: Customization Hooks ----- A hook is a user defined function that JED calls under certain conditions which allow the user to modify default actions. For example, when JED starts up it looks for the existence of a user defined function `command_line_hook'. If this function exists, JED calls the function. What the function does is completely arbitrary and is left to the discretion of the user. The startup file, `site.sl', defines such a function which reads in the files listed on the command line. It is also this function which loads the `jed.rc' startup file. Unlike the other hooks, this one must be present in the file `site.sl' since it is the only file loaded before calling the hook. After the startup files are loaded, JED calls the hook `jed_startup_hook' immediately before entering the main editor loop. This hook is useful to modify certain data structures which may not have existed when the startup files were loaded. In addition to the above hooks, JED currently also looks for: `suspend_hook' function to be executed before suspending `resume_hook' function that gets carried out after suspension `exit_hook' gets executed before exiting JED `mode_hook' sets buffer mode based on filename extension `find_file_hook' called before file is read into a buffer. It currently checks for presence of autosave file and warns user if it is more recent than file. See `site.sl' for explicit examples of the above hooks. Another useful hook is `is_paragraph_separator'. This hook is called when JED searches for the beginning or end of a paragraph. This search is performed by all paragraph formatting functions as well as the forward and backward paragraph movement commands. As JED performs the search, it moves from one line to another testing the line to see if it separates a paragraph. The function of the hook is to make this decision and return zero if the line does not separate paragraphs or return one if it does. The default value of this hook may be written in S-Lang as ( bol "\\" looking_at {1 return} if "%" looking_at {1 return} if skip_white eolp ) is_paragraph_separator A related hook called after a paragraph is formatted is `format_paragraph_hook'. This hook is only called if either `format_paragraph' or `narrow_paragraph' is called with a prefix digit argument. For example, `format_paragraph' is bound to `ESC q'. Simply pressing this key sequence will call `format_paragraph' but `format_paragraph_hook' will not be called. However, pressing `ESC 1' followed by `ESC q' will result in a call to `format_paragraph_hook'. Currently, this hook simply justifies the paragraph. That is, it fills each line in the paragraph such that the the line ends at the right margin, which is defined by the `WRAP' variable.  File: jed.info, Node: S-Lang Programming Hints (Debugging), Prev: Hooks, Up: Customization S-Lang Programming Hints (Debugging) ------------------------------------ This section assumes some knowledge about S-Lang and is designed to explain how to debug S-Lang routines quickly. For information about S-Lang, read `slang.txt'. There are two ways of loading a file of S-Lang code into JED. The most common way is through the function `evalfile'. If an error occurs while loading a file, JED will give some indication of where the problem lies by displaying the line number and the offending bit of S-Lang code in the minibuffer. In practice though, this can be quite inefficient. The `evalfile' function is primarily designed to load debugged and tested S-Lang code. The best way to develop and test S-Lang code with JED is to use the function `evalbuffer'. Simply load the piece of code into JED as an ordinary file, press `ESC X' and enter the function `evalbuffer' If the piece of code in the buffer has any syntax errors, JED will put the cursor on the error. This is the best way to spot compile time errors such as syntax errors. However, this will not catch runtime errors. When a runtime error occurs, JED will put the cursor on the top level function where the original call was made and NOT the actual location of the function. To aid in determining where an error occurs, JED can be made to give a symbolic traceback. As the S-Lang runtime stack unwinds, S-Lang will simply print the name of function at that particular level. If the function includes local variables, their values will be dumped as well. Hence, it is easy to quickly narrow the location of an error down to function where the error occurs. By default, the traceback is disabled. The traceback is enabled by setting the S-Lang variable `_traceback' to a non-zero value. It is simpliest to just press ` ESC' and enter `1 =_traceback' at the JED prompt. This is one of those times where one needs access to the `S-Lang>' prompt and not the `M-x' prompt. For example, consider the following piece of code: ( {} forever ) fun_two ;; loops forever ( fun_two ) fun_one ;; calls fun_two-- never returns Simply enter the above into an empty JED `*scratch*' buffer, then press ` ESC' and enter `1 =_traceback evalbuffer fun_one'. This will turn on tracebacks, evaluate the buffer and call the function `fun_one'. JED will then be put into an infinite loop which can only be stopped by pressing the abort character which by default is . Doing so, will produce the traceback messages S-Lang Traceback: fun_two S-Lang Traceback: fun_one in addition to the error message `User Break!'. Of course, this technique only narrows down the source of an error to a particular function. To proceed further, it may necessary to put "print" statements at suitable places in the function. There are several ways to do this: 1. Use the `insert' function to insert the contents of a variable into the current buffer. 2. Use the `error' function to abort the function and display the value of a variable in the minibuffer. 3. Use the `message' function to display the value of a variable in the minibuffer. Unlike `error', the `message' function does not abort the execution of the function. Since each of these functions require a string argument, it is usually best to call the `string' function first for the conversion followed by the output function. This has to be done anyway if it is desired to get the contents of an integer variable. Although the second approach is prehaps the most useful in practice, it is somtimes appropriate to use a combination of these techniques. Finally, to print the entire stack, one can use the `print_stack' function. This function dumps the S-Lang runtime stack into the `*traceback*' buffer. Since S-Lang is an interpreted language, judicious application of the above techniques should lead very quickly to the source of any errors.  File: jed.info, Node: Eight Bit Clean Issues, Next: Miscellaneous, Prev: Customization, Up: Top Eight Bit Clean Issues ====================== * Menu: * Displaying Characters with the High Bit Set:: * Inputting Characters with the High Bit Set:: * Upper Case - Lower Case Conversions::  File: jed.info, Node: Displaying Characters with the High Bit Set, Next: Inputting Characters with the High Bit Set, Up: Eight Bit Clean Issues Displaying Characters with the High Bit Set ------------------------------------------- There are several issues to consider here. The most important issue is how to get JED to display 8 bit characters in a "clean" way. By "clean" I mean any character with the high bit set is sent to the display device as is. This is achieved by putting the line: 1 =DISPLAY_EIGHT_BIT in the `jed.rc' (`.jedrc') startup file. European systems might want to put this in the file `site.sl' for all users. The default is 1 so unless its value has been changed, this step may not be necessary. There is another issue. Suppose you want to display 8 bit characters with extended Ascii codes greater than or equal to some value, say 160. This is done by putting `160 =DISPLAY_EIGHT_BIT'. I believe that ISO Latin character sets assume this. This is the default value for Unix and VMS systems. See also the file `iso-latin.sl'.  File: jed.info, Node: Inputting Characters with the High Bit Set, Next: Upper Case - Lower Case Conversions, Prev: Displaying Characters with the High Bit Set, Up: Eight Bit Clean Issues Inputting Characters with the High Bit Set ------------------------------------------ Inputting a character into JED with the high bit set is another issue. How JED interprets this is controlled by the variable `META_CHAR'. Specifically what happens is this: When JED reads a character from the input device with the high bit set, it: 1. Checks the value of `META_CHAR'. If this value is -1, JED simply inserts the character into the buffer. 2. For any other value of `META_CHAR' in the range 0 to 255, JED returns two 7-bit characters. The first character returned is `META_CHAR' itself. The next character returned is the original character but with the high bit stripped. The default value of `META_CHAR' is -1 which means that when JED sees a character with the high bit set, JED leaves it as is. Please note that a character with the high bit set cannot be the prefix character of a keymap. It can be a part of the keymap but not the prefix. Some systems only handle 7-bit character sequences and as a result, JED will only see 7-bit characters. JED is still able to insert any character in the range 0-255 on a 7-bit system. This is done through the use of the `quoted_insert' function which, by default, is bound to the backquote key `. If the `quoted_insert' function is called with a digit argument (repeat argument), the character with the value of the argument is inserted into the buffer. Operationally, one hits ESC, enters the extended Ascii code and hits the backquote key. For example, to insert character 255 into the buffer, simply press the following five keys: `ESC 2 5 5 `'.  File: jed.info, Node: Upper Case - Lower Case Conversions, Prev: Inputting Characters with the High Bit Set, Up: Eight Bit Clean Issues Upper Case - Lower Case Conversions ----------------------------------- The above discussion centers around input and output of characters with the high bit set. How JED treats them internally is another issue and new questions arise. For example, what is the uppercase equivalent of a character with ASCII code 231? This may vary from language to language. Some languages even have characters whose uppercase equivalent correspond to multiple characters. For JED, the following assumptions have been made: 1. Each character is only 8 bits. 2. Each character has a unique uppercase equivalent. 3. Each character has a unique lowercase equivalent. It would be nice if a fourth assumption could be made: 4. The value of the lowercase of a character is greater than or equal to its uppercase counterpart. However, apparently this is not possible since most IBMPC character sets violate this assumption. Hence, JED does not assume it. Suppose X is the upper case value of some character and suppose Y is its lower case value. Then to make JED aware of this fact and use it it case conversions, it may be necessary to put a statement of the form: X Y define_case in the startup file. For example, suppose 211 is the uppercase of 244. Then, the line `211 244 define_case' will make JED use this fact in operations involving the case of a character. This has already been done for the ISO Latin 1 character set. See the file `iso-latin.sl' for details. For MSDOS, this will not work. Instead use the files `dos437.sl' and `dos850.sl'. By default, JED's internal lookup tables are initialized to the ISO Latin set for Unix and VMS systems and to the DOS 437 code page for the IBMPC. To change the defaults, it is only necessary to load the appropriate file. For example, to load `dos850.sl' definitions, put "dos850.sl" evalfile pop in the startup file (e.g., `site.sl'). In addition to uppercase/lowercase information, these files also contain word definitions, i.e., which characters constitute a "word".  File: jed.info, Node: Miscellaneous, Prev: Eight Bit Clean Issues, Up: Top Miscellaneous ============= * Menu: * Abort Character:: * Input Translation:: * Display Sizes::  File: jed.info, Node: Abort Character, Next: Input Translation, Up: Miscellaneous Abort Character --------------- The abort character ( by default) is special and should not be rebound. On the IBMPC, the keyboard interrupt 0x09 is hooked and a quit condition is signaled when it is pressed. For this reason, it should not be used in any keybindings. A similar statement holds for the other systems. This character may be changed using the function `set_abort_char' Using this function affects all keymaps. For example, putting the line 30 set_abort_char in your `jed.rc' file will change the abort character from its current value to 30 which is Control-^.  File: jed.info, Node: Input Translation, Next: Display Sizes, Prev: Abort Character, Up: Miscellaneous Input Translation ----------------- By using the function `map_input' the user is able to remap characters input from the terminal before JED's keymap routines have a chance to act upon them. This is useful when it is difficult to get JED to see certain characters. For example, consider the  character. This character is especially notorious because many systems use it and  for flow control. Nevertheless Emacs uses  for searching. Short of rebinding all keys which involve a  how does one work with functions that are bound to key sequences using ? This is where `map_input' comes into play. The `map_input' function requires two integer arguments which define how a given ascii character is to be mapped. Suppose that you wish to substitute  for  everywhere. The line 28 19 map_input will do the trick. Here 28 is the ascii character of  and 19 is the ascii character for the . As another example, consider the case where the backspace key sends out a  instead of the DEL character (?). 8 127 map_input will map the  (8) to the delete character (127).  File: jed.info, Node: Display Sizes, Prev: Input Translation, Up: Miscellaneous Display Sizes ------------- On VMS and unix systems, the screen size may be changed to either 80 or 132 columns by using the functions `w80' and `w132' respectively. Simply enter the appropriate function name at the `M-x' prompt in the minibuffer. The default binding for access to the minibuffer is `ESC X'. Most window systems, e.g., DECWindows, allow the window size to be changed. When this is done, JED should automatically adapt to the new size. On the PC, at this time the screen size cannot be changed while JED is running. Instead it is necessary to exit JED first then set the display size and rerun JED. jed-0.99-19/info/jed.1in0000644002657400265740000005721711311317447013614 0ustar davisdavis File: jed.info, Node: Top, Next: Introduction, Up: (dir) Note!!! This document is nolonger maintained. See jed/doc/*.txt for more current documentation. Copyright (C) 1992, 1993 John E. Davis * Menu: * Introduction:: * Installing JED:: * Startup Files:: * Starting JED:: * Emulating Other Editors:: Emacs, EDT, and Wordstar emulation * File Types and Sizes:: * Backup and Autosave Files:: * Status line and Windows:: * MiniBuffer:: * Basic Editing:: * Modes:: * Keyboard Macros:: * Shells and Shell Commands:: * Getting Help:: * Editing Binary Files:: * Dired:: Using JED to maintain directories * Mail:: * Customization:: * Eight Bit Clean Issues:: * Miscellaneous::  File: jed.info, Node: Introduction, Next: Installing JED, Prev: Top, Up: Top Introduction ============ This document presents some basic information that users should know in order to use JED effectively. Any questions, comments, or bug reports, should be emailed to the author. Please be sure to include the version number. To be notified of future releases of JED, email to the address below and your email address will be placed on the announcement list. The email address is: davis@space.mit.edu (internet) davis@ohstpy (BITNET)  File: jed.info, Node: Installing JED, Next: Startup Files, Prev: Introduction, Up: Top Installing JED ============== Building JED from its sources requires the use of a C compiler that understands function prototypes. JED has been successfully built with `cc' on the ULTRIX, VMS, and IRIX operating systems. In addition, it has been created using `gcc' under SunOS and Borland's BCC 3.0 for the PC. Detailed installation instructions are in separate, operating system dependent files. They are: UNIX: install.unx VMS: install.vms IBMPC: install.pc When JED starts up, it will first try to load a site initialization file called `site.sl'. Site specific commands are placed here. Most likely, `site.sl' will define some functions, default hooks, etc... What goes in it is left to the discretion of the user or system manager. See the file `site.sl' for examples. If you intend to use characters with ASCII codes greater than 127, it is important to read the section on "Eight Bit Clean Issues" in order to install JED in an 8 bit clean manner. When loading `site.sl' as well as other `S-Lang' files (the user's personal initialization file, `.jedrc' or `jed.rc', is a special case, see below), JED searches all directories specified by the environment variable `JED_LIBRARY', and if the file is not found, JED will look for it in the default directory. The environment variable `JED_LIBRARY' is a comma separated list of directories. Here are some examples of setting this variable for different systems: VMS: define/job JED_LIBRARY dev$lib:[jedfiles] UNIX: setenv JED_LIBRARY '/usr/local/lib/jed,~/jed' IBMPC: set JED_LIBRARY = c:\editors\jed\lib You will probably want to put define `JED_LIBRARY' in your login startup file, e.g., `autoexec.bat', `login.com', or `.cshrc'. JED versions 0.92 and later allow the value of `JED_LIBRARY' to be specified at compile time an it may only be necessary to define `JED_LIBRARY' as an environment variable to override its pre-compiled value.  File: jed.info, Node: Startup Files, Next: Starting JED, Prev: Installing JED, Up: Top Startup Files ============= Once JED has loaded the startup file `site.sl', it will try to load the user's personal initialization file. It first looks in the directory pointed to by the environment variable `JED_HOME'. If that fails, it then searches the `HOME' directory and upon failure simply loads the one supplied in `JED_LIBRARY'. The name of the user initialization file varies according to the operating system. On Unix systems this file must be called `.jedrc' while on VMS and MSDOS, it goes by the name `jed.rc'. For VMS systems, the `HOME' directory corresponds to the `SYS$LOGIN' logical name while for the other two systems, it corresponds to the `HOME' environment variable. The purpose of this file is to allow an individual user to taylor JED to his or her personal taste. Most likely, this will involve choosing an initial set of keybindings, setting some variables, and so on.  File: jed.info, Node: Starting JED, Next: Emulating Other Editors, Prev: Startup Files, Up: Top Starting JED ============ Normally, JED is started as jed FILENAME or jed FILE_LIST. However, JED also takes the following switches: `-batch' run JED in batch mode. This is a non-interactive mode. `-n' do not load `jed.rc' (`.jedrc') file. `-g N' goto line N in buffer `-l FILE' load FILE as `S-Lang' code. `-f FUNCTION' execute S-Lang function named FUNCTION `-s STRING' search forward for STRING `-2' split window `-i FILE' insert FILE into current buffer. For example, the command line: jed slang.c -g 1012 -s error -2 file.c -f eob will start up JED, read in the file `slang.c', goto line 1012 of `slang.c' and start searching for the string `error', split the window, read in `file.c' and goto the end of the file. If the `-batch' parameter is used, it must be the first parameter. Similarly, if `-n' is used, it must also be the first parameter unless used with the `-batch' parameter in which case it must the second. JED should only be run in batch mode when non-interactive operation is desired. For example, JED is distributed with a file, `mkdoc.sl', that contains S-Lang code to produce a help file for functions and variables. In fact, the help file `jed_funs.hlp' was created by entering jed -batch -n -l mkdoc.sl at the command line. Now suppose that you want to read in a file with the name of one of the switches, say `-2'. How can this be done? The answer depends upon the operating system. For unix, instead of `jed -2', use `jed ./-2'; for VMS, use `jed []-2'. The case for MSDOS is similar to unix except that one must use the backslash. It is possible to completely change JED's command line syntax through the use of the user defined function `command_line_hook'. In fact, the behavior described above is dictated by the value of `command_line_hook' as distributed in `site.sl'. See the section on hooks for details.  File: jed.info, Node: Emulating Other Editors, Next: File Types and Sizes, Prev: Starting JED, Up: Top Emulating Other Editors ======================= JED's ability to create new functions using the S-Lang programming language as well as allowing the user to choose key bindings, makes the emulation of other editors possible. Currently, JED provides reasonable emulation of the Emacs, EDT, and Wordstar editors. * Menu: * Emacs Emulation:: * EDT Emulation:: * Wordstar Emulation::  File: jed.info, Node: Emacs Emulation, Next: EDT Emulation, Prev: Emulating Other Editors, Up: Emulating Other Editors Emacs Emulation --------------- Emacs Emulation is provided by the S-Lang code in `emacs.sl'. The basic functionality of Emacs is emulated; most Emacs users should have no problem with JED. To enable Emacs emulation in JED, make sure that the line "emacs.sl" evalfile pop is in your `jed.rc' (`.jedrc') startup file. JED is distributed with this line already present in the default `jed.rc' file.  File: jed.info, Node: EDT Emulation, Next: Wordstar Emulation, Prev: Emacs Emulation, Up: Emulating Other Editors EDT Emulation ------------- For EDT emulation, `edt.sl' must be loaded. This is accomplished by ensuring that the line "edt.sl" evalfile pop is in present in the `jed.rc' (`.jedrc') Startup File. JED is distributed with EDT emulation enabled on VMS and Unix systems but the above line is commented out in the `jed.rc' file on MSDOS systems. This emulation provides a near identical emulation of the EDT keypad key commands. In addition, the smaller keypad on the newer DEC terminals is also setup. It is possible to have both EDT and Emacs emulation at the same time. The only restriction is that `emacs.sl' must be loaded before `edt.sl' is loaded. One minor difference between JED's EDT emulation and the real EDT concerns the  key. EDT normally binds this to move the cursor to the beginning of the line. However, JED uses it as a help key. Nevertheless, it is possible to rebind it. See the section on rebinding keys as well as the file `edt.sl' for hints. Alternatively, simply put "^H" unsetkey "bol" "^H" setkey in the `jed.rc' startup file after `edt.sl' is loaded. Keep in mind that the  key will no longer function as a help key if this is done. EDT emulation for PCs only work with the enhanced keyboard. When `edt.sl' is loaded, a variable `NUMLOCK_IS_GOLD' is set which instructs JED to interpret the numlock key on the square numeric keypad to function as the EDT GOLD key. In fact, this keypad should behave exactly like the keypad on VTxxx terminals. The only other problem that remains concerns the + key on the PC keypad. This key occupies two VTxxx key positions, the minus and the comma (delete word and character) keys. Thus a decision had to be made about which key to emulate. I chose the + key to return the characters ` O l' which JED maps to the delete character function. This may be changed to the delete word function if you prefer. See the file `edt.sl' for details. The GOLD-GOLD key combination toggles the keypad between application and numeric states. On the PC, this is not possible. Instead, the PC F1 key has been instructed to perform this task.  File: jed.info, Node: Wordstar Emulation, Prev: EDT Emulation, Up: Emulating Other Editors Wordstar Emulation ------------------ `wordstar.sl' contains the S-Lang code for JED's Wordstar emulation. Adding the line "wordstar.sl" evalfile pop to your `jed.rc' (`.jedrc') startup file will enable JED's Wordstar emulation.  File: jed.info, Node: File Types and Sizes, Next: Backup and Autosave Files, Prev: Emulating Other Editors, Up: Top File Types and Sizes ==================== JED is primarily a text editor; however, it can also edit binary files (see the section on editing binary files). As a result, JED may edit lines of arbitrary length (actually this depends upon the size of an integer). It is capable of editing arbitrarily large buffers as long as there is enough memory for the buffer as well as the overhead involved. This editor employs a linked list representation; hence, the overhead can be quite high.  File: jed.info, Node: Backup and Autosave Files, Next: Status line and Windows, Prev: File Types and Sizes, Up: Top Backup and Autosave Files ========================= On UNIX and MSDOS systems, JED creates backup files by appending a `~' character to the filename. The VMS operating system handles backup files itself. JED periodically autosaves its buffers. On UNIX and MSDOS, autosave files are prefixed with the pound sign `#'. On VMS, they are prefixed with `_$'. The autosave interval may be changed by setting the variable MAX_HITS to the desired value. The default is 300 "hits" on the buffer. A "hit" is defined as a key which MAY change the state of the buffer. Cursor movement keys do not cause hits on the buffer. Like many of JED's features, the names of autosave and backup files can be controlled by the user. The file `site.sl' defines two functions, `make_backup_filename', and `make_autosave_filename' that generate the file names described in the previous paragraph. Like all S-Lang functions, these functions may be overloaded and replaced with different ones. See also information about `find_file_hook' in the section on hooks. On UNIX systems, JED catches most signals and tries to autosave its buffers in the event of a crash or if the user accidently disconnects from the system (`SIGHUP'). If an autosave file exists and you is desire to recover data from the autosave file, use the function `recover_file'. Whenever JED finds a file, it checks to see if an autosave file exists as well as the file's date. If the dates are such that the autosave file is more recent JED will display a message in the minibuffer alerting the user of this fact and that the function `recover_file' should be considered.  File: jed.info, Node: Status line and Windows, Next: MiniBuffer, Prev: Backup and Autosave Files, Up: Top Status line and Windows ======================= JED supports multiple windows. Each window may contain the same buffer or different buffers. A status line is displayed immediately below each window. The status line contains information such as the JED version number, the buffer name, "mode", etc. Please beware of the following indicators: `**' buffer has been modified since last save `%%' buffer is read only `m' mark set indicator. This means a region is being defined `d' file changed on disk indicator. This indicates that the file associated with the buffer is newer than the buffer itself. `s' spot pushed indicator `+' undo is enabled for the buffer `[Macro]' a macro is being defined. `[Narrow]' buffer is narrowed to a region of LINES.  File: jed.info, Node: MiniBuffer, Next: Basic Editing, Prev: Status line and Windows, Up: Top MiniBuffer ========== The MiniBuffer consists of a single line located at the bottom of the screen. Much of the dialog between the user and JED takes place in this buffer. For example, when you search for a string, JED will prompt you for the string in the MiniBuffer. The MiniBuffer also provides a direct link to the S-Lang interpreter. To access the interpreter, press  ESC and the `S-Lang>' prompt will appear in the MiniBuffer. Enter any valid S-Lang expression for evaluation by the interpreter. It is possible to to recall data previously entered into the MiniBuffer by using the up and down arrow keys. This makes it possible to use and edit previous expressions in a convenient and efficient manner. * Menu: * Command Line Completion:: * File Names:: * Buffer Name and File Name Completion::  File: jed.info, Node: Command Line Completion, Next: File Names, Up: MiniBuffer Command Line Completion ----------------------- The JED editor has several hundred built-in functions as well as many more written in the S-Lang extension language. Many of these functions are bound to keys and many are not. It is simply unreasonable to require the user to remember if a function is bound to a key or not and, if it is, to remember the key to which it is bound. This is especially true of those functions that are bound but rarely used. More often than not, one simply forgets the exact name or spelling of a function and requires a little help. For this reason, JED supports command line completion in the minibuffer. This function, called `emacs_escape_x', is bound to the key `ESC X'. This is one binding that must be remembered! As an example, suppose that you are editing several buffers and you wish to insert the contents of one buffer into the the current buffer. The function that does this is called `insert_buffer' and has no default keybinding. Pressing `ESC X' produces the prompt `M-x'. This prompt, borrowed from the Emacs editor, simply means that `ESC X' was pressed. Now type `in' and hit the space bar or the TAB key. In this context (completion context) the space bar and the TAB will expand the string in the MiniBuffer up until it is nolonger unique. In this case, `insert_file' and `insert_buffer' are only two functions that start with `in'. Hence, `in' will expand to `insert_' at which point it becomes necessary to enter more information to uniquely specify the desired function. However, in a completion context, the space bar also has a special property that enables the user to cycle among the possible completions. For this example, hitting the space bar twice consecutively will produce the string `insert_file' and hitting it again produces the desired string `insert_buffer'. The role of the space bar in completion is a point where Emacs and JED differ. Emacs will pop up a buffer of possible completions but JED expects the user to press the space bar to cycle among them. Both have there pros and cons. Frequently, one sees messages on the Usenet newsgroup `gnu.emacs.help' from Emacs users asking for the kind of completion JED employs.  File: jed.info, Node: File Names, Next: Buffer Name and File Name Completion, Prev: Command Line Completion, Up: MiniBuffer File Names ---------- JED takes every file name and "expands it" according to a set of rules which vary according to the Operating System. For concreteness, consider JED running under MSDOS. Suppose the user reads a new file into the editor via the `find_file' command which emacs binds to  . Then the following might be displayed in the minibuffer: Find File: C:\JED\SLANG\ Here JED is prompting for a file name in the directory \JED\SLANG on disk C:. However, suppose the user wants to get the file C:\JED\SRC\VIDEO.C. Then the following responses produce equivalent filenames when JED expands them internally: Find File: C:\JED\src\video.c Find File: C:\JED\SLANG\..\src\video.c Find File: C:\JED\SLANG\../src/video.c Note that the on MSDOS systems, JED replaces the `/' with a `\' and that case is not important. Now suppose you wish to get the file VIDEO.C from disk A:. The following are also valid: Find File: A:\video.c Find File: A:video.c Find File: C:\JED\SLANG\a:\video.c In the last case, JED is smart enough to figure out what is really meant. Although the above examples are for MSDOS systems, the rules also apply to unix and VMS systems as well. The only change is the file name syntax. For example, on VMS sys$manager:[misc]dev$user:[davis.jed]vms.c dev$user:[davis.jed]vms.c become equivalent filenames upon expansion. For unix, the following are equivalent: /user1/users/davis/jed/unix.c /usr/local/src//user1/users/davis/jed/unix.c /usr/local/src/~/jed/unix.c Note the last example: the tilde character `~' always expands into the users `HOME' directory, in this case to `/user1/users/davis'. When JED writes a buffer out to a file, it usually prompts for a file name in the minibuffer displaying the directory associated with the current buffer. At this point a name can be appended to the directory string to form a valid file name or the user may simply hit the RET key. If the latter alternative is chosen, JED simply writes the buffer to the file already associated with the buffer. Once the buffer is written to a file, the buffer becomes attached to that file. * Menu: * Buffer Name and File Name Completion::  File: jed.info, Node: Buffer Name and File Name Completion, Prev: File Names, Up: MiniBuffer Buffer Name and File Name Completion ------------------------------------ When JED prompts for a file name or a buffer name, the space bar and the TAB keys are special. Hitting the TAB key will complete the name that is currently in the minibuffer up until it is no longer unique. At that point, you can either enter more characters to complete the name or hit the space bar to cycle among the possible completions. The spacebar must be pressed at least twice to cycle among the completions. On MSDOS and VMS, it is possible to use wildcard characters in the file name for completion purposes. For example, entering `*.c' and hitting the space bar will cycle among file names matching `*.c'. Unfortunately, this feature is not available on unix systems.  File: jed.info, Node: Basic Editing, Next: Modes, Prev: MiniBuffer, Up: Top Basic Editing ============= Editing with JED is pretty easy-- most keys simply insert themselves. Movement around the buffer is usually done using the arrow keys or page up and page down keys. If `edt.sl' is loaded, the keypads on VTxxx terminals function as well. Here, only the highlights are touched upon (cut/paste operations are not considered "highlights"). In the following, any character prefixed by the `^' character denotes a Control character. On keyboards without an explicit Escape key, Control-[ will most likely generate and Escape character. The following list of useful keybindings assumes that `emacs.sl' has been loaded. ` ' redraw screen `' Undo (Control-underscore, also  u) `ESC q' reformat paragraph (wrap mode) `ESC n' narrow paragraph (wrap mode) `ESC ;' Make Language comment (Fortran and C) `ESC \' Trim whitespace around point `ESC !' Execute shell command `ESC $' Ispell word (unix) ` ?' Show line/column information ``' `quoted_insert' -- insert next char as is (backquote key) `ESC s' Center line `ESC u' Upcase word `ESC d' Downcase word `ESC c' Capitalize word `ESC x' Get M-x minibuffer prompt with command completion ` ' pop up a list of buffers ` ' exit JED ` 0' Delete Current Window ` 1' One Window ` 2' Split Window ` o' Other window ` b' switch to buffer ` k' kill buffer ` s' save some buffers `ESC .' Find tag (unix ctags compatible) `X Set Mark (Begin defining a region) * Menu: * Undo:: * Marking Text (Point and Mark):: * Tab Issues.:: * Searching:: * Rectangles:: * Sorting::  File: jed.info, Node: Undo, Next: Marking Text (Point and Mark), Up: Basic Editing Undo ---- One of JED's nicest features is the ability to undo nearly any change that occurs within a buffer at the touch of a key. If you delete a word, you can undo it. If you delete 10 words in the middle of the buffer, move to the top of the buffer and randomly make changes, you can undo all of that too. By default, the `undo' function is bound to the key  (Ascii 31). Since some terminals are not capable of generating this character, it is also bound to the key sequence  u. Due to the lack of virtual memory support on IBMPC systems, the `undo' function is not enabled on every buffer. In particular, it is not enabled for the `*scratch*' buffer. However, it is enabled for any buffer which is associated with a file. A "plus" character on the left hand side of the status line indicates that undo is enabled for the buffer. It is possible to enable undo for any buffer by using the `toggle_undo' function.  File: jed.info, Node: Marking Text (Point and Mark), Next: Tab Issues., Prev: Undo, Up: Basic Editing Marking Text (Point and Mark) ----------------------------- Many commands work on certain regions of text. A region is defined by the `Point' and the `Mark' The `Point' is the location of the current editing point or cursor position. The `Mark' is the location of a mark. The mark is set using the `set_mark_cmd' which is bound to `^@' (Control-2 or Control-Space on some keyboards). When the mark is set, the `m' mark indicator will appear on the status line. This indicates that a region is being defined. Moving the cursor (`Point') defines the other end of a region. Many editors will highlight the region as it is marked. I have not added this to JED since such a feature complicates the display code without contributing any useful functionality. Of course this is only my opinion and is open for debate. It is easy to see where the location of the mark is by using the `exchange' command which is bound to  . This simply exchanges the `Point' and the `Mark'. The region is still intact since it is defined only by the `Point' and `Mark'. Pressing   again restores the mark and Point back to their original locations. Try it. jed-0.99-19/info/jed.2in0000644002657400265740000006043411311317447013610 0ustar davisdavis File: jed.info, Node: Tab Issues., Next: Searching, Prev: Marking Text (Point and Mark), Up: Basic Editing Tab Issues. ----------- Strictly speaking, JED uses only fixed column tabs whose size is determined by the value of the `TAB' variable. Setting the `TAB' variable to 0 causes JED to not use tabs as whitespace and to display tabs as . Please note that changing the tab settings on the terminal will have no effect as far as JED is concerned. The `TAB' variable is local to each buffer allowing every buffer to have its own tab setting. The variable `TAB_DEFAULT' is the tab setting that is given to all newly created buffers. The default value for this variable is 8 which corresponds to eight column tabs. JED is also able to "simulate" arbitrary tabs as well through the use of user defined tab stops. Calling the function `edit_tab_stops' allows the user to interactively set the tab stops. That is, one simply presses `ESC X' to get the `M-x' prompt and enters `edit_tab_stops'. A window will pop open displaying the current tab settings. To add a tab stop, simply place a `T' in the appropriate column. Use the space bar to remove a tab stop. Here an argument is presented in favor of simulated tabs over real tab stops. First, consider what a "tab" really is. A "tab" in a file is nothing more than a character whose ASCII value is 9. For this reason, one also denotes a tab as ^I (Control-I). Unlike most other ASCII characters, the effect of the tab character is device dependent and is controlled through the device tab settings. Hence, a file which displays one way on one device may look totally different on another device if the tab settings do not correspond. For this reason, many people avoid tabs altogether and others the adopt "standard" of eight column tabs. Even though people always argue about what the correct tab settings should be, it must be kept in mind that this is primarily a human issue and not a machine issue. On a device employing tab stops, a tab will cause the cursor to jump to the position of the next tab stop. Now consider the effect of changing the tab settings. Assume that in one part of a document, text was entered using the first setting and in another part, the second setting was used. When moving from the part of the document where the current tab setting is appropriate to the part where the other tab setting was used will cause the document to look unformatted unless the appropriate tab settings are restored. Wordprocessors store the tab settings in the file with the text so that the tabs may be dynamically changed to eliminate such unwanted behavior. However, text editors such as JED, vi, Emacs, EDT, EVE (TPU), etc, do not store this information in the file. JED avoids this problem by using simulated tabs. When using simulated tabs, tabs are not really used at all. Rather JED inserts the appropriate number of spaces to achieve the desired effect. This also has the advantage of one being able to cut and paste from the part of a document using one tab setting to another part with a different tab setting. This simple operation may lead to unwanted results on some wordprocessors as well as those text editors using real tab stops.  File: jed.info, Node: Searching, Next: Rectangles, Prev: Tab Issues., Up: Basic Editing Searching --------- JED currently has two kinds of searches: ordinary searches and incremental searches. Both types of searches have forward and backward versions. The actual functions for binding purposes are: search_forward search_backward isearch_forward isearch_backward There is also the `occur' function which finds all occurrences of a single word (string). This function has no backwards version. By default it is not bound to any keys, so to use it, `occur' must be entered at the `M-x' prompt (`ESC X') or one is always free to bind it to a key. In the following only the incremental search is discussed. The default type of search in Emacs in the incremental search. However, since this type of search is confusing to the uninitiated, the ordinary type of search has been made the default in JED's Emacs emulation. For the traditional emacs keybinding, it is up to the user to provide the keybinding. As the name suggests, an incremental search performs a search incrementally. That is, as you enter the search string, the editor begins searching right away. For example, suppose you wish to search for the string `apple'. As soon as the letter `a' is entered into the incremental search prompt, JED will search for the first occurrence of `a'. Then as soon as the `p' is entered, JED will search from the current point for the string `ap', etc... This way, one is able to quickly locate the desired string with only a minimal amount of information. Unlike the "ordinary" search, the incremental search is not terminated with the RET (^M) key. Hitting the RET key causes JED to search for the next occurrence of the string based on the data currently entered at the prompt. The search is terminated with the ESC key. Finally, the DEL key (?) is used to erase the last character entered at the search prompt. In addition to erasing the last character of the search string, JED will return back to the location of the previous match. Erasing all characters will cause the editor to return to the place where the search began. Like many things, this is one of those that is easier to do than explain. Feel free to play around with it.  File: jed.info, Node: Rectangles, Next: Sorting, Prev: Searching, Up: Basic Editing Rectangles ---------- JED has built-in support for the editing of rectangular regions of text. One corner of rectangle is defined by setting the mark somewhere in the text. The Point (cursor location) defines the opposite corner of the rectangle. Once a rectangle is defined, one may use the following functions: `kill_rect' Delete text inside the rectangle saving the rectangle in the internal rectangle buffer. `open_rect' Push all text in the rectangle to the right outside the rectangle. `copy_rect' Copy text inside the rectangle to the internal rectangle buffer. `blank_rect' Replace all text inside the rectangle by spaces. The function `insert_rect' inserts a previously killed or copied rectangle into the text at the Point. These functions have no default binding and must be entered into the MiniBuffer by pressing `ESC X' to produce the `M-x' prompt.  File: jed.info, Node: Sorting, Prev: Rectangles, Up: Basic Editing Sorting ------- JED is capable of sorting a region of lines using the heapsort algorithm. The region is sorted alphabetically based upon the ASCII values of the characters located within a user defined rectangle in the region. That is, the rectangle simply defines the characters upon what the sort is based. Simply move to the top line of the region and set the mark on the the top left corner of the rectangle. Move to the bottom line and place the point at the position which defines the lower right corner of the rectangle. Press `ESC X' to get the `M-x' prompt and enter `sort' As as example, consider the following data: Fruit: Quantity: lemons 3 pears 37 peaches 175 apples 200 oranges 56 To sort the data based upon the name, move the Point to the top left corner of the sorting rectangle. In this case, the Point should be moved to the `l' in the word `lemons'. Set the mark. Now move to the lower right corner of the rectangle which is immediately after the `s' in `oranges'. Pressing `ESC X' and entering `sort' yields: Fruit: Quantity: apples 200 lemons 3 oranges 56 peaches 175 pears 37 Suppose that it is desired to sort by quantity instead. Looking at the original (unsorted) data, move the Point to two spaces before the `3' on the line containing `lemons'. The cursor should be right under the `u' in `Quantity'. Set the mark. Now move the Point to immediately after `56' on the `oranges' line and again press `ESC X' and enter `sort'. This yields the desired sort: Fruit: Quantity: lemons 3 pears 37 oranges 56 peaches 175 apples 200  File: jed.info, Node: Modes, Next: Keyboard Macros, Prev: Basic Editing, Up: Top Modes ===== Jed supports two internal modes as well as user defined modes. The two internal modes consist of a "C" mode for C Language programming and a "Wrap" mode for ordinary text editing. Examples of user defined modes are Fortran mode and DCL mode. Online documentation is provided for nearly every mode JED defines. For help on the current mode, press `ESC X' and enter `describe_mode'. A window will appear with a short description of the special features of the mode as well as a description of the variables affecting the mode. * Menu: * Wrap Mode:: * Smart Quotes:: * C Mode:: * Fortran Mode::  File: jed.info, Node: Wrap Mode, Next: Smart Quotes, Up: Modes Wrap Mode --------- In this mode, text is wrapped at the column given by the `WRAP' variable. The default is 78. The text does not wrap until the cursor goes beyond the wrap column and a space is inserted. * Menu: * Formatting paragraphs::  File: jed.info, Node: Formatting paragraphs, Up: Wrap Mode Formatting paragraphs ..................... Paragraph delimiters are: blank lines, lines that begin with either a percent character, `%', or a backslash character `\'. This definition is ideally suited for editing (La)TeX documents. However, it is possible for the user to change this definition. See the the discussion of the hook, `is_paragraph_separator', in the section on hooks for explicit details on how to do this. The paragraph is formatted according to the indentation of the current line. If the current line is indented, the paragraph will be given the same indentation. The default binding for this function is `ESC q'. In addition, a paragraph may be "narrowed" by the `narrow_paragraph' function which is bound to ESC N by default. This differs from the ordinary `format_paragraph' function described above in that the right margin is reduced by an amount equal to the indentation of the current line. For example: This paragraph is the result of using the function ``narrow_paragraph''. Note how the right margin is less here than in the above paragraph. Finally, if either of these functions is called from the keyboard with a prefix argument, the paragraph will be justified as well. For example, pressing `ESC 1 ESC N' on the previous paragraph yields: This paragraph is the result of using the function ``narrow_paragraph''. Note how the right margin is less here than in the above paragraph. See the discussion of `format_paragraph_hook' in the section on hooks for details on how this is implemented.  File: jed.info, Node: Smart Quotes, Next: C Mode, Prev: Wrap Mode, Up: Modes Smart Quotes ------------ You have probably noticed that many key words in this document are quoted in double quotes like "this is double quoted" and `this is single quoted'. By default, the double quote key (") and single quote key (') are bound to the function `text_smart_quote'. With this binding and in wrap mode, the single quote key inserts a single quote with the "proper" orientation and the double quote key inserts two single quotes of the "proper" direction. To turn this off, rebind the keys to `self_insert_cmd'. Some modes already do this (e.g., EDT). This brings up the question: if the double quote key is bound to `text_smart_quote' then how does one insert the character (")? The most common way is to use the `quoted_insert' function which, by default, is bound to the single backquote (``') key. This is the same mechanism that is used to insert control characters. The other method is to use the fact that if the preceding character is a backslash, `\', the character simply self inserts. Again, this is ideal for writing TeX documents.  File: jed.info, Node: C Mode, Next: Fortran Mode, Prev: Smart Quotes, Up: Modes C Mode ------ C Mode facilitates the editing of C files. Much of the latter part of the development of the JED editor was done using this mode. This mode may be customized by a judicious choice of the variables C_INDENT and C_BRACE as well as the bindings of the curly brace keys { and }. Experiment to find what you like or write your own using the S-Lang interface. By default, the RET key is bound to the function `newline_and_indent'. This does what its name suggests: inserts a newline and indents. Again, some modes may rebind this key. In addition, the keys {, }, and TAB are also special in this mode. The TAB key indents the current line and the { and } keys insert themselves and reindent. If you do not like any of these bindings, simply rebind the offending one to `self_insert_cmd'. Finally, the key sequence ESC ; is bound to a function called `c_make_comment'. This function makes and and indents a C comment to the column specified by the value of the variable `C_Comment_Column'. If a comment is already present on the line, it is indented.  File: jed.info, Node: Fortran Mode, Prev: C Mode, Up: Modes Fortran Mode ------------ Fortran Mode is written entirely in S-Lang and is designed to facilitate the writing of Fortran programs. It features automatic indentation of Fortran code as well as automatic placement of Fortran statement Labels. In this mode, the keys 0-9 are bound to a function `for_elebel' which does the following: 1. Inserts the calling character (0-9) into the buffer. 2. If the character is preceded by only other digit characters, it assumes the character is for a label and moves it to the appropriate position. 3. Reindents the line. This function is very similar to the one Emacs uses for labels.  File: jed.info, Node: Keyboard Macros, Next: Shells and Shell Commands, Prev: Modes, Up: Top Keyboard Macros =============== JED is able to record a series of keystrokes from the terminal and replay them. The saved series of keystrokes is known as a keyboard macro. To begin a keyboard macro, simply enter the begin keyboard macro key sequence which is bound to ^X( if `emacs.sl' is loaded. To stop recording the keystrokes, enter ^X). Then to "execute" the macro, press ^Xe. Please note that it is illegal to execute a macro while defining one and doing so generates an error. A macro can be aborted at anytime by pressing the  key. One nice feature JED includes is the "macro_query" function. That is, while defining a macro, the key sequence ` q' will cause JED to issue the prompt `Enter String:' in the minibuffer. Any string that is entered will be inserted into the buffer and the process of defining the macro continues. Every time the macro is executed, JED will prompt for a NEW string to be inserted. Any time an error is generated, the process of defining the macro is aborted as well as execution of the macro. This is very useful and may be exploited often. For example, suppose you want to trim excess whitespace from the end of ALL lines in a buffer. Let us also suppose that the number of lines in the buffer is less than 32000. Then consider the following keystrokes: ` (' ; begin macro `' ; goto end of line `ESC \' ; trim whitespace `DOWN' ; go down one line ` )' ; end macro Now the macro has been defined. So move to the top of the buffer and execute it 32000 times: `ESC <' ; top of buffer `ESC 3 2 0 0 0' ; repeat next command 32000 times ` e' ; execute macro If the buffer has less than 32000 lines, the end of the buffer will be reached and an error will be generated aborting the execution of the macro.  File: jed.info, Node: Shells and Shell Commands, Next: Getting Help, Prev: Keyboard Macros, Up: Top Shells and Shell Commands ========================= The default binding to execute a shell command and pump the output to a buffer is `ESC !'. JED will prompt for a command line and spawn a subprocess for its execution. Strictly speaking, JED does not support interactive subprocesses. However, JED includes S-Lang code that "emulates" such a subprocess. It may invoked by typing `shell' at the `M-x' minibuffer prompt. A window will be created with a buffer named `*shell*' attached to it. Any text entered at the system dependent shell prompt will be executed in a subprocess and the result stuffed back in the shell buffer. Don't try to execute any commands which try to take over the keyboard or the screen or something undesirable may happen. Examples of types of stupid commands are spawning other editors, logging in to remote systems, et cetera. Even `chdir' is stupid since its effect is not permanent. That is, > cd .. > dir will not do what might naively be expected. That is, the two commands above are not equivalent to the single command `dir ..'.  File: jed.info, Node: Getting Help, Next: Editing Binary Files, Prev: Shells and Shell Commands, Up: Top Getting Help ============ JED's help functions are bound to  by default. For example, ` C' will show what function a key carries out, ` i' will run JED's info reader, ` f' will give help on a particular S-Lang function, etc... However, some modes may use the  key for something else. For example, if EDT mode is in effect, then  may be bound to `bol' which causes the cursor to move to the beginning of the line. See the section on EDT for more information. If JED is properly installed, this entire document is accessable from within the editor using JED's info reader. ` i' will load `info_mode' allowing the user to browse the document as well as other "info" documents.  File: jed.info, Node: Editing Binary Files, Next: Dired, Prev: Getting Help, Up: Top Editing Binary Files ==================== JED may edit binary files as long as the proper precautions are taken. On IBMPC systems, this involves calling the S-Lang function `set_file_translation' with an integer argument. If the argument is 0, files are opened as text files; otherwise, they are opened in binary mode. There is no need to call this function for other systems. However, beware of the user variable `ADD_NEWLINE' which if non zero, a newline character will be appended to the file if the last character is not a newline character. If you are going to edit binary files, it is probably a good idea to set this variable to zero.  File: jed.info, Node: Dired, Next: Mail, Prev: Editing Binary Files, Up: Top Dired-- the Directory editor ============================ In addition to editing files, JED is also able to rename and delete them as well. JED's Dired mode allows one to do just this is a simple and safe manner. To run dired, simply press `ESC X' and enter `dired' at the prompt. JED will load `dired.sl' and prompt for a directory name. Once the directory is given, JED will display a list files in the directory in a buffer named `*dired*'. One may use normal buffer movemment commands to move around this. To delete one or more files, use the `d' key to "tag" the files. This in itself does not delete them; rather, it simply marks them for deleting. A capital `D' will appear in the left margin to indicate that a file has been tagged. Simply hit the u key to untag a file. The delete key will also untag the previously tagged file. To actually delete the tagged files, press the `x' key. This action causes JED to display a list of the tagged files in a separate window and prompt the user for confirmation. Only when the proper confirmation is given, will the file be deleted. Renaming a file is just as simple. Simply move to the line containg the name of the file that you wish to rename and hit the `r' key. JED will prompt for a filename or a directory name. If a directory is given, the file will be moved to the new directory but will keep the name. However, for the operation to succeed, the file must be one the same file system. To rename tagged files to a different directory residing on the same file system, use the `m' key. This has the effect of moving the tagged file out of the current directory to the new one. One may also use the f key to read the file indicated by the cursor position into a buffer for editing. If the file is a directory, the directory will be used for dired operations. In addition, one may also use the v to simply "view" a file. Finally, the `g' key will re-read the current directory and the `h' and `?' keys provide some help.  File: jed.info, Node: Mail, Next: Customization, Prev: Dired, Up: Top Mail ==== This section applies to Unix and VMS systems only. On these systems, it is possible to compose and send mail directly using JED. This assumes that the Unix system has `/usr/ucb/mail'. It is trivial to modify `mail.sl' to support another Unix mailer. For VMS, JED uses the callable mail interface present on VMS versions 5.0 and later. The default binding for the mail is  m. Alternatively, one may press `ESC X' and enter `mail' at the `M-x' prompt. The mail function will cause a window to open with a buffer called `*mail*' which contains the three lines: To: Subject: ---text follows this line--- Simply enter the email address of the person that you want to send the mail to on the line containing `To:' and put the subject of the message on the next line labeled `Subject:'. The text that you wish to mail follows the line labeled `---text follows this line---' which is used by JED as a marker. After you have composed the mail message, press `ESC X' and enter `send' at the `M-x' prompt. For example, the following is an email requesting to be put on the JED mailing list: To: davis@space.mit.edu Subject: jed mailing list ---text follows this line--- Hi, Please add me to the JED mailing list so that I may be notified of upcoming releases of JED. --Maria For VMS systems, the above example will probably fail because an internet address has been used for the example. For systems using a TCP/IP package, it may be necessary to change `davis@space.mit.edu' to something like `smtp%"davis@space.mit.edu"'. The mail function looks for a user defined hook called `mail_hook' and execute it if it exists. This hook may be used to bind certain keys in the keymap associated with the `*mail*' buffer. For example, ( "^C" local_unsetkey "send" "^C^C" local_setkey ) mail_hook defines the key `' in the mail keymap to perform the `send' function. Other possibilities include binding a key sequence, say ^C^W, to a function that inserts the contents of a signature file.  File: jed.info, Node: Customization, Next: Eight Bit Clean Issues, Prev: Mail, Up: Top Customization ============= To extend JED, it is necessary to become familiar with the S-Lang programming language. S-Lang not a standalone programming language like C, Pascal, etc... Rather it is meant to be embedded into a C program. The S-Lang programming language itself provides only arithmetic, looping, and branching constructs. In addition, it defines a few other other primitive operations on its data structures. It is up to the application to define other built-in operations tailored to the application. That is what has been done for the JED editor. See the document `slang.txt' for S-Lang basics as well as the JED Programmer's Manual for functions JED has added to the language. In any case, look at the `*.sl' files for explicit examples. For the most part, the average user will simply want to rebind some keys and change some variables (e.g., tab width). Here I discuss setting keys and the predefined global variables. * Menu: * Setting Keys:: * Predefined Variables:: * Hooks:: * S-Lang Programming Hints (Debugging):: jed-0.99-19/COPYRIGHT0000644002657400265740000000133311311317447012765 0ustar davisdavis Copyright (c) 1992, 1998, 2000, 2005, 2006 John E. Davis This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. jed-0.99-19/INSTALL.unx0000644002657400265740000001213411311317447013335 0ustar davisdavis-*-text-*- UNIX installation specific functions. Please read this file. 0. Building and installing JED requires that you also have the S-Lang library to installed. See http://www.jedsoft.org/slang/download.html for information about obtaining the library. * NOTE: Many Unix distributions distribute a version of the library that that may be used to compile against. For example, on Debian Linux the library is in the "libslang2-dev" package, which may be installed using: apt-get install libslang2-dev * NOTE: Since the jed editor is a conforming slang application, it makes use of the slsh library files, which are part of the slang distribution. If you install slang from source, then these files will also get installed. However, on Debian Linux and its derivatives, these files have been placed into a separate "slsh" package you will need to install: apt-get install slsh 1. Choose an installation location for JED. JED is distributed in a TREE structure: $JED_ROOT/ $JED_ROOT/src $JED_ROOT/info $JED_ROOT/doc $JED_ROOT/lib $JED_ROOT/bin Here JED_ROOT can be anything (e.g., /usr/local/jed). It must be specified in the Makefile of the src subdirectory. It is important that the subdirectories under $JED_ROOT remain intact. An environment variable called `JED_ROOT' can also be created to over ride the value compiled with the executable. 3. Build JED. ./configure --prefix=/usr/local This assumes that you want it installed with JED_ROOT equal to /usr/local/jed/, with the main jed executable installed in /usr/local/bin/. This step creates the necessary Makefiles. * Note: If you have the slang library installed in a non-standard location, you may have to tell configure where to look, e.g., ./configure --prefix=/usr/local --with-slang=/goodies/lib For more options, run `./configure --help` * Note: On CYGWIN, make sure the libslang2.dll in your PATH, otherwise jed will not run, nor will the chkslang program. * Note: On Linux systems, JED may be compiled to take advantage of the GPM mouse server. See the mouse section in src/Makefile for enabling this. * Note: If you are building jed on a system that uses more than one architecture, then before running make, define an environment variable called ARCH whose value specifies the system, e.g., sun4, solaris, etc. Now type `make' at the shell prompt. If you have X windows and you would like to create 'xjed', additionally run 'make xjed'. If all goes well install it with `make install'. JED comes with a highlighting recursive grep program called rgrep. Use `make rgrep` to build it. 4. By default, when JED starts up, it will load some files out of $JED_ROOT/lib then it will look for the file .jedrc in the user's home directory. If it does not find it, it will load the default file jed.rc from $JED_ROOT/lib. In fact, the user is encouraged to copy jed.rc to $HOME/.jedrc and make personal changes there. The $JED_ROOT/lib/jed.rc file should be regarded as a template for .jedrc and should not be changed. The default editor emulation is specified by the _Jed_Default_Emulation variable, which defaults to "emacs". Site specific customization should be placed in /etc/jed.conf or more generally in $prefix/etc/jed.conf. An example jed.conf file may be found in the lib subdirectory. Among other things, it may be used change many of the defaults on a system-wide basis. For instance, many Unix users may not want emacs bindings and may prefer something like Borland's IDE keybindings. It is in this file where such defaults may be made. See the sample file for more details. For more information about customizing jed on a site-wide basis, read the INSTALL file. 5. Optional but highly recommended: preparse the S-Lang files. This is done by running JED as: # jed -batch -n -l preparse.sl This creates pre-parsed *.slc files that load quicker than *.sl files. If this step fails to work for some reason, JED is probably not properly installed. Note that the bytecodes that are stored in the preparsed files (*.slc) may depend upon the version of the slang library that was used. This is particularly relevant if jed is dynamically linked to the slang library and for some reason you upgrade the library. If you do this, then immediately after installing a new version of the slang library, run the command `touch *.sl' on all the .sl files in the $JED_ROOT/lib directory. See the release notes (changes.txt) that are distributed with the slang library to see if any of the byte-codes have changed. 6. New releases will be announced to the jed mailing lists as well as the newsgroups comp.editors and alt.lang.s-lang. See for more information about the mailing lists. Additional information may be found at . 7. That's it. Enjoy. --John jed-0.99-19/autoconf/0000755002657400265740000000000011311317447013310 5ustar davisdavisjed-0.99-19/autoconf/config.guess0000755002657400265740000012626011311317447015637 0ustar davisdavis#! /bin/sh # Attempt to guess a canonical system name. # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, # 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, # Inc. timestamp='2006-07-02' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA # 02110-1301, USA. # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # Originally written by Per Bothner . # Please send patches to . Submit a context # diff and a properly formatted ChangeLog entry. # # This script attempts to guess a canonical system name similar to # config.sub. If it succeeds, it prints the system name on stdout, and # exits with 0. Otherwise, it exits with 1. # # The plan is that this can be called by configure scripts if you # don't specify an explicit build system type. me=`echo "$0" | sed -e 's,.*/,,'` usage="\ Usage: $0 [OPTION] Output the configuration name of the system \`$me' is run on. Operation modes: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit Report bugs and patches to ." version="\ GNU config.guess ($timestamp) Originally written by Per Bothner. Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." help=" Try \`$me --help' for more information." # Parse command line while test $# -gt 0 ; do case $1 in --time-stamp | --time* | -t ) echo "$timestamp" ; exit ;; --version | -v ) echo "$version" ; exit ;; --help | --h* | -h ) echo "$usage"; exit ;; -- ) # Stop option processing shift; break ;; - ) # Use stdin as input. break ;; -* ) echo "$me: invalid option $1$help" >&2 exit 1 ;; * ) break ;; esac done if test $# != 0; then echo "$me: too many arguments$help" >&2 exit 1 fi trap 'exit 1' 1 2 15 # CC_FOR_BUILD -- compiler used by this script. Note that the use of a # compiler to aid in system detection is discouraged as it requires # temporary files to be created and, as you can see below, it is a # headache to deal with in a portable fashion. # Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still # use `HOST_CC' if defined, but it is deprecated. # Portable tmp directory creation inspired by the Autoconf team. set_cc_for_build=' trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; : ${TMPDIR=/tmp} ; { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } || { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } || { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ; dummy=$tmp/dummy ; tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ; case $CC_FOR_BUILD,$HOST_CC,$CC in ,,) echo "int x;" > $dummy.c ; for c in cc gcc c89 c99 ; do if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then CC_FOR_BUILD="$c"; break ; fi ; done ; if test x"$CC_FOR_BUILD" = x ; then CC_FOR_BUILD=no_compiler_found ; fi ;; ,,*) CC_FOR_BUILD=$CC ;; ,*,*) CC_FOR_BUILD=$HOST_CC ;; esac ; set_cc_for_build= ;' # This is needed to find uname on a Pyramid OSx when run in the BSD universe. # (ghazi@noc.rutgers.edu 1994-08-24) if (test -f /.attbin/uname) >/dev/null 2>&1 ; then PATH=$PATH:/.attbin ; export PATH fi UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown # Note: order is significant - the case branches are not exclusive. case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in *:NetBSD:*:*) # NetBSD (nbsd) targets should (where applicable) match one or # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*, # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently # switched to ELF, *-*-netbsd* would select the old # object file format. This provides both forward # compatibility and a consistent mechanism for selecting the # object file format. # # Note: NetBSD doesn't particularly care about the vendor # portion of the name. We always set it to "unknown". sysctl="sysctl -n hw.machine_arch" UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \ /usr/sbin/$sysctl 2>/dev/null || echo unknown)` case "${UNAME_MACHINE_ARCH}" in armeb) machine=armeb-unknown ;; arm*) machine=arm-unknown ;; sh3el) machine=shl-unknown ;; sh3eb) machine=sh-unknown ;; *) machine=${UNAME_MACHINE_ARCH}-unknown ;; esac # The Operating System including object format, if it has switched # to ELF recently, or will in the future. case "${UNAME_MACHINE_ARCH}" in arm*|i386|m68k|ns32k|sh3*|sparc|vax) eval $set_cc_for_build if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep __ELF__ >/dev/null then # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). # Return netbsd for either. FIX? os=netbsd else os=netbsdelf fi ;; *) os=netbsd ;; esac # The OS release # Debian GNU/NetBSD machines have a different userland, and # thus, need a distinct triplet. However, they do not need # kernel version information, so it can be replaced with a # suitable tag, in the style of linux-gnu. case "${UNAME_VERSION}" in Debian*) release='-gnu' ;; *) release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` ;; esac # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: # contains redundant information, the shorter form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. echo "${machine}-${os}${release}" exit ;; *:OpenBSD:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE} exit ;; *:ekkoBSD:*:*) echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE} exit ;; *:SolidBSD:*:*) echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE} exit ;; macppc:MirBSD:*:*) echo powerpc-unknown-mirbsd${UNAME_RELEASE} exit ;; *:MirBSD:*:*) echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE} exit ;; alpha:OSF1:*:*) case $UNAME_RELEASE in *4.0) UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` ;; *5.*) UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` ;; esac # According to Compaq, /usr/sbin/psrinfo has been available on # OSF/1 and Tru64 systems produced since 1995. I hope that # covers most systems running today. This code pipes the CPU # types through head -n 1, so we only detect the type of CPU 0. ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` case "$ALPHA_CPU_TYPE" in "EV4 (21064)") UNAME_MACHINE="alpha" ;; "EV4.5 (21064)") UNAME_MACHINE="alpha" ;; "LCA4 (21066/21068)") UNAME_MACHINE="alpha" ;; "EV5 (21164)") UNAME_MACHINE="alphaev5" ;; "EV5.6 (21164A)") UNAME_MACHINE="alphaev56" ;; "EV5.6 (21164PC)") UNAME_MACHINE="alphapca56" ;; "EV5.7 (21164PC)") UNAME_MACHINE="alphapca57" ;; "EV6 (21264)") UNAME_MACHINE="alphaev6" ;; "EV6.7 (21264A)") UNAME_MACHINE="alphaev67" ;; "EV6.8CB (21264C)") UNAME_MACHINE="alphaev68" ;; "EV6.8AL (21264B)") UNAME_MACHINE="alphaev68" ;; "EV6.8CX (21264D)") UNAME_MACHINE="alphaev68" ;; "EV6.9A (21264/EV69A)") UNAME_MACHINE="alphaev69" ;; "EV7 (21364)") UNAME_MACHINE="alphaev7" ;; "EV7.9 (21364A)") UNAME_MACHINE="alphaev79" ;; esac # A Pn.n version is a patched version. # A Vn.n version is a released version. # A Tn.n version is a released field test version. # A Xn.n version is an unreleased experimental baselevel. # 1.2 uses "1.2" for uname -r. echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` exit ;; Alpha\ *:Windows_NT*:*) # How do we know it's Interix rather than the generic POSIX subsystem? # Should we change UNAME_MACHINE based on the output of uname instead # of the specific Alpha model? echo alpha-pc-interix exit ;; 21064:Windows_NT:50:3) echo alpha-dec-winnt3.5 exit ;; Amiga*:UNIX_System_V:4.0:*) echo m68k-unknown-sysv4 exit ;; *:[Aa]miga[Oo][Ss]:*:*) echo ${UNAME_MACHINE}-unknown-amigaos exit ;; *:[Mm]orph[Oo][Ss]:*:*) echo ${UNAME_MACHINE}-unknown-morphos exit ;; *:OS/390:*:*) echo i370-ibm-openedition exit ;; *:z/VM:*:*) echo s390-ibm-zvmoe exit ;; *:OS400:*:*) echo powerpc-ibm-os400 exit ;; arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) echo arm-acorn-riscix${UNAME_RELEASE} exit ;; arm:riscos:*:*|arm:RISCOS:*:*) echo arm-unknown-riscos exit ;; SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) echo hppa1.1-hitachi-hiuxmpp exit ;; Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. if test "`(/bin/universe) 2>/dev/null`" = att ; then echo pyramid-pyramid-sysv3 else echo pyramid-pyramid-bsd fi exit ;; NILE*:*:*:dcosx) echo pyramid-pyramid-svr4 exit ;; DRS?6000:unix:4.0:6*) echo sparc-icl-nx6 exit ;; DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*) case `/usr/bin/uname -p` in sparc) echo sparc-icl-nx7; exit ;; esac ;; sun4H:SunOS:5.*:*) echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; i86pc:SunOS:5.*:*) echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4*:SunOS:6*:*) # According to config.sub, this is the proper way to canonicalize # SunOS6. Hard to guess exactly what SunOS6 will be like, but # it's likely to be more like Solaris than SunOS4. echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4*:SunOS:*:*) case "`/usr/bin/arch -k`" in Series*|S4*) UNAME_RELEASE=`uname -v` ;; esac # Japanese Language versions have a version number like `4.1.3-JL'. echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` exit ;; sun3*:SunOS:*:*) echo m68k-sun-sunos${UNAME_RELEASE} exit ;; sun*:*:4.2BSD:*) UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 case "`/bin/arch`" in sun3) echo m68k-sun-sunos${UNAME_RELEASE} ;; sun4) echo sparc-sun-sunos${UNAME_RELEASE} ;; esac exit ;; aushp:SunOS:*:*) echo sparc-auspex-sunos${UNAME_RELEASE} exit ;; # The situation for MiNT is a little confusing. The machine name # can be virtually everything (everything which is not # "atarist" or "atariste" at least should have a processor # > m68000). The system name ranges from "MiNT" over "FreeMiNT" # to the lowercase version "mint" (or "freemint"). Finally # the system name "TOS" denotes a system which is actually not # MiNT. But MiNT is downward compatible to TOS, so this should # be no problem. atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit ;; atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit ;; *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit ;; milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) echo m68k-milan-mint${UNAME_RELEASE} exit ;; hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) echo m68k-hades-mint${UNAME_RELEASE} exit ;; *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) echo m68k-unknown-mint${UNAME_RELEASE} exit ;; m68k:machten:*:*) echo m68k-apple-machten${UNAME_RELEASE} exit ;; powerpc:machten:*:*) echo powerpc-apple-machten${UNAME_RELEASE} exit ;; RISC*:Mach:*:*) echo mips-dec-mach_bsd4.3 exit ;; RISC*:ULTRIX:*:*) echo mips-dec-ultrix${UNAME_RELEASE} exit ;; VAX*:ULTRIX*:*:*) echo vax-dec-ultrix${UNAME_RELEASE} exit ;; 2020:CLIX:*:* | 2430:CLIX:*:*) echo clipper-intergraph-clix${UNAME_RELEASE} exit ;; mips:*:*:UMIPS | mips:*:*:RISCos) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #ifdef __cplusplus #include /* for printf() prototype */ int main (int argc, char *argv[]) { #else int main (argc, argv) int argc; char *argv[]; { #endif #if defined (host_mips) && defined (MIPSEB) #if defined (SYSTYPE_SYSV) printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_SVR4) printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); #endif #endif exit (-1); } EOF $CC_FOR_BUILD -o $dummy $dummy.c && dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` && SYSTEM_NAME=`$dummy $dummyarg` && { echo "$SYSTEM_NAME"; exit; } echo mips-mips-riscos${UNAME_RELEASE} exit ;; Motorola:PowerMAX_OS:*:*) echo powerpc-motorola-powermax exit ;; Motorola:*:4.3:PL8-*) echo powerpc-harris-powermax exit ;; Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) echo powerpc-harris-powermax exit ;; Night_Hawk:Power_UNIX:*:*) echo powerpc-harris-powerunix exit ;; m88k:CX/UX:7*:*) echo m88k-harris-cxux7 exit ;; m88k:*:4*:R4*) echo m88k-motorola-sysv4 exit ;; m88k:*:3*:R3*) echo m88k-motorola-sysv3 exit ;; AViiON:dgux:*:*) # DG/UX returns AViiON for all architectures UNAME_PROCESSOR=`/usr/bin/uname -p` if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] then if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ [ ${TARGET_BINARY_INTERFACE}x = x ] then echo m88k-dg-dgux${UNAME_RELEASE} else echo m88k-dg-dguxbcs${UNAME_RELEASE} fi else echo i586-dg-dgux${UNAME_RELEASE} fi exit ;; M88*:DolphinOS:*:*) # DolphinOS (SVR3) echo m88k-dolphin-sysv3 exit ;; M88*:*:R3*:*) # Delta 88k system running SVR3 echo m88k-motorola-sysv3 exit ;; XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) echo m88k-tektronix-sysv3 exit ;; Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) echo m68k-tektronix-bsd exit ;; *:IRIX*:*:*) echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` exit ;; ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id exit ;; # Note that: echo "'`uname -s`'" gives 'AIX ' i*86:AIX:*:*) echo i386-ibm-aix exit ;; ia64:AIX:*:*) if [ -x /usr/bin/oslevel ] ; then IBM_REV=`/usr/bin/oslevel` else IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} fi echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} exit ;; *:AIX:2:3) if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #include main() { if (!__power_pc()) exit(1); puts("powerpc-ibm-aix3.2.5"); exit(0); } EOF if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` then echo "$SYSTEM_NAME" else echo rs6000-ibm-aix3.2.5 fi elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then echo rs6000-ibm-aix3.2.4 else echo rs6000-ibm-aix3.2 fi exit ;; *:AIX:*:[45]) IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then IBM_ARCH=rs6000 else IBM_ARCH=powerpc fi if [ -x /usr/bin/oslevel ] ; then IBM_REV=`/usr/bin/oslevel` else IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} fi echo ${IBM_ARCH}-ibm-aix${IBM_REV} exit ;; *:AIX:*:*) echo rs6000-ibm-aix exit ;; ibmrt:4.4BSD:*|romp-ibm:BSD:*) echo romp-ibm-bsd4.4 exit ;; ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to exit ;; # report: romp-ibm BSD 4.3 *:BOSX:*:*) echo rs6000-bull-bosx exit ;; DPX/2?00:B.O.S.:*:*) echo m68k-bull-sysv3 exit ;; 9000/[34]??:4.3bsd:1.*:*) echo m68k-hp-bsd exit ;; hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) echo m68k-hp-bsd4.4 exit ;; 9000/[34678]??:HP-UX:*:*) HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` case "${UNAME_MACHINE}" in 9000/31? ) HP_ARCH=m68000 ;; 9000/[34]?? ) HP_ARCH=m68k ;; 9000/[678][0-9][0-9]) if [ -x /usr/bin/getconf ]; then sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` case "${sc_cpu_version}" in 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 532) # CPU_PA_RISC2_0 case "${sc_kernel_bits}" in 32) HP_ARCH="hppa2.0n" ;; 64) HP_ARCH="hppa2.0w" ;; '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20 esac ;; esac fi if [ "${HP_ARCH}" = "" ]; then eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #define _HPUX_SOURCE #include #include int main () { #if defined(_SC_KERNEL_BITS) long bits = sysconf(_SC_KERNEL_BITS); #endif long cpu = sysconf (_SC_CPU_VERSION); switch (cpu) { case CPU_PA_RISC1_0: puts ("hppa1.0"); break; case CPU_PA_RISC1_1: puts ("hppa1.1"); break; case CPU_PA_RISC2_0: #if defined(_SC_KERNEL_BITS) switch (bits) { case 64: puts ("hppa2.0w"); break; case 32: puts ("hppa2.0n"); break; default: puts ("hppa2.0"); break; } break; #else /* !defined(_SC_KERNEL_BITS) */ puts ("hppa2.0"); break; #endif default: puts ("hppa1.0"); break; } exit (0); } EOF (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` test -z "$HP_ARCH" && HP_ARCH=hppa fi ;; esac if [ ${HP_ARCH} = "hppa2.0w" ] then eval $set_cc_for_build # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler # generating 64-bit code. GNU and HP use different nomenclature: # # $ CC_FOR_BUILD=cc ./config.guess # => hppa2.0w-hp-hpux11.23 # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess # => hppa64-hp-hpux11.23 if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | grep __LP64__ >/dev/null then HP_ARCH="hppa2.0w" else HP_ARCH="hppa64" fi fi echo ${HP_ARCH}-hp-hpux${HPUX_REV} exit ;; ia64:HP-UX:*:*) HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` echo ia64-hp-hpux${HPUX_REV} exit ;; 3050*:HI-UX:*:*) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #include int main () { long cpu = sysconf (_SC_CPU_VERSION); /* The order matters, because CPU_IS_HP_MC68K erroneously returns true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct results, however. */ if (CPU_IS_PA_RISC (cpu)) { switch (cpu) { case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; default: puts ("hppa-hitachi-hiuxwe2"); break; } } else if (CPU_IS_HP_MC68K (cpu)) puts ("m68k-hitachi-hiuxwe2"); else puts ("unknown-hitachi-hiuxwe2"); exit (0); } EOF $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` && { echo "$SYSTEM_NAME"; exit; } echo unknown-hitachi-hiuxwe2 exit ;; 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) echo hppa1.1-hp-bsd exit ;; 9000/8??:4.3bsd:*:*) echo hppa1.0-hp-bsd exit ;; *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) echo hppa1.0-hp-mpeix exit ;; hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) echo hppa1.1-hp-osf exit ;; hp8??:OSF1:*:*) echo hppa1.0-hp-osf exit ;; i*86:OSF1:*:*) if [ -x /usr/sbin/sysversion ] ; then echo ${UNAME_MACHINE}-unknown-osf1mk else echo ${UNAME_MACHINE}-unknown-osf1 fi exit ;; parisc*:Lites*:*:*) echo hppa1.1-hp-lites exit ;; C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) echo c1-convex-bsd exit ;; C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) if getsysinfo -f scalar_acc then echo c32-convex-bsd else echo c2-convex-bsd fi exit ;; C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) echo c34-convex-bsd exit ;; C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) echo c38-convex-bsd exit ;; C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) echo c4-convex-bsd exit ;; CRAY*Y-MP:*:*:*) echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*[A-Z]90:*:*:*) echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ -e 's/\.[^.]*$/.X/' exit ;; CRAY*TS:*:*:*) echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*T3E:*:*:*) echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*SV1:*:*:*) echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; *:UNICOS/mp:*:*) echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit ;; 5000:UNIX_System_V:4.*:*) FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'` echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit ;; i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} exit ;; sparc*:BSD/OS:*:*) echo sparc-unknown-bsdi${UNAME_RELEASE} exit ;; *:BSD/OS:*:*) echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} exit ;; *:FreeBSD:*:*) case ${UNAME_MACHINE} in pc98) echo i386-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; amd64) echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; *) echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; esac exit ;; i*:CYGWIN*:*) echo ${UNAME_MACHINE}-pc-cygwin exit ;; i*:MINGW*:*) echo ${UNAME_MACHINE}-pc-mingw32 exit ;; i*:windows32*:*) # uname -m includes "-pc" on this system. echo ${UNAME_MACHINE}-mingw32 exit ;; i*:PW*:*) echo ${UNAME_MACHINE}-pc-pw32 exit ;; x86:Interix*:[3456]*) echo i586-pc-interix${UNAME_RELEASE} exit ;; EM64T:Interix*:[3456]*) echo x86_64-unknown-interix${UNAME_RELEASE} exit ;; [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) echo i${UNAME_MACHINE}-pc-mks exit ;; i*:Windows_NT*:* | Pentium*:Windows_NT*:*) # How do we know it's Interix rather than the generic POSIX subsystem? # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we # UNAME_MACHINE based on the output of uname instead of i386? echo i586-pc-interix exit ;; i*:UWIN*:*) echo ${UNAME_MACHINE}-pc-uwin exit ;; amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) echo x86_64-unknown-cygwin exit ;; p*:CYGWIN*:*) echo powerpcle-unknown-cygwin exit ;; prep*:SunOS:5.*:*) echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; *:GNU:*:*) # the GNU system echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` exit ;; *:GNU/*:*:*) # other systems with GNU libc and userland echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu exit ;; i*86:Minix:*:*) echo ${UNAME_MACHINE}-pc-minix exit ;; arm*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; avr32*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; cris:Linux:*:*) echo cris-axis-linux-gnu exit ;; crisv32:Linux:*:*) echo crisv32-axis-linux-gnu exit ;; frv:Linux:*:*) echo frv-unknown-linux-gnu exit ;; ia64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; m32r*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; m68*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; mips:Linux:*:*) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #undef CPU #undef mips #undef mipsel #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) CPU=mipsel #else #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) CPU=mips #else CPU= #endif #endif EOF eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n ' /^CPU/{ s: ::g p }'`" test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; } ;; mips64:Linux:*:*) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #undef CPU #undef mips64 #undef mips64el #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) CPU=mips64el #else #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) CPU=mips64 #else CPU= #endif #endif EOF eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n ' /^CPU/{ s: ::g p }'`" test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; } ;; or32:Linux:*:*) echo or32-unknown-linux-gnu exit ;; ppc:Linux:*:*) echo powerpc-unknown-linux-gnu exit ;; ppc64:Linux:*:*) echo powerpc64-unknown-linux-gnu exit ;; alpha:Linux:*:*) case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in EV5) UNAME_MACHINE=alphaev5 ;; EV56) UNAME_MACHINE=alphaev56 ;; PCA56) UNAME_MACHINE=alphapca56 ;; PCA57) UNAME_MACHINE=alphapca56 ;; EV6) UNAME_MACHINE=alphaev6 ;; EV67) UNAME_MACHINE=alphaev67 ;; EV68*) UNAME_MACHINE=alphaev68 ;; esac objdump --private-headers /bin/sh | grep ld.so.1 >/dev/null if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} exit ;; parisc:Linux:*:* | hppa:Linux:*:*) # Look for CPU level case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in PA7*) echo hppa1.1-unknown-linux-gnu ;; PA8*) echo hppa2.0-unknown-linux-gnu ;; *) echo hppa-unknown-linux-gnu ;; esac exit ;; parisc64:Linux:*:* | hppa64:Linux:*:*) echo hppa64-unknown-linux-gnu exit ;; s390:Linux:*:* | s390x:Linux:*:*) echo ${UNAME_MACHINE}-ibm-linux exit ;; sh64*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; sh*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; sparc:Linux:*:* | sparc64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; vax:Linux:*:*) echo ${UNAME_MACHINE}-dec-linux-gnu exit ;; x86_64:Linux:*:*) echo x86_64-unknown-linux-gnu exit ;; i*86:Linux:*:*) # The BFD linker knows what the default object file format is, so # first see if it will tell us. cd to the root directory to prevent # problems with other programs or directories called `ld' in the path. # Set LC_ALL=C to ensure ld outputs messages in English. ld_supported_targets=`cd /; LC_ALL=C ld --help 2>&1 \ | sed -ne '/supported targets:/!d s/[ ][ ]*/ /g s/.*supported targets: *// s/ .*// p'` case "$ld_supported_targets" in elf32-i386) TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu" ;; a.out-i386-linux) echo "${UNAME_MACHINE}-pc-linux-gnuaout" exit ;; coff-i386) echo "${UNAME_MACHINE}-pc-linux-gnucoff" exit ;; "") # Either a pre-BFD a.out linker (linux-gnuoldld) or # one that does not give us useful --help. echo "${UNAME_MACHINE}-pc-linux-gnuoldld" exit ;; esac # Determine whether the default compiler is a.out or elf eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #include #ifdef __ELF__ # ifdef __GLIBC__ # if __GLIBC__ >= 2 LIBC=gnu # else LIBC=gnulibc1 # endif # else LIBC=gnulibc1 # endif #else #if defined(__INTEL_COMPILER) || defined(__PGI) || defined(__SUNPRO_C) || defined(__SUNPRO_CC) LIBC=gnu #else LIBC=gnuaout #endif #endif #ifdef __dietlibc__ LIBC=dietlibc #endif EOF eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n ' /^LIBC/{ s: ::g p }'`" test x"${LIBC}" != x && { echo "${UNAME_MACHINE}-pc-linux-${LIBC}" exit } test x"${TENTATIVE}" != x && { echo "${TENTATIVE}"; exit; } ;; i*86:DYNIX/ptx:4*:*) # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. # earlier versions are messed up and put the nodename in both # sysname and nodename. echo i386-sequent-sysv4 exit ;; i*86:UNIX_SV:4.2MP:2.*) # Unixware is an offshoot of SVR4, but it has its own version # number series starting with 2... # I am not positive that other SVR4 systems won't match this, # I just have to hope. -- rms. # Use sysv4.2uw... so that sysv4* matches it. echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} exit ;; i*86:OS/2:*:*) # If we were able to find `uname', then EMX Unix compatibility # is probably installed. echo ${UNAME_MACHINE}-pc-os2-emx exit ;; i*86:XTS-300:*:STOP) echo ${UNAME_MACHINE}-unknown-stop exit ;; i*86:atheos:*:*) echo ${UNAME_MACHINE}-unknown-atheos exit ;; i*86:syllable:*:*) echo ${UNAME_MACHINE}-pc-syllable exit ;; i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*) echo i386-unknown-lynxos${UNAME_RELEASE} exit ;; i*86:*DOS:*:*) echo ${UNAME_MACHINE}-pc-msdosdjgpp exit ;; i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} else echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} fi exit ;; i*86:*:5:[678]*) # UnixWare 7.x, OpenUNIX and OpenServer 6. case `/bin/uname -X | grep "^Machine"` in *486*) UNAME_MACHINE=i486 ;; *Pentium) UNAME_MACHINE=i586 ;; *Pent*|*Celeron) UNAME_MACHINE=i686 ;; esac echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} exit ;; i*86:*:3.2:*) if test -f /usr/options/cb.name; then UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \ && UNAME_MACHINE=i586 (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \ && UNAME_MACHINE=i686 (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ && UNAME_MACHINE=i686 echo ${UNAME_MACHINE}-pc-sco$UNAME_REL else echo ${UNAME_MACHINE}-pc-sysv32 fi exit ;; pc:*:*:*) # Left here for compatibility: # uname -m prints for DJGPP always 'pc', but it prints nothing about # the processor, so we play safe by assuming i386. echo i386-pc-msdosdjgpp exit ;; Intel:Mach:3*:*) echo i386-pc-mach3 exit ;; paragon:*:*:*) echo i860-intel-osf1 exit ;; i860:*:4.*:*) # i860-SVR4 if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 else # Add other i860-SVR4 vendors below as they are discovered. echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 fi exit ;; mini*:CTIX:SYS*5:*) # "miniframe" echo m68010-convergent-sysv exit ;; mc68k:UNIX:SYSTEM5:3.51m) echo m68k-convergent-sysv exit ;; M680?0:D-NIX:5.3:*) echo m68k-diab-dnix exit ;; M68*:*:R3V[5678]*:*) test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;; 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0) OS_REL='' test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4.3${OS_REL}; exit; } /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4; exit; } ;; m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) echo m68k-unknown-lynxos${UNAME_RELEASE} exit ;; mc68030:UNIX_System_V:4.*:*) echo m68k-atari-sysv4 exit ;; TSUNAMI:LynxOS:2.*:*) echo sparc-unknown-lynxos${UNAME_RELEASE} exit ;; rs6000:LynxOS:2.*:*) echo rs6000-unknown-lynxos${UNAME_RELEASE} exit ;; PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.0*:*) echo powerpc-unknown-lynxos${UNAME_RELEASE} exit ;; SM[BE]S:UNIX_SV:*:*) echo mips-dde-sysv${UNAME_RELEASE} exit ;; RM*:ReliantUNIX-*:*:*) echo mips-sni-sysv4 exit ;; RM*:SINIX-*:*:*) echo mips-sni-sysv4 exit ;; *:SINIX-*:*:*) if uname -p 2>/dev/null >/dev/null ; then UNAME_MACHINE=`(uname -p) 2>/dev/null` echo ${UNAME_MACHINE}-sni-sysv4 else echo ns32k-sni-sysv fi exit ;; PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort # says echo i586-unisys-sysv4 exit ;; *:UNIX_System_V:4*:FTX*) # From Gerald Hewes . # How about differentiating between stratus architectures? -djm echo hppa1.1-stratus-sysv4 exit ;; *:*:*:FTX*) # From seanf@swdc.stratus.com. echo i860-stratus-sysv4 exit ;; i*86:VOS:*:*) # From Paul.Green@stratus.com. echo ${UNAME_MACHINE}-stratus-vos exit ;; *:VOS:*:*) # From Paul.Green@stratus.com. echo hppa1.1-stratus-vos exit ;; mc68*:A/UX:*:*) echo m68k-apple-aux${UNAME_RELEASE} exit ;; news*:NEWS-OS:6*:*) echo mips-sony-newsos6 exit ;; R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) if [ -d /usr/nec ]; then echo mips-nec-sysv${UNAME_RELEASE} else echo mips-unknown-sysv${UNAME_RELEASE} fi exit ;; BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. echo powerpc-be-beos exit ;; BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. echo powerpc-apple-beos exit ;; BePC:BeOS:*:*) # BeOS running on Intel PC compatible. echo i586-pc-beos exit ;; SX-4:SUPER-UX:*:*) echo sx4-nec-superux${UNAME_RELEASE} exit ;; SX-5:SUPER-UX:*:*) echo sx5-nec-superux${UNAME_RELEASE} exit ;; SX-6:SUPER-UX:*:*) echo sx6-nec-superux${UNAME_RELEASE} exit ;; Power*:Rhapsody:*:*) echo powerpc-apple-rhapsody${UNAME_RELEASE} exit ;; *:Rhapsody:*:*) echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} exit ;; *:Darwin:*:*) UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown case $UNAME_PROCESSOR in unknown) UNAME_PROCESSOR=powerpc ;; esac echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} exit ;; *:procnto*:*:* | *:QNX:[0123456789]*:*) UNAME_PROCESSOR=`uname -p` if test "$UNAME_PROCESSOR" = "x86"; then UNAME_PROCESSOR=i386 UNAME_MACHINE=pc fi echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} exit ;; *:QNX:*:4*) echo i386-pc-qnx exit ;; NSE-?:NONSTOP_KERNEL:*:*) echo nse-tandem-nsk${UNAME_RELEASE} exit ;; NSR-?:NONSTOP_KERNEL:*:*) echo nsr-tandem-nsk${UNAME_RELEASE} exit ;; *:NonStop-UX:*:*) echo mips-compaq-nonstopux exit ;; BS2000:POSIX*:*:*) echo bs2000-siemens-sysv exit ;; DS/*:UNIX_System_V:*:*) echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} exit ;; *:Plan9:*:*) # "uname -m" is not consistent, so use $cputype instead. 386 # is converted to i386 for consistency with other x86 # operating systems. if test "$cputype" = "386"; then UNAME_MACHINE=i386 else UNAME_MACHINE="$cputype" fi echo ${UNAME_MACHINE}-unknown-plan9 exit ;; *:TOPS-10:*:*) echo pdp10-unknown-tops10 exit ;; *:TENEX:*:*) echo pdp10-unknown-tenex exit ;; KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) echo pdp10-dec-tops20 exit ;; XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) echo pdp10-xkl-tops20 exit ;; *:TOPS-20:*:*) echo pdp10-unknown-tops20 exit ;; *:ITS:*:*) echo pdp10-unknown-its exit ;; SEI:*:*:SEIUX) echo mips-sei-seiux${UNAME_RELEASE} exit ;; *:DragonFly:*:*) echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` exit ;; *:*VMS:*:*) UNAME_MACHINE=`(uname -p) 2>/dev/null` case "${UNAME_MACHINE}" in A*) echo alpha-dec-vms ; exit ;; I*) echo ia64-dec-vms ; exit ;; V*) echo vax-dec-vms ; exit ;; esac ;; *:XENIX:*:SysV) echo i386-pc-xenix exit ;; i*86:skyos:*:*) echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//' exit ;; i*86:rdos:*:*) echo ${UNAME_MACHINE}-pc-rdos exit ;; esac #echo '(No uname command or uname output not recognized.)' 1>&2 #echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2 eval $set_cc_for_build cat >$dummy.c < # include #endif main () { #if defined (sony) #if defined (MIPSEB) /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, I don't know.... */ printf ("mips-sony-bsd\n"); exit (0); #else #include printf ("m68k-sony-newsos%s\n", #ifdef NEWSOS4 "4" #else "" #endif ); exit (0); #endif #endif #if defined (__arm) && defined (__acorn) && defined (__unix) printf ("arm-acorn-riscix\n"); exit (0); #endif #if defined (hp300) && !defined (hpux) printf ("m68k-hp-bsd\n"); exit (0); #endif #if defined (NeXT) #if !defined (__ARCHITECTURE__) #define __ARCHITECTURE__ "m68k" #endif int version; version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; if (version < 4) printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); else printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version); exit (0); #endif #if defined (MULTIMAX) || defined (n16) #if defined (UMAXV) printf ("ns32k-encore-sysv\n"); exit (0); #else #if defined (CMU) printf ("ns32k-encore-mach\n"); exit (0); #else printf ("ns32k-encore-bsd\n"); exit (0); #endif #endif #endif #if defined (__386BSD__) printf ("i386-pc-bsd\n"); exit (0); #endif #if defined (sequent) #if defined (i386) printf ("i386-sequent-dynix\n"); exit (0); #endif #if defined (ns32000) printf ("ns32k-sequent-dynix\n"); exit (0); #endif #endif #if defined (_SEQUENT_) struct utsname un; uname(&un); if (strncmp(un.version, "V2", 2) == 0) { printf ("i386-sequent-ptx2\n"); exit (0); } if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ printf ("i386-sequent-ptx1\n"); exit (0); } printf ("i386-sequent-ptx\n"); exit (0); #endif #if defined (vax) # if !defined (ultrix) # include # if defined (BSD) # if BSD == 43 printf ("vax-dec-bsd4.3\n"); exit (0); # else # if BSD == 199006 printf ("vax-dec-bsd4.3reno\n"); exit (0); # else printf ("vax-dec-bsd\n"); exit (0); # endif # endif # else printf ("vax-dec-bsd\n"); exit (0); # endif # else printf ("vax-dec-ultrix\n"); exit (0); # endif #endif #if defined (alliant) && defined (i860) printf ("i860-alliant-bsd\n"); exit (0); #endif exit (1); } EOF $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && SYSTEM_NAME=`$dummy` && { echo "$SYSTEM_NAME"; exit; } # Apollos put the system type in the environment. test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; } # Convex versions that predate uname can use getsysinfo(1) if [ -x /usr/convex/getsysinfo ] then case `getsysinfo -f cpu_type` in c1*) echo c1-convex-bsd exit ;; c2*) if getsysinfo -f scalar_acc then echo c32-convex-bsd else echo c2-convex-bsd fi exit ;; c34*) echo c34-convex-bsd exit ;; c38*) echo c38-convex-bsd exit ;; c4*) echo c4-convex-bsd exit ;; esac fi cat >&2 < in order to provide the needed information to handle your system. config.guess timestamp = $timestamp uname -m = `(uname -m) 2>/dev/null || echo unknown` uname -r = `(uname -r) 2>/dev/null || echo unknown` uname -s = `(uname -s) 2>/dev/null || echo unknown` uname -v = `(uname -v) 2>/dev/null || echo unknown` /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null` /bin/uname -X = `(/bin/uname -X) 2>/dev/null` hostinfo = `(hostinfo) 2>/dev/null` /bin/universe = `(/bin/universe) 2>/dev/null` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null` /bin/arch = `(/bin/arch) 2>/dev/null` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` UNAME_MACHINE = ${UNAME_MACHINE} UNAME_RELEASE = ${UNAME_RELEASE} UNAME_SYSTEM = ${UNAME_SYSTEM} UNAME_VERSION = ${UNAME_VERSION} EOF exit 1 # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" # End: jed-0.99-19/autoconf/install.sh0000755002657400265740000001273611311317447015326 0ustar davisdavis#!/bin/sh # # install - install a program, script, or datafile # This comes from X11R5 (mit/util/scripts/install.sh). # # Copyright 1991 by the Massachusetts Institute of Technology # # Permission to use, copy, modify, distribute, and sell this software and its # documentation for any purpose is hereby granted without fee, provided that # the above copyright notice appear in all copies and that both that # copyright notice and this permission notice appear in supporting # documentation, and that the name of M.I.T. not be used in advertising or # publicity pertaining to distribution of the software without specific, # written prior permission. M.I.T. makes no representations about the # suitability of this software for any purpose. It is provided "as is" # without express or implied warranty. # # Calling this script install-sh is preferred over install.sh, to prevent # `make' implicit rules from creating a file called install from it # when there is no Makefile. # # This script is compatible with the BSD install script, but was written # from scratch. It can only install one file at a time, a restriction # shared with many OS's install programs. # set DOITPROG to echo to test this script # Don't use :- since 4.3BSD and earlier shells don't like it. doit="${DOITPROG-}" # put in absolute paths if you don't have them in your path; or use env. vars. mvprog="${MVPROG-mv}" cpprog="${CPPROG-cp}" chmodprog="${CHMODPROG-chmod}" chownprog="${CHOWNPROG-chown}" chgrpprog="${CHGRPPROG-chgrp}" stripprog="${STRIPPROG-strip}" rmprog="${RMPROG-rm}" mkdirprog="${MKDIRPROG-mkdir}" transformbasename="" transform_arg="" instcmd="$mvprog" chmodcmd="$chmodprog 0755" chowncmd="" chgrpcmd="" stripcmd="" rmcmd="$rmprog -f" mvcmd="$mvprog" src="" dst="" dir_arg="" while [ x"$1" != x ]; do case $1 in -c) instcmd="$cpprog" shift continue;; -d) dir_arg=true shift continue;; -m) chmodcmd="$chmodprog $2" shift shift continue;; -o) chowncmd="$chownprog $2" shift shift continue;; -g) chgrpcmd="$chgrpprog $2" shift shift continue;; -s) stripcmd="$stripprog" shift continue;; -t=*) transformarg=`echo $1 | sed 's/-t=//'` shift continue;; -b=*) transformbasename=`echo $1 | sed 's/-b=//'` shift continue;; *) if [ x"$src" = x ] then src=$1 else # this colon is to work around a 386BSD /bin/sh bug : dst=$1 fi shift continue;; esac done if [ x"$src" = x ] then echo "install: no input file specified" exit 1 else true fi if [ x"$dir_arg" != x ]; then dst=$src src="" if [ -d $dst ]; then instcmd=: chmodcmd="" else instcmd=mkdir fi else # Waiting for this to be detected by the "$instcmd $src $dsttmp" command # might cause directories to be created, which would be especially bad # if $src (and thus $dsttmp) contains '*'. if [ -f $src -o -d $src ] then true else echo "install: $src does not exist" exit 1 fi if [ x"$dst" = x ] then echo "install: no destination specified" exit 1 else true fi # If destination is a directory, append the input filename; if your system # does not like double slashes in filenames, you may need to add some logic if [ -d $dst ] then dst="$dst"/`basename $src` else true fi fi ## this sed command emulates the dirname command dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'` # Make sure that the destination directory exists. # this part is taken from Noah Friedman's mkinstalldirs script # Skip lots of stat calls in the usual case. if [ ! -d "$dstdir" ]; then defaultIFS=' ' IFS="${IFS-${defaultIFS}}" oIFS="${IFS}" # Some sh's can't handle IFS=/ for some reason. IFS='%' set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'` IFS="${oIFS}" pathcomp='' while [ $# -ne 0 ] ; do pathcomp="${pathcomp}${1}" shift if [ ! -d "${pathcomp}" ] ; then $mkdirprog "${pathcomp}" else true fi pathcomp="${pathcomp}/" done fi if [ x"$dir_arg" != x ] then $doit $instcmd $dst && if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi && if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi && if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi && if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi else # If we're going to rename the final executable, determine the name now. if [ x"$transformarg" = x ] then dstfile=`basename $dst` else dstfile=`basename $dst $transformbasename | sed $transformarg`$transformbasename fi # don't allow the sed command to completely eliminate the filename if [ x"$dstfile" = x ] then dstfile=`basename $dst` else true fi # Make a temp file name in the proper directory. dsttmp=$dstdir/#inst.$$# # Move or copy the file name to the temp name $doit $instcmd $src $dsttmp && trap "rm -f ${dsttmp}" 0 && # and set any options; do chmod last to preserve setuid bits # If any of these fail, we abort the whole thing. If we want to # ignore errors from any of these, just make sure not to ignore # errors from the above "$doit $instcmd $src $dsttmp" command. if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi && if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi && if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi && if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi && # Now rename the file to the real destination. $doit $rmcmd -f $dstdir/$dstfile && $doit $mvcmd $dsttmp $dstdir/$dstfile fi && exit 0 jed-0.99-19/autoconf/mkinsdir.sh0000755002657400265740000000113611311317447015470 0ustar davisdavis#! /bin/sh # mkinstalldirs --- make directory hierarchy # Author: Noah Friedman # Created: 1993-05-16 # Public domain errstatus=0 for file do set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'` shift pathcomp= for d in ${1+"$@"} ; do pathcomp="$pathcomp$d" case "$pathcomp" in -* ) pathcomp=./$pathcomp ;; esac if test ! -d "$pathcomp"; then echo "mkdir $pathcomp" 1>&2 mkdir "$pathcomp" || errstatus=$? fi pathcomp="$pathcomp/" done done exit $errstatus # mkinstalldirs ends here jed-0.99-19/autoconf/Makefile0000644002657400265740000000047311311317447014754 0ustar davisdavis../configure: aclocal.m4 configure.ac /bin/rm -rf autom4te.cache autoconf && mv ./configure .. update: config.sub config.guess config.guess: /usr/share/misc/config.guess /bin/cp -f /usr/share/misc/config.guess config.guess config.sub: /usr/share/misc/config.sub /bin/cp -f /usr/share/misc/config.sub config.sub jed-0.99-19/autoconf/config.sub0000755002657400265740000007730011311317447015302 0ustar davisdavis#! /bin/sh # Configuration validation subroutine script. # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, # 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, # Inc. timestamp='2006-07-02' # This file is (in principle) common to ALL GNU software. # The presence of a machine in this file suggests that SOME GNU software # can handle that machine. It does not imply ALL GNU software can. # # This file is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA # 02110-1301, USA. # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # Please send patches to . Submit a context # diff and a properly formatted ChangeLog entry. # # Configuration subroutine to validate and canonicalize a configuration type. # Supply the specified configuration type as an argument. # If it is invalid, we print an error message on stderr and exit with code 1. # Otherwise, we print the canonical config type on stdout and succeed. # This file is supposed to be the same for all GNU packages # and recognize all the CPU types, system types and aliases # that are meaningful with *any* GNU software. # Each package is responsible for reporting which valid configurations # it does not support. The user should be able to distinguish # a failure to support a valid configuration from a meaningless # configuration. # The goal of this file is to map all the various variations of a given # machine specification into a single specification in the form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM # or in some cases, the newer four-part form: # CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM # It is wrong to echo any other type of specification. me=`echo "$0" | sed -e 's,.*/,,'` usage="\ Usage: $0 [OPTION] CPU-MFR-OPSYS $0 [OPTION] ALIAS Canonicalize a configuration name. Operation modes: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit Report bugs and patches to ." version="\ GNU config.sub ($timestamp) Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." help=" Try \`$me --help' for more information." # Parse command line while test $# -gt 0 ; do case $1 in --time-stamp | --time* | -t ) echo "$timestamp" ; exit ;; --version | -v ) echo "$version" ; exit ;; --help | --h* | -h ) echo "$usage"; exit ;; -- ) # Stop option processing shift; break ;; - ) # Use stdin as input. break ;; -* ) echo "$me: invalid option $1$help" exit 1 ;; *local*) # First pass through any local machine types. echo $1 exit ;; * ) break ;; esac done case $# in 0) echo "$me: missing argument$help" >&2 exit 1;; 1) ;; *) echo "$me: too many arguments$help" >&2 exit 1;; esac # Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). # Here we must recognize all the valid KERNEL-OS combinations. maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` case $maybe_os in nto-qnx* | linux-gnu* | linux-dietlibc | linux-newlib* | linux-uclibc* | \ uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | \ storm-chaos* | os2-emx* | rtmk-nova*) os=-$maybe_os basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` ;; *) basic_machine=`echo $1 | sed 's/-[^-]*$//'` if [ $basic_machine != $1 ] then os=`echo $1 | sed 's/.*-/-/'` else os=; fi ;; esac ### Let's recognize common machines as not being operating systems so ### that things like config.sub decstation-3100 work. We also ### recognize some manufacturers as not being operating systems, so we ### can provide default operating systems below. case $os in -sun*os*) # Prevent following clause from handling this invalid input. ;; -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ -apple | -axis | -knuth | -cray) os= basic_machine=$1 ;; -sim | -cisco | -oki | -wec | -winbond) os= basic_machine=$1 ;; -scout) ;; -wrs) os=-vxworks basic_machine=$1 ;; -chorusos*) os=-chorusos basic_machine=$1 ;; -chorusrdb) os=-chorusrdb basic_machine=$1 ;; -hiux*) os=-hiuxwe2 ;; -sco6) os=-sco5v6 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco5) os=-sco3.2v5 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco4) os=-sco3.2v4 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco3.2.[4-9]*) os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco3.2v[4-9]*) # Don't forget version if it is 3.2v4 or newer. basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco5v6*) # Don't forget version if it is 3.2v4 or newer. basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco*) os=-sco3.2v2 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -udk*) basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -isc) os=-isc2.2 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -clix*) basic_machine=clipper-intergraph ;; -isc*) basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -lynx*) os=-lynxos ;; -ptx*) basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` ;; -windowsnt*) os=`echo $os | sed -e 's/windowsnt/winnt/'` ;; -psos*) os=-psos ;; -mint | -mint[0-9]*) basic_machine=m68k-atari os=-mint ;; esac # Decode aliases for certain CPU-COMPANY combinations. case $basic_machine in # Recognize the basic CPU types without company name. # Some are omitted here because they have special meanings below. 1750a | 580 \ | a29k \ | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ | am33_2.0 \ | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr | avr32 \ | bfin \ | c4x | clipper \ | d10v | d30v | dlx | dsp16xx \ | fr30 | frv \ | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ | i370 | i860 | i960 | ia64 \ | ip2k | iq2000 \ | m32c | m32r | m32rle | m68000 | m68k | m88k \ | maxq | mb | microblaze | mcore \ | mips | mipsbe | mipseb | mipsel | mipsle \ | mips16 \ | mips64 | mips64el \ | mips64vr | mips64vrel \ | mips64orion | mips64orionel \ | mips64vr4100 | mips64vr4100el \ | mips64vr4300 | mips64vr4300el \ | mips64vr5000 | mips64vr5000el \ | mips64vr5900 | mips64vr5900el \ | mipsisa32 | mipsisa32el \ | mipsisa32r2 | mipsisa32r2el \ | mipsisa64 | mipsisa64el \ | mipsisa64r2 | mipsisa64r2el \ | mipsisa64sb1 | mipsisa64sb1el \ | mipsisa64sr71k | mipsisa64sr71kel \ | mipstx39 | mipstx39el \ | mn10200 | mn10300 \ | mt \ | msp430 \ | nios | nios2 \ | ns16k | ns32k \ | or32 \ | pdp10 | pdp11 | pj | pjl \ | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \ | pyramid \ | sh | sh[1234] | sh[24]a | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ | sh64 | sh64le \ | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \ | sparcv8 | sparcv9 | sparcv9b | sparcv9v \ | spu | strongarm \ | tahoe | thumb | tic4x | tic80 | tron \ | v850 | v850e \ | we32k \ | x86 | xscale | xscalee[bl] | xstormy16 | xtensa \ | z8k) basic_machine=$basic_machine-unknown ;; m6811 | m68hc11 | m6812 | m68hc12) # Motorola 68HC11/12. basic_machine=$basic_machine-unknown os=-none ;; m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) ;; ms1) basic_machine=mt-unknown ;; # We use `pc' rather than `unknown' # because (1) that's what they normally are, and # (2) the word "unknown" tends to confuse beginning users. i*86 | x86_64) basic_machine=$basic_machine-pc ;; # Object if more than one company name word. *-*-*) echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 exit 1 ;; # Recognize the basic CPU types with company name. 580-* \ | a29k-* \ | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \ | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ | avr-* | avr32-* \ | bfin-* | bs2000-* \ | c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \ | clipper-* | craynv-* | cydra-* \ | d10v-* | d30v-* | dlx-* \ | elxsi-* \ | f30[01]-* | f700-* | fr30-* | frv-* | fx80-* \ | h8300-* | h8500-* \ | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ | i*86-* | i860-* | i960-* | ia64-* \ | ip2k-* | iq2000-* \ | m32c-* | m32r-* | m32rle-* \ | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ | m88110-* | m88k-* | maxq-* | mcore-* \ | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ | mips16-* \ | mips64-* | mips64el-* \ | mips64vr-* | mips64vrel-* \ | mips64orion-* | mips64orionel-* \ | mips64vr4100-* | mips64vr4100el-* \ | mips64vr4300-* | mips64vr4300el-* \ | mips64vr5000-* | mips64vr5000el-* \ | mips64vr5900-* | mips64vr5900el-* \ | mipsisa32-* | mipsisa32el-* \ | mipsisa32r2-* | mipsisa32r2el-* \ | mipsisa64-* | mipsisa64el-* \ | mipsisa64r2-* | mipsisa64r2el-* \ | mipsisa64sb1-* | mipsisa64sb1el-* \ | mipsisa64sr71k-* | mipsisa64sr71kel-* \ | mipstx39-* | mipstx39el-* \ | mmix-* \ | mt-* \ | msp430-* \ | nios-* | nios2-* \ | none-* | np1-* | ns16k-* | ns32k-* \ | orion-* \ | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \ | pyramid-* \ | romp-* | rs6000-* \ | sh-* | sh[1234]-* | sh[24]a-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \ | sparclite-* \ | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | strongarm-* | sv1-* | sx?-* \ | tahoe-* | thumb-* \ | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ | tron-* \ | v850-* | v850e-* | vax-* \ | we32k-* \ | x86-* | x86_64-* | xps100-* | xscale-* | xscalee[bl]-* \ | xstormy16-* | xtensa-* \ | ymp-* \ | z8k-*) ;; # Recognize the various machine names and aliases which stand # for a CPU type and a company and sometimes even an OS. 386bsd) basic_machine=i386-unknown os=-bsd ;; 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) basic_machine=m68000-att ;; 3b*) basic_machine=we32k-att ;; a29khif) basic_machine=a29k-amd os=-udi ;; abacus) basic_machine=abacus-unknown ;; adobe68k) basic_machine=m68010-adobe os=-scout ;; alliant | fx80) basic_machine=fx80-alliant ;; altos | altos3068) basic_machine=m68k-altos ;; am29k) basic_machine=a29k-none os=-bsd ;; amd64) basic_machine=x86_64-pc ;; amd64-*) basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'` ;; amdahl) basic_machine=580-amdahl os=-sysv ;; amiga | amiga-*) basic_machine=m68k-unknown ;; amigaos | amigados) basic_machine=m68k-unknown os=-amigaos ;; amigaunix | amix) basic_machine=m68k-unknown os=-sysv4 ;; apollo68) basic_machine=m68k-apollo os=-sysv ;; apollo68bsd) basic_machine=m68k-apollo os=-bsd ;; aux) basic_machine=m68k-apple os=-aux ;; balance) basic_machine=ns32k-sequent os=-dynix ;; c90) basic_machine=c90-cray os=-unicos ;; convex-c1) basic_machine=c1-convex os=-bsd ;; convex-c2) basic_machine=c2-convex os=-bsd ;; convex-c32) basic_machine=c32-convex os=-bsd ;; convex-c34) basic_machine=c34-convex os=-bsd ;; convex-c38) basic_machine=c38-convex os=-bsd ;; cray | j90) basic_machine=j90-cray os=-unicos ;; craynv) basic_machine=craynv-cray os=-unicosmp ;; cr16c) basic_machine=cr16c-unknown os=-elf ;; crds | unos) basic_machine=m68k-crds ;; crisv32 | crisv32-* | etraxfs*) basic_machine=crisv32-axis ;; cris | cris-* | etrax*) basic_machine=cris-axis ;; crx) basic_machine=crx-unknown os=-elf ;; da30 | da30-*) basic_machine=m68k-da30 ;; decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) basic_machine=mips-dec ;; decsystem10* | dec10*) basic_machine=pdp10-dec os=-tops10 ;; decsystem20* | dec20*) basic_machine=pdp10-dec os=-tops20 ;; delta | 3300 | motorola-3300 | motorola-delta \ | 3300-motorola | delta-motorola) basic_machine=m68k-motorola ;; delta88) basic_machine=m88k-motorola os=-sysv3 ;; djgpp) basic_machine=i586-pc os=-msdosdjgpp ;; dpx20 | dpx20-*) basic_machine=rs6000-bull os=-bosx ;; dpx2* | dpx2*-bull) basic_machine=m68k-bull os=-sysv3 ;; ebmon29k) basic_machine=a29k-amd os=-ebmon ;; elxsi) basic_machine=elxsi-elxsi os=-bsd ;; encore | umax | mmax) basic_machine=ns32k-encore ;; es1800 | OSE68k | ose68k | ose | OSE) basic_machine=m68k-ericsson os=-ose ;; fx2800) basic_machine=i860-alliant ;; genix) basic_machine=ns32k-ns ;; gmicro) basic_machine=tron-gmicro os=-sysv ;; go32) basic_machine=i386-pc os=-go32 ;; h3050r* | hiux*) basic_machine=hppa1.1-hitachi os=-hiuxwe2 ;; h8300hms) basic_machine=h8300-hitachi os=-hms ;; h8300xray) basic_machine=h8300-hitachi os=-xray ;; h8500hms) basic_machine=h8500-hitachi os=-hms ;; harris) basic_machine=m88k-harris os=-sysv3 ;; hp300-*) basic_machine=m68k-hp ;; hp300bsd) basic_machine=m68k-hp os=-bsd ;; hp300hpux) basic_machine=m68k-hp os=-hpux ;; hp3k9[0-9][0-9] | hp9[0-9][0-9]) basic_machine=hppa1.0-hp ;; hp9k2[0-9][0-9] | hp9k31[0-9]) basic_machine=m68000-hp ;; hp9k3[2-9][0-9]) basic_machine=m68k-hp ;; hp9k6[0-9][0-9] | hp6[0-9][0-9]) basic_machine=hppa1.0-hp ;; hp9k7[0-79][0-9] | hp7[0-79][0-9]) basic_machine=hppa1.1-hp ;; hp9k78[0-9] | hp78[0-9]) # FIXME: really hppa2.0-hp basic_machine=hppa1.1-hp ;; hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) # FIXME: really hppa2.0-hp basic_machine=hppa1.1-hp ;; hp9k8[0-9][13679] | hp8[0-9][13679]) basic_machine=hppa1.1-hp ;; hp9k8[0-9][0-9] | hp8[0-9][0-9]) basic_machine=hppa1.0-hp ;; hppa-next) os=-nextstep3 ;; hppaosf) basic_machine=hppa1.1-hp os=-osf ;; hppro) basic_machine=hppa1.1-hp os=-proelf ;; i370-ibm* | ibm*) basic_machine=i370-ibm ;; # I'm not sure what "Sysv32" means. Should this be sysv3.2? i*86v32) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv32 ;; i*86v4*) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv4 ;; i*86v) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv ;; i*86sol2) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-solaris2 ;; i386mach) basic_machine=i386-mach os=-mach ;; i386-vsta | vsta) basic_machine=i386-unknown os=-vsta ;; iris | iris4d) basic_machine=mips-sgi case $os in -irix*) ;; *) os=-irix4 ;; esac ;; isi68 | isi) basic_machine=m68k-isi os=-sysv ;; m88k-omron*) basic_machine=m88k-omron ;; magnum | m3230) basic_machine=mips-mips os=-sysv ;; merlin) basic_machine=ns32k-utek os=-sysv ;; mingw32) basic_machine=i386-pc os=-mingw32 ;; miniframe) basic_machine=m68000-convergent ;; *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) basic_machine=m68k-atari os=-mint ;; mips3*-*) basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` ;; mips3*) basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown ;; monitor) basic_machine=m68k-rom68k os=-coff ;; morphos) basic_machine=powerpc-unknown os=-morphos ;; msdos) basic_machine=i386-pc os=-msdos ;; ms1-*) basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'` ;; mvs) basic_machine=i370-ibm os=-mvs ;; ncr3000) basic_machine=i486-ncr os=-sysv4 ;; netbsd386) basic_machine=i386-unknown os=-netbsd ;; netwinder) basic_machine=armv4l-rebel os=-linux ;; news | news700 | news800 | news900) basic_machine=m68k-sony os=-newsos ;; news1000) basic_machine=m68030-sony os=-newsos ;; news-3600 | risc-news) basic_machine=mips-sony os=-newsos ;; necv70) basic_machine=v70-nec os=-sysv ;; next | m*-next ) basic_machine=m68k-next case $os in -nextstep* ) ;; -ns2*) os=-nextstep2 ;; *) os=-nextstep3 ;; esac ;; nh3000) basic_machine=m68k-harris os=-cxux ;; nh[45]000) basic_machine=m88k-harris os=-cxux ;; nindy960) basic_machine=i960-intel os=-nindy ;; mon960) basic_machine=i960-intel os=-mon960 ;; nonstopux) basic_machine=mips-compaq os=-nonstopux ;; np1) basic_machine=np1-gould ;; nsr-tandem) basic_machine=nsr-tandem ;; op50n-* | op60c-*) basic_machine=hppa1.1-oki os=-proelf ;; openrisc | openrisc-*) basic_machine=or32-unknown ;; os400) basic_machine=powerpc-ibm os=-os400 ;; OSE68000 | ose68000) basic_machine=m68000-ericsson os=-ose ;; os68k) basic_machine=m68k-none os=-os68k ;; pa-hitachi) basic_machine=hppa1.1-hitachi os=-hiuxwe2 ;; paragon) basic_machine=i860-intel os=-osf ;; pbd) basic_machine=sparc-tti ;; pbb) basic_machine=m68k-tti ;; pc532 | pc532-*) basic_machine=ns32k-pc532 ;; pc98) basic_machine=i386-pc ;; pc98-*) basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentium | p5 | k5 | k6 | nexgen | viac3) basic_machine=i586-pc ;; pentiumpro | p6 | 6x86 | athlon | athlon_*) basic_machine=i686-pc ;; pentiumii | pentium2 | pentiumiii | pentium3) basic_machine=i686-pc ;; pentium4) basic_machine=i786-pc ;; pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentiumpro-* | p6-* | 6x86-* | athlon-*) basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentium4-*) basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pn) basic_machine=pn-gould ;; power) basic_machine=power-ibm ;; ppc) basic_machine=powerpc-unknown ;; ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppcle | powerpclittle | ppc-le | powerpc-little) basic_machine=powerpcle-unknown ;; ppcle-* | powerpclittle-*) basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppc64) basic_machine=powerpc64-unknown ;; ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppc64le | powerpc64little | ppc64-le | powerpc64-little) basic_machine=powerpc64le-unknown ;; ppc64le-* | powerpc64little-*) basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ps2) basic_machine=i386-ibm ;; pw32) basic_machine=i586-unknown os=-pw32 ;; rdos) basic_machine=i386-pc os=-rdos ;; rom68k) basic_machine=m68k-rom68k os=-coff ;; rm[46]00) basic_machine=mips-siemens ;; rtpc | rtpc-*) basic_machine=romp-ibm ;; s390 | s390-*) basic_machine=s390-ibm ;; s390x | s390x-*) basic_machine=s390x-ibm ;; sa29200) basic_machine=a29k-amd os=-udi ;; sb1) basic_machine=mipsisa64sb1-unknown ;; sb1el) basic_machine=mipsisa64sb1el-unknown ;; sei) basic_machine=mips-sei os=-seiux ;; sequent) basic_machine=i386-sequent ;; sh) basic_machine=sh-hitachi os=-hms ;; sh64) basic_machine=sh64-unknown ;; sparclite-wrs | simso-wrs) basic_machine=sparclite-wrs os=-vxworks ;; sps7) basic_machine=m68k-bull os=-sysv2 ;; spur) basic_machine=spur-unknown ;; st2000) basic_machine=m68k-tandem ;; stratus) basic_machine=i860-stratus os=-sysv4 ;; sun2) basic_machine=m68000-sun ;; sun2os3) basic_machine=m68000-sun os=-sunos3 ;; sun2os4) basic_machine=m68000-sun os=-sunos4 ;; sun3os3) basic_machine=m68k-sun os=-sunos3 ;; sun3os4) basic_machine=m68k-sun os=-sunos4 ;; sun4os3) basic_machine=sparc-sun os=-sunos3 ;; sun4os4) basic_machine=sparc-sun os=-sunos4 ;; sun4sol2) basic_machine=sparc-sun os=-solaris2 ;; sun3 | sun3-*) basic_machine=m68k-sun ;; sun4) basic_machine=sparc-sun ;; sun386 | sun386i | roadrunner) basic_machine=i386-sun ;; sv1) basic_machine=sv1-cray os=-unicos ;; symmetry) basic_machine=i386-sequent os=-dynix ;; t3e) basic_machine=alphaev5-cray os=-unicos ;; t90) basic_machine=t90-cray os=-unicos ;; tic54x | c54x*) basic_machine=tic54x-unknown os=-coff ;; tic55x | c55x*) basic_machine=tic55x-unknown os=-coff ;; tic6x | c6x*) basic_machine=tic6x-unknown os=-coff ;; tx39) basic_machine=mipstx39-unknown ;; tx39el) basic_machine=mipstx39el-unknown ;; toad1) basic_machine=pdp10-xkl os=-tops20 ;; tower | tower-32) basic_machine=m68k-ncr ;; tpf) basic_machine=s390x-ibm os=-tpf ;; udi29k) basic_machine=a29k-amd os=-udi ;; ultra3) basic_machine=a29k-nyu os=-sym1 ;; v810 | necv810) basic_machine=v810-nec os=-none ;; vaxv) basic_machine=vax-dec os=-sysv ;; vms) basic_machine=vax-dec os=-vms ;; vpp*|vx|vx-*) basic_machine=f301-fujitsu ;; vxworks960) basic_machine=i960-wrs os=-vxworks ;; vxworks68) basic_machine=m68k-wrs os=-vxworks ;; vxworks29k) basic_machine=a29k-wrs os=-vxworks ;; w65*) basic_machine=w65-wdc os=-none ;; w89k-*) basic_machine=hppa1.1-winbond os=-proelf ;; xbox) basic_machine=i686-pc os=-mingw32 ;; xps | xps100) basic_machine=xps100-honeywell ;; ymp) basic_machine=ymp-cray os=-unicos ;; z8k-*-coff) basic_machine=z8k-unknown os=-sim ;; none) basic_machine=none-none os=-none ;; # Here we handle the default manufacturer of certain CPU types. It is in # some cases the only manufacturer, in others, it is the most popular. w89k) basic_machine=hppa1.1-winbond ;; op50n) basic_machine=hppa1.1-oki ;; op60c) basic_machine=hppa1.1-oki ;; romp) basic_machine=romp-ibm ;; mmix) basic_machine=mmix-knuth ;; rs6000) basic_machine=rs6000-ibm ;; vax) basic_machine=vax-dec ;; pdp10) # there are many clones, so DEC is not a safe bet basic_machine=pdp10-unknown ;; pdp11) basic_machine=pdp11-dec ;; we32k) basic_machine=we32k-att ;; sh[1234] | sh[24]a | sh[34]eb | sh[1234]le | sh[23]ele) basic_machine=sh-unknown ;; sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v) basic_machine=sparc-sun ;; cydra) basic_machine=cydra-cydrome ;; orion) basic_machine=orion-highlevel ;; orion105) basic_machine=clipper-highlevel ;; mac | mpw | mac-mpw) basic_machine=m68k-apple ;; pmac | pmac-mpw) basic_machine=powerpc-apple ;; *-unknown) # Make sure to match an already-canonicalized machine name. ;; *) echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 exit 1 ;; esac # Here we canonicalize certain aliases for manufacturers. case $basic_machine in *-digital*) basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` ;; *-commodore*) basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` ;; *) ;; esac # Decode manufacturer-specific aliases for certain operating systems. if [ x"$os" != x"" ] then case $os in # First match some system type aliases # that might get confused with valid system types. # -solaris* is a basic system type, with this one exception. -solaris1 | -solaris1.*) os=`echo $os | sed -e 's|solaris1|sunos4|'` ;; -solaris) os=-solaris2 ;; -svr4*) os=-sysv4 ;; -unixware*) os=-sysv4.2uw ;; -gnu/linux*) os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` ;; # First accept the basic system types. # The portable systems comes first. # Each alternative MUST END IN A *, to match a version number. # -sysv* is not here because it comes later, after sysvr4. -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\ | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \ | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ | -aos* \ | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ | -openbsd* | -solidbsd* \ | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \ | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ | -chorusos* | -chorusrdb* \ | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ | -mingw32* | -linux-gnu* | -linux-newlib* | -linux-uclibc* \ | -uxpv* | -beos* | -mpeix* | -udk* \ | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ | -skyos* | -haiku* | -rdos* | -toppers*) # Remember, each alternative MUST END IN *, to match a version number. ;; -qnx*) case $basic_machine in x86-* | i*86-*) ;; *) os=-nto$os ;; esac ;; -nto-qnx*) ;; -nto*) os=`echo $os | sed -e 's|nto|nto-qnx|'` ;; -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \ | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) ;; -mac*) os=`echo $os | sed -e 's|mac|macos|'` ;; -linux-dietlibc) os=-linux-dietlibc ;; -linux*) os=`echo $os | sed -e 's|linux|linux-gnu|'` ;; -sunos5*) os=`echo $os | sed -e 's|sunos5|solaris2|'` ;; -sunos6*) os=`echo $os | sed -e 's|sunos6|solaris3|'` ;; -opened*) os=-openedition ;; -os400*) os=-os400 ;; -wince*) os=-wince ;; -osfrose*) os=-osfrose ;; -osf*) os=-osf ;; -utek*) os=-bsd ;; -dynix*) os=-bsd ;; -acis*) os=-aos ;; -atheos*) os=-atheos ;; -syllable*) os=-syllable ;; -386bsd) os=-bsd ;; -ctix* | -uts*) os=-sysv ;; -nova*) os=-rtmk-nova ;; -ns2 ) os=-nextstep2 ;; -nsk*) os=-nsk ;; # Preserve the version number of sinix5. -sinix5.*) os=`echo $os | sed -e 's|sinix|sysv|'` ;; -sinix*) os=-sysv4 ;; -tpf*) os=-tpf ;; -triton*) os=-sysv3 ;; -oss*) os=-sysv3 ;; -svr4) os=-sysv4 ;; -svr3) os=-sysv3 ;; -sysvr4) os=-sysv4 ;; # This must come after -sysvr4. -sysv*) ;; -ose*) os=-ose ;; -es1800*) os=-ose ;; -xenix) os=-xenix ;; -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) os=-mint ;; -aros*) os=-aros ;; -kaos*) os=-kaos ;; -zvmoe) os=-zvmoe ;; -none) ;; *) # Get rid of the `-' at the beginning of $os. os=`echo $os | sed 's/[^-]*-//'` echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 exit 1 ;; esac else # Here we handle the default operating systems that come with various machines. # The value should be what the vendor currently ships out the door with their # machine or put another way, the most popular os provided with the machine. # Note that if you're going to try to match "-MANUFACTURER" here (say, # "-sun"), then you have to tell the case statement up towards the top # that MANUFACTURER isn't an operating system. Otherwise, code above # will signal an error saying that MANUFACTURER isn't an operating # system, and we'll never get to this point. case $basic_machine in spu-*) os=-elf ;; *-acorn) os=-riscix1.2 ;; arm*-rebel) os=-linux ;; arm*-semi) os=-aout ;; c4x-* | tic4x-*) os=-coff ;; # This must come before the *-dec entry. pdp10-*) os=-tops20 ;; pdp11-*) os=-none ;; *-dec | vax-*) os=-ultrix4.2 ;; m68*-apollo) os=-domain ;; i386-sun) os=-sunos4.0.2 ;; m68000-sun) os=-sunos3 # This also exists in the configure program, but was not the # default. # os=-sunos4 ;; m68*-cisco) os=-aout ;; mips*-cisco) os=-elf ;; mips*-*) os=-elf ;; or32-*) os=-coff ;; *-tti) # must be before sparc entry or we get the wrong os. os=-sysv3 ;; sparc-* | *-sun) os=-sunos4.1.1 ;; *-be) os=-beos ;; *-haiku) os=-haiku ;; *-ibm) os=-aix ;; *-knuth) os=-mmixware ;; *-wec) os=-proelf ;; *-winbond) os=-proelf ;; *-oki) os=-proelf ;; *-hp) os=-hpux ;; *-hitachi) os=-hiux ;; i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) os=-sysv ;; *-cbm) os=-amigaos ;; *-dg) os=-dgux ;; *-dolphin) os=-sysv3 ;; m68k-ccur) os=-rtu ;; m88k-omron*) os=-luna ;; *-next ) os=-nextstep ;; *-sequent) os=-ptx ;; *-crds) os=-unos ;; *-ns) os=-genix ;; i370-*) os=-mvs ;; *-next) os=-nextstep3 ;; *-gould) os=-sysv ;; *-highlevel) os=-bsd ;; *-encore) os=-bsd ;; *-sgi) os=-irix ;; *-siemens) os=-sysv4 ;; *-masscomp) os=-rtu ;; f30[01]-fujitsu | f700-fujitsu) os=-uxpv ;; *-rom68k) os=-coff ;; *-*bug) os=-coff ;; *-apple) os=-macos ;; *-atari*) os=-mint ;; *) os=-none ;; esac fi # Here we handle the case where we know the os, and the CPU type, but not the # manufacturer. We pick the logical manufacturer. vendor=unknown case $basic_machine in *-unknown) case $os in -riscix*) vendor=acorn ;; -sunos*) vendor=sun ;; -aix*) vendor=ibm ;; -beos*) vendor=be ;; -hpux*) vendor=hp ;; -mpeix*) vendor=hp ;; -hiux*) vendor=hitachi ;; -unos*) vendor=crds ;; -dgux*) vendor=dg ;; -luna*) vendor=omron ;; -genix*) vendor=ns ;; -mvs* | -opened*) vendor=ibm ;; -os400*) vendor=ibm ;; -ptx*) vendor=sequent ;; -tpf*) vendor=ibm ;; -vxsim* | -vxworks* | -windiss*) vendor=wrs ;; -aux*) vendor=apple ;; -hms*) vendor=hitachi ;; -mpw* | -macos*) vendor=apple ;; -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) vendor=atari ;; -vos*) vendor=stratus ;; esac basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` ;; esac echo $basic_machine$os exit # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" # End: jed-0.99-19/autoconf/Makefile.in0000644002657400265740000000310311311317447015352 0ustar davisdavis# -*- sh -*- #This is a UNIX-only makefile. For other systems, get a makefile from #src/mkfiles/ @SET_MAKE@ jed: makefiles cd src; $(MAKE) jed @echo If you have X, try 'make xjed' all: makefiles cd src; $(MAKE) all xjed: makefiles cd src; $(MAKE) xjed rgrep: makefiles cd src; $(MAKE) rgrep Makefile: configure autoconf/Makefile.in @echo "Makefile is older than the configure script". @echo "Please re-run the configure script." @exit 1 src/Makefile: configure src/Makefile.in src/config.hin src/jed-feat.h @echo "src/Makefile is older than its dependencies". @echo "Please re-run the configure script." @exit 1 makefiles: Makefile src/Makefile clean: /bin/rm -f *~ cd src; $(MAKE) clean # distclean: /bin/rm -f *~ Makefile config.status config.log config.cache files.pck cd src; $(MAKE) distclean # install: makefiles cd src; $(MAKE) install # getmail: makefiles cd src; $(MAKE) getmail @echo getmail created. Copy it to JED_ROOT/bin. # The symlinks target is for my own private use. It simply creates the object # directory as a symbolic link to a local disk instead of an NFS mounted one. symlinks: cd src; $(MAKE) symlinks configure: autoconf/aclocal.m4 autoconf/configure.ac cd autoconf && autoconf && mv ./configure .. update: autoconf/config.sub autoconf/config.guess autoconf/config.guess: /usr/share/misc/config.guess /bin/cp -f /usr/share/misc/config.guess autoconf/config.guess autoconf/config.sub: /usr/share/misc/config.sub /bin/cp -f /usr/share/misc/config.sub autoconf/config.sub .PHONY: jed all xjed rgrep clean distclean install getmail symlinks makefiles jed-0.99-19/autoconf/aclocal.m40000644002657400265740000006425611311317447015165 0ustar davisdavisdnl# -*- mode: sh; mode: fold -*- dnl# 0.2.5-1: Updated using autoupdate dnl# 0.2.5-0: M_LIB output variable created for haiku support (Scott McCreary) dnl# 0.2.4-0: Added optional 3rd argument to JD_WITH_LIBRARY for a default path dnl# 0.2.3-2: X was missing in a "test" statement (Joerg Sommer) dnl# 0.2.3-1: AC_AIX needs to be called before running the compiler (Miroslav Lichvar) dnl# 0.2.3: rewrote JD_CHECK_FOR_LIBRARY to loop over include/lib pairs dnl# 0.2.2-1: JD_WITH_LIBRARY bug-fix dnl# 0.2.2: Use ncurses5-config to search for terminfo dirs. dnl# 0.2.1: Add .dll.a to list of extensions to when searching for libs (cygwin) dnl# 0.2.0: Added install target name and more fixes for cygwin dnl# 0.1.12: Improved support for cygwin dnl# 0.1.11: Fixed elf linking on freebsd (Renato Botelho (garga at freebsd, org) dnl# Version 0.1.10: rpath support for netbsd dnl# Version 0.1.9: When searching for libs, use dylib on darwin dnl# Version 0.1.8: Add rpath support for OpenBSD dnl# Version 0.1.7: removed "-K pic" from IRIX compiler lines dnl# Version 0.1.6: Added cygwin module support dnl# Version 0.1.5: Added gcc version-script support. AC_DEFUN(JD_INIT, dnl#{{{ [ #These variable are initialized by JD init function CONFIG_DIR=`pwd` cd $srcdir if test "`pwd`" != "$CONFIG_DIR" then AC_MSG_ERROR("This software does not support configuring from another directory. See the INSTALL file") fi dnl# if test "X$PWD" != "X" dnl# then dnl# CONFIG_DIR="$PWD" dnl# fi AC_SUBST(CONFIG_DIR)dnl # Note: these will differ if one is a symbolic link if test -f /usr/bin/dirname; then JD_Above_Dir=`dirname $CONFIG_DIR` else # system is a loser JD_Above_Dir=`cd ..;pwd` fi JD_Above_Dir2=`cd ..;pwd` ]) dnl#}}} dnl# This function expand the "prefix variables. For example, it will expand dnl# values such as ${exec_prefix}/foo when ${exec_prefix} itself has a dnl# of ${prefix}. This function produces the shell variables: dnl# jd_prefix_libdir, jd_prefix_incdir AC_DEFUN(JD_EXPAND_PREFIX, dnl#{{{ [ if test "X$jd_prefix" = "X" then jd_prefix=$ac_default_prefix if test "X$prefix" != "XNONE" then jd_prefix="$prefix" fi jd_exec_prefix="$jd_prefix" if test "X$exec_prefix" != "XNONE" then jd_exec_prefix="$exec_prefix" fi dnl#Unfortunately, exec_prefix may have a value like ${prefix}, etc. dnl#Let the shell expand those. Yuk. eval `sh <>)dnl define(<<$2>>, translit($1, [a-z], [A-Z]))dnl changequote([, ])dnl ]) #}}} AC_DEFUN(JD_SIMPLE_LIB_DIR, dnl#{{{ [ JD_UPPERCASE($1,JD_UP_NAME) JD_UP_NAME[]_LIB_DIR=$JD_Above_Dir/$1/libsrc/"$ARCH"objs JD_UP_NAME[]_INCLUDE=$JD_Above_Dir/$1/libsrc if test ! -d "[$]JD_UP_NAME[]_INCLUDE" then JD_UP_NAME[]_LIB_DIR=$JD_Above_Dir/$1/src/"$ARCH"objs JD_UP_NAME[]_INCLUDE=$JD_Above_Dir/$1/src if test ! -d "[$]JD_UP_NAME[]_INCLUDE" then echo "" echo WARNING------Unable to find the JD_UP_NAME directory echo You may have to edit $CONFIG_DIR/src/Makefile. echo "" fi fi AC_SUBST(JD_UP_NAME[]_LIB_DIR)dnl AC_SUBST(JD_UP_NAME[]_INCLUDE)dnl undefine([JD_UP_NAME])dnl ]) dnl#}}} AC_DEFUN(JD_FIND_GENERIC, dnl#{{{ [ AC_REQUIRE([JD_EXPAND_PREFIX])dnl changequote(<<, >>)dnl define(<>, translit($1, [a-z], [A-Z]))dnl changequote([, ])dnl # Look for the JD_UP_NAME package #JD_UP_NAME[]_INCLUDE="" #JD_UP_NAME[]_LIB_DIR="" # This list consists of "include,lib include,lib ..." JD_Search_Dirs="$JD_Above_Dir2/$1/libsrc,$JD_Above_Dir2/$1/libsrc/"$ARCH"objs \ $JD_Above_Dir/$1/libsrc,$JD_Above_Dir/$1/libsrc/"$ARCH"objs \ $JD_Above_Dir2/$1/src,$JD_Above_Dir2/$1/src/"$ARCH"objs \ $JD_Above_Dir/$1/src,$JD_Above_Dir/$1/src/"$ARCH"objs" JD_Search_Dirs="$JD_Search_Dirs \ $jd_prefix_incdir,$jd_prefix_libdir \ $HOME/include,$HOME/lib" if test -n "$ARCH" then JD_Search_Dirs="$JD_Search_Dirs $HOME/include,$HOME/$ARCH/lib" JD_Search_Dirs="$JD_Search_Dirs $HOME/include,$HOME/sys/$ARCH/lib" fi # Now add the standard system includes. The reason for doing this is that # the other directories may have a better chance of containing a more recent # version. JD_Search_Dirs="$JD_Search_Dirs \ /usr/local/include,/usr/local/lib \ /usr/include,/usr/lib \ /usr/include/$1,/usr/lib \ /usr/include/$1,/usr/lib/$1" echo looking for the JD_UP_NAME library for include_and_lib in $JD_Search_Dirs do # Yuk. Is there a better way to set these variables?? generic_include=`echo $include_and_lib | tr ',' ' ' | awk '{print [$]1}'` generic_lib=`echo $include_and_lib | tr ',' ' ' | awk '{print [$]2}'` echo Looking for $1.h in $generic_include echo and lib$1.a in $generic_lib if test -r $generic_include/$1.h && test -r $generic_lib/lib$1.a then echo Found it. JD_UP_NAME[]_LIB_DIR="$generic_lib" JD_UP_NAME[]_INCLUDE="$generic_include" break else if test -r $generic_include/$1.h && test -r $generic_lib/lib$1.so then echo Found it. JD_UP_NAME[]_LIB_DIR="$generic_lib" JD_UP_NAME[]_INCLUDE="$generic_include" break fi fi done if test -n "[$]JD_UP_NAME[]_LIB_DIR" then jd_have_$1="yes" else echo Unable to find the $JD_UP_NAME library. echo You may have to edit $CONFIG_DIR/src/Makefile. JD_UP_NAME[]_INCLUDE=$JD_Above_Dir/$1/src JD_UP_NAME[]_LIB_DIR=$JD_Above_Dir/$1/src/"$ARCH"objs jd_have_$1="no" fi JD_UP_NAME[]_INC="-I[$]JD_UP_NAME[]_INCLUDE" JD_UP_NAME[]_LIB="-L[$]JD_UP_NAME[]_LIB_DIR" JD_SET_RPATH([$]JD_UP_NAME[]_LIB_DIR) dnl if test "X$GCC" = Xyes dnl then dnl RPATH_[]JD_UP_NAME="-Wl,-R[$]JD_UP_NAME[]_LIB_DIR" dnl else dnl RPATH_[]JD_UP_NAME="-R[$]JD_UP_NAME[]_LIB_DIR" dnl fi # gcc under solaris is often not installed correctly. Avoid specifying # -I/usr/include. if test "[$]JD_UP_NAME[]_INC" = "-I/usr/include" then JD_UP_NAME[]_INC="" fi if test "[$]JD_UP_NAME[]_LIB" = "-L/usr/lib" then JD_UP_NAME[]_LIB="" RPATH_[]JD_UP_NAME="" fi AC_SUBST(JD_UP_NAME[]_LIB)dnl AC_SUBST(JD_UP_NAME[]_INC)dnl AC_SUBST(JD_UP_NAME[]_LIB_DIR)dnl AC_SUBST(JD_UP_NAME[]_INCLUDE)dnl dnl AC_SUBST(RPATH_[]JD_UP_NAME)dnl undefine([JD_UP_NAME])dnl ]) dnl#}}} AC_DEFUN(JD_FIND_SLANG, dnl#{{{ [ JD_FIND_GENERIC(slang) ]) dnl#}}} AC_DEFUN(JD_GCC_WARNINGS, dnl#{{{ [ AC_ARG_ENABLE(warnings, [ --enable-warnings turn on GCC compiler warnings], [gcc_warnings=$enableval]) if test -n "$GCC" then #CFLAGS="$CFLAGS -fno-strength-reduce" if test -n "$gcc_warnings" then CFLAGS="$CFLAGS -Wall -W -pedantic -Winline -Wmissing-prototypes \ -Wnested-externs -Wpointer-arith -Wcast-align -Wshadow -Wstrict-prototypes" # Now trim excess whitespace CFLAGS=`echo $CFLAGS` fi fi ]) dnl#}}} IEEE_CFLAGS="" AC_DEFUN(JD_IEEE_CFLAGS, dnl#{{{ [ case "$host_cpu" in *alpha* ) if test "$GCC" = yes then IEEE_CFLAGS="-mieee" else IEEE_CFLAGS="-ieee_with_no_inexact" fi ;; * ) IEEE_CFLAGS="" esac ]) dnl#}}} AC_DEFUN(JD_CREATE_ORULE, dnl#{{{ [ PROGRAM_OBJECT_RULES="$PROGRAM_OBJECT_RULES \$(OBJDIR)/$1.o : \$(SRCDIR)/$1.c \$(DOT_O_DEPS) \$("$1"_O_DEP) cd \$(OBJDIR); \$(COMPILE_CMD) \$("$1"_C_FLAGS) \$(SRCDIR)/$1.c " ]) dnl#}}} AC_DEFUN(JD_CREATE_ELFORULE, dnl#{{{ [ PROGRAM_ELF_ORULES="$PROGRAM_ELF_ORULES \$(ELFDIR)/$1.o : \$(SRCDIR)/$1.c \$(DOT_O_DEPS) \$("$1"_O_DEP) cd \$(ELFDIR); \$(ELFCOMPILE_CMD) \$("$1"_C_FLAGS) \$(SRCDIR)/$1.c " ]) dnl#}}} AC_DEFUN(JD_CREATE_EXEC_RULE, dnl#{{{ [ PROGRAM_OBJECT_RULES="$PROGRAM_OBJECT_RULES $1 : \$(OBJDIR)/$1 @echo $1 created in \$(OBJDIR) \$(OBJDIR)/$1 : \$(OBJDIR)/$1.o \$("$1"_DEPS) \$(EXECDEPS) \$(CC) -o \$(OBJDIR)/$1 \$(LDFLAGS) \$(OBJDIR)/$1.o \$("$1"_LIBS) \$(EXECLIBS) \$(OBJDIR)/$1.o : \$(SRCDIR)/$1.c \$(DOT_O_DEPS) \$("$1"_O_DEP) cd \$(OBJDIR); \$(COMPILE_CMD) \$("$1"_INC) \$(EXECINC) \$(SRCDIR)/$1.c " ]) dnl#}}} AC_DEFUN(JD_CREATE_MODULE_ORULES, dnl#{{{ [ for program_module in $Program_Modules; do JD_CREATE_ORULE($program_module) JD_CREATE_ELFORULE($program_module) done ]) dnl#}}} AC_DEFUN(JD_GET_MODULES, dnl#{{{ [ PROGRAM_HFILES="" PROGRAM_OFILES="" PROGRAM_CFILES="" PROGRAM_OBJECTS="" PROGRAM_ELFOBJECTS="" PROGRAM_OBJECT_RULES="" PROGRAM_ELF_ORULES="" if test -z "$1" then Program_Modules="" else comment_re="^#" Program_Modules=`grep -v '$comment_re' $1 | awk '{print [$]1}'` Program_H_Modules=`grep -v '$comment_re' $1 | awk '{print [$]2}'` for program_module in $Program_H_Modules; do PROGRAM_HFILES="$PROGRAM_HFILES $program_module" done fi for program_module in $Program_Modules; do PROGRAM_OFILES="$PROGRAM_OFILES $program_module.o" PROGRAM_CFILES="$PROGRAM_CFILES $program_module.c" PROGRAM_OBJECTS="$PROGRAM_OBJECTS \$(OBJDIR)/$program_module.o" PROGRAM_ELFOBJECTS="$PROGRAM_ELFOBJECTS \$(ELFDIR)/$program_module.o" done dnl echo $PROGRAM_OFILES dnl echo $PROGRAM_HFILES AC_SUBST(PROGRAM_OFILES)dnl AC_SUBST(PROGRAM_CFILES)dnl AC_SUBST(PROGRAM_HFILES)dnl AC_SUBST(PROGRAM_OBJECTS)dnl AC_SUBST(PROGRAM_ELFOBJECTS)dnl ]) dnl#}}} AC_DEFUN(JD_APPEND_RULES, dnl#{{{ [ echo "$PROGRAM_OBJECT_RULES" >> $1 ]) dnl#}}} AC_DEFUN(JD_APPEND_ELFRULES, dnl#{{{ [ echo "$PROGRAM_ELF_ORULES" >> $1 ]) dnl#}}} AC_DEFUN(JD_CREATE_MODULE_EXEC_RULES, dnl#{{{ [ for program_module in $Program_Modules; do JD_CREATE_EXEC_RULE($program_module) done ]) dnl#}}} AC_DEFUN(JD_TERMCAP, dnl#{{{ [ AC_PATH_PROG(nc5config, ncurses5-config, no) if test "$nc5config" = "no" then AC_PATH_PROG(nc5config, ncurses5w-config, no) fi AC_MSG_CHECKING(for terminfo) if test "$nc5config" != "no" then MISC_TERMINFO_DIRS=`$nc5config --terminfo` else MISC_TERMINFO_DIRS="" fi JD_Terminfo_Dirs="$MISC_TERMINFO_DIRS \ /usr/lib/terminfo \ /usr/share/terminfo \ /usr/share/lib/terminfo \ /usr/local/lib/terminfo" TERMCAP=-ltermcap for terminfo_dir in $JD_Terminfo_Dirs do if test -d $terminfo_dir then AC_MSG_RESULT(yes) TERMCAP="" break fi done if test "$TERMCAP"; then AC_MSG_RESULT(no) AC_DEFINE(USE_TERMCAP) fi AC_SUBST(TERMCAP)dnl AC_SUBST(MISC_TERMINFO_DIRS)dnl ]) dnl#}}} AC_DEFUN(JD_ANSI_CC, dnl#{{{ [ AC_AIX AC_PROG_CC AC_PROG_CPP AC_PROG_GCC_TRADITIONAL AC_ISC_POSIX dnl #This stuff came from Yorick config script dnl dnl # HPUX needs special stuff dnl AC_EGREP_CPP(yes, [#ifdef hpux yes #endif ], [ AC_DEFINE(_HPUX_SOURCE) if test "$CC" = cc; then CC="cc -Ae"; fi ])dnl dnl dnl #Be sure we've found compiler that understands prototypes dnl AC_MSG_CHECKING(C compiler that understands ANSI prototypes) AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[ extern int silly (int);]])],[ AC_MSG_RESULT($CC looks ok. Good.)],[ AC_MSG_RESULT($CC is not a good enough compiler) AC_MSG_ERROR(Set env variable CC to your ANSI compiler and rerun configure.) ])dnl ])dnl dnl#}}} AC_DEFUN(JD_ELF_COMPILER, dnl#{{{ [ dnl #------------------------------------------------------------------------- dnl # Check for dynamic linker dnl #------------------------------------------------------------------------- DYNAMIC_LINK_LIB="" AC_CHECK_HEADER(dlfcn.h,[ AC_DEFINE(HAVE_DLFCN_H) AC_CHECK_LIB(dl,dlopen,[ DYNAMIC_LINK_LIB="-ldl" AC_DEFINE(HAVE_DLOPEN) ],[ AC_CHECK_FUNC(dlopen,AC_DEFINE(HAVE_DLOPEN)) if test "$ac_cv_func_dlopen" != yes then AC_MSG_WARN(cannot perform dynamic linking) fi ])]) AC_SUBST(DYNAMIC_LINK_LIB) if test "$GCC" = yes then if test X"$CFLAGS" = X then CFLAGS="-O2" fi fi dnl #Some defaults ELFLIB="lib\$(THIS_LIB).so" ELFLIB_MAJOR="\$(ELFLIB).\$(ELF_MAJOR_VERSION)" ELFLIB_MAJOR_MINOR="\$(ELFLIB_MAJOR).\$(ELF_MINOR_VERSION)" ELFLIB_MAJOR_MINOR_MICRO="\$(ELFLIB_MAJOR_MINOR).\$(ELF_MICRO_VERSION)" dnl# This specifies the target to use in the makefile to install the shared library INSTALL_ELFLIB_TARGET="install-elf-and-links" ELFLIB_BUILD_NAME="\$(ELFLIB_MAJOR_MINOR_MICRO)" INSTALL_MODULE="\$(INSTALL_DATA)" SLANG_DLL_CFLAGS="" M_LIB="-lm" case "$host_os" in *linux*|*gnu*|k*bsd*-gnu ) DYNAMIC_LINK_FLAGS="-Wl,-export-dynamic" ELF_CC="\$(CC)" ELF_CFLAGS="\$(CFLAGS) -fPIC" ELF_LINK="\$(CC) \$(LDFLAGS) -shared -Wl,-O1 -Wl,--version-script,\$(VERSION_SCRIPT) -Wl,-soname,\$(ELFLIB_MAJOR)" ELF_DEP_LIBS="\$(DL_LIB) -lm -lc" CC_SHARED="\$(CC) \$(CFLAGS) -shared -fPIC" ;; *solaris* ) if test "$GCC" = yes then DYNAMIC_LINK_FLAGS="" ELF_CC="\$(CC)" ELF_CFLAGS="\$(CFLAGS) -fPIC" ELF_LINK="\$(CC) \$(LDFLAGS) -shared -Wl,-ztext -Wl,-h,\$(ELFLIB_MAJOR)" ELF_DEP_LIBS="\$(DL_LIB) -lm -lc" CC_SHARED="\$(CC) \$(CFLAGS) -G -fPIC" else DYNAMIC_LINK_FLAGS="" ELF_CC="\$(CC)" ELF_CFLAGS="\$(CFLAGS) -K PIC" ELF_LINK="\$(CC) \$(LDFLAGS) -G -h\$(ELFLIB_MAJOR)" ELF_DEP_LIBS="\$(DL_LIB) -lm -lc" CC_SHARED="\$(CC) \$(CFLAGS) -G -K PIC" fi ;; # osr5 or unixware7 with current or late autoconf *sco3.2v5* | *unixware-5* | *sco-sysv5uw7*) if test "$GCC" = yes then DYNAMIC_LINK_FLAGS="" ELF_CC="\$(CC)" ELF_CFLAGS="\$(CFLAGS) -fPIC" ELF_LINK="\$(CC) \$(LDFLAGS) -shared -Wl,-h,\$(ELFLIB_MAJOR)" ELF_DEP_LIBS= CC_SHARED="\$(CC) \$(CFLAGS) -G -fPIC" else DYNAMIC_LINK_FLAGS="" ELF_CC="\$(CC)" ELF_CFLAGS="\$(CFLAGS) -K pic" # ELF_LINK="ld -G -z text -h#" ELF_LINK="\$(CC) \$(LDFLAGS) -G -z text -h\$(ELFLIB_MAJOR)" ELF_DEP_LIBS= CC_SHARED="\$(CC) \$(CFLAGS) -G -K pic" fi ;; *irix6.5* ) echo "Note: ELF compiler for host_os=$host_os may not be correct" echo "double-check: 'mode_t', 'pid_t' may be wrong!" if test "$GCC" = yes then # not tested DYNAMIC_LINK_FLAGS="" ELF_CC="\$(CC)" ELF_CFLAGS="\$(CFLAGS) -fPIC" ELF_LINK="\$(CC) \$(LDFLAGS) -shared -Wl,-h,\$(ELFLIB_MAJOR)" ELF_DEP_LIBS= CC_SHARED="\$(CC) \$(CFLAGS) -shared -fPIC" else DYNAMIC_LINK_FLAGS="" ELF_CC="\$(CC)" ELF_CFLAGS="\$(CFLAGS)" # default anyhow ELF_LINK="\$(CC) \$(LDFLAGS) -shared -o \$(ELFLIB_MAJOR)" ELF_DEP_LIBS= CC_SHARED="\$(CC) \$(CFLAGS) -shared" fi ;; *darwin* ) DYNAMIC_LINK_FLAGS="" ELF_CC="\$(CC)" ELF_CFLAGS="\$(CFLAGS) -fno-common" ELF_LINK="\$(CC) \$(LDFLAGS) -dynamiclib -install_name \$(install_lib_dir)/\$(ELFLIB_MAJOR) -compatibility_version \$(ELF_MAJOR_VERSION) -current_version \$(ELF_MAJOR_VERSION).\$(ELF_MINOR_VERSION)" ELF_DEP_LIBS="\$(LDFLAGS) \$(DL_LIB)" CC_SHARED="\$(CC) -bundle -flat_namespace -undefined suppress \$(CFLAGS) -fno-common" ELFLIB="lib\$(THIS_LIB).dylib" ELFLIB_MAJOR="lib\$(THIS_LIB).\$(ELF_MAJOR_VERSION).dylib" ELFLIB_MAJOR_MINOR="lib\$(THIS_LIB).\$(ELF_MAJOR_VERSION).\$(ELF_MINOR_VERSION).dylib" ELFLIB_MAJOR_MINOR_MICRO="lib\$(THIS_LIB).\$(ELF_MAJOR_VERSION).\$(ELF_MINOR_VERSION).\$(ELF_MICRO_VERSION).dylib" ;; *freebsd* ) ELF_CC="\$(CC)" ELF_CFLAGS="\$(CFLAGS) -fPIC" #if test "X$PORTOBJFORMAT" = "Xelf" ; then # ELF_LINK="\$(CC) \$(LDFLAGS) -shared -Wl,-soname,\$(ELFLIB_MAJOR)" #else # ELF_LINK="ld -Bshareable -x" #fi ELF_LINK="\$(CC) \$(LDFLAGS) -shared -Wl,-soname,\$(ELFLIB_MAJOR)" ELF_DEP_LIBS="\$(DL_LIB) -lm" CC_SHARED="\$(CC) \$(CFLAGS) -shared -fPIC" ;; *cygwin* ) DYNAMIC_LINK_FLAGS="" ELF_CC="\$(CC)" SLANG_DLL_CFLAGS="-DSLANG_DLL=1" ELF_CFLAGS="\$(CFLAGS) -DBUILD_DLL=1" DLL_IMPLIB_NAME="lib\$(THIS_LIB)\$(ELFLIB_MAJOR_VERSION).dll.a" #ELF_LINK="\$(CC) \$(LDFLAGS) -shared -Wl,-O1 -Wl,--version-script,\$(VERSION_SCRIPT) -Wl,-soname,\$(ELFLIB_MAJOR) -Wl,--out-implib=\$(DLL_IMPLIB_NAME) -Wl,-export-all-symbols -Wl,-enable-auto-import" ELF_LINK="\$(CC) \$(LDFLAGS) -shared -Wl,-O1 -Wl,--version-script,\$(VERSION_SCRIPT) -Wl,-soname,\$(ELFLIB_MAJOR) -Wl,--out-implib=\$(DLL_IMPLIB_NAME)" ELF_DEP_LIBS="\$(DL_LIB) -lm" CC_SHARED="\$(CC) \$(CFLAGS) -shared -DSLANG_DLL=1" dnl# CYGWIN prohibits undefined symbols when linking shared libs SLANG_LIB_FOR_MODULES="-L\$(ELFDIR) -lslang" INSTALL_MODULE="\$(INSTALL)" INSTALL_ELFLIB_TARGET="install-elf-cygwin" ELFLIB="lib\$(THIS_LIB).dll" ELFLIB_MAJOR="lib\$(THIS_LIB)\$(ELF_MAJOR_VERSION).dll" ELFLIB_MAJOR_MINOR="lib\$(THIS_LIB)\$(ELF_MAJOR_VERSION)_\$(ELF_MINOR_VERSION).dll" ELFLIB_MAJOR_MINOR_MICRO="lib\$(THIS_LIB)\$(ELF_MAJOR_VERSION)_\$(ELF_MINOR_VERSION)_\$(ELF_MICRO_VERSION).dll" ELFLIB_BUILD_NAME="\$(ELFLIB_MAJOR)" ;; *haiku* ) M_LIB="" DYNAMIC_LINK_FLAGS="-Wl,-export-dynamic" ELF_CC="\$(CC)" ELF_CFLAGS="\$(CFLAGS) -fPIC" ELF_LINK="\$(CC) \$(LDFLAGS) -shared -Wl,-O1 -Wl,--version-script,\$(VERSION_SCRIPT) -Wl,-soname,\$(ELFLIB_MAJOR)" ELF_DEP_LIBS="\$(DL_LIB)" CC_SHARED="\$(CC) \$(CFLAGS) -shared -fPIC" ;; * ) echo "Note: ELF compiler for host_os=$host_os may be wrong" ELF_CC="\$(CC)" ELF_CFLAGS="\$(CFLAGS) -fPIC" ELF_LINK="\$(CC) \$(LDFLAGS) -shared" ELF_DEP_LIBS="\$(DL_LIB) -lm -lc" CC_SHARED="\$(CC) \$(CFLAGS) -shared -fPIC" esac AC_SUBST(ELF_CC) AC_SUBST(ELF_CFLAGS) AC_SUBST(ELF_LINK) AC_SUBST(ELF_LINK_CMD) AC_SUBST(ELF_DEP_LIBS) AC_SUBST(DYNAMIC_LINK_FLAGS) AC_SUBST(CC_SHARED) AC_SUBST(ELFLIB) AC_SUBST(ELFLIB_MAJOR) AC_SUBST(ELFLIB_MAJOR_MINOR) AC_SUBST(ELFLIB_MAJOR_MINOR_MICRO) AC_SUBST(SLANG_LIB_FOR_MODULES) AC_SUBST(DLL_IMPLIB_NAME) AC_SUBST(INSTALL_MODULE) AC_SUBST(INSTALL_ELFLIB_TARGET) AC_SUBST(ELFLIB_BUILD_NAME) AC_SUBST(SLANG_DLL_CFLAGS) AC_SUBST(M_LIB) ]) dnl#}}} AC_DEFUN(JD_F77_COMPILER, dnl#{{{ [ case "$host_os" in *linux* ) F77="g77" F77_LIBS="-lg2c" ;; *solaris*) F77=f77 #F77_LIBS="-lF77 -lM77 -L/opt/SUNWspro/SC4.0/lib -lsunmath" F77_LIBS="-lF77 -lM77 -lsunmath" ;; *) echo "" echo "WARNING: Assuming f77 as your FORTRAN compiler" echo "" F77=f77 F77_LIBS="" esac AC_SUBST(F77) AC_SUBST(F77_LIBS) ]) dnl#}}} dnl# This macro process the --with-xxx, --with-xxxinc, and --with-xxxlib dnl# command line arguments and returns the values as shell variables dnl# jd_xxx_include_dir and jd_xxx_library_dir. It does not perform any dnl# substitutions, nor check for the existence of the supplied values. AC_DEFUN(JD_WITH_LIBRARY_PATHS, dnl#{{{ [ JD_UPPERCASE($1,JD_ARG1) jd_$1_include_dir="" jd_$1_library_dir="" if test X"$jd_with_$1_library" = X then jd_with_$1_library="" fi AC_ARG_WITH($1, [ --with-$1=DIR Use DIR/lib and DIR/include for $1], [jd_with_$1_arg=$withval], [jd_with_$1_arg=unspecified]) case "x$jd_with_$1_arg" in xno) jd_with_$1_library="no" ;; x) dnl# AC_MSG_ERROR(--with-$1 requires a value-- try yes or no) jd_with_$1_library="yes" ;; xunspecified) ;; xyes) jd_with_$1_library="yes" ;; *) jd_with_$1_library="yes" jd_$1_include_dir="$jd_with_$1_arg"/include jd_$1_library_dir="$jd_with_$1_arg"/lib ;; esac AC_ARG_WITH($1lib, [ --with-$1lib=DIR $1 library in DIR], [jd_with_$1lib_arg=$withval], [jd_with_$1lib_arg=unspecified]) case "x$jd_with_$1lib_arg" in xunspecified) ;; xno) ;; x) AC_MSG_ERROR(--with-$1lib requres a value) ;; *) jd_with_$1_library="yes" jd_$1_library_dir="$jd_with_$1lib_arg" ;; esac AC_ARG_WITH($1inc, [ --with-$1inc=DIR $1 include files in DIR], [jd_with_$1inc_arg=$withval], [jd_with_$1inc_arg=unspecified]) case "x$jd_with_$1inc_arg" in x) AC_MSG_ERROR(--with-$1inc requres a value) ;; xunspecified) ;; xno) ;; *) jd_with_$1_library="yes" jd_$1_include_dir="$jd_with_$1inc_arg" ;; esac ]) dnl#}}} dnl# This function checks for the existence of the specified library $1 with dnl# header file $2. If the library exists, then the shell variables will dnl# be created: dnl# jd_with_$1_library=yes/no, dnl# jd_$1_inc_file dnl# jd_$1_include_dir dnl# jd_$1_library_dir dnl# If $3 is present, then also look in $3/include+$3/lib AC_DEFUN(JD_CHECK_FOR_LIBRARY, dnl#{{{ [ AC_REQUIRE([JD_EXPAND_PREFIX])dnl dnl JD_UPPERCASE($1,JD_ARG1) JD_WITH_LIBRARY_PATHS($1) AC_MSG_CHECKING(for the $1 library and header files $2) if test X"$jd_with_$1_library" != Xno then jd_$1_inc_file=$2 dnl# jd_with_$1_library="yes" if test "X$jd_$1_inc_file" = "X" then jd_$1_inc_file=$1.h fi if test X"$jd_$1_include_dir" = X then inc_and_lib_dirs="\ $jd_prefix_incdir,$jd_prefix_libdir \ /usr/local/$1/include,/usr/local/$1/lib \ /usr/local/include/$1,/usr/local/lib \ /usr/local/include,/usr/local/lib \ /usr/include/$1,/usr/lib \ /usr/$1/include,/usr/$1/lib \ /usr/include,/usr/lib \ /opt/include/$1,/opt/lib \ /opt/$1/include,/opt/$1/lib \ /opt/include,/opt/lib" if test X$3 != X then inc_and_lib_dirs="$3/include,$3/lib $inc_and_lib_dirs" fi case "$host_os" in *darwin* ) exts="dylib so a" ;; *cygwin* ) exts="dll.a so a" ;; * ) exts="so a" esac xincfile="$jd_$1_inc_file" xlibfile="lib$1" jd_with_$1_library="no" for include_and_lib in $inc_and_lib_dirs do # Yuk. Is there a better way to set these variables?? xincdir=`echo $include_and_lib | tr ',' ' ' | awk '{print [$]1}'` xlibdir=`echo $include_and_lib | tr ',' ' ' | awk '{print [$]2}'` found=0 if test -r $xincdir/$xincfile then for E in $exts do if test -r "$xlibdir/$xlibfile.$E" then jd_$1_include_dir="$xincdir" jd_$1_library_dir="$xlibdir" jd_with_$1_library="yes" found=1 break fi done fi if test $found -eq 1 then break fi done fi fi if test X"$jd_$1_include_dir" != X -a X"$jd_$1_library_dir" != X then AC_MSG_RESULT(yes: $jd_$1_library_dir and $jd_$1_include_dir) jd_with_$1_library="yes" dnl# Avoid using /usr/lib and /usr/include because of problems with dnl# gcc on some solaris systems. JD_ARG1[]_LIB=-L$jd_$1_library_dir if test "X$jd_$1_library_dir" = "X/usr/lib" then JD_ARG1[]_LIB="" else JD_SET_RPATH($jd_$1_library_dir) fi JD_ARG1[]_INC=-I$jd_$1_include_dir if test "X$jd_$1_include_dir" = "X/usr/include" then JD_ARG1[]_INC="" fi else AC_MSG_RESULT(no) jd_with_$1_library="no" JD_ARG1[]_INC="" JD_ARG1[]_LIB="" fi AC_SUBST(JD_ARG1[]_LIB) AC_SUBST(JD_ARG1[]_INC) ]) dnl#}}} AC_DEFUN(JD_WITH_LIBRARY, dnl#{{{ [ JD_CHECK_FOR_LIBRARY($1, $2, $3) if test "$jd_with_$1_library" = "no" then AC_MSG_ERROR(unable to find the $1 library and header file $jd_$1_inc_file) fi ]) dnl#}}} AC_DEFUN(JD_SLANG_VERSION, dnl#{{{ [ slang_h=$jd_slang_include_dir/slang.h AC_MSG_CHECKING(SLANG_VERSION in $slang_h) slang_version=`grep "^#define *SLANG_VERSION " $slang_h | awk '{ print [$]3 }'` slang_major_version=`echo $slang_version | awk '{ print int([$]1/10000) }'` slang_minor_version=`echo $slang_version $slang_major_version | awk '{ print int(([$]1 - [$]2*10000)/100) }'` slang_patchlevel_version=`echo $slang_version $slang_major_version $slang_minor_version | awk '{ print ([$]1 - [$]2*10000 - [$]3*100) }'` AC_MSG_RESULT($slang_major_version.$slang_minor_version.$slang_patchlevel_version) AC_SUBST(slang_version) AC_SUBST(slang_major_version) AC_SUBST(slang_minor_version) AC_SUBST(slang_patchlevel_version) ]) #}}} AC_DEFUN(JD_SLANG_MODULE_INSTALL_DIR, dnl#{{{ [ AC_REQUIRE([JD_SLANG_VERSION]) if test "X$slang_major_version" = "X1" then MODULE_INSTALL_DIR="$libdir/slang/modules" else MODULE_INSTALL_DIR="$libdir/slang/v$slang_major_version/modules" fi SL_FILES_INSTALL_DIR=$datadir/slsh/local-packages AC_SUBST(MODULE_INSTALL_DIR) AC_SUBST(SL_FILES_INSTALL_DIR) ]) #}}} AC_DEFUN(JD_CHECK_LONG_LONG, dnl#{{{ [ AC_CHECK_TYPES(long long) AC_CHECK_SIZEOF(long long) ]) dnl#}}} AC_DEFUN(JD_LARGE_FILE_SUPPORTXXX, dnl#{{{ [ AC_REQUIRE([JD_CHECK_LONG_LONG]) AC_MSG_CHECKING(whether to explicitly activate long file support) AC_DEFINE(_LARGEFILE_SOURCE, 1) AC_DEFINE(_FILE_OFFSET_BITS, 64) jd_large_file_support=no if test X$ac_cv_type_long_long = Xyes then if test $ac_cv_sizeof_long_long -ge 8 then jd_large_file_support=yes fi fi if test $jd_large_file_support = yes then AC_DEFINE(HAVE_LARGEFILE_SUPPORT, 1) AC_MSG_RESULT(yes) else AC_MSG_RESULT(no) fi ]) dnl#}}} AC_DEFUN(JD_LARGE_FILE_SUPPORT, dnl#{{{ [ AC_SYS_LARGEFILE AC_FUNC_FSEEKO AC_TYPE_OFF_T AC_CHECK_SIZEOF(off_t) ]) #}}} AC_DEFUN(JD_HAVE_ISINF, dnl#{{{ [ AC_MSG_CHECKING([for isinf]) AC_LINK_IFELSE([AC_LANG_PROGRAM( [[#include ]], [[isinf (0.0);]])], [AC_MSG_RESULT([yes]) AC_DEFINE(HAVE_ISINF, 1)]) ]) #}}} jed-0.99-19/autoconf/include/0000755002657400265740000000000011311317447014733 5ustar davisdavisjed-0.99-19/autoconf/include/pkgcfg.m40000644002657400265740000001123511311317447016440 0ustar davisdavis#dnl -*- autoconf -*- ################################################################## ################################################################## ## Begin: STOLEN FROM A AUTOMAKE/ACLOCAL call #vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv #vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv # PKG_PROG_PKG_CONFIG([MIN-VERSION]) # ---------------------------------- AC_DEFUN([PKG_PROG_PKG_CONFIG], [m4_pattern_forbid([^_?PKG_[A-Z_]+$]) m4_pattern_allow([^PKG_CONFIG(_PATH)?$]) AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility])dnl if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then AC_PATH_TOOL([PKG_CONFIG], [pkg-config]) fi if test -n "$PKG_CONFIG"; then _pkg_min_version=m4_default([$1], [0.9.0]) AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version]) if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then AC_MSG_RESULT([yes]) else AC_MSG_RESULT([no]) PKG_CONFIG="" fi fi[]dnl ])# PKG_PROG_PKG_CONFIG # PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) # # Check to see whether a particular set of modules exists. Similar # to PKG_CHECK_MODULES(), but does not set variables or print errors. # # # Similar to PKG_CHECK_MODULES, make sure that the first instance of # this or PKG_CHECK_MODULES is called, or make sure to call # PKG_CHECK_EXISTS manually # -------------------------------------------------------------- AC_DEFUN([PKG_CHECK_EXISTS], [AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl if test -n "$PKG_CONFIG" && \ AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then m4_ifval([$2], [$2], [:]) m4_ifvaln([$3], [else $3])dnl fi]) # _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES]) # --------------------------------------------- m4_define([_PKG_CONFIG], [if test -n "$PKG_CONFIG"; then if test -n "$$1"; then pkg_cv_[]$1="$$1" else PKG_CHECK_EXISTS([$3], [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null`], [pkg_failed=yes]) fi else pkg_failed=untried fi[]dnl ])# _PKG_CONFIG # _PKG_SHORT_ERRORS_SUPPORTED # ----------------------------- AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED], [AC_REQUIRE([PKG_PROG_PKG_CONFIG]) if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then _pkg_short_errors_supported=yes else _pkg_short_errors_supported=no fi[]dnl ])# _PKG_SHORT_ERRORS_SUPPORTED # PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND], # [ACTION-IF-NOT-FOUND]) # # # Note that if there is a possibility the first call to # PKG_CHECK_MODULES might not happen, you should be sure to include an # explicit call to PKG_PROG_PKG_CONFIG in your configure.ac # # # -------------------------------------------------------------- AC_DEFUN([PKG_CHECK_MODULES], [AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl pkg_failed=no AC_MSG_CHECKING([for $1]) _PKG_CONFIG([$1][_CFLAGS], [cflags], [$2]) _PKG_CONFIG([$1][_LIBS], [libs], [$2]) m4_define([_PKG_TEXT], [Alternatively, you may set the environment variables $1[]_CFLAGS and $1[]_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details.]) if test $pkg_failed = yes; then _PKG_SHORT_ERRORS_SUPPORTED if test $_pkg_short_errors_supported = yes; then $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --errors-to-stdout --print-errors "$2"` else $1[]_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "$2"` fi # Put the nasty error message in config.log where it belongs echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD ifelse([$4], , [AC_MSG_ERROR(dnl [Package requirements ($2) were not met: $$1_PKG_ERRORS Consider adjusting the PKG_CONFIG_PATH environment variable if you installed software in a non-standard prefix. _PKG_TEXT ])], [AC_MSG_RESULT([no]) $4]) elif test $pkg_failed = untried; then ifelse([$4], , [AC_MSG_FAILURE(dnl [The pkg-config script could not be found or is too old. Make sure it is in your PATH or set the PKG_CONFIG environment variable to the full path to pkg-config. _PKG_TEXT To get pkg-config, see .])], [$4]) else $1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS $1[]_LIBS=$pkg_cv_[]$1[]_LIBS AC_MSG_RESULT([yes]) ifelse([$3], , :, [$3]) fi[]dnl ])# PKG_CHECK_MODULES #^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ #^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ## End: STOLEN FROM A AUTOMAKE/ACLOCAL call ################################################################## ################################################################## jed-0.99-19/autoconf/configure.ac0000644002657400265740000001141611311317447015601 0ustar davisdavisdnl -*- autoconf -*- dnl AC_INIT([Jed],[0.99-19],[jed-users@jedsoft.org]) AC_CONFIG_SRCDIR([src/ledit.c]) JD_INIT AC_CONFIG_AUX_DIR(autoconf) m4_include([./include/pkgcfg.m4]) dnl # infodir="\${JED_ROOT}/info" AC_CANONICAL_HOST AC_PROG_MAKE_SET AC_PROG_RANLIB AC_PROG_INSTALL JD_ANSI_CC JD_ELF_COMPILER PKG_PROG_PKG_CONFIG([0.14.0]) # determine X include and libs for XJed AC_PATH_XTRA #Check these header since they cause trouble AC_CHECK_HEADERS( \ stdlib.h \ unistd.h \ memory.h \ glob.h \ malloc.h \ termios.h \ fcntl.h \ sys/fcntl.h \ sys/pty.h \ pty.h \ ) # special treatment for sys/wait.h AC_HEADER_SYS_WAIT AC_HEADER_DIRENT AC_TYPE_MODE_T AC_TYPE_PID_T AC_TYPE_UID_T AC_CHECK_LIB(util,openpty) AC_CHECK_FUNCS(\ memset \ memcpy \ putenv \ setenv \ unsetenv \ getcwd \ setsid \ tcgetattr tcsetattr cfgetospeed \ grantpt \ setlocale \ utime \ symlink \ gethostname \ tcgetpgrp \ tcsetpgrp \ getpgid \ setpgid \ openpty \ snprintf vsnprintf \ ) AC_CHECK_SIZEOF(short, 2) AC_CHECK_SIZEOF(int, 4) AC_CHECK_SIZEOF(long, 4) AC_CHECK_SIZEOF(float, 4) AC_CHECK_SIZEOF(double, 8) JD_CHECK_LONG_LONG JD_LARGE_FILE_SUPPORT JD_SET_OBJ_SRC_DIR JD_TERMCAP JD_WITH_LIBRARY(slang) JD_GCC_WARNINGS AC_ARG_ENABLE(xft, AS_HELP_STRING([--disable-xft], [disable X FreeType library support (antialiased fonts)]), [enable_xft=$enableval], [enable_xft=default]) if test X"$enable_xft" = Xno then AC_MSG_NOTICE(checking for xft disabled) else AC_CHECK_LIB(Xft, XftFontOpen, [XRENDERFONTLIBS="-lXft" AC_SUBST(XRENDERFONTLIBS) AC_DEFINE(XJED_HAS_XRENDERFONT, 1) AC_PATH_PROG(PKGCONFIG, pkg-config) if test -n "$PKGCONFIG" then X_CFLAGS="$X_CFLAGS $($PKGCONFIG --cflags xft)" fi], [if test X"$enable_xft" = Xyes then AC_MSG_FAILURE([libXft not found]) fi]) fi dnl #------------------------------------------------------------------------ AC_ARG_ENABLE(gpm, AS_HELP_STRING([--disable-gpm], [disable gpm mouse support]), [enable_gpm=$enableval], [enable_gpm=default]) if test X"$enable_gpm" = Xno then AC_MSG_NOTICE(checking for gpm disabled) MOUSELIB="" MOUSEDEFINES="" MOUSE_O_FILE="" else AC_CHECK_LIB(gpm, Gpm_Open, [MOUSELIB="-lgpm" MOUSEDEFINES="-DUSE_GPM_MOUSE" MOUSE_O_FILE="gpmmouse.o" MOUSE_OBJ_FILE="\${OBJDIR}/gpmmouse.o" ], [if test X"$enable_gpm" = Xyes then AC_MSG_FAILURE([libgpm not found]) fi]) fi AC_SUBST(MOUSELIB) AC_SUBST(MOUSEDEFINES) AC_SUBST(MOUSE_O_FILE) AC_SUBST(MOUSE_OBJ_FILE) #--------------------------------------------------------------------------- # gtk #--------------------------------------------------------------------------- AC_DEFUN([WITH_GTK],[ AC_ARG_WITH( [gtk], AC_HELP_STRING([--with-gtk=PATH], [Directory where the pkg-config file gtk+-2.0.pc can be found. This is often /usr/lib/pkgconfig, /usr/lib64/pkgconfig or in a default garnome build of gnome $HOME/garnome/lib/pkgconfig]), GTK_DIR="$withval", GTK_DIR="" ) PKG_CONFIG_PATH="$GTK_DIR" export PKG_CONFIG_PATH PKG_CHECK_MODULES( GTK, [gtk+-2.0 >= 2.8.0], [jd_with_gtk="yes"], [jd_with_gtk="no"] ) echo "GTK dir: $GTK_DIR" AC_MSG_CHECKING([for gtk+-2.0 version >= 2.8.0]) AC_MSG_RESULT([$jd_with_gtk]) AC_MSG_RESULT([CFlags: $GTK_CFLAGS]) AC_MSG_RESULT([Libraries: $GTK_LIBS]) BUILD_GTKJED=$jd_with_gtk AC_SUBST(BUILD_GTKJED) ]) WITH_GTK dnl #------------------------------------------------------------------------ dnl JD_CHECK_FOR_LIBRARY(pcre) dnl if test $jd_with_pcre_library = yes dnl then dnl LINK_LIBPCRE="-lpcre" dnl AC_DEFINE(HAVE_PCRE_H) dnl else dnl LINK_LIBPCRE="" dnl fi dnl AC_SUBST(LINK_LIBPCRE) dnl #------------------------------------------------------------------------ if test "x$prefix" != xNONE; then default_jed_root="$prefix/jed" else default_jed_root="$ac_default_prefix/jed" fi JED_ROOT="${JED_ROOT:-$default_jed_root}" AC_SUBST(JED_ROOT)dnl dnl JD_GET_MODULES(src/modules.unx) dnl JD_CREATE_MODULE_ORULES AC_CONFIG_HEADER(src/sysconf.h:src/config.hin) AC_CONFIG_FILES([Makefile:autoconf/Makefile.in src/Makefile]) AC_OUTPUT dnl JD_CREATE_ORULE(jprocess) dnl JD_CREATE_ORULE(chkslang) dnl JD_CREATE_ORULE(display) dnl JD_CREATE_ORULE(vterm) dnl JD_CREATE_ORULE(xterm) dnl JD_CREATE_ORULE(gpmmouse) dnl JD_CREATE_ORULE(rgrep) dnl JD_CREATE_ORULE(getmail) dnl JD_APPEND_RULES(src/Makefile) echo "" echo "You will need to edit src/Makefile if any of the following are not correct:" echo " CC =" "$CC" echo " CFLAGS =" "$CFLAGS" echo " LDFLAGS =" "$LDFLAGS" "$DYNAMIC_LINK_FLAGS" echo " JED_ROOT =" "$JED_ROOT" echo "" echo "Also edit src/Makefile to enable:" echo " GPM Mouse support (Linux)" echo "You may also want to edit src/jed-feat.h to enable or disable some features." echo "" echo "Before typing 'make', type 'make clean' first." echo "" jed-0.99-19/jed.lis0000644002657400265740000001503511311317447012751 0ustar davisdavis@README @jed.lis @COPYING @COPYRIGHT #FILE_ID.DIZ @INSTALL @INSTALL.be @INSTALL.pc @INSTALL.unx @INSTALL.vms @changes.txt @configure 0755 @autoconf/configure.ac @autoconf/install.sh 0755 @autoconf/mkinsdir.sh 0755 @autoconf/config.sub 0755 @autoconf/config.guess 0755 @autoconf/Makefile.in @autoconf/aclocal.m4 @autoconf/include/pkgcfg.m4 @bin/vms/init_jed.com @bin/vms/jed_mail.com @bin/vms/keptjed.com @bin/w32/README @bin/w32/Makefile @bin/w32/w32shell.c *bin/w32/w32shell.exe *bin/w32/g32shell.exe @doc/README @doc/manual/jed.1 @doc/manual/rgrep.1 @doc/manual/jed.tex @doc/txt/abbrev.txt @doc/txt/menus.txt @doc/txt/color.txt @doc/txt/edt.txt @doc/txt/hooks.txt @doc/txt/jed_faq.txt @doc/txt/mouse.txt @doc/txt/pc-keys.txt @doc/txt/program.txt @doc/txt/rgrep.txt @doc/txt/rmail.txt @doc/txt/script.txt @doc/txt/syntax.txt @doc/txt/fold.txt @doc/txt/wjed.txt @doc/txt/dfa.txt @doc/txt/wordstar.txt @doc/txt/xjed.txt @doc/txt/undo.txt @doc/txt/yankpop.txt @doc/txt/emacs.txt @doc/txt/ide-mode.txt @doc/txt/filelock.txt @doc/txt/compile.txt @doc/txt/linux-keys.txt @doc/txt/utf8.txt @doc/txt/xrenderfont.txt @doc/hlp/jedfuns.hlp @doc/hlp/libfuns.hlp @doc/tm/Makefile @doc/tm/jedfuns.tm #@doc/tm/quickref.tm @doc/tm/README @doc/tm/rtl/tm-sort.sl 0755 @doc/tm/rtl/whatelse.sl 0755 @doc/tm/rtl/abbrev.tm @doc/tm/rtl/blocal.tm @doc/tm/rtl/buffer.tm @doc/tm/rtl/color.tm @doc/tm/rtl/eval.tm @doc/tm/rtl/file.tm @doc/tm/rtl/hidden.tm @doc/tm/rtl/hooks.tm @doc/tm/rtl/info.tm @doc/tm/rtl/insdel.tm @doc/tm/rtl/keys.tm @doc/tm/rtl/mark.tm @doc/tm/rtl/menu.tm @doc/tm/rtl/message.tm @doc/tm/rtl/mini.tm @doc/tm/rtl/misc.tm @doc/tm/rtl/mouse.tm @doc/tm/rtl/move.tm @doc/tm/rtl/process.tm @doc/tm/rtl/rect.tm @doc/tm/rtl/region.tm @doc/tm/rtl/search.tm @doc/tm/rtl/syntax.tm @doc/tm/rtl/userinfo.tm @doc/tm/rtl/terminal.tm @doc/tm/rtl/window.tm @doc/tm/rtl/xjed.tm @info/dir.info @info/info.info @info/jed.1in @info/jed.2in @info/jed.3in @info/jed.info @lib/README @lib/xformreg.sl @lib/tmmode.sl @lib/jed.conf @lib/chglog.sl @lib/emul.sl @lib/hooks.sl @lib/tclmode.sl #@lib/tm2sgml.sl @lib/ashell.sl @lib/bufed.sl @lib/macro.sl @lib/perl.sl @lib/perlxtra.sl @lib/filter.sl @lib/keycode.sl @lib/modehook.sl @lib/comments.sl @lib/brief.sl @lib/lisp.sl @lib/javamode.sl @lib/html.sl @lib/nroff.sl @lib/pscript.sl @lib/abbrev.sl @lib/abbrmisc.sl @lib/binary.sl @lib/bookmark.sl @lib/buf.sl @lib/bytecomp.sl @lib/cal.sl @lib/cmisc.sl @lib/cmode.sl @lib/compile.sl @lib/acompile.sl @lib/cpright.hlp @lib/aboutjed.hlp @lib/ctags.sl @lib/dabbrev.sl @lib/dcl.sl @lib/digraph.sl @lib/dired.sl #@lib/dispesc.sl @lib/dos437.sl @lib/dos850.sl @lib/win1250.sl @lib/dos852.sl @lib/edt.hlp @lib/cua.sl @lib/cuamisc.sl @lib/cua.hlp @lib/edt.sl @lib/emacs.hlp @lib/emacs.sl @lib/emacsmsc.sl @lib/fortran.sl @lib/f90.sl @lib/ff90.sl @lib/generic.hlp @lib/help.sl @lib/jedusage.sl @lib/idl.sl @lib/info.sl @lib/isearch.sl @lib/iso-latin.sl @lib/iso-lat2.sl @lib/iso-lat3.sl @lib/iso2xxx.sl @lib/ispell.sl @lib/jed.hlp @lib/jed.rc @lib/jedhelp.sl @lib/krconv.sl @lib/keydefs.sl @lib/jed.sl @lib/bibtex.sl @lib/latex.sl @lib/latex209.sl @lib/linux.sl @lib/ltx-comp.dat @lib/ltx-math.sl @lib/mail.sl @lib/man.sl @lib/maple.sl @lib/menu.sl @lib/menus.sl @lib/popups.sl @lib/mini.sl @lib/misc.sl #@lib/mkdoc.sl #@lib/mktex.sl @lib/most.sl @lib/mouse.sl @lib/mswmouse.sl @lib/mousex.sl @lib/mutekeys.sl @lib/os.sl @lib/php.sl @lib/pipe.sl @lib/pushmode.sl @lib/pymode.sl @lib/preparse.sl @lib/regexp.sl @lib/replace.sl @lib/rmail.sl @lib/mime.sl @lib/sendmail.sl @lib/seldisp.sl @lib/lua.sl @lib/mailalias.sl @lib/mailedit.sl @lib/mailutils.sl @lib/register.sl @lib/rot13.sl @lib/runpgm.sl @lib/search.sl @lib/shell.sl @lib/shmode.sl @lib/simple.hlp @lib/site.sl @lib/slmode.sl @lib/sort.sl @lib/folding.sl @lib/sortmisc.sl @lib/srchmisc.sl @lib/syntax.sl @lib/tabs.sl @lib/tex.sl @lib/texcom.sl @lib/tmisc.sl #@lib/textmac.sl @lib/textmode.sl @lib/tpascal.sl @lib/untab.sl @lib/util.sl @lib/occur.sl @lib/vms_shell.com @lib/vmshelp.sl @lib/wmenu.sl @lib/wmark.sl @lib/wordstar.sl @lib/wordstar.hlp @lib/yankpop.sl @lib/verilog.sl @lib/spicemod.sl @lib/vhdlmode.sl #@lib/tm/linuxdoc.tm @lib/compat.sl @lib/tiasm.sl @lib/modeinfo.sl @lib/backups.sl @lib/ide.sl @lib/ide.hlp @lib/matlab.sl @lib/rcs.sl @lib/require.sl #@lib/sgml.sl @lib/docbook.sl @lib/aprocess.sl @lib/compress.sl @lib/history.sl @lib/minued.sl @lib/recent.sl @lib/sccs.sl @lib/paste.sl @lib/gpg.sl @lib/syncproc.sl @lib/tmpfile.sl @lib/colors/README @lib/colors/update-colors 0755 @lib/colors/black1.sl @lib/colors/black2.sl @lib/colors/black3.sl @lib/colors/black4.sl @lib/colors/white1.sl @lib/colors/default1.sl @lib/colors/blue1.sl @lib/colors/blue2.sl @lib/colors/blue3.sl @lib/colors/Xjed/pastel0.sl @lib/colors/Xjed/elegant.sl @lib/colors/Xjed/modern.sl @lib/colors/Xjed/night.sl @lib/colors/Xjed/black4.sl @src/DESCRIP.MMS @src/Makefile.in @src/TODO @src/VMSMAKE.COM @src/abbrev.c @src/abbrev.h @src/blocal.c @src/blocal.h @src/buffer.c @src/buffer.h @src/chkslang.c @src/cmds.c @src/cmds.h @src/colors.c @src/colors.h @src/config.hin @src/copyright @src/dfasyntx.c @src/dfasyntx.h @src/display.c @src/display.h @src/dos_os2.c @src/doskeys.h @src/file.c @src/file.h @src/getmail.c @src/gpmmouse.c @src/gtkjed.h @src/gtkmenu.c @src/gtkterm.c @src/gtkwin.c @src/hooks.c @src/hooks.h @src/i386.c @src/ibmpc.c @src/indent.c @src/indent.h @src/ins.c @src/ins.h @src/intrin.c @src/jdmacros.h @src/jed-feat.h @src/jedconf.h @src/jedlimit.h @src/jedwin.c @src/jprocess.c @src/jprocess.h @src/keymap.c @src/keymap.h @src/ledit.c @src/ledit.h @src/line.c @src/line.h @src/lineattr.c @src/lineattr.h @src/lock.c @src/main.c @src/menu.c @src/menu.h @src/misc.c @src/misc.h @src/modules.unx @src/mouse.c @src/mswshell.c @src/os2.c @src/os2mouse.c @src/paste.c @src/paste.h @src/pcmouse.c @src/pcscan.c @src/pty.c @src/replace.c @src/replace.h @src/rgrep.c @src/screen.c @src/screen.h @src/search.c @src/search.h @src/sig.c @src/sig.h @src/syntax.c @src/sysdep.c @src/sysdep.h @src/text.c @src/text.h @src/undo.c @src/undo.h @src/unix.c @src/userinfo.c @src/userinfo.h @src/version.c @src/version.h @src/vfile.c @src/vfile.h @src/vms.c @src/vmshelp.c @src/vmsmail.c @src/vmsmail.h @src/vterm.c @src/vterm.h @src/w32cons.c @src/w32proc.c @src/win16.c @src/win32.c @src/win32.h @src/window.c @src/window.h @src/wterm.c @src/xkeys.c @src/xterm.c @src/mkfiles/makefile.all @src/mkfiles/README *src/mkfiles/mkmake.c *src/mkfiles/mkmake.exe *src/test/runtests.sh 0755 @src/test/test_cmode.sl @src/test/test_cmode.dat @src/test/test_links.sl @src/test/test_narrow.sl @src/test/test_search.sl @src/test/test_replace.sl @src/test/test_expand.sl jed-0.99-19/README0000644002657400265740000000326711311317447012362 0ustar davisdavisREADME file for JED. JED is distributed in two forms: jedXXX.tar.gz: Contains the complete source to the editor. It does not contain the slang library source. The library is available from ftp://space.mit.edu/pub/davis/slang. Building JED requires the use of a C compiler which understands function prototypes. I have sucessfully built JED with `cc' on the ULTRIX, VMS, and IRIX operating systems. In addition, I have created it using `gcc' under SunOS and Linux. See src/mkfiles/README for building it under DOS, OS/2, and Windows systems. jedXXX.zip: Contains no source code but it does include pre-compiled executables for MSDOS and Windows systems. The executable is in the bin directory and will work only on 386+ PCs with a DPMI server, such as provided by Windows (See INSTALL.pc for information regarding the server). The executables were created using gcc for win32 and MSDOS (specifically, MINGW32 and DJGPP). For installation instructions on Unix: read INSTALL.unx VMS: read INSTALL.vms DOS, OS/2, Win9X, NT: read INSTALL.pc Then, read INSTALL for more installation tips. For changes and new features, read changes.txt. Addition information about JED is available from The documentation for the slang library and interpreter is available from and . Useful newsgroups include comp.editors and alt.lang.s-lang. A mailing list is also available. See for more information about it. jed-0.99-19/bin/0000755002657400265740000000000011311317447012242 5ustar davisdavisjed-0.99-19/bin/vms/0000755002657400265740000000000011311317447013047 5ustar davisdavisjed-0.99-19/bin/vms/jed_mail.com0000644002657400265740000000273211311317447015317 0ustar davisdavis$ ! Command procedure to invoke an editor for MAIL. $ ! $ ! Inputs: $ ! $ ! P1 = Input file name. $ ! P2 = Output file name. $ ! $ ! If MAIL$EDIT is undefined, MAIL will invoke callable EDT. $ ! If MAIL$EDITis defined to be a command procedure, $ ! MAIL will create a subprocess to edit the mail. $ ! $ ! Note that this procedure is run in the context of a subprocess. $ ! LOGIN.COM is not executed. However, all process logical names $ ! and DCL global symbols are copied. $ ! $ ! The default directory is the same as the parent process $ ! $!++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ $! $! jed: $! $! $!++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ $! $! *** jed *** $! $ VERIFY = F$VERIFY (0) $ define/job/nolog jed_attach_to 'f$getjpi("", "PID") $ define /user sys$input 'f$trnlnm("SYS$OUTPUT")' $ if (p1 .EQS. "") THEN GOTO NO_INPUT_jed $! $ copy 'p1' 'p2' $! $ No_Input_Jed: $! $ priv_list = f$setprv ("NOWORLD, NOGROUP") $ pid := 'f$trnlnm("JED_PID")' $ if (pid .eqs. "") then goto no_attach $ context = 0 $ Loop: $ if (pid .eqs. f$pid ( context )) then goto attach $ if (context .ne. 0) then goto loop $! $ no_attach: $ priv_list = f$setprv (priv_list) $ runjed 'p2' $ goto done $ attach: $ priv_list = f$setprv (priv_list) $ define/nolog/job jed_file_name "''p2'" $ attach/id = 'pid' $ deassign/job jed_file_name $ done: $! $ IF (VERIFY) THEN SET VERIFY $ EXIT jed-0.99-19/bin/vms/init_jed.com0000644002657400265740000000231111311317447015331 0ustar davisdavis$! This file defines the appropriate symbols for JED. It requires $! two parameters: $ define/job jed_library jed_root:[lib] $ jedexe = "jed_root:[bin.vms]jed." + f$getsyi("ARCH_NAME") + "_EXE" $ if (p1 .nes "0") .and. (p1 .nes. "1") then goto USAGE $ if (p2 .nes "0") .and. (p2 .nes. "1") then goto USAGE $ if (p1 .eqs. "1") then goto KEPT $! $! simple editor $! $ runjed :== $'jexexe' $ jed :== $'jedexe' $ goto do_mail $! $ kept: $ runjed :== $'jedexe' $ jed :== @jed_root:[bin.vms]keptjed.com $ do_mail: $ if (p2 .nes. "1") then goto done $ define/job mail$edit "@jed_root:[bin.vms]jed_mail.com" $ done: $ exit $! $ usage: type sys$input This command procedure requires two parameters with the value of either 0 or 1. If first parameter is 1, it indicates that JED is to run as a kepteditor otherwise JED is run as a normal executable. If the second parameter has a value of 1, JED is used as the editor for mail. So, the following are valid: @jed_root:[bin.vms]init_jed 0 0 !normal/no mail @jed_root:[bin.vms]init_jed 0 1 !normal/mail @jed_root:[bin.vms]init_jed 1 0 !kept/nomail <-- most systems @jed_root:[bin.vms]init_jed 1 1 !kept/mail $ exit jed-0.99-19/bin/vms/keptjed.com0000644002657400265740000000424411311317447015201 0ustar davisdavis$ verify = f$verify (0) $! $! Kept_Jed.com --- basede on kepteditor.com by Joe Kelsey $! $! Defines the PF1 key to reattach instantly instead of going back $! through this file again. $! $ if p1 .eqs. "-BATCH" $ then $ runjed 'p1' 'p2' 'p3' 'p4' 'p5' 'p6' 'p7' 'p8' 'p9' $ exit $ endif $! $ name = "JED " + f$trnlnm ( "TT" ) - ":" $ priv_list = f$setprv ("NOWORLD, NOGROUP") $ context = 0 $ Loop: $ pid = f$pid ( context ) $ proc = f$getjpi (pid, "PRCNAM") $ if proc .eqs. name then goto attach $ if context .ne. 0 then goto Loop $! $ args = p1 + " " + p2 + " " + p3 + " " - + p4 + " " + p5 + " " + p6 + " " + p7 + " " + p8 $ priv_list = f$setprv ( priv_list ) $ write sys$error "[Spawning a new Kept JED]" $ define/user sys$input sys$command $ spawn/nolog/process="''name'" runjed 'args' $! $! define gold key (PF1) to immediately attach $! $ context = 0 $ gold_loop: $ pid = f$pid ( context ) $ proc = f$getjpi (pid, "PRCNAM") $ if proc .eqs. name then goto gold_loop_exit $ if context .ne. 0 then goto gold_loop $ goto quit !could not find jed process so we quit $! $ gold_loop_exit: $ define/key/nolog/terminate/noecho pf1 "attach/ident=''pid'" $ define/nolog/job JED_PID "''pid'" $ goto quit $! $! $ attach: $ priv_list = f$setprv ( priv_list ) $ message_status = f$environment("message") $ set noon $ set message /nofacility/noidentification/noseverity/notext $ set on $ set message 'message_status $ if p1 .eqs. "" then goto no_logical $ temp = f$trnlnm("SYS$DISK") + f$directory() + p1 $ temp = f$edit(temp,"lowercase") $ define/nolog/job jed_file_name "''temp'" $ no_logical: $ write sys$error "[Attaching to process ''NAME']" $ define/user sys$input sys$command $ attach "''NAME'" $! $ quit: $! $ message_status = f$environment("message") $ set noon $ set message /nofacility/noidentification/noseverity/notext $ deassign/job jed_file_name $ set on $ set message 'message_status $ write sys$error - "[Attached to DCL in directory ''F$TRNLNM("SYS$DISK")'''F$DIRECTORY()']" $ if verify then set verify $ exit jed-0.99-19/bin/w32/0000755002657400265740000000000011311317447012655 5ustar davisdavisjed-0.99-19/bin/w32/g32shell.exe0000644002657400265740000001000011311317447014772 0ustar davisdavisMZÿÿ¸@€º´ Í!¸LÍ!This program cannot be run in DOS mode. $PELï ’7à 7 H @P@.textð `.data  @À.bss 0€À.idata@ @Àr_t* ws1, const wchar_t* ws2); int _wcsicoll (const wchar_t* ws1, const wchar_t* ws2); wchar_t* _wcslwr (wchar_t* wsToConvert); int _wcsnicmp (const wchar_t* ws1, const wchar_t* ws2, size_t sizeMaxCompare); wchar_t* _wcsnset (wchar_t* wsToFill, wchar_t wcFill, size_t sizeMaxFill); wchar_t* _wcsrev (wchar_t* wsToReverse); wchar_t* _wcsset (wchar_t* wsToFill, wchar_t wcToFill); wchar_t* _wcsupr (wchar_t* wsToConvert); void* memccpy (void*U‰åƒìÿ5 @EüPh @h @èaÉÃvU‰å‹ @…Òtk¡ @@‰¡¨@@…Àtÿ5 @Pè#ƒÄPè"ƒÄ¡¨@@P …Òtÿ5 @RèÿƒÄPèþƒÄ¡¨@@ƒÀ@tÿ5 @Pè݃ÄPèÜÉÉöU‰åVS‹E1Û1ö‹‹=‘Àw=ÀsB=Àtëv=“Àt2=”Àt0ëfjj 舃ăøu jj èwëE…ÀtFj ë;t&¾jjèZƒÄƒøujjèIƒÄ…ötè5ë v…Àt jÿлÿÿÿÿ‰Øeø[^ÉÉöU‰åSh @èZèè þÿÿè¿þÿÿ¡Ð@@ÿ0ÿ5 @ÿ5 @è#‰ÃèÔSè.‰öU‰åè´ÿÿÿÉÃOut of memory U‰åƒì WVS‹u1ÛÇEü;] s$‰òt&‹:1Àü¹ÿÿÿÿò®÷Ñ˃ÂÿEü‹E 9EürâCP詉EøƒÄ…Àuh @¡¨@@ƒÀ@Pè„1ÀëP1ÛÇEü;] s8ÿ6‹EøØPè]‹>1Àü¹ÿÿÿÿò®÷Ñ\ ÿ‹EøÆ CƒÄƒÆÿEü‹E 9EürÈ‹EøÆ‹EøeÔ[^_ÉÃUsage: %s CMD‰ö%s: Command '%s' failed to run U‰åƒì`WVS‹}‹u èlƒÿuÿ6hp@¡¨@@ƒÀ@PèÊé¹GÿPFPèÐþÿÿ‰ÃƒÄ…Û„Ÿ}°1Àü¹ó«ÇE°DÇEÜjö豉Eèjõ觉Eìjôè‰EðE PE°PjjjjjjSj膅Àt*jÿÿu è€ÿu è€ÿu¤èxSè"1Àë'¶Sÿ6h€@¡¨@@ƒÀ@PèSèü¸e”[^_ÉÃU‰å¡ @ƒ8t v¡ @‹ÿС @P‰ @ƒxuãÉÃU‰åS‹à@ƒúÿu1Òƒ=ä@t¹à@¸ƒÀBƒ<uö‰Ó…Ût ‹à@ÿÐKuôh @莋]üÉÃU‰åƒ= @uÇ @è•ÿÿÿÉÃÿ% @@ÿ%¨@@ÿ%Ð@@ÿ%È@@ÿ%¤@@ÿ%Ä@@ÿ%Ô@@ÿ%°@@ÿ%¬@@ÿ%¼@@ÿ%Ì@@ÿ%¸@@ÿ%À@@ÿ%´@@ÿ%è@@ÿ%ô@@ÿ%ä@@ÿ%ì@@ÿ%ð@@ÿ%à@@ÿÿÿÿÿÿÿÿReverse); wchar_t* wcsset (wchar_t* wsToFill, wchar_t wcToFill); wchar_t* wcsupr (wchar_t* wsToConvert); # 7 "C:\\CC\\MINGW32\\BIN\\..\\lib\\gcc-lib\\i386-mingw32\\egcs-2.91.66\\..\\..\\..\\..\\i386-mingw32\\include\\memory.h" 2 3 # 19 ÿÿÿÿì@ # 16 "./wterm.c" 2 # 1 "C:\\CC\\MINGW32\\BIN\\..\\lib\\gcc-lib\\i386-mingw32\\egcs-2.91.66\\..\\..\\..\\..\\i386-mingw32\\include\\process.h" 1 3 # 1 "C:\\CC\\MINGW32\\BIN\\..\\lib\\gcc-lib\\i386-mingw32\\egcs-2.91.66\\..\\..\\..\\..\\i386-mingw32\\include\\sys/types.h" 1 3 @@\B @€@€Bà@ü@ AA A0A #include #include #include #ifdef __MINGW32__ # ifdef NO_GLOBBING int _CRT_glob = 0; # endif #endif /* The more I learn about this OS, the less I care for it. This program * is necessary to run pipes. Yuk! */ static char *build_cmd (char **args, unsigned int num) { unsigned int len; unsigned int i; char *buf; len = 0; for (i = 0; i < num; i++) len += strlen (args[i]) + 1; if (NULL == (buf = malloc (len + 1))) { fprintf (stderr, "Out of memory\n"); return NULL; } len = 0; for (i = 0; i < num; i++) { strcpy (buf + len, args[i]); len += strlen (args[i]); buf[len] = ' '; len++; } buf[len] = 0; return buf; } int main (int argc, char **argv) { STARTUPINFO si; PROCESS_INFORMATION pi; char *cmd; if (argc == 1) { fprintf (stderr, "Usage: %s CMD", argv[0]); return 1; } if (NULL == (cmd = build_cmd (argv + 1, argc-1))) return 1; memset ((char *) &si, 0, sizeof (STARTUPINFO)); si.cb = sizeof(STARTUPINFO); si.dwFlags = STARTF_USESTDHANDLES; si.hStdInput = GetStdHandle (STD_INPUT_HANDLE); si.hStdOutput = GetStdHandle (STD_OUTPUT_HANDLE); si.hStdError = GetStdHandle (STD_ERROR_HANDLE); if (FALSE == CreateProcess (NULL, cmd, NULL, NULL, TRUE, 0, NULL, NULL, &si, &pi)) { fprintf (stderr, "%s: Command '%s' failed to run\n", argv[0], cmd); free (cmd); return 1; } WaitForSingleObject (pi.hProcess, INFINITE); CloseHandle (pi.hProcess); CloseHandle (pi.hThread); free (cmd); return 0; } jed-0.99-19/bin/w32/README0000644002657400265740000000034411311317447013536 0ustar davisdavisw32shell.exe and g32shell.exe are necessary for the win32 versions of jed to execute shell commands. Do NOT move it from this directory. g32shell.exe performs globbing on its command line arguments, but w32shell.exe does not. jed-0.99-19/bin/w32/w32shell.exe0000644002657400265740000001000011311317447015012 0ustar davisdavisMZÿÿ¸@€º´ Í!¸LÍ!This program cannot be run in DOS mode. $PELð ’7à 7 H @P@.textð `.data  @À.bss 0€À.idata@ @ÀâPšWémÿFâPjjjjš" ÀuéŽÄ^&‹G& Gt3Ûë»ÿÿ‰^ô Û}ép‹^&Ä_kFô؉^ÞŒFà&‹_Äv&‹D & Dt/ Ûu+ÿvÿvÿvÿv ÿv ‹Þ&ÿw &ÿw&Ä_&Ä&ÿ_ƒÄé‹FÞ‹Và‰Fü‰Vþ¹‹øvâŽÂÑéÀ;Éó§u+Èó¦tvâŒÐŽØÄ~ü¹ ó¥éßNâQÄ^ü&ÿ7&ÿw&ÿwjšÿÿ‹Fü‹Vþ¹‹øvâŽÂÑéÀ;Éó§u+Èó¦td~är FâPšÿÿé|~äuérƒ~ä#uéi~är ~ä wéX~ä r ~ä©wéG~är ~äwé6ÿvâÿväé‹Näƒùuéƒùuéƒùuéÿƒùué÷ùuéîù‚uéåùuéîƒù#uéæùr ù wé×ù r ù©wéÈùr ùwé¹U‰åƒìÿ5 @EüPh @h @èaÉÃvU‰å‹ @…Òtk¡ @@‰¡¨@@…Àtÿ5 @Pè#ƒÄPè"ƒÄ¡¨@@P …Òtÿ5 @RèÿƒÄPèþƒÄ¡¨@@ƒÀ@tÿ5 @Pè݃ÄPèÜÉÉöU‰åVS‹E1Û1ö‹‹=‘Àw=ÀsB=Àtëv=“Àt2=”Àt0ëfjj 舃ăøu jj èwëE…ÀtFj ë;t&¾jjèZƒÄƒøujjèIƒÄ…ötè5ë v…Àt jÿлÿÿÿÿ‰Øeø[^ÉÉöU‰åSh @èZèè þÿÿè¿þÿÿ¡Ð@@ÿ0ÿ5 @ÿ5 @è#‰ÃèÔSè.‰öU‰åè´ÿÿÿÉÃOut of memory U‰åƒì WVS‹u1ÛÇEü;] s$‰òt&‹:1Àü¹ÿÿÿÿò®÷Ñ˃ÂÿEü‹E 9EürâCP詉EøƒÄ…Àuh @¡¨@@ƒÀ@Pè„1ÀëP1ÛÇEü;] s8ÿ6‹EøØPè]‹>1Àü¹ÿÿÿÿò®÷Ñ\ ÿ‹EøÆ CƒÄƒÆÿEü‹E 9EürÈ‹EøÆ‹EøeÔ[^_ÉÃUsage: %s CMD‰ö%s: Command '%s' failed to run U‰åƒì`WVS‹}‹u èlƒÿuÿ6hp@¡¨@@ƒÀ@PèÊé¹GÿPFPèÐþÿÿ‰ÃƒÄ…Û„Ÿ}°1Àü¹ó«ÇE°DÇEÜjö豉Eèjõ觉Eìjôè‰EðE PE°PjjjjjjSj膅Àt*jÿÿu è€ÿu è€ÿu¤èxSè"1Àë'¶Sÿ6h€@¡¨@@ƒÀ@PèSèü¸e”[^_ÉÃU‰å¡ @ƒ8t v¡ @‹ÿС @P‰ @ƒxuãÉÃU‰åS‹à@ƒúÿu1Òƒ=ä@t¹à@¸ƒÀBƒ<uö‰Ó…Ût ‹à@ÿÐKuôh @莋]üÉÃU‰åƒ= @uÇ @è•ÿÿÿÉÃÿ% @@ÿ%¨@@ÿ%Ð@@ÿ%È@@ÿ%¤@@ÿ%Ä@@ÿ%Ô@@ÿ%°@@ÿ%¬@@ÿ%¼@@ÿ%Ì@@ÿ%¸@@ÿ%À@@ÿ%´@@ÿ%è@@ÿ%ô@@ÿ%ä@@ÿ%ì@@ÿ%ð@@ÿ%à@@ÿÿÿÿÿÿÿÿvühÄ^ &ÿw&ÿ7šÿÿƒÄ‹F Ft0Ä^ô&ƒ u&&"0uÿvÿv&ÿw*&ÿw(ÿvÿvšÿÿ‹ð‰VúÿvòÿvðšÿÿÿvöÿvôšÊ‹Æ‹Vú^_ÉÊÈWV+À‰Fî‰FìÄ^&‰G&‰FìP‹F‹V‹È‹ÚÀÒÁÓÀÒÀÒƒÒRPš§ƒÄ Fð‰Vò Ðtéž3À‹N‹^ì‹Vî‹ñÉÎÁáƒÁ‹ûŽÂÑéó«sª‹V‰vü‰Vþ‹Fì‰FøŒFú‹F‹V‰Fô‰Vö‹vøì@ÿvÿv ÿvúVÿv šÿÿ‰Fð‰Vò Ðu$Ä^ì&ƒ&ƒWƒÇƒÆ 뺋Fì‹VîÄ^&‰&‰W‹Fò Fðt ÿvîÿvìšÿÿ‹Fð‹Vò^_ÉÊ¸Ê ¸ÿÿŽØ¸ÊÈLWV‹~+À‰Fú‰Fø‰Fö‰FôÄ^ &‰G&‰FøPjj‹FPWŽÀ&Ä&ÿ_8ƒÄ ‹ð‰Vþ Ðté¾jjÿvÿvÄ^øS&Ä&ÿ_ƒÄ ‹ð‰Vþ Ðté™öFtWÿvÿvÿvÿvjjF´PFäPFôPšÿÿ‹ð‰Vþ Ò|f‹Fö Fôt"jjÿvöÿvôÄ^øS&Ä&ÿ_8ƒÄ ‹ð‰Vþ Ðu<öFt&öFt jjhÄ^øS&Ä&ÿ_DƒÄ ‹ð‰Vþ Ðu‹Fø‹VúÄ^ &‰&‰W‹Æ‹Vþ^_ÉÊÈWV‹~‹vÿvVÿvÿvÿv ÿv ÿvWšÿÿ‰Fü‰Vþ Ðté•ÿvVÿvÿvÿv ÿv ‹Ç‹V RPE$RPšÿÿ‰Fü‰Vþ ÐugÿvV@@\B @€@€Bà@ü@ AA A0A exists include it (culliton at io, com) 28. lib/ctags.sl,cmode.sl,...: skip_chars("..\\X..") was replaced by skip_chars("..\\\\X..") since \\X specifies a character class X. 29. src/file.c: If the inode/device of the file associated with the current buffer has changed, set the buffer's FILE_MODIFIED flag. 30. lib/ctags.sl: Modified to use buffer-local variables Word_Chars and Tags_File when they exist. Also, the global variable Tag_File was renamed to Tags_File. 31. lib/rmail.sl: rmail_output_to_folder now takes an optional argument: the folder name. 32. lib/ispell.sl: Use a try/catch block instead of an ERROR_BLOCK for better stack maintenance. 33. lib/site.sl,lib/os.sl: The definition of define_blocal_var has been moved from os.sl to site.sl. Documentation for the functions was provided by G. Milde. 34. lib/site.sl+others: When linked against slang versions >= 2.1.x, use the && and || operators instead of the andelse/orelse constructs. 35. lib/perl.sl: Updated to Mark Olesen's latest version. Also added perlxtra.sl. 36. lib/colors/[Xjed/]black4.sl: Updated (Mark Olesen). 37. src/ledit.c: In the filename completion window, do not show the full pathnames. Otherwise a pathname could exceed the size of the window rendering it useless. 38. lib/cmode.sl: Fixed a number of minor annoyances of the indent-line routines, including: * the indentation of array elements and lists. * multiline preprocessor macros. * "stairstepping" of multiple continued lines. Also calls to c_indent_line have been changed to indent_line to allow the resulting behavior to be influenced by the buffer-hooks. Shamelessly stole some of the comments from Mark Olesen's cmode.sl. 39. lib/bytecomp.sl: perlxtra.sl added to be preparsed. 40. lib/cmode.sl: Do not indent successive lines of a structure. 41. lib/ispell.sl: "finally:" changed to "finally" for compatibility with older versions of slang-2. 42. lib/cmode.sl: Additional comments and a small change so that trailing whitespace does not affect the indentation of ')'. (Mark Olesen). 43. src/test/*.sl: changed "static" to "private". 44. src/test/test_cmode.*: Regression script for cmode.sl 45. lib/isearch.sl: Added Isearch_Highlight variable to control whether or not the match should be highlighted. 46. lib/cmode.sl: Merged Mark Oleson's patches that support "foam-style" indentation. 47. src/undo.c: New intrinsic "set_undo_position" that may be used to set a buffer position that "undo" will use. 48. lib/site.sl: Files with .pm extensions will use perl-mode. 49. lib/perl*.sl: Fixed a couple of small problems with the embedded tm documentation that caused tmexpand to balk. 50. src/ledit.c: Made slang array intrinsics available to jed: transpose, sum, cumsum, array_swap, array_reverse, min, max, any, all This was motivated by the use of modules that assume these functions are available. 51. src/*.sl: Changed 'if (length(where(foo)))' to 'if (any(foo))'. This change also makes the code more readable, e.g., compare if (length (where (List_Of_Buffers == buf))) do_something (); to if (any (List_Of_Buffers == buf)) do_something (); 52. lib/site.sl: A typo introduced in #49 was corrected (Paul Boekholt). 53. lib/slmode.sl: Added "then" and "ifnot" as a keywords, which slang 2.1 uses. 54. src/main.c: When run as jed-script, error messages were not always written out. 55. lib/compress.sl: A reference argument may be used to get the current compression mode. 56. lib/popups.sl: Add support for compressed documentation files. 57. doc/...: Some documentation tweaks (Jörg Sommer). 58. src/menu.c: UTF-8 "hot keys" were not being written properly (Jörg Sommer). 59. lib/python.sl: Do not use both tabs and spaces when indenting. Also, avoid treating "passport" and "returning" as block delimiters. Added python2 keywords. Added support for prefix arguments to the region shift functions. (Jörg Sommer). 60. lib/help.sl: Enhanced version of describe_bindings (Jörg Sommer): * It makes all key descriptions are aligned among each other, * it splits the listing into two sections: one with the keys defined in the global mode and one with the keys special to this mode * it prints the description of the function bound to the key behind the function 61. lib/info.sl,site.sl,..: info_mode renamed to info_reader_mode. This way files such as foo.info can be edited. 62. lib/site.sl: ^Hb will run describe_bindings (Rafael Laboissiere). 63. lib/cmode.sl: When building the function list avoid adding "if", "while", etc, which can occur outside a function. (Jörg Sommer) 64. lib/help.sl: Use an associative array to cache previous calls to "help_get_doc_string". (Paul Boekholt) 65. lib/mouse.sl: A new variable called Mouse_Selection_Word_Chars may be used to define the set of characters that will be used for "double-click" selections. 66. lib/mouse.sl: Fixed a bug involving pasting via the middle mouse button in the presence of a visible mark. 67. src/text.c: skip_chars_forward/backward: Treat a the complement of "^SET" as "SET". 68. lib/text.sl: newline_indent_hook bound to text_newline_and_indent_relative. 69. lib/help.sl: If Help_Describe_Bindings_Show_Synopsis is non-zero, key descriptions will be displayed by the describe_bindings function. The default setting is 0. 70. lib/site.sl: The slsh help directories have been added to the list of documentation files since it is possible for jed to utilize those functions. 71. lib/info.sl: merged info_reader_mode into info_reader, since strictly speaking info_reader_mode is not an editing mode. I also added info_mode to compat.sl for backward compatibility. Please migrate to using info_reader instead of info_mode. (See #61 above). 72. lib/site.sl: The slsh help directories were added to the list of directories to search for documentation. This was done because jed can use slsh library files and modules. 73. lib/help.sl: If a documentation file is specfied as a directory, then all files with a .hlp extension will be searched in that directory. 74. lib/ispell.sl: The character range "a-zA-Z" was replaced by "\a"R, which represents any alphabetic character. Also ',' is assumed to be the delimiter used by ispell instead of a space character (Jörg Sommer). 75. lib/php.sl: Fixed indentation problem on the second line of scripts starting with . (Paul Boekholt). 76. autoconf/aclocal.m4: Added rpath support for OpenBSD. 77. src/cmds.c: Changed quoted_insert to insert a byte instead of a wchar, unless the value was specified via a prefix argument. 78. lib/textmode.sl: Unset the indent and newline_and_indent hooks because the "indent_text_relative" routines did not seem to useful for ordinary text files. 79. lib/history.sl: Ignore errors in saving the history at exit (Paul Boekholt). 80. lib/cmode.sl: Don't indent the second, third, etc items of a list that follows an open parenthesis. Also Mark Oleson corrected an off-by-1 error when indenting foam-style constructs. 81. doc/txt/dfa.txt: Updated for slang-2 and some additional clarifications (Guenter Milde). 82. lib/site.sl: provide/require were removed and are now autoloaded from require.sl, which itself was updated to the latest slsh version. 83. lib/xform.sl: Eliminated the use of narrow_to_region by these functions. This fixes a problem with capitalize_word when used in the minibuffer. 84. lib/site.sl: Documentation for `double_line` (Jörg Sommer). 85. lib/site.sl: Handle a possible NULL return value by guess_jed_install_prefix. 86. lib/man.sl: Remove strange <88> combinations that appeared in man pages after upgrading to Debian Etch. 87. src/jprocess.c: If a read/write operation on a descriptors returns with errno=EIO, then flag it to not be used by the select system call. 88. src/xterm.c: The x_toggle_visibility function may be used to raise or lower the window associated with Xjed. (Jörg Sommer). 89. src/*.c, *.h: Some of the files were missing the GPL copyright. (Jörg Sommer). 90. src/unix.c: The wrong value of max_fd was getting passed to select. 91. src/jprocess.c: The test for errno==EIO was not being made. 92. src/unix.c: Testing subprocess descriptors via FD_ISSET was also testing those with EIO errors. 93. src/xform.c: capitalize_region was not working with single character regions. 94. src/jprocess.c: fd was being passed to flag_fd_as_eio_error instead of p->rd. (Joerg Sommer). 95. lib/mime.sl: Use byte-semantics for parsing quoted-printable. 96. lib/perl.sl: When searching for a matching '{', ignore fold marks. 97. src/buffer.c:remake_line: If the line is to be made shorter, then reallocate the buffer associated with it. 98. src/lock.c: Add support for errno = EOPNOTSUPP return value from symlink. 99. src/misc.c: msg_error changed to call SLang_verror instead of SLang_set_error. This allows, among other things, exceptions to access jed error messages. 100. src/jprocess.c: Fixed a race condition in the master/slave pty code. 101. lib/html.sl: If _Reserved_Key_Prefix is NULL, do not use if in calls to un/definekey. 102. Updated aclocal.m4 for better CYGWIN support 103. src/pcmouse.c: Use jed_insert_nbytes instead of jed_insert_chars. (Robert Riebisch). 104. src/mkfiles/makefile.all: Add -lm to the LINK macro for DJGPP (Robert Riebisch). 105. src/wterm.c: In enable_menu_item, changed MF_GRAYED to MF_DISABLED (Joerg Sommer). 106. lib/cmode.sl: Fixed enum indentation (Marc Butler) 107. src/misc.c: In BATCH mode read_mini() should not print the default string if it is the empty string (Joerg Sommer). 108. lib/emacsmsc.sl:string_rectangle: If the rectangle has no width, then do not delete it. (Joerg Sommer). 109. lib/bytecomp.sl: Removed require.sl from the list of files to be preparsed. 110. src/xterm.c,screen.c,mouse.c: Small tweaks to avoid gcc warnings (Joerg Sommer). 111. src/screen.c: A space character was omitted from the new sprintf format string used in #110. This affect the display of line numbers. 112. lib/cmode.sl: Added addtional C indentation variables: C_Label_Offset, C_Label_Indents_Relative, C_Outer_Block_Offset. 113. doc/tm/hooks.tm: Added documentation for _jed_run_hooks (Joerg Sommer). 114. src/wterm.c: Corrected a typo in the documentation for w32_enable_menu_item_pos (Joerg Sommer). 115. src/text.c: Modified the wrapping algorithm for better performance. 116. src/text.c: Change #115 introduced a bug triggered when the length of the "word" is larger than the value of the wrap column. (Paul Boekholt). 117. src/cmds.c: When inserting multiple spaces beyond the wrap column, the editing point would always stay on the current line instead of moving to the next line after the wrap. 118. lib/keydefs.sl: Work around an incorrect rxvt terminfo entry for Shift-Insert. 119. src/ins.c: Handle return value from jed_lock_buffer_file to avoid modifying a locked buffer. 120. configure: Updated configure script using the latest aclocal.m4 file. 121. src/dfasyntax.c: Tweaked the code to avoid writing single bytes of a multi-byte character. 122. src/buffer.c: Added get_buffer_hook function. 123. lib/texcom.sl: rewrote tex_blink_dollar to not the use narrow_to_region. 124. lib/site.sl: When creating an autosave-filename from a template name, expand any symbolic links that occur in the template name. This ensures that the autosave file will be created in the actual directory of the file and not in the directory of the symbolic link. 125. lib/cmode.sl: Only indent as a label if the label name is present. 126. src/syntax.c: Added support for syntax-coloring of tab characters. To this end, Highlight_Trailing_Whitespace variable has been deprecated in favor of Highlight_Whitespace, which is a new bitmapped variable: Highlight_Whitespace = 1; % highlight trailing whitespace Highlight_Whitespace = 2; % highlight tabs Highlight_Whitespace = 3; % highlight tabs and trailing ws 127. lib/digraph.sl: Added support for ä, ë, etc via a ':' prefix. 128. lib/mail.sl,sendmail.sl: The mail_format_buffer now allows a list of optional headers to add to the buffer. 129. lib/cmode.sl: The is_label_statement function is now a bit smarter; previously it would sometimes interpret a ternary statement as a label statement. 130. src/Makefile.in: variation of a patch from Joerg Sommer to allow debian to install bin files separately from data and lib files. 131. src/gpmmouse.c: Do not use GPM if running in xterm or rxvt (Joerg Sommer). 132. doc/tm/rtl/mini.sl: Documentation tweaks (Joerg Sommer) 133. src/keymap.c: The LASTKEY variable was not being updated before _jed_before_key_hooks. (Joerg Sommer) 134. lib/help.sl: Handle keybindings to macros and bindings that contain newlines. (Joerg Sommer) 135. doc/manual/jed.1: Updates to the man page (Joerg Sommer) 136. doc/txt/jed_faq.txt: Updates to the FAQ (Joerg Sommer) 137. lib/site.sl: jed_append/insert_doc_file will update slang's internal doc file list via set_doc_files. Eventally Jed_Doc_Files will go away in favor of get_doc_files. (Joerg Sommer). 138. lib/site.sl, src/ledit.c, src/main.c: The get/set_jed_library_path functions have been deprecated in favor of get/set_slang_load_path and prepend/append_to_slang_load_path. (Joerg Sommer) 139. src/screen.c: Multibyte characters in the status line string were not being processed (Paul Boekholt). 140. autoconf/aclocal.m4: Reimplemented JD_CHECK_FOR_LIBRARY. 141. lib/site.sl: Add the slsh library directory to the slang load path even if it does not contain a local-packages sub-directory (Joerg Sommer). 142. src/ledit.c: Changed the error message generated when unable to open a .sl to something less confusing (Suggested by Guenter Milde). 143. lib/dabbrev.sl: Byte semantics instead of character semantics were used during expansion causing problems with words that contain multibyte characters. 144. lib/site.sl: Updated doc for search_path_for_file 145. lib/os.sl: In dfa_enable_highlight_cache Explicitly pass a comma to search_path_for_file function. A similar change was made in preparse.sl. 146. lib/ctags.sl: use atoi instead of integer. 147. src/Makefile.in: Use `test -r` instead of `test -e` because some versions of test do not support -e. 148. src/Makefile.in: Minimum slang version set to 2.1.0. Also buffer.h added as a global dependency. 148. lib/site.sl: Some code simplified by using "&&". 149. lib/cmode.sl: Ternary statements with a colon at the end of the line were being interpreted as label statements. 150. src/Makefile.in: Added support for configure --infodir=value (Joerg Sommer). 151. src/sysdep.c: Use memmove instead of an explicit loop. (Joerg Sommer). 152. lib/site.sl: The goto_top/bottom_of_window functions were not accounting for hidden lines (Joerg Sommer). 153. lib/html.sl: Use " /dev/c/0013 to be interpreted as a C file. 37. src/win32.c: differentiate between (shift|alt|ctrl)-backspace (John Skilleter ) 38. src/cmisc.sl: Make c_end_of_function symmetric with c_top_of_function. (Reuben Thomas ) 39. src/wterm.c: fix problem with calculation of font-height for wjed. Also added new intrinsic for setting the font: w32_select_font (John Skilleter) 40. New internal hooks added: _jed_before_key_hooks, _jed_after_key_hooks 41. lib/wmark.sl: rewritten to use _jed_before/after_key hooks. The result is that one is now able to use the regions with menu and minibuffer commands. 42. lib/popups.sl: Edit menu enhanced with more region functions. Register functions moved to region functions popup. 43. src/menu.c: disabled access to the menus from the minibuffer 44. lib/cmode.sl: added mode-specific menu entries to list all functions and macros defined by the file. This affects C mode and SLang mode. 45. New intrinsics: exit, _exit. These are useful in jed scripts to return an exit value to the shell. exit is like exit_jed and _exit is like quit_jed except an argument is required. 46. lib/tmmode.sl: This file implements the tm_mode for editing text-macro files. In addition, the text-macro processing code (textmac.sl) was removed from the jed distribution as well as lib/tm/*. Instead, the text-macro processing code and macros will be made available as a separate package. 47. src/sig.c: Changed the way SIGHUP and SIGTERM are handled to avoid a possible race condition. 48. lib/latex.sl,ltx-math.sl: If another tex file was loaded while latex math mode was active, then latex_math_mode would cease to work in the first buffer. This has been fixed. 49. lib/perl.sl: Updated to Mark Olesen's latest version. See lib/perl.sl for details. 50. lib/sccs.sl: New file supporting SCCS revision control (Philip Brown). 51. src/intrin.c: New intrinsic function: run_program. This plays the same role as the "system" function except jed resets the display first, if run in a terminal. For X, it runs the specified program in another xterm, or the terminal set by the XTerm_Pgm variable. *** Note: This function needs to be fixed to work asynchronously on win32. Any volunteers?? 52. src/xterm.c: Added Charl Botha's XRENDER patch to Xjed. 53. lib/ide.sl: Remove references to ide_function_help (Guido Gonzato). 54. lib/site.sl: save_buffer was not calling read_file_from_mini without a prompt string 55. doc/tm/*.tm: removed docs for obsolete functions 56. lib/mouse.sl: wheel mouse was not ignoring hidden lines 57. lib/f90.sl: Merged fix and free formats into the same file. In addition to f90_mode, there is now f90_fixed_format_mode and f90_free_format_mode. The default format for f90_mode is "free", which may be set via the F90_Default_Format variable. 58. lib/registers.sl: rewritten to allow registers to be given meaningful names by the user. Also, fixed limit of 95 registers removed. 59. lib/folding.sl: Fixed endless loop during a call to fold_whole_buffer when a fold-start mark is at the end of the buffer. Several other tweaks aimed at preserving the current position when closing folds (klaus.schmid at kdt.de) 60. lib/edt.sl: multiple definition of exit corrected (joukj at hrem.stm.tudelft.nl (Jacob (=Jouk) Jansen)) 61. lib/search.sl,isearch.sl: If the search string contains any upper case characters then a case-sensitive search will be performed. 62. src/mkfiles/makefile.all: Add CFLAGS macro to MINGW32/CYGWIN32 section. Miquel Garriga 63. src/screen.c: Make the [EOB] line read-only. Miquel Garriga 64. src/version.c: Use __MINGW32_VERSION if defined to get the compiler version. Miquel Garriga 65. lib/os.sl: make sure W32shell_Perform_Globbing is declared. Miquel Garriga 66. lib/cal.sl: avoid interpretation of 08 in dates as octal. Miquel Garriga 67. src/screen.c: %F may be used to specify complete pathname on the mode-line. (John Skilleter). 68. doc/tm/keys.tm: get_key_binding documentation corrected. (Klaus Schmid ) 69. src/mkfiles/makefile.all: Make sure CFLAGS defines JED. Also add support for creating wjed in cygwin environment (Paul Shirley). 70. New intrinsic: expand_symlink expands symbolic links }}} Changes since B0.99-14 {{{ 1. lib/site.sl: if $HOME/.jedrc does not exist, then load jed.rc from $JED_LIBRARY. This did not work in 0.99-14. 2. lib/cmode.sl: Use double quotes when calling c_set_style_hook. (Marko Mahnic ). 3. src/abbrev.c:what_abbrev_table: A misplaced return statement prevented it from returning information regarding the global table. (John Skilleter ). 4. lib/cmode.sl: modify in_class function to allow template classes. 5. lib/cmode.sl: modify c_set_style to account for C_Class_Offset. 6. lib/compile.sl: tweak RE for VC++ 6 and add RE for RGBE gameboy assembler (Paul Shirley" ). 7. lib/cmode.sl: Handle multiple // in // style comments. 8. src/userinfo.c(get_username_info): avoid NULL ptr deref if getpwuif fails. 9. lib/ashell.sl: try_builtin was returning -1 upon failure instead of cmd. 10. src/pty.c: use openpty when available (Diego Roversi ). 11. src/indent.c: Ignore the quote character when looking for the end of a comment. 12. lib/info.sl: Avoiding locking the info file when in a read-only directory. 13. src/keymap.c: Make sure to call switch_active_buffer_hooks after the startup_hooks have been run. 14. lib/latex.sl: updated for newer latex info files (harpend@xmission.com). 15. lib/ide.sl: updated by Guido Gonzato. 16. src/menus.c: Scrolling implemented for popup menus that contain more rows than the display. 17. src/wterm.c: convert X #ABCDEF-style color specification to windows decimal form. 18. lib/edt.sl: work around new xterm bug affecting the toggling of the keypad state. 19. lib/php.sl: updated to v1.4 (Mikael Hultgren ) 20. src/intrin.c: set_color intrinsic renamed to _set_color. set_color is now a slang function that calls _set_color. The idea is to allow one to overload set_color with something more sophisticated, e.g., one that exploits a color name database (rgb.txt). 21. src/wterm.c: included latest patches from John Skilleter for wheel-mouse support. 22. src/intrin.c: New intrinsic variable Menus_Active indicates whether or not the menus are currently active. 23. src/wterm.c: fix problem with background color used when the screen is cleared not matching the background color used in drawing text. }}} Changes since B0.99-13 {{{ 1. lib/chglog.sl: tweak date format (Peter Wang ). 2. Xjed would crash whenever 'set_abort_char' was called. This affected ide and wordstar modes. 3. screen.c: enable syntax highlighting by default. 4. src/Makefile.in: support for $CPPFLAGS added 5. src/Makefile.in: DESTDIR support added by Brad . 6. src/text.c: forward/backward_paragraph functions were removing whitespace from the end of lines. 7. Ctrl-X binding in ide.sl fixed. 8. QNX-specific patches from Tijs Michels . 9. Typos corrected in VMSMAKE.COM by Jouk Jansen . 10. updated ide.sl, docbook.sl, and rcs.sl from Guido Gonzato. 11. New function unset_ctrl_keys that unsets keys ^A-^Z. This is better than calling unsetkey for ^K, ^X, etc. 12. Default value for Jed_Highlight_Cache_Path initialized from 'get_jed_library_path' instead of JED_ROOT/lib. 13. lib/comments.sl: get_comment_info changed to return NULL upon failure. 14. src/wterm.c: Several places where buffer overflows could happen were fixed. 15. If c_set_style_hook is defined, it will be called to allow the user to define custom styles. 16. src/wterm.c: support for wheel mouse added by John Skilleter . 17. src/wterm.c: small fix for NumLock GOLD key emulation courtesy of Nick Tatham . 18. lib/shell.sl: shell function now calls shell_mode_hook. 19. lib/occur.sl: add 'bob' to find all occurances in the current buffer. (Reuben Thomas ) 20. lib/texcom.sl: Allow lines that start with \ to be in the middle of paragraphs unless the line starts with \begin, \end, or \item. (Reuben Thomas ) 21. New function to signal the foreground process group of a subprocess: signal_fg_process. lib/ashell.sl modified accordingly. 22. src/file.c: Set the buffer creation time associated with a file to the file modification time. This avoids problems with broken software that set the modification time to the future. (John Skilleter ) 23. Warn user if an attempt is made to modify a buffer whose file is read-only. 24. lib/site.sl: new variable: Jed_Home_Directory. 25. _jed_startup_hooks added. These hooks are called prior to going into editor's main loop. This replaces jed_startup_hook. 26. Menu_Load_Popups_Hook variable replaced by the "load_popup_hooks" chain. Instead of using: variable Menu_Load_Popups_Hook = &some_function; use, e.g., append_to_hook ("load_popup_hooks", &some_function); 27. New intrinsic function: _jed_run_hooks, which will run the hooks in a hook chain. 28. src/ledit.c: Make sure that JWindow is non-NULL in flush_message. 29. src/menu.c: Support Simulate_Graphic_Chars on DOS/WINDOWS. 30. lib/site.sl: Associate slang_mode with .jedrc, add python_mode to completions (Tom Culliton ). 31. lib/site.sl: runhooks can be passed optional arguments 32. lib/bibtex.sl: Add support for bibtex_field_default_hook (see bibtext.sl) Lutz Donnerhacke . 33. src/search.c:regexp_nth_match: if passed 0, return the whole match as documented. 34. src/ledit.c: work around a slang bug triggered by jed that prevents the use of #ifeval expressions. 35. Support for hook called "keybindings_hook". See doc/txt/hooks.txt for more information. 36. Keyboard macros were stopped if a slang function triggered an error that was subsequently cleared via an ERROR_BLOCK. Now, such macros will continue to execute. 37. lib/mouse.sl: new variable: Mouse_Wheel_Scroll_Lines. This variable may be used to customize the number of lines that are scrolled when using the wheel. (Default is 3). 38. lib/ashell.sl: filename completion added. 39. lib/comments.sl: Avoid adding whitespace to the end of lines if a comment does not have an end-comment string (Guenter Milde ). 40. lib/os.sl: wjed.exe can now use jed's text menus instead of the native GUI menus. At the moment, the text menus are far more functional than the native menus. Uncomment the appropriate line in lib/os.sl to use the text menus. }}} Changes since B0.99-12 {{{ 0. Important Notes: a) If you are not using set_color_scheme to set colors, you may find that your color settings will not work. Now, if the user does not call set_color_scheme, it will automatically be called with _Jed_Default_Color_Scheme. If you do not want this feature, set _Jed_Default_Color_Scheme to NULL after setting your colors. b) All keybindings prefixed with ^C were removed from lib/*.sl and replaced by calls to functions such as definekey_reserved. The idea is that each emulation (emacs, ide, etc), is to reserve prefix key that may be used by various modes for binding. As an example, folding.sl used to contain lines such as: local_setkey ("fold_whole_buffer", "^C^W"); This made this mode and others fundamentally at odds with emulations that use ^C for something else, e.g. the ide emulation. Now, lines such as the above have been changed to: local_setkey_reserved ("fold_whole_buffer", "^W"); Of course the emacs emulation preserves the ^C key for extension in this way, which means that the two lines are equivalent. The interface to this ``reserved'' key prefix includes the following functions: setkey_reserved unsetkey_reserved local_setkey_reserved local_unsetkey_reserved definekey_reserved undefinekey_reserved and have the same calling syntax as similar functions without the reserved suffix. The variable specifying the reserved key prefix is called _Reserved_Key_Prefix, whose value will depend upon the emulation: emacs: ^C ide: ^Z 1. src/VMSMAKE.COM: typo corrected (joukj@hrem.stm.tudelft.nl). 2. lib/textmac.sl: del(2) --> deln(2) (affects processing of {}) 3. lib/cmode.sl: New variable C_Switch_Offset controls indentation in a switch statement. 4. cua.sl added to the distribution. 5. provide/require functions added. 6. If ^G pressed in mini-buffer, make sure mode-dependent menubar is restored. 7. Avoid file-changed-on-disk problems associated with a failed write to disk. 8. src/file.c: VMS specific problem writing to a new file on OpenVMS fixed by joukj@hrem.stm.tudelft.nl. 9. src/ledit.c: Regard a library file beginning with ../ as relative to the current dir. That is, `jed -l ../file.sl' will load the obvious one. 10. Signal an error if the insert intrinsic fails. 12. lib/pymode.sl: small patch from jimbag@kw.igs.net to close the output window if it is empty. 13. src/main.c: If unable to get the current working directory upon startup, chdir to / and assume that (Pascal Haakmat ). 14. DECCMAKE.COM removed from the distribution--- it is not needed. 15. Color_Scheme_Path variable added. This is a comma-separated list of directories to search for color schemes. 16. lib/info.sl: subtle bug fix involving search for split files 17. doc/txt/slangfun.txt dropped from the distribution since it is distributed with slang. 18. lib/help.sl: A patch from Guenter Milde to provide some help on internal functions. 19. lib/verilog.sl: updated keywords provided by Kikutani Makoto . 20. lib/comments.sl: new functions to support commenting lines/regions provided by Guenter Milde . 21. src/w32cons.c: Support for AltGR added by Juha Ruotsalainen . 22. src/keymap.c: Default keybinding of " and ' keys changed from text_smart_quote to self_insert_cmd. 23. Additional command line options added: -help, -a, and -e. Run 'jed -help' for more info. 24. New modes: docbook (Guido Gonzato); php (Mikael Hultgren ). 25. Updated lib/rcs.sl, backups.sl (Guido Gonzato) 26. lib/compile.sl: support for column info added by Lutz Donnerhacke . 27. Xjed: Support for wheel mice added by Daniel Serpell . 28. lib/keydefs.sl tweaked by GM . 29. src/wterm.c: Added Nick Tatham's NumLock patches for EDT emulation. 30. If Xjed cannot open the display, it will revert to jed and use the terminal. (Thomas J. Moore ). 31. Updated perl.sl from Mark Olesen . 32. lib/shell.sl: do_shell_cmd now accepts an optional argument (G. Milde ) 33. lib/register.sl: Updated by Francesc Rocher . 34. lib/iso-latin.sl: word definition tweaked by Thomas Henlich . 35. tweaks to src/mkfiles/makefile.all from John Skilleter . 36. src/wterm.c: Recognize Shift-TAB (Paul Shirley ). 37. lib/minued.sl, lib/history.sl updated by Francesc Rocher. 38. New function: c_set_style: this may be used to set the C indentation style to one of several popular styles, e.g., "GNU", "k&r", "BSD", "linux", and of course "jed". 39. src/unix.c: filename completion now supports globbing on Unix systems, e.g., completion on *.c returns files that end in *.c. (Olly Betts ) 40. If a mode cannot be found for a filename extension 'ext', but 'ext_mode' exists as a function, then use it. 41. Support for DFA syntax highlighting enabled by default. The names of the DFA-specific intrinsic functions have been prefixed by "dfa_". Now the user can turn on/off dfa syntax highlighting for any mode via any of the new functions: use_dfa_syntax disable_dfa_syntax_for_mode enable_dfa_syntax_for_mode Finally two new variables control the search for DFA cache files: Jed_Highlight_Cache_Dir Jed_Highlight_Cache_Path 42. Unix: /etc/jed.conf or /usr/local/etc/jed.conf may be used in place of $JED_ROOT/lib/defaults.sl --- See INSTALL. }}} Changes since B0.99-11 {{{ 1. If file system does not support symbolic links, or the directory does not allow the creation of symbolic links, then continue without locking. 2. VMS specific typo in file.c corrected. 3. If a file is writable, but the directory is not, then do not mark the buffer associated with the file as read-only. 4. lib/ide.sl: change occurance of "^(XX)" to "XX" to get function key sequences from the terminfo file. 5. win32 patches from John Skilleter : a. sysdep.c:pcsystem_getdisk: correct typo and use getdrive with BCC. b. wterm.c: avoid infinite loop when parsing command line containing quotes. 6. Tweak to avoid locking file during narrow/widen operations 7. lib/info.sl: If searching a file via grep for -SOMETHING, then escape the `-' with \. 8. Patch from Nick Tatham to build wjed.exe with VC. 10. Documentation reorganized and Guido's reference guide has been added. 11. lib/info.sl: Add support for bzipped files (Guido Gonzato). 12. _jed_switch_active_buffer_hooks added. These hooks are called whenever one switches active buffers. 13. src/xterm.c: If pasted text starts with ESC(B, then assume it is ISO2022 encoded. 14. Bug-fix made to allow two or more menubars to co-exist. This was never tested until recently. 15. text.c: bug fixed when wrapping paragraphs that contain lines indented beyond the wrap column. 16. Bug involving xform_region fixed. 17. Internal function `save_buffers' renamed to `save_some_buffers' to avoid name conflict with slang function `save_buffers'. 18. lib/site.sl: save_buffer function modified to work on buffers with no associated filename. 19. src/lock.c: If running in batch mode and a file is locked, then treat it as so. 20. lib/textmac.sl: support for passthru environments added. 21. lib/shell.sl restructured. Now, `do_shell_cmd' with a prefix argument will use the current buffer for its output. Note that the shell_perform_cmd function now requires 2 arguments. 22. lib/pushmode.sl: push_mode can now take an optional argument. 23. src/indent.c: Make sure lines containing repeated perl-style comment characters are recognized as comments. 24. lib/mousex.sl: make sure value of META_CHAR does not affect mouse input. 25. lib/html.sl: reference to "?help" removed. 26. abbrev.sl: set_abbrev_mode function was not calling _set_buffer_flag properly. 27. New color scheme: blue3.sl, also win1250 and dos852 character tables (PPrikryl,Petr ) 28. CUA-like keybindings added (Reuben Thomas ). 29. New file: keydefs.sl. This defines symbolic constants for many function keys. I modified ide.sl and wmark.sl to use it. 30. sysdep.c: small patch for compiling on OS/2 (Michael Muller ) 31. Small mis-feature corrected by Olly Betts involving combination of forward and backward yp_* functions. 32. Xjed specific pastel color scheme added (Frank Klemm ) 33. Xjed-specific color scheme directory added. Use, e.g., set_color_scheme ("Xjed/pastel0"); 34. lib/cal.sl internationalized by Tamminen Eero . 35. lib/emacs.sl: forward/backward_paragraph bindings added. }}} Changes since B0.99-10 {{{ 0. Important backward-incompatible changes: a. Compiler interface simplified. New functions include: compile_select_compiler compile_add_compiler The variables `compile_parse_error_function' and `compile_parse_regexp' are nolonger used. Use Compile_Default_Compiler instead. The default is "gcc". See doc/compile.txt for more information. b. slang version 1.3.11, or later is required. If you have not already done so, then it is a good idea to upgrade to 1.4.1. c. get_key_function replaced by get_key_binding, which is more versatile. 1. TeX/LaTeX modes: Automatic conversion of ... to \dots suppressed in verbatum environments. 2. xjed: --debug-xjed command line argument added. Currently, this does very little but may prove useful. 3. lib/chglog.sl added. This gives jed the ability to maintain ChangeLog files. The default binding for the `changelog_add_entry' function is "^X4a" (for consistency with emacs). 3. lib/rcs.sl modified. 4. Several lib/*.sl files were modified to use high-level functions to set buffer flags instead of setting them directly. 5. New intrinsics: set_username (String_Type); set_realname (String_Type); set_hostname (String_Type); String_Type get_username (); String_Type get_realname (); String_Type get_hostname (); and slang functions: set_emailaddress (String_Type); get_emailaddress (String_Type); 6. Emacs-style file locking added (see doc/filelock.txt). 7. Changes made to jed/src/file.c to avoid possible race conditions in a multi-user environment. (Colin Phipps ). 8. Some cleanup involving expand_filename and expand_link. 9. ctags.sl modified. 10. If `global_mode_hook' exists, it will be called after calling the mode hook. This function will be passed the name of the mode hook. 11. To implement 10, calls to `runhooks' in mode-setting functions were replaced by run_mode_hooks. 12. jed --version displays compile-time features. 13. `insert' intrinsic can now insert binary strings (those with \0). 14. If an expansion for an abbreviation ends in \010, then the expansion will be performed but the character causing the expansion will not be inserted. In addition to this feature, arbitrary limits were removed from src/abbrev.c 15. Directory name that shell command will run in is displayed as part of the shell command prompt. 16. pymode.sl updated to v1.3. 17. On command line, files such as a//b/c are replaced by a/b/c. 18. Avoid infinite loop when using query_replace_match to replace ^$ with nothing. 19. If using slang 1.4.1+ use strreplace in str_replace_all. 20. matlab.sl: matlab_mode function was accessing $1 variable. 21. Two eol-type comment styles now supported. For example, matlab_mode defines both `#' and `%' as comments. It should now be possible to have comments such as `REM', which should be familiar to BASIC programmers. 22. src/pty.c: Allow an ioctl to silently fail if `ttcompat' does not exist as a stream module. (Diego Roversi ) 23. lib/cmode.sl: C_Class_Offset variable added to allow the specification of indentation withing a class definition. (Kumaran Santhanam ) 24. src/unix.c: BeOS support added by Eddie Penninkhof . 25. macro.sl: bug fix involving use of an unitialized variable in macro_to_function. 26. lib/pymode.sl: make python keywords case sensitive (Simon Tatham ). 27. xterm.c: If a window is uncovered the xterm.c current color could become out of sync with vterm.c color. (Simon Tatham ). 28. lib/digraph.sl: DOS specific patch from G.Milde@physik.tu-dresden.de (G. Milde). 29. src/rgrep.c: example for finding repeated words corrected 30. doc/tm/rtl/color.sl: keywordN added to set_color doc 31. erase_buffer function checks read-only status of buffer 32. set_process intrinsic modified to accept function references. 33. Bug in translate_region fixed. 34. New menu_insert_* intrinsic functions from James Telfer . 35. Bug in re_search_forward fixed involving non-RE search pattern. 36. iso2xxx.sl: replace strncat by strcat. 37. setbuf_info: If this is used to rename a buffer to one that already exists, then a unique name will be generated (e.g., xxx -> xxx<1>). 38. New hooks facility that allows one to attach hooks to the following internal hook lists: _jed_append_region_hooks _jed_exit_hooks _jed_find_file_after_hooks _jed_find_file_before_hooks _jed_init_display_hooks _jed_insert_file_hooks _jed_quit_hooks _jed_read_file_hooks _jed_reset_display_hooks _jed_resume_hooks _jed_save_buffer_after_hooks _jed_save_buffer_before_hooks _jed_set_mode_hooks _jed_suspend_hooks _jed_write_region_hooks See doc/hooks.txt--- especially if you have created (non-mode related) hooks. 39. lib/compress.sl: This implements a new function called `auto_compression_mode' that uses the new hooks facility to automatically compress/decompress files. 40. Additional slang intrinsics made available to the editor: stdio, posix_io, and ospath. 41. custom_variable function added to site.sl. This function is due to Francesc Rocher . 42. Patches from Jim Knoble : Xjed: set group_leader WM hint and WM_COMMAND property. Add drag threshold for ButtonPress/Release events menu.c: Add menu_selection_char color for additional control of menu items. 43. Patches from John Skilleter : win32: Allow command line arguments with spaces by removing quote characters. Attach Drive letter to filenames without one. Extra control over status line: * %O - Overwrite/Insert flag - like %o, but shows INS/OVR * %l - Line number - shows current line number * %L - max line nmber - shows number of lines in the file 44. Added history.sl and minued.sl from Francesc Rocher . history.sl uses _jed_exit_hooks to save/recall minibuffer history. See lib/history.sl for more information. 45. Xjed: Cut/paste fixed to work with programs that do not support COMPOUND_TEXT selections (gnome, kde, ...). 46. The maximum length of a keyword has been increased to 48 characters. In a later release, the limit will be removed. 47. If C_Autoinsert_CPP_Comments is non-zero, and if a line starts with // style comments, newline_and_indent will insert // on the next line. 48. unix.c: when saving a file, try to preserve uid of file instead of using uid of process (Thomas Henlich ). 49. Updated perl_mode from Juho Snellman . This version included a routine for indenting perl; however, it is disabled by default. 50. New syntax flag bit: 0x80. This indicates that strings do not span multiple lines. 51. getbuf_info/setbuf_info may be given an optional argument to work with any buffer. 52. New intrinsic: copy_keymap. This creates a new keymap by copying another. 53. In text-mode, TAB is bound to the new function text_indent_relative. 54. wmark.sl tweaked. 55. win32 console version: Fixed problem with ENHANCED keys. }}} Changes since B0.99-9 {{{ 1. perl.sl: (=head,=cut) regarded as comment begin/end pairs 2. java.sl: syntax for // comments added. 3. menu_set_menu_bar_prefix intrinsic added to allow one to change the menu prefix string ("F10 key ==> "). 4. edt.sl: better emulation of EDT scroll regions (Ulli Horlacher ). 5. Calling `recenter' will not force an immediate screen update. 6. shmode.sl: Extra keywords added (Ulli Horlacher ). 7. isearch.sl: Function/Arrow keys will also terminate search 8. Updated ide.sl mode from Guido Gonzato . 9. Various patches from Charl Botha affecting bibtex.sl, latex.sl, and site.sl. 10. modeinfo.sl rewritten to use an associative array. 11. xterm.c: ignore ConfigureNotify event if the window size does not change (Charl Botha ). 12. `unsigned short' replaced by `SLsmg_Char_Type'. More work will have to be done when version 2.0 of slang comes out with unicode support. 13. Change Buffer menu item added. This required a new intrinsic function: menu_set_select_popup_callback 14. Documentation updates and redundant documentation removed from C files. 15. Whitespace in front of C preprocessor constructs ignored via new `set_syntax_flags' bit. 16. Documentation changed to reflect the fact that vinsert does not require the number of items. Similarly, the .sl files were modified accordingly. 17. process_query_at_exit intrinsic added. 18. If DOLLAR_CHARACTER is 0, no such character will be used as an indicator that text extends beyond the borders of the window. 19. New inrinsics: _get_point, _set_point. These should be used in favor of the POINT variable which will be removed from future releases. 20. win32: all intrinsic win32 menu functions have been renamed with a `w32_' prefix, e.g., redraw_menubar --> w32_rename_menubar. Hopefully, this change will not affect anyone. 21. `directory' function is no longer an intrinsic function. Now it is a slang function simulated using the listdir intrinsic. 22. win32, msdos, OS/2: New variable: Case_Sensitive_Filenames If non-zero, filenames will be treated as case-sensitive on these systems, otherwise filenames will be considered as case-insensitive. This change was patterned on a patch from Eddie Penninkhof . }}} Changes since B0.99-8 {{{ 0. Miscellaneous patches from Ricard Sierra added. (Note: this item was added on Nov 17, 1999) 1. win32: define_color intrinsic was not working properly because of an old-style definition. 2. win32: g32shell.exe performs globbing on command line arguments but w32shell.exe does not. To use the globbing shell, put `W32shell_Perform_Globbing=1;' in your jed.rc file. 3. win32.c: bug in sys_findnext corrected. 4. problem with enable_menu_keys on win32 fixed. 5. doc/script.txt updated. 6. QNX specific patches from SvOlli . 7. Xjed: fgKeyword2 and bgKeyword2 resource settings added. 8. idl.sl: ide_window_down typo corrected (Matthew Gabeler-Lee ). 9. win32 Borland specific patches from John Skilleter . 10. Updated ide.sl mode from Guido Gonzato . 11. install targets rewritten to work around limitations of the autoconf install script. 12. Improved detection of fold marks. 13. win32 patch involving read-only files from John Skilleter . 14. update_sans_update_hook intrinsic added. 15. win32: bug involve handling of ALTGR fixed. In addition, several other changes were made to the win32 keyboard code to allow ^G to interrupt a slang procedure, e.g., while(1); 16. If an interactive seach finds a match on a hidden line, e.g., one in a fold, then the line will be made momentarily visible. (B0.99-9 released) 17. win32: Ctrl-2 was not generating the correct keysequence. (B0.99-9a released) }}} Changes since B0.99-7 {{{ 0. win32 subprocess support changed. Basically from what I consider to be bug in windows, a helper application is required to launch subprocesses (jed/bin/w32shell.exe). Microsoft says this need is due to ``differences'' between windows 95, 98, and NT (???!!!). A function `_win32_get_helper_app_name' has been added to allow some experimentation with the helper app. In addition, the console version will spawn a subshell when suspending. 1. Under Unix, if `info' is a symbolic link to jed, then jed will run as an info reader. 2. If you attempt to write to a file that has changed on the disk, you will be warned. 3. Asynchronous process denied if started via `jed -secure' 4. A warning message is printed if compiled against a version of slang that is more recent that the one it is linked to--- this happens when the user does not properly install the slang library. 5. OS/2 findfirst/findnext patch from Eddie Penninkhof . }}} Changes since B0.99-6 {{{ 1. set_syntax_flags enhanced to allow additional customization of the highlighting of preprocessor lines. 2. ISO-Latin word character definitions tweaked (Thomas Henlich ). 3. More documentation added to the Help menu. 4. edt.sl setkey inconsistency fixed. 5. Updated ide.sl mode from Guido Gonzato and blue2.sl color scheme. 6. sgml.sl syntax coloring tweaks. 7. More menu tweaks: a. pgup/pgdn keys may be used to navigate. b. Popup definitions moved to popups.sl to be autoloaded upon use. c. Mode menu item added to menubar for mode-specific commands. 8. Bug fixed involving deletion of the mini-buffer. 9. _jed_version_string added. 10. tweaked indentation of C preprocessor statements. 11. lib/syntax.sl rewritten to take advantage of associative arrays. 12. __IBMC__ patches from Eddie Penninkhof . 13. enable_menu_keys added to make the menu-bar hotkeys work after loading an emulation that redefines the keys, e.g., ESC-f in emacs.sl. 14. DISPLAY_EIGHT_BIT semantics changed to match those of the SLsmg screen management routines. 15. SELECTIVE_DISPLAY variable removed. 16. enable_xmouse function added to facilitate loading of mousex.sl when running jed in an Xterm. }}} Changes since B0.99-5 {{{ 0. New drop down menu system added. These menus work in all versions of jed and may be activated via the F10 key or via the mouse. For use in an xterm, load mousex.sl. See doc/menus.txt for more information. 1. site.sl:mode_hook modified so that ~ gets removed from the extension. 2. src/Makefile.in was not installing the color definition files. 3. VMS patches from Jouk Jansen : Jed_Doc_Files was not getting set. Typo in vms.c corrected. 4. Gpm mouse patch from George Young to fix the ``sticky mouse'' problem. 5. Updated pymode.sl to v1.2. 6. f90.sl patch from Jouk Jansen: Include `<' and `>' as binary operators. 7. Work around for a glibc or linux 2.2 kernel bug that gets triggered when reading 0 bytes from a pipe. 8. win32 patches from John Skilleter . These allow jed to be compiled with Borland 5. 9. Reworked the init_slang hook to allow multiple hooks. 10. lib/os.sl:set_selective_display moved to lib/seldisp.sl. In addition, the function was modified so that the current column is used to set the display column. 11. lib/emacs.sl: goto_line_cmd bound to ESC-g (Ang Chin Han ). 12. New color schemes: default1.sl, blue1.sl 13. Updated .sl files from Guido Gonzato : ide.hlp, ide.sl, matlab.sl, rcs.sl, sgml.sl. 14. 1+1 is now highlighted correctly. 15. unset_buffer_hook intrinsic added. }}} Changes since 0.98-7 {{{ 0. Major changes to the display system. Now jed uses the SLang screen management routines. Syntax highlight of multi-line comments should now work correctly. 1. insert_char did not check read-only status of buffer. 2. Added patches from Joao Luis Fonseca to src/mkfiles/makefile.all. 3. Typo in idl.sl corrected. 4. New rmail functions: rmail_hide_deleted rmail_unhide_deleted 5. %p status line specifier now includes the column if LINENUMBERS is greater than 1. 6. Tweaks to src/gpmmouse.c from George R. Young . 7. Port to MINGW32 from Marko Pistotnik . Note: mswshell.exe is still a BCC compiled 16 bit executable. It appears that mswshell.c still needs ported to WIN32. 9. VMSMAKE.COM changes provided by Martin P.J. Zinser . He also provided jed/doc/JED.HLP for VMS. 10. OS/2 ICC patches from Eddie Penninkhof . 11. Small regexp bug in backward searches fixed (hbitteur@club-internet.fr). 12. check_buffers intrinsic function added. 13. Bug fix in keymap.c fixed (Tom Culliton ) 14. jed/lib/syntax.sl: bug fixed (Michael Johnson). 15. compile.sl typo fixed 16. Major changes to win32/win16 code from Luchesar Ionkov . 17. Patch to x_region_to_cutbuffer from Mark Olesen . 18. OS/2 and isearch specific patches from k-yosino@inatori.netsweb.ne.jp. 19. Xjed color allocation changes from Radim Halir . 20. CHanges to better support C++ from Michael Johnson as well as changes to html.sl. 21. Fortran-sytle comments are now mode dependent in a much more useful and flexible way via the new intrinsic `set_fortran_comment_chars'. 22. TI asm mode added (tiasm.sl). 23. modeinfo.sl added. The functions in this file facilitate sharing information between modes: mode_get_mode_info mode_set_mode_info For example, a mode can define folding information that folding.sl can use. See, e.g., folding.sl and cmode.sl. (B0.99.1 snapshot released) 24. Bug fixes: * Blink match bug fixed involving " at the beginning of a line. * In sh-mode `\'' given a string syntax. 25. hook_add_to_hook replaced by hooks.sl:hook_add_hook. I believe this interface permits better chaining of hooks. 26. isearch.sl bug fix involving ^G abortion of search. 27. Updates to dabbrev.sl to use array syntax. Also foreach...using used in some .sl files. See slang documentation for information about foreach construct. 28. Some functions and variables in several lib/*.sl files have been made `static'. ----- snapshot jed0.99_981116 made available (B0.99.2) ----- 29. Microsoft Visual C support added to compile.sl (Paul Shirley ). 30. Small patch to mouse.c that fixes a bug in the presence of folded text. 31. Tweak to shmode.sl 32. On black and white terminals, message lines are nolonger displayed with attributes. 33. Tweaks to xjed display to correct a bug on maximization of the window. 34. OS/2 Subprocess support provided by Kazuhisa Yoshino . 35. showkey for ``eight-bit'' character now displays the character properly. 36. Under SVR4 unix, pty implementation changed to use stream modules instead of BSD pty emulation. This was necessary because Solaris 2.6 and 2.7 have buggy BSD pty emulation and jed was able to crash those operating systems. 37. New modes from Guido Gonzato : ide.sl : 99% compatible Borland IDE mode (see doc/ide-mode.txt) sgml.sl rcs.sl matlab.sl backups.sl : Make numbered backups ------B0.99.3 snapshot released (0.99_981127) -------------- 38. __BORLANDC__ specific patches from John Skilleter . 39. MAIN_ARGC replaced by __argc and command_line_arg replaced by __argv. 40. Tweaks to c_format_paragraph 41. New MSWINDOWS vaiable from John Skilleter: FN_CHAR Normally, function keys generate a two character sequence: ^@ (ascii 0) followed by some other character (see doc/pc-keys.txt). This variable makes ^@ configurable. The default is 0 (^@). 42. Documentation of library functions available online and via doc/libfuns.txt. 43. Use of strchop and strchopr modified according to new semantics. 44. mkdir and rmdir intrinsic functions were replaced by slang library intrinsics. 45. unix_kill function changed to `kill' (S-Lang library change). 46. textmac.sl modified to use associative arrays. ------B0.99.4 snapshot released ------------ 47. Improved Xjed selection support and internationalization support from Kazuhisa Yoshino . 48. iso-lat3.sl added (Byrial Jensen ). 49. It is now possible to set dabbrev's word characters on a mode via: mode_set_mode_info ("C", "dabbrev_word_chars", "a-z_0-9A-Z"); 50. Improved python mode submitted by Tom Culliton . 51. nick.tatham@pobox.com provided a work-around for a windows 95 bug in the rename function affecting long filenames. 52. Wrap bug involving a long line of non-whitespace characters fixed. 53. Makefile install target fixed. 54. Additional highlighting of ANSI/ISO C++ keywords courtesy of Ragnar Hojland Espinosa . 55. Windows specific patch from cpbotha@bigfoot.com that fixes a NULL pointer dereference in cover_exposed_area. 56. Bug fixed involving the free_narrow function. Also, dabbrev.sl uses widen_region instead of widen. 56. If buffer does not exist on disk, and is not modified, then file_changed_on_disk will return 1. 57. Misc bug-fixes: ()=insert() in sendmail.sl, blink bug in indent.c. 58. If a file contains hard links, a backup is made via copying. 59. Misc patches from Marcin 'Qrczak' Kowalczyk" : html typo and changes made to xkeys.c for better EDT emulation by Xjed. 60. set_prefix_argument intrinsic function added and changed made to the emacs_escape_x function to preserve a prefix argument. 61. compile function modified to accept an optional string argument to specify the command to run. If the argument is not present, then the user will be prompted for the command. 62. Buffer-local variables modified to allow any slang data type. The function `create_blocal_var' nolonger accepts a `type' argument. Also a new intrinsic `blocal_var_exists' was added. This change was suggested by Lucho Ionkov. 63. jed --version prints version number. 64. A workaround for a Sun cmdtool bug. That terminal is a real loser. 65. Configure indicates that linux has `grantpt', which indicates that it has SysV ptys but it does not. BSD pty support forced for linux. This was the reason that subprocess support failed to work with 2.2 kernels. 66. New function: `set_color_scheme (name)'. This will allow a user to select a predefined color scheme. See jed/lib/colors/README. =========================================================================== }}} Changes since 0.98-6 {{{ 0. Due to a change in the prototype of SLtt_init_video, SLang version 1.0.3 is required. 1. VMS specific bugs fixed, e.g., typo in file.h corrected. 2. f90.sl mode updated with .f90 extension associated with it. 3. Bug fixes in latex.sl corrected (Peter Chang ) 4. `Xjed -ic' (iconic) now works thanks to Jim Clifton . 5. Better support for long file names for WIN95 systems. }}} Changes since 0.98-5 {{{ 1. Small iso-latin.sl patch from Thomas Roessler . 2. rmail.sl tweak for parsing email addresses 3. small hack to input_pending and ungetkey when called from a keyboard macro. 4. wmark.sl: mods to use display_hook (Marius Groeger ). 6. OS/2 and Windows patches }}} Changes since 0.98-4 {{{ 0. MAJOR changes to the slang language. It is now MUCH more powerful and flexible. However, there is a price to pay since some functions changed. See slang documentation for full details. Also look at slang/UPGRADE.txt for more information about upgrading your slang functions. Important changes include that may affect user functions include: vmessage and verror now work like: vmessage ("%s-%s", "hello", "world"); instead of vmessage ("%s-%s", "hello", "world", 2); extract_element returns NULL if element does not exist getenv returns NULL if environment variable does not exist Creation of arrays is now much easier, e.g, i = Integer_Array [10, 20]; creates an integer array with 10 rows and 20 columns. In fact, create_array is nolonger supported by the language; however, it is available as a function in jed/lib/compat.sl. Switch statement syntax modified slightly. An object is nolonger pushed onto the stack. Before some code looked like: switch (x) { case '1' or (case (x, '2') : do_this (); } { pop (); do_that (); } % default Now it is cleaner: switch (x) { case '1' or case '2' : do_this (); } { do_that (); } % default 1. Rmail changes that take Content-Length into account on Solaris systems. Patches for this were submitted by Jan Hlavacek . 2. Another symbolic link bug fixed. 3. Stack overflow while doing undo fixed. 4. Fixed a small problem when multiple subprocesses exist. 5. New wordstar mode by guido@ibogfs.df.unibo.it. See also ide.sl for a borland ide mode. 6. Tweaks to make jed work better with gpm 1.13. 7. New hook: save_buffer_hook. See doc/hooks.txt. }}} Changes since 0.98-3 {{{ 0. Oops. The pushmode stuff introduced in 0.98-3 also introduced a bug. 0.98-3 was pulled for this reason. }}} Changes since 0.98-2 {{{ 1. Bug in expand_filename found and corrected. Tiny bug dealing with links also fixed. 2. Mark's changes to wmark.sl integrated. Chaining of suspend/resume hooks is still an issue. I also included his bufed routines. 3. f90 mode updated by joukj@crys.chem.uva.nl. 4. Man pages for rgrep and jed provided by borik@isracom.co.il. 5. some routine code cleanup 6. Tweaks to various modes, edt, c-mode, etc... 7. New pushmode.sl file implements push_mode and pop_mode functions that facilitate temporary changing of modes in a buffer. This requires buffer-local-variable support. 8. New global variable Default_Jedrc_Startup_File that may be set in defaults.sl to define default jed.rc file. }}} Changes since 0.98beta {{{ -2. JED386.EXE now requires a DPMI server. Read INSTALL.pc for more information. -1. Ctrl-H now deletes backward. Experienced users may want to add setkey ("help_prefix", "^H"); in their .jedrc file to restore the old behavior. The help_prefix function is now bound to `ESC ?'. 0. Patches for VMS and OS/2 applied. Also features.h changed to jed-feat.h to avoid confusion with system header file. 1. New fold function: c_fold_buffer 2. Ctrl-X 8 now runs the digraph command for inputting accented characters. 3. Some modifications to sendmail.sl and rmail.sl to make them work smoothly together. 4. If the buffer local variables feature is available, the goto bookmark functions will work properly across folds. A new intrinsic function `is_user_mark_in_narrow' was necessary to make this possible. 5. The current buffer position is remembered immediately before a call to the goto bookmark function. To return to this position, press the spacebar at the goto bookmark prompt. 6. Jed has better command line support for info topics, e.g., jed -info gcc will run jed as an info reader and visit the gcc info page. In addition, an additional parameter may be supplied to specific which node to visit, e.g., jed -info gcc bugs 7. rmail_edit function added to rmail mode. The default binding is to the "e" key. Also simple MIME decoding has been added to the rmail mode. 8. If a command line argument begins with `--', jed will attempt to match the remaining part of the argument to a function and execute the function. It will also replace all `-' characters by `_' before doing so. For example, I have a function called `no_fold' that sets Fold_Mode_Ok to 0. I can call this function from the command line as `jed --no-fold' That is, `jed -f BLA_BLA_BLA' is now equivalent to `jed --BLA-BLA-BLA'. 9. On pc versions, shift arrow keys now generate a distinct key sequence from unshifted keys. See doc/pc-keys.txt for more information. 10. New wmark.sl file that implements DOS/Windows style cut/paste via shift arrow keys. Add () = evalfile ("umark"); to your jed.rc file to get this. Note: it only works on terminals that generate distinct escape sequences for the shift arrow keys. This includes the pc versions of jed, Xjed, and jed running in rxvt compiled with support for this feature. [Luchesar Ionkov is responsible for this feature]. 11. joukj@alpha.chem.uva.nl created fortran 90 modes. See jed/lib/f90.sl and jed/lib/ff90.sl. Also a python mode is available courtesy of Harri Pasanen . 12. New variable USE_TABS controls whether or not TAB characters should be used for whitespace. 13. New Xjed specific intrinisic function: x_server_vendor This function returns the name of X server vendor. This might be useful for setting keysyms on a server by server basis. 14. If GPM Mouse support is compiled in, the new intrinsic function `gpm_disable_mouse' may be used to disable the mouse. }}} Changes since 0.97-14 {{{ 0. Many small architectural changes. 1. Thanks to Andy Harper (A.HARPER@kcl.ac.uk) for work on DCL make files for VMS. 2. Under Unix, ~ is stripped off filename extension before determining the mode. 3. rgrep change: -B option may be used to skip binary files. These files are defined to be any file with a null character in the first 32 bytes of the file. 4. Folding mode and selective display if jed is compiled with line attribute support. This adds about 4 bytes of overhead per buffer line. As a result, I do not recommend it for systems with no virtual memory (DOS). The 32 bit DOS executable (jed386.exe) does come with folding support. wjed.exe and jed.exe do not provide folding support because they are 16 bit executables. To enable folding mode, you must set the variable Fold_Mode_Ok to non-zero value in your jedrc file. See doc/fold.txt for more information. `set_color ("...", "blue", "white");' may be used to set the color of the "..." hidden line indicator. 5. Line marks added. See online documentation `create_line_mark'. This is a user mark that has a color associated with it. A line that has a line mark will be displayed using this color. 6. A buffer-local facility has been added. See documentation on the new intrinsic functions: create_blocal_var get_blocal_var set_blocal_var define_blocal_var for more information. 7. If asynchronous subprocess support is enabled, jed will compile in the background. 8. Mouse interface completely re-written to be more functional. New intrinsics include: mouse_set_default_hook mouse_set_current_window mouse_map_buttons Double and Triple clicking is now supported in XJed. 9. Several new intrinsics including: usleep is_visible_mark 10. More sophisticated syntax highlighting added by Simon Tatham . His approach based on regular expressions is available if jed is compiled with JED_HAS_DFA_SYNTAX defined (see src/features.h). See jed/doc/dfa.txt for more information. 11. slang_mode mode line changed from "SL" to "SLang". This makes it more consistent with other modes. 12. Mark Olesen's sendmail and mail-alias slang packages have been integrated into jed. The sendmail interface replaces the old interface on Unix systems. See sendmail.sl for more information. 13. I have tried to unify the various makefiles for pc systems. There are simply too many compilers and too many incompatable make programs for DOS/WINDOWS/OS2 systems and about every other week I would receive a new makefile from someone that works with X version of make using compiler version Y. The problem with this is that I simply cannot maintain that many makefiles. See jed/src/mkfiles/README for my proposed solution. }}} Changes since 0.97-13 {{{ 0. Some intrinsic functions have been renamed: whatmode --> what_mode setmode --> set_mode 1. New functions: verror, vmessage : These take a variable number of arguments in vinsert Sprintf style _stk_roll : rolls the stack strchop, strchopr : Chops up a string into substrings del_eol : delete to end of line del_through_eol : delete through end of line pop_mark_0 : equiv to pop_mark(0) pop_mark_1 : equiv to pop_mark(1) go_left_1 : equiv to go_left(1) go_right_1 : equiv to go_right (1) ffind_char : like ffind but search for char bfind_char : fsearch_char : bsearch_char : bol_bsearch_char : bol_fsearch_char : For details, see the online documentation. 2. narrow_to_region, widen_region: These are similar to the functions `narrow' and `widen' except that these actually delimit editing to a region. 3. undo now has redo. See doc/undo.txt. This is due to Dan Nelsen . 4. In C and SLang modes, the TAB key also adjusts the indentation of preprocessor directives. The variable C_Preprocess_Indent controls the amount of indentation. By default, it is 1. 5. XJed specific: the resource names have been changed to conform more closely with other programs. In particular, XJed must be changed to xjed in your .Xdefaults file because XJed now uses the XTerm class. 6. Emacs-like insert/copy-to register operations added. The actual functions are called `reg_insert_register' (Ctrl-X G) and `reg_copy_to_register' (Ctrl-X X). These functions are not available on 16 bit systems. 7. Experimental java mode. (Marko Teittinen ) }}} Changes since 0.97-12 {{{ 0. Misc bug fixes. Nothing major. 1. New intrinsic variable: REPLACE_PRESERVE_CASE. If non-zero, replace functions will attempt to match the case of the new string with the replaced one. This only happens if the two strings have the same length. 2. Maximum keyword length for syntax highlighting has been raised from 16 characters to 20 characters. 3. C-mode improvements 4. Big news for wjed users: Luchesar Ionkov seems to have fixed the subprocess support under Windows. There have also been a few other wjed bug fixes. 5. jed's mailer now works properly with mailx. Someday I need to integrate Eric's sendmail patches. }}} Changes since 0.97-11 {{{ 1. Xjed was rejecting command line arguments-- now fixed. 2. Repeat factor now works for `@' type keybindings (macros). 3. New mousex.sl (jed running in an Xterm--- NOT Xjed). 4. Misc bug fixes. 5. More improvements to Windows jed (wjed), specifically pull down menus and shell commands are available. Again, this is due to Luchesar Ionkov. Note: Under MSWINDOWS, os.sl loads a different file (mswmouse.sl) to define mouse actions more suitable to a 2 button mouse. I suspect that this file should be modified to make the mouse behave more like other Windows programs. e.g., drag mouse to define a region then click a menu item to act on the region. Any volunteers? }}} Changes since 0.97-10 {{{ 0. MS-Windows version of jed now available. This is called `wjed.exe'. Right now, it is rather primative with no support for menus or shell interaction. Of course the mouse works with the middle button simulated by the alt key (see jed/doc/mouse.txt). Thanks to lionkov@sf.cit.bg (Luchesar Ionkov)) for the patches. (He also sent me patches for shell interaction but they would not compile under BCC 3.1). 1. There were many complaints about change number 4 in 0.97-6: 4. XJed: Now when the meta (alt) key is used in conjunction with a non-alphanumeric key such as `{', the character is simply returned. If this creates a backward compatibility problem or appears too restrictive, please let me know. Apparantly, this is too restrictive so I have removed the restriction. Email me for for a simple way around this lifting of the restriction. 2. Directories with names ending in ~ were not getting expanded properly. 3. Slang Version 0.99-19 is now required. This implements the new intrinsic function `strcompress'. 4. QNX support added. 5. Support for an alternate set of keywords added. The C-mode defines some of these keywords such as `exit', `malloc', `strlen', etc... Use something like: set_color ("keyword1", "green", "white"); to set the colors for this set. 6. A couple of MSDOS jed bugs found. One affects the keyboard and the other fix corrects a bad regular expression when compiling using bcc. 7. idl mode enhanced with indentation. }}} Changes since 0.97-9 {{{ 1. Small bug in cmode.sl dealing with C++ style comments at first line of buffer corrected. 2. Syntax highlighting problem fixed. 3. Is shell.sl finally fixed under MSDOS? I think so. 4. Tiny change to mutekeys.sl. 5. jed -secure args.... will run jed in secure mode. This means that access to the shell will be denied. 6. Tiny bug affecting slang_mode corrected. (Very rare case). 7. First attempt at a brief mode. If you want to try it out, add: () = evalfile ("brief"); to your jed.rc file. Currently this file is only for MSDOS and OS2. 8. Better EDT support for jed386.exe. You will need GOLD.COM which is a TSR that maps the Numlock key to GOLD. 9. Low level keyboard interface for OS/2 and MSDOS re-written. Let me know if there are any inconsistencies. I have been unable to test it under OS/2. 10. Is dired fixed for OS/2?? 11. bibtex mode added (Author: Carsten Tinggaard Nielsen, tinggard@iesd.auc.dk) }}} Changes since 0.97-8 {{{ 1. html syntax highlighting mode added. 2. New functions: _autoload and _add_completion. See function documentation. Briefly, these permit slightly faster loading. 3. Typos corrected in shell.sl, emacs.sl, and dired.sl. 4. Small correction for file name expansion under VMS. 5. Ran purify on source code and fixed about two bad memory references. 6. new nroff mode }}} Changes since 0.97-7 {{{ 1. The F1-F12 keys may now be used with jed386.exe and edt.sl. See jed/doc/jed_faq.txt for more on EDT mode and jed386.exe. 2. The `untab' function has been fixed. I broke it in 0.97-7 (see below). 3. Somewhat nasty bug fixed that affected jed386.exe. 4. Unix and VMS: If the environment variable `COLORTERM' is defined, jed will automatically set the variable USE_ANSI_COLORS to a non-zero value. This feature is only available when compiled against slang version 0.99-14. Patches have also been sent in to the maintainer of the color xterm `rxvt' to automatically set this variable. Incidently, if you are using `color_xterm', I suggest that you try out `rxvt'. 5. New dired.sl and shell.sl courtesy of olesen@weber.me.queensu.ca (Mark Olesen) }}} Changes since 0.97-6 {{{ -1. Mouse support added to OS/2 version. (Thanks to John Burnell. ) 0. ``Expansion hook'' added. This hook is called upon TAB completion to preprocess the file before completion. The default definition of this function expands environment variables when the variable is preceeded by a dollar sign, e.g., $HOME. This function has not been defined for VMS since VMS already has this feature built in. Under Unix, this function also expands ~name to the login directory of the user `name'. The expansion only takes place when the TAB key is pressed. The new intrinsic: set_expansion_hook may be used to change the hook. 1. Under Unix, the function `get_passwd_info' may be used to return information about a specified user such as login dir, shell, etc... 2. TeX mode highlighting fixes: a. words containing accents now handled properly b. The TeX special characters `&_^#' are now colored as `operators'. c. Braces `{}' are colored as delimiters. 3. A prefix argument to the `untab' function will cause spaces to be converted into tabs. 4. Page up/down commands modified slightly to give appear more intuitive. 5. Misc bug fixes including: a. Parenthesis matching now works when `(` is also a comment delimiter. 6. Pasting using the mouse has changed slightly. Previously, text would be pasted at the position of the mouse. Now, it is pasted at the position of the cursor. This seems more intuitive. In addition, the editing position is restored to what it was before dragging text into the cutbuffer. Again, this is more intuitive and more closely follows the Xterm usage. 7. In C-mode, a if a line is preceeded by a line that ends with \, it is indented to the first column. This is useful for continuation lines. 8. Better native support for SunOS keyboards (pageup/down/home/end). 9. The function `shell_cmd' has been changed to return the exit code of the subprocess. Previously, it returned nothing. 10. idl mode added. Actually, only syntax highlighting is defined. This mode takes effect on .pro files. }}} Changes since 0.97-5 {{{ 0. New routines for adding keywords. These include: add_keyword, define_keywords See shmode.sl for an example. Basically, this file implements syntax highlighting for Unix sh and csh files. 1. Bug fixed in filename completion. 2. Kevin Humphreys auctex-for-jed package has been integrated into the source. Thanks Kevin. 3. Popular combinations of slang functions have been combined to create new functions. These include: bol (); skip_white (); ------------------> bol_skip_white (); down (1); ------------------> down_1 (); go_down (1); ------------------> go_down_1 (); up (1); ------------------> up_1 (); go_up (1); ------------------> go_up_1 (); These load twice as fast and use half as much memory. If I make them into intrinsics, they will execute twice as fast. Jed slang programmers are encouraged to use these. 4. XJed: Now when the meta (alt) key is used in conjunction with a non-alphanumeric key such as `{', the character is simply returned. If this creates a backward compatibility problem or appears too restrictive, please let me know. 5. XJed: XJed now will never read a file from stdin. This means that the *stdin* buffer will nolonger appear when it is started from a menu by the window manager. }}} Changes since 0.97-4a {{{ 0. A COMPLETE rewrite of all the indentation routines. The new routines are much more customizable through the use of syntax tables. Now, the C mode is completely written in S-Lang. New features: * Now much easier to add support for new languages. * ESC-q will format a comment if it is in the canonical form: /* * This is a C comment in * the canonical form * Notice how each line * begins with a `*'. */ * `goto_match' now works in both directions. * New C-mode functions: c_end_of_function : ESC Ctrl-E c_top_of_function : ESC Ctrl-A c_mark_function : ESC Ctrl-H 1. The function `whatline' has been renamed to `what_line' for consistency with other names. 2. New function: translate_region. This function is capable of modifying all characters in a region according to a lookup table. This is useful for converting buffers between various character sets. See the new version of jed/lib/rot13.sl for an example of its usage. 3. New functionality: yank-pop. This is implemented in jed/lib/yankpop.sl. Unfortunately this is not available on 16bit systems. This means if you use jed.exe you cannot use it. However, jed386.exe is a 32bit executable so it is available. If you do not know what yank-pop is already, do not worry too much. You should not notice its presence. However, if you do, hopefully you will welcome jed's emulation of it. This was added to improve the emacs emulation. See jed/doc/yankpop.txt for a simple discussion. 4. New intrinsic variable _jed_version added. This variable is an integer that represents the version number. For 0.97-5, it has the value 9705. For 0.97-11, it will have the value 9711 and so on. 5. A bug in jed386.exe was corrected. This bug was responsible for some keyboard lockups. }}} Changes since 0.97-4 {{{ 1. Intrinsic function documentation improved. 2. Source code should now compiled without specifying VAX compatability on ALPHA/AXP systems running OpenVMS. Use the deccmake.com files to create jed & slang. }}} Changes since 0.97-3 {{{ 1. New intrinsic functions: set_color_object: Associate a foreground/background color pair with an integer, e.g., set_color_object (31, "green", "red"); set_column_colors: Allows one to display the columns of a buffer in different colors. For example: set_color_object (31, "green", "white"); set_color_object (32, "red", "white"); set_column_colors (31, 1, 40); set_column_colors (32, 41, 80); Display columns 1 to 40 in green/white and columns 41 to 80 in red on white. This operates on a buffer by buffer basis does not work when there is syntax highlighting already associated with the buffer. This function is only useful when the buffer consists of data organized in columns, e.g., columns of numbers, dired mode, rmail mode, etc... str_replace: replace substrings in strings 2. In XJed, set_color("normal", "foreground-color", "background-color"), now works. This means it is nolonger necessary to mess with .Xdefaults to set the background color. 3. Small problem with expansion of symbolic links fixed. 4. It is now possible to set the color used for messages and errors. This is accomplished by using, e.g., set_color ("message", "blue", "white"); set_color ("error", "red", "white"); 5. A problem with info failing under VMS has been fixed. }}} Changes since 0.97-2 {{{ 1. GPM mouse support under Linux. This provides jed with complete mouse support (dragging, etc...) under the Linux console (See mouse.txt). 2. Mouse support under MSDOS. Read doc/mouse.txt for information. 3. Fixed a keymap problem in Xjed (specifically for Ctrl-_ and Function keys). }}} Changes since 0.97-1 {{{ 1. `:' key now overwrites instead of inserts in overwrite mode 2. Fixed tiny problem with indentation of preprocessor lines when the colon is pressed. 3. Corrected the omission of the closing `"' in abbrmisc.sl. 4. Problem with replace_across_buffer_files corrected. 5. If a file is edited for which one does not have write permission, the buffer is made read-only. 6. Termcap nolonger used. JED is now exclusively terminfo. }}} Changes since 0.97-0 {{{ 1. Fixed Xjed problem of cutting and pasting with other X applications. This file documents changes and new features found in JED }}} Changes since 0.96-2: {{{ -20. A bug introduced by `-18' beow that prevented searches from working properly when using a macro has been fixed. -19. `dired' modified such that ^K nolonger runs the function `dired_kill_line'. Instead, one must do: define dired_hook () { local_unsetkey ("^K"); local_setkey ("dired_kill_line", "^K"); } See jed.rc where this is performed. -18. RETURN key may be used to continue searches. Also, matches are highlighted. -17. Variable `No_Backups' added to control whether or not JED is to create backup files. -16. Command line argument parsing modified (in site.sl) to make it easier to write non-interactive scripts, e.g., jed -script my-script.sl file1 file2 ... Basically, `-script' simply loads the next argument (my_script.sl). It is up to the script file to interpret the remaining arguments. See doc/script.txt for more info. -15. Trivial modification that allow JED to become a GNU-info reader by using: `alias info jed -f info_reader' (Unix csh) $ info :== jed -f info_reader (VMS) -14. A VMS bug fixed. Specifically, the getkey AST is now disabled while the main thread is accessing the keyboard buffer. -13. NEW abbrev mode. This is a major rewrite of the old abbrev mode. See jed/doc/abbrev.txt for details. -12. `read_string_with_completion' added to read a string in the mini buffer using a list of strings for completion. -11. Major change in S-Lang library removes the need for functions such as `free_array'. As a result, this function has been removed. -10. abbrev mode. This differs from `dabbrev' in the sense that you can define global and local abbreviations and use them. The function `toggle_abbrev' may be used to turn the mode on/off. See abbrev.sl for details. -9. mousex.sl package adds mouse routines to any terminal using the XTerm client mouse protocol. Such terminals include the Linux console running selection as well as XTerm itself. Note: this could be made available across a dialup line from a PC using MS-Kermit, Procomm, etc... if someone would write the appropriate mouse TSR. -8. Added `tex_ldots' binding that converts three `.' to \ldots. -7. `replace_across_buffer_files' added. This function allows the user to replace a string across all buffers attached to a file. It is interactive. -6. Book marks added: `bkmrk_goto_mark' and `bkmrk_set_mark' These functions allow the user to set up to 10 bookmarks (0-9) and return to a previously set book mark from any buffer. These marks are implemented using new jed intrinsics: `user_mark_buffer' : returns buffer name associtated with mark `goto_user_mark' : goto position specified by mark `create_user_mark' : returns a mark at the current position -5. Automatic detection of ``non-native'' line endings. On Unix, if a file is read in with ^Ms at the end of lines, it is flagged such that writing out the file will preserve the line ending attributes. A `C' will appear on the status line to indicate this fact. On DOS, etc... if a file is read in without the ^M, it is flagged and an `L' will appear on the status line. Use the function `toggle_crmode' to change the attribute. -4A. New ways added to facilitate associating modes with files: a. add_mode_for_extension ("c", "c++"); This asscoiates c_mode with a file named something.c++. b. If top line of file contains something like: -*- mode -*- Note that in both cases the mode argument must omit the `_mode' part of the name. In fact, all modes now have names that end in `_mode'. -4B. `fortran' and `dcl' have been renamed `fortran_mode' and `dcl_mode'. -3. C mode indenting improved. -2. Writing to terminal under VMS SIGNIFICANTLY improved. Basically I just bypassed the VAXC buffered stdio routines in favor of my own. This might improve performance for Unix systems as well. -1. Emacs style completion added-- press tab to show completions, press space to cycle through them. Note that pressing PageUp/Down keys will scroll the completion buffer from the minibuffer. 0. Bug fixes 1. Massive restructuring. Keymaps, Searching, and Terminal I/O moved to S-Lang. 2. color syntax highlighting in FORTRAN, TeX, and C modes. 3. TeX mode enhanced--- more to come. 4. ``menu'' bar can now be hidden-- see jed.rc. 5. More hooks: c_mode_hook, tex_mode_hook, text_mode_hook, wrap_hook 6. Better documentation on hooks (see doc/hooks.txt). 7. showkey binding changed to `Ctrl-H k'. Also rectangle commands are now bound in emacs.sl to emacs bindings. 8. Mute (Dead or accent) key support added. See jed.rc 9. gzipped info file support added for MSDOS 10. Alt key processing for X-Windows fixed. 11. Significant additions to dired, e.g, `~' flags all backup files. 12. Visible bell add to systems that support it (Xjed, pc and OS/2, Linux, etc...). }}} Changes since 0.96-1: {{{ 1. bug fix regarding regular expressions 2. Indentation of data statment in fortran mode fixed. 3 Documentation is improving.... 4. dabbrev mode added (ESC / expands current word based on other words in the buffer.) 5. Now possible to control Xjed syntax highlighting from .Xdefaults file. 6. Improvements to S-Lang ==> improvements to JED 7. rmail.sl: added `Rmail_Dont_Reply_To' variable to suppress unwanted CCs. For example, I have: variable Rmail_Dont_Reply_To = "davis@amy,davis@pacific.mps.ohio-state.edu,davis@amy.tch.harvard.edu"; in my .jedrc file. }}} Changes since 0.96-0: {{{ 1. set_color_escape_sequence function added to exploit JED's ability to do color syntax highighting on more exotic color terminals. 2. Preprocessor lines can now be highlighted. See jed.rc as well as doc/syntax.txt for details. 3. Tiny bug fixes: * bug in info.sl found caused by info file that do not end with a newline character * isearch.sl is again able to repeat isearch backwards by pressing ^R. This bug was introduced in 0.96-0. * EDT special insert now works. * Archive bit now set when JED creates a new file on MSDOS (only jed.exe had this problem--- not jed386.exe) 4. Support for CRAY added. 5. If JED is started without a filename specified, the brief message will be displayed warning the user that the scratch buffer will not be saved. 6. On MSDOS, rgrep.exe (recursive grep) is now distributed. ON Unix, simply do `make rgrep' to get a recursive highlighting grep. Highlights of Major changes for 0.96: 1. OS/2 versions available!! 2. Color syntax highlighting in C mode. 3. Much improved indentation for C code. 4. Improved Fortran mode 5. Up to 20% faster loading 6. jed386.exe distributed with DOS version and runs in a Windows DOS box (provides up to 256 Megs of Virtual memory) }}} Changes since 0.95-8b: {{{ 0. JED now compiles and runs under OS/2! OS/2 executables are zipped in the pc distribution. See install.pc for more information. [ I would like to acknowledge John Burnell (johnb@huia.grace.cri.nz) for his work on the OS/2 port. In addition, I am very grateful to Darrel Hankerson (hankedr@mail.auburn.edu), who is responsible for the Microsoft C and emx/gcc versions, as well Dominik Wujastyk (ucgadkw@ucl.ac.uk) for his contribution to the OS/2 version. ] 1. re_fsearch and re_bsearch functions have been changed to return 1 + the length of the match, if a match was found, or return 0 if no match was found. For example, `re_fsearch("$")' matches the end of a line which, strictly speaking, is a match with 0 length. 2. Use `jed -l preparse' to pre-parse the .sl files for faster loading. `jed -l preprocess' is now obsolete. Again, read install.*. }}} Changes since 0.95-7b: {{{ 1. Color syntax highlighting added to C mode. It is possible to separately color keywords, strings, numbers, delimeters, comments, and operators. This even works on VMS and Unix systems when using character based color terminals such as NCSA telnet, MS-Kermit, etc... See doc/color.txt and doc/syntax.txt for more information. 2. byte compiling changed to allow preprocessing only. Simply preprocessing is recommended on systems where more than one type of JED executable will share the same set of *.slc library files (e.g., Unix where both JED and XJed might be running). Simply do: jed -batch -l preprocess.sl On MSDOS systems with only one version of jed.exe running, use: jed -batch -l bytecomp.sl }}} Changes since 0.95-6b: {{{ 1. It is now possible to display 24 hour time on the status line. Earlier versions were capable of displaying on AM/PM format. 2. -tmp command line switch added. This means that the current buffer is to not be autosaved or backed up. This is suitable when JED is used as an editor for elm, etc... 3. DJGPP version fixed so that JED can read embedded ^M characters and ^Z characters while in text mode. Of course the ^M is striped if it preceeds a line feed character. 4. Improved fortran mode. The fortran mode is the first mode that I ever wrote for JED using S-Lang. Since then, I have had alot of experience with S-Lang and recently I found myself programming FORTRAN again, so I rewrote it. Do `Ctrl-H f fortran' for details. }}} Changes since 0.95-5b: {{{ 0. XJED now compiles as a DECWindows executable under VMS. 1. The interactive replace function has been renamed to `replace_cmd' and is now implemented in S-lang. It can now search/replace across lines. For most users, this change should be transparent. 2. New functions: set_buffer_no_backup () set_buffer_no_autosave () 3. XJed mouse changes: Clicking on a window status line causes a different behavior. Specifically: left: switch to next buffer middle: split the window right: delete the window For example, one can quickly move from one buffer to the next by simply clicking on the status line with the left mouse button. 4. XJed can nor distinguish shifted and control function keys. This enables one to bind Shift arrow keys and Control arrow keys to different functions. 5. Improved indenting in C-mode. 6. New variables added: Default_Mode: default mode for a file of unknown extension. Startup_With_File: if non-zero, JED will prompt for a filename if none was specified on the command line. }}} Changes since 0.95b for 0.95-5b. {{{ 1. Bug fixes: rectangular cut and paste (when cutting single char region from empty line) minor color problem fixed when scrolling on color terminals edt_line function fixed (kp0 key) minor rmail mode changes backward RE-search fix. info mode bug fixed that deals with multiple word node names typo in menu.sl corrrected. The type was causing a STACK_UNDERFLOW error to be generated. parenthesis blinking bug fixed that manifested itself when inserting a parenthesis on a line that was automatically horizontally panned. 2. RETURN now selects menu item in info mode. 3. Now possible to search/replace strings that span multiple lines. 4. In XJed, it is now possible to distinguish between Shift and Control function and arrow keys. Also, every function key now returns something (use the function x_set_keysym to change what a function returns) 5. In XJed, clicking on the status line of a window now switches to a new buffer for that window. This makes it possible to conveniently cycle through all buffers. 6. rgrep flag now added so that directory links may be followed. Rgrep is a recursive, highlightin grep that is distributed with JED. See doc/rgrep.doc for more information. 7. The search forward/backwad commands are now S-Lang functions which means that they may be changed easily. 8. New function for PC versions (DJGPP too!): find_binary_file. This function will prompt for a filename and find it in binary mode. A binary mode file is indicated by a `Z' status line flag. This means that when the file is saved, it will be saved in binary mode as well. This function provides a transparent way to edit binary files under DOS. 9. JED now understands 8 bit control sequences generated by terminals in 8 bit mode such as DEC VTXXX. This is particularly relevant when using JED on VMS. Changes for version 0.95 (since 0.94-2) 0. JED distribution is different. If you have built JED in the past, please read the install files because things have changed. 1. Support for column numbers on status line (set LINENUMBERS = 2) 2. X-Terminal (and DECWindows) version (make xjed). See doc/xjed.doc 3. Elm like read/write mail (see rmail.txt-- this is considered ALPHA, by default it is not enabled.) 4. Additional support for Color terminals (allow different colors for modelines, regions, etc...) 5. MUCH Improved support for colors on PC versions (looks MUCH nicer, see how it is used in jed.rc) 6. By popular demand, a new function `describe_bindings' is available that dumps the keybindings for the current keymap. 7. New variable Stratup_With_File can be set to prompt user for a filename if none is specified on the command line. 8. VMS: A convenient new interface to VMSHELP is now available. This overcomes most of the shortcomings of the VMS HELP command. It is bound to Ctrl-H M. 9. search_forward + search_backward can now search for strings spanning multiple lines. Also, looking_at can see across multiple lines. Also see changes listed in the next section. ********* Important ************** The S-Lang preprocessing conditional compilation declarations have changed. Now, constructs such as: #ifdef UNIX .. #else .. #endif are used. This means that you may have to edit you personal jed.rc file. Instead, I encourage you to simply copy the jed.rc file shipped with this version and add your own extensions to it. ************************************ }}} New changes SINCE 0.94-0: {{{ 1. New buffer flags: no backup and no autosave 2. #ifdef #else #endif preprocessing 3. skip_chars, bskip_chars changed. Now, say, `skip_chars("^a-z")' will skip ALL characters EXCEPT in range `a-z'. 4. Default EDT binding of TAB changed to `indent_line'. See jed.rc to change it back. 5. `occur' function now uses regular expression searches. 6. Special `linux.sl' file for Linux systems. See `install.unx'. 7. New intrinsics: buffer_visible, pop2buf_whatbuf, bury_buffer, regexp_nth_match, 8. `window_info' intrinsic modified to take a parameter. 9. `search_file' intrinsic modified for regular expression search. 10. New support for saving and reusing keyboard macros. This feature has not been exploited yet! 11. By popluar request: Highlighting only occurs in the CURRENT window. 12. Miscellaneous bug fixes. There are also some new S-Lang builtin intrinsic functions: 1. string_match: preforms RE match on a string 2. string_match_nth: returns information about previous match 3. Unix specific intrinsics: unix_kill : sends a signal to a process unix_ctime : converts a time value to a string representation stat_file : performs `stat' on a given file. lstat_file : like stat but returns information about a link stat_struct: returns information from previous stat call. chown : change owner/group of a file chmod : change protections of file. 4. It is now possible to perform assignments in variable declaration statements: variable i = 10, y = 20.87; 5. && and || are now flagged as errors. ****************************** New since 0.94-0 : ------------------------------------------------------------ PageUP/Down functions scroll other window if called from the minibuffer. Some defaults changed in jed.rc: Display line numbers on the status line is now the default. Regular expression matching (search/replace): re_search_forward, re_search_backward, query_replace_match New S-Lang intrinsics include: prefix_argument() : returns value of prefix argument. set_status_line(format, flag) : enables user to customize status line re_fsearch, re_bsearch, replace_match : regular expression intrinsics getpid : returns process pid New user variables: DISPLAY_TIME if non-zero, allows %t processing in status line format. ALT_CHAR (ibmpc only) enables Alt-key processing. Specifically, setting this to 27 (Ascii 27) causes ALT-X to generate ESCAPE-X, etc... C_BRA_NEWLINE if non-zero, insert a newline before inserting '{' in C-mode. This was the default in previous versions but it now user selectable. ------------------------------------------------------------------------------ New features in 0.94-0 0.94-0 does not really add any new functionality to 0.93. However, there is a major change: S-Lang is now very C-Like. (It can still be programmed as RPN though, see e.g., info.sl) By C-like, I mean that you can write S-Lang functions that look like: define sum(a, b) % sum integers from a to b { variable s, i; s = 0; for (i = a; i <= b; i++) s += i; return (s); } S-Lang has not lost any functionality, rather, its new syntax makes it more accessable to others. The new philosophy is that JED is an editor which just happens to embed S-Lang as its extension language. Actually, this has always been the philosophy but not it is even more clear cut. To compile the new JED (0.94) you will need to pick up /pub/slang/slang.tar.Z as well. This is the S-Lang interpreter code to be compiled as a library and linked in with JED. The only other ``major'' changes are: 1. do_while construct added: do { stuff... } while (expression); 2. `defined?' replaced by `is_defined'. 3. Temporary global variables $0, $1, ... $9 added for convenience and clarity. 4. Comment delimeter changed from `;' to `%'. 5. Arrays are indexed from 0 not 1. 6. \??? is now Octal ??? NOT decimal ???. \d??? is decimal. 7. Sprintf added to intrinsics (formats strings) In addition, you should ``bytecompile'' the .sl files after installing the new version of jed. It is this simple: jed -batch -l bytecomp.sl }}} }}} jed-0.99-19/INSTALL.pc0000644002657400265740000001756511311317447013142 0ustar davisdavis-*- mode: text -*- IBMPC (DOS, Win9X, NT, and OS/2) installation specific functions. !!! Important News: The `real-mode' version of jed is no longer distributed. This version of jed will work only with 386+ class pcs. It will not work on earlier systems. This distribution includes following jed executables in the bin subdirectory. jed386.exe MSDOS (DJGPP V2) jed.exe Win32 console mode (MING32 egcs-2.91.66) wjed.exe Win32 GUI (MING32 egcs-2.91.66) Do NOT run these executables without first properly installing the editor. Brief installation overview. ============================ 1. Unzip the distribution. 2. Set the appropriate environment variables in your autoexec.bat file. This is also important for long file name support. 3. Copy the executables to somewhere on your path. 4. If installing on MSDOS (not win9x,NT), make sure a DPMI server is available. 5. Reboot. 6. Test it. OS/2 specific information follows the last step. =========================================================================== Step 1: Unzipping the distribution =========================================================================== Files with the extension '.zip' can be unzipped with Info-Zip's unzip or with pkunzip. However, if using pkunzip, then you MUST use the -d option; e.g., pkunzip -d jedB0998.zip The -d option is necessary to preserve the directory structure. =========================================================================== Step 2: Environment variables =========================================================================== Suppose that you have unzipped jed.zip from the subdirectory c:\editors. You will then find: c:\editors\jed c:\editors\jed\lib c:\editors\jed\bin c:\editors\jed\src c:\editors\jed\info c:\editors\jed\doc The directory C:\editors\jed will be your JED_ROOT directory. You will need to set the environment variable JED_ROOT, as in: set JED_ROOT=c:\editors\jed Under DOS and Windows, this command should be placed in the autoexec.bat file. **Note: If you intend to use shell commands on a win32 system (win9x,NT), then do NOT install in a directory containing space characters. If you choose to do so, then specifiy JED_ROOT using the short file name form. Under OS/2, users often place such lines in config.sys so that the variable is set in every command window. Other users have a standard file which they run at the start of every command window, and the "set" command could be placed in such a file. Don't edit config.sys unless you are confident in your ability to make changes to this essential file. Long File Names: --------------- The win32 versions of jed (jed.exe, wjed.exe) support long file names. The DJGPP version (jed386.exe) supports long file names on a win32 system provided that set LFN=y is put in your autoexec.bat file. Unfortunately, it looks like NT does not support the long filename API used by jed386.exe. This is not important since one would probably use the win32 versions of jed on such systems. =========================================================================== Step 3: Install jed*.exe =========================================================================== Copy the executable files `bin\jed*.exe' to where you keep your other *.exe and *.com files (somewhere in your path!). =========================================================================== Step 4: The DPMI Server =========================================================================== (You can skip this step if your system is a win9x,NT system) The executable jed386.exe is a flat 32 bit djgpp compiled executable requiring a 386 class machine. It also requires the presence of DPMI server. Windows, QDPMI, 386Max, NWDOS, OS/2, Win/NT and Linux DOSEmu all provide DPMI services that jed386 can use. If you do not have a DPMI server, use Charles Sandmann's freely available DPMI server. I have made the binary available via ftp from space.mit.edu in /pub/davis/jed/csdpmi. That directory contains two .zip files. The only file that is required is `csdpmi3b.zip' which contains the DPMI server and documentation. The other file, `csdpmi3s.zip', contains the sources to the server and is not required. Please read the documentation that comes with the server for installation. Briefly this involves putting the executable `cwsdpmi.exe' somewhere in your path, e.g., where you put jed386.exe. That's really all there is to it. By default, it will create a swap file called C:\cwsdpmi.swp. Read the instructions as part of csdpmi3b.zip for information about changing the name or location of the swap file. =========================================================================== Step 5: Reboot =========================================================================== Reboot your machine so that the changes you have made in your autoexec.bat or config.sys file will take effect. =========================================================================== Step 6: Test =========================================================================== JED should now be installed on your system. To test to see if it properly installed, run the editor in batch mode: jed -batch -f quit_jed This should produce something like (the actual output may vary): loading C:\editors\jed\lib\site.slc loading C:\editors\jed\lib\os.sl loading C:\editors\jed\lib\jed.rc At some point, you may also want to preparse the S-Lang library files by running jed as: jed -batch -n -l preparse This creates pre-parsed jed\lib\*.slc files that load quicker than lib\*.sl files. Once jed is installed on your system, it can be customized by editing the file `jed.rc'. Read the bit about defaults.sl in install.all for customizing your distribution in a way that is compatable with future versions. !!!Note: If you see an error message of the form: Load Error: no DPMI then your need to re-read the above comments about a DPMI server. =========================================================================== OS/2-specific information =========================================================================== JED can be compiled for OS/2 2.x using Mattes' emx/gcc or Borland C, and for OS/2 1.x--2.x with Microsoft C. The file jed/mkfiles/makefile.os2 will build JED using emx/gcc or MSC, depending on the settings given in the makefile.os2; the default is to use emx/gcc. To compile JED for OS/2 using emx/gcc, just change to the directory jed/src, and give the command "DMAKE -f mkfiles/makefile.os2". The default JED_ROOT location can be specified in the makefile, but if you prefer, you can leave the makefile value as it is, and instead specify the location by using a "SET JED_ROOT=..." statement in the OS/2 config.sys file to set the environment variable. The environment variable overrides the value built into JED by the makefile. OS/2 versions first appeared in 0.95. Extended attributes are handled, and the case of filenames on HPFS will be preserved. Buffer-name completion will cycle through all matches, regardless of case. The OS/2 versions can handle compressed info files, ispell, and man. Necessary support programs for these capabilities may be obtained from ftp.cdrom.com (currently in pub/os2/all/unix/ or pub/os2/2_x/unix/) or ftp.informatik.tu-muenchen.de. I would like to acknowledge John Burnell (johnb@huia.grace.cri.nz) for his work on the OS/2 port. In addition, I am very grateful to Darrel Hankerson (hankedr@mail.auburn.edu), who is responsible for the Microsoft C and emx/gcc versions, as well Dominik Wujastyk (ucgadkw@ucl.ac.uk) for his contribution to the OS/2 version. Any questions should be emailed to me at davis@space.mit.edu. jed-0.99-19/INSTALL.be0000644002657400265740000000102211311317447013103 0ustar davisdavisBeOS is largely Unix/GNU compatible so for installing you should read the instructions in INSTALL.unx. But there are a few issues: - If you get the message 'error: cannot guess host type; you must specifiy one' you need a autoconf/config.guess and autoconf/config.sub. Those from autoconf-2.13 work. - BeOS neither needs nor supports -lm. You should remove them (after configure) from the Makefile manually. - BeOS uses a blinking white-on-black cursor. This is largely unreadable in the default Jed 0.99 color-scheme. jed-0.99-19/doc/0000755002657400265740000000000011311317447012237 5ustar davisdavisjed-0.99-19/doc/hlp/0000755002657400265740000000000011311317447013022 5ustar davisdavisjed-0.99-19/doc/hlp/libfuns.hlp0000644002657400265740000027374311311317447015211 0ustar davisdavisbufed SYNOPSIS bufed DESCRIPTION Mode designed to aid in navigating through multiple buffers patterned somewhat after dired. To invoke Bufed, do `M-x bufed' or bind to `C-x C-b' (emacs) `g' Update the buffer listing. `k' Kill the buffer described on the current line, like typing `M-x kill_buffer' and supplying that buffer name. `s' Save the buffer described on the current line. `f', `SPC', `CR', `TAB' Visit the buffer described on the current line. `f' and `SPC' will create a new window if required. `CR' will use the current window. `TAB' will revert to a single window. `Q' Quit bufed mode. -------------------------------------------------------------- save_buffers SYNOPSIS save_buffers USAGE Void save_buffers (); DESCRIPTION Save all modified buffers that are associated with a file without user intervention. -------------------------------------------------------------- next_buffer SYNOPSIS Cycle through the list of buffers USAGE Void next_buffer () DESCRIPTION Switches to the next in the list of buffers. NOTES (This is the same function as mouse_next_buffer in mouse.sl) SEE ALSO buffer_list, list_buffers -------------------------------------------------------------- save_buffer_as SYNOPSIS Save the buffer to a different file/directory USAGE Void save_buffer_as(force_overwrite=0) DESCRIPTION Asks for a new filename and saves the buffer under this name. Asks before overwriting an existing file, if not called with force_overwrite=1. Sets readonly flag to 0, becouse if we are able to write, we can also modify. SEE ALSO save_buffer, write_buffer -------------------------------------------------------------- C_Autoinsert_CPP_Comments SYNOPSIS Control insertion of C++ comments DESCRIPTION In c-mode, if a line starts with //, then pressing return will cause the next line to also start with //. This feature is useful for writing multiple comment lines using C++ style comments. SEE ALSO c_mode -------------------------------------------------------------- C_Switch_Offset SYNOPSIS Additional indentation to switch blocks USAGE C_Switch_Offset = 0 DESCRIPTION This function may be used to increase the indentation of code within a `switch' block. Since this also affects the indentation of `case' statements, `C_Colon_Offset' may need to be adjusted. SEE ALSO C_Colon_Offset -------------------------------------------------------------- C_Outer_Block_Offset SYNOPSIS Indentation offset for code in an outer block USAGE C_Outer_Block_Offset = 0 DESCRIPTION The value of this variable may be used to adjust the indentation of code in an outer block. An outer block is one that has its opening brace at the start of a line. The values of this variable does not affect the indentation of C++ classes and namespaces. EXAMPLE NOTES SEE ALSO -------------------------------------------------------------- C_Namespace_Offset SYNOPSIS C_Namespace_Offset DESCRIPTION Integer C_Namespace_Offset = 3; This variable may be changed to adjust the indentation of members inside of a class declaration block. SEE ALSO c_mode SEE ALSO C_BRA_NEWLINE, C_BRACE, C_Class_Offset, C_INDENT, C_Namespace_Offset -------------------------------------------------------------- C_Class_Offset SYNOPSIS C_Class_Offset DESCRIPTION Integer C_Class_Offset = 3; This variable may be changed to adjust the indentation of members inside of a class declaration block. SEE ALSO c_mode SEE ALSO C_BRA_NEWLINE, C_BRACE, C_INDENT, C_Namespace_Offset -------------------------------------------------------------- C_Param_Offset_Max SYNOPSIS Control indentation of continued parameter list USAGE Integer C_Param_Offset_Max = -1 DESCRIPTION This variable may be changed to adjust the indentation of parameters in a funcion call that extends over multiple lines. If the value is less than 0, the feature is off, otherwise it holds the max number of spaces to indent the parameters on the continuation line(s). SEE ALSO c_mode SEE ALSO C_BRA_NEWLINE, C_BRACE, C_INDENT -------------------------------------------------------------- C_Macro_Indent SYNOPSIS Control indentation of pre-processor macros USAGE Integer C_Macro_Indent = 3 DESCRIPTION This variable may be changed to adjust the indentation of pre-processor macros. SEE ALSO c_mode SEE ALSO C_INDENT -------------------------------------------------------------- C_Bracket_Indent SYNOPSIS Control indentation within lone brackets USAGE Integer C_Bracket_Indent = 4 DESCRIPTION Control the alignment of within parenthetic content that start with a lone left parenthesis. A value greater than zero uses C_INDENT to determine the indentation level. Additionally, common operators are outdented. eg, while ( expr1 + expr2 == expr3 ) ... A value less than 1 turns this feature off. SEE ALSO c_mode SEE ALSO C_INDENT -------------------------------------------------------------- C_Label_Indents_Relative SYNOPSIS Set labels to indent relative to block USAGE C_Label_Indents_Relative = 0; DESCRIPTION If the value of this variable is non-zero, then label statements (goto targets) will get indented by the value of the `C_Label_Offset' variable relative to the enclosing block. Otherwise, `C_Label_Offset' will be interpreted as an absolute offset from the beginning of the line. SEE ALSO C_Label_Offset, C_Colon_Offset -------------------------------------------------------------- C_Label_Offset SYNOPSIS Controls the indentation of label statements USAGE C_Label_Offset = 0; DESCRIPTION The value of this variable controls the indentation of (goto) label statements. It is interpreted as an absolute or relative offset according to the `C_Label_Indents_Relative' variable. It does not affect the indentation of `case' statements. SEE ALSO C_Label_Indents_Relative, C_Colon_Offset -------------------------------------------------------------- c_mode SYNOPSIS c_mode USAGE Void cmode (); DESCRIPTION This is a mode that is dedicated to facilitate the editing of C language files. Functions that affect this mode include: function: default binding: c_insert_bra { c_insert_ket } newline_and_indent RETURN indent_line TAB goto_match Ctrl-\ c_make_comment ESC ; c_top_of_function ESC Ctrl-A c_end_of_function ESC Ctrl-E c_mark_function ESC Ctrl-H Variables affecting indentation include: C_INDENT C_BRACE C_BRA_NEWLINE C_CONTINUED_OFFSET C_Comment_Column (used by c_make_comment) C_Class_Offset C_Switch_Offset C_Colon_Offset C_Namespace_Offset Hooks: `c_mode_hook' SEE ALSO c_set_style -------------------------------------------------------------- c_set_style SYNOPSIS Set the indentation style for C mode USAGE Void c_set_style (style) DESCRIPTION This function sets the C mode indentation variables appropriate for a common indentation style. Currently supported styles include: "gnu" Style advocated by GNU "k&r" Style popularized by Kernighan and Ritchie "bsd" Berkeley style "foam" Derivate bsd-style used in OpenFOAM "linux" Linux kernel indentation style "jed" Style used by the author "kw" The Kitware style used in ITK, VTK, ParaView, ... SEE ALSO c_mode -------------------------------------------------------------- get_comment_info SYNOPSIS Get comment information according to mode USAGE Struct_Type = get_comment_info ( [mode] ); DESCRIPTION Retrieves the comment information according to the optional `mode' argument, or for the present mode if `mode' is not present. Every mode that wants to use this function should provide comment information using the `set_comment_info' function. The returned value is a structure with the following fields: cbeg % begin comment string cend % end comment string flags % flags column % preferred column for comments If comment information does not exist for the mode, then `NULL' will be returned. SEE ALSO set_comment_info, comment_region, comment_line, uncomment_region -------------------------------------------------------------- set_comment_info SYNOPSIS Set comment information for a mode USAGE set_comment_info ([mode,] cbeg, cend, flags) DESCRIPTION This function sets comment information for a specified mode. If the optional mode argument is not present, the current mode will be used. The other 3 required arguments represent the comment start string (`cbeg'), the comment end string (`cend'), and an integer flags argument that indications how these strings are to be used by the `comment_region' function. In particular, `flags' is a bitmapped integer whose bits have the following meaning: 0x01 : Comments will start at column defined by the region start, otherwise comments will be indented to the level of the first line in the region. 0x02 : Lines in the region will be padded out to the same column. 0x04 : Blank lines will be commented. SEE ALSO set_comment_info, comment_region, comment_line, uncomment_region -------------------------------------------------------------- strncat SYNOPSIS strncat USAGE Void strncat (String a, String b, ..., Integer n); DESCRIPTION Returns concatenated string "abc..." NOTES This function is obsolete. -------------------------------------------------------------- Compile_Default_Compiler USAGE variable Compile_Default_Compiler = "gcc"; DESCRIPTION This variable specifies the default compiler to be assumed when parsing error messages in the compile buffer. If not set, "gcc" is assumed. Currently supported compilers include: gcc (GNU C Compiler) bcc (Borland C Compiler) tcc (Turbo C Compiler) ultrix_cc (Ultrix C Compiler) hp_cc (HP C compiler) sun_acc (Sun ANSI C compiler) aix, xlc, xlf (Various AIX C compilers) wcc (Watcom C compiler) javac (Java Compiler) vc (Microsoft Visual C) NOTES The primary purpose of this variable is to select a compiler prior to loading compile.sl. Once compile.sl has been loaded, the value of this variable has no effect. To switch compilers, the `compile_select_compiler' function must be used. SEE ALSO compile_select_compiler, compile_add_compiler -------------------------------------------------------------- auto_compression_mode SYNOPSIS Toggle auto-compression-mode USAGE auto_compression_mode ([Int_Type state [,&prev_state]]) DESCRIPTION The `auto_compression_mode' function toggles the auto-compression-mode on or off. When on, files whose names end with `.gz', `.Z', or `.bz2' will automatically uncompressed when read in, and compressed when written out. -------------------------------------------------------------- cua_delete_word SYNOPSIS Delete the current word (or a defined region) USAGE Void cua_delete_word () DESCRIPTION cua_delete_word is somewhat context sensitive: * Delete from the current position to the end of a word. * If there is just whitespace following the editing point, delete it. * If there is any other non-word char, delete just one char. * If a region is defined, delete it (instead of the above actions). This way, you can do a "piecewise" deletion by repeatedly pressing the same key-combination. NOTES This is actually the ide_delete_word function form Guido Gonzatos ide.sl mode, put here to be usable also with other emulations. SEE ALSO delete_word, delete_cmd, cua_kill_region -------------------------------------------------------------- repeat_search SYNOPSIS continue searching with last searchstring USAGE define repeat_search () SEE ALSO LAST_SEARCH, search_forward, search_backward -------------------------------------------------------------- cua_indent_region_or_line SYNOPSIS Indent the current line or (if defined) the region USAGE Void cua_indent_region_or_line () DESCRIPTION Call the indent_line_hook for every line in a region. If no region is defined, call it for the current line. SEE ALSO indent_line, set_buffer_hook, is_visible_mark -------------------------------------------------------------- cua_escape_cmd SYNOPSIS Escape from a command/aktion USAGE cua_escape_cmd() DESCRIPTION Undo/Stop an action. If a region is defined, undefine it. Else call kbd_quit. SEE ALSO kbd_quit -------------------------------------------------------------- cua_escape_cmd SYNOPSIS Distinguish the ESC key from other keys starting with "\e" USAGE Void cua_escape_cmd() DESCRIPTION If there is input pending (i.e. if the keycode is multi-character), "\e" will be put back to the input stream. Otherwise (if the ESC key is pressed, "\e\e\e" is pushed back. With ALT_CHAR = 27, the Alt key can be used as Meta-key as usual (i.e. press both ALT + to get the equivalent of the ESC key sequence. SEE ALSO escape_cmd, one_press_escape, kbd_quit, map_input, setkey -------------------------------------------------------------- cua_one_press_escape SYNOPSIS Redefine the ESC key to issue "\e\e\e" USAGE cua_one_press_escape() DESCRIPTION Dependend on the jed-version, either x_set_keysym or meta_escape_cmd is used to map the ESC key to "\e\e\e" EXAMPLE To let the ESC key abort functions but retain bindings for keystrings that start with "\e" do cua_one_press_escape(); setkey ("cua_escape_cmd", "\e\e\e"); % Triple-Esc -> abort NOTES The function is experimental and has sideeffects if not using xjed. For not-x-jed: It uses the "^^" character for temporarily remapping, i.e. Ctrl-^ will call cua_escape_cmd(). In order to work, it must be loaded before any mode-specific keymaps are defined -- otherwise this modes will be widely unusable due to not working cursor keys...! It breaks functions that rely on getkey() (e.g. isearch, showkey, old wmark(pre 99.16), ...) It will not work in keybord macros and might fail on slow terminal links. SEE ALSO cua_escape_cmd, cua_escape_cmd, getkey, setkey, x_set_keysym -------------------------------------------------------------- cua_save_buffer SYNOPSIS cua_save_buffer USAGE Void cua_save_buffer(); DESCRIPTION Save current buffer. -------------------------------------------------------------- Dabbrev_delete_tail SYNOPSIS Let completion replace word tail? USAGE Int_Type Dabbrev_delete_tail = 0 DESCRIPTION Should the completion replace the part of the word behind the cursor? SEE ALSO dabbrev -------------------------------------------------------------- Dabbrev_Default_Buflist SYNOPSIS Which buffers should dabbrev expand from? USAGE Int_Type Dabbrev_Default_Buflist = 0 DESCRIPTION The buffer-list when dabbrev is called without argument 0 = current buffer, 1 = visible buffers (including the current), 2 = all buffers of same mode, 3 = all buffers, 4 = other visible buffers (excluding the current), 5 = all other buffers of same mode (excluding the current), 6 = all other buffers (excluding the current) SEE ALSO dabbrev -------------------------------------------------------------- Dabbrev_Look_in_Folds SYNOPSIS Scan folds for expansions USAGE Int_Type Dabbrev_Look_in_Folds = 1 DESCRIPTION Should dabbrev scan folded parts of the source buffer(s) for expansions too? SEE ALSO dabbrev -------------------------------------------------------------- Dabbrev_Case_Search SYNOPSIS Let dabbrev stick to case USAGE Int_Type Dabbrev_Case_Search = 1 DESCRIPTION Should dabbrev consider the case of words when looking for expansions? Will be overridden by a blocal variable "Dabbrev_Case_Search" or by the mode-info variable "dabbrev_case_search". SEE ALSO dabbrev -------------------------------------------------------------- dabbrev SYNOPSIS Complete the current word looking for similar words USAGE dabbrev([optional_argument]) DESCRIPTION Takes the current stem (part of word before the cursor) and scans the current buffer for words that begin with this stem. The current word is expanded by the non-stem part of the finding. Subsequent calls to dabbrev replace the last completion with the next guess. The search for completions takes place over a list of buffers specified by the `Dabbrev_Default_Buflist' variable unless `dabbrev' has been called with an argument. The optional argument may either be an integer whose value is interpreted as for `Dabbrev_Default_Buflist', or a string containing a newline separated list of buffer names to search. The scan proceeds as follows: foreach buffer in buflist from cursor backwards to the beginning of the buffer from cursor forwards to the end of the buffer EXAMPLE The current buffer contains the line foo is better than foobar, foobase or foo with the cursor at the end of the line. dabbrev completes foo with foobase. If called again (immediately) foobase is changed to foobar If called once again, foobase is changed to foo and a message is given: No more completions. NOTES You can use the optional argument to have keybindings to different "flavours" of dabbrev. setkey("dabbrev", "^A"); % expand from Dabbrev_Default_Buflist setkey("dabbrev(1)", "\ea"); % expand from visible buffers setkey("dabbrev(\"wordlist\")","\e^A"); % expand from the buffer "wordlist" SEE ALSO Dabbrev_Default_Buflist, Dabbrev_Look_in_Folds -------------------------------------------------------------- dired SYNOPSIS dired DESCRIPTION Mode designed for maintaining and editing a directory. To invoke Dired, do `M-x dired' or `C-x d' (emacs) Dired will prompt for a directory name and get a listing of files in the requested directory. The primary use of Dired is to "flag" files for deletion and then delete the previously flagged files. `d' Flag this file for deletion. `u' Remove deletion flag on this line. DEL Move point to previous line and remove deletion flag. `~' Flag all backup files for deletion. `x' eXpunge all flagged files. Dired will show a list of the files tagged for deletion and ask for confirmation before actually deleting the files. `r' Rename file on the current line; prompts for a newname `m' Move tagged files to a new dir; prompts for dir name `g' Update the entire contents of the Dired buffer `f' Visit the file described on the current line, like typing `M-x find_file' and supplying that file name. If current line is a directory, runs dired on the directory and the old buffer is killed. `v' View the file described on the current line in MOST mode. `q' Quit dired mode. `M-x dired_search' use fsearch to perform a search through the files listed in the dired buffer from the current point forward. `M-x dired_search' from the visited file will revert to the dired buffer and continue the search from the next file in the list. all the usual motion commands plus some extras: `C-n' `n' SPC move point to the next line (at the beginning of the file name) `C-p' `p' move point to the previous line (at the beginning of the file name) `M-x dired_kill_line' `^K' (emacs) removes a line from the dired buffer -------------------------------------------------------------- docbook_mode SYNOPSIS docbook_mode USAGE Void docbook_mode (); DESCRIPTION This mode is designed to facilitate the editing of Docbook 3.1 SGML files. If a region is defined (i.e., if a mark is set), many SGML tags will insert around the region; e.g. '' and ''. Tags are inserted either using the Mode menu, or with a key combination resembling the menu entry, e.g. ^Cce inserts (M&ode/&Character/<&emphasis>). Functions that affect this mode include (Emacs mode assumed - IDE mode uses ^Z instead of ^C): sgml_bskip_tag ^C^B sgml_skip_tag ^C^F sgml_para ^CP sgml_section ^CS sgml_sect ^CN insert $ ^C$ insert & ^C& insert … ^C. insert < ^C< insert > ^C> Variables affecting this mode include: Variable Default value SGML_INDENT 2 Sgml_Compile_PS_Cmd "db2ps" Sgml_Compile_Pdf_Cmd "db2pdf" Sgml_Compile_Html_Cmd "db2html" Sgml_View_PS_Cmd "gv" Sgml_View_Pdf_Cmd "gv" Sgml_View_Html_Cmd "netscape" To change the value of a variable, define that variable in .jedrc before loading docbook.sl. For example: variable SGML_INDENT = 3; Hooks: `sgml_mode_hook' -------------------------------------------------------------- edt_advance SYNOPSIS edt_advance DESCRIPTION ADVANCE - (4) Sets the current direction to forward for the CHAR, WORD, LINE, EOL, PAGE, SECT, SUBS, FIND, and FNDNXT keys. ADVANCE means that movement will be toward the end of the buffer; that is, to the right and down. -------------------------------------------------------------- edt_backup SYNOPSIS edt_backup DESCRIPTION BACKUP - (5) Sets the cursor direction to backward for the CHAR, WORD, LINE, EOL, PAGE, SECT, SUBS, FIND, and FNDNXT keys. BACKUP means that movement will be toward the beginning of the buffer% that is, to the left and up. -------------------------------------------------------------- edt_wdel SYNOPSIS edt_wdel DESCRIPTION DEL W - (-) Deletes text from the cursor to the beginning of the next word, storing the text in the delete word buffer. -------------------------------------------------------------- edt_uwdel SYNOPSIS edt_uwdel DESCRIPTION UND W - (GOLD -) Inserts the contents of the delete word buffer directly to the left of the cursor. -------------------------------------------------------------- edt_ldel SYNOPSIS edt_ldel DESCRIPTION DEL L - (PF4) Deletes text from the cursor position to the end of the current line, including the line terminator. If the cursor is positioned at the beginning of a line, the entire line is deleted. The deleted text is saved in the delete line buffer. -------------------------------------------------------------- edt_uldel SYNOPSIS edt_uldel DESCRIPTION UND L - (GOLD PF4) Inserts the contents of the delete line buffer directly to the left of the cursor. -------------------------------------------------------------- edt_find SYNOPSIS edt_find DESCRIPTION FIND - (GOLD PF3) Searches for an occurrence of a string. Press the FIND key and then enter the string using the main keyboard. End the string by pressing either the ADVANCE or BACKUP key to set the direction of the search, or the ENTER key to search in the current direction. -------------------------------------------------------------- edt_findnxt SYNOPSIS edt_findnxt DESCRIPTION FNDNXT - (PF3) Searches for the next occurrence of the search string previously entered with the FIND key. The direction of the search is the current one (ADVANCE or BACKUP). -------------------------------------------------------------- edt_sect SYNOPSIS edt_sect DESCRIPTION SECT - (8) Moves the cursor 16 lines (one section) forward or backward, depending on the current direction (see ADVANCE and BACKUP). The cursor is moved to the beginning of the appropriate line. -------------------------------------------------------------- edt_page SYNOPSIS edt_page DESCRIPTION PAGE - (7) Moves the cursor to the top of a page. A page is defined by a delimiter string, which can be set by the SET ENTITY command. The default page delimiter is the formfeed character (CTRL/L). -------------------------------------------------------------- edt_append SYNOPSIS edt_append DESCRIPTION APPEND - (9) Moves the select range to the end of the PASTE buffer. The select range is all the text between the selected position (see SELECT) and the current cursor position. If no SELECT has been made and the cursor is positioned on the current search string, that string is appended. -------------------------------------------------------------- edt_replace SYNOPSIS edt_replace DESCRIPTION REPLACE - (GOLD 9) Deletes the select range and replaces it with the contents of the PASTE buffer. -------------------------------------------------------------- f90_mode SYNOPSIS f90_mode DESCRIPTION Mode designed for the purpose of editing F90 files. After the mode is loaded, the hook 'f90_hook' is called. Useful functions include: Function: Default Binding: f90_continue_newline ESC RETURN indents current line, and creates a continuation line on next line. f90_comment ESC ; comments out current line f90_uncomment ESC : uncomments current line f90_electric_label 0-9 Generates a label for current line or simply inserts a digit. f90_next_statement ^C^N moves to next f90 statementm skips comment lines f90_previous_statement ^C^P moves to previous f90 statement, skips comment lines f90_ruler ^C^R inserts a ruler above the current line. Press any key to continue f90_beg_of_subprogram ESC ^A moves cursor to beginning of current subroutine/function f90_end_of_subprogram ESC ^E moves cursor to end of current subroutine/function f90_mark_subprogram ESC ^H mark the current subroutine/function Variables include: F90_Continue_Char --- character used as a continuation character. By default, its value is ">" F90_Comment_String --- string used by 'f90_comment' to comment out a line. The default string is "C "; F90_Indent_Amount --- number of spaces to indent statements in a block. The default is 2. F90_Default_Format --- Either "fixed" or "free". -------------------------------------------------------------- Fold_Bob_Eob_Error_Action SYNOPSIS Fold_Bob_Eob_Error_Action USAGE Integer Fold_Bob_Eob_Error_Action = 1; DESCRIPTION This value of this variable determines the what will happen upon reaching the boundary of the current fold via the up/down keys. If the value is 0, an error will be generated; if the value is 1, the fold will be exited; otherwise, the next/previous fold will be entered. -------------------------------------------------------------- fortran_mode SYNOPSIS fortran_mode DESCRIPTION Mode designed for the purpose of editing FORTRAN files. After the mode is loaded, the hook 'fortran_hook' is called. Useful functions include Function: Default Binding: fortran_continue_newline ESC RETURN indents current line, and creates a continuation line on next line. fortran_comment ESC ; comments out current line fortran_uncomment ESC : uncomments current line fortran_electric_label 0-9 Generates a label for current line or simply inserts a digit. fortran_next_statement ^C^N moves to next fortran statementm skips comment lines fortran_previous_statement ^C^P moves to previous fortran statement, skips comment lines fortran_ruler ^C^R inserts a ruler above the current line. Press any key to continue fortran_beg_of_subprogram ESC ^A moves cursor to beginning of current subroutine/function fortran_end_of_subprogram ESC ^E moves cursor to end of current subroutine/function fortran_mark_subprogram ESC ^H mark the current subroutine/function Variables include: Fortran_Continue_Char --- character used as a continuation character. By default, its value is "&" Fortran_Comment_String --- string used by 'fortran_comment' to comment out a line. The default string is "C "; Fortran_Indent_Amount --- number of spaces to indent statements in a block. The default is 2. -------------------------------------------------------------- Help_Describe_Bindings_Show_Synopsis SYNOPSIS Used to control the searching of synopsis strings USAGE variable Help_Describe_Bindings_Show_Synopsis = 0; DESCRIPTION If the value of this variable is non-zero, the `describe_bindings' function will search through the documentation for synopsis strings and display the resulting strings along with the key bindings. Since this can be a time consuming process for slow computers or slow filesystems, this feature is turned off by default. EXAMPLE variable Help_Describe_Bindings_Show_Synopsis = 1; -------------------------------------------------------------- expand_keystring SYNOPSIS expand_keystring USAGE String expand_keystring (String key) DESCRIPTION This function takes a key string that is suitable for use in a 'setkey' definition and expands it to a human readable form. For example, it expands ^X to the form "Ctrl-X", ^[ to "ESC", ^[[A to "UP", etc... SEE ALSO setkey -------------------------------------------------------------- History_File SYNOPSIS History_File USAGE String_Type History_File = "jed.his"; DESCRIPTION The variable `History_File' is used by the function `history_save' to know the file name in which to store all non-blank lines of the mini-buffer. Its default value is "~/.jed-history" under Unix and "~/jed.his" on other platforms. SEE ALSO history_load, history_save -------------------------------------------------------------- history_load SYNOPSIS history_load USAGE Void_Type history_load (); DESCRIPTION This function reads a history file, i.e. each line of the file is stored in the mini-buffer, but not evaluated. By default, historical records are kept in a file whose name is stored in the `History_file' variable. This file is written in the current working directory associated with jed, i.e. the directory from which you started the jed process. For example, to read your history file every time you start jed and give an alternative name to the history file, put: variable History_File; if (BATCH == 0) { () = evalfile ("history"); History_File = ".my-jed-history"; history_load (); } in your .jedrc (or jed.rc) file. The `History_File' variable can be assigned either a file name or an absolute path+filename. In the first case, a file will be saved in the current working directory (the one you were in when you started jed), so you will find a history file in every directory you work in. In the second one, only one file will be created, but you can handle 'local' history files easily (see `history_local_save' to know how to do it). SEE ALSO history_save, history_local_save, minued_mode SEE ALSO History_File -------------------------------------------------------------- history_save SYNOPSIS history_save USAGE Int_Type history_save () DESCRIPTION This function saves the contents of the mini-buffer (see `history_load' for more information) to the file specified by the variable `History_File' or to the local history file (see `history_local_save' for more information). It returns -1 upon failure, or 0 upon success. NOTES When history.sl is loaded, `history_save' will automatically get attached to the editors exit hooks. As a result, it is really not necessary to call this function directly. SEE ALSO history_load, history_local_save SEE ALSO History_File -------------------------------------------------------------- history_local_save SYNOPSIS history_local_save USAGE Void_Type history_local_save () DESCRIPTION This function saves the contents of the mini-buffer at some arbitrary file. If you give the same filename as in `History_File' but use a different path, then `history_load' will load this file into the mini-buffer every time you start jed from that (and only from that) directory. This behavior is only useful when the value of `History_File' is an absoulte filename and you want a local history when you start jed from some specific directory. SEE ALSO history_load, history_save SEE ALSO History_File -------------------------------------------------------------- html_skip_tag SYNOPSIS html_skip_tag DESCRIPTION skip forward past html tag -------------------------------------------------------------- html_bskip_tag SYNOPSIS html_bskip_tag DESCRIPTION skip backward past html tag -------------------------------------------------------------- html_mark_next_tag SYNOPSIS html_mark_next_tag DESCRIPTION mark the next html tag forward -------------------------------------------------------------- html_mark_prev_tag SYNOPSIS html_mark_prev_tag DESCRIPTION mark the previous html tag -------------------------------------------------------------- html_mode SYNOPSIS html_mode USAGE Void html_mode (); DESCRIPTION `html_mode' is a mode designed for editing HTML files. If a region is defined (i.e., if a mark is set), many HTML tags will insert around the region, e.g. '' and ''. Keybindings begin with ^C and are grouped according to function: ^CA... Anchors (...) ^CD... Definition lists (
...
) ^CF... Forms (
...
) ^CH... Headings, document type, etc. ^CI... Images ^CL... Lists (
    ...
) ^CP... Paragraph styles, etc. (

,
,


,
, etc.) ^CS... Character styles (, , , , etc.) ^CT... Tables Additionally, some special movement commands and miscellaneous characters are defined: ^C^B skip to beginning of prior HTML tag ^C^F skip to end of next HTML tag ^C^N mark next HTML tag from '<' to '>' ^C^P mark prior HTML tag from '<' to '>' ^C& insert HTML text for '&' ^C> insert HTML text for '>' ^C< insert HMTL text for '<' ^C insert HMTL text for '
' ^C insert HMTL text for NonBreakableSPace ^Ce insert HMTL text for 'Eurosymbol' ^CC insert HTML comment (around region, if marked) For a complete list of keybindings, use `describe_bindings'. This function calls `html_mode_hook' if it exists. -------------------------------------------------------------- Ispell_Program_Name SYNOPSIS spell-check program name USAGE variable Ispell_Program_Name = "" DESCRIPTION The spell check command used by the `ispell' function. It must be ispell-compatible (one of "ispell", "aspell" or "hunspell"). If unset, the ispell program will be auto-detected by searching the path for one of the above programs. SEE ALSO ispell, search_path_for_file -------------------------------------------------------------- latex_mode SYNOPSIS latex_mode USAGE Void latex_mode (); DESCRIPTION This mode is designed to facilitate the task of editing latex files. It calls the function `latex_mode_hook' if it is defined. In addition, if the abbreviation table `"TeX"' is defined, that table is used. The default key-bindings for this mode include: "tex_insert_braces" "^C{" "tex_font" "^C^F" "latex_environment" "^C^E" "latex_section" "^C^S" "latex_close_environment" "^C]" "latex_insert_item" "^C^J" "tex_comment_region" "^C;" "tex_uncomment_region" "^C:" "tex_comment_paragraph" "^C%" "tex_mark_environment" "^C." "tex_mark_section" "^C*" "latex_toggle_math_mode" "^C~" "tex_insert_macro" "^C^M" "tex_complete_symbol" "\e^I" "latex_help" "^Ci" "latex_indent_next_line" "^J" "latex_indent_region" "^C^Q^R" "latex_indent_section" "^C^Q^S" "latex_indent_environment" "^C^Q^E" -------------------------------------------------------------- lua_mode SYNOPSIS lua_mode USAGE lua_mode () DESCRIPTION A major mode for editing lua files. The following keys have lua specific bindings: DELETE deletes to previous indent level TAB indents line ^C# comments region or current line ^C> shifts line or region right ^C< shifts line or region left ^C^C executes the region, or the buffer if region not marked. ^C| executes the region ^C\t reindents the region Hooks: `lua_mode_hook' SEE ALSO Lua_Indent_Level SEE ALSO set_mode, c_mode -------------------------------------------------------------- mailutils_find_header_separator SYNOPSIS Searches for the header/body separator USAGE Int_Type mailutils_find_header_separator () DESCRIPTION This function searches for the line separating the mail headers from the body. It returns 1 if found, and 0 otherwise. SEE ALSO mailutils_narrow_to_header -------------------------------------------------------------- mailutils_narrow_to_header SYNOPSIS Narrow to the mail headers USAGE Int_Type mailutils_narrow_to_header () DESCRIPTION This function narrows the buffer to the mail headers. It returns 0 if sucessful (headers were found), or -1 upon failure. SEE ALSO mailutils_find_header_separator, mailutils_set_keyword_value, widen -------------------------------------------------------------- mailutils_get_keyword_value SYNOPSIS Obtain the value of a header keyword USAGE String_Type mailutils_get_keyword_value (kw) DESCRIPTION This function returns the value of a mail header specified by the `kw' parameter. If no such header exists, NULL will be returned. NOTES This function does not preserve the editing point. SEE ALSO mailutils_set_keyword_value -------------------------------------------------------------- mailutils_set_keyword_value SYNOPSIS Set the value of a mail header USAGE mailutils_set_keyword_value (String_Type kw, String_Type val) DESCRIPTION This function sets the value of the header keyword specified by the `kw' argument to that of the `val' argument. If no such header exists, one will be created. The editing point will be left at the end of the header's value. If the header exists and has a value, then that value will be replace. NOTES This function does not preserve the editing point. SEE ALSO mailutils_get_keyword_value, mailutils_find_header_separator -------------------------------------------------------------- man_clean_manpage SYNOPSIS man_clean_manpage DESCRIPTION remove _^H and ^H combinations and multiple blank lines (man page) -------------------------------------------------------------- unix_man SYNOPSIS unix_man DESCRIPTION retrieve a man page entry and use clean_manpage to clean it up -------------------------------------------------------------- matlab_mode SYNOPSIS matlab_mode DESCRIPTION Protoytype: Void matlab_mode (); This is a mode that is dedicated to facilitate the editing of Matlab/Octave language files. Functions that affect this mode include: function: default binding: matlab_indent RETURN Variables affecting indentation include: Hooks: `matlab_mode_hook' -------------------------------------------------------------- Minued_Lines SYNOPSIS Minued_Lines USAGE Integer_Type Minued_Lines = 0; DESCRIPTION This variable controls the number of lines shown in the minued buffer. If the value of `Minued_Lines' is -1, then the entire screen is used. If it is 0, the window splits vertically. A positive value selects the exact number of lines to show. This value shouldn't be greater than `SCREEN_HEIGHT'-4, and is only useful while you are working with one window. Default value is 0. SEE ALSO minued SEE ALSO SCREEN_HEIGHT -------------------------------------------------------------- minued_mode SYNOPSIS minued_mode USAGE Void minued_mode (); DESCRIPTION `minued_mode' is a mini-buffer's contents editor with which you can view all previously entered lines in it. Select and modify one of them. Press return and that line will be updated in the mini-buffer and evaluated in the buffer from which minued was called. All lines appears numbered, in the same order that they are stored in the mini-buffer. Use the last line of minued if you want to add a new one. Instead of a number, that line shows "add> ". The following key-bindings are defined in `minued_mode': Return Update and evaluate the current line. Meta-Return Evaluate the current line. Ctrl-U Update the current line, don't leave 'minued_mode'. Meta-R Remove the current line, don't leave 'minued_mode'. Ctrl-C Quit. Note: Minued cannot be invoked from the mini-buffer. SEE ALSO history_load, history_save SEE ALSO Minued_Lines -------------------------------------------------------------- make_tmp_buffer_name SYNOPSIS make_tmp_buffer_name USAGE String make_tmp_buffer_name (String base); DESCRIPTION Generates a unique buffer name using the string 'base' for the beginning of the name. The buffer name is returned. The buffer is not created. -------------------------------------------------------------- append_string_to_file SYNOPSIS append_string_to_file USAGE Integer append_string_to_file (String str, String file); DESCRIPTION The string 'str' is appended to file 'file'. This function returns -1 upon failure or the number of lines written upon success. See append_region_to_file for more information. -------------------------------------------------------------- write_string_to_file SYNOPSIS write_string_to_file USAGE Integer write_string_to_file (String str, String file); DESCRIPTION The string 'str' is written to file 'file'. This function returns -1 upon failure or the number of lines written upon success. This function does not modify a buffer visiting the file. -------------------------------------------------------------- Enable_Mode_Hook_Eval SYNOPSIS Control the use of "eval" from a file's mode statement DESCRIPTION When a file is read into a buffer, the editor will look for a line near the top of the file containing `-*- TEXT -*-', where `TEXT' usually specifies the mode to be applied to the buffer, e.g., /* -*- C -*- */ For this reason, such a line is referred to as the files mode statement. In addition, an arbitrary S-Lang expression may be executed by the mode statement through the use of `eval' and `evalfile', e.g., /* -*- mode: C; eval: set_buffer_no_backup; -*- */ This example would cause c-mode to be assigned to the buffer, and backups for the file turned-off. Obviously this poses a security risk, since it permits the evaluation of arbitrary S-Lang code. The `Enable_Mode_Hook_Eval' variable may be used to control how `eval', and other potentially risky constructs are handled by the file's mode statement. If its value is 0, such statements will not get executed. If the value of `Enable_Mode_Hook_Eval' is NULL, then the editor will query the user about whether to execute the statement, otherwise such statements will get executed. The default value is NULL, i.e., to query the user. SEE ALSO modeline_hook2, eval, evalfile, set_mode -------------------------------------------------------------- most_mode SYNOPSIS most_mode DESCRIPTION Emulates MOST fileviewer The following keys are defined: SPACE next screen DELETE previous screen / search_forward ? search_backward n find next occurrence q quit most mode (usually kills buffer if not modified) e edit buffer h help summary t Top of Buffer b End of Buffer -------------------------------------------------------------- Mouse_Selection_Word_Chars SYNOPSIS Characters that delimit double-click selections USAGE String_Type Mouse_Selection_Word_Chars DESCRIPTION The value of this variable represents a set of characters that serve to delimit double-click selections. The default value of this variable is Mouse_Selection_Word_Chars = "^ \n\"%&'()*,;<=>?@[]^`{|}"; If the value of this variable is NULL, the word characters associated with the buffer will be used. SEE ALSO define_word -------------------------------------------------------------- Mouse_Save_Point_Mode SYNOPSIS Mouse_Save_Point_Mode USAGE Integer Mouse_Save_Point_Mode = 1; DESCRIPTION If this variable is non-zero, the editing point will be restored to its original position when the left button is used to copy a region to the cutbuffer. If the variable is zero, the current point is left at the end of the copied region. -------------------------------------------------------------- nroff_mode SYNOPSIS nroff_mode DESCRIPTION Protoytype: Void nroff_mode (); A primitive mode for editing nroff/troff files. mostly to define the paragraph separator -------------------------------------------------------------- occur SYNOPSIS occur USAGE Void occur (); DESCRIPTION This function may be used to search for all occurances of a string in the current buffer. It creates a separate buffer called `*occur*' and associates a keymap called `Occur' with the new buffer. In this buffer, the `g' key may be used to go to the line described by the match. -------------------------------------------------------------- Perl_Continued_Offset SYNOPSIS Perl_Continued_Offset USAGE Integer Perl_Continued_Offset = 2; DESCRIPTION This variable controls the indentation of statements that are continued onto the next line as in the following example: print "hallo ", " world\n"; The default value (2) corresponds to the default for `perltidy' SEE ALSO C_CONTINUED_OFFSET, Perl_Indent -------------------------------------------------------------- perl_indent_line SYNOPSIS Void perl_indent_line (Void) DESCRIPTION indents the line SEE ALSO perl_indent_region, Perl_Indent, Perl_Continued_Offset, perl_mode -------------------------------------------------------------- perl_indent_region SYNOPSIS Void perl_indent_region (Void) DESCRIPTION indents each line in the region SEE ALSO perl_indent_line, perl_indent_buffer, perltidy, perl_mode -------------------------------------------------------------- perl_indent_buffer SYNOPSIS Void perl_indent_buffer (Void) DESCRIPTION indents the entire buffer (NB: using perltidy might be easier) SEE ALSO perl_indent_line, perl_indent_region, perltidy, perl_mode -------------------------------------------------------------- perl_beg_chunk SYNOPSIS Void perl_beg_chunk (Void) DESCRIPTION move to the beginning of a code chunk (starting with 'sub' in the first column) or to the beginning of a POD chunk. SEE ALSO perl_end_chunk, perl_mark_chunk, perl_mode -------------------------------------------------------------- perl_end_chunk SYNOPSIS Void perl_end_chunk (Void) DESCRIPTION move to the end of a code chunk or to the end of a POD chunk SEE ALSO perl_beg_chunk, perl_mark_chunk, perl_mode -------------------------------------------------------------- perl_mark_chunk SYNOPSIS Void perl_mark_chunk (Void) DESCRIPTION marks the code/Pod code SEE ALSO perl_beg_chunk, perl_end_chunk, perl_mode -------------------------------------------------------------- perl_mark_matching SYNOPSIS Void perl_mark_matching (Void) DESCRIPTION works mostly like find_matching_delimiter, except that it attempts to be extra smart if starting out on whitespace SEE ALSO find_matching_delimiter -------------------------------------------------------------- perl_paragraph_sep SYNOPSIS Void perl_paragraph_sep (Void) DESCRIPTION defines paragraphs for Perl mode SEE ALSO parse_to_point -------------------------------------------------------------- perl_format_paragraph SYNOPSIS Void perl_format_paragraph (Void) DESCRIPTION should format a comment paragraph in Perl mode, but not entirely stable? SEE ALSO perl_mode -------------------------------------------------------------- perl_mode SYNOPSIS Void perl_mode (Void) DESCRIPTION This is a mode that is dedicated to editing Perl language files including a bimodal Pod/Perl indentation mode. The indentation style matches the results of perltidy(1) with '-ci=2 -i=4 -en=8' fairly closely, except some of the closing brackets. This seems to be missing, so you might want to add add_mode_for_extension("perl", "pm"); Functions that affect this mode include: function: default binding: indent_line TAB perl_beg_chunk ESC Ctrl-A perl_end_chunk ESC Ctrl-E perl_mark_chunk ESC Ctrl-H perl_mark_matching ESC Ctrl-M perl_next_chuck ESC Ctrl-N perl_prev_chunk ESC Ctrl-P perl_indent_region ESC TAB perl_indent_region Ctrl-C TAB perl_format_paragraph ESC q perl_newline_and_indent Ctrl-M (not bound) perl_indent_buffer (not bound) perl_help Ctrl-C ? perl_check Ctrl-C c perl_indent_region Ctrl-TAB perl_exec Ctrl-C e perl_info Ctrl-C i perltidy Ctrl-C Ctrl-T Variables affecting this mode include: Perl_Continued_Offset Perl_Flags Perl_Indent Hooks: `perl_mode_hook' SEE ALSO perldoc -------------------------------------------------------------- Perl_Flags SYNOPSIS Perl_Flags USAGE String Perl_Flags = "-w"; DESCRIPTION Extra (or 'expert') command-line options (switches) for running Perl. eg, `'-I'' or `'-M''. You only need these if you know why you need these. Warnings are *always* enabled, regardless of what you try here. If your code doesn't run with `'-w'', re-write it so it does or you're an expert and know which sections of code should have warnings disabled anyhow. -------------------------------------------------------------- Perl_Indent SYNOPSIS Perl_Indent USAGE Integer Perl_Indent = 4; DESCRIPTION This value determines the number of columns the current line is indented past the previous line containing an opening `'{'' character. eg., if (test) { statement(); } else { statement(); } The default value (4) corresponds to the default for `perltidy' SEE ALSO C_INDENT, Perl_Continued_Offset -------------------------------------------------------------- perltidy SYNOPSIS Void perltidy (Void) DESCRIPTION Runs the `perltidy' program on a region, buffer or narrowed buffer. The `perltidy' program (available from `http://perltidy.sourceforge.net') must be installed for this to work! With a numerical prefix argument (eg Ctrl-U), prompts for extra flags for `perltidy'. The following style preferences settings in `~/.perltidyrc' seem to give good results: -et=8 # standard tabs -nola # no outdent labels -wba="." # break after string concatenation -se # errors to standard error output -sbt=2 # very tight square brackets SEE ALSO perl_indent_region, perl_indent_buffer, perl_mode -------------------------------------------------------------- perl_exec SYNOPSIS Void perl_exec (Void) DESCRIPTION This function runs `perl' on a region, buffer or narrowed buffer. With a numerical prefix argument (eg Ctrl-U), also prompts for extra Perl flags. Display output in *shell-output* buffer window. SEE ALSO perl_check, perl_mode -------------------------------------------------------------- perl_check SYNOPSIS Void perl_check (Void) DESCRIPTION This function runs a perl `-CT' check on a region, buffer or narrowed buffer. Display output in *shell-output* buffer window. SEE ALSO perl_exec, perltidy, perl_mode -------------------------------------------------------------- perl_info SYNOPSIS Void perl_info (Void) DESCRIPTION displays the perl settings `perl -V' in the help buffer -------------------------------------------------------------- perl_help SYNOPSIS Void perl_help (Void) DESCRIPTION extract an alphanumeric keyword (a function) and display help via perldoc for it -------------------------------------------------------------- perldoc SYNOPSIS Void perldoc (void) DESCRIPTION use perldoc to find information The '-f' option is inferred for lowercase strings not starting with 'perl' perldoc [options] PageName|ModuleName|ProgramName... perldoc [options] -f BuiltinFunction perldoc [options] -q FAQRegex Options: -u Display unformatted pod text -m Display module's file in its entirety -q Search the text of questions (not answers) in perlfaq[1-9] SEE ALSO perl_help, perl_mode -------------------------------------------------------------- php_mode SYNOPSIS php_mode USAGE Void php_mode (); DESCRIPTION This is a mode that is dedicated to faciliate the editing of PHP language files. It calls the function `php_mode_hook' if it is defined. It also manages to recognice whetever it is in a php block or in a html block, for those people that doesnt seperate function from form ;) Functions that affect this mode include: function: default binding: php_top_of_function ESC Ctrl-A php_end_of_function ESC Ctrl-E php_mark_function ESC Ctrl-H php_mark_matching ESC Ctrl-M php_indent_buffer Ctrl-C Ctrl-B php_insert_class Ctrl-C Ctrl-C php_insert_function Ctrl-C Ctrl-F php_insert_bra { php_insert_ket } php_insert_colon : php_format_paragraph ESC q indent_line TAB newline_and_indent RETURN goto_match Ctrl-\ php_insert_tab Ctrl-C Ctrl-I Variables affecting indentation include: PHP_INDENT PHP_BRACE PHP_BRA_NEWLINE PHP_KET_NEWLINE PHP_Colon_Offset PHP_CONTINUED_OFFSET PHP_Class_Offset PHP_Autoinsert_Comments PHP_Switch_Offset Hooks: `php_mode_hook' -------------------------------------------------------------- python_mode SYNOPSIS python_mode USAGE python_mode () DESCRIPTION A major mode for editing python files. The following keys have python specific bindings: DELETE deletes to previous indent level TAB indents line ^C# comments region or current line ^C> shifts line or region right ^C< shifts line or region left ^C^C executes the region, or the buffer if region not marked. ^C| executes the region ^C\t reindents the region : colon dedents appropriately Hooks: `python_mode_hook' SEE ALSO Py_Indent_Level SEE ALSO set_mode, c_mode -------------------------------------------------------------- shell_builtin SYNOPSIS shell_builtin DESCRIPTION rudimentary `builtin' shell commands: `cd [dir]' change the default directory `exit' exit the subshell `pwd' Print Working Directory functions to eliminate some jed/shell vs. real shell problems `clear' erase the *shell* buffer `e' simulate ^X^F keybinding `jed' simulate ^X^F keybinding returns one of the following on the stack Null_String - builtin dispatched, no prompt "pwd" - builtin dispatched, give prompt cmd - use shell to execute CMD -------------------------------------------------------------- Tab_Always_Inserts_Tab SYNOPSIS Configure the tab key DESCRIPTION If this variable is non-zero, then the tab key will insert tab characters into the buffer. It is possible to override this setting via a mode hook. SEE ALSO local_setkey -------------------------------------------------------------- Info_Directory SYNOPSIS Info_Directory DESCRIPTION A comma-separated list of info directories to search. -------------------------------------------------------------- Jed_Highlight_Cache_Path SYNOPSIS Search path for DFA syntax tables A comma-separated list of directories to search for cached DFA syntax highlighting tables. If a table is not found, it will be created on the fly and then cached in the directory specified by the `Jed_Highlight_Cache_Dir' variable. SEE ALSO Jed_Highlight_Cache_Dir, use_dfa_syntax -------------------------------------------------------------- Jed_Highlight_Cache_Dir SYNOPSIS Directory where newly created DFA syntax tables are placed If the caching of DFA syntax tables is enabled, the newly created tables will be saved in the directory specified by this variable. SEE ALSO Jed_Highlight_Cache_Path, use_dfa_syntax -------------------------------------------------------------- C_CONTINUED_OFFSET SYNOPSIS C_CONTINUED_OFFSET USAGE Integer C_CONTINUED_OFFSET = 2; DESCRIPTION This variable controls the indentation of statements that are continued onto the next line as in the following example: if (something) continued_statement (); else another_continued_statement (); SEE ALSO C_BRA_NEWLINE, C_BRACE, C_INDENT, C_Colon_Offset -------------------------------------------------------------- C_Colon_Offset SYNOPSIS C_Colon_Offset DESCRIPTION Integer C_Colon_Offset = 1; This variable may be changed to adjust the indentation of `case' statements in C-Mode. SEE ALSO c_mode SEE ALSO C_BRA_NEWLINE, C_BRACE, C_INDENT, C_Colon_Offset -------------------------------------------------------------- C_Preprocess_Indent SYNOPSIS C_Preprocess_Indent USAGE Integer C_Preprocess_Indent = 1; DESCRIPTION This variable controls the indentation of preprocessor directives in C-mode. SEE ALSO c_mode SEE ALSO C_BRA_NEWLINE, C_BRACE, C_INDENT, C_Colon_Offset -------------------------------------------------------------- C_Comment_Column SYNOPSIS C_Comment_Column DESCRIPTION Column to begin a C comment--- used by c_make_comment -------------------------------------------------------------- C_INDENT SYNOPSIS C_INDENT USAGE Integer C_INDENT = 3; DESCRIPTION This value determines the number of columns the current line is indented past the previous line containing an opening `'{'' character. SEE ALSO C_BRACE, C_BRA_NEWLINE. -------------------------------------------------------------- C_BRACE SYNOPSIS C_BRACE USAGE Integer C_BRACE = 2; DESCRIPTION This is a C-mode variable that specifies how much an opening brace should be indented compared its surrounding block. SEE ALSO C_INDENT, C_BRA_NEWLINE -------------------------------------------------------------- C_BRA_NEWLINE SYNOPSIS C_BRA_NEWLINE USAGE Integer C_BRA_NEWLINE = 1; DESCRIPTION This variable is used by the indentation routines for the C langauge. If it is non-zero, the `'{'' character will be placed on a line by itself when one presses the `'{'' character. For K&R indentation style, set this variable to zero. SEE ALSO C_INDENT, C_BRACE -------------------------------------------------------------- custom_variable SYNOPSIS custom_variable USAGE Integer_Type custom_variable (String_Type name, Any_Type value) DESCRIPTION This function is used to create a new public global variable called `name', initialized to `value', unless it exists. If the variable already exists but is not initialized, then it is initialized to `value'. This is quite useful for slang files with user configurable variables. These variables can be defined and initialized by users before evaluating the file, or can be defined and initialized to a default value in a file using this function. This function returns 2 if the variable `name' has been defined and initialized, or 1 if it has only been intialized. If the variable `name' has already been defined and initialized, this function does nothing and returns 0. If `name' is an invalid variable name, this function does nothing and returns -1. This function should be only used by slang programmers, not users. SEE ALSO custom_color -------------------------------------------------------------- str_replace_all SYNOPSIS str_replace_all USAGE String str_replace_all (str, old, new); DESCRIPTION Replace all occurances of `old' in `str' with `new' and return the result. SEE ALSO str_replace, replace_cmd -------------------------------------------------------------- vinsert SYNOPSIS vinsert USAGE Void vinsert (String, fmt,...); DESCRIPTION This function is like `insert' except that it takes a variable number of arguments and a format string. SEE ALSO insert, sprintf, insert_char -------------------------------------------------------------- dircat SYNOPSIS Merge a directory name and file name USAGE String_Type = dircat (String_Type a, String_Type b); DESCRIPTION The `dircat' function may be used to obtain the path name of a file with filename `b' in directory `a'. It performs this function in an operating system dependent manner. -------------------------------------------------------------- bol_skip_white SYNOPSIS bol_skip_white USAGE Void bol_skip_white (); DESCRIPTION This function combines the two functions `bol' and `skip_white' into a single operation. That is, it moves the point to the beginning of the line and then skips over whitespace to the first non-whitespace character. SEE ALSO bol, skip_white, skip_chars -------------------------------------------------------------- bskip_white SYNOPSIS bskip_white USAGE Void bskip_white (); DESCRIPTION This function skips backward over whitespace. Note: it does not cross lines. SEE ALSO skip_white, bskip_chars -------------------------------------------------------------- buffer_filename SYNOPSIS buffer_filename USAGE String_Type buffer_filename ([String_Type bufname]) DESCRIPTION When called with no arguments, this function returns the name of the file associated with the current buffer. If called with a string argument representing the name of a buffer, it will return the name of the file associated with that buffer. If no file is associated with the specified buffer, the empty string will be returned. SEE ALSO getbuf_info -------------------------------------------------------------- file_type SYNOPSIS file_type DESCRIPTION returns type of file. e.g., /usr/a.b/file.c --> c SEE ALSO path_extname -------------------------------------------------------------- search_path_for_file SYNOPSIS search_path_for_file USAGE String_Type search_path_for_file (path, file [,delim]) DESCRIPTION The `search_path_for_file' function searches the directories specified by the delimiter-separated set of directories `path' for the filename `file'. If the file exists, it returns the expanded filename, otherwise it returns NULL. The optional parameter may be used to specify the path delimiter. The default delimiter is system-dependent and is the same as that returned by the `path_get_delimiter' function. -------------------------------------------------------------- expand_jedlib_file SYNOPSIS expand_jedlib_file DESCRIPTION Search for FILE in jed lib search directories and return expanded pathname if found or the Null string otherwise. -------------------------------------------------------------- find_jedlib_file SYNOPSIS find_jedlib_file DESCRIPTION find a file from JED_LIBRARY, returns number of lines read or 0 if not found. -------------------------------------------------------------- parse_filename SYNOPSIS parse_filename USAGE (dir, file) = parse_filename(fn) DESCRIPTION breaks a filespec into dir filename--- this routine returns dir and filename such that a simple strcat will suffice to put them together again. For example, on unix, /a/b/c returns /a/b/ and c -------------------------------------------------------------- prepend_to_slang_load_path SYNOPSIS Prepend a directory to the load-path USAGE prepend_to_slang_load_path (String_Type dir) DESCRIPTION This function adds a directory to the beginning of the interpreter's load-path. SEE ALSO append_to_slang_load_path, set_slang_load_path -------------------------------------------------------------- append_to_slang_load_path SYNOPSIS Append a directory to the load-path USAGE append_to_slang_load_path (String_Type dir) DESCRIPTION This function adds a directory to the end of the interpreter's load-path. SEE ALSO prepend_to_slang_load_path, set_slang_load_path -------------------------------------------------------------- go_up SYNOPSIS go_up USAGE Void go_up (Integer n); DESCRIPTION Move up 'n' lines. SEE ALSO up, go_down -------------------------------------------------------------- up_1 SYNOPSIS up_1 USAGE Void up_1 (); DESCRIPTION Move up 1 line. If successful, returns 1 otherwise it returns 0. SEE ALSO up, go_down, go_up, go_up_1 -------------------------------------------------------------- go_up_1 SYNOPSIS go_up_1 USAGE Void go_up_1 (); DESCRIPTION Move up exactly 1 line if possible. SEE ALSO up, go_down -------------------------------------------------------------- go_down SYNOPSIS go_down USAGE Void go_down (Integer n); DESCRIPTION Move down 'n' lines. SEE ALSO go_up, down -------------------------------------------------------------- down_1 SYNOPSIS down_1 USAGE Int_Type down_1 (); DESCRIPTION Move down exactly one line. If sucessful, 1 is returned otherwise zero is returned. SEE ALSO go_up, down, go_down_1 -------------------------------------------------------------- go_down_1 SYNOPSIS go_down_1 USAGE Void go_down_1 (); DESCRIPTION Move down one lines. SEE ALSO go_up, down -------------------------------------------------------------- go_left SYNOPSIS go_left USAGE Void go_left (Integer n); DESCRIPTION Move backward 'n' characters. SEE ALSO left, go_right -------------------------------------------------------------- go_right SYNOPSIS go_right USAGE Void go_right (Integer n); DESCRIPTION Move forward 'n' characters. SEE ALSO right, go_left -------------------------------------------------------------- go_right_1 SYNOPSIS go_right_1 USAGE Void go_right_1 (); DESCRIPTION Move forward 1 characters. SEE ALSO right, go_left -------------------------------------------------------------- go_left_1 SYNOPSIS go_left_1 USAGE Void go_left_1 (); DESCRIPTION Move forward 1 characters. SEE ALSO left, go_left -------------------------------------------------------------- newline SYNOPSIS newline USAGE Void newline (Void); DESCRIPTION insert a newline in the buffer at point. SEE ALSO insert, insert_char -------------------------------------------------------------- insert_single_space SYNOPSIS insert_single_space DESCRIPTION insert a single space into the buffer. -------------------------------------------------------------- looking_at_char SYNOPSIS looking_at_char USAGE Integer looking_at_char (Integer ch); DESCRIPTION This function returns non-zero if the character at the current editing point is 'ch' otherwise it retuns zero. This function performs a case sensitive comparison. -------------------------------------------------------------- local_setkey SYNOPSIS local_setkey USAGE Void local_setkey (String fun, String key); DESCRIPTION This function is like 'setkey' but unlike 'setkey' which operates on the global keymap, 'local_setkey' operates on the current keymap which may or may not be the global one. SEE ALSO setkey, definekey, local_unsetkey -------------------------------------------------------------- local_unsetkey SYNOPSIS local_unsetkey USAGE Void local_unsetkey (String key); DESCRIPTION This function is like 'unsetkey' but unlike 'unsetkey' which unsets a key from the global keymap, 'local_unsetkey' operates on the current keymap which may or may not be the global one. SEE ALSO unsetkey, undefinekey, local_setkey -------------------------------------------------------------- call_function SYNOPSIS Call a function with arguments USAGE call_function (String_Type f, [optional args...]) -------------------------------------------------------------- runhooks SYNOPSIS runhooks USAGE Void runhooks (String_Type hook, [optional args...]); -------------------------------------------------------------- run_mode_hooks SYNOPSIS Run the user's mode hooks for the specified mode USAGE run_mode_hooks (mode_hook_name) DESCRIPTION This function should be called at the end of the mode setting function to allow the user to hook into the function. It takes a single parameter: the name of the mode hook. Prior to call the specified user-hook, this function calls `global_mode_hook'. SEE ALSO runhooks, global_mode_hook -------------------------------------------------------------- Jed_Tmp_Directory SYNOPSIS Directory used to hold temporary files USAGE Jed_Tmp_Directory = "/tmp"; DESCRIPTION This variable is used by the `make_tmp_file' function to create temporary filenames. SEE ALSO make_tmp_file, make_tmp_buffer_name, open_unique_filename -------------------------------------------------------------- pop_mark_0 SYNOPSIS pop_mark_0 USAGE Void pop_mark_0 (); DESCRIPTION Since `pop_mark' is used so often with an argument of `0', this function is simply equivalent to `pop_mark(0)'. SEE ALSO pop_mark, pop_mark_1 -------------------------------------------------------------- pop_mark_1 SYNOPSIS pop_mark_1 USAGE Void pop_mark_1 (); DESCRIPTION Since `pop_mark' is used so often with an argument of `1', this function is simply equivalent to `pop_mark(1)'. SEE ALSO pop_mark, pop_mark_0 -------------------------------------------------------------- goto_spot SYNOPSIS goto_spot USAGE Void goto_spot (); DESCRIPTION This function returns to the position of the last pushed spot. The spot is not popped. SEE ALSO push_spot, pop_spot, create_user_mark -------------------------------------------------------------- push_spot_bob SYNOPSIS push_spot_bob USAGE Void push_spot_bob (); DESCRIPTION The function sequence `push_spot (); bob ();' occurs so often that it makes sense to have a single function that performs this task. SEE ALSO push_spot, bob, pop_spot, push_spot_bol -------------------------------------------------------------- push_spot_bol SYNOPSIS push_spot_bol USAGE Void push_spot_bol (); DESCRIPTION The function sequence `push_spot (); bol ();' occurs so often that it makes sense to have a single function that performs this task. SEE ALSO push_spot, bol, pop_spot, push_spot_bob -------------------------------------------------------------- push_mark_eol SYNOPSIS push_mark_eol USAGE Void push_mark_eol (); DESCRIPTION The function sequence `push_mark (); eol ();' occurs so often that it makes sense to have a single function that performs this task. SEE ALSO push_mark, eol, pop_mark, push_mark_eob -------------------------------------------------------------- push_mark_eob SYNOPSIS push_mark_eob USAGE Void push_mark_eob (); DESCRIPTION The function sequence `push_mark (); eob ();' occurs so often that it makes sense to have a single function that performs this task. SEE ALSO push_mark, eob, pop_mark, push_mark_eob -------------------------------------------------------------- mark_buffer SYNOPSIS mark_buffer USAGE mark_buffer (); DESCRIPTION This function marks the whole buffer leaving the point at the end of the buffer. SEE ALSO push_mark, pop_mark, bob, eob -------------------------------------------------------------- bufsubstr_delete SYNOPSIS bufsubstr_delete USAGE String bufsubstr_delete () DESCRIPTION This functions returns the contents of a region defined my the mark and the current point. The region will be deleted. SEE ALSO bufsubstr -------------------------------------------------------------- del_eol SYNOPSIS del_eol USAGE Void del_eol (); DESCRIPTION This function deletes from the current position to the end of the line. SEE ALSO del, delete_line, del_through_eol -------------------------------------------------------------- del_through_eol SYNOPSIS del_through_eol USAGE del_through_eol (); DESCRIPTION This function deletes all text from the current point through the end of the line. SEE ALSO del, del_eol, del_region -------------------------------------------------------------- line_as_string SYNOPSIS line_as_string USAGE String line_as_string () DESCRIPTION This function returns the current line as a string. This does not include the newline character at the end of the line. The editing point is left at the end of the line. That is, this function does not preserve the point. SEE ALSO bufsubstr -------------------------------------------------------------- double_line SYNOPSIS Duplicate the current line DESCRIPTION This function inserts a line into the buffer at the position of the current line that is a copy of the current line. If the position of the editing point was originally one line N column C, then the editing point will be left on line (N+1) column C. SEE ALSO line_as_string -------------------------------------------------------------- bol_trim SYNOPSIS bol_trim USAGE Void bol_trim (); DESCRIPTION Move to beginning of line and remove whitespace. SEE ALSO bol, trim -------------------------------------------------------------- eol_trim SYNOPSIS eol_trim USAGE Void eol_trim (); DESCRIPTION Move to end of line and remove whitespace. SEE ALSO eol, trim -------------------------------------------------------------- get_blocal_var SYNOPSIS Return the value of a buffer-local variable USAGE value = get_blocal_var (String name, [default]) DESCRIPTION This function returns the value of the buffer-local variable specified by `name'. If the the optional `default' argument is given, it will be returned if no local variable of the specified name exists. Otherwise an error will be thrown. EXAMPLE if (get_blocal_var("foo", 0)) message("this buffer is fooish"); will print the message if `foo' is a buffer-local variable with a nonzero value. SEE ALSO define_blocal_var, blocal_var_exists -------------------------------------------------------------- define_blocal_var SYNOPSIS Create and initialize a buffer local variable USAGE define_blocal_var (name, value) DESCRIPTION This function may be used to create a buffer-local variable named `name' and set it to `value'. A buffer-local variable is a variable whose value is local to the current buffer. NOTES The order of the `name' and `value' arguments to this function are the reverse from that of the `set_blocal_var' function. SEE ALSO get_blocal_var, create_blocal_var, set_blocal_var -------------------------------------------------------------- whatpos SYNOPSIS whatpos DESCRIPTION display row and column information in minibuffer -------------------------------------------------------------- redo SYNOPSIS Undo the last undo USAGE redo() DESCRIPTION Undo the last undo. This works only one step, however as any undo is appended to the end of the undo buffer, you can actually roll the whole history back. SEE ALSO undo -------------------------------------------------------------- no_mode SYNOPSIS no_mode DESCRIPTION Generic mode not designed for anything in particular. Related Functions: `text_mode', `c_mode' -------------------------------------------------------------- Mode_Hook_Pointer SYNOPSIS Mode_Hook_Pointer DESCRIPTION called from mode_hook. Returns 0 if it is desired that control return to mode_hook or 1 if mode hook should exit after calling mode_hook_ptr -------------------------------------------------------------- modeline_hook SYNOPSIS modeline_hook DESCRIPTION check first line for the simplest Emacs mode statement -*- modename -*- -------------------------------------------------------------- add_mode_for_extension SYNOPSIS add_mode_for_extension USAGE Void add_mode_for_extension (String mode, String ext); DESCRIPTION This function modifies Mode_List in such a way that when a file with filename extension `ext' is read in, function strcat (mode, "_mode") will be called to set the mode. That is, the first parameter 'mode' is the name of a mode without the '_mode' added to the end of it. -------------------------------------------------------------- mode_hook SYNOPSIS mode_hook DESCRIPTION This is a hook called by find_file routines to set the mode for the buffer. This function takes one parameter, the filename extension and returns nothing. -------------------------------------------------------------- set_buffer_modified_flag SYNOPSIS set_buffer_modified_flag DESCRIPTION sets buf modified flag. If argument is 1, mark buffer as modified. If argument is 0, mark buffer as unchanged. -------------------------------------------------------------- buffer_modified SYNOPSIS buffer_modified USAGE Int_Type buffer_modified () DESCRIPTION returns non-zero if the buffer modified flag is set. It returns zero if the buffer modified flag is not been set. This works on the current buffer. See also 'set_buffer_modified_flag'. -------------------------------------------------------------- set_buffer_undo SYNOPSIS set_buffer_undo DESCRIPTION set undo mode for buffer. If argument is 1, undo is on. 0 turns it off -------------------------------------------------------------- set_readonly SYNOPSIS set_readonly DESCRIPTION Takes 1 parameter: 0 turn off readonly 1 turn on readonly -------------------------------------------------------------- is_readonly SYNOPSIS Test whether or not the buffer is in read-only mode USAGE Int_Type is_readonly () DESCRIPTION This function returns a non-zero value if the buffer is read-only; otherwise it returns 0. SEE ALSO set_readonly, getbuf_info, setbuf_info -------------------------------------------------------------- is_overwrite_mode SYNOPSIS Checks whether or not the buffer is in overwrite mode USAGE Int_Type is_overwrite_mode () DESCRIPTION This function returns a non-zero value if the buffer is in overwrite-mode; otherwise it returns 0. SEE ALSO toggle_overwrite, getbuf_info, setbuf_info -------------------------------------------------------------- set_overwrite SYNOPSIS set_overwrite USAGE set_overwrite (Int_Type x) DESCRIPTION If the parameter `x' is non-zero, the buffer will be put in overwrite mode; otherwise it will be ut in insert mode. SEE ALSO toggle_overwrite, is_overwrite_mode, getbuf_info, setbuf_info -------------------------------------------------------------- toggle_crmode SYNOPSIS Toggle the buffer line endings between CRLF and LF USAGE toggle_crmode () DESCRIPTION The `toggle_crmode' function causes the line endings of the buffer to alternate between CRLF and LF characters. SEE ALSO getbuf_info, setbuf_info -------------------------------------------------------------- toggle_readonly SYNOPSIS Toggle the readonly status of the buffer USAGE toggle_readonly () DESCRIPTION The `toggle_readonly' function toggles the read-only status of the current buffer. SEE ALSO set_readonly, is_readonly, getbuf_info, setbuf_info -------------------------------------------------------------- toggle_overwrite SYNOPSIS Toggle the overwrite mode of the buffer USAGE toggle_overwrite () DESCRIPTION The `toggle_overwrite' function toggles the overwrite mode of the current buffer. SEE ALSO set_overwrite, is_overwrite_mode, getbuf_info, setbuf_info -------------------------------------------------------------- toggle_undo SYNOPSIS Toggle the undo mode of the buffer USAGE toggle_undo () DESCRIPTION The `toggle_undo' function toggles the undo mode of the current buffer. SEE ALSO getbuf_info, setbuf_info -------------------------------------------------------------- set_buffer_no_backup SYNOPSIS set_buffer_no_backup USAGE Void set_buffer_no_backup (); DESCRIPTION -------------------------------------------------------------- set_buffer_no_autosave SYNOPSIS set_buffer_no_autosave USAGE Void set_buffer_no_autosave (); DESCRIPTION -------------------------------------------------------------- toggle_line_number_mode SYNOPSIS toggle_line_number_mode USAGE Void toggle_line_number_mode (); DESCRIPTION This function toggles the line number display state on or off. SEE ALSO set_line_number_mode -------------------------------------------------------------- custom_color SYNOPSIS Create a color object to be customized by the user USAGE custom_color (color, fg, bg) DESCRIPTION This function may be used to create a specified color object. If the object does not already exist, it will be given the specified foreground and background colors. SEE ALSO custom_variable -------------------------------------------------------------- help_for_help_string SYNOPSIS help_for_help_string DESCRIPTION string to display at bottom of screen upon JED startup and when user executes the help function. -------------------------------------------------------------- Help_File SYNOPSIS Help_File DESCRIPTION name of the file to load when the help function is called. -------------------------------------------------------------- help SYNOPSIS help USAGE Void help ([String_Type help_file]) DESCRIPTION This function pops up a window containing the specified help file. If the function was called with no arguments, the the file given by the `Help_File' variable will be used. -------------------------------------------------------------- read_file_from_mini SYNOPSIS read_file_from_mini USAGE String read_file_from_mini (String p); DESCRIPTION This function prompts the user for a file name using `p' as a prompt. It reads a filename with completion from the mini-buffer and returns it. SEE ALSO read_with_completion, read_mini -------------------------------------------------------------- read_string_with_completion SYNOPSIS read_string_with_completion USAGE String read_string_with_completion (prompt, dflt, list) DESCRIPTION This function takes 3 String parameters and returns a String. The first parameter is used as the prompt, the second parameter is the default value to be returned and the third parameter is a list to be used for completions. This list is simply a comma separated list of strings. -------------------------------------------------------------- Startup_With_File SYNOPSIS Startup_With_File DESCRIPTION If non-zero, startup by asking user for a filename if one was not specified on the command line. -------------------------------------------------------------- jed_startup_hook SYNOPSIS jed_startup_hook DESCRIPTION Function that gets executed right before JED enters its main editing loop. This is for last minute modifications of data structures that did not exist when startup files were loaded. -------------------------------------------------------------- save_buffer SYNOPSIS save_buffer USAGE Void save_buffer (); DESCRIPTION Save current buffer. -------------------------------------------------------------- push_visible_mark SYNOPSIS push_visible_mark USAGE Void push_visible_mark (); DESCRIPTION This function is performs the same task as `push_mark' except that the region between this mark and the cursor position will be highlighted. Such a mark is said to be a visible mark. SEE ALSO push_mark, pop_mark, set_mark_cmd -------------------------------------------------------------- set_mark_cmd SYNOPSIS set_mark_cmd USAGE Void set_mark_cmd (); DESCRIPTION If a mark is already set, and that mark is a visible mark, then this function will remove that mark. It will then push a visible mark onto the mark stack. SEE ALSO push_visible_mark, pop_mark, smart_set_mark_cmd -------------------------------------------------------------- smart_set_mark_cmd SYNOPSIS smart_set_mark_cmd USAGE Void smart_set_mark_cmd (); DESCRIPTION If the top mark is a visible mark, this function will remove that mark; otherwise it will push a visible mark onto the mark stack. Use of this function has the effect of toggling a highlighted region. SEE ALSO set_mark_cmd, push_mark, push_visible_mark -------------------------------------------------------------- buffer_format_in_columns SYNOPSIS buffer_format_in_columns DESCRIPTION Prototype Void buffer_format_in_columns(); takes a buffer consisting of a sigle column of items and converts the buffer to a multi-column format. -------------------------------------------------------------- rename_buffer SYNOPSIS Rename the current buffer USAGE rename_buffer (String_Type new_name) DESCRIPTION This function may be used to change the name of the current buffer to the one specified by the `new_name' parameter. SEE ALSO setbuf_info, whatbuf -------------------------------------------------------------- deln SYNOPSIS deln USAGE Void deln (Integer n); DESCRIPTION delete the next 'n' characters. -------------------------------------------------------------- enable_dfa_syntax_for_mode SYNOPSIS Use DFA syntax highlighting for one or more modes USAGE enable_dfa_syntax_for_mode (String_Type mode, ...) DESCRIPTION This function may be used to enable the use of DFA syntax highlighting for one or more specified modes. Each of the String_Type arguments must be the name of a mode. The name of a buffer's mode is usually displayed on the status line. EXAMPLE To enable DFA syntax highlighting for perl and postscript modes, use enable_dfa_syntax_for_mode ("perl", "PostScript"); SEE ALSO disable_dfa_syntax_for_mode, use_dfa_syntax -------------------------------------------------------------- disable_dfa_syntax_for_mode SYNOPSIS Use DFA syntax highlighting for one or more modes USAGE disable_dfa_syntax_for_mode (String_Type mode, ...) DESCRIPTION This function may be used to disable the use of DFA syntax highlighting for one or more specified modes. Each of the String_Type arguments must be the name of a mode. The name of a buffer's mode is usually displayed on the status line. EXAMPLE To disable DFA syntax highlighting for C and S-Lang modes, use disable_dfa_syntax_for_mode ("C", "SLang"); SEE ALSO enable_dfa_syntax_for_mode, use_dfa_syntax -------------------------------------------------------------- Jed_Home_Directory SYNOPSIS User's jed home directory DESCRIPTION The value of this variable specifies the user's so-called home directory where personal jed-related files are assumed to be found. Normally, this corresponds to the user's home directory unless the user has specified an alternate directory via the `JED_HOME' environment variable. -------------------------------------------------------------- toggle_case_search SYNOPSIS Toggle the CASE_SEARCH variable USAGE Void toggle_case_search () SEE ALSO CASE_SEARCH -------------------------------------------------------------- open_filter_process SYNOPSIS Open a subprocess as a filter USAGE Int_Type pid = open_filter_process (String_Type argv[], String_Type output) DESCRIPTION The `open_filter_process' function may be used to open an interactive synchronous process. The first argument should be an array of strings representing the program to be run in the subprocess, and the command line parameters passed to it. The second argument specifies what to do with the output generated by the process. It can be any value supported by the "output" option of the `set_process' function. The process should be closed using the `close_filter_process' function. SEE ALSO close_filter_process, send_process, call_process_region -------------------------------------------------------------- close_filter_process SYNOPSIS Close a filter process and return its status USAGE Int_Type close_filter_process (Int_Type pid) DESCRIPTION The `close_filter_process' function waits for the specified process to terminate and returns the exit status of the process. The process must have been previously opened via the `open_filter_process' function. SEE ALSO open_filter_process, send_process, get_process_input -------------------------------------------------------------- add_keywords SYNOPSIS add_keywords USAGE String add_keywords (String tbl, String kws, Int len, Int n); DESCRIPTION Adds a set of keywords `kws', each of length `len', to the already existing syntax table `tbl'. For convenience of the user, the function does alphabetical sorting and removes duplicate entries. The previous list of keywords is returned. SEE ALSO define_keywords_n, create_syntax_table, add_keyword_n -------------------------------------------------------------- add_keyword_n SYNOPSIS add_keyword_n USAGE Void add_keyword_n (String tbl, String kw, Int n); DESCRIPTION Adds a single keyword `kw' to the already existing syntax table `tbl'. SEE ALSO define_keywords_n, create_syntax_table, add_keywords -------------------------------------------------------------- add_keyword SYNOPSIS add_keyword USAGE Void add_keyword (String_Type tbl, String_Type kw); DESCRIPTION Adds a single keyword `kw' to the already existing syntax table `tbl'. SEE ALSO define_keywords_n, create_syntax_table, add_keyword_n -------------------------------------------------------------- remove_keywords SYNOPSIS remove_keywords USAGE String remove_keywords (String tbl, String kws, Int len, Int n); DESCRIPTION Removes a set of keywords `kws', each of length `len', from the already existing syntax table `tbl'. The previous list of keywords is returned. SEE ALSO add_keywords, define_keywords_n, create_syntax_table, add_keyword_n -------------------------------------------------------------- tcl_mode SYNOPSIS tcl_mode DESCRIPTION Protoytype: Void tcl_mode (); This is a mode that is dedicated to facilitate the editing of Tcl language files. See the source (tclmode.sl) for more info. Functions that affect this mode include: function: default binding: tcl_insert_bra { tcl_insert_ket } tcl_insert_comment # newline_and_indent RETURN indent_line TAB tcl_indent_region Ctrl-C Ctrl-Q Variables affecting indentation include: C_INDENT C_CONTINUED_OFFSET Hooks: `tcl_mode_hook' -------------------------------------------------------------- tex_mode SYNOPSIS tex_mode DESCRIPTION Mode useful for editing TeX and LaTeX modes. Useful bindings: '"' : tex_insert_quote '\'' : tex_insert_quote '$' : tex_blink_dollar '.' : tex_ldots. Inserts a '.' except if preceeded by two dots. In this case, the dots are converted to \ldots. When tex mode is loaded, 'tex_mode_hook' is called. This hook will allow users to customize the mode. In particular, certain functions here have no keybindings, e.g., 'latex_do_environment'. So, in your jed.rc file, add something like: define tex_mode_hook () { local_setkey ("latex_do_environment", "^C^E"); } which binds the function to Ctrl-C Ctrl-E. -------------------------------------------------------------- text_indent_relative SYNOPSIS Indent to next indentation point DESCRIPTION The `text_indent_relative' function inserts enough whitespace to move the editing point to the next indentation level defined by the whitespace pattern of the previous non-blank line. If the current point is beyond the last indentation level of the reference line, then a literal TAB will be inserted into the buffer. SEE ALSO set_buffer_hook, newline_and_indent -------------------------------------------------------------- text_mode SYNOPSIS text_mode DESCRIPTION Mode for indenting and wrapping text Functions that affect this mode include: Function: Default Binding: text_indent_relative TAB newline_and_indent RETURN format_paragraph ESC Q narrow_paragraph ESC N SEE ALSO no_mode, c_mode, set_buffer_hook SEE ALSO WRAP_INDENTS, WRAP, TAB, TAB_DEFAULT -------------------------------------------------------------- make_tmp_file SYNOPSIS make_tmp_file USAGE String make_tmp_file (String base); DESCRIPTION This function returns a unique file name that begins with `base'. If `base' does not specify an absolute path, the value of `Jed_Tmp_Directory' will be used for the directory. -------------------------------------------------------------- open_unique_filename SYNOPSIS Generate and unique filename and open the file USAGE structure = open_unique_filename (base, extname) DESCRIPTION This function generates a unique filename of the form `baseXXXXXX.extname' and returns a structure with fields filename : The name of the file fd : The FD_Type file descriptor fp : The FP_Type file pointer If `base' represents an absolute path, then the file will be opened in the correspondind directory. Otherwise the value of the `Jed_Tmp_Directory' variable will be used. If this function fails, an exception will be thrown. NOTES The value of the `fp' structure field is generated from the value of the `fd' field using the `fdopen' function. See the documentation of the `fdopen' function for the relationship of these two types and their semantics. SEE ALSO fdopen -------------------------------------------------------------- untab SYNOPSIS untab USAGE Void untab (); DESCRIPTION This function may be used either to convert tabs to spaces or, if called with a prefix argument, it will perform the opposite conversion from spaces to tabs. This function operates on a region. -------------------------------------------------------------- vhdl_mode SYNOPSIS vhdl_mode DESCRIPTION Mode designed for the purpose of editing VHDL files. After the mode is loaded, the hook 'vhdl_hook' is called. Useful functions include Function: Default Binding: vhdl_beg_of_subprogram ESC ^A moves cursor to beginning of current function/process vhdl_end_of_subprogram ESC ^E moves cursor to end of current function/process vhdl_mark_subprogram ESC ^H mark the current function/process Variables include: VHDL_Comment_String : string used by 'vhdl_comment' to comment out a line. Default is "--". VHDL_Indent_Amount : number of spaces to indent statements in a block. The default is 2. -------------------------------------------------------------- jed-0.99-19/doc/hlp/jedfuns.hlp0000644002657400265740000060711211311317447015174 0ustar davisdavisabbrev_table_p SYNOPSIS Test whether an abbreviation table "name" exists USAGE Integer abbrev_table_p (String name) DESCRIPTION Returns non-zero if an abbreviation table with called `name' exists. If the table does not exist, it returns zero. -------------------------------------------------------------- create_abbrev_table SYNOPSIS Create an abbreviation table "name" USAGE Void create_abbrev_table (String name, String word) DESCRIPTION Create an abbreviation table with name `name'. The second parameter `word' is the list of characters used to represent a word for the table. If the empty string is passed for `word', the characters that currently constitute a word are used. -------------------------------------------------------------- define_abbrev SYNOPSIS Define an abbreviation USAGE Void define_abbrev (String tbl, String abbrv, String expans) DESCRIPTION This function is used to define an abbreviation `abbrv' that will be expanded to `expans'. The definition will be placed in the table with name `tbl'. -------------------------------------------------------------- delete_abbrev_table SYNOPSIS Delete the abbrev table "name" USAGE Void delete_abbrev_table (String name) DESCRIPTION Delete the abbrev table specified by `name'. -------------------------------------------------------------- dump_abbrev_table SYNOPSIS Insert the abbreviation table "name" USAGE Void dump_abbrev_table (String name) DESCRIPTION This function inserts the contents of the abbreviation table called `name' into the current buffer. -------------------------------------------------------------- list_abbrev_tables SYNOPSIS Return the names of all defined abbreviation tables USAGE Integer list_abbrev_tables () DESCRIPTION This function returns the names of all currently defined abbreviation tables. The top item on the stack will be the number of tables followed by the names of the tables. -------------------------------------------------------------- use_abbrev_table SYNOPSIS Use the abbreviation table "table" for the current buffer USAGE Void use_abbrev_table (String table) DESCRIPTION Use the abbreviation table named `table' as the abbreviation table for the current buffer. By default, the "Global" table is used. -------------------------------------------------------------- what_abbrev_table SYNOPSIS Return info about the current abbreviation table USAGE (String, String) what_abbrev_table () DESCRIPTION This functions returns both the name of the abbreviation table and the definition of the word for the table currently associated with the current buffer. If none is defined it returns two empty strings. -------------------------------------------------------------- blocal_var_exists SYNOPSIS Determine whether a buffer-local variable exists USAGE Int_Type blocal_var_exists (String_Type name) DESCRIPTION The `blocal_var_exists' function returns non-zero if the specified buffer-local variable exists. It returns zero of the variable does not exists. SEE ALSO get_blocal_var, create_blocal_var, set_blocal_var, define_blocal_var -------------------------------------------------------------- create_blocal_var SYNOPSIS Create a buffer local variable "name" USAGE Void create_blocal_var (String name) DESCRIPTION This function is used to create a buffer local variable named `name'. A buffer local variable is a variable whose value is local to the current buffer. SEE ALSO get_blocal_var, set_blocal_var, define_blocal_var -------------------------------------------------------------- set_blocal_var SYNOPSIS Set the buffer local variable "v" to value "val" USAGE Void set_blocal_var (val, String v) DESCRIPTION This function sets the value of the buffer local variable with name `v' to value `val'. The buffer local variable specified by `v' must have been previously created by the `create_blocal_var' function. `val' must have the type that was declared when `create_blocal_var' was called. SEE ALSO get_blocal_var, create_blocal_var -------------------------------------------------------------- ADD_NEWLINE SYNOPSIS Add a newline to a buffer when saving USAGE Int_Type ADD_NEWLINE DESCRIPTION If the value of `ADD_NEWLINE' is non-zero and the buffer if the buffer does not end with a newline character, a newline character will be silently added to the end of a buffer when the buffer is written out to a file. -------------------------------------------------------------- MAX_HITS SYNOPSIS Set the Autosave Interval USAGE Int_Type MAX_HITS DESCRIPTION The value of the `MAX_HITS' variable specifies how many ``hits'' a buffer can take before it is autosaved. A hit is defined as a single key sequence that could modify the buffer. SEE ALSO -------------------------------------------------------------- autosave SYNOPSIS Save the current buffer to an autosave file USAGE Void autosave () DESCRIPTION The `autosave' function saves the current buffer in an auto save file if the buffer has been marked for the auto save operation. SEE ALSO setbuf_info, autosaveall SEE ALSO MAX_HITS -------------------------------------------------------------- autosaveall SYNOPSIS Save all buffers to autosave files USAGE Void autosaveall () DESCRIPTION This function is like `autosave' except that it causes all files marked for the auto save operation to be auto-saved. SEE ALSO autosave, setbuf_info SEE ALSO MAX_HITS -------------------------------------------------------------- buffer_list SYNOPSIS Return the names of buffers USAGE Integer buffer_list () DESCRIPTION This function returns an integer indicating the number of buffers and leaves the names of the buffers on the stack. For example, the following function displays the names of all buffers attached to files: define show_buffers () { variable b, str = "", file; loop (buffer_list ()) { b = (); (file,,,) = getbuf_info (b); if (strlen (file)) str = strcat (str, strcat (" ", b)); } message (str); } SEE ALSO getbuf_info, whatbuf -------------------------------------------------------------- buffer_visible SYNOPSIS Return the number of windows containing a specified buffer USAGE Integer buffer_visible (String buf) DESCRIPTION This function is used to determine whether or not a buffer with name specified by the string `buf' is in a window or not. More explicitly, it returns the number of windows containing `buf'. This means that if `buf' does not occupy a window, it returns zero. For Example, define find_buffer_in_window (buf) { !if (buffer_visible (buf)) return 0; pop2buf (buf); return 1; } is a function that moves to the window containing `buf' if `buf' is in a window. SEE ALSO bufferp, nwindows -------------------------------------------------------------- bufferp SYNOPSIS Test if a buffer exists or not USAGE Integer bufferp (String buf) DESCRIPTION This function is used to see if a buffer exists or not. If a buffer with name `buf' exists, it returns a non-zero value. If it does not exist, it returns zero. SEE ALSO setbuf, getbuf_info -------------------------------------------------------------- bury_buffer SYNOPSIS Make it unlikely for a specified buffer to appear in a window USAGE Void bury_buffer (String name) DESCRIPTION The `bury_buffer' function may be used to make it unlikely for the buffer specified by the paramter `name' to appear in a window. SEE ALSO sw2buf, getbuf_info -------------------------------------------------------------- check_buffers SYNOPSIS Check if any buffers have been changed on disk USAGE check_buffers () DESCRIPTION The `check_buffers' function checks to see whether or not any of the disk files that are associated with the editor's buffers have been modified since the assocation was made. The buffer flags are updated accordingly. SEE ALSO file_time_compare, file_changed_on_disk -------------------------------------------------------------- delbuf SYNOPSIS Delete a named buffer USAGE Void delbuf (String buf) DESCRIPTION `delbuf' may be used to delete a buffer with the name specified by `buf'. If the buffer does not exist, a S-Lang error will be generated. SEE ALSO whatbuf, bufferp, sw2buf -------------------------------------------------------------- getbuf_info SYNOPSIS Get basic information about a buffer USAGE (file, dir, name, flags) = getbuf_info ([ buf ]) String_Type buf; % optional argument -- name of buffer Int_Type flags; % buffer flags String_Type name; % name of buffer String_Type dir; % directory associated with buffer String_Type file; % name of file associated with buffer (if any). DESCRIPTION This function may be used to get some basic information about a specified buffer. If the optional argument `buf' is not present, the current buffer will be used, otherwise `buf' must be the name of an existing buffer. The integer that corresponds to the buffer flags are encoded as: bit 0: (0x001) buffer modified bit 1: (0x002) auto save mode bit 2: (0x004) file on disk modified bit 3: (0x008) read only bit bit 4: (0x010) overwrite mode bit 5: (0x020) undo enabled bit 6: (0x040) buffer buried bit 7: (0x080) Force save upon exit. bit 8: (0x100) Do not backup bit 9: (0x200) File associated with buffer is a binary file bit 10: (0x400) Add CR to end of lines when writing buffer to disk. bit 11: (0x800) Abbrev mode For example, (file,,,flags) = getbuf_info(); returns the file and the flags associated with the current buffer. SEE ALSO setbuf_info, whatbuf -------------------------------------------------------------- pop2buf SYNOPSIS Open a specified buffer in a second window USAGE Void pop2buf (String buf) DESCRIPTION The `pop2buf' function will switch to another window and display the buffer specified by `buf' in it. If `buf' does not exist, it will be created. If `buf' already exists in a window, the window containing `buf' will become the active one. This function will create a new window if necessary. All that is guaranteed is that the current window will continue to display the same buffer before and after the call to `pop2buf'. SEE ALSO whatbuf, pop2buf_whatbuf, setbuf, sw2buf, nwindows -------------------------------------------------------------- pop2buf_whatbuf SYNOPSIS pop2buf and return the old buffers name USAGE String pop2buf_whatbuf (String buf) DESCRIPTION This function performs the same function as `pop2buf' except that the name of the buffer that `buf' replaced in the window is returned. This allows one to restore the buffer in window to what it was before the call to `pop2buf_whatbuf'. SEE ALSO pop2buf, whatbuf -------------------------------------------------------------- set_buffer_umask SYNOPSIS Set the process file creation mask for the current buffer USAGE Integer set_buffer_umask (Integer cmask) DESCRIPTION The function may be used to set the process file creation mask for the appropriate operations associated with the current buffer. This makes it possible to have a buffer-dependent umask setting. The function takes the desired umask setting and returns the previous setting. If `cmask' is zero, the default process umask setting will be used for operations while the buffer is current. If `cmask' is -1, the umask associated with the buffer will not be changed. -------------------------------------------------------------- set_mode SYNOPSIS Set mode flags and name USAGE Void set_mode(String mode, Integer flags) DESCRIPTION This function sets buffer mode flags and status line mode name. `mode' is a string which is displayed on the status line if the `%m' status line format specifier is used. The second argument, `flags' is an integer with the possible values: 0 : no mode. Very generic 1 : Wrap mode. Lines are automatically wrapped at wrap column. 2 : C mode. 4 : Language mode. Mode does not wrap but is useful for computer languages. 8 : S-Lang mode 16: Fortran mode highlighting 32: TeX mode highlighting SEE ALSO whatmode, getbuf_info, setbuf_info. -------------------------------------------------------------- setbuf SYNOPSIS Temporary change the default buffer to another USAGE Void setbuf(String buf) DESCRIPTION Changes the default buffer to one named `buf'. If the buffer does not exist, it will be created. Note: This change only lasts until top level of editor loop is reached at which point the the buffer associated with current window will be made the default. That is this change should only be considered as temporary. To make a long lasting change, use the function `sw2buf'. SEE ALSO sw2buf, pop2buf, whatbuf, pop2buf_whatbuf -------------------------------------------------------------- setbuf_info SYNOPSIS Change attributes for a buffer USAGE setbuf_info([ buf, ] file, dir, name, flags) String_Type buf; % optional argument -- name of buffer Int_Type flags; % buffer flags String_Type name; % name of buffer String_Type dir; % directory associated with buffer String_Type file; % name of file associated with buffer (if any). DESCRIPTION This function may be used to change attributes regarding the buffer `buf'. If the optional argument `buf' is not present, the current buffer will be used. `setbuf_info' performs the opposite function of the related function `getbuf_info'. Here `file' is the name of the file to be associated with the buffer; `dir' is the directory to be associated with the buffer; `buf' is the name to be assigned to the buffer, and `flags' describe the buffer attributes. See `getbuf_info' for a discussion of `flags'. Note that the actual file associated with the buffer is located in directory `dir' with the name `file'. For example, the function define set_overwrite_mode () { variable dir, file, flags, name; (file, dir, name, flags) = getbuf_info (); flags = flags | (1 shl 4); setbuf_info (file, dir, name, flags); } may be used to turn on overwrite mode for the current buffer. Advanced S-Lang programmers exploit the fact that S-Lang is a stack based language and simply write the above function as: define set_overwrite_mode () { setbuf_info (getbuf_info () | 0x10); } Here, `(1 shl 4)' has been written as the hexidecimal number `0x10'. SEE ALSO getbuf_info, setbuf, whatbuf -------------------------------------------------------------- sw2buf SYNOPSIS Switch to a buffer (more permanent than setbuf) USAGE Void sw2buf (String buf) DESCRIPTION This function is used to switch to another buffer whose name is specified by the parameter `buf'. If the buffer specified by `buf' does not exist, one will be created. Note: Unlike `setbuf', the change to the new buffer is more permanent in the sense that when control passed back out of S-Lang to the main editor loop, if the current buffer at that time is the buffer specified here, this buffer will be attached to the window. SEE ALSO setbuf, pop2buf, bufferp -------------------------------------------------------------- what_mode SYNOPSIS Get mode flags and name of the current buffer USAGE (String name, Integer flags) = Integer what_mode () DESCRIPTION This function may be used to obtain the mode flags and mode name of the current buffer. See `set_mode' for more details. SEE ALSO set_mode, getbuf_info, setbuf_info -------------------------------------------------------------- whatbuf SYNOPSIS Return the name of the current buffer USAGE String what_buffer() DESCRIPTION `whatbuf' returns the name of the current buffer. It is usually used in functions when one wants to work with more than one buffer. The function `setbuf_info' may be used to change the name of the buffer. SEE ALSO getbuf_info, bufferp -------------------------------------------------------------- write_buffer SYNOPSIS Write the current buffer to a file USAGE Integer write_buffer (String filename) DESCRIPTION This function may be used to write the current buffer out to a file specified by `filename'. The buffer will then become associated with that file. The number of lines written to the file is returned. An error condition will be signaled upon error. SEE ALSO write_region_to_file, setbuf_info -------------------------------------------------------------- add_color_object SYNOPSIS Return the object number associated with "obj" USAGE add_color_object (String_Type name) DESCRIPTION This function creates a new color object with a specified name. See the `set_color' documentation for pre-defined color objects. SEE ALSO set_color, get_color, color_number -------------------------------------------------------------- color_number SYNOPSIS Return the object number associated with "obj" USAGE Integer color_number (String obj) DESCRIPTION This function returns the object number associated with the string `obj'. Valid names for `obj' are as per `set_color'. SEE ALSO set_color, set_column_colors SEE ALSO WANT_SYNTAX_HIGHLIGHT, USE_ANSI_COLORS -------------------------------------------------------------- get_color SYNOPSIS Return the foreground and background color of an object USAGE (String_Type fg, String_Type bg) = get_color (String_Type name) DESCRIPTION This function returns the foreground and background colors of the specified color object. SEE ALSO set_color, color_number, add_color_object -------------------------------------------------------------- set_color SYNOPSIS Set fore- and background colors of an object USAGE set_color (String_Type obj, String_Type fg, String_Type bg) DESCRIPTION This function sets the foreground and background colors of an object specified by the string `obj' to `fg' and `bg'. The exact values of the strings `fg' and `bg' are system dependent. For the X-Window system, they can be any string that the server understands, e.g., `"SteelBlue"'. For other systems, the color must be one of the following: "black" "gray" "red" "brightred" "green" "brightgreen" "brown" "yellow" "blue" "brightblue" "magenta" "brightmagenta" "cyan" "brightcyan" "lightgray" "white" "default" One most terminals, the values in the second column have no affect when used as the background color. Using "default" as a foreground or background color instructs the editor to tell the terminal to use the default foreground and background colors of the window. If you use a terminal that uses a transparant background, then you need to specify "default" as the background color. Not all terminals support the notion of the "default" color. The valid names for `obj' are: "normal" Default foreground/background "status" The status window line "region" Highlighted Regions "cursor" Text Cursor (X-Windows) "cursorovr" Text Cursor in overwrite mode (X-Windows) "menu" The menu bar "error" Error messages "message" Other messages "dollar" Color of the indicator that text extends beyond the boundary of the window. "linenum" Line number field If color syntax highlighting is enabled, the following object names are also meaningful: "number" Numbers in C-mode and Equations in TeX-mode "delimiter" Commas, semi-colons, etc... "keyword" Language dependent "keyword1" Language dependent "keyword2" Language dependent "keyword3" Language dependent "keyword4" Language dependent "keyword5" Language dependent "keyword6" Language dependent "keyword7" Language dependent "keyword8" Language dependent "keyword9" Language dependent "string" Literal strings "comment" Comments "operator" Such as +, -, etc... "preprocess" Preprocessor lines "tab" "trailing_whitespace" "html" and '<' syntax objects. If line attributes are available, then you may also specifiy the color of the hidden line indicator: "..." Hidden line indicator The color of the menu objects may be specified via "menu_char" Menu item key-shortcut color "menu_shadow" Color of the shadow "menu_selection" Selected menu-item color "menu_popup" Color of the popup box "menu_selection_char" Selected menu item key-shortcut color Xjed defines the following objects: "mouse" Mouse cursor color "border" Window borde color SEE ALSO define_syntax, set_color_esc, set_column_colors, set_color_object SEE ALSO WANT_SYNTAX_HIGHLIGHT, USE_ANSI_COLORS -------------------------------------------------------------- set_color_esc SYNOPSIS associate an escape sequence with an object USAGE Void set_color_esc (String object, String esc_seq) DESCRIPTION This function may be used to associate an escape sequence with an object. The escape sequence will be sent to the terminal prior to sending updating the object. It may be used on mono terminals to underline objects, etc... The object names are the same names used by the `set_color' function. Note: Care should be exercised when using this function. Also, one may need to experiment around a little to get escape sequences that work together. SEE ALSO set_color -------------------------------------------------------------- set_color_object SYNOPSIS Associate colors "fg" and "bg" with object "obj" USAGE Void set_color_object (Integer obj, String fg, String bg) DESCRIPTION Associate colors `fg' and `bg' with object `obj'. Valid values for `obj' are in the range 30 to 128. All other values are reserved. Values for the strings `fg' and `bg' are as given by the description for `set_color'. SEE ALSO set_column_colors, set_color -------------------------------------------------------------- set_column_colors SYNOPSIS Associate a color with columns `c0' through `c1' USAGE Void set_column_colors (Integer color, Integer c0, Integer c1) DESCRIPTION This function associates a color with columns `c0' through `c1' in the current buffer. That is, if there is no syntax highlighting already defined for the current buffer, when the current buffer is displayed, columns `c0' through `c1' will be displayed with the attributes of the `color' object. The parameters `c0' and `c1' are restricted to the range 1 through `SCREEN_WIDTH'. Use the function `set_color_object' to assign attributes to the `color' object. SEE ALSO set_color_object -------------------------------------------------------------- _autoload SYNOPSIS Specify multiple functions to autoload USAGE Void _autoload (String fun, String fn, ..., Integer n) DESCRIPTION The `_autoload' function is like the `autoload' function except that it takes `n' pairs of function name (`fun') / filename (`fn') pairs. For example, _autoload ("fun_a", "file_a", "fun_b", "file_b", 2); is equivalent to autoload ("fun_a", "file_a"); autoload ("fun_b", "file_b"); SEE ALSO autoload -------------------------------------------------------------- evalbuffer SYNOPSIS Eval the current buffer as S-Lang script USAGE Void evalbuffer ([String_Type namespace]) DESCRIPTION This function causes the current buffer to be sent to the S-Lang interpreter for evaluation. If the optional namespace argument is given, the buffer will be evaluated in the specified namespace. If an error is encountered while parsing the buffer, the cursor will be placed at the location of the error. SEE ALSO evalfile, require -------------------------------------------------------------- get_jed_library_path SYNOPSIS Return the current search path for jed library files USAGE String get_jed_library_path () DESCRIPTION This function returns the current search path for jed library files. The path may be set using the function `set_jed_library_path'. SEE ALSO set_jed_library_path -------------------------------------------------------------- set_jed_library_path SYNOPSIS Set the search path for library files USAGE Void set_jed_library_path (String p) DESCRIPTION This function may be used to set the search path for library files. Its parameter `p' may be a comma separated list of directories to search. When the editor is first started, the path is initialized from the `JED_ROOT', or `JED_LIBRARY' environment variables. SEE ALSO get_jed_library_path -------------------------------------------------------------- BACKUP_BY_COPYING SYNOPSIS Set the backup mode USAGE Int_Type BACKUP_BY_COPYING DESCRIPTION If non-zero, backup files will be made by copying the original file to the backup file. If zero, the backup file will be created by renaming the original file to the backup file. The default for `BACKUP_BY_COPYING' is zero because it is fastest. SEE ALSO rename_file, copy_file -------------------------------------------------------------- IsHPFSFileSystem SYNOPSIS Test if drive of "path" is HPFS USAGE Int_Type IsHPFSFileSystem(String_Type path) DESCRIPTION Returns non-zero if drive of `path' (possibly the default drive) is HPFS. -------------------------------------------------------------- change_default_dir SYNOPSIS Change the current working directory USAGE Int_Type change_default_dir (String_Type new_dir) DESCRIPTION This function may be used to change the current working directory of the editor to `new_dir'. It returns zero upon success or `-1' upon failure. Note: Each buffer has its own working directory. This function does not change the working directory of the buffer. Rather, it changes the working directory of the whole editor. This has an effect on functions such as `rename_file' when such functions are passed relative filenames. SEE ALSO setbuf_info, getbuf_info, rename_file -------------------------------------------------------------- copy_file SYNOPSIS Copy a file "src" to "dest" USAGE Int_Type copy_file (String_Type src, String_Type dest) DESCRIPTION This function may be used to copy a file named `src' to a new file named `dest'. It attempts to preserve the file access and modification times as well as the ownership and protection. It returns `0' upon success and `-1' upon failure. SEE ALSO rename_file, file_status -------------------------------------------------------------- delete_file SYNOPSIS Delete the file "file" USAGE Int_Type delete_file (String_Type file) DESCRIPTION This function may be used to delete a file specified by the `file' parameter. It returns non-zero if the file was sucessfully deleted or zero otherwise. SEE ALSO rmdir -------------------------------------------------------------- directory SYNOPSIS Return number of files and list of files matching filename DESCRIPTION returns the number of files and a list of files which match filename. On unix, this defaults to filename*. It is primarily useful for DOS and VMS to expand wildcard filenames -------------------------------------------------------------- expand_filename SYNOPSIS Expand a file name to a canonical form USAGE String_Type expand_filename (String_Type file) DESCRIPTION The `expand_filename' function expands a file to a canonical form. For example, under Unix, if `file' has the value `"/a/b/../c/d"', it returns `"/a/c/d"'. Similarly, if `file' has the value `"/a/b/c//d/e"', `"/d/e"' is returned. SEE ALSO expand_symlink, path_concat -------------------------------------------------------------- expand_symlink SYNOPSIS Expand a symbolic link USAGE String_Type expand_symlink (String_Type pathname) DESCRIPTION The `expand_symlink' is like the `expand_filename' function except that it also expands components of the pathname that are symbolic links. SEE ALSO expand_filename, path_concat, readlink -------------------------------------------------------------- extract_filename SYNOPSIS Separate the file name from "filespec" USAGE String_Type extract_filename (String_Type filespec) DESCRIPTION This function may be used to separate the file name from the path of of a file specified by `filespec'. For example, under Unix, the expression extract_filename ("/tmp/name"); returns the string `"name"'. SEE ALSO expand_filename -------------------------------------------------------------- file_changed_on_disk SYNOPSIS Test if file "fn" is more recent than the current buffer USAGE Int_Type file_changed_on_disk (String_Type fn) DESCRIPTION This function may be used to determine if the disk file specified by the parameter `fn' is more recent than the current buffer. SEE ALSO file_time_compare, check_buffers -------------------------------------------------------------- file_status SYNOPSIS Return information about file "filename" USAGE Int_Type file_status (String_Type filename) DESCRIPTION The `file_status' function returns information about a file specified by the name `filename'. It returns an integer describing the file type: 2 file is a directory 1 file exists and is not a directory 0 file does not exist. -1 no access. -2 path invalid -3 unknown error -------------------------------------------------------------- file_time_compare SYNOPSIS Compares the modification times of two files USAGE Int_Type file_time_cmp (String_Type file1, String_Type file2) DESCRIPTION This function compares the modification times of two files, `file1' and `file2'. It returns an integer that is either positive, negative, or zero integer for `file1 > file2', `file1 < file2', or `file1 == file2', respectively. In this context, the comparison operators are comparing file modification times. That is, the operator `>' should be read ``is more recent than''. The convention adopted by this routine is that if a file does not exist, its modification time is taken to be at the beginning of time. Thus, if `f' exists, but `g' does not, the `file_time_compare (f, g)' will return a positive number. SEE ALSO file_status, time -------------------------------------------------------------- find_file SYNOPSIS Open the file "name" in a buffer (or just goto buffer) USAGE Int_Type find_file (String_Type name) DESCRIPTION The `find_file' function switches to the buffer associated with the file specified by `name'. If no such buffer exists, one is created and the file specified by `name' is read from the disk and associated with the new buffer. The buffer will also become attached to the current window. Use the `read_file' function to find a file but not associate it with the current window. SEE ALSO read_file -------------------------------------------------------------- insert_file SYNOPSIS Insert a file "f" into the current buffer USAGE Int_Type insert_file (String_Type f) DESCRIPTION This function may be used to insert the contents of a file named `f' into the buffer at the current position. The current editing point will be placed at the end of the inserted text. The function returns `-1' if the file was unable to be opened; otherwise it returns the number of lines inserted. This number can be zero if the file is empty. SEE ALSO read_file, find_file, insert -------------------------------------------------------------- msdos_fixup_dirspec SYNOPSIS remove trailing backslash from "dir" USAGE String_Type msdos_fixup_dirspec (String_Type dir) DESCRIPTION The motivation behind this is that DOS does not like a trailing backslash except if it is for the root dir. This function makes `dir' conform to that. -------------------------------------------------------------- read_file SYNOPSIS Read file "fn" but don't open in a window USAGE Int_Type read_file (string fn) DESCRIPTION The `read_file' function may be used to read a file specified by `fn' into its own buffer. It returns a non-zero value upon success and signals an error upon failure. The hook `find_file_hook' is called after the file is read in. Unlike the related function, `find_file', this function does not create a window for the newly created buffer. SEE ALSO find_file, file_status, write_buffer -------------------------------------------------------------- rename_file SYNOPSIS Change the name of a file USAGE Int_Type rename_file (String_Type old_name, String_Type new_name) DESCRIPTION This function may be used to change the name of a disk file from `old_name' to `new_name'. Upon success, zero is returned. Any other value indicates failure. Note: Both filenames must refer to the same file system. SEE ALSO file_status, stat_file -------------------------------------------------------------- set_file_translation SYNOPSIS Set the way the next file is opened: 1 binary, 0 text mode USAGE set_file_translation (Int_Type n) DESCRIPTION This function affects only the way the next file is opened. Its affect does not last beyond that. If it the value of the parameter is 1, the next file will be opened in binary mode. If the parameter is zero, the file will be opened in text mode. -------------------------------------------------------------- is_line_hidden SYNOPSIS Test if the current line is hidden USAGE Integer is_line_hidden () DESCRIPTION This function returns a non-zero value if the current line is hidden. It will return zero if the current line is visible. SEE ALSO set_line_hidden -------------------------------------------------------------- set_line_hidden SYNOPSIS Set the hidden attribute: 1 hidden, 0 visible USAGE Void set_line_hidden (Integer flag) DESCRIPTION If the parameter `flag' is non-zero, the current line will be given the hidden attribute. This means that it will not be displayed. If the parameter is zero, the hidden attribute will be turned off. SEE ALSO set_region_hidden, is_line_hidden -------------------------------------------------------------- set_region_hidden SYNOPSIS Set the hidden attribute for all lines in a region USAGE Void set_region_hidden (Integer flag) DESCRIPTION This function may be used to hide the lines in a region. If `flag' is non-zero, all lines in the region will be hidden. If it is zero, the lines in the region will be made visible. SEE ALSO set_line_hidden, is_line_hidden, skip_hidden_lines_forward -------------------------------------------------------------- skip_hidden_lines_backward SYNOPSIS Move backward across either hidden or non-hidden lines USAGE Void skip_hidden_lines_backward (Integer type) DESCRIPTION This function may be used to move backward across either hidden or non-hidden lines depending upon whether the parameter `type' is non-zero or zero. If `type' is non-zero, the Point is moved backward across hidden lines until a visible line is reached. If `type' is zero, visible lines will be skipped instead. If the top of the buffer is reached before the appropriate line is reached, the Point will be left there. Note: The functions `up' and `down' are insensitive to whether or not a line is hidden. SEE ALSO skip_hidden_lines_forward, is_line_hidden -------------------------------------------------------------- skip_hidden_lines_forward SYNOPSIS Move forward across either hidden or non-hidden lines USAGE Void skip_hidden_lines_forward (Integer type) DESCRIPTION This function may be used to move forward across either hidden or non-hidden lines depending upon whether the parameter `type' is non-zero or zero. If `type' is non-zero, the Point is moved forward across hidden lines until a visible line is reached. If `type' is zero, visible lines will be skipped instead. If the end of the buffer is reached before the appropriate line is reached, the Point will be left there. Note: The functions `up' and `down' are insensitive to whether or not a line is hidden. SEE ALSO skip_hidden_lines_backward, is_line_hidden -------------------------------------------------------------- add_to_hook SYNOPSIS Add a function to a hook (as first one) USAGE add_to_hook (String_Type hook_name, Ref_Type funct) DESCRIPTION `add_to_hook' adds the function `funct' to the beginnning of the list of hooks associated with `hook_name'. The currently supported hooks include: _jed_append_region_hooks _jed_exit_hooks _jed_find_file_after_hooks _jed_find_file_before_hooks _jed_init_display_hooks _jed_insert_file_hooks _jed_quit_hooks _jed_read_file_hooks _jed_reset_display_hooks _jed_resume_hooks _jed_save_buffer_after_hooks _jed_save_buffer_before_hooks _jed_set_mode_hooks _jed_switch_active_buffer_hooks _jed_suspend_hooks _jed_write_region_hooks See the file `hooks.txt' in the main jed distribution for more information. SEE ALSO append_to_hook, remove_from_hook -------------------------------------------------------------- append_to_hook SYNOPSIS Append a function to a hook USAGE append_to_hook (String_Type hook_name, Ref_Type funct) DESCRIPTION `append_to_hook' adds the function `funct' to the end of the list of hooks associated with `hook_name'. See `add_to_hook' for more information. SEE ALSO add_to_hook, remove_from_hook -------------------------------------------------------------- remove_from_hook SYNOPSIS Remove a function from a list of hooks USAGE remove_from_hook (String_Type hook_name, Ref_Type funct) DESCRIPTION `remove_from_hook' removes the function `funct' from the list of hooks associated with `hook_name'. SEE ALSO add_to_hook, append_to_hook -------------------------------------------------------------- _jed_run_hooks SYNOPSIS Execute the functions in a hook chain USAGE _jed_run_hooks (String_Type hook_name, Integer_Type mode [,Array_Type args]) DESCRIPTION `_jed_run_hooks' executes the functions registered for `hook_name'. The argument `mode' defines which functions are called: JED_HOOKS_RUN_ALL all functions; no function should return a value. JED_HOOKS_RUN_UNTIL_0 Run until a function returns the value 0; every function must return an integer value. JED_HOOKS_RUN_UNTIL_NON_0 Run until a function returns a non-zero value; every function must return an integer value. If the third argument is given, then it must be an array of strings to be passed as arguments to the the hook-functions. SEE ALSO append_to_hook, add_to_hook -------------------------------------------------------------- get_buffer_hook SYNOPSIS Get the value of a specified buffer hook USAGE Ref_Type get_buffer_hook (String_Type hook_name) DESCRIPTION The `get_buffer_hook' function returns the value of the specified hook name as a function reference. If no hook was defined or the hook does not exist, then NULL will be returned. See the documentation for `set_buffer_hook' for a list of hook-names. EXAMPLE % temporarily unset the indent hook fun = get_buffer_hook ("indent_hook"); unset_buffer_hook ("indent_hook"); . . % restore the indent hook if (fun != NULL) set_buffer_hook ("indent_hook", fun); SEE ALSO set_buffer_hook, unset_buffer_hook -------------------------------------------------------------- set_buffer_hook SYNOPSIS Set a specified buffer hook USAGE set_buffer_hook (String_Type hook_name, Ref_Type func) DESCRIPTION This function sets the specified hook for the current buffer to the function `func'. The value of `func' may either be a string or a function reference (e.g., `&my_hook'). The use of a function reference is preferred since that allows hooks to be static or private functions. Currently supported hooks include: "par_sep" -- returns zero if the current line does not constitute the beginning or end of a paragraph. It returns non-zero otherwise. The default value of hook is is_paragraph_separator. "indent_hook" -- returns nothing. It is called by the indent line routines. "wrap_hook" hook that is called after a line is wrapped. Returns nothing. "wrapok_hook" hook that is called prior to wrapping a line. If it returns non-zero, the line will be wrapped, otherwise the line will not be wrapped. "newline_indent_hook" --- returns nothing. If this hook is defined, it will be called instead of the internal function newline_and_indent is called. "bob_eob_error_hook" --- returns nothing. If this hook is defined, it will be called whenever an error one of the internal cursor movement functions would have generated an end of buffer or beginning of buffer error. It is passed an integer that indicates which function would have generated the error. Specifically: -1 previous_line_cmd -2 previous_char_cmd -3 page_up 1 next_line_cmd 2 next_char_cmd 3 page_down "mouse_down", "mouse_up", "mouse_drag" "mouse_2click" "mouse_3click" These hooks are used to override default hooks defined by the mouse_set_default_hook function. "mark_paragraph_hook" This hook hook is called by the format_paragraph function to mark a paragraph. "forward_paragraph_hook", "backward_paragraph_hook" "format_paragraph_hook" See the file jed/doc/hooks.txt for more information and examples. SEE ALSO unset_buffer_hook, mouse_set_default_hook, get_buffer_hook -------------------------------------------------------------- unset_buffer_hook SYNOPSIS Remove a buffer hook USAGE unset_buffer_hook (String_Type name) DESCRIPTION The `unset_buffer_hook' function removes a specified buffer hook from the current buffer. If `name' is the empty string, then all the buffer hooks of the current buffer will be unset. See the documentation for `set_buffer_hook' for a list of hook-names. SEE ALSO set_buffer_hook, get_buffer_hook -------------------------------------------------------------- bobp SYNOPSIS Test if the current position is at the beginning of the buffer USAGE Integer bobp (); DESCRIPTION The `bolp' function is used to determine if the current position is at the beginning of the buffer or not. If so, it returns a non-zero value. However, if it is not, it returns zero. This simple example, define is_buffer_empty () { return bobp () and eobp (); } returns non-zero if the buffer is empty; otherwise, it returns zero. SEE ALSO bob, eobp, bolp, eolp -------------------------------------------------------------- bolp SYNOPSIS Test if the current position is at the beginning of the line USAGE Integer bolp (); DESCRIPTION `bolp' is used to test if the current position is at the beginning of a line or not. It returns non-zero if the position is at the beginning of a line or zero if not. SEE ALSO bol, eolp, bobp, eobp -------------------------------------------------------------- count_chars SYNOPSIS Return information about size of and position in the buffer USAGE String count_chars (); DESCRIPTION This function returns information about the size of the current buffer and current position in the buffer. The string returned is of the form: 'h'=104/0x68/0150, point 90876 of 127057 SEE ALSO what_char -------------------------------------------------------------- eobp SYNOPSIS Test if the current position is at the end of the buffer USAGE Integer eobp (); DESCRIPTION The functio `eobp' is used to determine if the current position is at the end of the buffer or not. It returns a non-zero value if at the end of the buffer or zero if not. SEE ALSO eob, bolp, eolp -------------------------------------------------------------- eolp SYNOPSIS Test if the current position is at the end of the line USAGE Integer eolp (); DESCRIPTION This function may be used to determine whether or not the current position is at the end of a line ot not. If it is, the routine returns a non-zero value; otherwise it returns zero. SEE ALSO eol, bolp, eobp, bobp -------------------------------------------------------------- get_word_chars SYNOPSIS Get the currently defined word range USAGE String_Type get_word_chars () DESCRIPTION The `get_word_chars' returns the currently defined set of characters that constitute a word. The set may be returned as a character range. SEE ALSO define_word -------------------------------------------------------------- what_char SYNOPSIS Return the ASCII-value of the character at the current position USAGE ULong_Type what_char () DESCRIPTION The `what_char' function returns the value of the character at the current position as an unsigned long value. If UTF-8 mode is active and the current character is part of an illegal byte sequence, then the function returns a negative value equal in magnitude to the value of the byte. EXAMPLE while (not (eolp ())) { if (what_char () == '_') { del (); insert ("\\_"); continue; } go_right (1); } has the effect of replacing all underscore characters on the current line with a backslash-underscore combination. SEE ALSO looking_at -------------------------------------------------------------- what_column SYNOPSIS Return the current column number USAGE Integer what_column (); DESCRIPTION The `what_column' function returns the current column number expanding tabs, control characters, etc... The beginning of the line is at column number one. SEE ALSO whatline, whatpos, goto_column, bolp, eolp -------------------------------------------------------------- what_line SYNOPSIS Get the current line number USAGE Int_Type what_line DESCRIPTION The value of the `what_line' specifies the current line number. Lines are numbered from one. NOTES This is a read-only variable. The actual number is measured from the top of the buffer which is itself is affected by whether the buffer is narrowed or not. For example, define one () { push_mark (); narrow (); return what_line; } always returns 1. SEE ALSO what_column, goto_line -------------------------------------------------------------- USE_TABS SYNOPSIS Control use of tabs in whitespace USAGE Int_Type USE_TABS DESCRIPTION If `USE_TABS' is non-zero, the editor may use tab characters when creating whitespace. If the value of this variable is zero, no tabs will be used. SEE ALSO TAB, TAB_DEFAULT -------------------------------------------------------------- WRAP SYNOPSIS Set the column at which wrapping occurs USAGE Int_Type WRAP DESCRIPTION The `WRAP' variable determines the column number at which wrapping will occur. When entering text, if the current point goes beyond this column, the text will automatically wrap to the next line. This will only happen for those buffers for which the wrap flag is set. SEE ALSO WRAP_INDENTS, getbuf_info, set_mode -------------------------------------------------------------- WRAP_INDENTS SYNOPSIS Control indentation after wrapping USAGE Int_Type WRAP_INDENTS DESCRIPTION If this variable is non-zero, after a line is wrapped, the new line will start at the same indentation as the current one. On the other hand, if the value of `WRAP_INDENTS' is zero, the new line will begin in the first column. -------------------------------------------------------------- del SYNOPSIS Delete the character at the current editing position USAGE Void del () DESCRIPTION The `del' function deletes the character at the current editing position. If the position is at the end of the buffer, nothing happens. If the deletion occurs at the end of a line, the next line will be joined with the current one. SEE ALSO eobp, erase_buffer, insert -------------------------------------------------------------- del_region SYNOPSIS Delete the region USAGE Void del_region () DESCRIPTION This function deletes the region defined by the mark and the current editing point. For example, define delete_this_line () { bol (); push_mark (); eol (); del_region (); } defines a function that deletes all characters on the current line from the beginning of the line until the end of the line. It does not delete the line itself. SEE ALSO push_mark, markp, check_region -------------------------------------------------------------- erase_buffer SYNOPSIS Erase all text from the current buffer USAGE erase_buffer () DESCRIPTION The `erase_buffer' function erases all text from the current buffer. However, it does not delete the buffer itself. Note: This function destroys all undo information associated with the buffer making it impossible to undo the result of this function. SEE ALSO delbuf, del -------------------------------------------------------------- indent_line SYNOPSIS Indent the current line (using the `indent_hook') USAGE Void indent_line () DESCRIPTION The `indent_line' line function indents the current line in a manner which depends upon the current buffer. The actual function that gets called is set via a prior call the `set_buffer_hook' to set the indent hook. The default value is to indent the line to the indentation level of the previous line. SEE ALSO set_buffer_hook -------------------------------------------------------------- insbuf SYNOPSIS Insert buffer "buf" into the current buffer USAGE Void insbuf (String buf) DESCRIPTION This function may be used to insert the contents of a buffer specified by the name `buf' into the current buffer. The editing position is advanced to the end of the insertion. SEE ALSO copy_region, narrow, narrow_to_region -------------------------------------------------------------- insert SYNOPSIS Insert string "str" into buffer at the current position USAGE Void insert (String str) DESCRIPTION Inserts string `str' into buffer at the current position. The editing point is moved to the end of the of the string that was inserted. SEE ALSO insert_char, del, insert_file, insbuf -------------------------------------------------------------- insert_char SYNOPSIS Insert a character at the current position USAGE Void insert_char (ULong_Type ch) DESCRIPTION This function inserts the specified character into the buffer. SEE ALSO what_char, insert, insert_byte -------------------------------------------------------------- insert_byte SYNOPSIS Insert a byte into the buffer USAGE Void insert_byte (UChar_Type ch) DESCRIPTION This function inserts the specified byte into the buffer at the current position. SEE ALSO what_char, insert_char, insert -------------------------------------------------------------- insert_file_region SYNOPSIS Insert a region of the file "file" USAGE Integer insert_file_region (String file, String beg, String end) DESCRIPTION This function may be used to insert a region specified by the strings `beg' and `end' of the file with name `file' into the current buffer. The file is scanned line by line until a line that begins with the string given by `beg' is encountered. Then, that line and all successive lines up to the one that starts with the string specified by `end' is inserted into the buffer. The line beginning with the value of `end' is not inserted although the one beginning with `beg' is. The function returns the number of lines inserted or `-1' upon failure to open the file. Note that a zero length `beg' corresponds to the first line and that a zero length `end' corresponds to the last line. SEE ALSO insert_file -------------------------------------------------------------- insert_from_kill_array SYNOPSIS Insert the contents of element "n" of the kill array USAGE Void insert_from_kill_array (Integer n) DESCRIPTION This function inserts the contents of the nth element, specified by `n', of an internal array of character strings. Note: This function is not available on 16 bit systems. SEE ALSO insert_from_kill_array, copy_region_to_kill_array SEE ALSO KILL_ARRAY_SIZE -------------------------------------------------------------- trim SYNOPSIS Remove all whitespace around the current editing point USAGE Void trim () DESCRIPTION The `trim' function removes all whitespace around the current editing point. In this context, whitespace is considered to be any combination of tab and space characters. In particular, it does not include the newline character. This means that the `trim' function will not delete across lines. SEE ALSO skip_chars, skip_white, del, del_region -------------------------------------------------------------- whitespace SYNOPSIS Insert white space of length "n" USAGE whitespace (Integer n) DESCRIPTION The `whitespace' function inserts white space of length `n' into the current buffer using a combination of spaces and tabs. The actual combination of spaces and tabs used depends upon the buffer local variable `TAB'. In particular, if `TAB' is zero, no tab characters will be used for the expansion. SEE ALSO insert, trim, goto_column SEE ALSO TAB,TAB_DEFAULT -------------------------------------------------------------- ALT_CHAR SYNOPSIS Controls the Alt character prefix USAGE Int_Type ALT_CHAR DESCRIPTION If this variable is non-zero, characters pressed in combination the `Alt' key will generate a two character sequence: the first character is the value of `ALT_CHAR' itself followed by the character pressed. For example, if `Alt-X' is pressed and `ALT_CHAR' has a value of 27, the characters `ESC X' will be generated. NOTES This variable may not be available on all platforms. SEE ALSO META_CHAR, FN_CHAR -------------------------------------------------------------- CURRENT_KBD_COMMAND SYNOPSIS The currently executing keyboard command USAGE String_Type CURRENT_KBD_COMMAND DESCRIPTION The value of the `CURRENT_KBD_COMMAND' function represents the name of the currently executing procedure bound to the currently executing key sequence. SEE ALSO LASTKEY, LAST_KBD_COMMAND, _function_name -------------------------------------------------------------- DEC_8BIT_HACK SYNOPSIS Set the input mode for 8 bit control characters USAGE Int_Type DEC_8BIT_HACK DESCRIPTION If set to a non-zero value, a input character between 128 and 160 will be converted into a two character sequence: `ESC' and the character itself stripped of the high bit + 64. The motivation behind this variable is to enable the editor to work with VTxxx terminals that are in eight bit mode. SEE ALSO META_CHAR -------------------------------------------------------------- DEFINING_MACRO SYNOPSIS Non-zero if defining a macro USAGE Int_Type DEFINING_MACRO DESCRIPTION The `DEFINING_MACRO' variable will be non-zero is a keyboard macro definition is in progress. SEE ALSO EXECUTING_MACRO -------------------------------------------------------------- EXECUTING_MACRO SYNOPSIS Non-zero if a keyboard macro is currently executing USAGE Int_Type EXECUTING_MACRO DESCRIPTION The `EXECUTING_MACRO' variable will be non-zero is a keyboard macro is currently being executed. SEE ALSO -------------------------------------------------------------- FN_CHAR SYNOPSIS Set the function key prefix USAGE Int_Type FN_CHAR DESCRIPTION If this variable is non-zero, function keys presses will generate a two character sequence: the first character is the value of the `FN_CHAR' itself followed by the character pressed. NOTES This variable is available only for Microsoft window systems. SEE ALSO ALT_CHAR, META_CHAR -------------------------------------------------------------- IGNORE_USER_ABORT SYNOPSIS Control keyboard interrupt processing USAGE Int_Type IGNORE_USER_ABORT DESCRIPTION If set to a non-zero value, the keyboard interrupt character, e.g., `Ctrl-G' will not trigger a S-Lang error. When JED starts up, this value is set to 1 so that the user cannot interrupt the loading of site.sl. Later, it is set to 0. SEE ALSO set_abort_char -------------------------------------------------------------- KILL_LINE_FEATURE SYNOPSIS Configure the kill_line function USAGE Int_Type KILL_LINE_FEATURE DESCRIPTION If non-zero, kill_line will kill through end of line character if the cursor is at the beginning of a line. Otherwise, it will kill only to the end of the line. SEE ALSO bolp -------------------------------------------------------------- LASTKEY SYNOPSIS The value of the current key sequence USAGE String_Type LASTKEY DESCRIPTION The value of the `LASTKEY' variable represents the currently executing key sequence. NOTES Key sequences involving the null character may not be accurately recorded. SEE ALSO LAST_KBD_COMMAND -------------------------------------------------------------- LAST_CHAR SYNOPSIS The Last Character read from the keyboard USAGE Int_Type LAST_CHAR DESCRIPTION The value of `LAST_CHAR' will be the last character read from the keyboard buffer. SEE ALSO -------------------------------------------------------------- META_CHAR SYNOPSIS Specify the meta-character USAGE Int_Type META_CHAR DESCRIPTION This variable determines how input characters with the high bit set are to be treated. If `META_CHAR' is less than zero, the character is passed through un-processed. However, if `META_CHAR' is greater than or equal to zero, an input character with the high bit set is mapped to a two character sequence. The first character of the sequence is the character whose ascii value is `META_CHAR' and the second character is the input with its high bit stripped off. SEE ALSO DISPLAY_EIGHT_BIT, DEC_8BIT_HACK -------------------------------------------------------------- X_LAST_KEYSYM SYNOPSIS Keysym associated with the last key USAGE Int_Type X_LAST_KEYSYM DESCRIPTION The value of the `X_LAST_KEYSYM' variable represents the keysym of the most previously processed key. NOTES This variable is availible only in the XWindows version of jed. SEE ALSO LASTKEY -------------------------------------------------------------- buffer_keystring SYNOPSIS Append string "str" to the end of the input stream USAGE Void buffer_keystring (String str); DESCRIPTION Append string `str' to the end of the input stream to be read by JED's getkey routines. SEE ALSO ungetkey, getkey -------------------------------------------------------------- copy_keymap SYNOPSIS Create a new keymap by copying another USAGE copy_keymap (String_Type new_map, String_Type old_map) DESCRIPTION The `copy_keymap' creates a new keymap whose name is given by `new_map' by copying an existing keymap specified by `old_map'. SEE ALSO make_keymap, keymap_p, use_keymap -------------------------------------------------------------- definekey SYNOPSIS Bind keys to a function in a specific keymap USAGE Void definekey(String f, String key, String kmap); DESCRIPTION Unlike `setkey' which operates on the global keymap, this function is used for binding keys to functions in a specific keymap. Here `f' is the function to be bound, `key' is a string of characters that make up the key sequence and `kmap' is the name of the keymap to be used. See `setkey' for more information about the arguments. SEE ALSO setkey, undefinekey, make_keymap, use_keymap -------------------------------------------------------------- dump_bindings SYNOPSIS Insert a list of keybindings for "map" into the buffer USAGE Void dump_bindings(String map); DESCRIPTION This functions inserts a formatted list of keybindings for the keymap specified by `map' into the buffer at the current point. SEE ALSO get_key_binding -------------------------------------------------------------- enable_flow_control SYNOPSIS Turn on XON/XOFF flow control USAGE Void enable_flow_control (Integer flag); DESCRIPTION This Unix specific function may be used to turn XON/XOFF flow control on or off. If `flag' is non-zero, flow control is turned on; otherwise, it is turned off. -------------------------------------------------------------- flush_input SYNOPSIS Process all forms of queued input USAGE Void flush_input (); DESCRIPTION This function may be used to remove all forms of queued input. SEE ALSO input_pending, getkey -------------------------------------------------------------- get_key_binding SYNOPSIS Return binding information about a key sequence USAGE (type, funct) = get_key_binding ([ keyseq ]) Int_Type type; String_Type funct; String_Type keyseq; DESCRIPTION `get_key_binding' returns binding information about a specified key sequence. If the optional parameter `keyseq' is not present, then `get_key_binding' will wait for the user to enter a key sequence. If `keyseq' is present, then it denotes the key sequence. This function returns two values: a String_Type or Ref_Type representing the key sequence binding (`funct'), and an integer that indicates the key binding type: type description ------------------------------------- -1 funct is NULL, which indicates that the key has no binding 0 funct is the name of a S-Lang function 1 funct is the name of an internal function 2 funct represents a macro ("@macro") 3 funct represents a string to be inserted (" STRING") 4 funct is a reference (Ref_Type) to the actual function SEE ALSO getkey, input_pending -------------------------------------------------------------- _getkey SYNOPSIS Read an input byte from the keyboard USAGE Int_Type _getkey () DESCRIPTION The `_getkey' function may be used to read a byte character from the keyboard. It should be used instead of `getkey' when byte-semantics are required. SEE ALSO input_pending, _ungetkey, getkey -------------------------------------------------------------- getkey SYNOPSIS Read an input character from the keyboard USAGE Long_Type getkey () DESCRIPTION The `getkey' function may be used to read an input character from the keyboard. If UTF-8 mode is in effect, the value returned can be negative if the key-sequence corresponds to an invalid UTF-8 encoded sequence. In such a case, the value returned will correspond to the first byte of the sequence, and will be equal in magnitude to the value of byte. SEE ALSO input_pending, ungetkey, _getkey -------------------------------------------------------------- input_pending SYNOPSIS Test whether there is pending keyboard input USAGE Integer input_pending (Integer tsecs); DESCRIPTION This function is used to see if keyboard input is available to be read or not. The paramter `tsecs' is the amount of time to wait for input before returning if input is not available. The time unit for `tsecs' is one-tenth of a second. That is, to wait up to one second, pass a value of ten to this routine. It returns zero if no input is available, otherwise it returns non-zero. As an example, define peek_key () { variable ch; !if (input_pending (0)) return -1; ch = getkey (); ungetkey (ch); return ch; } returns the value of the next character to be read if one is available; otherwise, it returns -1. SEE ALSO getkey, ungetkey -------------------------------------------------------------- keymap_p SYNOPSIS Test if a keymap "kmap" exists USAGE Integer keymap_p (String kmap); DESCRIPTION The `keymap_p' function may be used to determine whether or not a keymap with name `kmap' exists. If the keymap specified by `kmap' exists, the function returns non-zero. It returns zero if the keymap does not exist. SEE ALSO make_keymap, definekey -------------------------------------------------------------- make_keymap SYNOPSIS Create a keymap with name "km" USAGE Void make_keymap (String km); DESCRIPTION The `make_keymap' function creates a keymap with a name specified by the `km' parameter. The new keymap is an exact copy of the pre-defined `"global"' keymap. SEE ALSO use_keymap, copy_keymap, keymap_p, definekey, setkey -------------------------------------------------------------- map_input SYNOPSIS Remap an input character "x" to "y". USAGE Void map_input (Integer x, Integer y); DESCRIPTION The `map_input' function may be used to remap an input character with ascii value `x' from the keyboard to a different character with ascii value `y'. This mapping can be quite useful because it takes place before the editor interprets the character. One simply use of this function is to swap the backspace and delete characters. Since the backspace character has an ascii value of `8' and the delete character has ascii value `127', the statement map_input (8, 127); maps the backspace character to a delete character and map_input (127, 8); maps the delete character to a backspace character. Used together, these two statement effectively swap the delete and backspace keys. SEE ALSO getkey -------------------------------------------------------------- prefix_argument SYNOPSIS Test if the user has entered a prefix argument USAGE Int_Type prefix_argument () DESCRIPTION This function may be used to determine whether or not the user has entered a prefix argument from the keyboard. If a prefix argument is present, its value is returned, otherwise NULL will be returned. Calling this function cancels the prefix-argument. EXAMPLE This example displays the prefix argument in the message area: arg = prefix_argument (); if (arg == NULL) message ("No Prefix Argument"); else vmessage ("Prefix argument: %d", arg); NOTES The old semantics, which are still supported but deprecated allows an integer argument to be passed to the function. This argument will be returned instead of NULL if no prefix-argument is present. Using the old semantics, the above example could be written as arg = prefix_argument (-9999); if (arg == -9999) message ("No Prefix Argument"); else vmessage ("Prefix argument: %d", arg); SEE ALSO set_prefix_argument -------------------------------------------------------------- set_abort_char SYNOPSIS change the keyboard character that generates an S-Lang interrupt USAGE Void set_abort_char (Integer ch); DESCRIPTION This function may be used to change the keyboard character that generates an S-Lang interrupt. The parameter `ch' is the ASCII value of the character that will become the new abort character. The default abort character `Ctrl-G' corresponds to `ch=7'. -------------------------------------------------------------- set_current_kbd_command SYNOPSIS Do as if "s" were entered from the keybord USAGE Void set_current_kbd_command (String s); DESCRIPTION Undocumented -------------------------------------------------------------- set_prefix_argument SYNOPSIS Set the prefix argument USAGE Void set_prefix_argument (Int_Type n) DESCRIPTION This function may be used to set the prefix argument to the value specified by `n'. If `n' is less than zero, then the prefix argument is cancelled. SEE ALSO prefix_argument -------------------------------------------------------------- setkey SYNOPSIS Bind a key sequence "key" to the function "fun" USAGE Void setkey(String fun, String key); DESCRIPTION This function may be used to define a key sequence specified by the string `key' to the function `fun'. `key' can contain the `^' character which denotes that the following character is to be interpreted as a control character, e.g., setkey("bob", "^Kt"); sets the key sequence `Ctrl-K t' to the function `bob'. The `fun' argument is usually the name of an internal or a user defined S-Lang function. However, if may also be a sequence of functions or even another keysequence (a keyboard macro). For example, setkey ("bol;insert(string(whatline()))", "^Kw"); assigns the key sequence `Ctrl-K w' to move to the beginning of a line and insert the current line number. For more information about this important function, see the JED User Manual. Note that `setkey' works on the "global" keymap. SEE ALSO unsetkey, definekey -------------------------------------------------------------- undefinekey SYNOPSIS Remove a keybinding from "kmap" USAGE Void undefinekey (String key, String kmap); DESCRIPTION This function may be used to remove a keybinding from a specified keymap. The key sequence is given by the parameter `key' and the keymap is specified by the second parameter `kmap'. SEE ALSO unsetkey, definekey, what_keymap -------------------------------------------------------------- _ungetkey SYNOPSIS Push a byte onto the input stream USAGE Void _ungetkey (Int_Type c) DESCRIPTION This function may be used to push a byte `c' onto the input stream. This means that the next keyboard byte to be read will be `c'. SEE ALSO buffer_keystring, _getkey, get_key_binding -------------------------------------------------------------- ungetkey SYNOPSIS Push a character onto the input stream USAGE Void ungetkey (Integer c); DESCRIPTION This function may be used to push a character `c' represented by its character code onto the input stream. This means that the next keyboard character to be read will be `c'. SEE ALSO buffer_keystring, getkey, get_key_binding -------------------------------------------------------------- unsetkey SYNOPSIS Remove the definition of "key" from the "global" keymap USAGE Void unsetkey(String key); DESCRIPTION This function is used to remove the definition of the key sequence `key' from the "global" keymap. This is sometimes necessary to bind new key sequences which conflict with other ones. For example, the "global" keymap binds the keys `"^[[A"', `"^[[B"', `"^[[C"', and `"^[[D"' to the character movement functions. Using `unsetkey("^[[A")' will remove the binding of `"^[[A"' from the global keymap but the other three will remain. However, `unsetkey("^[[")' will remove the definition of all the above keys. This might be necessary to bind, say, `"^[["' to some function. SEE ALSO setkey, undefinekey -------------------------------------------------------------- use_keymap SYNOPSIS Set the keymap for the current buffer USAGE Void use_keymap (String km); DESCRIPTION This function may be used to dictate which keymap will be used by the current buffer. `km' is a string value that corresponds to the name of a keymap. SEE ALSO make_keymap, copy_keymap, keymap_p, what_keymap -------------------------------------------------------------- what_keymap SYNOPSIS Return the name of the current buffer's keymap USAGE String what_keymap (); DESCRIPTION This function returns the name of the keymap associated with the current buffer. SEE ALSO create_keymap, keymap_p -------------------------------------------------------------- which_key SYNOPSIS Return the keys that are bound to the function "f" USAGE Integer which_key (String f); DESCRIPTION The `which_key' function returns the the number of keys that are bound to the function `f' in the current keymap. It also returns that number of key sequences with control characters expanded as the two character sequence `^' and the the whose ascii value is the control character + 64. For example, define insert_key_bindings (f) { variable n, key; n = which_key (f); loop (n) { str = (); insert (str); insert ("\n"); } } inserts into the buffer all the key sequences that are bound to the function `f'. SEE ALSO get_key_binding, setkey, what_keymap -------------------------------------------------------------- create_line_mark SYNOPSIS Return a line mark (of the type User_Mark) USAGE User_Mark create_line_mark (Integer c) DESCRIPTION The function `create_line_mark' returns an object of the type `User_Mark'. This object contains information regarding the current position and current buffer. The parameter `c' is used to specify the color to use when the line is displayed. SEE ALSO create_user_mark, set_color_object -------------------------------------------------------------- create_user_mark SYNOPSIS Return an object of the type User_Mark USAGE User_Mark create_user_mark () DESCRIPTION The function `create_user_mark' returns an object of the type `User_Mark'. This object contains information regarding the current position and current buffer. SEE ALSO move_user_mark, goto_user_mark, user_mark_buffer -------------------------------------------------------------- dupmark SYNOPSIS Duplicate the mark (if set), return success USAGE Integer dupmark () DESCRIPTION This function returns zero if the mark is not set or, if the mark is set, a duplicate of it is pushed onto the mark stack and a non-zero value is returned. SEE ALSO push_mark, markp, pop_mark -------------------------------------------------------------- goto_user_mark SYNOPSIS Return to the position of the User Mark "mark" USAGE Void goto_user_mark (User_Mark mark) DESCRIPTION This function returns to the position of the User Mark `mark'. Before this function may be called, the current buffer must be the buffer associated with the makr. SEE ALSO move_user_mark, create_user_mark, user_mark_buffer -------------------------------------------------------------- is_user_mark_in_narrow SYNOPSIS Test if the user mark "m" is within the narrowed buffer. USAGE Integer is_user_mark_in_narrow (User_Mark m) DESCRIPTION This function returns non-zero if the user mark `m' refers to a position that is within the current narrow restriction of the current buffer. It returns zero if the mark lies outside the restriction. An error will be generated if `m' does not represent a mark for the current buffer. SEE ALSO goto_user_mark, move_user_mark -------------------------------------------------------------- is_visible_mark SYNOPSIS Test if the mark is a visible mark USAGE is_visible_mark () DESCRIPTION This function may be used to test whether or not the mark is a visible mark. A visible mar is one which causes the region defined by it to be highlighted. It returns `1' is the mark is visible, or `0' if the mark is not visible or does not exist. SEE ALSO markp, push_mark -------------------------------------------------------------- markp SYNOPSIS Test if a mark is set USAGE Void markp () DESCRIPTION This function returns a non-zero value if the mark is set; otherwise, it returns zero. If a mark is set, a region is defined. SEE ALSO push_mark, pop_mark, check_region, push_spot -------------------------------------------------------------- move_user_mark SYNOPSIS Move the User Mark "mark" to the current position USAGE Void move_user_mark (User_Mark mark) DESCRIPTION This function call takes a previously created User Mark, `mark', and moves it to the current position and buffer. This means that if one subsequently calls `goto_user_mark' with this mark as an argument, the the position will be set to the new position. Note: This function call is not equivalent to simply using mark = create_user_mark (); because independent copies of a User Mark are not created upon assignment. That is, if one has variable mark1, mark2; setbuf ("first"); mark1 = create_user_mark (); mark2 = mark1; setbuf ("second"); and then calls move_user_mark (mark1); both user marks, `mark1' and `mark2' will be moved since they refer to the same mark. SEE ALSO goto_user_mark, create_user_mark, user_mark_buffer -------------------------------------------------------------- pop_mark SYNOPSIS Pop the most recent mark (if "g" is non-zero, go there USAGE pop_mark (Integer g) DESCRIPTION `pop_mark' pops the most recent mark pushed onto the mark stack. If the argument `g' is non-zero, the editing position will be moved to the location of the mark. However, if `g' is zero, the editing position will be unchanged. SEE ALSO push_mark, pop_spot, markp, check_region, goto_user_mark -------------------------------------------------------------- pop_spot SYNOPSIS Pop the last spot (and go there) USAGE Void pop_spot () DESCRIPTION This function is used after a call to `push_spot' to return to the editing position at the last call to `push_spot' in the current buffer. SEE ALSO push_spot, pop_mark -------------------------------------------------------------- push_mark SYNOPSIS Mark the current position as the beginning of a region USAGE Void push_mark() DESCRIPTION This function marks the current position as the beginning of a region. and pushes other marks onto a stack. A region is defined by this mark and the editing point. The mark is removed from the stack only when the function `pop_mark' is called. For example, define mark_buffer () { bob (); push_mark (); eob (); } marks the entire buffer as a region. SEE ALSO pop_mark, push_spot, markp, dupmark, check_region -------------------------------------------------------------- push_spot SYNOPSIS Push the current buffer location onto a stack USAGE Void push_spot () DESCRIPTION `push_spot' pushes the location of the current buffer location onto a stack. This function does not set the mark. The function `push_mark' should be used for that purpose. The spot can be returned to using the function `pop_spot'. Note: Spots are local to each buffer. It is not possible to call `push_spot' from one buffer and then subsequently call `pop_spot' from another buffer to return to the position in the first buffer. For this purpose, one must use user marks instead. SEE ALSO pop_spot, push_mark, create_user_mark -------------------------------------------------------------- user_mark_buffer SYNOPSIS Return the name of the buffer with User Mark "m" USAGE String user_mark_buffer (User_Mark m) DESCRIPTION This function returns the name of the buffer associated with the User Mark specified by `m'. SEE ALSO goto_user_mark, create_user_mark, move_user_mark, is_user_mark_in_narrow -------------------------------------------------------------- enable_top_status_line SYNOPSIS Set the top_status_line: 1 enabled, 0 hidden USAGE Void enable_top_status_line (Integer x); DESCRIPTION If x is non-zero, the top status line is enabled. If x is zero, the top status line is disabled and hidden. SEE ALSO set_top_status_line -------------------------------------------------------------- menu_append_item SYNOPSIS Append an entry to a menu USAGE menu_append_item (menu, name, fun [,client_data]) String_Type menu, name; String_Type or Ref_Type fun; Any_Type client_data DESCRIPTION The `menu_append_item' function appends a menu item called `name' to the menu `menu'. If called with 3 arguments, the third argument must be a string that will get executed or called when the menu item is selected. When called with 4 arguments, the `fun' argument may be either a string or a reference to a function. When the item is selected, the function will be called and `client_data' will be passed to it. SEE ALSO menu_append_popup -------------------------------------------------------------- menu_append_popup SYNOPSIS Append a popup menu to a menu USAGE menu_append_popup (String_Type parent_menu, String_Type popup_name) DESCRIPTION The `menu_append_popup' function may be used to append a new popup menu with name `popup_name' to the menu `parent_menu', which may either be another popup menu or a menu bar. SEE ALSO menu_append_item, menu_append_separator -------------------------------------------------------------- menu_append_separator SYNOPSIS Append a separator to a menu USAGE menu_append_separator (String_Type menu) DESCRIPTION The `menu_append_separator' function appends a menu item separator to the menu `menu'. SEE ALSO menu_append_item, menu_append_popup -------------------------------------------------------------- menu_copy_menu SYNOPSIS Copy a menu to another USAGE menu_copy_menu (String_Type dest, String_Type src) DESCRIPTION Then `menu_copy_menu' function copies the menu item, which may be another popup menu, to another popup menu. SEE ALSO menu_append_popup, menu_append_item -------------------------------------------------------------- menu_create_menu_bar SYNOPSIS Create a menu bar USAGE menu_create_menu_bar (String_Type name) DESCRIPTION The `menu_create_menu_bar' function may be used to create a new menu bar called `name'. The new menu bar may be associated with a buffer via the `menu_use_menu_bar' function. SEE ALSO menu_use_menu_bar, menu_append_popup -------------------------------------------------------------- menu_delete_item SYNOPSIS Delete a menu item USAGE menu_delete_item (String_Type name) DESCRIPTION The `menu_delete_item' function deletes the menu called `name' and all of its submenus. EXAMPLE To delete the `System' menu from the global menu bar, use menu_delete_item ("Global.S&ystem"); SEE ALSO menu_delete_items -------------------------------------------------------------- menu_delete_items SYNOPSIS Delete the items from a menu USAGE menu_delete_items (String_Type menu) DESCRIPTION The `menu_delete_items' function deletes all the menu items attached to a specified popup menu. However, unlike the related function `menu_delete_item', the popup menu itself will not be removed. SEE ALSO menu_delete_item, menu_append_popup -------------------------------------------------------------- menu_insert_item SYNOPSIS Insert an entry into a menu at a specified position USAGE menu_insert_item (position, menu, name, fun [,client_data]) Int_Type/String_Type position; String_Type menu, name; String_Type or Ref_Type fun; Any_Type client_data; DESCRIPTION The `menu_insert_item' function inserts a menu item called `name' to the menu `menu' at a specified position. The insertion position may be specified as an integer, or as the name of a menu item within `parent_menu'. When specified as an integer, the insertion will take place at the corresponding position of the menu, where zero denotes the first item. If the position specifier is the name of a menu item, the the insertion will take place before that item. If called with 4 arguments, the third argument must be a string that will get executed or called when the menu item is selected. When called with 5 arguments, the `fun' argument may be either a string or a reference to a function. When the item is selected, the function will be called and `client_data' will be passed to it. SEE ALSO menu_append_item, menu_insert_popup, menu_insert_separator -------------------------------------------------------------- menu_insert_popup SYNOPSIS Inserts a popup menu into a menu at a specified position USAGE menu_insert_popup (position, parent_menu, popup_name) Int_Type/String_Type position; String_Type parent_menu, popup_name; DESCRIPTION The `menu_insert_popup' function will insert a popup menu with name `popup_name' into a pre-existing popup menu or menu bar with name given by {parent_menu}. The insertion position may be specified as an integer, or as the name of a menu item within `parent_menu'. When specified as an integer, the insertion will take place at the corresponding position of the menu, where zero denotes the first item. If the position specifier is the name of a menu item, the the insertion will take place before that item. SEE ALSO menu_append_popup, menu_insert_item, menu_insert_separator -------------------------------------------------------------- menu_insert_separator SYNOPSIS Inserts a separator into a menu at a specified position USAGE menu_insert_separator (position, parent_menu) Int_Type/String_Type position; String_Type parent_menu; DESCRIPTION The `menu_insert_separator' function inserts a separator into a pre-existing popup menu or menu bar with name given by `parent_menu'. The insertion position may be specified as an integer, or as the name of a menu item within `parent_menu'. When specified as an integer, the insertion will take place at the corresponding position of the menu, where zero denotes the first item. If the position specifier is the name of a menu item, the the insertion will take place before that item. SEE ALSO menu_append_separator, menu_insert_item, menu_insert_popup -------------------------------------------------------------- menu_select_menu SYNOPSIS Select a menu item USAGE menu_select_menu (String_Type menu) DESCRIPTION This function allows interpreter access to a specified menu it. If the parameter specifies a popup menu, then the corresponding menu will be invoked. Otherwise the function bound to the specified menu will be called. EXAMPLE menu_select_menu ("Global.&File"); menu_select_menu ("Global.&File.Save &Buffers"); SEE ALSO menu_insert_item -------------------------------------------------------------- menu_set_init_menubar_callback SYNOPSIS Set the initialize menu bar callback USAGE menu_set_init_menubar_callback (Ref_Type cb) DESCRIPTION The `menu_set_init_menubar_callback' may be used to specify the function that is to be called whenever a menu bar may need to be updated. This may be necessary when the user switches buffers or modes. The callback function must accept a single argument which is the name of the menubar. SEE ALSO menu_set_select_menubar_callback, menu_create_menu_bar -------------------------------------------------------------- menu_set_menu_bar_prefix SYNOPSIS Set the prefix string to be displayed on the menu bar USAGE menu_set_menu_bar_prefix (String_Type menubar, String_Type prefix) DESCRIPTION The `menu_set_menu_bar_prefix' specifies the string that is to be displayed on the specified menu bar. The default prefix is `"F10 key ==> "'. SEE ALSO menu_create_menu_bar -------------------------------------------------------------- menu_set_object_available SYNOPSIS Set the availablity of a menu item USAGE menu_set_object_available (String_Type menuitem, Int_Type flag) DESCRIPTION The `menu_set_object_available' function may be used to activate or inactivate the specified menu item, depending upon whether `flag' is non-zero or zero, respectively. SEE ALSO menu_append_item -------------------------------------------------------------- menu_set_select_menubar_callback SYNOPSIS Set the function to be called when the menu bar is activated USAGE menu_set_select_menubar_callback (String_Type menubar, Ref_Type f) DESCRIPTION The `menu_set_select_menubar_callback' function is used to indicate that the function whose reference is `f' should be called whenever the menu bar is selected. The callback function is called with one argument: the name of the menu bar. SEE ALSO menu_set_init_menubar_callback, menu_set_select_popup_callback -------------------------------------------------------------- menu_set_select_popup_callback SYNOPSIS Specify the function to be called prior to a popup USAGE menu_set_select_popup_callback (String_Type popup, Ref_Type f DESCRIPTION The `menu_set_select_popup_callback' function may be used to specify a function that should be called just before a popup menu is displayed. The callback function must be defined to take a single argument, namely the name of the popup menu. The basic purpose of this function is to allow the creation of a dynamic popup menu. For this reason, the popup menu will have its items deleted before the callback function is executed. SEE ALSO menu_set_select_menubar_callback, menu_append_item -------------------------------------------------------------- menu_use_menu_bar SYNOPSIS Associate a menu bar with the current buffer USAGE menu_use_menu_bar (String_Type menubar) DESCRIPTION The `menu_use_menu_bar' function may be used to associate a specified menu bar with the current buffer. If no menu bar has been associated with a buffer, the `"Global"' menu bar will be used. SEE ALSO menu_create_menu_bar -------------------------------------------------------------- set_top_status_line SYNOPSIS Set the string to be displayed at the top of the display USAGE String set_top_status_line (String str); DESCRIPTION This functions sets the string to be displayed at the top of the display. It returns the value of the line that was previously displayed. SEE ALSO enable_top_status_line -------------------------------------------------------------- MESSAGE_BUFFER SYNOPSIS The Contents of the Message Buffer USAGE String_Type MESSAGE_BUFFER DESCRIPTION The `MESSAGE_BUFFER' variable is a read-only string variable whose value indicates the text to be displayed or is currently displayed in the message buffer. SEE ALSO message, vmessage, error, verror -------------------------------------------------------------- beep SYNOPSIS Beep (according to the value of `IGNORE_BEEP') USAGE Void beep (); DESCRIPTION The `beep' function causes the terminal to beep according to the value of the variable `IGNORE_BEEP'. SEE ALSO tt_send SEE ALSO IGNORE_BEEP -------------------------------------------------------------- clear_message SYNOPSIS Clear the message line of the display USAGE Void clear_message (); DESCRIPTION This function may be used to clear the message line of the display. SEE ALSO message, update, error, flush -------------------------------------------------------------- flush SYNOPSIS Immediately display "msg" as a message in the mini-buffer USAGE Void flush (String msg); DESCRIPTION The `flush' function behaves like `message' except that it immediately displays its argument `msg' as a message in the mini-buffer. That is, it is not necessary to call `update' to see the message appear. SEE ALSO message, error -------------------------------------------------------------- tt_send SYNOPSIS Send "s" directly to the terminal USAGE Void tt_send (String s); DESCRIPTION This function may be used to send a string specified by `s' directly to the terminal with no interference by the editor. One should exercise caution when using this routine since it may interfere with JED's screen management routines forcing one to redraw the screen. Nevertheless, it can serve a useful purpose. For example, when run in an XTerm window, using tt_send ("\e[?9h"); will enable sending mouse click information to JED encoded as keypresses. SEE ALSO beep -------------------------------------------------------------- MINIBUFFER_ACTIVE SYNOPSIS Non-zero is the mini-buffer is in use USAGE Int_Type MINIBUFFER_ACTIVE DESCRIPTION The `MINIBUFFER_ACTIVE' variable will be non-zero if the mini-buffer is in use. SEE ALSO read_mini -------------------------------------------------------------- _add_completion SYNOPSIS "add_completion" for "n" names "f1", ... "fn" USAGE Void _add_completion (String f1, String f2, ..., Integer n); DESCRIPTION The `_add_completion' function is like the `add_completion' function except that it takes `n' names `f1', ... `fn'. For example, _add_completion ("fun_a", "fun_b", 2); is equivalent to add_completion ("fun_a"); add_completion ("fun_b"); SEE ALSO add_completion -------------------------------------------------------------- add_completion SYNOPSIS Add the function "f" to the list for mini-buffer completion USAGE Void add_completion(String f); DESCRIPTION The `add_completion' function adds the user defined S-Lang function with name specified by the string `f' to the list of functions that are eligible for mini-buffer completion. The function specified by `f' must be already defined before this function is called. The S-Lang function `is_defined' may be used to test whether or not the function is defined. SEE ALSO read_with_completion, _add_completion -------------------------------------------------------------- get_mini_response SYNOPSIS Prompt for a key USAGE Int_Type get_mini_response (String_Type str) DESCRIPTION The `get_mini_response' function display the text `str' at the bottom of the screen and waits for the user to press a key. The key is returned. SEE ALSO read_mini, getkey, flush -------------------------------------------------------------- get_y_or_n SYNOPSIS Prompt for a y or n response USAGE Int_Type get_y_or_n (String_Type str) DESCRIPTION The `get_y_or_n' function forms a y/n question by concatenating `"? (y/n)"' to `str' and displays the result at the bottom of the display. It returns 1 if the user responds with `y', 0 with `n', or `-1' if the user cancelled the prompt. SEE ALSO get_yes_no, get_mini_response -------------------------------------------------------------- get_yes_no SYNOPSIS Get a yes or no response from the user USAGE Integer get_yes_no (String s); DESCRIPTION This function may be used to get a yes or no response from the user. The string parameter `s' will be used to construct the prompt by concating the string `"? (yes/no)"' to `s'. It returns `1' if the answer is yes or `0' if the answer is no. SEE ALSO getkey, flush, message -------------------------------------------------------------- read_mini SYNOPSIS Read input from the mini-buffer USAGE String read_mini (String prompt, String dflt, String init); DESCRIPTION The `read_mini' function reads a line of input from the user in the mini-buffer. The first parameter, `prompt', is used to prompt the user. The second parameter, `dflt', is what is returned as a default value if the user simply presses the return key. The final parameter, `init', is stuffed into the mini-buffer for editing by the user. For example, define search_whole_buffer () { variable str; str = read_mini ("Search for:", "", ""); !if (strlen (str)) return; !if (fsearch (str)) { push_mark (); bob (); if (fsearch (str)) pop_mark (0); else pop_mark (1); { pop_mark (1); error ("Not found"); } } } reads a string from the user and then searches forward for it and if not found, it resumes the search from the beginning of the buffer. NOTES If the user aborts the function `mini_read' by pressing the keyboard quit character (e.g., Ctrl-G), an error is signaled. This error can be caught by a `try'-`catch' statement and the appropriate action taken. Also if the mini-buffer is already in use, this function should not be called. The variable `MINIBUFFER_ACTIVE' may be checked to determine if this is the case or not. SEE ALSO read_with_completion, getkey, input_pending SEE ALSO MINIBUFFER_ACTIVE -------------------------------------------------------------- read_with_completion SYNOPSIS Read input from the minibuffer (with completion) USAGE Void read_with_completion (String prt, String dflt, String s, Integer type); DESCRIPTION This function may be used to read one of the objects specified by the last parameter `type'. The first parameter, `prt', is used as a prompt, the second parameter, `dflt', is used to specify a default, and the third parameter, `s', is used to initialize the string to be read. `type' is an integer with the following meanings: 'f' file name 'b' buffer name 'F' function name 'V' variable name. Finally, if `type' has the value `'s'', then the set of completions will be defined by a zeroth parameter, `list', to the function call. This parameter is simple a comma separated list of completions. For example, read_with_completion ("Larry,Curly,Moe", "Favorite Stooge:", "Larry", "", 's'); provides completion over the set of three stooges. The function returns the string read. SEE ALSO read_mini -------------------------------------------------------------- set_expansion_hook SYNOPSIS Specify a function to expand a filename upon TAB completion USAGE Void set_expansion_hook (String fname); DESCRIPTION This function may be used to specify a function that will be called to expand a filename upon TAB completion. The function `fname' must already be defined. When `fname' is called, it is given a string to be expanded. If it changes the string, it must return a non-zero value and the modified string. If the string is not modified, it must simply return zero. -------------------------------------------------------------- BATCH SYNOPSIS Non-Zero if in Batch Mode USAGE Int_Type BATCH (read-only) DESCRIPTION The value of `BATCH' will be 0 if the editor is run in interactive or full-screen mode. It will be 1 if the editor is in batch mode (via the `-batch' comment line argument). If the editor is in script mode (via `-script'), then the value of `BATCH' will be 2. -------------------------------------------------------------- JED_ROOT SYNOPSIS Location of the JED root directory USAGE String_Type JED_ROOT DESCRIPTION This is a read-only string variable whose value indicates JED's root directory. This variable may be set using the `JED_ROOT' environment variable. SEE ALSO get_jed_library_path, set_jed_library_path, getenv -------------------------------------------------------------- _jed_secure_mode (read-only) SYNOPSIS Indicates if the editor is in secure mode USAGE Int_Type _jed_secure_mode DESCRIPTION The value of `_jed_secure_mode' will be non-zero if the editor is running in secure mode. This mode does not allow any access to the shell. SEE ALSO system -------------------------------------------------------------- _jed_version SYNOPSIS The JED version number USAGE Int_Type _jed_version DESCRIPTION The value of `_jed_version' represents the version number of the editor. SEE ALSO _jed_version_string, _slang_version -------------------------------------------------------------- _jed_version_string SYNOPSIS The JED version number as a string USAGE String_Type _jed_version_string DESCRIPTION The value of `_jed_version_string' represents the version number of the editor. SEE ALSO _jed_version, _slang_version_string -------------------------------------------------------------- call SYNOPSIS Execute an internal function USAGE Void call(String f) DESCRIPTION The `call' function is used to execute an internal function which is not directly accessable to the S-Lang interpreter. SEE ALSO is_internal -------------------------------------------------------------- core_dump SYNOPSIS Exit the editor dumping the state of some crucial variables USAGE Void core_dump(String msg, Integer severity) DESCRIPTION `core_dump' will exit the editor dumping the state of some crucial variables. If `severity' is `1', a core dump will result. Immediately before dumping, `msg' will be displayed. SEE ALSO exit, exit_jed, quit_jed, message, error -------------------------------------------------------------- define_word SYNOPSIS Define the set of characters that form a word USAGE Void define_word (String s) DESCRIPTION This function is used to define the set of characters that form a word. The string `s' consists of those characters or ranges of characters that define the word. For example, to define only the characters `A-Z' and `a-z' as word characters, use: define_word ("A-Za-z"); To include a hyphen as part of a word, it must be the first character of the control string `s'. So for example, define_word ("-i-n"); defines a word to consist only of the letters `i' to `n' and the hyphen character. -------------------------------------------------------------- exit SYNOPSIS Exit the editor gracefully with a status value USAGE exit (Int_Type status) DESCRIPTION This function performs the same actions as `exit_jed' except that the status code returned to the shell may be specified. SEE ALSO _exit, exit_jed -------------------------------------------------------------- exit_jed SYNOPSIS Exit JED in a graceful and safe manner USAGE Void exit_jed () DESCRIPTION This function should be called to exit JED in a graceful and safe manner. If any buffers have been modified but not saved, the user is queried about whether or not to save each one first. `exit_jed' calls the S-Lang hook `exit_hook' if it is defined. If `exit_hook' is defined, it must either call `quit_jed' or `exit_jed' to really exit the editor. If `exit_jed' is called from `exit_hook', `exit_hook' will not be called again. For example: define exit_hook () { flush ("Really Exit?"); forever { switch (getkey () & 0x20) % map to lowercase { case 'y': exit_jed (); } { case 'n': return; } beep (); } } may be used to prompt user for confirmation of exit. SEE ALSO exit, quit_jed, suspend, flush, getkey SEE ALSO BATCH -------------------------------------------------------------- get_last_macro SYNOPSIS Return characters composing the last keyboard macro USAGE String get_last_macro () DESCRIPTION This function returns characters composing the last keyboard macro. The charactors that make up the macro are encoded as themselves except the following characters: '\n' ----> \J null ----> \@ \ ----> \\ '"' ----> \" -------------------------------------------------------------- get_passwd_info SYNOPSIS Return information about the user "username" USAGE (dir, shell, pwd, uid, gid) = get_passwd_info (String username) DESCRIPTION This function returns password information about the user with name `username'. The returned variables have the following meaning: dir: login directory shell: login shell pwd: encripted password uid: user identification number gid: group identification number If the user does not exist, or the system call fails, the function returns with `uid' and `gid' set to `-1'. -------------------------------------------------------------- getpid SYNOPSIS Return the process identification number for the editor USAGE Integer getpid () DESCRIPTION This function returns the process identification number for the current editor process. -------------------------------------------------------------- is_internal SYNOPSIS Test if function "f" is defined as an internal function USAGE Integer is_internal(String f) DESCRIPTION `is_internal' returns non-zero is function `f' is defined as an internal function or returns zero if not. Internal functions not immediately accessable from S-Lang; rather, they must be called using the `call' function. See also the related S-Lang function `is_defined' in the S-Lang Programmer's Reference. SEE ALSO call -------------------------------------------------------------- quit_jed SYNOPSIS Quit the editor immediately: no autosave, no hooks USAGE Void quit_jed ([ status ]) DESCRIPTION This function quits the editor immediately without saving any buffers and without any exit hooks called. The function `exit_jed' should be called when it is desired to exit in a safe way. The exit status of the program may be specified via the optional integer argument. If called with no argument, a value of 0 will be used as the exit status. SEE ALSO exit_jed -------------------------------------------------------------- random SYNOPSIS Return a random number in the range [0, "nmax"[ USAGE Integer random (Integer seed, Integer nmax) DESCRIPTION The `random' function returns a random number in the range 0 to, but not including, `nmax'. If the first parameter `seed' is 0, the number generated depends on a previous seed. If `seed' is -1, the current time and process id will be used to seed the random number generator; otherwise `seed' will be used. Example: generate 1000 random integers in the range 0-500 and insert them into buffer: () = random (-1, 0); % seed generator usingtime and pid loop (1000) insert (Sprintf ("%d\n", random (0, 500), 1)); Note: The random number is generated via the expression: r = r * 69069UL + 1013904243UL; -------------------------------------------------------------- set_line_readonly SYNOPSIS Turn on or off the read-only state of the current line USAGE Void set_line_readonly (Integer flag) DESCRIPTION This function may be used to turn on or off the read-only state of the current line. If the integer parameter `flag' is non-zero, the line will be made read-only. If the paramter is zero, the read-only state will be turned off. SEE ALSO getbuf_info -------------------------------------------------------------- set_undo_position SYNOPSIS Add the current position to the undo stack USAGE set_undo_position () DESCRIPTION This function adds the current position to the buffer's undo stack. Ocassionally this may be necessary when using `narrow_to_region' to prevent the cursor from moving to the beginning or the end of a previously narrowed region during "undo". SEE ALSO narrow_to_region -------------------------------------------------------------- suspend SYNOPSIS Suspend the editor USAGE Void suspend () DESCRIPTION The action of this command varies with the operating system. Under Unix, the editor will be suspended and control will pass to the parent process. Under VMS and MSDOS, a new subprocess will be spawned. Before suspension, `suspend_hook' is called. When the editor is resumed, `resume_hook' will be called. These hooks are user-defined functions that take no arguments and return no values. -------------------------------------------------------------- usleep SYNOPSIS Pause for "ms" milliseconds USAGE Void usleep (Integer ms) DESCRIPTION A call to usleep will cause the editor to pause for `ms' milliseconds. SEE ALSO input_pending -------------------------------------------------------------- vms_get_help SYNOPSIS Interact with the VMS help system from within the editor USAGE Void vms_get_help (String hlp_file, String hlp_topic) DESCRIPTION This function may be used on VMS systems to interact with the VMS help system from within the editor. `hlp_file' is the name of the help file to use and `hlp_topic' is the topic for which help is desired. -------------------------------------------------------------- vms_send_mail SYNOPSIS interface to the VMS callable mail facility USAGE Integer vms_send_mail (String recip_lis, String subj) DESCRIPTION This VMS specific function provides an interface to the VMS callable mail facility. The first argument, `recip_lis', is a comma separated list of email addresses and `subj' is a string that represents the subject of the email. The current buffer will be emailed. It returns `1' upon success and `0' upon failure. -------------------------------------------------------------- gpm_disable_mouse SYNOPSIS Disable support for the GPM mouse USAGE gpm_disable_mouse () DESCRIPTION The `gpm_disable_mouse' function may be used to inactivate support for the GPM mouse. NOTES This function may not be available on all systems. SEE ALSO mouse_get_event_info -------------------------------------------------------------- mouse_get_event_info SYNOPSIS Return information about the last processed mouse event USAGE (x, y, state) = mouse_get_event_info () DESCRIPTION This function returns the position of the last processed mouse event, and the state of the mouse buttons and shift keys before the event. `x' and `y' represent the column and row, respectively, where the event took place. They are measured with relative to the top left corner of the editor's display. `state' is a bitmapped integer whose bits are defined as follows: 1 Left button pressed 2 Middle button pressed 4 Right button pressed 8 Shift key pressed 16 Ctrl key pressed Other information such as the button that triggered the event is available when the mouse handler is called. As a result, this information is not returned by `mouse_get_event_info'. SEE ALSO mouse_set_default_hook, set_buffer_hook. -------------------------------------------------------------- mouse_map_buttons SYNOPSIS Map one mouse button to another USAGE Void mouse_map_buttons (Integer x, Integer y) DESCRIPTION This function may be used to map one mouse button to another. The button represented by `x' will appear as `y'. -------------------------------------------------------------- mouse_set_current_window SYNOPSIS Change to the window to that of the the mouse event USAGE Void mouse_set_current_window () DESCRIPTION Use of this function results in changing windows to the window that was current at the time of the mouse event. SEE ALSO mouse_set_default_hook -------------------------------------------------------------- mouse_set_default_hook SYNOPSIS Associate a function "fun" with the mouse event "name" USAGE Void set_default_mouse_hook (String name, String fun) DESCRIPTION This function associates a slang function `fun' with the mouse event specified by `name'. The first parameter `name' must be one of the following: "mouse_up" "mouse_status_up" "mouse_down" "mouse_status_down" "mouse_drag" "mouse_status_drag" "mouse_2click" "mouse_status_2click" "mouse_3click" "mouse_status_3click" The meaning of these names should be obvious. The second parameter, `fun' must be defined as define fun (line, column, btn, shift) and it must return an integer. The parameters `line' and `column' correspond to the line and column numbers in the buffer where the event took place. `btn' is an integer that corresonds to the button triggering the event. It can take on values `1', `2', and `4' corresponding to the left, middle, and right buttons, respectively. `shift' can take on values `0', `1', or `2' where `0' indicates that no modifier key was pressed, `1' indicates that the SHIFT key was pressed, and `2' indicates that the CTRL key was pressed. For more detailed information about the modifier keys, use the function `mouse_get_event_info'. When the hook is called, the editor will automatically change to the window where the event occured. The return value of the hook is used to dictate whether or not hook handled the event or whether the editor should switch back to the window prior to the event. Specifically, the return value is interpreted as follows: -1 Event not handled, pass to default hook. 0 Event handled, return active window prior to event 1 Event handled, stay in current window. SEE ALSO mouse_get_event_info, mouse_set_current_window, set_buffer_hook -------------------------------------------------------------- Skip past all word characters SYNOPSIS bskip_word_chars USAGE Void bskip_word_chars () DESCRIPTION This function moves the current editing point backward past all word characters until a non-word character is encountered. Characters that make up a word are set by the `define_word' function. SEE ALSO define_word, skip_word_chars, bskip_chars, bskip_non_word_chars -------------------------------------------------------------- _get_point SYNOPSIS Get the current offset from the beginning of the line USAGE Int_Type _get_point () DESCRIPTION The `_get_point' function returns the current character offset fro the beginning of the line. SEE ALSO _set_point, what_column -------------------------------------------------------------- _set_point SYNOPSIS Move to a specified offset from the beginning of the line USAGE _set_point (Int_Type nth) DESCRIPTION The `_set_point' function moves the current editing position to the `nth' character of the current line. SEE ALSO _get_point, goto_column -------------------------------------------------------------- backward_paragraph SYNOPSIS Move backward to a line that is a paragraph separator USAGE Void backward_paragraph () DESCRIPTION This function moves the current editing point backward past the current paragraph to the line that is a paragraph separator. Such a line is determined by the S-Lang hook `is_paragraph_separator'. This hook can be modified on a buffer by buffer basis by using the function `set_buffer_hook'. SEE ALSO forward_paragraph, set_buffer_hook -------------------------------------------------------------- bob SYNOPSIS Go to the beginning of the buffer USAGE Void bob () DESCRIPTION The function `bob' is used to move the current editing point to the beginning of the buffer. The function `bobp' may be used to determine if the editing point is at the beginning of the buffer or not. SEE ALSO bobp, eob, bol, eol -------------------------------------------------------------- bol SYNOPSIS Go to the beginning of the line USAGE Void bol() DESCRIPTION This function moves the current editing point to the beginning of the current line. The function `bolp' may be used to see if one is already at the beginning of a line. SEE ALSO eol, bob, eob, bolp -------------------------------------------------------------- bskip_chars SYNOPSIS Skip past all characters defined by string "str" USAGE Void bskip_chars (String str) DESCRIPTION This function may be used to skip past all characters defined by the string `str'. See `skip_chars' for the definition of `str'. The following example illustrates how to skip past all whitespace including newline characters: bskip_chars (" \t\n"); SEE ALSO skip_chars, left -------------------------------------------------------------- bskip_non_word_chars SYNOPSIS Skip past all non-word characters USAGE Void bskip_word_chars () DESCRIPTION This function moves the current editing point backward past all non-word characters until a word character is encountered. Characters that make up a word are set by the `define_word' function. SEE ALSO define_word, skip_non_word_chars, bskip_chars, bskip_word_chars -------------------------------------------------------------- down SYNOPSIS Move the editing point "n" lines down USAGE Integer down(Integer n) DESCRIPTION The `down' function is used to move the editing point down a number of lines specified by the integer `n'. It returns the number of lines actually moved. The number returned will be less than `n' only if the last line of the buffer has been reached. The editing point will be left at the beginning of the line if it succeeds in going down more than one line. Example: The function define trim_buffer { bob (); do { eol (); trim (); } while (down (1)); } removes excess whitespace from the end of every line in the buffer. SEE ALSO down, left, right, goto_line -------------------------------------------------------------- eob SYNOPSIS Move to the end of the buffer USAGE Void eob() DESCRIPTION The `eob' function is used to move the current point to the end of the buffer. The function `eobp' may be used to see if the current position is at the end of the buffer. SEE ALSO eobp, bob, bol, eol -------------------------------------------------------------- eol SYNOPSIS Go to the end of the line USAGE Void eol() DESCRIPTION Moves the current position to the end of the current line. The function `eolp' may be used to see if one is at the end of a line or not. SEE ALSO eolp, bol, bob, eob -------------------------------------------------------------- forward_paragraph SYNOPSIS Go to the end of the current paragraph USAGE Void forward_paragraph () DESCRIPTION This function moves the current editing point forward past the end of the current paragraph. Paragraph delimiters are defined through either a buffer hook or via the hook `is_paragraph_separator'. SEE ALSO backward_paragraph, set_buffer_hook -------------------------------------------------------------- goto_column SYNOPSIS Move to the column "n" USAGE Void goto_column (Integer n) DESCRIPTION This function moves the current editing point to the column specified by the parameter `n'. It will insert a combination of spaces and tabs if necessary to achieve the goal. Note: The actual character number offset from the beginning of the line depends upon tab settings and the visual expansion of other control characters. SEE ALSO goto_column_best_try, what_column, left, right, goto_line SEE ALSO TAB,TAB_DEFAULT,DISPLAY_EIGHT_BIT -------------------------------------------------------------- goto_column_best_try SYNOPSIS like "goto_column" but don't insert whitespace USAGE Integer goto_column_best_try (Integer c) DESCRIPTION This function is like `goto_column' except that it will not insert whitespace. This means that it may fail to achieve the column number specified by the argument `c'. It returns the current column number. SEE ALSO goto_column, what_column -------------------------------------------------------------- goto_line SYNOPSIS Go to line number "n" USAGE Void goto_line (Integer n) DESCRIPTION The `goto_line' function may be used to move to a specific line number specified by the parameter `n'. Note: The actual column that the editing point will be left in is indeterminate. SEE ALSO what_line, goto_column, down, up. -------------------------------------------------------------- left SYNOPSIS Move the editing point backward "n" characters USAGE Integer left(Integer n) DESCRIPTION `left' moves the editing point backward `n' characters and returns the number actually moved. The number returned will be less than `n' only if the top of the buffer is reached. SEE ALSO right, up, down, bol, bob -------------------------------------------------------------- right SYNOPSIS Move the editing position forward forward "n" characters USAGE Integer right(Integer n) DESCRIPTION This function moves the editing position forward forward `n' characters. It returns the number of characters actually moved. The number returned will be smaller than `n' if the end of the buffer is reached. SEE ALSO left, up, down, eol, eob -------------------------------------------------------------- skip_chars SYNOPSIS Go forward past all characters defined by "s" USAGE Void skip_chars(String s) DESCRIPTION This fnction may be used to move the editing point forward past all characters in string `s' which contains the chars to skip, or a range of characters. A character range is denoted by two charcters separated by a hyphen. If the first character of the string `s' is a `'^'' character, then the list of characters actually denotes the complement of the set of characters to be skipped. To explicitly include the hyphen character in the list, it must be either the first or the second character of the string, depending upon whether or not the `'^'' character is present. So for example, skip_chars ("- \t0-9ai-o_"); will skip the hyphen, space, tab, numerals `0' to `9', the letter `a', the letters `i' to `o', and underscore. An example which illustrates the complement of a range is skip_chars("^A-Za-z"); which skips all characters except the letters. Note: The backslash character may be used to escape only the first character in the string. That is, `"\\^"' is to be used to skip over `^' characters. SEE ALSO bskip_chars, skip_white -------------------------------------------------------------- skip_non_word_chars SYNOPSIS Go forward until a word character is encountered USAGE Void skip_non_word_chars () DESCRIPTION This function moves the current editing point forward past all non-word characters until a word character is encountered. Characters that make up a word are set by the `define_word' function. SEE ALSO define_word, skip_word_chars, skip_chars, bskip_non_word_chars -------------------------------------------------------------- skip_white SYNOPSIS Go forward until a non-whitespace character or the end of the line USAGE Void skip_white () DESCRIPTION The `skip_white' function moves the current point forward until it reaches a non-whitespace character or the end of the current line, whichever happens first. In this context, whitespace is considered to be any combination of space and tab characters. To skip newline characters as well, the function `skip_chars' may be used. SEE ALSO bskip_chars, what_char, trim, right -------------------------------------------------------------- skip_word_chars SYNOPSIS Go forward until a non-word character is encountered USAGE Void skip_word_chars () DESCRIPTION This function moves the current editing point forward across all characters that constitute a word until a non-word character is encountered. Characters that make up a word are set by the `define_word' function. SEE ALSO define_word, skip_non_word_chars, skip_chars, bskip_word_chars -------------------------------------------------------------- up SYNOPSIS Go up "n" lines USAGE Integer up(Integer n) DESCRIPTION This function moves the current point up `n' lines and returns the number of lines actually moved. The number returned will be less than `n' only if the top of the buffer is reached. SEE ALSO down, left, right -------------------------------------------------------------- get_process_input SYNOPSIS Read all pending input by all subprocesses USAGE Void get_process_input (Int_Type tsecs) DESCRIPTION Read all pending input by all subprocesses. If no input is available, this function will wait for input until `tsecs' tenth of seconds have expired. SEE ALSO open_process, kill_process -------------------------------------------------------------- get_process_flags SYNOPSIS Get the flags associated with a process USAGE Int_Type get_process_flags (Int_Type id) DESCRIPTION This function returns the flags associated with the current process. The `set_process_flags' may be used to set the flags. SEE ALSO open_process, set_process_flags -------------------------------------------------------------- kill_process SYNOPSIS Kill the subprocess specified by the process handle "id" USAGE Void kill_process (Int_Type id) DESCRIPTION Kill the subprocess specified by the process handle `id' SEE ALSO open_process -------------------------------------------------------------- open_process SYNOPSIS Open a process and return a unique process id USAGE Int_Type open_process (name, argv1, argv2, ..., argvN, N) DESCRIPTION Open subprocess `name'. Returns id of process, -1 upon failure. SEE ALSO kill_process, process_mark, process_query_at_exit -------------------------------------------------------------- process_mark SYNOPSIS Return user mark for the position of the last output by the process USAGE User_Mark process_mark (Int_Type id) DESCRIPTION This function returns the user mark that contains the position of the last output by the process. -------------------------------------------------------------- process_query_at_exit SYNOPSIS Whether or not to silently kill a process at exit USAGE Void process_query_at_exit (Int_Type pid, Int_Type query) DESCRIPTION The `process_query_at_exit' may be used to specify whether or not the process specified by `pid' should be silently ignored when the editor exits. If the parameter `query' is non-zero, the user will be reminded the process exists before exiting. SEE ALSO open_process, kill_process, exit_jed -------------------------------------------------------------- run_program SYNOPSIS Run another program in a window USAGE Int_Type run_program (String_Type pgm) DESCRIPTION Like the `system' function, the `run_program' function may be used to execute another program. However, this function is more useful for executing interactive programs that require some sort of display manipulation, e.g., `lynx', the text-mode web browser. When called from `xjed', the other program is executed asynchronously in a separate xterm window. If the editor is running in an ordinary terminal, `jed' will be suspended while the other program runs. The function returns the exit value of the invoked process. EXAMPLE if (0 != run_program ("lynx http://www.jedsoft.org")) error ("lynx failed to run"); NOTES The `XTerm_Pgm' variable may be used to specify the terminal that `xjed' uses when calling `run_program'. For example, to use `rxvt', use: variable XTerm_Pgm = "rxvt"; SEE ALSO system, open_process -------------------------------------------------------------- run_shell_cmd SYNOPSIS Run "cmd" in a separate process USAGE Integer_Type run_shell_cmd (String cmd) DESCRIPTION The `run_shell_cmd' function may be used to run `cmd' in a separate process. Any output generated by the process is inserted into the buffer at the current point. It generates a S-Lang error if the process specified by `cmd' could not be opened. Otherwise, it returns the exit status of the process. -------------------------------------------------------------- send_process SYNOPSIS Send a string to the specified subprocess USAGE Void send_process (Int_Type id, String s) DESCRIPTION This function sends the string `s' to the standard input of the process with the ID `id'. With this function and `set_process' with the argument `output'' you can establish a bi-directional communication with the process. SEE ALSO open_process, set_process, send_process_eof -------------------------------------------------------------- send_process_eof SYNOPSIS Close the "stdin" of the process "id" USAGE send_process_eof (Int_Type id) DESCRIPTION This function closes the `stdin' of the process specified by the handle `id'. -------------------------------------------------------------- set_process SYNOPSIS Set "what" for process "pid" USAGE Void set_process (pid, what, value) Int_Type pid; String_Type what; String_Type or Ref_Type value; DESCRIPTION `pid' is the process handle returned by `open_process'. The second parameter, `what', specifies what to set. It must be one of the strings: "signal" : indicates that 'value' is the name of a function to call when the process status changed. The function specified by 'value' must be declared to accept an argument list: (pid, flags, status) where 'pid' has the same meaning as above and flags is an integer with the meanings: 1: Process Running 2: Process Stopped 4: Process Exited Normally 8: Process Exited via Signal The meaning of the status parameter depends upon the flags parameter. If the process exited normally, then status indicates its return status. Otherwise status represents the signal that either stopped or killed the process. Note: when this function is called, the current buffer is guaranteed to be the buffer associated with the process. "output" : This parameter determines how output from the process is is processed. If the 'value' is the empty string "", output will go to the end of the buffer associated with the process and the point will be left there. If value is ".", output will go at the current buffer position. If value is "@", output will go to the end of the buffer but the point will not move. Otherwise, 'value' is the name or a reference to a slang function that takes arguments: (pid, data) where pid has the above meaning and data is the output from the process. Normally jed automatically switches to the buffer associated with the process prior to handling data from the process. This behavior may be modified through the use of the `set_process_flags' function. SEE ALSO set_process_flags, get_process_flags, open_process -------------------------------------------------------------- set_process_flags SYNOPSIS Set the flags associated with a process USAGE set_process_flags (Int_Type id, Int_Type flags) DESCRIPTION This function may be used to set the flags associated with the specified process. The flags may be used to affect the behavior of the process. Currently the following bits are defined: 0x01 Do not switch to the process buffer prior to calling any hooks associated with the buffer including output from the process. SEE ALSO open_process, get_process_flags, set_process -------------------------------------------------------------- signal_process SYNOPSIS Send a signal to the process "pid" USAGE Void signal_process (Int_Type pid, Int_Type signum) DESCRIPTION This function may be used to send a signal to the process whose process handle is given by `pid'. The `pid' must be a valid handle that was returned by `open_process'. SEE ALSO open_process, kill_process, send_process_eof -------------------------------------------------------------- Replace all text in the rectangle by spaces SYNOPSIS Replace the rectangle defined by point and mark with spaces USAGE Void blank_rect () DESCRIPTION The `blank_rect' function replaces all text in the rectangle defined by the current editing point and the mark by spaces. SEE ALSO push_mark, kill_rect, insert_rect, copy_rect -------------------------------------------------------------- copy_rect SYNOPSIS Copy the contents of the rectangle to the rectangle buffer USAGE Void copy_rect () DESCRIPTION The `copy_rect' function is used to copy the contents of the currently defined rectangle to the rectangle buffer. It overwrites the previous contents of the rectangle buffer. A rectangle is defined by the diagonal formed by the mark and the current point. SEE ALSO insert_rect, kill_rect, blank_rect -------------------------------------------------------------- insert_rect SYNOPSIS Insert the contents of the rectangle buffer USAGE insert_rect () DESCRIPTION The `insert_rect' function inserts the contents of the rectangle buffer at the current editing point. The rectangle buffer is not modified. Any text that the rectangle would overwrite is moved to the right by an amount that is equal to the width of the rectangle. SEE ALSO kill_rect, blank_rect, copy_rect -------------------------------------------------------------- kill_rect SYNOPSIS Delete the rectangle and place a copy in the rectangle buffer USAGE Void kill_rect () DESCRIPTION This function deletes the rectangle defined by the mark and the current point. The contents of the rectangle are saved in the rectangle buffer for later retrieval via the `insert_rect' function. The previous contents of the rectangle buffer will be lost. SEE ALSO insert_rect, blank_rect, copy_rect -------------------------------------------------------------- open_rect SYNOPSIS Insert a blank rectangle determined by mark and point USAGE Void open_rect () DESCRIPTION The `open_rect' function may be used to insert a blank rectangle whose size is determined by the mark and the current editing point. Any text that lies in the region of the rectangle will be pushed to the right. SEE ALSO insert_rect, kill_rect, copy_rect -------------------------------------------------------------- KILL_ARRAY_SIZE SYNOPSIS The size of the internal kill buffer array USAGE Int_Type KILL_ARRAY_SIZE DESCRIPTION This variable contains the value of the size of the internal kill array of character strings. Any number from zero up to but not including the value of `KILL_ARRAY_SIZE' may be used as an argument in the functions that manipulate this array. NOTES This variable is a read-only varaible and may not available on 16 bit systems. SEE ALSO insert_from_kill_array, copy_region_to_kill_array, append_region_to_kill_array -------------------------------------------------------------- append_region_to_file SYNOPSIS Append the region to "file" USAGE Integer append_region_to_file (String file) DESCRIPTION Appends a marked region to `file' returning number of lines written or -1 on error. This does NOT modify a buffer visiting the file; however, it does flag the buffer as being changed on disk. -------------------------------------------------------------- append_region_to_kill_array SYNOPSIS Append the region to the element "n" of the kill array USAGE Void append_region_to_kill_array (Integer n) DESCRIPTION This function appends the currently defined region to the contents of nth element, specified by `n', of an internal array of character strings. Note: This function is not available on 16 bit systems. SEE ALSO insert_from_kill_array, copy_region_to_kill_array SEE ALSO KILL_ARRAY_SIZE -------------------------------------------------------------- bufsubstr SYNOPSIS Return the region as a string USAGE String bufsubstr () DESCRIPTION This function returns a string that contains the characters in the region specified by a mark and the current editing point. If the region crosses lines, the string will contain newline characters. SEE ALSO insbuf, push_mark -------------------------------------------------------------- check_region SYNOPSIS Test if a region is defined and ensure the mark comes before point USAGE Void check_region (Integer ps) DESCRIPTION This function checks to see if a region is defined and may exchange the current editing point and the mark to define a canonical region. If the mark is not set, it signals an S-Lang error. A canonical region is one with the mark set earlier in the buffer than than the editing point. Always call this if using a region which requires such a situation. If the argument `ps' is non-zero, `push_spot' will be called, otherwise, `ps' is zero and it will not be called. As an example, the following function counts the number of lines in a region: define count_lines_region () { variable n; check_region (1); % spot pushed narrow (); n = what_line (); widen (); pop_spot (); return n; } SEE ALSO markp, push_mark -------------------------------------------------------------- copy_region SYNOPSIS copy a region to the buffer "buf" USAGE Void copy_region (String buf) DESCRIPTION This function may be used to copy a region defined by a mark and the current position to the buffered specified by the name `buf'. It does not delete the characters in region but it does pop the mark that determines the region. SEE ALSO insbuf, bufsubstr, push_mark, pop_mark, bufferp -------------------------------------------------------------- copy_region_to_kill_array SYNOPSIS Copy the defined region to element "n" of the kill array USAGE Void copy_region_to_kill_array (Integer n) DESCRIPTION This function copies the currently defined region to the nth element, specified by `n', of an internal array of character strings replacing what is currently there. Note: This function is not available on 16 bit systems. SEE ALSO insert_from_kill_array, append_region_kill_array SEE ALSO KILL_ARRAY_SIZE -------------------------------------------------------------- count_narrows SYNOPSIS Return the narrow depth of the current buffer USAGE Integer count_narrows () DESCRIPTION This function returns the narrow depth of the current buffer. SEE ALSO narrow, widen, widen_buffer, push_narrow -------------------------------------------------------------- narrow SYNOPSIS Restict editing to the region (complete lines) USAGE Void narrow () DESCRIPTION This function may be used to restict editing to the region of lines between the mark and the editing point. The region includes the line containing the mark as well as the line at the current point. All other lines outside this region are completely inacessable without first lifting the restriction using the `widen' function. As a simple example, suppose that there is a function called `print_buffer' that operates on the entire buffer. Then the following function will work on a region of lines: define print_region () { narrow (); print_buffer (); widen (); } The `narrow' function will signal an error if the mark is not set. Note also that the narrow function may be used recursively in the sense that a narrowed region may be further restricted using the `narrow' function. For each narrow, the `widen' function must be called to lift each restriction. SEE ALSO widen, narrow_to_region -------------------------------------------------------------- narrow_to_region SYNOPSIS Restict editing exactly to the region USAGE Void narrow_to_region (void) DESCRIPTION The `narrow_to_region' function behaves like the `narrow' function that `narrow' operates on lines and `narrow_to_region' restricts editing to only characters within the region. SEE ALSO widen_region, narrow. -------------------------------------------------------------- pipe_region SYNOPSIS Execute "cmd" as subprocess and sends the region to its stdin USAGE Integer pipe_region (String cmd) DESCRIPTION The `pipe_region' function executes `cmd' in a separate process and sends the region of characters defined by the mark and the current point to the standard input of the process. It successful, it returns the exit status of the process. Upon failure it signals an error. Note: This function is only available for Unix and OS/2 systems. SEE ALSO run_shell_cmd, push_mark -------------------------------------------------------------- pop_narrow SYNOPSIS restore the last narrow context USAGE Void pop_narrow () DESCRIPTION The purpose of this function is to restore the last narrow context that was saved via `push_narrow'. SEE ALSO push_narrow, widen, widen_buffer -------------------------------------------------------------- push_narrow SYNOPSIS Save the current narrow context USAGE Void push_narrow () DESCRIPTION This function saves the current narrow context. This is useful when one wants to restore this context after widening the buffer. SEE ALSO pop_narrow, narrow, widen, widen_buffer -------------------------------------------------------------- translate_region SYNOPSIS translate the characters in the region according to "a" USAGE Void translate_region (String_Type[256] a) DESCRIPTION This function uses the 256 element array of strings to translate the characters in a region based on the mapping defined by the array. If an array element is `NULL', then the corresponding character will not be replaced. The `translate_region' function leaves the editing point at the end of the region. EXAMPLE variable a = String_Type[256]; a['&'] = "&"; a['<'] = "<"; a['>'] = ">"; a['$'] = "$"; bob (); push_mark (); eob (); translate_region (a); uses `translate_region' to replace the characters `'&'', `'<'', `'>'', and `'$'' by the strings `"&"', `"<"', `">"', and `"$"', respectively. SEE ALSO insert, delete, what_char, replace -------------------------------------------------------------- widen SYNOPSIS Undo the effect of "narrow" USAGE Void widen () DESCRIPTION This function undoes the effect of `narrow'. Consult the documentation for `narrow' for more information. SEE ALSO widen_region, narrow -------------------------------------------------------------- widen_buffer SYNOPSIS Widen the whole buffer USAGE Void widen_buffer () DESCRIPTION This function widens the whole buffer. If one intends to restore the narrow context after calling this function, the narrow context should be saved via `push_narrow'. SEE ALSO narrow, widen, push_narrow, pop_narrow -------------------------------------------------------------- widen_region SYNOPSIS Undo the effect of "narrow_to_region" USAGE Void widen_region () DESCRIPTION This function undoes the effect of `narrow_to_region'. Consult the documentation for `narrow_to_region' for more information. SEE ALSO widen, narrow_to_region -------------------------------------------------------------- write_region_to_file SYNOPSIS Write the region to the file "filename" USAGE Integer write_region_to_file (String filename) DESCRIPTION This function may be used to write a region of the current buffer to the file specified by `filename'. It returns the number of lines written to the file or signals an error upon failure. SEE ALSO write_buffer, append_region_to_file, push_mark -------------------------------------------------------------- xform_region SYNOPSIS Change the characters in the region according to "how" USAGE Void xform_region (Integer how) DESCRIPTION This function changes the characters in the region in a way specified by the parameter `how'. This is an integer that can be any of of the following: 'u' Upcase_region 'd' Downcase_region 'c' Capitalize region Anything else will change case of region. SEE ALSO translate_region, define_case -------------------------------------------------------------- CASE_SEARCH SYNOPSIS Control the case-sensitivity for searches in the current buffer USAGE Int_Type CASE_SEARCH DESCRIPTION If the value of `CASE_SEARCH' is non-zero, text searches performed in the current buffer will be case-sensitive, otherwise case-insensitive searches will be performed. The value of this variable may vary from buffer to buffer. SEE ALSO CASE_SEARCH_DEFAULT, fsearch, ffind -------------------------------------------------------------- CASE_SEARCH_DEFAULT SYNOPSIS The default CASE_SEARCH setting for newly created buffers USAGE Int_Type CASE_SEARCH_DEFAULT DESCRIPTION Searches in a buffer are performed according to the value of the `CASE_SEARCH' variable. Newly created buffers are given a `CASE_SEARCH' value of `CASE_SEARCH_DEFAULT'. The default value of `CASE_SEARCH_DEFAULT' is 0. SEE ALSO CASE_SEARCH, fsearch, ffind -------------------------------------------------------------- bfind SYNOPSIS Search backward to the beginning of the line USAGE Integer bfind (String str) DESCRIPTION `bfind' searches backward from the current position to the beginning of the line for the string `str'. If a match is found, the length of `str' is returned and the current point is moved to the start of the match. If no match is found, zero is returned. Note: This function respects the setting of the `CASE_SEARCH' variable. SEE ALSO bsearch, ffind, bol_bsearch, re_bsearch SEE ALSO CASE_SEARCH -------------------------------------------------------------- bfind_char SYNOPSIS Search backward on the current line for a character USAGE Integer fsearch_char (Integer ch) DESCRIPTION This function searches backward on the current line for a character `ch'. If it is found, `1' is returned; otherwise `0' is returned. SEE ALSO fsearch_char, ffind_char, fsearch SEE ALSO CASE_SEARCH -------------------------------------------------------------- bol_bsearch SYNOPSIS Search backward for "str" at the beginning of a line USAGE Integer bol_bsearch (str) DESCRIPTION `bol_bsearch' searches backward from the current point until the beginning of the buffer for the occurrences of the string `str' at the beginning of a line. If a match is found, the length of `str' is returned and the current point is moved to the start of the match. If no match is found, zero is returned. Note: `bol_bsearch' is much faster than using `re_bsearch' to perform a search that matches the beginning of a line. SEE ALSO bol_fsearch, bsearch, bfind, re_bsearch SEE ALSO CASE_SEARCH -------------------------------------------------------------- bol_bsearch_char SYNOPSIS Search backward for character "ch" at the beginning of a line USAGE Integer bol_fsearch_char (Integer ch) DESCRIPTION This function searches backward for a character `ch' at the beginning of a line. If it is found, `1' is returned; otherwise `0' is returned. SEE ALSO bol_bsearch, bol_fsearch_char, bsearch_char SEE ALSO CASE_SEARCH -------------------------------------------------------------- bol_fsearch SYNOPSIS Search forward for "str" at the beginning of a line USAGE Integer bol_fsearch (str) DESCRIPTION `bol_fsearch' searches forward from the current point until the end of the buffer for occurrences of the string `str' at the beginning of a line. If a match is found, the length of `str' is returned and the current point is moved to the start of the match. If no match is found, zero is returned. Note: `bol_fsearch' is much faster than using `re_fsearch' to perform a search that matches the beginning of a line. SEE ALSO bol_bsearch, fsearch, ffind, re_fsearch SEE ALSO CASE_SEARCH -------------------------------------------------------------- bol_fsearch_char SYNOPSIS Search forward for character "ch" at the beginning of a line USAGE Integer bol_fsearch_char (Integer ch) DESCRIPTION This function searches forward for a character `ch' at the beginning of a line. If it is found, `1' is returned; otherwise `0' is returned. SEE ALSO bol_fsearch, bol_bsearch_char, fsearch_char SEE ALSO CASE_SEARCH -------------------------------------------------------------- bsearch SYNOPSIS Search backward for "str" USAGE Integer bsearch (String str) DESCRIPTION The `bsearch' function searches backward from the current position for the string `str'. If `str' is found, this function will return the length of `str' and move the current position to the beginning of the matched text. If a match is not found, zero will be returned and the position will not change. It respects the value of the variable `CASE_SEARCH'. SEE ALSO fsearch, bol_bsearch, re_bsearch -------------------------------------------------------------- bsearch_char SYNOPSIS Search backward for a character USAGE Integer bsearch_char (Integer ch) DESCRIPTION This function searches backward for a character `ch'. If it is found, `1' is returned; otherwise `0' is returned. SEE ALSO fsearch_char, ffind_char, fsearch SEE ALSO CASE_SEARCH -------------------------------------------------------------- ffind SYNOPSIS Search forward to the end of the line for the string "str" USAGE Integer ffind (String s) DESCRIPTION `ffind' searches forward from the current position to the end of the line for the string `str'. If a match is found, the length of `str' is returned and the current point is moved to the start of the match. If no match is found, zero is returned. Note: This function respects the setting of the `CASE_SEARCH' variable. To perform a search that includes multiple lines, use the `fsearch' function. SEE ALSO fsearch, bfind, re_fsearch, bol_fsearch -------------------------------------------------------------- ffind_char SYNOPSIS Search forward on the current line for character "ch" USAGE Integer ffind_char (Integer ch) DESCRIPTION This function searches forward on the current line for the character `ch'. If it is found, `1' is returned; otherwise `0' is returned. SEE ALSO fsearch_char, bfind_char, fsearch SEE ALSO CASE_SEARCH -------------------------------------------------------------- find_matching_delimiter SYNOPSIS Look for the delimiter that matches "ch" USAGE Integer find_matching_delimiter (Integer ch) DESCRIPTION This function scans either forward or backward looking for the delimiter that matches the character specified by `ch'. The actual direction depends upon the syntax of the character `ch'. The matching delimiter pair must be declared as such by a prior call to `define_syntax'. This function returns one of the following values: 1 Match found 0 Match not found -1 A match was attempted from within a string. -2 A match was attempted from within a comment 2 No information In addition, the current point is left either at the match or is left at the place where the routine either detected a mismatch or gave up. In the case of a comment or a string (return values of -2 or -1), the current point is left at the beginning of a comment. Note: If the of `ch' is zero, the character at the current point will be used. SEE ALSO blink_match, create_syntax_table, define_syntax, parse_to_point -------------------------------------------------------------- fsearch SYNOPSIS Search forward for the string "str" USAGE Integer fsearch (String str) DESCRIPTION This function may be used to search forward in buffer looking for the string `str'. If not found, this functions returns zero. However, if found, the length of the string is returned and the current point is moved to the to the start of the match. It respects the setting of the variable `CASE_SEARCH'. If the string that one is searching for is known to be at the beginning of a line, the function `bol_fsearch' should be used instead. Note: This function cannot find a match that crosses lines. SEE ALSO ffind, fsearch_char, bsearch, bol_fsearch, re_fsearch, looking_at SEE ALSO CASE_SEARCH -------------------------------------------------------------- fsearch_char SYNOPSIS Search forward for a character USAGE Integer fsearch_char (Integer ch) DESCRIPTION This function searches forward for the character `ch'. If it is found, `1' is returned; otherwise `0' is returned. SEE ALSO fsearch, ffind_char, bsearch_char SEE ALSO CASE_SEARCH -------------------------------------------------------------- looking_at SYNOPSIS Test if the characters immediately following the point match "s" USAGE Integer looking_at (String s) DESCRIPTION This function returns non-zero if the characters immediately following the current editing point match the string specified by `s'. Whether the match is case-sensitive or not depends upon the value of the variable `CASE_SEARCH'. The function returns zero if there is no match. SEE ALSO ffind, fsearch, re_fsearch, bfind -------------------------------------------------------------- re_bsearch SYNOPSIS Search backward for regular expression "pattern" USAGE Integer re_bsearch(String pattern) DESCRIPTION Search backward for regular expression `pattern'. This function returns the 1 + length of the string matched. If no match is found, it returns 0. SEE ALSO bsearch, bol_bsearch, re_fsearch -------------------------------------------------------------- re_fsearch SYNOPSIS Search forward for regular expression "pattern" USAGE Integer re_fsearch(String pattern) DESCRIPTION Search forward for regular expression `pattern'. This function returns the 1 + length of the string matched. If no match is found, it returns 0. SEE ALSO fsearch, bol_fsearch, re_bsearch -------------------------------------------------------------- regexp_nth_match SYNOPSIS Return the nth sub-expression from the last re search USAGE String regexp_nth_match (Integer n) DESCRIPTION This function returns the nth sub-expression matched by the last regular expression search. If the parameter `n' is zero, the entire match is returned. Note: The value returned by this function is meaningful only if the editing point has not been moved since the match. SEE ALSO re_fsearch, re_bsearch -------------------------------------------------------------- replace SYNOPSIS Replace all occurances of "old" with "new" USAGE Void replace(String old, String new) DESCRIPTION This function may be used to replace all occurances of the string `old' with the string, `new', from current editing point to the end of the buffer. The editing point is returned to the initial location. That is, this function does not move the editing point. SEE ALSO replace_chars, fsearch, re_fsearch, bsearch, ffind, del SEE ALSO REPLACE_PRESERVE_CASE -------------------------------------------------------------- replace_chars SYNOPSIS Replace the next "n" characters with another string USAGE Int_Type replace_chars (Int_Type n, String_Type new) DESCRIPTION This function may be used to replace the next `n' characters at the editing position by the string `new'. After the replacement, the editing point will be moved to the end of the inserted string. The length of the replacement string `new' is returned. SEE ALSO fsearch, re_fsearch, bsearch, ffind, del SEE ALSO REPLACE_PRESERVE_CASE -------------------------------------------------------------- replace_match SYNOPSIS Replace text previously matched with "re_fsearch" or "re_bsearch" USAGE Int_Type replace_match(String_Type str, Int_Type method) DESCRIPTION This function replaces text previously matched with `re_fsearch' or `re_bsearch' at the current editing point with string `str'. If `method' is zero, `str' is a specially formatted string of the form described below. If `method' is non-zero, `str' is regarded as a simple string and is used literally. If the replacement fails, this function returns zero otherwise, it returns a non-zero value. NOTES This function should be used at the position of the corresponding match and nowhere else. -------------------------------------------------------------- search_file SYNOPSIS Regular expression search for strings in a disk file USAGE Integer search_file (String filename, String re, Integer nmax) DESCRIPTION This function may be used to search for strings in a disk file matching the regular expression `re'. The first argument `filename' specifies which file to search. The last argument `nmax' specifies how many matches to return. Each line that is matched is pushed onto the S-Lang stack. The number of matches (limited by `nmax') is returned. If the file contains no matches, zero is returned. -------------------------------------------------------------- create_syntax_table SYNOPSIS Create a new syntax table "name" USAGE Void create_syntax_table (String name); DESCRIPTION This the purpose of this function is to create a new syntax table with the name specified by `name'. If the table already exists, this clears the table of its current syntax entries. SEE ALSO define_syntax, use_syntax_table, define_keywords, what_syntax_table -------------------------------------------------------------- define_keywords_n SYNOPSIS Define a set of keywords USAGE String define_keywords_n (String table, String kws, Integer len, Integer N); DESCRIPTION This function is used to define a set of keywords for the syntax table `table' to be color syntax highlighted in the `"keywordN"' color, The first parameter, `table', specifies which syntax table is to be used for the definition. The second parameter, `kws', is a string that is the concatenation of keywords of length specified by the last parameter `len'. The list of keywords specified by `kws' must be in alphabetic order. The function returns the previous list of keywords of length `len'. For example, C mode uses the statement () = define_keywords_n ("C", "asmforintnewtry", 3, 0); to define the four three-letter keywords `asm', `for', `int', `new', and `try' to be given the `"keyword0"' color. Note that in the above example, the return value is not used. SEE ALSO define_syntax, set_color SEE ALSO WANT_SYNTAX_HIGHLIGHT,USE_ANSI_COLORS -------------------------------------------------------------- define_syntax SYNOPSIS Add a syntax entry to the table "name" USAGE Void define_syntax (..., Integer type, String name); DESCRIPTION This function adds a syntax entry to the table specified by the last parameter `name'. The actual number of parameters vary according to the next to the last parameter `type'. If `type' is `'"'' or `'\''', a string or character delimiter syntax is defined. In this case, `define_syntax' only takes three parameters where the first parameter is an integer that represents the character for which the syntax is to be applied. Similarly, if `type' is `'\\'', then a quote syntax is defined and again `define_syntax' only takes three parameters where the first parameter is an integer that represents the character for which the syntax is to be applied. A quote character is one in which the syntax of the following character is not treated as special. If `type' is `'('', then `define_syntax' takes four parameters where the first two parameters are strings that represent a matching set of delimiters. The first string contains the set of opening delimiters and the second string specifies the set of closing delimiters that match the first set. If a character from the closing set is entered into the buffer, the corresponding delimiter from the opening set will be blinked. For example, if the C language syntax table is called `"C"', then one would use define_syntax ("([{", ")]}", '(', "C"); to declare the matching delimiter set. Note that the order of the characters in the two strings must correspond. That is, the above example says that `'('' matches `')'' and so on. If `type' is `'%'', a comment syntax is defined. As in the previous case, `define_syntax' takes four parameters where there first two parameters are strings that represent the begin and end comment delimiters. If the comment syntax is such that the comment ends at the end of a line, the second string must either be the empty string, `""', or a newline `"\n"'. The current implementation supports at most two such types of comments. If `type' is `'+'', the first parameter is a string whose characters are given the operator syntax. If type is `','', the first parameter is a string composed of characters that are condered to be delimiters. If type is '0', the first parameter is a string composed of characters that make up a number. If `type' is `<', the first parameter is a string whose successive characters form begin and end keyword highlight directives. Finally, if `type' is `'#'', the first parameter is an integer whose value corresponds to the character used to begin preprocessor lines. As an example, imagine a language in which the dollar sign character `$' is used as a string delimiter, the backward quote character ``' is used as a quote character, comments begin with a semi-colon and end at the end of a line, and the characters `'<'' and `'>'' form matching delimiters. The one might use create_syntax_table ("strange"); define_syntax ('$', '"', "strange"); define_syntax ('`', '\\', "strange"); define_syntax (";", "", '%', "strange"); define_syntax ("<", ">", '(', "strange"); to create a syntax table called `"strange"' and define the syntax entries for appropriate this example. SEE ALSO create_syntax_table, use_syntax_table, find_matching_delimiter SEE ALSO BLINK -------------------------------------------------------------- dfa_build_highlight_table SYNOPSIS Build a DFA table for the syntax table "n" USAGE Void dfa_build_highlight_table (String n); DESCRIPTION This function builds a DFA table for the enhanced syntax highlighting scheme specified for the syntax table specified by the name `n'. This must be called before any syntax highlighting will be done for that syntax table. SEE ALSO create_syntax_table, use_syntax_table, dfa_define_highlight_rule, dfa_enable_highlight_cache SEE ALSO WANT_SYNTAX_HIGHLIGHT,USE_ANSI_COLORS -------------------------------------------------------------- dfa_define_highlight_rule SYNOPSIS Add an DFA rule to the syntax table "n" USAGE Void dfa_define_highlight_rule (String rule, String color, String n); DESCRIPTION This function adds an enhanced highlighting rule to the syntax table specified by the name `n'. The rule is described as a regular expression by the string `rule', and the associated color is given by the string `color', in the same format as is passed to `set_color'. For example: create_syntax_table ("demo"); dfa_define_highlight_rule ("[A-Za-z][A-Za-z0-9]*", "keyword", "demo"); dfa_define_highlight_rule ("//.*$", "comment", "demo"); dfa_build_highlight_table ("demo"); causes a syntax table to be defined in which any string of alphanumeric characters beginning with an alphabetic is highlighted in keyword color, and anything after "//" on a line is highlighted in comment color. The regular expression syntax understands character classes like `[a-z]' and `[^a-z0-9]', parentheses, `+', `*', `?', `|' and `.'. Any metacharacter can be escaped using a backslash so that it can be used as a normal character, but beware that due to the syntax of S-Lang strings the backslash has to be doubled when specified as a string constant. For example: dfa_define_highlight_rule ("^[ \t]*\\*+[ \t].*$", "comment", "C"); defines any line beginning with optional whitespace, then one or more asterisks, then more whitespace to be a comment. Note the doubled backslash before the `*'. Note also that `dfa_build_highlight_table' must be called before the syntax highlighting can take effect. SEE ALSO create_syntax_table, use_syntax_table, dfa_build_highlight_table SEE ALSO WANT_SYNTAX_HIGHLIGHT,USE_ANSI_COLORS -------------------------------------------------------------- dfa_enable_highlight_cache SYNOPSIS Enable caching of the DFA table USAGE Void dfa_enable_highlight_cache (String file, String n); DESCRIPTION This function enables caching of the DFA table for the enhanced syntax highlighting scheme belonging to the syntax table specified by the name `n'. This should be called before any calls to `dfa_define_highlight_rule' or to `dfa_build_highlight_table'. The parameter `file' specifies the name of the file (stored in the directory set by the `set_highlight_cache_dir' function) which should be used as a cache. For example, in `cmode.sl' one might write dfa_enable_highlight_cache ("cmode.dfa", "C"); to enable caching of the DFA. If caching were not enabled for C mode, the DFA would take possibly a couple of seconds to compute every time Jed was started. Transferring cache files between different computers is theoretically possible but not recommended. Transferring them between different versions of Jed is not guaranteed to work. SEE ALSO create_syntax_table, use_syntax_table, dfa_define_highlight_rule, dfa_build_highlight_table SEE ALSO WANT_SYNTAX_HIGHLIGHT,USE_ANSI_COLORS -------------------------------------------------------------- dfa_set_init_callback SYNOPSIS Set a callback to initialize a DFA syntax table USAGE Void dfa_set_init_callback (Ref_Type func, String_Type tbl) DESCRIPTION This function defines a callback function `func' that will be used to build a DFA syntax table for the syntax table `tbl'. When the `use_dfa_syntax' function is called to enable syntax highlighting, the callback function `func' will be called to to create the specified syntax table if it does not already exist. SEE ALSO create_syntax_table, use_syntax_table, dfa_define_highlight_rule, dfa_enable_highlight_cache SEE ALSO WANT_SYNTAX_HIGHLIGHT,USE_ANSI_COLORS -------------------------------------------------------------- parse_to_point SYNOPSIS Attempt to determine the syntactic context of the point USAGE Integer parse_to_point (); DESCRIPTION This function attempts to determine the syntactic context of the current editing point. That is, it tries to determine whether or not the current point is in a comment, a string, or elsewhere. It returns: -2 In a comment -1 In a string or a character 0 Neither of the above Note: This routine is rather simplistic since it makes the assumption that the character at the beginning of the current line is not in a comment nor is in a string. SEE ALSO define_syntax, find_matching_delimiter -------------------------------------------------------------- set_fortran_comment_chars SYNOPSIS Specify characters for fortran-like comments USAGE Void set_fortran_comment_chars (String_Type table, String_Type list DESCRIPTION This function may be used to specify the set of characters that denote fortran style comments. The first parameter `table' is the name of a previously defined syntax table, and `list' denotes the set of characters that specify the fortran-style comment. The string `list' is simply a set of characters and may include character ranges. If the first character of `list' is `'^'', then the meaning is that only those characters that do not specify fortran sytle comments are included in the list. EXAMPLE Fortran mode uses the following: set_fortran_comment_chars ("FORTRAN", "^0-9 \t\n"); This means that if any line that begins with any character except the characters `0' to `9', the space, tab, and newline characters will denote a comment. NOTES The usefulness of this function is not limited to fortran modes. In fact, many languages have fortran-style comments. This function is meaningful only if the syntax table has fortran-style comments as specified via the `set_syntax_flags' function. SEE ALSO define_syntax, set_syntax_flags -------------------------------------------------------------- set_highlight_cache_dir SYNOPSIS Set the directory for the dfa syntax highlighting cache files USAGE Void set_highlight_cache_dir (String dir); DESCRIPTION This function sets the directory where the dfa syntax highlighting cache files are located. See also: `dfa_enable_highlight_cache' -------------------------------------------------------------- set_syntax_flags SYNOPSIS Set the flags in the syntax table "table" USAGE Void set_syntax_flags (String table, Integer flag); DESCRIPTION This function may be used to set the flags in the syntax table specified by the `table' parameter. The `flag' parameter may take any of the following values or any combination bitwise or-ed together: 0x01 Keywords are case insensitive 0x02 Comments are Fortran-like 0x04 Ignore leading whitespace in C comments 0x08 Keywords are TeX-like 0x10 EOL style comments must be surrounded by whitespace. 0x20 Syntax highlight whole preprocessor line in same color. 0x40 Leading whitespace allowed for preprocessor lines. 0x80 Strings do not span lines A Fortran-like comment means that any line that begins with certain specified characters is considered to be a comment. This special subset of characters must be specified via a call to the `set_fortran_comment_chars' function. If the `0x04' bit is set, then whitespace at the beginning of a line in a C comment preceeding a `'*'' character will not be highlighted. A TeX-like keyword is any word that follows the quote character. An EOL style comment is one that ends at the end of the line. SEE ALSO define_syntax, set_fortran_comment_chars -------------------------------------------------------------- use_dfa_syntax SYNOPSIS Turn on/off DFA syntax highlighting for the current mode USAGE use_syntax_table (Int_Type on_off) DESCRIPTION This function may be used to turn on or off DFA syntax highlighting for the current mode according to whether or not the `on_off' parameter is non-zero. The most useful way of using this function is from within a mode hook. EXAMPLE The following example illustrates how to use this function to enable DFA syntax highlighting for C mode: define c_mode_hook () { use_dfa_syntax (1); } SEE ALSO enable_dfa_syntax_for_mode, disable_dfa_syntax_for_mode -------------------------------------------------------------- use_syntax_table SYNOPSIS Associate the current buffer with the syntax table "n" USAGE Void use_syntax_table (String n); DESCRIPTION This function associates the current buffer with the syntax table specified by the name `n'. Until another syntax table is associated with the buffer, the syntax table named `n' will be used in all operations that require a syntax. This includes parenthesis matching, indentation, etc. SEE ALSO create_syntax_table, define_syntax -------------------------------------------------------------- what_syntax_table SYNOPSIS Get the name of the active syntax table USAGE String_Type what_syntax_table () DESCRIPTION This function returns of the name of the syntax table used by the current buffer. If no table is in effect it returns NULL. SEE ALSO define_syntax, use_syntax_table, define_keywords -------------------------------------------------------------- CHEAP_VIDEO SYNOPSIS Control flicker on old video cards USAGE Int_Type CHEAP_VIDEO DESCRIPTION Some old video cards for MSDOS systems, most notably the CGA card, display snow when updating the card. This variable should be set to 1 to avoid the presence of snow when used with such a card. NOTES This variable is not available on all systems. SEE ALSO SCREEN_WIDTH, SCREEN_HEIGHT -------------------------------------------------------------- IGNORE_BEEP SYNOPSIS Control beeping of the terminal USAGE Int_Type IGNORE_BEEP DESCRIPTION This variable determines how the terminal is to be beeped. It may be any one of the following values: 0 Do not beep the terminal in any way. 1 Produce an audible beep only. 2 Produce an visible beep only by flashing the display. 3 Produce both audible and visible bells. NOTES Not all terminals support visible bells. SEE ALSO beep -------------------------------------------------------------- SCREEN_HEIGHT SYNOPSIS Number of display rows USAGE Int_Type SCREEN_HEIGHT DESCRIPTION This is a read-only variable whose value represents the number of rows of the display or terminal. SEE ALSO SCREEN_WIDTH, window_info -------------------------------------------------------------- SCREEN_WIDTH SYNOPSIS Number of display columns USAGE Int_Type SCREEN_WIDTH DESCRIPTION This is a read-only variable whose value represents the number of columns of the display or terminal. SEE ALSO SCREEN_HEIGHT, window_info -------------------------------------------------------------- TERM_BLINK_MODE SYNOPSIS Enable the use of high intensity background colors USAGE Int_Type TERM_BLINK_MODE DESCRIPTION If the value of this variable is non-zero, jed will interpret high-intensity background colors as blinking characters. On some terminals, e.g., `rxvt', the blink bit will be mapped to an actual high intensity background color. NOTES This variable is not available on all systems. SEE ALSO -------------------------------------------------------------- TERM_CANNOT_INSERT SYNOPSIS Control the use of terminal insertion USAGE Int_Type TERM_CANNOT_INSERT DESCRIPTION The value of this variable indicates whether or not the terminal is able to insert. Do disable the use of the insertion capability, set the value of this variable to 0. NOTES This variable is not available on all systems. It is a good idea not to set this variable. SEE ALSO TERM_CANNOT_SCROLL -------------------------------------------------------------- TERM_CANNOT_SCROLL SYNOPSIS Control the use of the terminal's scrolling capability USAGE Int_Type TERM_CANNOT_SCROLL DESCRIPTION If this variable is set to 0, the hardware scrolling capability of the terminal will not be used. This also means that the window will be recentered if the cursor moves outside the top or bottom rows of the window. NOTES This variable is not available on all systems. SEE ALSO TERM_CANNOT_INSERT -------------------------------------------------------------- USE_ANSI_COLORS SYNOPSIS Enable the use of colors USAGE Int_Type USE_ANSI_COLORS DESCRIPTION The variable `USE_ANSI_COLORS' may be used to enable or disable color support. If set to a non-zero value, the terminal will be assumed to support ANSI colors. This value of this variable is initially determined by examining the terminal's terminfo file, or by looking for the existence of a `COLORTERM' environment variable. NOTES This variable is not available on all platforms. SEE ALSO HIGHLIGHT -------------------------------------------------------------- get_termcap_string SYNOPSIS Return the keystring associated with the termcap capability "cap" USAGE String get_termcap_string (String cap); DESCRIPTION This function may be used to extract the string associated with the termcap capability associated with `cap'. Note: This function is only available on Unix systems. -------------------------------------------------------------- set_term_vtxxx SYNOPSIS Set terminal display appropriate for a vtxxx terminal DESCRIPTION Set terminal display appropriate for a vtxxx terminal. This function takes a single integer parameter. If non-zero, the terminal type is set for a vt100. This means the terminal lacks the ability to insert/delete lines and characters. If the parameter is zero, the terminal is assumed to be vt102 compatable. Unless you are using a VERY old terminal or a primitive emulator, use zero as the parameter. -------------------------------------------------------------- get_hostname SYNOPSIS Get the name of the host computer USAGE String_Type get_hostname () DESCRIPTION The `get_hostname' function returns the name of the host computer. If the editor is unable to determine the name, and the user has not specified a name, then `"localhost"' is returned. SEE ALSO set_hostname, get_realname, get_username -------------------------------------------------------------- get_realname SYNOPSIS Get the user's real name USAGE String_Type get_realname DESCRIPTION The `get_realname' returns the user's real name. If the editor is unable to determine this value, an empty string is returned. SEE ALSO set_realname, get_username, get_hostname -------------------------------------------------------------- get_username SYNOPSIS Get the username USAGE String_Type get_username () DESCRIPTION The `get_username' function returns the username associated with the current process. If is is unable to determine this value, `"unknown"' will be returned. SEE ALSO set_username, get_realname, get_hostname -------------------------------------------------------------- set_hostname SYNOPSIS Set the name of the host USAGE set_hostname (String_Type hostname) DESCRIPTION `set_hostname' may be used to set set the name of the host that the editor will associate with the current process. SEE ALSO get_hostname, set_username, set_realname -------------------------------------------------------------- set_realname SYNOPSIS Set the user's realname USAGE set_realname (String_Type realname) DESCRIPTION The `set_realname' function sets the editor's notion of what the user's real name is such that subsequent calls to `get_realname' will return the specified value. SEE ALSO get_realname, get_username, set_username, set_hostname -------------------------------------------------------------- set_username SYNOPSIS Set the username of the editor process USAGE set_username (String_Type username) DESCRIPTION This function may be used to specify the username associated with the editor process. SEE ALSO get_username, set_realname, set_hostname -------------------------------------------------------------- BLINK SYNOPSIS Set whether or not parentheses will be blinked USAGE Int_Type BLINK DESCRIPTION The `BLINK' variable controls whether or not matching parenthesis are blinked upon the insertion of a closing parenthesis. If its value is non-zero, the matching parenthesis will be blinked; otherwise, it will not. -------------------------------------------------------------- DISPLAY_EIGHT_BIT SYNOPSIS Set the display mode for eight-bit characters USAGE Int_Type DISPLAY_EIGHT_BIT DESCRIPTION This variable determines how characters with the high bit set are to be displayed. Specifically, any character whose value is greater than or equal to the value of `DISPLAY_EIGHT_BIT' is output to the terminal as is. Characters with the high bit set but less than this value are sent to the terminal in a multiple character representation. For Unix and VMS systems the value should be set to 160. This is because many terminals use the characters with values between 128 and 160 as eight bit control characters. For other systems, it can be set to zero. SEE ALSO META_CHAR -------------------------------------------------------------- DISPLAY_TIME SYNOPSIS Control the display of the current time USAGE Int_Type DISPLAY_TIME DESCRIPTION If this variable is non-zero, the current time will be displayed on the status line if the format for the status line permits it. If it is zero, the time will not be displayed even if the `%t' format string is part of the status line format. SEE ALSO set_status_line -------------------------------------------------------------- DOLLAR_CHARACTER SYNOPSIS The line continuation character USAGE Int_Type DOLLAR_CHARACTER = '$' DESCRIPTION The character represented by `DOLLAR_CHARACTER' is used to indicate that text extends beyond the borders of the window. This character is traditionally a dollar sign. If the value of `DOLLAR_CHARACTER' is 0, no character will be used for this indicator. SEE ALSO set_color -------------------------------------------------------------- HIGHLIGHT SYNOPSIS Turn on/off region highlighting USAGE Int_Type HIGHLIGHT DESCRIPTION If this variable is non-zero, marked regions will be highlighted. SEE ALSO WANT_SYNTAX_HIGHLIGHT, set_color -------------------------------------------------------------- HORIZONTAL_PAN SYNOPSIS Set the horizontal panning mode USAGE Int_Type HORIZONTAL_PAN DESCRIPTION If the value of this variable is non-zero, the window wil pan when the cursor goes outside the border of the window. More precisely, if the value is less than zero, the entire window will pan. If the value is positive, only the current line will pan. The absolute value of the number determines the panning increment. SEE ALSO SCREEN_WIDTH -------------------------------------------------------------- LINENUMBERS SYNOPSIS Enable the display of line or column numbers USAGE Int_Type LINENUMBERS DESCRIPTION The `LINENUMBERS' variable determines whether or not line or column numbers will be displayed on the status line. If the value of `LINENUMBERS' is 0, then neither the line nor column number information will be displayed. If `LINENUMBERS' is set to 1, then the current line number will be displayed but column numbers will not be. If `LINENUMBERS' is 2, the both line a column numbers will be displayed. SEE ALSO set_status_line -------------------------------------------------------------- Simulate_Graphic_Chars SYNOPSIS Specifies whether or not graphic characters are to be used USAGE Int_Type Simulate_Graphic_Chars DESCRIPTION If the value of this variable is non-zero, graphic characters will be simulated by simple ascii characters instead of trying to use the terminal's alternate character set. NOTES This variable is not available on all platforms. -------------------------------------------------------------- Status_Line_String SYNOPSIS The string used for the status line USAGE String_Type Status_Line_String DESCRIPTION `Status_Line_String' is a read-only string variable that specifies the format of the status line for newly created buffers. To set the status line format, use the function `set_status_line'. SEE ALSO set_status_line -------------------------------------------------------------- TAB SYNOPSIS Set the current buffer TAB width USAGE Int_Type TAB DESCRIPTION This variable controls the tab width associated with the current buffer. A value of zero means that tab characters are not expanded and that tabs are never used to produce whitespace. SEE ALSO TAB_DEFAULT, USE_TABS -------------------------------------------------------------- TAB_DEFAULT SYNOPSIS Set the default tab width USAGE Int_Type TAB_DEFAULT DESCRIPTION The value of `TAB_DEFAULT' is the default tab setting given to all newly created buffers. A value of zero means that tab characters are not expanded and that tabs are never used to produce whitespace. NOTES A related variable `TAB' may be used to change the current buffer's tab setting. SEE ALSO TAB, USE_TABS, TAB_DEFAULT -------------------------------------------------------------- TOP_WINDOW_ROW SYNOPSIS Top window's starting row USAGE Int_Type DESCRIPTION This read-only variable gives the value of the starting row of the top window. If a menubar is present, the value will be 2, otherwise it will be 1. SEE ALSO enable_top_status_line, window_info -------------------------------------------------------------- WANT_EOB SYNOPSIS Control the display of the end of buffer indicator USAGE Int_Type DESCRIPTION If this value of this variable is non-zero, the end of buffer indicator `"[EOB]"' will be displayed at the end of the buffer. Such an indicator is used for various editor emulations such as the VAX/VMS EDT editor. -------------------------------------------------------------- WANT_SYNTAX_HIGHLIGHT SYNOPSIS Enable or disable syntax highlighting USAGE Int_Type WANT_SYNTAX_HIGHLIGHT DESCRIPTION If the value of this variable is non-zero, syntax highlighting will be enabled. Otherwise, syntax highlighting will be turned off. SEE ALSO HIGHLIGHT, set_color -------------------------------------------------------------- blink_match SYNOPSIS Blink the matching delimiter USAGE Void blink_match (); DESCRIPTION This function will attempt to blink the matching delimiter immediately before the editing point. SEE ALSO find_matching_delimiter, define_syntax -------------------------------------------------------------- enlargewin SYNOPSIS Increase the size of the current window USAGE Void enlargewin () DESCRIPTION This function increases the size of the current window by one line by adjusting the size of the other windows accordingly. SEE ALSO window_info, onewindow -------------------------------------------------------------- nwindows SYNOPSIS Return the number of windows currently visible USAGE Integer nwindows (); DESCRIPTION The `nwindows' function returns the number of windows currently visible. If the variable `MINIBUFFER_ACTIVE' is non-zero, the minibuffer is busy and contributes to the number of windows. SEE ALSO splitwindow, onewindow, window_size SEE ALSO MINIBUFFER_ACTIVE -------------------------------------------------------------- onewindow SYNOPSIS Make current window the only one USAGE Void onewindow (); DESCRIPTION This function deletes all other windows except the current window and the mini-buffer window. SEE ALSO nwindows, splitwindow, enlargewin SEE ALSO MINIBUFFER_ACTIVE -------------------------------------------------------------- otherwindow SYNOPSIS Make the next window the default window USAGE Void otherwindow () DESCRIPTION This function will make the next window in the ring of windows as the default window. For example, define zoom_next_window () { otherwindow (); onewindow (); } defines a function that moves to the next window and then makes it the only window on the screen. SEE ALSO nwindows, onewindow SEE ALSO MINIBUFFER_ACTIVE -------------------------------------------------------------- recenter SYNOPSIS Scroll the window to make the "nth" line contain the current line USAGE Void recenter (Integer nth); DESCRIPTION This function may be used to scroll the window such that the `nth' line of the window contains the current line. If `nth' is zero, the current line will be placed at the center of the window and the screen will be completely redrawn. SEE ALSO nwindows, window_info -------------------------------------------------------------- set_status_line SYNOPSIS Customize the status line of the current window USAGE set_status_line (String format, Integer flag) DESCRIPTION This function may be used to customize the status line of the current window according to the string `format'. If the second parameter `flag' is non-zero, `format' will apply to the global format string; otherwise it applies to current buffer only. Newly created buffer inherit the global format string when they appear in a window. The format string may contain the following format specifiers: %b buffer name %f file name (without the directory part) %F file name with directory %v JED version %t current time --- only used if variable DISPLAY_TIME is non-zero %p line number or percent string. If LINENUMBERS is 2, this expands to "line number,column number" %c column number %% literal '%' character %m mode string %a If abbrev mode, expands to "abbrev" %n If buffer is narrowed, expands to "Narrow" %o If overwrite mode, expands to "Ovwrt" %O Overwrite/Insert flag - like %o, but shows INS/OVR %l Shows current line number %L Shows number of lines in the file For example, the default status line used by JED's EDT emulation uses the format string: "(Jed %v) EDT: %b (%m%a%n%o) %p,%c Advance %t" SEE ALSO set_mode, narrow, whatbuf, getbuf_info SEE ALSO DISPLAY_TIME,LINENUMBERS, Global_Top_Status_Line, Status_Line_String -------------------------------------------------------------- splitwindow SYNOPSIS Split the current window vertically USAGE Void splitwindow (); DESCRIPTION This function splits the current window vertically creating another window that carries the current window's buffer. SEE ALSO onewindow, enlargewin, window_info -------------------------------------------------------------- update SYNOPSIS Update the display USAGE Void update (Integer f); DESCRIPTION This function may be called to update the display. If the parameter `f' is non-zero, the display will be updated even if there is input pending. If `f' is zero, the display may only be partially updated if input is pending. SEE ALSO input_pending, flush -------------------------------------------------------------- update_sans_update_hook SYNOPSIS Update the display without running the update hooks USAGE update_sans_update_hook (Int_Type force) DESCRIPTION The `update_sans_update_hook' function performs the same function as `update', except that the buffer's update hook will not be run. See `update' for more information. SEE ALSO update, set_buffer_hook, unset_buffer_hook -------------------------------------------------------------- w132 SYNOPSIS Set the number of columns on a vtxxx compatable terminal to 132. USAGE Void w132 () DESCRIPTION This function may be used to set the number of columns on a vtxxx compatable terminal to 132. SEE ALSO w80, set_term_vtxxx -------------------------------------------------------------- w80 SYNOPSIS Set the number of columns on a vtxxx compatable terminal to 80 USAGE Void w80 () DESCRIPTION This function may be used to set the number of columns on a vtxxx compatable terminal to 80. SEE ALSO w132, set_term_vtxxx -------------------------------------------------------------- window_info SYNOPSIS Return information concerning the current window USAGE Integer window_info(Integer item); DESCRIPTION The `window_info' function returns information concerning the current window. The actual information that is returned depends on the `item' parameter. Acceptable values of `item' and the description of the information returned is given in the following table: 'r' : Number of rows 'w' : Width of window 'c' : Starting column (from 1) 't' : Screen line of top line of window (from 1) SEE ALSO otherwindow, nwindows SEE ALSO SCREEN_HEIGHT,SCREEN_WIDTH -------------------------------------------------------------- window_line SYNOPSIS Return the number of rows from the top of the window USAGE Integer window_line (); DESCRIPTION This function returns the number of rows from the top of the current window for the current line. If the current line is the very first line in the window, a value of `1' will be returned, i.e., it is the first line of the window. SEE ALSO window_info, nwindows SEE ALSO TOP_WINDOW_ROW -------------------------------------------------------------- get_scroll_column SYNOPSIS Get the scroll column for the current window USAGE Int_Type get_scroll_column () DESCRIPTION This function returns the scroll column for the current window. SEE ALSO set_scroll_column -------------------------------------------------------------- set_scroll_column SYNOPSIS Set the scroll column for the current window USAGE set_scroll_column (Int_Type col) DESCRIPTION This function may be used to set the scroll column of the current window. SEE ALSO get_scroll_column -------------------------------------------------------------- x_copy_region_to_cutbuffer SYNOPSIS Copy the region to the X cutbuffer USAGE x_copy_region_to_cutbuffer () DESCRIPTION places a copy of the region to the X cutbuffer for insertion in other X-window programs. In wjed the region is copies to the clipboard. SEE ALSO x_copy_region_to_selection -------------------------------------------------------------- x_copy_region_to_selection SYNOPSIS Copy the region to the X selection USAGE x_copy_region_to_selection () DESCRIPTION places a copy of the region to the X selection for insertion in other X-window programs. This function is only available in xjed. SEE ALSO x_copy_region_to_cutbuffer -------------------------------------------------------------- x_insert_cutbuffer SYNOPSIS Insert the content of the X cutbuffer USAGE Int_Type x_insert_cutbuffer () DESCRIPTION Inserts cutbuffer (in wjed the clipboard) into the current buffer and returns the number of characters inserted. SEE ALSO -------------------------------------------------------------- x_insert_selection SYNOPSIS Insert data from the X selection owner USAGE Int_Type x_insert_selection () DESCRIPTION This function only requests selection data from the selection owner. If Xjed received EVENT, Xjed inserts selection data into the current buffer and returns the number of characters inserted. SEE ALSO -------------------------------------------------------------- x_server_vendor SYNOPSIS Return the vendor name of the X server USAGE String_Type x_server_vendor () DESCRIPTION This function returns the vendor name of the X server. SEE ALSO -------------------------------------------------------------- x_set_icon_name SYNOPSIS Set the icon do display in X windows (xjed only) USAGE x_set_icon_name (String_Type name) DESCRIPTION SEE ALSO -------------------------------------------------------------- x_set_keysym SYNOPSIS Associate a string with a key USAGE x_set_keysym (Int_Type keysym, Int_Type shift, String_Type str) DESCRIPTION This function may be used to assocate a string `str' with a key `keysym' modified by mask `shift'. Pressing the key associated with `keysym' will then generate the keysequence given by `str'. The function keys are mapped to integers in the range `0xFF00' to `0xFFFF'. On most systems, the keys that these mappings refer to are located in the file `/usr/include/X11/keysymdef.h'. For example, on my system, the keysyms for the function keys `XK_F1' to `XK_F35' fall in the range `0xFFBE' to `0xFFE0'. So to make the `F1' key correspond to the string given by the two characters `Ctrl-X' `Ctrl-C', simply use: x_set_keysym (0xFFBE, 0, "^X^C"); The `shift' argument is an integer with the following meanings: 0 : unmodified key '$' : shifted '^' : control Any other value for shift will default to 0 (unshifted). SEE ALSO x_set_meta_keys -------------------------------------------------------------- x_set_meta_keys SYNOPSIS Specify which modifier keys are to be interpreteted as meta keys USAGE x_set_meta_keys (Int_Type mod_mask) DESCRIPTION The `x_set_meta_keys' function allows the user to specify which modifier keys are to be interpreteted as meta keys. The parameter `mod_mask' is a bitmapped value whose bits correspond to a modifier mask: 0: Mod1Mask 1: Mod2Mask 2: Mod3Mask 3: Mod4Mask 4: Mod5Mask EXAMPLE x_set_meta_keys ((1<<0) | (1<<3)); specifies that meta keys are to be associated with Mod1Mask and Mod4Mask. SEE ALSO x_set_keysym -------------------------------------------------------------- x_toggle_visibility SYNOPSIS Shows or hides the window USAGE x_toggle_visibility([Integer_Type hide]) DESCRIPTION Makes the window visible or invisible. If the argument `hide' is not given, the visility of the windows is toggled, e.g. if the window is invisible it becomes visible and vice versa. If the optional argument `hide' is given the state to the window becomes visible if `hide' is non-zero or invisible if `hide' is zero, independent of the current state. NOTES You can also hide the window by calling `suspend', but you can not show it, if the window doesn't have the focus. SEE ALSO suspend -------------------------------------------------------------- x_set_window_name SYNOPSIS Set the title of the xjed window USAGE x_set_window_name (String_Type name) -------------------------------------------------------------- x_warp_pointer SYNOPSIS warp pointer USAGE DESCRIPTION -------------------------------------------------------------- jed-0.99-19/doc/txt/0000755002657400265740000000000011311317447013056 5ustar davisdavisjed-0.99-19/doc/txt/utf8.txt0000644002657400265740000000707211311317447014513 0ustar davisdavisUnicode via the UTF-8 encoding is available for jed versions 0.99-17 and greater provided that slang2 is used. There are several complicating factors that one needs to consider when running jed in its UTF-8 mode. In a pure UTF8-8 environment, jed's support for UTF-8 should be transparent. By a pure environment I mean one where all files that jed reads and writes use the UTF-8 character set, and all terminal I/O assumes the UTF-8 encoding. Unfortunately, such environments are rare because in practice one must deal with files using national character sets, e.g., ISO-Latin-1. Hence, the common scenario will be one involving a mixture of character sets. In the current implementation, jed either runs in UTF-8 mode or it doesn't. There is no provision for enabling or disabling UTF-8 support during runtime. When not running in UTF-8 mode, jed knows almost nothing about character sets. This is the only mode supported by older versions of jed. When running in UTF-8 mode, internally everything uses UTF-8, including the interpreter. This means that all strings used by the slang interpreter are encoded using the UTF-8 character set. For example, the strlen function returns the number of (UTF-8) characters in the string, not the number of bytes. In this mode, reading a file using a national character set without first converting it to UTF-8 may cause some characters in the file to not display properly. In particular, all characters with codes greater than 128 will display as where XX represents the hex character code. Enabling UTF-8 support ---------------------- The environment dictates whether or not jed will run in UTF-8 mode. If the locale indicates that the character set is UTF-8, then UTF-8 mode will be enabled. For the time being, jed can be forced into UTF-8 mode by defining the JED_UTF8 environment variable. If the value of this variable is 1, then jed will run in UTF-8 mode. This can be useful for cases when the terminal does not support UTF-8 but for some reason one has to edit a UTF-8 encoded file. I want to stress that the use of JED_UTF8 is considered to be a temporary hack. Character set conversion ------------------------ At the moment, jed provides no built-in mechanism for transparent character set conversion. It is expected that once such support is in place, it will probably be done via hooks such as _jed_find_file_after_hooks. If pre-existing hooks prove inadequate, then it may be necessary to introduce other hooks. Until such support, it is recommended that one use other programs such as "iconv" to perform character set conversion outside the editor. It is always possible to create a function that forces the buffer from the national character set to UTF-8 via the direct replacement. The following functions may be used to convert the buffer to and from ISO-Latin-1: define iso_to_utf8 () { if (_slang_utf8_ok == 0) verror ("This function requires a UTF-8 enabled version of jed"); push_spot (); bob (); forever { variable ch = what_char (); if (ch < 0) { del (); insert_char (-ch); continue; } !if (right(1)) break; } pop_spot (); } define utf8_to_iso () { if (_slang_utf8_ok == 0) verror ("This function requires a UTF-8 enabled version of jed"); push_spot (); bob (); forever { variable ch = what_char (); if ((ch >= 128) and (ch < 256)) { del (); insert_byte (ch); continue; } !if (right (1)) break; } pop_spot (); } Note that the above functions require slang2 to work properly and must be run in a UTF-8 enabled version of jed. jed-0.99-19/doc/txt/mouse.txt0000644002657400265740000001546111311317447014756 0ustar davisdavisUsing a mouse with Jed and XJed =============================== Jed provides native support for a mouse on the following systems: 1. A Linux console running the GPM server. This server is a replacement for the `selection' program. It is available from sunsite.unc.edu:/pub/Linux/system/Daemons/gpm-0.97.tar.gz 2. MSDOS 3. XJed Later, OS/2 support will be added. In addition to ``native'' mouse support, JED is able to interact with a mouse using the `XTerm Event Protocol'. Support for this protocol is available when running JED in an XTerm as well as interacting with JED from an MSDOS terminal emulator, e.g., MS-Kermit, using the PCMOUSE TSR. This document is divided into two sections. The first section describes native mouse support (Linux, MSDOS, XJed) and the second section describes the support for the XTerm Event Protocol. ============================================================================== Native Mouse Support ============================================================================== The S-Lang file jed/lib/mouse.sl provides a user interface to the mouse. It can only be loaded for systems which provide native support for the mouse. Currently this includes MSDOS, Linux console, and XJed. This file is automatically loaded from os.sl when JED is started up. (See os.sl for how this is accomplished). Once this file has been loaded, the mouse buttons behave as described below. This interface assumes the presence of a three button mouse. Unfortunately, in the MSDOS world, two button mice are are quite common. Nevertheless, JED is able to emulate a three button mouse by using the ALT key. Any button pressed in combination with the ALT key is considered to be the MIDDLE mouse button. For example, to get the effect of pressing Ctrl-Middle, hold down on the ALT and Ctrl key while pressing any mouse button. Clicking in a window -------------------- Left If a region is already marked, simply un-mark it. If one is not marked, move cursor to the mouse point crossing windows if necessary. If the button is held down and the mouse is dragged, a region will be highlighted and then copied to the cutbuffer when the button is released. Middle If a region is already marked, copy it to the mouse paste-buffer. Otherwise, paste text from the system cut buffer to current editing point. This MAY NOT BE the position of the mouse. Right If a region is already marked, delete it and place a copy into the mouse paste-buffer. Otherwise, simply position the editing point at the position of the mouse. If the button is held down and the mouse is dragged, a new region will be marked. Shift Middle Insert contents of the last JED mouse copy or kill. This function may be identical to simply clicking on the middle button without using the shift key on non-X systems. Simply clicking the middle mouse button will insert the contents of the current selection which may not be owned by JED. Other buttons combinations are undefined. Some modes may utilize the mouse in a slightly different manner. Clicking on a window status line -------------------------------- Left Switch to next buffer. Ctrl-Left Kill buffer described by status line. Shift-Left Scroll window back one page. Shift-Right Scroll window forward one page Middle Split the window. Right: Delete the window For example, one can quickly move from one buffer to the next by simply clicking on the status line with the left mouse button. Tips for using the mouse ------------------------- 1. To quicky move the cursor to another location, simply point the mouse at that spot and click the LEFT mouse button. 2. To copy a region for subsequent pasting, move the mouse to the beginning of the region and press the LEFT mouse button. While holding it down, ``drag'' the mouse to the end of the region and release it. 3. To cut a region and put it in the paste buffer, define a region by dragging with the RIGHT mouse button. Now release the RIGHT button and then press and immediately release it. ============================================================================== XTerm Event Support ============================================================================== Xterm event support is provided by not only Xterm but also the Linux console running the `selection' program. Only versions 1.6 and greater of selection provide this support. In addition, one must be using a recent Linux kernel (1.1.35 or newer.) Please note that the selection program is considered obsolete and should be replaced by the GPM mouse server. Installation ============= To enable JED to use this mouse support, the following steps must be performed: 1. Make sure you have the appropriate version of selection and the Linux kernel installed. 2. Put the following on your .jedrc file: () = evalfile ("mousex"); The file `mousex.sl' creates three hooks: `exit_hook', `suspend_hook', and `resume_hook'. If you have already defined these hooks for yourself, look at `mousex.sl' and modify your hooks appropriately. These hooks are necessary so that the `selection' state can be properly initialized and restored. Mouse Usage =========== Left Button: ------------ If the left button is clicked on the status line of a window, the window will switch to a different buffer. If the button is pressed anywhere else in the window, the cursor will be positioned at the location of the click. Middle Button: ------------- On status line: split the window Anywhere else: If the region is highlighted, the region will be copied to the pastebuffer. This does not delete the region. Otherwise, the contents in the pastebuffer will be pasted to the current editing point. Right Button: ------------- On status line: delete the window. Anywhere else: If a region is highlighted, the region will be extended to the position of the mouse. Otherwise, the mark is set and a region will be defined. Cut/Paste Tips: To mark and manipulate a region do: 1. Click the LEFT mouse button at the beginning of the region. 2. Move the mouse to the end of the region and click the RIGHT mouse button. The region should now be marked. 3. Click the MIDDLE button to copy the region to the pastebuffer. 4. To paste from the pastebuffer, move the cursor to where you want to paste and press the MIDDLE button. jed-0.99-19/doc/txt/dfa.txt0000644002657400265740000002146011311317447014354 0ustar davisdavisDFA-based Syntax Highlighting ============================= DFA highlighting is an alternative syntax highlighting mechanism to Jed's original simple one. It's a lot more powerful, but it takes up more memory and makes the executable larger if it's compiled in. It's also more difficult to design new highlighting modes for. DFA highlighting works *alongside* Jed's standard highlighting system in the sense that the user can choose which scheme is to be used on a mode-by-mode basis. Some examples of what DFA highlighting can do that the standard scheme can't are: - Correct separation of numeric tokens in C. The text `2+3' would get highlighted as a single number by the old scheme, since `+' is a valid numeric character (when preceded by an E). DFA highlighting can spot that the `+' is not a valid numeric character in _this_ instance, though, and correctly interpret it as an operator. - Enhanced HTML mode, in which tags containing mismatched quotes (such as `" fold_exit_fold "^C<" fold_open_buffer "^C^O" fold_fold_region "^C^F" fold_open_fold "^C^S" fold_close_fold "^C^X" fold_search_forward "^Cf" fold_search_backward "^Cb" I realize that these key bindings are sub-optimal. However, they are consistent with the Emacs bindings. Of course, you are always free to re-bind them via a `fold_mode_hook', e.g., define fold_mode_hook () { local_setkey ("fold_whole_buffer", "^P"); . . } The `fold_search_forward' and `fold_search_backward' functions will not find matches on hidden buffer lines. The standard editor search functions are indifferent to hidden lines. Double clicking with the mouse left button on a fold will cause the editor to enter the fold (fold_enter_fold). Double clicking on any other line will cause the editor to exit the current fold. The current fold will be exited when an attempt is made to cross the boundary of the fold via the the Up/Down arrow keys (more precisely, the functions `previous_line_cmd' and `next_line_cmd'). This behavior can be controlled by the variable `Fold_Bob_Eob_Error_Action'. To cause an error to be generated when attempting to cross the boundary of a fold, add the line variable Fold_Bob_Eob_Error_Action = 0; to your jedrc startup initialization file. To automatically enter the next (previous) fold, use variable Fold_Bob_Eob_Error_Action = 2; The default value of this variable is 1. Of course, the easiest way to learn the folding mode is to fold a buffer and use the folding_mode key bindings to navigate it. Since this file contains fold marks, it is a good place to start. }}} {{{ Automatically folding files ------------------------------- By default, folded files are not automatically folded when they are loaded into the editor. To automatically fold a file, set the variable, Fold_Mode_Ok to a non-zero value in your .jedrc file: Fold_Mode_Ok = 1; Then any file that contains the line of the form -*- bla bla... mode: fold; -*- near the top will be folded. For example, the first line of both site.sl and folding.sl look like: % -*- mode: slang; mode: fold -*- This tells the editor to load slang mode, then load fold mode. A C file might contain the line /* -*- mode: C; mode: fold -*- */ as its first line. It is important to note that `mode: fold' must follow the main mode of the buffer, i.e., using /* -*- mode: fold; mode: C -*- */ will NOT work. The function `fold_mode', defined in os.sl looks like: define fold_mode () { if (Fold_Mode_Ok) folding_mode (); } That is, it is simply a wrapper around `folding_mode'. }}} {{{ Fold Marks -------------- By now it should be fairly obvious that the curly braces that appear near the beginning and end of sections of this document have something to do with folding. The line that starts a fold must contain a special string of characters (called a folding mark) either at the beginning of the line or at the end of the line. Similarly, the line that denotes end of a fold is denoted by a mark which must be different from the mark that starts a fold. The marks usually vary on a mode-by-mode basis. For example, this file uses the characters `{{{' to denote the start of a fold, and the characters `}}}' denote the end of a fold. C mode uses `/*{{{ TEXT */' to start a fold and `/*}}}*/' to end it. The function `fold_add_mode_marks' may be used to associate marks with a fold. See folding.sl for more information. The function `fold_fold_region' may be used to facilitate the placement of folding marks. To use this function simply mark a region of text and press `Ctrl-C Ctrl-F' (or whatever key sequence is bound to the `fold_fold_region' function'). If the beginning of the region is located anywhere on a non-blank line, the start-fold mark will be placed at the END of that line; otherwise, the start-fold mark will be placed at the beginning. See the folding.sl file for examples of both kinds of start-fold marks. }}} {{{ Caveats ----------- One should exercise care when editing a folded file to make sure that only visible lines are modified. Most of the interactive insert/delete functions are aware of whether or not a line is hidden. However, other functions, e.g., `replace_cmd', will allow a hidden line to be modified. Fortunately, the interactive cursor movement functions, e.g., `next_line_cmd', avoid leaving the editing point within a fold. However, lower level functions such as `down' do not know about folds or hidden lines. The bottom line is that if you need to modify text within a fold, either enter the fold (fold_enter_fold) or unfold the buffer (fold_open_buffer). }}} jed-0.99-19/doc/txt/rgrep.txt0000644002657400265740000000240211311317447014734 0ustar davisdavisThis file documents rgrep, a recursive, highlighting grep program. Currently, rgrep is only available on Unix systems. To build it, move to the src directory for JED and enter: `make rgrep'. Why use rgrep instead of more traditional Unix tools? ------------------------------------------------------ Unlike grep and egrep, rgrep has the ability to recursively descend directories. The traditional way of performing this kind of search on Unix systems utilizes the `find' command in conjunction with `grep'. However, this results in very poor performance. Consider the tradional approach where one wants to search the /usr/include directory for the string `FD_SET': For this, one would use: % find /usr/include -exec grep -l FD_SET \{\} \; -print Ignoring the fact that the above expression looks complex, it failed to find any occurence of FD_SET under the /usr/include directory of my Ultrix system. Now, if rgrep is used, one types: % rgrep -lFr FD_SET /usr/include which yielded: /usr/include/sys/types.h The reason that `find' failed is that /usr/include/sys is a symbolic link to /sys/h. `rgrep' was able to succeed because of the `-F' flag which telles it to follow links. I looked in the man page for a similar option for `find' but nothing turned up. jed-0.99-19/doc/txt/hooks.txt0000644002657400265740000004450011311317447014745 0ustar davisdavis This file documents the various hooks for extending JED. A `hook' is simply a user defined S-Lang function that may be used to extend the editor or to modify how it behaves under certain circumstances. There are two kinds of hooks that vary according to whether the hook is called ``internally'' from the editor by the underlying C code or whether the hook is called from another S-Lang function. The hooks may be subdivided further according to their scope. They may apply to all buffers (globally), only buffers sharing the same mode (modal), or to a single buffer (local). =========================================================================== Buffer-local Hooks =========================================================================== Buffer-local hooks are hooks that are defined on a buffer-by-buffer basis. These hooks are associated with the current buffer via the function `set_buffer_hook'. The syntax for this function is set_buffer_hook (name_of_hook, &hook_function); Here name_of_hook is a string that indicates the name of the hook that is being set. The second argument, `hook_function' specifies the S-Lang function to be associated with the hook. The calling syntax of the hook function varies with the hook. The following buffer-local hooks are supported: "par_sep" This hook is used to determine whether or no the current line constitutes the beginning or the end of a paragraph. The function attached to this hook must be defined to take no arguments and return 1 if the current line is the beginning or end of a paragraph, or 0 otherwise. If this hook has not been defined, the global hook is_paragraph_separator will be called. "mark_paragraph_hook" If this hook exists, it will be used to mark the paragraph that is about to be formatted. It should place a mark at the beginning of the paragraph and leave the editing point at the end of the paragraph. "forward_paragraph_hook" "backward_paragraph_hook" "format_paragraph_hook" "indent_hook" If this hook exists, it will be used by the indent_line function to indent the line. It takes no arguments and returns no values. "wrap_hook" This hook is called whenever a character insertion has caused a line to be wrapped. It takes no arguments and returns nothing. Here is a simple example of the use of this hook: Often when writing text, I use numbered paragraphs or lists, e.g., in jed's changes.txt file. After wrapping, I want paragraphs to be indented beyond the number. This is accomplished via a wrap_hook such as: private define text_mode_wrap_hook () { push_spot (); go_up(1); bol (); skip_white (); variable p = what_column (); skip_chars ("0-9"); if ((p != what_column ()) and looking_at (". ")) { go_right (1); skip_white (); p = what_column (); } go_down(1); bol (); trim (); whitespace (p-1); pop_spot (); } and then declared as the wrap-hook in text mode: define text_mode_hook () { set_buffer_hook ("wrap_hook", &text_mode_wrap_hook); } Note that if a buffer has been assigned a "wrap_hook", the value of the WRAP_INDENTS variable will be ignored for the buffer. "wrapok_hook" This hook may be used to enable automatic wrapping on a line-by-line basis. Jed will call this hook prior to wrapping a line, and if it returns a non-zero value, the line will be wrapped. See lib/slmode.sl for an example of its use. "newline_indent_hook" If this hook exists, it will be called by the newline_and_indent function. It takes no arguments and returns nothing. "bob_eob_error_hook" This hook is called whenever one of the internal cursor movement functions would have generated an end-of-buffer or beginning-of-buffer error. It is passed an integer that indicates which function would have generated the error. Specifically: -1 previous_line_cmd -2 previous_char_cmd -3 page_up 1 next_line_cmd 2 next_char_cmd 3 page_down The hook returns nothing. "mouse_down", "mouse_up", "mouse_drag", "mouse_2click", "mouse_3click" These hooks are used to override default hooks defined by the mouse_set_default_hook function. "update_hook" This hook is called prior to updating the display. It takes no arguments and returns nothing. =========================================================================== S-Lang Hooks =========================================================================== This type of hook is called from another S-Lang function. The most common hook of this class is a mode-hook, e.g., c_mode_hook. *_mode_hook ----------- Nearly all mode-setting functions call a hook via the `run_mode_hooks' function that the user may use for customization. Examples, include text_mode_hook, c_mode_hook, etc. These are hooks that get called when the editor enters a particular mode. Usually, one just wants to setup some key bindings for the mode. For this purpose, the `local_setkey' function should be used. For instance, c_mode sets the RETURN key to the function `newline_and_indent'. Some users may not like this binding and prefer the simpler `newline' function. Defining a c_mode_hook easily permits this customization: define c_mode_hook () { local_setkey ("newline", "\r"); } global_mode_hook ---------------- This hook is called by the run_mode_hooks function prior to calling the actual mode-hook. It takes a single argument whose value is the name of the mode-hook. For instance, many users prefer to have the TAB key always insert a TAB instead of running the indent_line function. The easiest way to enforce this for every mode is through a global_mode_hook such as: define global_mode_hook (hook_name) { if (hook_name != "c_mode_hook") local_setkey ("self_insert_cmd", "\t"); } This example illustrates how to cause the TAB key to insert a TAB in all modes _except_ C-mode. keybindings_hook ---------------- This hook is called after a set of keybindings have been loaded. The function takes a single argument that indicates the name of the keybindings, e.g., "emacs", "ide", etc: define keybindings_hook (name) { if (name == "emacs") { unsetkey ("^A"); setkey ("dabbrev", "^A"); } } =========================================================================== Internal Hooks =========================================================================== Internal hooks are hooks that are called by the C functions of the editor. mode_hook --------- One of the most important hooks that the user may want to define or customize if `mode_hook'. This hook may be used to associate a mode with a file or buffer. Immediately after JED loads a file into a buffer, it calls `mode_hook' to set the mode of the buffer. The default value is defined in `site.sl'. This hook is called with with the file name extension of the file as its only parameter. This function sets the mode of the buffer based on the value of the file name extension. There are several ways to customize this hook. The easiest is to simply call the function `add_mode_for_extension' with the mode that is to be associated with a particular extension. For example, suppose that you edit files with names like `main.c++'. To have `c_mode' associated with files of this type, simply call: add_mode_for_extension ("c", "c++"); The important point to realize is that the first parameter is the name of the mode but it should not include the `_mode' part of the mode name. The other way to customize mode_hook is through the function reference `Mode_Hook_Pointer' which the user can define to set the mode. If the function pointed to by `Mode_Hook_Pointer' returns non-zero, `mode_hook' will return to the calling routine. Specifically, the default value of `mode_hook' looks like: define mode_hook (ext) { if (@Mode_Hook_Pointer (ext)) return; . . } One could simply point `Mode_Hook_Pointer' to something like: define set_no_mode (ext) { return 1; } Mode_Hook_Pointer = &set_no_mode; Typically, one would do something useful like: define my_mode_hook (ext) { if (strcmp ("pas", ext)) return 0; my_pascal_mode (); return 1; } Mode_Hook_Pointer = &my_mode_hook; Here `my_pascal_mode' is a hypothetical pascal mode. As another example of the `mode_hook', consider the case where one would like to set the mode based on the filename and NOT the extension. For example, the Elm mailer user files of the form `snd.XXX' and one would like to use text mode on such files. Again, the solution is to use the `Mode_Hook_Pointer': define my_mode_hook (ext) { variable file; (file,,,) = getbuf_info (); if (0 != strncmp (file, "snd.", 4)) return 0; text_mode (); return 1; } Mode_Hook_Pointer = &my_mode_hook; Finally, the global variable `Default_Mode' may be pointed to a function to set the mode if a suitable mode was not obtained from the extension. By default, it has the value: Default_Mode = &text_mode; format_paragraph_hook --------------------- This hook is called after a paragraph is formatted but only if a prefix argument was given prior to the execution of the internal function `format_paragraph'. More explicitly, the default binding of `format_paragraph' is `ESC q'. Pressing `ESC 1' immediately before pressing `ESC q' will format the paragraph and then call `format_paragraph_hook'. The default definition for this hook is in tmisc.sl, and causes the paragraph to be left and right justified. is_paragraph_separator ---------------------- This hook is called by the editor to locate paragraph delimiters. If defined, it applies globally to all buffers except those which have a local definition (see the description of the buffer-local `par_sep' hook). The default value is coded internally in C and basically reduces to: define is_paragraph_separator () { bol(); if (looking_at("\\") or looking_at("%")) return (1); skip_white(); return (eolp()); } which is useful for TeX mode. The hook must return a non-zero value if the current line is a paragraph delimiter or zero if it is not. command_line_hook ----------------- This hook is called from within the editor to parse the command line arguments, and it also loads the user's personal initialization file. It is defined in the file `site.sl' and should not be customized by the user. =========================================================================== Internal Hook Lists =========================================================================== Some internal hooks may be chained together. All hooks in a chain may be executed, or executed until some value is returned. A hook may be inserted at the beginning of a specified chain via the add_to_hook function, or appended to the chain via append_to_hook. _jed_startup_hooks ------------------ This set of hooks are called just prior to entering the main editor loop of the editor. All the hooks in the chain are called. Each hook takes no arguments and should return no values. An example of the hook is provided in site.sl. _jed_exit_hooks --------------- The hooks in this chain are called from the internal function `exit_jed'. Each hook in the chain is called until one of them returns a value less than or equal to zero. If one of these hooks returns such a value, then the attempted exit will be aborted. If one of the hooks recursively calls `exit_jed', then exit will take place without calling other exit-hooks. For instance, suppose that one wants to be prompted before exiting. The following accomplishes this: private define my_exit_hook () { variable ch; if (BATCH) return 1; ch = get_mini_response ("Really Exit?"); if ((ch == 'y') or (ch == 'Y')) return 1; return 0; } add_to_hook ("_jed_exit_hooks", &my_exit_hook); _jed_quit_hooks ---------------- The hooks in this list are called by the `quit_jed' function. Each hook in this list takes no arguments and returns no value. All hooks in the list are executed. For systems such as MSDOS or VMS that do not have a separate working directory for each process, it might be desirable to ensure that the editor exit in the same directory in which it started. The following quit-hook may be used to implement this: define my_quit_hook () { variable dir; if (bufferp("*scratch*")) { (,dir,,) = getbuf_info ("*scratch*"); () = chdir (dir); } } _jed_suspend_hooks ------------------ The hooks in this list are called by the `sys_spawn_cmd' function which causes the editor to be suspended on Unix, or spawn a subprocess on other systems. They are called prior to the suspension action and if any hook returns less than or equal to zero, suspension will not take place. _jed_resume_hooks ----------------- All the hooks in the _jed_resume_hooks list are called after returning from a suspension state. Hooks in this list take no arguments and return no values. A silly example of this hook is: private define my_resume_hook () { message ("Welcome back to JED"); } add_to_hook ("_jed_resume_hooks", &my_resume_hook); _jed_init_display_hooks, _jed_reset_display_hooks -------------------------------------------------- The corresponding hooks in these lists are called after initializing, or prior to resetting the display. The hook functions take no parameters and return no values. See lib/mousex.sl for an example of these hooks. _jed_save_buffer_before_hooks, _jed_save_buffer_after_hooks ------------------------------------------------------------ The hooks in these lists are called before and after the current buffer has been saved, respectively. Each hook is passed a single argument: the name of the file to which the buffer is to be written. The hooks return no values. _jed_find_file_before_hooks ---------------------------- Each of the hooks in this list will be passed the name of the file to be found. The hooks in this list are called until one returns a value of 1, which indicates that the file has been found and read into a buffer. Otherwise, the hook must return 0 to allow the rest of the hooks in the chain to run. If a hook indicates that the file has been found, then the related hooks _jed_find_file_after_hooks will _not_ be run. _jed_find_file_after_hooks --------------------------- After a file has been read into a buffer and had its mode set, all the hooks in this list are called. These hooks take no arguments and return no values. _jed_insert_file_hooks ----------------------- The hooks in this list are called upon to insert the specified file, passed as an argument to the hook into the current buffer. If the specified file has been inserted, the hook should return 1; otherwise it must return 0 to indicate that the file was not inserted. _jed_read_file_hooks --------------------- The hooks in this list are called upon to read the specified file passed as an argument to the hook, into an empty buffer. If the specified file has been read into the buffer, the hook should return 1; otherwise it must return 0 to indicate that the file was not read. Note that the difference between these hooks and _jed_insert_file_hooks is somewhat subtle. The main difference between the two sets of hooks is that the scope of _jed_insert_file_hooks is more limited. See lib/compress.sl for an example of these hooks. _jed_write_region_hooks, _jed_append_region_hooks ------------------------------------------------- These hooks are called upon whenever a region is written out, or appended to a file. Each of the hooks in these lists will be passed the name of the file. The hooks execute until one returns 1 to indicate that the region was written (or appended) to the specified file; otherwise the hooks should return 0. _jed_set_mode_hooks -------------------- These hooks are called before `mode_hook' is called to set the buffer's mode. Like `mode_hook', the filename extension is passed to the hooks in this list. If one of the hooks returns 1, the the mode is considered to be set. If none of the hooks return 1, then mode_hook will be called to set the mode. _jed_switch_active_buffer_hooks ------------------------------- These hooks are called from the main editing loop if the active buffer has changed to a different one. The active buffer is defined to be the buffer that one is interactively editing. One should note that this does not mean that these hooks will be called whenever one switches to a different buffer because such a switch may not be visible from within the main editing loop. Also note that these hooks may not be called during the execution of keyboard macros since they are executed outside of the main editing loop. Nor will these hooks be called when the mini-buffer is the current buffer since the mini-buffer is not considered to be an active buffer. Functions in this list take a single argument: the name of the previously active buffer. No value should be returned. The following example shows how this hook may be used to set the name of the Xjed window to that of the currently active buffer. private define my_switch_buffer_hook (old_buffer) { x_set_window_name (whatbuf ()); } add_to_hook ("_jed_switch_active_buffer_hooks", &my_switch_buffer_hook); _jed_before_key_hooks --------------------- These hooks are called just prior to the execution of the function bound to a key. Hooks of this type are passed a single value representing the function to be executed, and return no value. The value representing the key function may be either a string giving the name of the function or as a reference via a Ref_Type object. define before_key_hook (fun) {...} _jed_after_key_hooks --------------------- Hooks of this type are called after the function associated with a key has been executed. They are passed no value and should return no value. jed-0.99-19/doc/txt/jed_faq.txt0000644002657400265740000004515111311317447015216 0ustar davisdavisFrequently Asked Questions about the JED editor. To find the answer to one of the following questions, Search for the number enclosed in <>, e.g., <3> for question 3. ---------------------------------------------------------------------------- Frequently asked questions: 1. How do I obtain JED? (ftp and email) 2. How do I disable JED's C mode? 3. What is C mode? 4. How do I turn on wrap mode or turn it off? 5. What are the differences between internal and intrinsic functions? 6. Sometimes during screen updates, JED pauses. Why is this? 7. How do I get JED to recognize Control-S and Control-Q? 8. Can I bind the Alt keys on the PC? 9. How do I find out what characters a particular key generates? 10. JED scrolls slowly on my WizBang-X-Super-Terminal. What can I do about it? 11. How do I get a list of functions? 12. How can I use edt.sl with jed386.exe? 13. The TAB key is broken--- it does not insert TABs! 14. How do I set custom tab stops in jed? 15. When I paste text into Jed, it misaligns everything. How can I prevent this? 16. Why is copy/paste via the mouse not working on the console? 17. Jed makes a difference between a single '/' and multiple '/' in pathnames! Why? 18. Why is jed linked against libncurses when it uses slang? 19. When running Jed in an xterm, alt is not sending meta. So, how do I make alt-f skip word forwards? 20. How do I cancel a command that prompts me with "y/n" choices, without a "cancel" otpion? 21. I define keybindings in my jed.rc file but they are not working. What is wrong? ---------------------------------------------------------------------------- Answers: <1> How do I obtain JED? (ftp and email) JED is available via anonymous ftp from space.mit.edu in the pub/davis/jed directory. JED comes in three forms: jedxxx.tar.gz unix distribution for version xxx jedxxx.zip PC distribution with precompiled jed.exe All distributions are identical except that the zip file also contains a precompiled executable for PC systems. <2> How do I disable JED's C mode. The startup file `site.sl' contains the function `mode_hook' which is called whenever a file is loaded. This function is passed the filename extension. If a file with `c' or `h' extension is read, this function will turn on C-mode for that buffer. You could modify this function to not select C-mode. However, this is not recommended. Rather, it is recommended that you simply rebind the offending keybinding. These include: `{`, `}`, the TAB key, and the RETURN key. Simply put any or all of: "self_insert_cmd" "{" setkey "self_insert_cmd" "}" setkey "self_insert_cmd" "^I" setkey "newline" "^M" setkey in your personal startup file (jed.rc or .jedrc). Before you do this, are you sure that you really understand what C mode does? If not, please read on. <3> What is C mode? In C mode, the TAB key does not insert tabs. Instead, it runs a command called `indent_line'. It is really the quickest way to edit C code. In this mode, the TAB, RETURN, `{`, and `}' keys are special. If you edit a file called x.c, JED will invoke its C mode. Entering the 28 characters (no newline, TAB, etc...) `main (){if (x == 2){x = 4;}}' should result in: main () { if (x == 2) { x = 4; } } which would take alot more time using the TAB and NEWLINE keys. If you do not like the indentation style, you can customize it by setting the appropriate variables in jed.rc. My preference is to set the variables such that the SAME characters above yield: main () { if (x == 2) { x = 4; } } To see the use of the tab key, delete the whitespace in front of all the lines to produce: main () { if (x == 2) { x = 4; } } Now, move to any of the lines (anywhere on the line) and hit the TAB key. This should correctly indent the line to according to your preferences (i.e., the variables in jed.rc). Finally, move to one of the lines and enter `ESC ;'. This should produce a C comment. Using the C mode and the TAB key as indent_line also helps you avoid syntax errors. Basically, a line simply will not indent properly. This indicats that you left off a brace, mismatched parenthesis, etc... If you bind TAB away from indent_line, you lose some of this. Note that these same comments apply to Fortran mode. Get a file called `x.for'. Enter the characters: TABprogram mainRETinteger*4 iRETdo 10 i=1,3RETcall f(i)RET10continueRETend Here TAB means hit TAB and RET means hit return. This will result in: program main integer*4 i do 10 i=1,3 call f(i) 10 continue end Again, the editor has done all the work. Once you get used to this style of editing, you will not want to go back. Also note that this will not work if EDT is loaded. To get this functionality back, you will need to do: setkey("indent_line_cmd", "\t"); setkey("newline_and_indent_cmd", "^M"); AFTER edt.sl is loaded. <4> How do I turn on wrap mode or turn it off? Normally, this is done automatically when JED loads a file with extensions .txt, .doc, etc... See question 2 for a discussion of how this is done. To turn on wrap mode for the current buffer, simply press Escape-X and enter: text_mode at the prompt. To turn it off, you must change the mode to something else. A fairly generic choice is the `no_mode' mode. To do this, press Escape-X and enter: no_mode at the prompt. It is easy to write a function to toggle the mode for you that can be bound to a key. This one (toggle_wrapmode) will work: define toggle_wrapmode () { variable mode, modestr; (modestr, mode) = what_mode (); if (mode & 1) % test wrap bit mode = mode & ~(1); % wrap bit on so mask it off else mode = mode | 1; % wrap bit off so set it. set_mode (modestr, mode); } <5> What is the difference between internal and intrinsic functions? An intrinsic function is a function that is directly callable from S-Lang while an internal function cannot. However, internal functions can be called indirectly through the use of the intrinsic function `call'. For example, consider the internal function `self_insert_cmd'. Most typing keys are bound to this function and cause the key to be directly inserted into the buffer. Consider the effect of this. After a character to be inserted is received by JED, the buffer is updated to reflect its insertion. Then the screen is updated. Here lies the essential difference between the two types of functions. If the screen was in sync before the insertion, JED can simply put the terminal in insert mode, send out the character and take the terminal back out of insert mode. However, this requires knowing the state of the screen. If called from a S-Lang routine, all bets are off. Since the screen update is not performed until after any S-Lang function has returned to JED, the buffer and the screen will almost always be out of sync with respect to one another and a full screen update will have to be performed. But this is very costly to have to do for every insertion. Hence, JED makes a distinction between the two types of functions by making the most common ones internal. The upshot is this: intrinsic functions will cause a full screen update while internal ones may not. <6> Sometimes during screen updates, JED pauses. Why is this? Since version 0.91, JED checks the baud rate and tries to output characters based on reported rate. JED will literally sleep when outputting many characters if the reported baud rate is small. One should first check to see that terminal driver has the baud rate set appropriately. On Unix, this is done by typing `stty -a' at the shell prompt. If setting the baud rate to the correct value does not help, set the internal global variable `OUTPUT_RATE' to zero. This is achived by uncommenting the line referring to OUTPUT_RATE in the jed.rc initialization file. If there is still a problem, contact me. <7> How do I get JED to recognize Control-S and Control-Q? Many systems use ^S/^Q for flow control--- the so-called XON/XOFF protocol which is probably the reason JED does not see either of these two characters. Perhaps the most portable solution to this problem is to simply avoid using ^S and ^Q altogether. This may require the user to rebind those those functions that have key bindings composed of these characters. JED is able to enable or disable flow control on the system that it is running. This may be done by putting the line: enable_flow_control (0); % turn flow control off in your .jedrc file. Using a value of 1 turns flow control on. Another solution is to use the `map_input' function to map a different key to ^S (and ^Q). For example, one might simply choose to map ^\ to ^S and ^^ (Control-^) to ^Q. To do this, simply put: map_input (28, 19); % ^\ --> ^S map_input (30, 17); % ^^ --> ^Q in your .jedrc (jed.rc) file. <8> Can I bind the Alt keys on the PC? Yes. The ALT keys return a two character key sequence. The key sequence for a particular ALT key as well as other function keys are listed in the file `pc-keys.txt'. Many users simply want to use the ALT key as a Meta Character. To have JED interpret ALT-X as ESC-X, put ALT_CHAR = 27; int your jed.rc file. Here `X' is any key. (Actually, this should not be necessary-- the default value for ALT_CHAR is 27). <9> How do I find out what characters a particular key generates? The simpliest way is to start JED via the command: jed -l keycode -f keycode JED will then prompt for a key to be pressed and return the escape sequence that the key sends. If Xjed is used, it will also return the keysym (See online help on the x_set_keysym function for more information). An alternative approach is to use the quoted insert function. By default, this is bound to the backquote (`) key. Simply switch to the `*scratch*' buffer, press the backquote key followed by the key in question. The key sequence will be inserted into the buffer. This exploits the fact that most multi-character key sequences begin with the ESC character followed one or more printable characters. If this fails, the following function will suffice: define insert_this_key () { variable c; pop2buf ("*scratch*"); eob (); message ("Press key:"); update (1); forever { c = getkey (); if (c == 0) insert("^@"); else insert (char (c)); !if (input_pending (3)) break; } } Simply type it into the scratch buffer, press ESC-X and type `evalbuffer'. Then, to use the function, press ESC-X again and enter `insert_this_key'. <10> JED scrolls slowly on my WizBang-X-Super-Terminal. What can I do about it? On Unix, JED uses termcap (terminfo) and the value of the TERM environment variable. Chance are, even though you are using an expansive state of the art terminal, you have told unix it is a vt100. Even if you have set the TERM variable to the appropriate value for you terminal, the termcap file may be missing entries for your ``WizBang'' features. This is particularly the case for Ultrix systems--- the vt102, vt200, and vt300 termcap entries are missing the AL and DL termcap flags. In fact, the Ultrix man page for termcap does not even mention these capabilities! JED is able to compensate for missing termcap entries only for vtxxx terminals. If your terminal is a fancy vtxxx terminal, put the line: set_term_vtxxx (0); in your .jedrc file. <11> How do I get a list of functions? Help on any documented function is available by pressing `Ctrl-H f' and entering the function name at the prompt. If you simply hit return, you will get the documentation for all functions. <12> How can I use edt.sl with jed386.exe? The basic problem is the current generation of the 32 bit compiler (DJGPP) used to generate jed386.exe cannot handle the hardware keyboard interrupt used to remap the numeric keypad. Nevertheless, it is possible to use edt.sl with jed386. However, the function keys, F1 to F10 must be used for the EDT keypad. The remapping is as follows: VT100 Keys IBM Function On the Numeric Keypad ------------------------- ------------------------- | F1 | F2 | F3 | F4 | | PF1 | PF2 | PF3 | PF4 | |-----+-----+-----+-----| |-----+-----+-----+-----| | F5 | F6 | F7 | F8 | | 7 | 8 | 9 | - | |-----+-----+-----+-----| |-----+-----+-----+-----| | F9 | F10 | F11 | F12 | | 4 | 5 | 6 | , | |-----+-----+-----+-----| |-----+-----+-----+-----| | SF1 | SF2 | SF3 | SF4 | | 1 | 2 | 3 | | |-----------+-----|-----| |-----------+-----|ENTER| | SF5 | SF6 | SF7 | SF8 | | 0 | . | | ------------------------- ------------------------- Here, SF1 means SHIFT-F1, etc... <13> The TAB key is broken--- it does not insert TABs! Should it? By default, the TAB key runs the `indent_line' function. If you really want the TAB key to insert TABS, then you will have to bind it to `self_insert_cmd'. To do this for all modes, put the following lines in your .jedrc file: public define global_mode_hook (hook_name) { local_setkey ("self_insert_cmd", "\t"); } setkey ("self_insert_cmd", "\t"); See <2> for a related topic. <14> How do I set custom tab stops in jed? Put something like: variable Tab_Stops = [0:19]*8 + 1; in your jed.rc file to define 8-column tab stops. To individually set them use Tab_Stops[0] = 4; Tab_Stops[1] = 18; etc... <15> When I paste indented text into Jed, it misaligns everything (i.e. every succeeding line is indented more than the previous, yielding horizontally cascading text). How can I prevent this? The reason, why this happens is: In Jed, carriage return is bound to `newline_and_indent'. While this auto-indention is a great help in normal editing, it stands in the way when text is pasted via the mouse. Unfortunately, Jed cannot tell whether its input comes from a keyboard, another program, or the mouse (XJed can). There is more than one answer to how you can prevent it: 1: Use xjed. 2: Use the `paste' function 1. M-x paste (or bind "paste" to a key) 2. Now paste your text... 3: Install txtutils [1] from jedmodes and use newline_indent(). See Help>Describe_Function newline_indent for details. [1] http://jedmodes.sourceforge.net/mode/txtutils/ 4: Temporarily change the keybinding by doing: 1. M-X local_setkey("newline","^M") (Alt-Shift-X: the S-Lang prompt) 3. Now paste your text... 4. M-X local setkey("newline_and_indent","^M") 5: Bind "newline_and_indent" to a different key. In jed.rc do e.g.: #ifndef XWINDOWS IBMPC_SYSTEM % Fix staircase effect with mouse-pasting in an x-terminal setkey("newline", "^M"); setkey("newline_and_indent", "\eM"); % Alt_Return % Some modes overwrite the Key_Return binding. Restore it: define global_mode_hook (hook) { if (wherefirst(what_keymap() == ["C", "DCL", "IDL", "perl", "PHP"]) != NULL) local_setkey("newline", "^M"); } #endif <16> Why is copy/paste via the mouse not working on the console? First, be sure that the gpm package is installed and correctly configured. Copying and pasting in a JED window on the console should then work like in X-Windows (with a three button mouse, for instance, select with the left button and paste with the middle button). However, for inserting text selected outside the JED window, you should press down the Alt key when pasting with the mouse. <17> Jed makes a difference between a single '/' and multiple '/' in pathnames - e.g., '/usr//bin/' is *not* equal to '/usr/bin/'! Why? This is also how Emacs behaves and is part of the emacs emulation. <18> Why is jed linked against libncurses when it uses slang? Because it has GPM mouse support and the GPM librares use ncurses. <19> When running Jed in an xterm, alt is not sending meta (and meta is not sending escape) so that alt-f and alt-b e.g., don't skip words forwards and backwards respectively. According to Thomas Dickey (do a google search to see that there is NO arguing here :) this is normal for xterm. To make alt "work", add 'xterm*metaSendsEscape: true' to your .Xresources (or equivalent) and make sure 'xmodmap -e "keysym Alt_L = Meta_L Alt_L"' is executed somewhere at X-startup (modify e.g., ~/.Xmodmap). <20> How do I cancel a command that prompts me with "y/n" choices, without a "cancel" otpion? In Jed, (almost all) actions can be aborted by pressing a configurable "abort character" or calling the function kbd_quit(). The most used default abort character is `Ctrl-G'. Some emulations use a different default: CUA: `Ctrl-D' (and optional ESC, see cua_escape_cmd()) Wordstar: `Ctrl-^' (AKA Ctrl-6) <21> I define keybindings in my jed.rc file but they are not working. What is wrong? Jed will load a fallback keybinding-file if you do not specify an emulation in your jed.rc overwriting your bindings. Either select an emulation in your jed.rc (as in the example file), or put your keybindings inside a keybindings_hook(), e.g.:: define keybindings_hook(emulation) { setkey("menu_select_menu(\"Global.&Help\")", Key_F1); % ... } If you define all your keybindings without resorting to an emulation mode, set the variable _Jed_Emulation (e.g. _Jed_Emulation = "cool") to prevent loading the _Jed_Default_Emulation fallback. ------------------------------------------------------------------------------- This is a useful function used to maintain numbers in this faq. define faq_fix () { variable n; n = 1; bob(); bol_fsearch("---------------"); pop(); % always found push_mark(); bol_fsearch("-------------"); pop(); narrow(); bob(); while (re_fsearch("^[0-9]+\\.")) { replace_match (strcat(string(n), "."), 1); pop(); ++n; } widen(); n = 1; while (re_fsearch("^<[0-9]+>")) { replace_match (Sprintf("<%d>", n, 1), 1); pop(); ++n; } } jed-0.99-19/doc/txt/color.txt0000644002657400265740000000323011311317447014733 0ustar davisdavisThis is a short note explaining how to use JED with a color terminal. This only applies to Unix and VMS. This is particularly relevant if you want to exploit JED's ability to do color syntax highlighting on a character based terminal. *Note: If you use MS-Kermit as a terminal emulator, you will need to tell it what foreground/background colors you want via the `set term color' function. For example, if you choose back on white as the `normal' color, put `set term color 30 47' in your MSKermit.ini file. This same comment applies to other color terminals which emulate this flawed color model. To use JED with a color terminal, it is necessary that the terminal understand ANSI color escape sequences. If so, then it is possble to set up JED to use different foreground and background colors for the modeline, region highlighting, syntax highlighting, etc... To turn on ANSI color support, set the variable `USE_ANSI_COLORS' to a non-zero value. If set to zero, the support is turned off. The colors may be specified using the set_color function as illustrated in jed.rc. They only become active if USE_ANSI_COLORS is non-zero. Unfortunately, few termcaps provide information regarding whether the terminal is a color one or not. To interactively set USE_ANSI_COLORS, simply press `Ctrl-X ESC' and enter USE_ANSI_COLORS = 1 at the `S-Lang>' prompt. This variable is automatically set to a non-zero value by jed if environment variable COLORTERM exists. Finally, you could simply put: define term_use_colors () { USE_ANSI_COLORS = 1; } in your jed.rc (.jedrc) and define (alias) jed to be: alias colorjed 'jed -f term_use_colors' jed-0.99-19/doc/txt/linux-keys.txt0000644002657400265740000000206511311317447015732 0ustar davisdavisMatti-Oskari Leppänen suggested the following: I think that you should mention somewhere in documents howto make shift-arrow etc. work under linux-console ... because it's quite simple just make file that has following lines save it as some.map and loadkeys some.map then you have same keysyms as used in wmark.sl ________________________________________________ # S+Up shift keycode 103 = F100 string F100 = "\033[a" #S+Left shift keycode 106 = F101 string F101 = "\033[c" #S+Right shift keycode 105 = F102 string F102 = "\033[d" # S+Down shift keycode 108 = F103 string F103 = "\033[b" #C+Ins control keycode 110 = F104 string F104="\033[2^" #S+Ins shift keycode 110 = F105 string F105="\033[2$" #S+PgUp shift keycode 104 = F106 string F106 = "\033[5$" #S+PgDn shift keycode 109 = F107 string F107 = "\033[6$" #S+Home shift keycode 102 = F108 string F108 = "\033[1$" #S+End shift keycode 107 = F109 string F109 = "\033[4$" #S+Del shift keycode 111 = F110 string F110 = "\033[3$" #C+Del control keycode 111 = F111 string F111 = "\033[3^" jed-0.99-19/doc/txt/script.txt0000644002657400265740000001016411311317447015125 0ustar davisdavisThis document describes how to use JED in its non-interactive mode. It assumes that the reader is reasonably familiar with S-Lang programming for JED. --------------------------------------------------------------------------- In a very real sense, JED is a text processing utility that operates in two modes: interactive mode and non-interactive or BATCH mode. One example of using JED in batch mode is: jed -batch -l preparse.sl JED will run non-interactively only if the command line parameter is `-batch'. For example, % jed -batch -f quit_jed loading /usr/local/jed/lib/site.slc loading /usr/local/jed/lib/os.sl loading /usr1/users/davis/.jedrc Notice that this is very noisy since it displays all the files that it is loading. There is a quieter non-interactive form that is specified by using `-script' instead of `-batch'. The syntax for this parameter is: jed -script script-file [arg] .... The `-script' parameter functions exactly like the `-l' (load file) parameter except that 1. It runs in non-interactive mode. 2. The rest of the command line arguments (arg) are not parsed. It is up to the code in the script file to parse the remaining arguments if they are present. 3. The user's .jedrc (jed.rc) file is NOT loaded. To load it, add the appropriate `evalfile' to the script. It is best to provide an example, although silly. This example script writes simply counts the number of lines in the files specified on the command line and writes the value on stdout. --------------------------------------------------------------------- static variable i = 3; static variable count = 0; if (__argc <= 3) { message ("Usage: jed -script count-lines.sl file ..."); quit_jed (); } while (i < __argc) { () = read_file (__argv[i]); eob (); count += what_line (); if (bolp ()) count--; delbuf (whatbuf()); i++; } vmessage ("%d lines", count); quit_jed (); ---------------------------------------------------------------------- Note the following points: 1. When the script file is loaded, the NEXT command line argument to be evaluated is 3. 2. The global variable __argc contains the number of command line arguments. The command line arguments are contained in the array __argv. Since the arguments are numbered from 0, the last one is number __argc - 1. The ith command line argument is given by __argv[i]. For this particular example, the __argv array will consist of: __argv[0] = "jed" __argv[1] = "-script" __argv[2] = "count-lines.sl"; __argv[3] = the name of the file to be processed 3. `quit_jed' is called to exit the editor. `exit_jed' could also be used when it is necessary to run the exit hooks. To exectute this script, type: % jed -script count-lines.sl It should display the usage message. Unix also provides a mechanism for making any script file an executable file. The trick is to add the appropriate line to the top of the script and change the permissions on the script to make it executable. In this case, do the following: 1. Add: #!/usr/bin/env jed-script to the top of the file. The /usr/bin/env program is used because some operating systems put a limit on the number of characters allowed in this line. Note also "jed-script" is used. Here jed-script is a assumed to be a symbolic link to jed. 2. At the unix prompt, enter: chmod +x count-lines.sl As a final example, consider a script file that may be used in DOS batch files to replace strings in files, e.g., to replace all occurances of `x' with `y' in `C:\windows\win.ini'. If such a script file is called `change.sl', it could be used as: jed -script change.sl C:\windows\win.ini x y A script file that performs this task is: % change.sl if (__argc != 6) { message ("Usage: jed -script change.sl file old-string new-string"); quit_jed (); } () = read_file (__argv[3]); replace (__argv[4], __argv[5]); save_buffer (); quit_jed (); jed-0.99-19/doc/txt/wordstar.txt0000644002657400265740000000344711311317447015474 0ustar davisdavisJED Wordstar mode notes 0. To enable wordstar emulation, comment out the line in jed.rc loading emacs and edt bindings. Then uncomment the line regarding wordstar bindings. 1. The abort character is changed from ^G to ^^ (^6 on most keyboards). This is necessary because ^G is bound to delete character in wordstar. 2. I have implemented ^K, and ^Q keymaps. I do not know bindings for other keymaps which is why they are not defined. If there are any missing bindings and keymaps, please feel free to let me know and I will try to add them. 3. Wordstar idea of block is preserved. I have not changed its meaning as emacs does. However, note that wordstar's concept of a region is different from the concept that JED uses. For this reason, blocks in JED's wordstar mode are not highlighted. Bug me if you want this changed. 4. Since one of the keymaps is ^Q, it is up to the user to make sure that JED can receive the ^Q character. This means that the user must make sure that ^Q is not used for flow control. The alternative would be to use the map_input function to map a different control character to ^Q. See jed.txt for details. 5. Finally, you might consider the native JED keybindings which are based on my experience using the Turbo Pascal editor. To get an idea of these bindings, startup jed with no default init file as by using `jed -n'. Once in jed, press ESC-X and enter `describe_bindings' at the prompt. If you get lost, press ^H? for menus. Using the default JED bindings results in a faster startup of JED since there is no need to load any keybindings other than possible extensions to the default ones. Mail comments and suggestions for the wordstar mode to davis@space.mit.edu. jed-0.99-19/doc/txt/undo.txt0000644002657400265740000000041011311317447014557 0ustar davisdavisThe `undo' function is bound to keys `Ctrl-_' and `Ctrl-X u'. There is no `redo' function. However, it is possible to `redo' by first pressing `Ctrl-G' followed immediately by either `Ctrl-_' or `Ctrl-X u'. That is, `Ctrl-G' tells the `undo' function to `redo'. jed-0.99-19/doc/txt/pc-keys.txt0000644002657400265740000000744711311317447015206 0ustar davisdavis%% Key codes returned for most Alt keys and Control-keypad keys %% The ALT key definitions assume that the global variable ALT_CHAR is 0. %% The default value of ALT_CHAR is 27 which means that if you want to %% use the values presented below, you will have to set ALT_CHAR to 0 in %% your jed.rc file. %% example: define Alt-1 to goto top of buffer (bob): %% %% setkey ("bob", "^@x"); %% %% For other keys, use this function to find out what they represent: %% define ibmpc_showkey() { variable c, ch, key = Null_String; variable timeout = 50; % 5 seconds flush ("Press key:"); while (input_pending(timeout)) { timeout = 0; c = getkey(); if (c == 0) ch = "^@"; else { if (c == 224) ch = "\\xE0"; else if (c > 127) ch = strcat ("\\d", string (c)); else ch = char (c); } key = strcat(key, ch); } % insert (key); message (key); } % Alt-1 ^@x % Alt-2 ^@y % Alt-3 ^@z % Alt-4 ^@{ % Alt-5 ^@| % Alt-6 ^@} % Alt-7 ^@~ % Alt-8 ^@ % Alt-A ^@^^ % Alt-B ^@0 % Alt-C ^@. % Alt-D ^@ SPACE % Alt-E ^@^R % Alt-F ^@! % Alt-G ^@\" % Alt-H ^@# % Alt-I ^@^W % Alt-J ^@$ % Alt-K ^@% % Alt-L ^@& % Alt-M ^@2 % Alt-N ^@1 % Alt-O ^@^X % Alt-P ^@^Y % Alt-Q ^@^P % Alt-R ^@^S % Alt-S ^@^_ % Alt-T ^@^T % Alt-U ^@^V % Alt-V ^@/ % Alt-W ^@^Q % Alt-X ^@- % Alt-Y ^@^U % Alt-Z ^@, % % These are the 6 keys on the small keypad + 4 Arrow keys below % Key No-modifier Ctrl Shift Alt % ------------------------------------------------------------- % Home \xE0G \xE0w \xE00 ^@\d151 % Up \xE0H \xE0\d141 \xE01 ^@\d152 % PgUp \xE0I \xE0\d132 \xE02 ^@\d153 % Left \xE0K \xE0s \xE03 ^@\d155 % Right \xE0M \xE0t \xE04 ^@\d157 % End \xE0O \xE0u \xE05 ^@\d159 % Down \xE0P \xE0\d145 \xE06 ^@\d160 % PgDn \xE0Q \xE0v \xE07 ^@\d161 % Insert \xE0R \xE0\d146 \xE08 ^@\d162 % Delete \xE0S \xE0\d147 \xE09 ^@\d163 % These keys are located on the numeric keypad % Key No-modifier Ctrl Shift Alt % ------------------------------------------------------------- % End Oq ^@u % Insert Op ^@\d146 % Home Ow ^@w % Delete On ^@\d147 % PgUP Oy ^@\d132 % PgDn Os ^@v % Left Ot ^@s % Right Ov ^@t % Up Ox ^@\d141 % Down Or ^@\d145 % Five Ou ^@\d143 % Slash OQ ^@\d149 OQ ^@\d164 % Star OR ^@\d150 OR ^@7 % Minus OS ^@\d142 OS ^@J % Plus Om ^@\d144 Om ^@N % Enter OM OM ^@\d166 % % % Key No-modifier Ctrl Shift Alt % ------------------------------------------------------------- % F1: ^@; ^@^ ^@T ^@h % F2: ^@< ^@_ ^@U ^@i % F3: ^@= ^@` ^@V ^@j % F4: ^@> ^@a ^@W ^@k % F5: ^@? ^@b ^@X ^@l % F6: ^@@ ^@c ^@Y ^@m % F7: ^@A ^@d ^@Z ^@n % F8: ^@B ^@e ^@[ ^@o % F9: ^@C ^@f ^@\ ^@p % F10: ^@D ^@g ^@] ^@q % F11: ^@\d133 ^@\d137 ^@\d135 ^@\d139 % F12: ^@\d134 ^@\d136 ^@\d136 ^@\d140 jed-0.99-19/doc/txt/syntax.txt0000644002657400265740000000502111311317447015143 0ustar davisdavisJED is now able to do simple syntax highlighting while in C, Fortran, or TeX mode. To enable syntax highlighting, in your startup file (.jedrc, jed.rc) set the variable `WANT_SYNTAX_HIGHLIGHT' to 1. On Unix and VMS systems, it is also necessary to set the variable `USE_ANSI_COLORS' to a non-zero value. To control how to do color syntax highlight highlighting, use the `set_color' function. This function takes three parameters: the first says what to color and the last two specify what foreground and background colors to use. The `what' parameter can be any one of: "operator" "number" "comment" "string" "keyword" "delimiter" "preprocess" What these actually refer to is mode dependent. For C mode, they have the following meaning: "operator" : `+', `-', `*', `/', `?', etc. "number" : 1.23, -3, 0x101, etc... "comment" : /* c comment */ // c++ comment "string" : "anything in single or double quotes" "keyword" : c++ keywords such as `if', `while', `register', `class' "delimiter" : Braces {}, parenthesis, commas, etc... "preprocess" : Lines starting with `#' Fortran mode syntax highlighting is similar to C mode. In TeX mode only "number" : a formula: $c^2 = a^2 + b^2$ "comment" : % This is a comment "keyword" : Anything following a slash(e.g., \begin) and `{', `}', `&', etc... have meaning. Any other object not falling in any of the above categories is not highlighted. In C mode, to avoid the task of parsing the buffer on every screen update, comments must either be confined to a single line, or have the following format: /* This is a multi-line * comment. Note how the lines * following the initial one * start with a `*' followed by a * whitespace character */ That is, the second, third, and lines must start with one or more `*' followed by at least one whitespace character. This means that *p++ = ' '; will not be interpreted as comment but * p++ = ' '; will be flagged by the editor as a comment line. Finally, if the screen is panned to the right, syntax highlighting will sometimes fail. This is because the highlighting is performed based entirely upon the visible information. This is only a problem when strings are split with the beginning off to the left of the display (not visible) and the end lying in the visible portion of the buffer. A similar statement holds for comments as well. jed-0.99-19/doc/txt/ide-mode.txt0000644002657400265740000001726311311317447015313 0ustar davisdavisIDE Mode for Jed ----------------- By Guido Gonzato, Version 1.3.0. 27 February 2001. Introduction ------------- IDE mode is a compatibility mode for the editor Jed, specifically designed for former DOS/Windows users. It aims at making Jed as similar to the Borland IDE as possible. If you have experience with any of the Borland (now Imprise) languages (Turbo Pascal, Turbo C++, etc), or DOS/Windows edit, or even the ancestor WordStar, you will feel immediately at home with Jed. Joe users accustomed to the Jstar version will like IDE mode, too. I wrote IDE Mode because many years ago I used WordStar, whose key bindings are now firmly etched in my DNA. Years of experience with DOS, Turbo Pascal, and Turbo C++ don't help switching to Emacs... IDE mode is based on John E. Davis' original wordstar.sl, which IMHO should be considered obsolete. This version works with Jed B0.99.12 upwards, under Linux (console, xterms and Xjed) and DOS/Windows; it won't work with Wjed. Installation ============ To enable IDE mode, include this line in your .jedrc (Linux) or jed.rc (DOS/Windows): () = evalfile ("ide"); Make sure that all references to emacs.sl, brief.sl, and wordstar.sl are commented out. IDE mode has been tested on a wide range of terminals, and should work well even if you use Jed over a Telnet/SSH session. I tried successfully with these fine telnet/ssh clients for Windows: TeraTerm (http://www.zip.com.au/%7Eroca/ttssh.html), Putty (http://www.chiark.greenend.org.uk/%7Esgtatham/putty.html), and Mindterm (http://www.mindbright.se/mindterm). Some terminal emulators may cause problems, though. If you get this error: S-Lang Error: Inconsistency in define key. or if there are problems with colours and/or function keys, then try to redefine the TERM variable to `xterm-color' or `vt220': $ export TERM=xterm-color # bash $ setenv TERM xterm-color # csh This may be required for recent rxvts and xterms. Your mileage may vary. Note for EDT users ------------------- IDE mode and EDT mode can happily coexist, and I actually use them both. To try out IDE and EDT mode together, edit your .jedrc so that it reads: () = evalfile("edt"); % EDT mode can coexist with IDE mode () = evalfile("ide"); % use IDE mode in addition to EDT That way you can use *both* EDT and IDE keybindings, taking advantage of some of the features that EDT mode doesn't offer. Main Features -------------- Writing ide.sl I tried hard to implement as many of the Borland key bindings and routines as possible; some ideas were copied from Jstar. To begin with, most special keys are supported: F1: help F2: save current buffer F3: load file in a new buffer F4: (unimplemented) F5: magnify the current window F6: switch to the next buffer F7: ispell F8: (unimplemented) F9: compile F10: invoke the system menu ESC-F3: close the current buffer ESC-F1: help on the function under the cursor ESC-letter is equivalent to Alt-letter. There are a few inevitable differences (see below). IDE mode also modifies the standard menus, adding a few items. This is the help file for IDE mode: ------------------------------------------------------------------------------ JED IDE mode 1.3.0. ^ = Ctrl (e.g., ^X = Ctrl-X); M = Alt (M-X = Alt-X) Press `q' to quit this help screen; F6 or ^KP to switch to the next buffer CURSOR GO TO BLOCK DELETE EXIT ^S left ^D right ^R prev. screen ^KB begin M-G char ^KX save ^E up ^Z down ^C^C next screen ^KY cut ^Y line ^KZ shell ^A word ^QS beg. of line ^KH copy ^T >word ^QD end of line ^KC paste M-BS line ^KE new ^QF find text ^QX screen end ^KT word ^U undo ^KR insert ^QA replace ^QR top of file ^K/ filter ^KQ kill ^L find next ^QC end of file ^KG to reg. MACRO ^KD save ^QT toggle case ^Q0-9 bookmark ^KJ from reg. ESC-( beg. ^KS save as ^QI line No. ^KU up. case ESC-) end ^KN next MISC ^QP prev.position ^KL lo. case M-R run ^KP prev. ^B reformat ^K0-9 set bookmark ^KI one window ^V completion ^P compose char Press M-X or ESC-X to issue commands; press ^G to quit the command line Press F10 to activate the menus. Please read the documentation! ------------------------------------------------------------------------------ Other features you may find handy: o after any movement or operation you can go back to the previous location with ^QP. o additional block operations: ^KT selects a word, ^KL turns the block to lowercase, ^KU to uppercase, ^K/ filters the block through an external filter (e.g. sort, tr, tac...), ^K; comments out the block according to the language (TeX, C, Fortran...), ^K: uncomments the block, ^KG copies the block to a "register" (multiple clipboard), ^KJ pastes the contents of a register. o macros: Alt-( or ESC-( to start defining a macro, Alt-) or ESC-) to end, Alt-R or ESC-R to run the macro. o special characters: press ^P + ASCII code to insert a special character (e.g., ^P123 inserts a left curly bracket '{'). There could be many more things to say. If you are curious, browse the file ide.sl for a complete list of available features. Differences ------------ Some key bindings/actions couldn't be fully implemented. The miss-list includes: o Ctrl-G doesn't act as DELETE key; use Alt-G instead. The original wordstar.sl uses ^^, which is a pain to find on non-US keyboards. o F3 is bound to File->Open as in Borland IDE, instead of Repeat Search as in DOS edit. o Alt-F3 doesn't close the current buffer, because this key binding is employed to switch to the third virtual console under Linux. Use ESC-F3 instead. o Alt-X doesn't quit Jed. This key binding is reserved for Jed's minibuffer. o more importantly: blocks are implemented with the usual key bindings, but behave differently. In fact, blocks are handled as in Emacs mode to provide compatibility with many other .sl files. You don't actually use a block, but rather define a region: - define the beginning with ^KB - there is no need to define the end with ^KK!!! - press ^KH to copy the block to the clipboard, or - press ^KY to delete ("cut") the block, or - press one of the other keybindings to perform an action on the block; for instance, ^K/ filters the block to an external filter. ^QB and ^QK work as usual. Can you think of any other differences? If so, please let me know and I'll try and see to it. Better Windows Compatibility ----------------------------- I strongly suggest that you put these lines in your .jedrc file: () = evalfile ("wmark.sl"); % Windows-like regions () = evalfile ("mousex.sl"); % use the mouse in xterm wmark.sl provides the capability of defining blocks using Shift-arrow, plus a few other features: Ctrl-Ins to copy the block to the clipboard, Shift-Ins to paste the clipboard contents, Bs to delete the block, etc. Unfortunately, it doesn't work in Linux console but only in Xjed. Final Remarks -------------- I use IDE Mode every day and I'm very satisfied with it. I hope I have done something useful for other people too. Special thanks to John E. Davis for writing Jed! Cheers, Guido =8-) -- Dr. Guido Gonzato - NT & Linux System Administrator My public PGP key is at http://ibogeo.df.unibo.it/guido/PGP.asc "It is a good morning exercise for a research scientist to discard a pet hypothesis every day before breakfast. It keeps him young." -- Konrad Lorenz jed-0.99-19/doc/txt/xrenderfont.txt0000644002657400265740000000154711311317447016164 0ustar davisdavisXJed is able to utilise the X Render extensions in order to display anti-aliased fonts. If you're going to use this, do the following easy steps: 1. Read http://www.xfree86.org/~keithp/render/aafont.txt (and act) 2. Make sure "xterm -fa mono" renders anti-aliased fonts 3. Edit the jed src/Makefile (AFTER you've run configure) and modify the XRENDERFONT_LIBS and XRENDERFONT_CFLAGS variables. 4. Build JED 5. With the newly compiled xjed, try something like: xjed -fn mono -fs 16 masterpiece.c If you don't specify -fs somenumber (facesize, e.g. -fs 12 or -fs 16) jed will revert to traditional font rendering. When -fs is specified, the -fn parameter is treated as facename, so you can do things like: xjed -fn trebuc -fs 16 bomb.c This functionality was brought to you by: Charl P. Botha March 26, 2001 (updated Oct 2005) jed-0.99-19/doc/txt/menus.txt0000644002657400265740000000353311311317447014752 0ustar davisdavisThis file documents the drop-down menu support in non-Windows versions of jed. Menu Activation and Navigation ------------------------------ The menus may be activated via the mouse, or by pressing the F10 key or the ESC-m key. Also, ESC + accelerator character may be used to activate a particular menu-bar item, e.g. `ESC-f' to select the `File' menu, provided that the particular editor emulation does not bind the key to something else. For example, Emacs uses ESC-f to move by words. See the discussion about `enable_menu_keys' below to work around this problem. The arrow keys or the mouse may be used to navigate the menus. Use the ENTER key to select a menu item. To go back to a previous menu, press either the ESC key or the backspace key. Menu Colors ----------- The colors of the menus may be controlled by the `set_color' strings: "menu" Color of the menu bar "menu_popup" Color of the popped-up menu window "menu_char" Color of the keyboard-accelerator character "menu_selection" Color of the current selection "menu_shadow" Color of the popup-box shadow Special Hints ------------- To enable the mouse when running jed in an xterm, put the line enable_xmouse (); in your .jedrc file. To hide the menu bar, put enable_top_status_line (0); in your .jedrc file. This will hide the menu bar until it is activated via a key such as F10. Some terminals map the ALT key modifier to ESC + key. For such terminals, an item on the menu bar may be activated via the ALT key + the accelerator key, e.g., `ALT-f' to select the file menu. The main problem with hot-keys such as ESC-f is that certain modes rebind these keys to other function. To rebind these keys to the menubar functions, put the line: enable_menu_keys (); in your .jedrc file AFTER loading the appropriate editor emulation, e.g., emacs. jed-0.99-19/doc/txt/yankpop.txt0000644002657400265740000001070311311317447015301 0ustar davisdavisThis document discusses Jed's implementation of yank-pop. Briefly, yank-pop allows one to use multiple paste buffers in a convenient way. Jed's implementation provides 16 such pastebuffers. The file, jed/lib/yankpop.sl provides the interface and in particular the following functions: yp_yank Ctrl-Y yp_yank_pop ESC Y yp_bkill_word ESC DEL yp_kill_word ESC d yp_kill_line Ctrl-K yp_kill_region Ctrl-W yp_copy_region_as_kill ESC W which are meant to be bound to keys. The second column shows the default emacs bindings. It should be obvious from the names of these functions that the can be grouped into two categories: those that ``kill'' and those that ``yank''. Associated with these two groups are two active pastebuffers--- one where text is ``killed'' into and one where previously killed text is ``yanked'' from. Most of the time these two pastebuffers are equivalent. That is, a kill followed by a subsequent yank will result in the yank using the pastebuffer that was used for the kill. In fact, whenever something is killed, the yank pastebuffer automatically is set to the one used for the kill. Only the `yp_yank_pop' function can change the active yank pastebuffer to something different from the active kill one. The kill functions put what they have killed into the currently active pastebuffer. If the last key sequence entered from the keyboard did not invoke one of the kill functions, the currently active pastebuffer becomes the next one in the ring of pastebuffers and the killed text is placed in it. Otherwise the last key sequence invoked one of the kill functions and the text from the kill will be appended to the text from the last kill. It is important to note that the act of killing something sets the pastebuffer for a subsequent yank to the pastebuffer used for the kill. {Terminology: By a ring of pastebuffers, it is meant that when the all the pastebuffers become used, the contents of the oldest one will be discarded and that one will become the active one.} This sounds more complex than it really is. Consider the act of moving somewhere and pressing the sequence `ESC d' three times in a row to execute the `yp_kill_word' function. The first `ESC d' sequence results in deleting a word and placing it in a new currently active pastebuffer since the previous key sequence was not a kill sequence. The other two `ESC d' sequences follow a kill sequence, namely, the first `ESC d'. This means that the next two words will be appended to the first one that was killed. So, if the `yp_yank' function is invoked via Ctrl-Y, the three killed words will be pasted back as if they had been killed together. There are two yank functions: `yp_yank' and `yp_yank_pop'. The `yp_yank' function simply pastes text into the buffer from the the current pastebuffer for yanking. One the other hand, the `yp_yank_pop' function must immediately follow the `yp_yank' function or another `yp_yank_pop'. It will delete (not kill) the previously pasted text with the text in the pastebuffer that comes immediately before the current yank pastebuffer in the ring of pastebuffers. The current yank pastebuffer will then become the one selected by `yp_yank_pop'. Simply stated, the `yp_yank_pop' allows the user to cycle through the set of pastebuffers. Again, this is best illustrated with an example. We will continue with the previous one. After killing the three words as previously described, consider moving to the top of the buffer and deleting the top line by pressing Ctrl-K to invoke the `yp_kill_line' function. In doing so, we are left with two used pastebuffers: the most recent contains the line killed at the top of the buffer and the other contains the three words that were killed earlier. Now move somewhere else and press Ctrl-Y to invoke the function `yp_yank'. This results in the pasting of the line killed at the top of the buffer at the current position. Now, press `ESC y' to invoke the `yp_yank_pop' function. This replaces the the text that was just pasted with the three words that were kill earlier. Continue to press the `ESC y' key sequence. This will result in cycling between the two pastebuffers and replacing the text that was most recently pasted with the text from the other pastebuffer. The last pastebuffer for the paste will become the active one for future yanks until the next kill. jed-0.99-19/doc/txt/filelock.txt0000644002657400265740000000212411311317447015406 0ustar davisdavisOn Unix systems, JED locks files in a way that is consistent with Emacs, which is also consistent with Interleaf. It made no sense to implement a different incompatible locking system because that would render it useless when interacting with other programs. Whenever a buffer that is attached to a file gets modified, JED will attempt to lock the file. When the buffer is no longer modified (via getting saved to disk or changes discarded via undo), JED will unlock the file. The lock is made by creating a symbolic link in the file's directory with a name that is derived by prefixing the buffer file's name with `.#'. The value of the link is given by USER@HOST.PID. If there is already a lock but owned by another process, then JED will prompt the user for one of the following actions: steal the lock ignore the lock and proceed anyway abort the operation If the user elects to steal the lock, then the symbolic link will be recreated with the value appropriate for the current process. It is probably best to abort the operation and contact the person who has the file locked. jed-0.99-19/doc/txt/emacs.txt0000644002657400265740000002104611311317447014712 0ustar davisdavisThis file was provided by rgo@drmail.dr.att.com. Default Key Bindings for JED EMACS ================================== KEY ACTION JED FUNCTION (Invoke via ESC X) ENTER New line and indent newline_and_indent DEL Backward delete character backward_delete_char_untabify Backspace Help help_prefix TAB "Smart" line indent indent_line PageDown Move forward by pages page_down PageUp Move backward by pages page_up Up Arrow Move backward by lines previous_line_cmd Down Arrow Move forward by lines next_line_cmd CONTROL ^A Go to start of line beg_of_line ^B Move backward by characters previous_char_command ^D Forward delete character delete_char_cmd ^E Go to end of line eol_cmd ^F Move forward by characters next_char_cmd ^G Abort out of things kdb_quit ^H Help help_prefix ^HA Show related functions ^HF Help on function ^HH Show basic key bindings ^HK Show key binding ^HI Bring up Info Browser ^HM Display Unix man page ^HV Show variable definition and value ^HW Show what key is bound to a command ^H? Show Menus ^I "Smart" line indent indent_line ^J New line (CR-LF) newline ^K Kill to end of line yp_kill_line ^L Put current line in center emacs_recenter ^M New line and indent newline_and_indent ^N Move forward by lines next_line_cmd ^O Open up a blank line emacs_open_line ^P Move backward by lines previous_line_cmd ^Q Insert literal quoted_insert ^R Search backwards search_backward ^S Search forward search_forward ^T Transpose characters transpose_chars ^U Repeat command four times universal_argument ^V Move forward by pages page_down ^W Kill region yp_kill_region ^X Command prefix ^Y Yank back from kill buffer yp_yank ^Z Suspend JED sys_spawn_cmd ^_ Undo undo ^@ Start to define region (set mark) smart_set_mark_cmd ESCAPE ESC B Backup by words bskip_word ESC C Initial capitalize word capitalize_word ESC D Delete forward word yp_kill_word ESC F Advance by words skip_word ESC L Lower case word downcase_word ESC N Narrow paragraph narrow_paragraph ESC n Scroll up in place scroll_up_in_place ESC O Command prefix ESC P Scroll down in place scroll_down_in_place ESC Q Format paragraph format_paragraph ESC S Center line center_line ESC U Upper case word upcase_word ESC V Move backward by pages page_up ESC W Copy region to kill buffer yp_copy_region_as_kill ESC X Execute JED command emacs_escape_x ESC Y Yank and pop yp_yank_pop ESC ^B Go back to matching (, {, or [ backward_sexp ESC ^F Go ahead to matching ), }, or ] forward_sexp ESC ^H Go to start of function c_mark_function ESC ^K Kill to matching ), }, or ] kill_sexp ESC % Query search and replace replace_cmd ESC < Move to start of buffer beg_of_buffer ESC > Move to end of buffer end_of_buffer ESC ! Execute shell command do_shell_cmd ESC . Find tag find_tag ESC ; Create language comment c_make_comment ESC $ Invoke ispell ispell ESC / Abbreviation (?) dabbrev ESC DEL Backward delete word yp_bkill_word ESC \ Delete all whitespace trim_whitespace ESC space Trim whitespace to one space .bskip_white trim insert_single_space ESC right arrow Advance by words skip_word ESC left arrow Backup by words bskip_word CONTROL-X ^X B Switch to buffer switch_to_buffer ^X D Invoke directory editor dired ^X E Execute macro execute_macro ^X F Set fill column set_fill_column ^X G Insert from register reg_insert_register ^X H Mark buffer emacs_mark_buffer ^X I Insert file insert_file ^X J Go to last spot and unmark it pop_spot ^X K Kill buffer kill_buffer ^X M Send mail mail ^X N Delete everything but region narrow_to_region ^X O Goto other window other_window ^X Q Macro query macro_query ^X RK Kill rectangular region kill_rect ^X RO Open rectangular region open_rect ^X RR Copy rectangular region copy_rect ^X RY Insert rectangular region insert_rect ^X S Save buffers save_buffers ^X U Undo undo ^X W Undo effects of Narrow to region widen_region ^X X Copy region to register reg_copy_to_register ^X ( Begin macro begin_macro ^X ) End macro end_macro ^X / Mark a spot mark_spot ^X 0 Delete current window delete_window ^X 1 One window one_window ^X 2 Split current window split_window ^X 4B Switch to buffer in other window find_buffer_other_window ^X 4F Find file in other window find_file_other_window ^X < Scroll left scroll_left ^X > Scroll right scroll_right ^X ^ Enlarge display window enlarge_window ^X ? Show the cursor position whatpos ^X = Show the cursor position whatpos ^X ' Compile parse errors compile_parse_errors ^X ^B Display buffer list list_buffers ^X ^C Exit JED exit_jed ^X ^F Find file find_file ^X ^O Collapse blank lines to one delete_blank_lines ^X ^Q Toggle read-only mode toggle_readonly ^X ^S Save current buffer save_buffer ^X ^T Transpose lines transpose_lines ^X ^V Find alternate file find_alternate_file ^X ^W Write buffer to file write_buffer ^X ^X Go to other end of region exchange ^X ESC Invoke S-LANG Interpreter evaluate_cmd JED FUNCTIONS NOT BOUND TO KEYS - ACCESS VIA ESC X (OR BIND TO KEYS IN YOUR .jedrc FILE) ========================================================= FUNCTION MEANING abbrev_mode append_region Append region to file beep blank_rect Blank-fill rectangular region c_mode Set C program mode calendar Display a 3-month calendar in a new window compile define_abbreviation describe_bindings describe_mode digit_arg edit_tab_stops Define tab stops in arbitrary columns evalbuffer exit_mini find_binary_file Edit binary file fortran_mode Set Fortran program mode goto_column_cmd Go to column number goto_line_cmd Go to line number goto_match Go to matching delimiter: (, ), [, ], {, or } insert_buffer Insert buffer isearch_backward Incremental search backward isearch_forward Incremental search forward latex_mode Set LaTex mode mini_complete narrow no_mode Set no mode occur Find all occurrences of a regular expression query_replace_match Regular expression query search and replace re_search_backward Regular expression search backward re_search_forward Regular expression search forward recover_file Recover file from backup redraw replace_across_buffer_files save_abbrevs self_insert_cmd set_mark_cmd sh_mode Set shell mode shell Open a window running a Unix shell sort Sort a region text_mode Set text mode text_smart_quote toggle_crmode toggle_undo Enable/disable undo capability on a buffer trim_buffer Trim trailing whitespace in a buffer untab Convert tabs to blanks in a region widen write_region Write region to file jed-0.99-19/doc/txt/rmail.txt0000644002657400265740000000743011311317447014727 0ustar davisdavisInformation about the JED rmail reader. (Unix only!) Note: JED's rmail mode is intended for experienced JED users. It should not be used by novice users. JED is able to read mail with proper file locking via the standalone executable `getmail'. It attempts to lock the spool file through the `flock' system call, or via a lock file if `flock' is not available. The latter approach requires that the spool directory be writable. To install rmail, you must first create the executable `getmail'. After building JED, simply type `make getmail'. Move the resulting executable to JED_ROOT/bin. Add the following to your .jedrc file: autoload ("rmail", "rmail"); add_completion("rmail"); Mail is moved (with locking) from the user's mail box file to a directory $HOME/Mail. This directory is created if it does not exist. JED will then parse the new mail and moved individual messages to the directory $HOME/Mail/NewMail. Future versions will compress the new mail. The variable Rmail_Spool_Mailbox_File determines the name of the input mailbox file. If this variable is not defined, JED will attempt to determine the location of the mail box file by looking in /var/spool/mail. After moving the messages from the user's mail box to the Mail directory, JED will parse the headers of the new mail and create a file called $HOME/Mail/NewMail.index. JED uses this index to manage files in the NewMail folder. Similar statements apply to new folders. JED will then show a window containing the index. It may look like: 4 12-Dec R Darrel R Hankerson & 1 == 1 if menu item is enabled & 2 == 1 if menu item is checked Integer w32_get_menu_state(Integer hmenu, Integer pos) Gets state of menu item at zero-based position 'pos' & 1 == 1 if menu item is enabled & 2 == 1 if menu item is checked Void w32_get_popup_menu(Integer hmenu, Integer pos) Returns handle of popup menu at zero-based position 'pos' If return value is 0, there is no popup at the position. Void w32_check_menu_item(Integer hmenu, Integer id, Integer flag) This functions changes check state of menu item. If flag is nonzero, it checks menu item, otherwise it unchecks it Void w32_check_menu_item(Integer hmenu, Integer pos, Integer flag) This functions changes check state of menu item. If flag is nonzero, it checks menu item, otherwise it unchecks it Void w32_check_menu_item(Integer hmenu, Integer id, Integer flag) This functions enable or disable menu item. If flag is nonzero, the menu item will be enabled, otherwise it'll be disabled. Void w32_check_menu_item(Integer hmenu, Integer pos, Integer flag) This functions enable or disable menu item. If flag is nonzero, the menu item will be enabled, otherwise it'll be disabled. Void w32_redraw_menubar(Void) Redraws menubar. This functions should be called if menubar is changed Void w32_set_init_popup_callback(String callback) Executes callback before popup menu is popped up. Void msw_help(String filename, String keword, Integer Partial_Keys) Starts Windows Help with 'filename' help file. If 'keyword' is not null string shows topic with specified keyword. If 'Partial_Keys' != 0 shows Search dialog if there is more than one help topic beginnig with 'keyword' jed-0.99-19/doc/txt/edt.txt0000644002657400265740000000473011311317447014377 0ustar davisdavisTo enable EDT emulation, put the line require ("edt"); in your jed.rc (.jedrc) file. By default, the value of the Gold-Key is system-dependent. On Unix and VMS systems, it corresponds to the actual Gold key on a vtXXX terminal. Such a key sends "\eOP". Unfortunately most users are not using a terminal that has such a key. For such users a different key can be used as the Gold-Key, as described below. Versions of jed for DOS/Windows can use the NumLock key as the Gold-Key. This is controlled by the NUMLOCK_IS_GOLD variable. If that variable has a non-zero value when this file is loaded, then the NumLock key will generate "\eOP". Otherwise, it is assumed that the Gold-Key corresponds to the F1 key. To specify a different value, e.g., the value of the F7 key, use require ("keydefs"); variable Key_Gold = Key_F7; require ("edt"); in your jedrc file. Differences between EDT and Jed's EDT emulation ----------------------------------------------- Hopefully, you will not notice any difference if you use the keypad keys. I have done my best to ensure that the functionality of the application-keypad is preserved. By default, JED binds Ctrl-H to help. EDT on VMS uses Ctrl-H to move to the beginning of the line. If you want this behavior instead of JED's, then put the lines unsetkey ("^H"); setkey ("bol", "^H"); in your jed.rc (.jedrc) file AFTER the require("edt.sl") statement. There appears to be no standard set of GOLD-X (X represents a character in the set [A-Z]) key definitions. For this reason, I have defined only a few combinations. However, this should not stop you from defining your own. I have defined 2 GOLD key combinitions: GOLD-E and GOLD-Q. Both of these are bound to the "exit" command. If you would like to bind additional GOLD-X key combinations, then it is very easy. For example, suppose you want GOLD-I to insert a file into the buffer, GOLD-W to write the buffer to a file, and GOLD-S to switch to a previous buffer. Then add the following to your .jedrc (jed.rc) file: setkey ("insert_file", Key_Gold + "I"); setkey ("write_buffer", Key_Gold + "W"); setkey ("switch_to_buffer", Key_Gold + "S"); In addition to the standard keypad, newer DEC terminals (vt220 etc) have a smaller keypad (Find, Insert here, Prev SCreen, etc....). Key sequences corresponfing to these keys have also been bound. Finally, JED does not support any EDT line editing commands, nor are there any plans to do so. jed-0.99-19/doc/txt/abbrev.txt0000644002657400265740000001660111311317447015064 0ustar davisdavisThis document explains how to use abbreviations with JED. Overview ======== Abbreviations are possible only when `abbrev' mode is enabled. It can be toggled on and off on a buffer by buffer basis using the `abbrev_mode' command. If it is on, the word `abbrev' will appear on the status line. Each buffer can have its own abbreviation table or use the ``Global'' abbreviation table. If a table has not been defined for a given buffer, the ``Global'' table will be used. Typically, abbreviation tables are mode dependent and are usually assigned to the buffer when a mode is selected. An abbreviation table consists of abbreviations as well as a definition of characters that are allowed to appear in an abbreviation. By default, the characters that comprise a word are used. However, this is not always what is desired. For example, one might like to use abbreviations like `\be' for `\begin{equation}' in TeX mode. For this to happen, the `\' character should be included in the definition of a word. The examples below should shed more light on this concept. Using Abbreviations =================== Once abbreviations have been loaded into the editor (the mechanism is explained below), they can be used only if abbrev mode is turned on. This mode can be turned on or off by pressing `ESC X' and entering `abbrev_mode' at the prompt. It can also be turned on in a mode hook. After entering an abbreviation into the buffer, the abbreviation will be expanded if the next character inserted into the buffer immediately after the position of the abbreviation is NOT a member of the set of characters that is allowed in an abbreviation. Then the editor scans backward across the text until it finds a character that is NOT part of the set of special characters. Finally it attempts to expand the resulting abbreviation. For example, consider an abbreviation for TeX mode and assume that, when the abbreviation table was created, the characters `\', `a-z', `A-Z', and `0-9' were specified as the special set of characters that may be used in an abbreviation. This means that `\be' is a valid abbreviation but `@be' is not since `@' is not part of the above set. Suppose that `\be' is the abbreviation for `\begin{equation}' and `\be' is entered on a line as This is an equation.\be At this point nothing happens. However, if a SPACE is inserted, the editor will realize that the space is not part of the special abbreviation character set and scan back until another character NOT in the set is found. In this case, it will find a `.'. From this information, it looks up `\be' in the table, finds `\begin{equation}' and expands the line to look like: This is an equation.\begin{equation} However, if the line had looked like: This is an equation\be the expansion would have failed because the editor would have scanned back to the space character between `an' and `equation' and tried to expand `equation\be'. Although this sounds complex, it is trivial in practice. The Abbreviation File ====================== An abbreviation file is simply a file that contains the approrite S-Lang function calls to create abbreviation tables and assign abbreviations to the tables. It is loaded like any other S-Lang file, via `evalfile'. Simply turning abbreviations on via `abbrev_mode' is sufficient to cause JED to load the file. The variable `Abbrev_File' may be used to specify the name of the abbreviation file. If this variable is undefined, the file name defaults to `abbrevs.sl' on non-Unix systems and `.abbrevs.sl' on Unix. It is assumed to reside in the HOME directory. To specify a different name, e.g., `/usr/lib/jed/abbrev.sl', put variable Abbrev_File = "/usr/lib/jed/abbrev.sl"; in the JED startup file. Here is a simple file that is sufficient to create a global abbreviation table and a local table for TeX mode: % abbrevs.sl create_abbrev_table ("Global", ""); define_abbrev ("Global", "adn", "and"); define_abbrev ("Global", "amy", "amy.tch.harvard.edu"); create_abbrev_table ("TeX", "\\A-Za-z0-9"); define_abbrev ("TeX", "\\be", "\\begin{equation}"); define_abbrev ("TeX", "\\ee", "\\end{equation}"); Note that `create_abbrev_table' takes 2 parameters. The first parameter is simply the name of the table to be created and the second parameter represents the list of characters that are allowed to be in an abbreviation. If the second parameter is the empty string, JED's word definition willbe used. Also note that the backslash character must be typed twice for S-Lang to interpret it properly as a backslash character. The `define_abbrev' function takes 3 parameters: the name of the table, the abbreviation, and the expansion for the abbreviation. If the last character of the expansion is the backspace character (\010), then the character that triggered the expansion (e.g., a space) will not get inserted. For example, define_abbrev ("TeX", "\\s", "\\section{\010"); is preferable to define_abbrev ("TeX", "\\s", "\\section{"); There is really nothing special about an abbreviation file. The code that appears in it can also appear in the JED startup file. Usually the abbreviation mode is enabled in a hook. For example, to enable abbreviations for TeX mode, use a mode hook of the form: define tex_mode_hook () { set_abbrev_mode (1); } This way, when TeX mode is enabled, the abbreviation file will be automatically loaded if not already loaded and abbrev mode will be turned on. Creating Abbreviations ====================== There are two ways to create abbreviations: 1. Simply create an abbreviation file by hand. 2. Use the `define_abbreviation' function call. Here the latter method is explained. The `define_abbreviation' function uses the abbreviation table associated with the current buffer. If there is none explicitly associated with the buffer, the Global table will be used. If the table does not exist, it will be created. This function will prompt for an abbreviation. It may or may not prompt for an expansion. If a region is defined when `define_abbreviation' is called, the region will be taken as the expansion. This is useful if the expansion consists of of more than one word. If a region is not defined, the expansion will consist of the previous word as defined by the table. Only if that fails will the user be prompted for an expansion, e.g., this could happen if the Point is at the beginning of a line. Note that simply using `define_abbreviation' by itself does not save the abbreviation for future use. To save the abbreviations to the abbreviation file, use the function `save_abbrevs'. That is, press `ESC X' and enter `save_abbrevs' at the prompt. The editor will then prompt for a file name. Simply hitting RETURN at the prompt means that the `Abbrev_File' definition will be used. Enter a different filename to save them elsewhere. Note that entering a new file name will not change the value of `Abbrev_File'. Also, this function saves ALL currently defined abbreviation tables. jed-0.99-19/doc/README0000644002657400265740000000274511311317447013127 0ustar davisdavisThe main reason JED's version number is below 1.0 is due to the lack of adequate documentation. It is slowing being improved. There are several sub-directories here including: txt/ Many text files that describe various aspects of the editor are in this directory. They will eventually be stitched together and included in the manual. tm/ This directory contains the text-macro source for the intrinsic functions. In addition, it contains Guido Gonzato's quick reference guide for jed. manual/ Eventually the jed manual will be put here. Right now what is in there is old and is most likely out of date. ACKNOWLEDGEMENTS ---------------- I am extremely grateful to the following individuals for their contributions to jed. For many of them, this is long overdue. Luchesar Ionkov Mark Olesen John Burnell Darrel Hankerson Dominik Wujastyk Ulli Horlacher Hunter Goatley Simon Tatham Nick Tatham Andy Harper John Skilleter Jim Knoble Guido Gonzato Charl Botha Eddie Penninkhof Jouk Jansen Martin P.J. Zinser Tom Culliton Kazuhisa Yoshino Jim Clifton Jan Hlavacek Francesc Rocher Thomas J. Moore There are other names that belong on this list, particularly from those who supported jed when the version was still 0.8. Unfortunately I no longer have any records of their contributions. jed-0.99-19/doc/manual/0000755002657400265740000000000011311317447013514 5ustar davisdavisjed-0.99-19/doc/manual/jed.10000644002657400265740000002221711311317447014344 0ustar davisdavis.\" ================================================================== .\" Jed programmers editor, this manpage was writen by .\" "Boris D. Beletsky" copyright(c) 1996 .\" This manpage may be freely distrebuted as part of GNU Debian Linux .\" ================================================================== .TH JED 1 "OCT 1996" Debian "User Manuals" .SH NAME Jed \- programmers editor .SH SYNOPSIS .B jed \-\-version .br .B jed\-script \-\-version .br .B xjed \-\-version .sp .B jed [\-\-secure] [\-\-batch|\-\-script|\-\-help] [options] .I file .B ... .br .B jed\-script [\-\-secure] .I script file .B [script options] ... .br .B xjed [\-\-secure] [X options] [\-\-batch|\-\-script|\-\-help] [options] .I file .B ... .SH DESCRIPTION .B Jed - programmers editor .LP Features: .LP Color syntax .I highlighting. Emulation of .B Emacs, .B EDT, .B Wordstar, and Brief editors. Extensible in a language resembling C. Completely customizable. Editing TeX files with AUC-TeX style editing (BiBTeX support too). Folding support, and much more... .LP For complete documentation, see GNU info files, this manual only provides brief tutorial. .SH OPTIONS .SS major options .LP .I \-\-version .RS prints the version and compiletime variables. .RE .I \-\-help .RS prints usage information. .RE .I \-\-secure .RS runs Jed in secure mode, e.g. you can't run any external commands with .I system() or .I run_shell_cmd(). .RE .I \-\-batch .RS run Jed in batch mode. This is a non-interactive mode. .RE .I \-\-script .RS this is a mode like .I \-\-batch but jed does not eval the startup files. It behaves like .I slsh. You must give the file that should be evaluated as second argument. It's the same as calling .B jed\-script. .SS minor options .LP .I \-n .RS do not load .I .jedrc file. .RE .I \-a 'file' .RS load .I file as user configuration file instead of .jedrc. .RE .I + 'n' .RS goto line .I n in buffer (notice that in order to this option to take effect, if must appear before the file name in the command line, like 'jed +3 file') .RE .I \-g 'n' .RS goto line .I n in buffer (notice that in order to this option to take effect, if must appear after the file name in the command line, like 'jed file \-g 3') .RE .I \-l 'file' .RS load .I file as S\-Lang code. .RE .I \-f 'function' .RS execute S\-Lang function named .I function .RE .I \-s 'string' .RS search forward for .I string .RE .I \-2 .RS split window .RE .I \-i 'file' .RS insert .I file into current buffer. .RE .LP .SS X options .B xjed accapts the common options like .I \-display, \-name, \-fn and \-geometry. Additionaly it accepts .LP .I \-facesize SIZE, \-fs SIZE .RS if build with XRENDERFONT support, selects the font size .I SIZE. Use it with the option .I \-fn to select a scalable font. .RE .I \-foreground COLOR, \-fg COLOR .RS sets the foreground color. .RE .I \-background COLOR, \-bg COLOR .RS sets the background color. .RE .I \-fgMouse COLOR, \-mfg COLOR .RS sets the foreground color of the mouse pointer. .RE .I \-bgMouse COLOR, \-mbg COLOR .RS sets the background color of the mouse pointer. .RE .I \-Iconic, \-ic .RS start iconified. .RE .I \-title NAME .RS sets the window title to .I NAME. .RE .LP For more options look at .B xterm.c. .SH CONFIGURATION .RS .I Emulating Other Editors .RE .LP JED's ability to create new functions using the .I S\-Lang programming language as well as allowing the user to choose key bindings, makes the emulation of other editors possible. Currently, JED provides reasonable emulation of the .I Emacs, EDT, and Wordstar editors. .LP .RS .I Emacs Emulation .RE .LP .I Emacs Emulation is provided by the S\-Lang code in .I emacs.sl. The basic functionality of Emacs is emulated; most Emacs users should have no problem with JED. To enable Emacs emulation in JED, make sure that the line: .LP .RS .I () = evalfile ("emacs"); .RE .LP is in your .I jed.rc (.jedrc) startup file. JED is distributed with this line already present in the default jed.rc file. .LP .RS .I EDT Emulation .RE .LP For .I EDT emulation, .I edt.sl must be loaded. This is accomplished by ensuring that the line: .LP .RS .I () = evalfile ("edt"); .RE .LP is in present in the jed.rc (.jedrc) Startup File. .LP .RS .I Wordstar Emulation .RE .LP wordstar.sl contains the S\-Lang code for JED's Wordstar emulation. Adding the line .LP .RS .I () = evalfile ("wordstar"); .RE .LP to your jed.rc (.jedrc) startup file will enable JED's Wordstar emulation. .SH RUN TIME .LP .RS .I Status line and Windows .RE .LP .I JED supports multiple windows. Each window may contain the same buffer or different buffers. A status line is displayed immediately below each window. The status line contains information such as the JED version number, the buffer name, .I mode, etc. Please beware of the following indicators: .LP .I ** .RS buffer has been modified since last save. .RE .I %% .RS buffer is read only. .RE .I m .RS Mark set indicator. This means a region is being defined. .RE .I d .RS File changed on disk indicator. This indicates that the file associated with the buffer is newer than the buffer itself. .RE .I s .RS spot pushed indicator. .RE .I + .RS Undo is enabled for the buffer. .RE .I [Narrow] .RS Buffer is narrowed to a region of LINES. .RE .I [Macro] .RS A macro is being defined. .RE .LP .RS .I Mini-Buffer. .RE .LP The .I Mini-Buffer consists of a single line located at the bottom of the screen. Much of the dialog between the user and JED takes place in this buffer. For example, when you search for a string, JED will prompt you for the string in the Mini-Buffer. .LP The .I Mini-Buffer also provides a direct link to the S\-Lang interpreter. To access the interpreter, press .I Ctrl-X Esc and the .I S\-Lang> prompt will appear in the Mini-Buffer. Enter any valid S\-Lang expression for evaluation by the interpreter. .LP It is possible to recall data previously entered into the .I Mini-Buffer by using the up and down arrow keys. This makes it possible to use and edit previous expressions in a convenient and efficient manner. .LP .RS .I Basic Editing .RE .LP .I Editing with JED is pretty easy - most keys simply insert themselves. Movement around the buffer is usually done using the .I arrow keys or page up and page down keys. If .I edt.sl is loaded, the keypads on VTxxx terminals function as well. Here, only the highlights are touched upon (cut/paste operations are not considered `highlights'). In the following, any character prefixed by the .I ^ character denotes a Control character. On keyboards without an explicit Escape key, .I "Ctrl-[" will most likely generate and Escape character. .LP A .I prefix argument to a command may be generated by first hitting the .I Esc key, then entering the number followed by pressing the desired key. Normally, the prefix argument is used simply for repetition. For example, to move to the right 40 characters, one would press .I "Esc 4 0" followed immediately by the right arrow key. This illustrates the use of the repeat argument for repetition. However, the prefix argument may be used in other ways as well. For example, to begin defining a region, one would press the .I "Ctrl-@" key. This sets the mark and begins highlighting. Pressing the .I "Ctrl-@" key with a prefix argument will abort the act of defining the region and to pop the mark. The following list of useful keybindings assumes that .I emacs.sl has been loaded. .LP .I Ctrl-L .RS Redraw screen. .RE .I Ctrl-_ .RS Undo (Control-underscore, also Ctrl-X u'). .RE .I Esc q .RS Reformat paragraph (wrap mode). Used with a prefix argument. will justify the paragraph as well. .RE .I Esc n .RS narrow paragraph (wrap mode). Used with a prefix argument will justify the paragraph as well. .RE .I Esc ; .RS Make Language comment (Fortran and C) .RE .I Esc \\\\ .RS Trim whitespace around point .RE .I Esc ! .RS Execute shell command .RE .I Esc $ .RS Ispell word .RE .I Ctrl-X ? .RS Show line/column information. .RE .I ` .RS quoted_insert --- insert next char as is (backquote key) .RE .I Esc s .RS Center line. .RE .I Esc u .RS Upcase word. .RE .I Esc d .RS Downcase word. .RE .I Esc c .RS Capitalize word. .RE .I Esc x .RS Get M-x minibuffer prompt with command completion .RE .I Ctrl-X Ctrl-B .RS pop up a list of buffers .RE .I Ctrl-X Ctrl-C .RS exit JED .RE .I Ctrl-X 0 .RS Delete Current Window .RE .I Ctrl-X 1 .RS One Window. .RE .I Ctrl-X 2 .RS Split Window. .RE .RS .I Ctrl-X o .RE .RS Other window. .RE .I Ctrl-X b .RS switch to buffer .RE .I Ctrl-X k .RS kill buffer .RE .I Ctrl-X s .RS save some buffers .RE .I Ctrl-X Esc .RS Get "S\-Lang>" prompt for interface to the S\-Lang interpreter. .RE .I Esc . .RS Find tag .RE .I Ctrl-@ .RS Set Mark (Begin defining a region). Used with a prefix argument aborts the act of defining the region and pops the Mark. .RE .RE .\"--------------------------------------------------------- .SH FILES .I JED_ROOT/lib/*.sl .RS these are the default runtime jed slang files .RE .I JED_ROOT/lib/site.sl .RS This is the default startup file. .RE .I /etc/jed.rc .RS The system wide configuration file. .RE .I ~/.jedrc .RS Per user configuration file. .SH AUTHOR .I "John E. Davis" .RS Jed's Author .RE --- This document was .I translated to nroff by "Boris D. Beletsky" jed-0.99-19/doc/manual/jed.tex0000644002657400265740000021567211311317447015015 0ustar davisdavis% Copyright (c) 2007 John E. Davis % This file is part of JED editor. % % You may distribute this file under the terms the GNU General Public % License. See the file COPYING for more information. % \documentstyle{article} \setlength{\oddsidemargin}{0mm} \setlength{\evensidemargin}{0mm} \setlength{\textwidth}{160mm} \setlength{\topmargin}{-10mm} \setlength{\textheight}{210mm} \setlength{\parindent}{0mm} \setlength{\parskip}{5mm} \def\mytitle{The JED Editor} \newlength{\pagewidth} \setlength{\pagewidth}{\textwidth} %\addtolength\pagewidth\marginparwidth % \addtolength\pagewidth\marginparsep \makeatletter \def\ps@headings{\def\@oddfoot{}% \def\@oddhead{\makebox[\textwidth][l]{\underline{\hbox to \pagewidth{\bf \mytitle\hfill\thepage}}}}% \def\@evenfoot{}% \def\@evenhead{\makebox[\textwidth][l]{\underline{\hbox to \pagewidth{\bf \mytitle\hfill\thepage}}}}}% \pagestyle{headings} \newcommand{\slang}{{\bf S-Lang}} \newcommand{\jed}{{\bf jed}} \newcommand{\exmp}[1]{{\tt #1}} \newcommand{\var}[1]{{\tt #1}} \newcommand{\key}[1]{{\sc #1}} \begin{document} \tableofcontents \pagebreak \section{Introduction} This document presents some basic information that users should know in order to use \jed{} effectively. Any questions, comments, or bug reports, should be email-ed to the author. Please be sure to include the version number. To be notified of future releases of \jed{}, email to the address below and your email address will be placed on the announcement list. The email address is: \begin{verbatim} davis@space.mit.edu (Internet) davis@ohstpy (BITNET) \end{verbatim} \section{Installing JED} Building \jed{} from its sources requires the use of a C compiler that understands function prototypes. \jed{} has been successfully built with \verb|cc| on the ULTRIX, VMS, and IRIX operating systems. In addition, it has been created using \verb|gcc| under SunOS and Borland's BCC 3.0 for the PC. Detailed installation instructions are in separate, operating system dependent files. They are: \begin{verbatim} UNIX: install.unx VMS: install.vms IBM-PC: install.pc \end{verbatim} When \jed{} starts up, it will first try to load a site initialization file called \verb|site.sl|. Site specific commands are placed here. Most likely, \verb|site.sl| will define some functions, default hooks, etc\ldots What goes in it is left to the discretion of the user or system manager. See the file \verb|site.sl| for examples. When loading \verb|site.sl| as well as other \verb|S-Lang| files (the user's personal initialization file, \verb|.jedrc| or \verb|jed.rc|, is a special case, see below), \jed{} searches all directories specified by the environment variable \verb|JED_LIBRARY|, and if the file is not found, \jed{} will look for it in the default directory. The environment variable \verb|JED_LIBRARY| is a comma separated list of directories. Here are some examples of setting this variable for different systems: \begin{verbatim} VMS: define/job JED_LIBRARY dev$lib:[jedfiles] UNIX: setenv JED_LIBRARY '/usr/local/lib/jed,~/jed' IBMPC: set JED_LIBRARY = c:\editors\jed\lib \end{verbatim} %$ You will probably want to put define \verb|JED_LIBRARY| in your login startup file, e.g., \verb|autoexec.bat|, \verb|login.com|, or \verb|.cshrc|. \jed{} versions 0.92 and later allow the value of \verb|JED_LIBRARY| to be specified at compile time an it may only be necessary to define \verb|JED_LIBRARY| as an environment variable to override its pre--compiled value. \section{Startup Files} Once \jed{} has loaded the startup file \verb|site.sl|, it will try to load the user's personal initialization file. It first looks in the directory pointed to by the environment variable \verb|JED_HOME|. If that fails, it then searches the \verb|HOME| directory and upon failure simply loads the one supplied in \verb|JED_LIBRARY|. The name of the user initialization file varies according to the operating system. On Unix systems this file must be called \verb|.jedrc| while on VMS and MSDOS, it goes by the name \verb|jed.rc|. For VMS systems, the \verb|HOME| directory corresponds to the \verb|SYS$LOGIN| %$ logical name while for the other two systems, it corresponds to the \verb|HOME| environment variable. The purpose of this file is to allow an individual user to tailor \jed{} to his or her personal taste. Most likely, this will involve choosing an initial set of key-bindings, setting some variables, and so on. \section{Starting JED} Normally, \jed{} is started as \begin{verbatim} jed \end{verbatim} or \begin{verbatim} jed \end{verbatim} However, \jed{} also takes the switches defined in the following table: \begin{verbatim} Switch Meaning ------ ------- -batch run JED in batch mode. This is a non-interactive mode. -n do not load jed.rc (.jedrc) file. -g goto line `n' in buffer -l load `file' as S-Lang code. -f execute S-Lang function named `function' -s search forward for `string' -2 split window -i insert into current buffer. \end{verbatim} For example, the command line: \begin{verbatim} jed slang.c -g 1012 -s error -2 file.c -f eob \end{verbatim} will start up \jed{}, read in the file \var{slang.c}, goto line 1012 of \var{slang.c} and start searching for the string \var{error}, split the window, read in \var{file.c} and goto the end of the file. If the \var{-batch} parameter is used, it must be the first parameter. Similarly, if \var{-n} is used, it must also be the first parameter unless used with the \var{-batch} parameter in which case it must the second. \jed{} should only be run in batch mode when non--interactive operation is desired. For example, \jed{} is distributed with a file, \verb|mkdoc.sl|, that contains S--Lang code to produce a help file for functions and variables. In fact, the help file \verb|jed_funs.hlp| was created by entering \begin{verbatim} jed -batch -n -l mkdoc.sl \end{verbatim} at the command line. Now suppose that you want to read in a file with the name of one of the switches, say \verb|-2|. How can this be done? The answer depends upon the operating system. For Unix, instead of \var{jed -2}, use \var{jed ./-2}; for VMS, use \var{jed []-2}. The case for MS-DOS is similar to Unix except that one must use the backslash. It is possible to completely change \jed{}'s command line syntax through the use of the user defined function \verb|command_line_hook|. In fact, the behavior described above is dictated by the value of \verb|command_line_hook| as distributed in \verb|site.sl|. See the section on hooks for details. \section{Emulating Other Editors} \jed{}'s ability to create new functions using the S--Lang programming language as well as allowing the user to choose key bindings, makes the emulation of other editors possible. Currently, \jed{} provides reasonable emulation of the Emacs, EDT, and Wordstar editors. \subsection{Emacs Emulation} Emacs Emulation is provided by the \slang{} code in \verb|emacs.sl|. The basic functionality of Emacs is emulated; most Emacs users should have no problem with \jed{}. To enable Emacs emulation in \jed{}, make sure that the line \begin{verbatim} evalfile ("emacs"); pop (): \end{verbatim} is in your \verb|jed.rc| (\verb|.jedrc|) startup file. \jed{} is distributed with this line already present in the default \verb|jed.rc| file. \subsection{EDT Emulation} For EDT emulation, \verb|edt.sl| must be loaded. This is accomplished by ensuring that the line \begin{verbatim} evalfile ("edt"); pop (); \end{verbatim} is in present in the \verb|jed.rc| (\verb|.jedrc|) Startup File. \jed{} is distributed with EDT emulation enabled on VMS and Unix systems but the above line is commented out in the \verb|jed.rc| file on MS-DOS systems. This emulation provides a near identical emulation of the EDT keypad key commands. In addition, the smaller keypad on the newer DEC terminals is also setup. It is possible to have both EDT and Emacs emulation at the same time. The only restriction is that \verb|emacs.sl| must be loaded before \verb|edt.sl| is loaded. One minor difference between \jed{}'s EDT emulation and the real EDT concerns the \key{Ctrl-H} key. EDT normally binds this to move the cursor to the beginning of the line. However, \jed{} uses it as a help key. Nevertheless, it is possible to re-bind it. See the section on re-binding keys as well as the file \verb|edt.sl| for hints. Alternatively, simply put \begin{verbatim} unsetkey ("^H"); setkey ("bol", "^H"); \end{verbatim} in the \verb|jed.rc| startup file after \verb|edt.sl| is loaded. Keep in mind that the \key{Ctrl-H} key will no longer function as a help key if this is done. EDT emulation for PCs only work with the enhanced keyboard. When \verb|edt.sl| is loaded, a variable \verb|NUMLOCK_IS_GOLD| is set which instructs \jed{} to interpret the Num-Lock key on the square numeric keypad to function as the EDT GOLD key. In fact, this keypad should behave exactly like the keypad on VTxxx terminals. The only other problem that remains concerns the \key{+} key on the PC keypad. This key occupies two VTxxx key positions, the minus and the comma (delete word and character) keys. Thus a decision had to be made about which key to emulate. I chose the \key{+} key to return the characters \key{Esc O l} which \jed{} maps to the delete character function. This may be changed to the delete word function if you prefer. See the file \verb|edt.sl| for details. The \key{GOLD}--\key{GOLD} key combination toggles the keypad between application and numeric states. On the PC, this is not possible. Instead, the PC \key{F1} key has been instructed to perform this task. \subsection{Wordstar Emulation} \verb|wordstar.sl| contains the \slang{} code for \jed{}'s Wordstar emulation. Adding the line \begin{verbatim} evalfile ("wordstar"); pop (); \end{verbatim} to your \verb|jed.rc| (\verb|.jedrc|) startup file will enable \jed{}'s Wordstar emulation. \section{File Types and Sizes} \jed{} is primarily a text editor; however, it can also edit binary files (see the section on editing binary files). As a result, \jed{} may edit lines of arbitrary length (actually this depends upon the size of an integer). It is capable of editing arbitrarily large buffers as long as there is enough memory for the buffer as well as the overhead involved. This editor employs a linked list representation; hence, the overhead can be quite high. \section{Backup and Auto-save Files} On UNIX and MS-DOS systems, \jed{} creates backup files by appending a \verb|~| character to the filename. The VMS operating system handles backup files itself. \jed{} periodically auto-saves its buffers. On UNIX and MS-DOS, auto-save files are prefixed with the pound sign \var{\#}. On VMS, they are prefixed with \verb|_$|. %$ The auto-save interval may be changed by setting the variable \verb|MAX_HITS| to the desired value. The default is 300 ``hits'' on the buffer. A ``hit'' is defined as a key which MAY change the state of the buffer. Cursor movement keys do not cause hits on the buffer. Like many of \jed{}'s features, the names of auto-save and backup files can be controlled by the user. The file \verb|site.sl| defines two functions, \verb|make_backup_filename|, and \verb|make_autosave_filename| that generate the file names described in the previous paragraph. Like all S--Lang functions, these functions may be overloaded and replaced with different ones. See also information about \verb|find_file_hook| in the section on hooks. On UNIX systems, \jed{} catches most signals and tries to auto-save its buffers in the event of a crash or if the user accidently disconnects from the system (\var{SIGHUP}). If an auto-save file exists and you is desire to recover data from the auto-save file, use the function \verb|recover_file|. Whenever \jed{} finds a file, it checks to see if an auto-save file exists as well as the file's date. If the dates are such that the auto-save file is more recent \jed{} will display a message in the mini-buffer alerting the user of this fact and that the function \verb|recover_file| should be considered. \section{Status line and Windows} \jed{} supports multiple windows. Each window may contain the same buffer or different buffers. A status line is displayed immediately below each window. The status line contains information such as the \jed{} version number, the buffer name, ``mode'', etc. Please beware of the following indicators: \var{**}\\ buffer has been modified since last save. \var{\%\%}\\ buffer is read only. \var{m}\\ Mark set indicator. This means a region is being defined. \var{d}\\ File changed on disk indicator. This indicates that the file associated with the buffer is newer than the buffer itself. \var{s}\\ spot pushed indicator. \var{+}\\ Undo is enabled for the buffer. \var{[Macro]}\\ A macro is being defined. \var{[Narrow]} Buffer is narrowed to a region of LINES. \section{Mini-Buffer} The Mini-Buffer consists of a single line located at the bottom of the screen. Much of the dialog between the user and \jed{} takes place in this buffer. For example, when you search for a string, \jed{} will prompt you for the string in the Mini-Buffer. The Mini-Buffer also provides a direct link to the \slang{} interpreter. To access the interpreter, press \key{Ctrl-X} \key{Esc} and the \var{S-Lang>} prompt will appear in the Mini-Buffer. Enter any valid \slang{} expression for evaluation by the interpreter. It is possible to recall data previously entered into the Mini-Buffer by using the up and down arrow keys. This makes it possible to use and edit previous expressions in a convenient and efficient manner. \subsection{Command Line Completion} The \jed{} editor has several hundred built--in functions as well as many more written in the \slang{} extension language. Many of these functions are bound to keys and many are not. It is simply unreasonable to require the user to remember if a function is bound to a key or not and, if it is, to remember the key to which it is bound. This is especially true of those functions that are bound but rarely used. More often than not, one simply forgets the exact name or spelling of a function and requires a little help. For this reason, \jed{} supports command line completion in the mini-buffer. This function, called \verb|emacs_escape_x|, is bound to the key \key{Esc X}. This is one binding that must be remembered! As an example, suppose that you are editing several buffers and you wish to insert the contents of one buffer into the current buffer. The function that does this is called \verb|insert_buffer| and has no default key-binding. Pressing \key{Esc X} produces the prompt \var{M-x}. This prompt, borrowed from the Emacs editor, simply means that \key{Esc X} was pressed. Now type \var{in} and hit the space bar or the \key{Tab} key. In this context (completion context) the space bar and the \key{Tab} will expand the string in the Mini-Buffer up until it is no longer unique. In this case, \verb|insert_file| and \verb|insert_buffer| are only the two functions that start with \var{in}. Hence, \var{in} will expand to \verb|insert_| at which point it becomes necessary to enter more information to uniquely specify the desired function. However, in a completion context, the space bar also has a special property that enables the user to cycle among the possible completions. For this example, hitting the space bar twice consecutively will produce the string \verb|insert_file| and hitting it again produces the desired string \verb|insert_buffer|. The role of the space bar in completion is a point where Emacs and \jed{} differ. Emacs will pop up a buffer of possible completions but \jed{} expects the user to press the space bar to cycle among them. Both have there pros and cons. Frequently, one sees messages on the Usenet newsgroup \verb|gnu.emacs.help| from Emacs users asking for the kind of completion \jed{} employs. \subsection{File Names} \jed{} takes every file name and ``expands it'' according to a set of rules which vary according to the Operating System. For concreteness, consider \jed{} running under MS-DOS. Suppose the user reads a new file into the editor via the \verb|find_file| command which emacs binds to \key{Ctrl-X} \key{Ctrl-F}. Then the following might be displayed in the mini-buffer: \begin{verbatim} Find File: C:\JED\SLANG\ \end{verbatim} Here \jed{} is prompting for a file name in the directory \verb|\JED\SLANG| on disk \var{C:}. However, suppose the user wants to get the file \verb|C:\JED\SRC\VIDEO.C|. Then the following responses produce equivalent filenames when \jed{} expands them internally: \begin{verbatim} Find File: C:\JED\src\video.c Find File: C:\JED\SLANG\..\src\video.c Find File: C:\JED\SLANG\../src/video.c \end{verbatim} Note that the on MS-DOS systems, \jed{} replaces the \var{/} with a \verb|\| and that case is not important. Now suppose you wish to get the file \var{VIDEO.C} from disk \var{A:}. The following are also valid: \begin{verbatim} Find File: A:\video.c Find File: A:video.c Find File: C:\JED\SLANG\a:\video.c \end{verbatim} In the last case, \jed{} is smart enough to figure out what is really meant. Although the above examples are for MS-DOS systems, the rules also apply to Unix and VMS systems as well. The only change is the file name syntax. For example, on VMS \begin{verbatim} sys$manager:[misc]dev$user:[davis.jed]vms.c dev$user:[davis.jed]vms.c \end{verbatim} %$ become equivalent filenames upon expansion. For unix, the following are equivalent: \begin{verbatim} /user1/users/davis/jed/unix.c /usr/local/src//user1/users/davis/jed/unix.c /usr/local/src/~/jed/unix.c \end{verbatim} Note the last example: the tilde character \verb|~| always expands into the users \verb|HOME| directory, in this case to \verb|/user1/users/davis|. When \jed{} writes a buffer out to a file, it usually prompts for a file name in the minibuffer displaying the directory associated with the current buffer. At this point a name can be appended to the directory string to form a valid file name or the user may simply hit the \key{RET} key. If the latter alternative is chosen, \jed{} simply writes the buffer to the file already associated with the buffer. Once the buffer is written to a file, the buffer becomes attached to that file. \subsection{Buffer Name and File Name Completion} When \jed{} prompts for a file name or a buffer name, the space bar and the \key{Tab} keys are special. Hitting the \key{Tab} key will complete the name that is currently in the minibuffer up until it is no longer unique. At that point, you can either enter more characters to complete the name or hit the space bar to cycle among the possible completions. The spacebar must be pressed at least twice to cycle among the completions. On MSDOS and VMS, it is possible to use wildcard characters in the file name for completion purposes. For example, entering \key{*.c} and hitting the space bar will cycle among file names matching \key{*.c}. Unfortunately, this feature is not available on unix systems. \section{Basic Editing} Editing with \jed{} is pretty easy--- most keys simply insert themselves. Movement around the buffer is usually done using the arrow keys or page up and page down keys. If \verb|edt.sl| is loaded, the keypads on VTxxx terminals function as well. Here, only the highlights are touched upon (cut/paste operations are not considered ``highlights''). In the following, any character prefixed by the \verb|^| character denotes a Control character. On keyboards without an explicit Escape key, \key{Ctrl-[} will most likely generate and Escape character. A ``prefix argument'' to a command may be generated by first hitting the \key{Esc} key, then entering the number followed by pressing the desired key. Normally, the prefix argument is used simply for repetition. For example, to move to the right 40 characters, one would press \key{Esc 4 0} followed immediately by the right arrow key. This illustrates the use of the repeat argument for repetition. However, the prefix argument may be used in other ways as well. For example, to begin defining a region, one would press the \key{Ctrl-@} key. This sets the mark and begins highlighting. Pressing the \key{Ctrl-@} key with a prefix argument will abort the act of defining the region and to pop the mark. The following list of useful keybindings assumes that \verb|emacs.sl| has been loaded. \key{Ctrl-L}\\ Redraw screen. \key{Ctrl-\_}\\ Undo (Control-underscore, also \key{Ctrl-X u}). \key{Esc q}\\ Reformat paragraph (wrap mode). Used with a prefix argument. will justify the paragraph as well. \key{Esc n}\\ narrow paragraph (wrap mode). Used with a prefix argument will justify the paragraph as well. \key{Esc ;}\\ Make Language comment (Fortran and C) \key{Esc} \verb|\|\\ Trim whitespace around point \key{Esc !}\\ Execute shell command \key{Esc \$}\\ Ispell word (unix) \key{Ctrl-X ?}\\ Show line/column information. \key{`}\\ \verb|quoted_insert| --- insert next char as is (backquote key) \key{Esc s}\\ Center line. \key{Esc u}\\ Upcase word. \key{Esc d}\\ Downcase word. \key{Esc c}\\ Capitalize word. \key{Esc x}\\ Get M-x minibuffer prompt with command completion \key{Ctrl-X Ctrl-B}\\ pop up a list of buffers \key{Ctrl-X Ctrl-C}\\ exit \jed{} \key{Ctrl-X 0}\\ Delete Current Window \key{Ctrl-X 1}\\ One Window. \key{Ctrl-X 2}\\ Split Window. \key{Ctrl-X o}\\ Other window. \key{Ctrl-X b}\\ switch to buffer \key{Ctrl-X k}\\ kill buffer \key{Ctrl-X s}\\ save some buffers \key{Ctrl-X Esc}\\ Get \var{S-Lang>} prompt for interface to the \slang{} interpreter. \key{Esc .}\\ Find tag (unix ctags compatible) \key{Ctrl-@}\\ Set Mark (Begin defining a region). Used with a prefix argument aborts the act of defining the region and pops the Mark. \subsection{Undo} One of \jed{}'s nicest features is the ability to undo nearly any change that occurs within a buffer at the touch of a key. If you delete a word, you can undo it. If you delete 10 words in the middle of the buffer, move to the top of the buffer and randomly make changes, you can undo all of that too. By default, the \verb|undo| function is bound to the key \key{Ctrl-\_} (Ascii 31). Since some terminals are not capable of generating this character, it is also bound to the key sequence \key{Ctrl-X} u. Due to the lack of virtual memory support on IBMPC systems, the \verb|undo| function is not enabled on every buffer. In particular, it is not enabled for the \verb|*scratch*| buffer. However, it is enabled for any buffer which is associated with a file. A ``plus'' character on the left hand side of the status line indicates that undo is enabled for the buffer. It is possible to enable undo for any buffer by using the \verb|toggle_undo| function. \subsection{Marking Text (Point and Mark)} Many commands work on certain regions of text. A region is defined by the \verb|Point| and the \verb|Mark| The \verb|Point| is the location of the current editing point or cursor position. The \verb|Mark| is the location of a mark. The mark is set using the \verb|set_mark_cmd| which is bound to \key{Ctrl-@} (Control-2 or Control-Space on some keyboards). When the mark is set, the \var{m} mark indicator will appear on the status line. This indicates that a region is being defined. Moving the cursor (\verb|Point|) defines the other end of a region. If the variable \var{HIGHLIGHT} is non-zero, \jed{} will highlight the region as it is defined. Even without highlighting, it is easy to see where the location of the mark is by using the \verb|exchange| command which is bound to \key{Ctrl-X} \key{Ctrl-X}. This simply exchanges the \verb|Point| and the \verb|Mark|. The region is still intact since it is defined only by the \verb|Point| and \verb|Mark|. Pressing \key{Ctrl-X} \key{Ctrl-X} again restores the mark and Point back to their original locations. Try it. \subsection{Tab Issues.} Strictly speaking, \jed{} uses only fixed column tabs whose size is determined by the value of the \verb|TAB| variable. Setting the \verb|TAB| variable to 0 causes \jed{} to not use tabs as whitespace and to display tabs as \key{Ctrl-I}. Please note that changing the tab settings on the terminal will have no effect as far as \jed{} is concerned. The \verb|TAB| variable is local to each buffer allowing every buffer to have its own tab setting. The variable \verb|TAB_DEFAULT| is the tab setting that is given to all newly created buffers. The default value for this variable is 8 which corresponds to eight column tabs. \jed{} is also able to ``simulate'' arbitrary tabs as well through the use of user defined tab stops. Calling the function \verb|edit_tab_stops| allows the user to interactively set the tab stops. That is, one simply presses \key{Esc X} to get the \verb|M-x| prompt and enters \verb|edit_tab_stops|. A window will pop open displaying the current tab settings. To add a tab stop, simply place a \key{T} in the appropriate column. Use the space bar to remove a tab stop. Here an argument is presented in favor of simulated tabs over real tab stops. First, consider what a ``tab'' really is. A ``tab'' in a file is nothing more than a character whose ASCII value is 9. For this reason, one also denotes a tab as \verb|^I| (\key{Ctrl-I}). Unlike most other ASCII characters, the effect of the tab character is device dependent and is controlled through the device tab settings. Hence, a file which displays one way on one device may look totally different on another device if the tab settings do not correspond. For this reason, many people avoid tabs altogether and others the adopt ``standard'' of eight column tabs. Even though people always argue about what the correct tab settings should be, it must be kept in mind that this is primarily a human issue and not a machine issue. On a device employing tab stops, a tab will cause the cursor to jump to the position of the next tab stop. Now consider the effect of changing the tab settings. Assume that in one part of a document, text was entered using the first setting and in another part, the second setting was used. When moving from the part of the document where the current tab setting is appropriate to the part where the other tab setting was used will cause the document to look unformatted unless the appropriate tab settings are restored. Wordprocessors store the tab settings in the file with the text so that the tabs may be dynamically changed to eliminate such unwanted behavior. However, text editors such as \jed{}, vi, Emacs, EDT, EVE (TPU), etc, do not store this information in the file. \jed{} avoids this problem by using simulated tabs. When using simulated tabs, tabs are not really used at all. Rather \jed{} inserts the appropriate number of spaces to achieve the desired effect. This also has the advantage of one being able to cut and paste from the part of a document using one tab setting to another part with a different tab setting. This simple operation may lead to unwanted results on some wordprocessors as well as those text editors using real tab stops. \subsection{Searching} \jed{} currently has two kinds of searches: ordinary searches and incremental searches. Both types of searches have forward and backward versions. The actual functions for binding purposes are: \begin{verbatim} search_forward search_backward isearch_forward isearch_backward \end{verbatim} There is also the \verb|occur| function which finds all occurrences of a single word (string). This function has no backwards version. By default it is not bound to any keys, so to use it, \verb|occur| must be entered at the \verb|M-x| prompt (\key{Esc X}) or one is always free to bind it to a key. In the following only the incremental search is discussed. The default type of search in Emacs in the incremental search. However, since this type of search is confusing to the uninitiated, the ordinary type of search has been made the default in \jed{}'s Emacs emulation. For the traditional emacs keybinding, it is up to the user to provide the keybinding. As the name suggests, an incremental search performs a search incrementally. That is, as you enter the search string, the editor begins searching right away. For example, suppose you wish to search for the string \var{apple}. As soon as the letter \key{a} is entered into the incremental search prompt, \jed{} will search for the first occurrence of \var{a}. Then as soon as the \key{p} is entered, \jed{} will search from the current point for the string \var{ap}, etc. This way, one is able to quickly locate the desired string with only a minimal amount of information. Unlike the ``ordinary'' search, the incremental search is not terminated with the \key{Enter} key. Hitting the \key{Enter} key causes \jed{} to search for the next occurrence of the string based on the data currently entered at the prompt. The search is terminated with the \key{Esc} key. Finally, the \key{DEL} key (\key{Ctrl-?}) is used to erase the last character entered at the search prompt. In addition to erasing the last character of the search string, \jed{} will return back to the location of the previous match. Erasing all characters will cause the editor to return to the place where the search began. Like many things, this is one of those that is easier to do than explain. Feel free to play around with it. \subsection{Rectangles} \jed{} has built-in support for the editing of rectangular regions of text. One corner of rectangle is defined by setting the mark somewhere in the text. The Point (cursor location) defines the opposite corner of the rectangle. Once a rectangle is defined, one may use the following functions: \verb|kill_rect|\\ Delete text inside the rectangle saving the rectangle in the internal rectangle buffer. \verb|n_rect|\\ Push all text in the rectangle to the right outside the rectangle. \verb|copy_rect|\\ Copy text inside the rectangle to the internal rectangle buffer. \verb|blank_rect|\\ Replace all text inside the rectangle by spaces. The function \verb|insert_rect| inserts a previously killed or copied rectangle into the text at the Point. These functions have no default binding and must be entered into the MiniBuffer by pressing \key{Esc X} to produce the \verb|M-x| prompt. \subsection{Sorting} \jed{} is capable of sorting a region of lines using the heapsort algorithm. The region is sorted alphabetically based upon the ASCII values of the characters located within a user defined rectangle in the region. That is, the rectangle simply defines the characters upon what the sort is based. Simply move to the top line of the region and set the mark on the top left corner of the rectangle. Move to the bottom line and place the point at the position which defines the lower right corner of the rectangle. Press \key{Esc X} to get the \verb|M-x| prompt and enter \verb|sort| As as example, consider the following data: \begin{verbatim} Fruit: Quantity: lemons 3 pears 37 peaches 175 apples 200 oranges 56 \end{verbatim} To sort the data based upon the name, move the Point to the top left corner of the sorting rectangle. In this case, the Point should be moved to the \var{l} in the word \var{lemons}. Set the mark. Now move to the lower right corner of the rectangle which is immediately after the \var{s} in \var{oranges}. Pressing \key{Esc X} and entering \verb|sort| yields: \begin{verbatim} Fruit: Quantity: apples 200 lemons 3 oranges 56 peaches 175 pears 37 \end{verbatim} Suppose that it is desired to sort by quantity instead. Looking at the original (unsorted) data, move the Point to two spaces before the \var{3} on the line containing \var{lemons}. The cursor should be right under the \var{u} in \var{Quantity}. Set the mark. Now move the Point to immediately after \var{56} on the \var{oranges} line and again press \key{Esc X} and enter \verb|sort|. This yields the desired sort: \begin{verbatim} Fruit: Quantity: lemons 3 pears 37 oranges 56 peaches 175 apples 200 \end{verbatim} \section{Modes} \jed{} supports two internal modes as well as user defined modes. The two internal modes consist of a ``C'' mode for C Language programming and a ``Wrap'' mode for ordinary text editing. Examples of user defined modes are Fortran mode and DCL mode. Online documentation is provided for nearly every mode \jed{} defines. For help on the current mode, press \key{Esc X} and enter \verb|describe_mode|. A window will appear with a short description of the special features of the mode as well as a description of the variables affecting the mode. \subsection{Wrap Mode} In this mode, text is wrapped at the column given by the \verb|WRAP| variable. The default is 78. The text does not wrap until the cursor goes beyond the wrap column and a space is inserted. \subsubsection{Formatting paragraphs} Paragraph delimiters are: blank lines, lines that begin with either a percent character, \var{\%}, or a backslash character \verb|\|. This definition is ideally suited for editing \LaTeX{} documents. However, it is possible for the user to change this definition. See the discussion of the hook, \verb|is_paragraph_separator|, in the section on hooks for explicit details on how to do this. The paragraph is formatted according to the indentation of the current line. If the current line is indented, the paragraph will be given the same indentation. The default binding for this function is \key{Esc q}. In addition, a paragraph may be ``narrowed'' by the \verb|narrow_paragraph| function which is bound to \key{Esc N} by default. This differs from the ordinary \verb|format_paragraph| function described above in that the right margin is reduced by an amount equal to the indentation of the current line. For example: \begin{verbatim} This paragraph is the result of using the function ``narrow_paragraph''. Note how the right margin is less here than in the above paragraph. \end{verbatim} Finally, if either of these functions is called from the keyboard with a prefix argument, the paragraph will be justified as well. For example, pressing \key{Esc 1 Esc N} on the previous paragraph yields: \begin{verbatim} This paragraph is the result of using the function ``narrow_paragraph''. Note how the right margin is less here than in the above paragraph. \end{verbatim} See the discussion of \verb|format_paragraph_hook| in the section on hooks for details on how this is implemented. \subsection{Smart Quotes} You have probably noticed that many key words in this document are quoted in double quotes like ``this is double quoted'' and `this is single quoted'. By default, the double quote key (") and single quote key (') are bound to the function \verb|text_smart_quote|. With this binding and in wrap mode, the single quote key inserts a single quote with the ``proper'' orientation and the double quote key inserts two single quotes of the ``proper'' direction. To turn this off, rebind the keys to \verb|self_insert_cmd|. Some modes already do this (e.g., EDT). This brings up the question: if the double quote key is bound to \verb|text_smart_quote| then how does one insert the character (")? The most common way is to use the \verb|quoted_insert| function which, by default, is bound to the single backquote (\key{`}) key. This is the same mechanism that is used to insert control characters. The other method is to use the fact that if the preceding character is a backslash, \verb|\|, the character simply self inserts. Again, this is ideal for writing \TeX{} documents. \subsection{C Mode} C Mode facilitates the editing of C files. Much of the latter part of the development of the \jed{} editor was done using this mode. This mode may be customized by a judicious choice of the variables \verb|C_INDENT| and \verb|C_BRACE| as well as the bindings of the curly brace keys \var{\{} and \key{\}}. Experiment to find what you like or write your own using the \slang{} interface. By default, the \key{Enter} key is bound to the function \verb|newline_and_indent|. This does what its name suggests: inserts a newline and indents. Again, some modes may rebind this key. In addition, the keys \var{\{}, \var{\}}, and \key{Tab} are also special in this mode. The \key{Tab} key indents the current line and the \var{\{} and \var{\}} keys insert themselves and reindent. If you do not like any of these bindings, simply rebind the offending one to \verb|self_insert_cmd|. Finally, the key sequence \key{Esc ;} is bound to a function called \verb|c_make_comment|. This function makes and indents a C comment to the column specified by the value of the variable \verb|C_Comment_Column|. If a comment is already present on the line, it is indented. \subsection{Fortran Mode} Fortran Mode is written entirely in \slang{} and is designed to facilitate the writing of Fortran programs. It features automatic indentation of Fortran code as well as automatic placement of Fortran statement Labels. In this mode, the keys \key{0}-\key{9} are bound to a function \verb|for_elebel| which does the following: \begin{enumerate} %\begin{itemize} \item Inserts the calling character (0-9) into the buffer. \item If the character is preceded by only other digit characters, it assumes the character is for a label and moves it to the appropriate position. \item Reindents the line. \end{enumerate} %\end{itemize} This function is very similar to the one Emacs uses for labels. \section{Keyboard Macros} \jed{} is able to record a series of keystrokes from the terminal and replay them. The saved series of keystrokes is known as a keyboard macro. To begin a keyboard macro, simply enter the begin keyboard macro key sequence which is bound to \key{Ctrl-X (} if \verb|emacs.sl| is loaded. To stop recording the keystrokes, enter \key{Ctrl-X )}. Then to ``execute'' the macro, press \key{Ctrl-X e}. Please note that it is illegal to execute a macro while defining one and doing so generates an error. A macro can be aborted at anytime by pressing the \key{Ctrl-G} key. One nice feature \jed{} includes is the \verb|macro_query| function. That is, while defining a macro, the key sequence \key{Ctrl-X q} will cause \jed{} to issue the prompt \var{Enter String:} in the minibuffer. Any string that is entered will be inserted into the buffer and the process of defining the macro continues. Every time the macro is executed, \jed{} will prompt for a NEW string to be inserted. Any time an error is generated, the process of defining the macro is aborted as well as execution of the macro. This is very useful and may be exploited often. For example, suppose you want to trim excess whitespace from the end of ALL lines in a buffer. Let us also suppose that the number of lines in the buffer is less than 32000. Then consider the following keystrokes: \begin{verbatim} Ctrl-X ( (begin macro) Ctrl-E (goto end of line) ESC (trim whitespace) Down Arrow (go down one line) Ctrl-X ) (end macro) \end{verbatim} Now the macro has been defined. So move to the top of the buffer and execute it 32000 times: \begin{verbatim} ESC < (top of buffer) ESC 3 2 0 0 0 (repeat next command 32000 times Ctrl-X e (execute macro) \end{verbatim} If the buffer has less than 32000 lines, the end of the buffer will be reached and an error will be generated aborting the execution of the macro. \section{Shells and Shell Commands} The default binding to execute a shell command and pump the output to a buffer is \key{Esc !}. \jed{} will prompt for a command line and spawn a subprocess for its execution. Strictly speaking, \jed{} does not support interactive subprocesses. However, \jed{} includes \slang{} code that ``emulates'' such a subprocess. It may invoked by typing \verb|shell| at the \verb|M-x| minibuffer prompt. A window will be created with a buffer named \var{*shell*} attached to it. Any text entered at the system dependent shell prompt will be executed in a subprocess and the result stuffed back in the shell buffer. Don't try to execute any commands which try to take over the keyboard or the screen or something undesirable may happen. Examples of types of stupid commands are spawning other editors, logging in to remote systems, et cetera. Even \var{chdir} is stupid since its effect is not permanent. That is, \begin{verbatim} > cd .. > dir \end{verbatim} will not do what might naively be expected. That is, the two commands above are not equivalent to the single command \var{dir ..}. \section{Getting Help} \jed{}'s help functions are bound to \key{Ctrl-H} by default. For example, \key{\key{Ctrl-H} C} will show what function a key carries out, \key{\key{Ctrl-H} i} will run \jed{}'s info reader, \key{Ctrl-H f} will give help on a particular \slang{} function, etc. However, some modes may use the \key{Ctrl-H} key for something else. For example, if EDT mode is in effect, then \key{Ctrl-H} may be bound to \verb|bol| which causes the cursor to move to the beginning of the line. See the section on EDT for more information. If \jed{} is properly installed, this entire document is accessable from within the editor using \jed{}'s info reader. \key{Ctrl-H i} will load \verb|info_mode| allowing the user to browse the document as well as other ``info'' documents. \section{Editing Binary Files} \jed{} may edit binary files as long as the proper precautions are taken. On IBMPC systems, this involves calling the \slang{} function \verb|set_file_translation| with an integer argument. If the argument is 0, files are opened as text files; otherwise, they are opened in binary mode. There is no need to call this function for other systems. However, beware of the user variable \verb|ADD_NEWLINE| which if non zero, a newline character will be appended to the file if the last character is not a newline character. If you are going to edit binary files, it is probably a good idea to set this variable to zero. \section{Dired--- the Directory editor} In addition to editing files, \jed{} is also able to rename and delete them as well. \jed{}'s Dired mode allows one to do just this is a simple and safe manner. To run dired, simply press \key{Esc X} and enter \verb|dired| at the prompt. \jed{} will load \verb|dired.sl| and prompt for a directory name. Once the directory is given, \jed{} will display a list files in the directory in a buffer named \var{*dired*}. One may use normal buffer movement keys to move around this buffer. To delete one or more files, use the \key{d} key to ``tag'' the files. This in itself does not delete them; rather, it simply marks them for deleting. A capital `D' will appear in the left margin to indicate that a file has been tagged. Simply hit the \key{u} key to untag a file. The delete key will also untag the previously tagged file. To actually delete the tagged files, press the `x' key. This action causes \jed{} to display a list of the tagged files in a separate window and prompt the user for confirmation. Only when the proper confirmation is given, will the file be deleted. Renaming a file is just as simple. Simply move to the line containg the name of the file that you wish to rename and hit the `r' key. \jed{} will prompt for a filename or a directory name. If a directory is given, the file will be moved to the new directory but will keep the name. However, for the operation to succeed, the file must be one the same file system. To rename tagged files to a different directory residing on the same file system, use the \key{m} key. This has the effect of moving the tagged file out of the current directory to the new one. One may also use the \key{f} key to read the file indicated by the cursor position into a buffer for editing. If the file is a directory, the directory will be used for dired operations. In addition, one may also use the \key{v} to simply ``view'' a file. Finally, the \key{g} key will re-read the current directory and the \key{h} and \key{?} keys provide some help. \section{Mail} This section applies to Unix and VMS systems only. On these systems, it is possible to compose and send mail directly using \jed{}. This assumes that the Unix system has \verb|/usr/ucb/mail|. It is trivial to modify \verb|mail.sl| to support another Unix mailer. For VMS, \jed{} uses the callable mail interface present on VMS versions 5.0 and later. The default binding for the mail is \key{Ctrl-X m}. Alternatively, one may press \key{Esc X} and enter \verb|mail| at the \var{M-x} prompt. The mail function will cause a window to open with a buffer called \verb|*mail*| which contains the three lines: \begin{verbatim} To: Subject: ---text follows this line--- \end{verbatim} Simply enter the email address of the person that you want to send the mail to on the line containing \var{To:} and put the subject of the message on the next line labeled \var{Subject:}. The text that you wish to mail follows the line labeled \var{---text follows this line---} which is used by \jed{} as a marker. After you have composed the mail message, press \key{Esc X} and enter \verb|send| at the \verb|M-x| prompt. For example, the following is an email requesting to be put on the \jed{} mailing list: \begin{verbatim} To: davis@space.mit.edu Subject: jed mailing list ---text follows this line--- Hi, Please add me to the JED mailing list so that I may be notified of upcoming releases of JED. --Maria \end{verbatim} For VMS systems, the above example will probably fail because an internet address has been used for the example. For systems using a TCP/IP package, it may be necessary to change \var{davis@space.mit.edu} to something like \var{smtp\%"davis@space.mit.edu"}. The mail function looks for a user defined hook called \verb|mail_hook| and execute it if it exists. This hook may be used to bind certain keys in the keymap associated with the \verb|*mail*| buffer. For example, \begin{verbatim} define mail_hook () { local_unsetkey ("^C"); local_setkey ("send", "^C^C"); } \end{verbatim} defines the key \key{Ctrl-C Ctrl-C} in the mail keymap to perform the \verb|send| function. Other possibilities include binding a key sequence, say \key{Ctrl-C Ctrl-W}, to a function that inserts the contents of a signature file. \section{Customization} To extend \jed{}, it is necessary to become familiar with the \slang{} programming language. \slang{} not a standalone programming language like C, Pascal, etc. Rather it is meant to be embedded into a C program. The \slang{} programming language itself provides only arithmetic, looping, and branching constructs. In addition, it defines a few other primitive operations on its data structures. It is up to the application to define other built-in operations tailored to the application. That is what has been done for the \jed{} editor. See the document \verb|slang.txt| for \slang{} basics as well as the \jed{} Programmer's Manual for functions \jed{} has added to the language. In any case, look at the \verb|*.sl| files for explicit examples. For the most part, the average user will simply want to rebind some keys and change some variables (e.g., tab width). Here I discuss setting keys and the predefined global variables. \subsection{Setting Keys} Defining a key to invoke a certain function is accomplished using the \verb|setkey| function. This function takes two arguments: the function to be executed and the key binding. For example, suppose that you want to bind the key \key{Ctrl-A} to cause the cursor to go to the beginning of the current line. The \jed{} function that causes this is \verb|bol| (See the \jed{} Programmer's Manual for a complete list of functions). Putting the line: \begin{verbatim} setkey ("bol", "^A"); \end{verbatim} in the startup file \verb|jed.rc| (\verb|.jedrc|) file will perform the binding. Here \verb|^A| consists of the two characters \verb|^| and \var{A} which \jed{} will interpret as the single character \verb|Ctrl-A|. For more examples, see either of the \slang{} files \verb|emacs.sl| or \verb|edt.sl|. The first argument to the \verb|setkey| function may be {\em any} \slang expression. Well, almost any. The only restriction is that the newline character cannot appear in the expression. For example, the line \begin{verbatim} setkey ("bol();skip_white ();", "^A"); \end{verbatim} defines the \verb|Ctrl-A| key such that when it is pressed, the editing point will move the beginning of the line and then skip whitespace up to the first non-whitespace character on the line. In addition to being able to define keys to execute functions, it is also possible to define a key to directly insert a string of characters. For example, suppose that you want to define a key to insert the string \var{int main(int argc, char **argv)} whenever you press the key \key{Esc m}. This may be accomplished as follows: \begin{verbatim} setkey (" int main(int argc, char **argv)", "\em"); \end{verbatim} Notice two things. First of all, the key sequence \key{Esc m} has been written as \verb|"\em"| where \verb|\e| will be interpreted by \jed{} as \key{Esc}. The other salient feature is that the first argument to \verb|setkey|, the ``function'' argument, begins with a space. This tells \jed{} that it is not be interpreted as the name of a function; rather, the characters following the space are to be inserted into the buffer. Omitting the space character would cause \jed{} to execute a function called \var{int main(int argc, char **argv)} which would fail and generate an error. Finally, it is possible to define a key to execute a series of keystrokes similar to a keyboard macro. This is done by prefixing the ``function'' name with the \var{@} character. This instructs \jed{} to interpret the characters following the \var{@} character as characters entered from the keyboard and execute any function that they are bound to. For example, consider the following key definition which will generate a C language comment to comment out the current line of text. In C, this may be achieved by inserting symbol \var{"/*"} at the beginning of the line and inserting \var{"*/"} at the end of the line. Hence, the sequence is clear (Emacs keybindings): %\begin{itemize} \begin{enumerate} \item Goto the beginning of the line: \key{Ctrl-A} or decimal \verb|"\001"|. \item Insert \var{/*}. \item Goto end of the line: \key{Ctrl-E} or decimal \verb|\005|. \item Insert \var{*/} \end{enumerate} %\end{itemize} To bind this sequence of steps to the key sequence \key{Esc ;}, simply use \begin{verbatim} setkey("@\001/*\005*/", "\e;"); \end{verbatim} Again, the prefix \var{@} lets \jed{} know that the remaining characters will carry out the functions they are currently bound to. Also pay particular attention to the way \key{Ctrl-A} and \key{Ctrl-E} have been written. Do not attempt to use the \verb|^| to represent ``\key{Ctrl}''. It does not have the same meaning in the first argument to the \verb|setkey| function as it does in the second argument. To have control characters in the first argument, you must enter them as \verb|\|{\em xyz} where {\em xyz} is a three digit decimal number coinciding with the ASCII value of the character. In this notation, the \key{Esc} character could have been written as \verb|\027|. See the \slang{} Programmer's Reference Manual for further discussion of this notation. The \verb|setkey| function sets a key in the \verb|global| keymap from which all others are derived. It is also possible to use the function \verb|local_setkey| which operates only upon the current keymap which may or may not be the \verb|global| map. \subsection{Predefined Variables} \jed{} includes some predefined variables which the user may change. By convention, predefined variables are in uppercase. The variables which effect all modes include: \verb|BLINK|\\ (1) if non-zero, blink matching parenthesis. \verb|TAB_DEFAULT|\\ (8) sets default tab setting for newly created buffers to specified number of columns. \verb|TAB|\\ Value of tab setting for current buffer. \verb|ADD_NEWLINE|\\ (1) adds newline to end of file if needed when writing it out to the disk. \verb|META_CHAR|\\ (-1) prefix for chars with high bit set (see section on eight bit clean issues for details) \verb|DISPLAY_EIGHT_BIT|\\ see section on eight bit clean issues. \verb|COLOR|\\ (23) IBMPC background color (see \verb|jed.rc| for meaning) \verb|LINENUMBERS|\\ (0) if 1, show current line number on status line \verb|WANT_EOB|\\ (0) if 1, [EOB] denotes end of buffer. \verb|TERM_CANNOT_INSERT|\\ (0) if 1, do not put the terminal in insert mode when writing to the screen. \verb|IGNORE_BEEP|\\ (0) do not beep the terminal when signalling errors In addition to the above, there are variables which affect only certain modes. See the section on modes for details. \subsection{Hooks} A hook is a user defined function that \jed{} calls under certain conditions which allow the user to modify default actions. For example, when \jed{} starts up it looks for the existence of a user defined function \verb|command_line_hook|. If this function exists, \jed{} calls the function. What the function does is completely arbitrary and is left to the discretion of the user. The startup file, \verb|site.sl|, defines such a function which reads in the files listed on the command line. It is also this function which loads the \verb|jed.rc| startup file. Unlike the other hooks, this one must be present in the file \verb|site.sl| since it is the only file loaded before calling the hook. After the startup files are loaded, \jed{} calls the hook \verb|jed_startup_hook| immediately before entering the main editor loop. This hook is useful to modify certain data structures which may not have existed when the startup files were loaded. In addition to the above hooks, \jed{} currently also looks for: \verb|suspend_hook|\\ function to be executed before suspending \verb|resume_hook|\\ function that gets carried out after suspension \verb|exit_hook|\\ gets executed before exiting \jed{} \verb|mode_hook|\\ sets buffer mode based on filename extension \verb|find_file_hook|\\ called before file is read into a buffer. It currently checks for presence of autosave file and warns user if it is more recent than file. See \verb|site.sl| for explicit examples of the above hooks. Another useful hook is \verb|is_paragraph_separator|. This hook is called when \jed{} searches for the beginning or end of a paragraph. This search is performed by all paragraph formatting functions as well as the forward and backward paragraph movement commands. As \jed{} performs the search, it moves from one line to another testing the line to see if it separates a paragraph. The function of the hook is to make this decision and return zero if the line does not separate paragraphs or return one if it does. The default value of this hook may be written in \slang{} as \begin{verbatim} define is_paragraph_separator () { bol (); if (looking_at ("\\")) return 1; if (looking_at ("%")) return 1; skip_white(); eolp (); } \end{verbatim} A related hook called after a paragraph is formatted is \verb|format_paragraph_hook|. This hook is only called if either \verb|format_paragraph| or \verb|narrow_paragraph| is called with a prefix digit argument. For example, \verb|format_paragraph| is bound to \key{Esc q}. Simply pressing this key sequence will call \verb|format_paragraph| but \verb|format_paragraph_hook| will not be called. However, pressing \key{Esc 1} followed by \key{Esc q} will result in a call to \verb|format_paragraph_hook|. Currently, this hook simply justifies the paragraph. That is, it fills each line in the paragraph such that the line ends at the right margin, which is defined by the \verb|WRAP| variable. \subsection{S-Lang Programming Hints (Debugging)} This section assumes some knowledge about \slang{} and is designed to explain how to debug \slang{} routines quickly. For information about \slang{}, read \verb|slang.txt|. There are two ways of loading a file of \slang{} code into \jed{}. The most common way is through the function \verb|evalfile|. If an error occurs while loading a file, \jed{} will give some indication of where the problem lies by displaying the line number and the offending bit of \slang{} code in the minibuffer. In practice though, this can be quite inefficient. The \verb|evalfile| function is primarily designed to load debugged and tested \slang{} code. The best way to develop and test \slang{} code with \jed{} is to use the function \verb|evalbuffer|. Simply load the piece of code into \jed{} as an ordinary file, press \key{Esc X} and enter the function \verb|evalbuffer| If the piece of code in the buffer has any syntax errors, \jed{} will put the cursor on the error. This is the best way to spot compile time errors such as syntax errors. However, this will not catch runtime errors. When a runtime error occurs, \jed{} will put the cursor on the top level function where the original call was made and NOT the actual location of the function. To aid in determining where an error occurs, \jed{} can be made to give a symbolic traceback. As the \slang{} runtime stack unwinds, \slang{} will simply print the name of function at that particular level. If the function includes local variables, their values will be dumped as well. Hence, it is easy to quickly narrow the location of an error down to function where the error occurs. By default, the traceback is disabled. The traceback is enabled by setting the \slang{} variable \verb|_traceback| to a non-zero value. It is simpliest to just press \key{Ctrl-X Esc} and enter \verb|_traceback = 1| at the \var{S-Lang} prompt. This is one of those times where one needs access to the \var{S-Lang>} prompt and not the \var{M-x} prompt. For example, consider the following piece of code: \begin{verbatim} define fun_two () {forever {}} % loops forever define fun_one () {fun_two ()} % calls fun_two-- never returns \end{verbatim} Simply enter the above into an empty \jed{} \verb|*scratch*| buffer, then press \key{Ctrl-X Esc} and enter: \begin{verbatim} _traceback = 1; () = evalbuffer (); fun_one (); \end{verbatim} This will turn on tracebacks, evaluate the buffer and call the function \verb|fun_one|. \jed{} will then be put into an infinite loop which can only be stopped by pressing the abort character which by default is \key{Ctrl-G}. Doing so, will produce the traceback messages \begin{verbatim} S-Lang Traceback: fun_two S-Lang Traceback: fun_one \end{verbatim} in addition to the error message \var{User Break!}. Of course, this technique only narrows down the source of an error to a particular function. To proceed further, it may necessary to put ``print'' statements at suitable places in the function. There are several ways to do this: %\begin{itemize} \begin{enumerate} \item Use the \verb|insert| function to insert the contents of a variable into the current buffer. \item Use the \verb|error| function to abort the function and display the value of a variable in the minibuffer. \item Use the \verb|message| function to display the value of a variable in the minibuffer. Unlike \verb|error|, the \verb|message| function does not abort the execution of the function. \end{enumerate} %\end{itemize} Since each of these functions require a string argument, it is usually best to call the \verb|string| function first for the conversion followed by the output function. This has to be done anyway if it is desired to get the contents of an integer variable. Although the second approach is prehaps the most useful in practice, it is somtimes appropriate to use a combination of these techniques. Finally, to print the entire stack, one can use the \verb|print_stack| function. This function dumps the \slang{} runtime stack into the \var{*traceback*} buffer. Since \slang{} is an interpreted language, judicious application of the above techniques should lead very quickly to the source of any errors. \section{Eight Bit Clean Issues} \subsection{Displaying Characters with the High Bit Set} There are several issues to consider here. The most important issue is how to get \jed{} to display 8 bit characters in a ``clean'' way. By ``clean'' I mean any character with the high bit set is sent to the display device as is. This is achieved by putting the line: \begin{verbatim} DISPLAY_EIGHT_BIT = 1; \end{verbatim} in the \verb|jed.rc| (\verb|.jedrc|) startup file. European systems might want to put this in the file \verb|site.sl| for all users. The default is 1 so unless its value has been changed, this step may not be necessary. There is another issue. Suppose you want to display 8 bit characters with extended Ascii codes greater than or equal to some value, say 160. This is done by putting \verb|DISPLAY_EIGHT_BIT = 160;|. I believe that ISO Latin character sets assume this. This is the default value for Unix and VMS systems. \subsection{Inputting Characters with the hight bit Set} Inputting characters with the high bit set into \jed{} is another issue. How \jed{} interprets this bit is controlled by the variable \verb|META_CHAR|. What happens is this: When \jed{} reads a character from the input device with the high bit set, it: %\begin{itemize} \begin{enumerate} \item Checks the value of \verb|META_CHAR|. If this value is -1, \jed{} simply inserts the character into the buffer. \item For any other value of \verb|META_CHAR| in the range 0 to 255, \jed{} returns two 7-bit characters. The first character returned is \verb|META_CHAR| itself. The next character returned is the original character but with the high bit stripped. \end{enumerate} %\end{itemize} The default value of \verb|META_CHAR| is -1 which means that when \jed{} sees a character with the high bit set, \jed{} leaves it as is. Please note that a character with the high bit set it {\em cannot} be the prefix character of a keymap. It can be a part of the keymap but not the prefix. Some systems only handle 7-bit character sequences and as a result, \jed{} will only see 7-bit characters. \jed{} is still able to insert {\em any} character in the range 0-255 on a 7-bit system. This is done through the use of the \verb|quoted_insert| function which, by default, is bound to the backquote key \var{`}. If the \verb|quoted_insert| function is called with a digit argument (repeat argument), the character with the value of the argument is inserted into the buffer. Operationally, one hits \key{Esc}, enters the extended Ascii code and hits the backquote key. For example, to insert character 255 into the buffer, simply press the following five keys: \key{Esc 2 5 5 `}. \subsection{Upper Case - Lower Case Conversions} The above discussion centers around input and output of characters with the high bit set. How \jed{} treats them internally is another issue and new questions arise. For example, what is the uppercase equivalent of a character with ASCII code 231? This may vary from language to language. Some languages even have characters whose uppercase equivalent correspond to multiple characters. For \jed{}, the following assumptions have been made: \begin{itemize} \item Each character is only 8 bits. \item Each character has a unique uppercase equivalent. \item Each character has a unique lowercase equivalent. \end{itemize} It would be nice if a fourth assumption could be made: \begin{itemize} \item The value of the lowercase of a character is greater than or equal to its uppercase counterpart. \end{itemize} However, apparently this is not possible since most IBMPC character sets violate this assumption. Hence, \jed{} does not assume it. Suppose \var{X} is the upper case value of some character and suppose \var{Y} is its lower case value. Then to make \jed{} aware of this fact and use it case conversions, it may be necessary to put a statement of the form: \begin{verbatim} define_case (X, Y); \end{verbatim} in the startup file. For example, suppose 211 is the uppercase of 244. Then, the line \begin{verbatim} define_case (211, 244); \end{verbatim} will make \jed{} use this fact in operations involving the case of a character. This has already been done for the ISO Latin 1 character set. See the file \verb|iso-latin.sl| for details. For MSDOS, this will not work. Instead use the files \verb|dos437.sl| and \verb|dos850.sl|. By default, \jed{}'s internal lookup tables are initialized to the ISO Latin set for Unix and VMS systems and to the DOS 437 code page for the IBMPC. To change the defaults, it is only necessary to load the appropriate file. For example, to load \verb|dos850.sl| definitions, put \begin{verbatim} evalfile ("dos850"); pop (); \end{verbatim} in the startup file (e.g., \verb|site.sl|). In addition to uppercase/lowercase information, these files also contain word definitions, i.e., which characters constitute a ``word''. \section{Miscellaneous} \subsection{Abort Character} The abort character (\key{Ctrl-G} by default) is special and should not be rebound. On the IBMPC, the keyboard interrupt 0x09 is hooked and a quit condition is signaled when it is pressed. For this reason, it should not be used in any keybindings. A similar statement holds for the other systems. This character may be changed using the function \verb|set_abort_char| Using this function affects all keymaps. For example, putting the line \begin{verbatim} set_abort_char (30); \end{verbatim} in your \verb|jed.rc| file will change the abort character from its current value to 30 which is \key{Ctrl-}\verb|^|. \subsection{Input Translation} By using the function \verb|map_input| the user is able to remap characters input from the terminal before \jed{}'s keymap routines have a chance to act upon them. This is useful when it is difficult to get \jed{} to see certain characters. For example, consider the \key{Ctrl-S} character. This character is especially notorious because many systems use it and \key{Ctrl-Q} for flow control. Nevertheless Emacs uses \key{Ctrl-S} for searching. Short of rebinding all keys which involve a \key{Ctrl-S} how does one work with functions that are bound to key sequences using \key{Ctrl-S}? This is where \verb|map_input| comes into play. The \verb|map_input| function requires two integer arguments which define how a given ascii character is to be mapped. Suppose that you wish to substitute \key{Ctrl-}\verb|\| for \key{Ctrl-S} everywhere. The line \begin{verbatim} map_input (28, 19); \end{verbatim} will do the trick. Here 28 is the ascii character of \key{Ctrl-}\verb|\| and 19 is the ascii character for the \key{Ctrl-S}. As another example, consider the case where the backspace key sends out a \key{Ctrl-H} instead of the \key{DEL} character (\key{Ctrl-?}). \begin{verbatim} map_input (8, 127); \end{verbatim} will map the \key{Ctrl-H} (ascii 8) to the delete character (ascii 127). \subsection{Display Sizes} On VMS and unix systems, the screen size may be changed to either 80 or 132 columns by using the functions \verb|w80| and \verb|w132| respectively. Simply enter the appropriate function name at the \verb|M-x| prompt in the minibuffer. The default binding for access to the minibuffer is \key{Esc X}. Most window systems, e.g., DECWindows, allow the window size to be changed. When this is done, \jed{} should automatically adapt to the new size. On the PC, at this time the screen size cannot be changed while \jed{} is running. Instead it is necessary to exit \jed{} first then set the display size and rerun \jed{}. \end{document} } ---------------------------------------------------------------------- query_replace_match: "\( [a-z]+\)\1 " "\1 " finds and replaces repeated words. "/\*\(.*\)\*/.*$" "//\1" convert /* c comment */ at eol to // ... "//.*$" "/*\1 */" convert c++ to C jed-0.99-19/doc/manual/rgrep.10000644002657400265740000000742411311317447014724 0ustar davisdavis.\"=========================================================================== .\" rgrep ­ a recursive highlighting grep program, this manpage was writen by .\" "Boris D. Beletsky" copyright(c) 1996 .\" This manpage may be freely distrebuted as part of GNU Debian Linux .\"=========================================================================== .TH RGREP 1 "OCT 1996" Debian "User Manuals" .SH NAME rgrep \- a recursive, highlighting grep program .SH SYNOPSIS .B rgrep .I [ options ] .I pattern .I [ file ] .B ... .SH DESCRIPTION .I rgrep, unlike .I grep(1) and .I egrep(1) rgrep has the ability to recursively descend directories. The traditional way of performing this kind of search on Unix systems utilizes the .I find(1) command in conjunction with .I grep(1). However, this results in very poor performance. .SH COMMAND LINE OPTIONS .LP .I -? .RS additional help (use '-?' to avoid shell expansion on some systems) .RE .I -c .RS count matches .RE .I -h .RS highlight match (ANSI compatable terminal assumed) .RE .I -H .RS Output match instead of entire line containing match .RE .I -i .RS ignore case .RE .I -l .RS list filename only .RE .I -n .RS print line number of match .RE .I -F .RS follow links .RE .I -r .RS recursively scan through directory tree .RE .I -N .RS Do NOT perform a recursive search .RE .I -R 'pat' .RS like '-r' except that only those files matching 'pat' are checked .RE .I -v .RS print only lines that do NOT match the specified pattern .RE .I -x 'ext' .RS checks only files with extension given by 'ext'. .RE .I -D .RS Print all directories that would be searched. This option is for debugging purposes only. No file is grepped with this option. .RE .I -W 'len' .RS lines are 'len' characters long (not newline terminated). .RE .LP .SH SUPPORTED REGULAR EXPRESSIONS: .LP .I . .RS match any character except newline .RE .I \\\d .RS match any digit .RE .I \\\\e .RS match ESC char .RE .I * .RS matches zero or more occurences of previous RE .RE .I + .RS matches one or more occurences of previous RE .RE .I ? .RS matches zero or one occurence of previous RE .RE .I ^ .RS matches beginning of line .RE .I $ .RS matches end of line .RE .I [ ... ] .RS matches any single character between brackets. For example, .I [-02468] matches .I '-' or any even digit. and .I [-0-9a-z] matches .I '-' and any digit between .I 0 and .I 9 as well as letters .I a through .I z. .RE .LP .I \\\\{ ... \\\\} .LP .I \\\\( ... \\\\) .LP .I \\\\1, \\\\2, ..., \\\\9 .RS matches match specified by nth .I '\\\\( ... \\\\)' expression. For example, .I '\\\\([\ \\\\t][a-zA-Z]+\\\\)\\\\1[\ \\\\t]' matches any word repeated consecutively. .RE .LP .SH EXAMPLES Look in all files with a 'c' extension in current directory and all its subdirectories looking for matches of 'int ' at the beginning of a line, printing the line containing the match with its line number: (two methods) .LP .I rgrep -n -R '*.c' '^int ' . .LP .I rgrep -n -x c '^int ' . .LP Highlight all matches of repeated words in file 'paper.tex': .LP .I rgrep -h .I '[\ \\\\t]\\\\([a-zA-Z]+\\\\)[\ \\\\t]+\\\\1[\ \\\\t\\\\n]' paper.tex .LP .I rgrep -h '^\\\\([a-zA-Z]+\\\\)[\ \\\\t]+\\\\1[\ \\\\t\\\\n]' paper.tex .LP (Note that this version of rgrep requires two passes for this example) .LP Search through all files EXCEPT .o and .a file below /usr/src/linux looking for the string 'mouse' without regard to case: .LP .I rgrep -i -R '*.[^ao]' mouse /usr/src/linux .LP Search a fixed record length FITS file for the keyword EXTNAME: .LP .I rgrep -W80 ^EXTNAME file.fits .LP (Note that the regular expression .I '^[A-Z]+' will dump all fits headers.) .SH AUTHOR .LP .RS .I \ """John E. Davis""" .RE .LP -- This manpage was translated to troff by .LP "Boris D. Beletsky" jed-0.99-19/doc/tm/0000755002657400265740000000000011311317447012657 5ustar davisdavisjed-0.99-19/doc/tm/jedfuns.tm0000644002657400265740000000476411311317447014672 0ustar davisdavis#% -*- mode: tm; mode: fold; eval: .0 =TAB -*- #%{{{ Macros #i linuxdoc.tm #d slang \bf{S-lang} #d jed \bf{JED} #d kw#1 \tt{$1} #d exmp#1 \tt{$1} #d var#1 \tt{$1} #d dtype#1 \tt{$1} #d ldots ... #d function#1 \section{$1\label{$1}} #d variable#1 \section{$1\label{$1}} #% d function#1

$1\label{$1}

#d synopsis#1 Synopsis $1 #d keywords#1 Keywords $1 #d usage#1 Usage $1 #d description Description #d example Example #d notes Notes #d seealso#1 \ifarg{$1}{ See Also $1} #d documentstyle article #d r#1 \ref{$1}{$1} #d done

#d -1 -1 #d 0 0 #d 1 1 #d 2 2 #d 3 3 #d 4 4 #d 5 5 #d NULL NULL #d documentstyle book #d section#1 \sect{$1} #%}}} \linuxdoc \begin{\documentstyle} \title Jed Intrinsic Function Reference Manual \author John E. Davis, \tt{davis@space.mit.edu} \date \__today__ \toc \chapter{Movement Functions} #i rtl/move.tm \chapter{Insertion/Deletions Functions} #i rtl/insdel.tm \chapter{Search Functions} #i rtl/search.tm \chapter{Buffer Related Functions} #i rtl/buffer.tm \chapter{Abbreviation Functions} #i rtl/abbrev.tm \chapter{Buffer-Local Variable Functions} #i rtl/blocal.tm \chapter{Color Functions} #i rtl/color.tm \chapter{Loading and Evaluation of S-Lang Code Functions} #i rtl/eval.tm \chapter{File Related Functions} #i rtl/file.tm \chapter{Functions that work with Hidden Lines} #i rtl/hidden.tm \chapter{Functions dealing with hooks} #i rtl/hooks.tm \chapter{Informational Functions} #i rtl/info.tm \chapter{Keymaps and Key Input Functions} #i rtl/keys.tm \chapter{Mark and Spot Functions} #i rtl/mark.tm \chapter{Menu Functions} #i rtl/menu.tm \chapter{Message Functions} #i rtl/message.tm \chapter{Mini-Buffer Functions} #i rtl/mini.tm \chapter{Mouse Functions} #i rtl/mouse.tm \chapter{Subprocess Functions} #i rtl/process.tm \chapter{Rectangle Functions} #i rtl/rect.tm \chapter{Functions that Involve Regions} #i rtl/region.tm \chapter{Search/Replace Functions} #i rtl/search.tm \chapter{Syntax Highlighting and Parsing Functions} #i rtl/syntax.tm \chapter{Terminal Functions} #i rtl/terminal.tm \chapter{User and Host Functions} #i rtl/userinfo.tm \chapter{Display and Window Functions} #i rtl/window.tm \chapter{Xjed-specific Functions} #i rtl/xjed.tm \chapter{Miscellaneous Functions} #i rtl/misc.tm \end{\documentstyle} jed-0.99-19/doc/tm/rtl/0000755002657400265740000000000011311317447013460 5ustar davisdavisjed-0.99-19/doc/tm/rtl/keys.tm0000644002657400265740000004222511311317447015002 0ustar davisdavis\variable{ALT_CHAR} \synopsis{Controls the Alt character prefix} \usage{Int_Type ALT_CHAR} \description If this variable is non-zero, characters pressed in combination the \exmp{Alt} key will generate a two character sequence: the first character is the value of \var{ALT_CHAR} itself followed by the character pressed. For example, if \exmp{Alt-X} is pressed and \var{ALT_CHAR} has a value of 27, the characters \exmp{ESC X} will be generated. \notes This variable may not be available on all platforms. \seealso{META_CHAR, FN_CHAR} \done \variable{CURRENT_KBD_COMMAND} \synopsis{The currently executing keyboard command} \usage{String_Type CURRENT_KBD_COMMAND} \description The value of the \var{CURRENT_KBD_COMMAND} function represents the name of the currently executing procedure bound to the currently executing key sequence. \seealso{LASTKEY, LAST_KBD_COMMAND, _function_name} \done \variable{DEC_8BIT_HACK} \synopsis{Set the input mode for 8 bit control characters} \usage{Int_Type DEC_8BIT_HACK} \description If set to a non-zero value, a input character between 128 and 160 will be converted into a two character sequence: \var{ESC} and the character itself stripped of the high bit + 64. The motivation behind this variable is to enable the editor to work with VTxxx terminals that are in eight bit mode. \seealso{META_CHAR} \done \variable{DEFINING_MACRO} \synopsis{Non-zero if defining a macro} \usage{Int_Type DEFINING_MACRO} \description The \var{DEFINING_MACRO} variable will be non-zero is a keyboard macro definition is in progress. \seealso{EXECUTING_MACRO} \done \variable{EXECUTING_MACRO} \synopsis{Non-zero if a keyboard macro is currently executing} \usage{Int_Type EXECUTING_MACRO} \description The \var{EXECUTING_MACRO} variable will be non-zero is a keyboard macro is currently being executed. \seealso{} \done \variable{FN_CHAR} \synopsis{Set the function key prefix} \usage{Int_Type FN_CHAR} \description If this variable is non-zero, function keys presses will generate a two character sequence: the first character is the value of the \var{FN_CHAR} itself followed by the character pressed. \notes This variable is available only for Microsoft window systems. \seealso{ALT_CHAR, META_CHAR} \done \variable{IGNORE_USER_ABORT} \synopsis{Control keyboard interrupt processing} \usage{Int_Type IGNORE_USER_ABORT} \description If set to a non-zero value, the keyboard interrupt character, e.g., \exmp{Ctrl-G} will not trigger a S-Lang error. When JED starts up, this value is set to \1 so that the user cannot interrupt the loading of site.sl. Later, it is set to 0. \seealso{set_abort_char} \done \variable{KILL_LINE_FEATURE} \synopsis{Configure the kill_line function} \usage{Int_Type KILL_LINE_FEATURE} \description If non-zero, kill_line will kill through end of line character if the cursor is at the beginning of a line. Otherwise, it will kill only to the end of the line. \seealso{bolp} \done \variable{LASTKEY} \synopsis{The value of the current key sequence} \usage{String_Type LASTKEY} \description The value of the \var{LASTKEY} variable represents the currently executing key sequence. \notes Key sequences involving the null character may not be accurately recorded. \seealso{LAST_KBD_COMMAND} \done \variable{LAST_CHAR} \synopsis{The Last Character read from the keyboard} \usage{Int_Type LAST_CHAR} \description The value of \var{LAST_CHAR} will be the last character read from the keyboard buffer. \seealso{} \done \variable{META_CHAR} \synopsis{Specify the meta-character} \usage{Int_Type META_CHAR} \description This variable determines how input characters with the high bit set are to be treated. If \var{META_CHAR} is less than zero, the character is passed through un-processed. However, if \var{META_CHAR} is greater than or equal to zero, an input character with the high bit set is mapped to a two character sequence. The first character of the sequence is the character whose ascii value is \var{META_CHAR} and the second character is the input with its high bit stripped off. \seealso{DISPLAY_EIGHT_BIT, DEC_8BIT_HACK} \done \variable{X_LAST_KEYSYM} \synopsis{Keysym associated with the last key} \usage{Int_Type X_LAST_KEYSYM} \description The value of the \var{X_LAST_KEYSYM} variable represents the keysym of the most previously processed key. \notes This variable is availible only in the XWindows version of \jed. \seealso{LASTKEY} \done \function{buffer_keystring} \synopsis{Append string "str" to the end of the input stream} \usage{Void buffer_keystring (String str);} \description Append string \var{str} to the end of the input stream to be read by JED's getkey routines. \seealso{ungetkey, getkey} \done \function{copy_keymap} \synopsis{Create a new keymap by copying another} \usage{copy_keymap (String_Type new_map, String_Type old_map)} \description The \var{copy_keymap} creates a new keymap whose name is given by \var{new_map} by copying an existing keymap specified by \var{old_map}. \seealso{make_keymap, keymap_p, use_keymap} \done \function{definekey} \synopsis{Bind keys to a function in a specific keymap} \usage{Void definekey(String f, String key, String kmap);} \description Unlike \var{setkey} which operates on the global keymap, this function is used for binding keys to functions in a specific keymap. Here \var{f} is the function to be bound, \var{key} is a string of characters that make up the key sequence and \var{kmap} is the name of the keymap to be used. See \var{setkey} for more information about the arguments. \seealso{setkey, undefinekey, make_keymap, use_keymap} \done \function{dump_bindings} \synopsis{Insert a list of keybindings for "map" into the buffer} \usage{Void dump_bindings(String map);} \description This functions inserts a formatted list of keybindings for the keymap specified by \var{map} into the buffer at the current point. \seealso{get_key_binding} \done \function{enable_flow_control} \synopsis{Turn on XON/XOFF flow control} \usage{Void enable_flow_control (Integer flag);} \description This Unix specific function may be used to turn XON/XOFF flow control on or off. If \var{flag} is non-zero, flow control is turned on; otherwise, it is turned off. \done \function{flush_input} \synopsis{Process all forms of queued input} \usage{Void flush_input ();} \description This function may be used to remove all forms of queued input. \seealso{input_pending, getkey} \done \function{get_key_binding} \synopsis{Return binding information about a key sequence} \usage{(type, funct) = get_key_binding ([ keyseq ])} #v+ Int_Type type; String_Type funct; String_Type keyseq; #v- \description \var{get_key_binding} returns binding information about a specified key sequence. If the optional parameter \var{keyseq} is not present, then \var{get_key_binding} will wait for the user to enter a key sequence. If \var{keyseq} is present, then it denotes the key sequence. This function returns two values: a \dtype{String_Type} or \dtype{Ref_Type} representing the key sequence binding (\var{funct}), and an integer that indicates the key binding type: #v+ type description ------------------------------------- -1 funct is NULL, which indicates that the key has no binding 0 funct is the name of a S-Lang function 1 funct is the name of an internal function 2 funct represents a macro ("@macro") 3 funct represents a string to be inserted (" STRING") 4 funct is a reference (Ref_Type) to the actual function #v- \seealso{getkey, input_pending} \done \function{_getkey} \synopsis{Read an input byte from the keyboard} \usage{Int_Type _getkey ()} \description The \ifun{_getkey} function may be used to read a byte character from the keyboard. It should be used instead of \ifun{getkey} when byte-semantics are required. \seealso{input_pending, _ungetkey, getkey} \done \function{getkey} \synopsis{Read an input character from the keyboard} \usage{Long_Type getkey ()} \description The \var{getkey} function may be used to read an input character from the keyboard. If UTF-8 mode is in effect, the value returned can be negative if the key-sequence corresponds to an invalid UTF-8 encoded sequence. In such a case, the value returned will correspond to the first byte of the sequence, and will be equal in magnitude to the value of byte. \seealso{input_pending, ungetkey, _getkey} \done \function{input_pending} \synopsis{Test whether there is pending keyboard input} \usage{Integer input_pending (Integer tsecs);} \description This function is used to see if keyboard input is available to be read or not. The paramter \var{tsecs} is the amount of time to wait for input before returning if input is not available. The time unit for \var{tsecs} is one-tenth of a second. That is, to wait up to one second, pass a value of ten to this routine. It returns zero if no input is available, otherwise it returns non-zero. As an example, #v+ define peek_key () { variable ch; !if (input_pending (0)) return -1; ch = getkey (); ungetkey (ch); return ch; } #v- returns the value of the next character to be read if one is available; otherwise, it returns -1. \seealso{getkey, ungetkey} \done \function{keymap_p} \synopsis{Test if a keymap "kmap" exists} \usage{Integer keymap_p (String kmap);} \description The \var{keymap_p} function may be used to determine whether or not a keymap with name \var{kmap} exists. If the keymap specified by \var{kmap} exists, the function returns non-zero. It returns zero if the keymap does not exist. \seealso{make_keymap, definekey} \done \function{make_keymap} \synopsis{Create a keymap with name "km"} \usage{Void make_keymap (String km);} \description The \var{make_keymap} function creates a keymap with a name specified by the \var{km} parameter. The new keymap is an exact copy of the pre-defined \exmp{"global"} keymap. \seealso{use_keymap, copy_keymap, keymap_p, definekey, setkey} \done \function{map_input} \synopsis{Remap an input character "x" to "y".} \usage{Void map_input (Integer x, Integer y);} \description The \var{map_input} function may be used to remap an input character with ascii value \var{x} from the keyboard to a different character with ascii value \var{y}. This mapping can be quite useful because it takes place before the editor interprets the character. One simply use of this function is to swap the backspace and delete characters. Since the backspace character has an ascii value of \var{8} and the delete character has ascii value \var{127}, the statement #v+ map_input (8, 127); #v- maps the backspace character to a delete character and #v+ map_input (127, 8); #v- maps the delete character to a backspace character. Used together, these two statement effectively swap the delete and backspace keys. \seealso{getkey} \done \function{prefix_argument} \synopsis{Test if the user has entered a prefix argument} \usage{Int_Type prefix_argument ()} \description This function may be used to determine whether or not the user has entered a prefix argument from the keyboard. If a prefix argument is present, its value is returned, otherwise \NULL will be returned. Calling this function cancels the prefix-argument. \example This example displays the prefix argument in the message area: #v+ arg = prefix_argument (); if (arg == NULL) message ("No Prefix Argument"); else vmessage ("Prefix argument: %d", arg); #v- \notes The old semantics, which are still supported but deprecated allows an integer argument to be passed to the function. This argument will be returned instead of \NULL if no prefix-argument is present. Using the old semantics, the above example could be written as #v+ arg = prefix_argument (-9999); if (arg == -9999) message ("No Prefix Argument"); else vmessage ("Prefix argument: %d", arg); #v- \seealso{set_prefix_argument} \done \function{set_abort_char} \synopsis{change the keyboard character that generates an S-Lang interrupt} \usage{Void set_abort_char (Integer ch);} \description This function may be used to change the keyboard character that generates an S-Lang interrupt. The parameter \var{ch} is the ASCII value of the character that will become the new abort character. The default abort character \exmp{Ctrl-G} corresponds to \exmp{ch=7}. \done \function{set_current_kbd_command} \synopsis{Do as if "s" were entered from the keybord} \usage{Void set_current_kbd_command (String s);} \description Undocumented \done \function{set_prefix_argument} \synopsis{Set the prefix argument} \usage{Void set_prefix_argument (Int_Type n)} \description This function may be used to set the prefix argument to the value specified by \var{n}. If \var{n} is less than zero, then the prefix argument is cancelled. \seealso{prefix_argument} \done \function{setkey} \synopsis{Bind a key sequence "key" to the function "fun"} \usage{Void setkey(String fun, String key);} \description This function may be used to define a key sequence specified by the string \var{key} to the function \var{fun}. \var{key} can contain the \exmp{^} character which denotes that the following character is to be interpreted as a control character, e.g., #v+ setkey("bob", "^Kt"); #v- sets the key sequence \exmp{Ctrl-K t} to the function \var{bob}. The \var{fun} argument is usually the name of an internal or a user defined S-Lang function. However, if may also be a sequence of functions or even another keysequence (a keyboard macro). For example, #v+ setkey ("bol;insert(string(whatline()))", "^Kw"); #v- assigns the key sequence \exmp{Ctrl-K w} to move to the beginning of a line and insert the current line number. For more information about this important function, see the JED User Manual. Note that \var{setkey} works on the "global" keymap. \seealso{unsetkey, definekey} \done \function{undefinekey} \synopsis{Remove a keybinding from "kmap"} \usage{Void undefinekey (String key, String kmap);} \description This function may be used to remove a keybinding from a specified keymap. The key sequence is given by the parameter \var{key} and the keymap is specified by the second parameter \var{kmap}. \seealso{unsetkey, definekey, what_keymap} \done \function{_ungetkey} \synopsis{Push a byte onto the input stream} \usage{Void _ungetkey (Int_Type c)} \description This function may be used to push a byte \exmp{c} onto the input stream. This means that the next keyboard byte to be read will be \exmp{c}. \seealso{buffer_keystring, _getkey, get_key_binding} \done \function{ungetkey} \synopsis{Push a character onto the input stream} \usage{Void ungetkey (Integer c);} \description This function may be used to push a character \exmp{c} represented by its character code onto the input stream. This means that the next keyboard character to be read will be \exmp{c}. \seealso{buffer_keystring, getkey, get_key_binding} \done \function{unsetkey} \synopsis{Remove the definition of "key" from the "global" keymap} \usage{Void unsetkey(String key);} \description This function is used to remove the definition of the key sequence \var{key} from the "global" keymap. This is sometimes necessary to bind new key sequences which conflict with other ones. For example, the "global" keymap binds the keys \exmp{"^[[A"}, \exmp{"^[[B"}, \exmp{"^[[C"}, and \exmp{"^[[D"} to the character movement functions. Using \exmp{unsetkey("^[[A")} will remove the binding of \exmp{"^[[A"} from the global keymap but the other three will remain. However, \exmp{unsetkey("^[[")} will remove the definition of all the above keys. This might be necessary to bind, say, \exmp{"^[["} to some function. \seealso{setkey, undefinekey} \done \function{use_keymap} \synopsis{Set the keymap for the current buffer} \usage{Void use_keymap (String km);} \description This function may be used to dictate which keymap will be used by the current buffer. \var{km} is a string value that corresponds to the name of a keymap. \seealso{make_keymap, copy_keymap, keymap_p, what_keymap} \done \function{what_keymap} \synopsis{Return the name of the current buffer's keymap} \usage{String what_keymap ();} \description This function returns the name of the keymap associated with the current buffer. \seealso{create_keymap, keymap_p} \done \function{which_key} \synopsis{Return the keys that are bound to the function "f"} \usage{Integer which_key (String f);} \description The \var{which_key} function returns the the number of keys that are bound to the function \var{f} in the current keymap. It also returns that number of key sequences with control characters expanded as the two character sequence \exmp{^} and the the whose ascii value is the control character + 64. For example, #v+ define insert_key_bindings (f) { variable n, key; n = which_key (f); loop (n) { str = (); insert (str); insert ("\n"); } } #v- inserts into the buffer all the key sequences that are bound to the function \var{f}. \seealso{get_key_binding, setkey, what_keymap} \done jed-0.99-19/doc/tm/rtl/userinfo.tm0000644002657400265740000000362411311317447015661 0ustar davisdavis\function{get_hostname} \synopsis{Get the name of the host computer} \usage{String_Type get_hostname ()} \description The \var{get_hostname} function returns the name of the host computer. If the editor is unable to determine the name, and the user has not specified a name, then \exmp{"localhost"} is returned. \seealso{set_hostname, get_realname, get_username} \done \function{get_realname} \synopsis{Get the user's real name} \usage{String_Type get_realname} \description The \var{get_realname} returns the user's real name. If the editor is unable to determine this value, an empty string is returned. \seealso{set_realname, get_username, get_hostname} \done \function{get_username} \synopsis{Get the username} \usage{String_Type get_username ()} \description The \var{get_username} function returns the username associated with the current process. If is is unable to determine this value, \exmp{"unknown"} will be returned. \seealso{set_username, get_realname, get_hostname} \done \function{set_hostname} \synopsis{Set the name of the host} \usage{set_hostname (String_Type hostname)} \description \var{set_hostname} may be used to set set the name of the host that the editor will associate with the current process. \seealso{get_hostname, set_username, set_realname} \done \function{set_realname} \synopsis{Set the user's realname} \usage{set_realname (String_Type realname)} \description The \var{set_realname} function sets the editor's notion of what the user's real name is such that subsequent calls to \var{get_realname} will return the specified value. \seealso{get_realname, get_username, set_username, set_hostname} \done \function{set_username} \synopsis{Set the username of the editor process} \usage{set_username (String_Type username)} \description This function may be used to specify the username associated with the editor process. \seealso{get_username, set_realname, set_hostname} \done jed-0.99-19/doc/tm/rtl/process.tm0000644002657400265740000001666611311317447015517 0ustar davisdavis\function{get_process_input} \synopsis{Read all pending input by all subprocesses} \usage{Void get_process_input (Int_Type tsecs)} \description Read all pending input by all subprocesses. If no input is available, this function will wait for input until \var{tsecs} tenth of seconds have expired. \seealso{open_process, kill_process} \done \function{get_process_flags} \synopsis{Get the flags associated with a process} \usage{Int_Type get_process_flags (Int_Type id)} \description This function returns the flags associated with the current process. The \ifun{set_process_flags} may be used to set the flags. \seealso{open_process, set_process_flags} \done \function{kill_process} \synopsis{Kill the subprocess specified by the process handle "id"} \usage{Void kill_process (Int_Type id)} \description Kill the subprocess specified by the process handle \var{id} \seealso{open_process} \done \function{open_process} \synopsis{Open a process and return a unique process id} \usage{Int_Type open_process (name, argv1, argv2, ..., argvN, N)} \description Open subprocess \var{name}. Returns id of process, -1 upon failure. \seealso{kill_process, process_mark, process_query_at_exit} \done \function{process_mark} \synopsis{Return user mark for the position of the last output by the process} \usage{User_Mark process_mark (Int_Type id)} \description This function returns the user mark that contains the position of the last output by the process. \done \function{process_query_at_exit} \synopsis{Whether or not to silently kill a process at exit} \usage{Void process_query_at_exit (Int_Type pid, Int_Type query)} \description The \var{process_query_at_exit} may be used to specify whether or not the process specified by \var{pid} should be silently ignored when the editor exits. If the parameter \var{query} is non-zero, the user will be reminded the process exists before exiting. \seealso{open_process, kill_process, exit_jed} \done \function{run_program} \synopsis{Run another program in a window} \usage{Int_Type run_program (String_Type pgm)} \description Like the \var{system} function, the \var{run_program} function may be used to execute another program. However, this function is more useful for executing interactive programs that require some sort of display manipulation, e.g., \var{lynx}, the text-mode web browser. When called from \var{xjed}, the other program is executed asynchronously in a separate xterm window. If the editor is running in an ordinary terminal, \var{jed} will be suspended while the other program runs. The function returns the exit value of the invoked process. \example #v+ if (0 != run_program ("lynx http://www.jedsoft.org")) error ("lynx failed to run"); #v- \notes The \var{XTerm_Pgm} variable may be used to specify the terminal that \var{xjed} uses when calling \var{run_program}. For example, to use \var{rxvt}, use: #v+ variable XTerm_Pgm = "rxvt"; #v- \seealso{system, open_process} \done \function{run_shell_cmd} \synopsis{Run "cmd" in a separate process} \usage{Integer_Type run_shell_cmd (String cmd)} \description The \var{run_shell_cmd} function may be used to run \var{cmd} in a separate process. Any output generated by the process is inserted into the buffer at the current point. It generates a S-Lang error if the process specified by \var{cmd} could not be opened. Otherwise, it returns the exit status of the process. \done \function{send_process} \synopsis{Send a string to the specified subprocess} \usage{Void send_process (Int_Type id, String s)} \description This function sends the string \exmp{s} to the standard input of the process with the ID \var{id}. With this function and \ifun{set_process} with the argument `output'' you can establish a bi-directional communication with the process. \seealso{open_process, set_process, send_process_eof} \done \function{send_process_eof} \synopsis{Close the "stdin" of the process "id"} \usage{send_process_eof (Int_Type id)} \description This function closes the \var{stdin} of the process specified by the handle \var{id}. \done \function{set_process} \synopsis{Set "what" for process "pid"} \usage{Void set_process (pid, what, value)} #v+ Int_Type pid; String_Type what; String_Type or Ref_Type value; #v- \description \var{pid} is the process handle returned by \var{open_process}. The second parameter, \var{what}, specifies what to set. It must be one of the strings: #v+ "signal" : indicates that 'value' is the name of a function to call when the process status changed. The function specified by 'value' must be declared to accept an argument list: (pid, flags, status) where 'pid' has the same meaning as above and flags is an integer with the meanings: 1: Process Running 2: Process Stopped 4: Process Exited Normally 8: Process Exited via Signal The meaning of the status parameter depends upon the flags parameter. If the process exited normally, then status indicates its return status. Otherwise status represents the signal that either stopped or killed the process. Note: when this function is called, the current buffer is guaranteed to be the buffer associated with the process. "output" : This parameter determines how output from the process is is processed. If the 'value' is the empty string "", output will go to the end of the buffer associated with the process and the point will be left there. If value is ".", output will go at the current buffer position. If value is "@", output will go to the end of the buffer but the point will not move. Otherwise, 'value' is the name or a reference to a slang function that takes arguments: (pid, data) where pid has the above meaning and data is the output from the process. #v- Normally \jed automatically switches to the buffer associated with the process prior to handling data from the process. This behavior may be modified through the use of the \ifun{set_process_flags} function. \seealso{set_process_flags, get_process_flags, open_process} \done \function{set_process_flags} \synopsis{Set the flags associated with a process} \usage{set_process_flags (Int_Type id, Int_Type flags)} \description This function may be used to set the flags associated with the specified process. The flags may be used to affect the behavior of the process. Currently the following bits are defined: #v+ 0x01 Do not switch to the process buffer prior to calling any hooks associated with the buffer including output from the process. #v- \seealso{open_process, get_process_flags, set_process} \done \function{signal_process} \synopsis{Send a signal to the process "pid"} \usage{Void signal_process (Int_Type pid, Int_Type signum)} \description This function may be used to send a signal to the process whose process handle is given by \var{pid}. The \var{pid} must be a valid handle that was returned by \var{open_process}. \seealso{open_process, kill_process, send_process_eof} \done jed-0.99-19/doc/tm/rtl/mini.tm0000644002657400265740000001336611311317447014767 0ustar davisdavis\variable{MINIBUFFER_ACTIVE} \synopsis{Non-zero is the mini-buffer is in use} \usage{Int_Type MINIBUFFER_ACTIVE} \description The \var{MINIBUFFER_ACTIVE} variable will be non-zero if the mini-buffer is in use. \seealso{read_mini} \done \function{_add_completion} \synopsis{"add_completion" for "n" names "f1", ... "fn"} \usage{Void _add_completion (String f1, String f2, ..., Integer n);} \description The \var{_add_completion} function is like the \var{add_completion} function except that it takes \var{n} names \var{f1}, ... \var{fn}. For example, #v+ _add_completion ("fun_a", "fun_b", 2); #v- is equivalent to #v+ add_completion ("fun_a"); add_completion ("fun_b"); #v- \seealso{add_completion} \done \function{add_completion} \synopsis{Add the function "f" to the list for mini-buffer completion} \usage{Void add_completion(String f);} \description The \var{add_completion} function adds the user defined S-Lang function with name specified by the string \var{f} to the list of functions that are eligible for mini-buffer completion. The function specified by \var{f} must be already defined before this function is called. The S-Lang function \var{is_defined} may be used to test whether or not the function is defined. \seealso{read_with_completion, _add_completion} \done \function{get_mini_response} \synopsis{Prompt for a key} \usage{Int_Type get_mini_response (String_Type str)} \description The \var{get_mini_response} function display the text \var{str} at the bottom of the screen and waits for the user to press a key. The key is returned. \seealso{read_mini, getkey, flush} \done \function{get_y_or_n} \synopsis{Prompt for a y or n response} \usage{Int_Type get_y_or_n (String_Type str)} \description The \var{get_y_or_n} function forms a y/n question by concatenating \exmp{"? (y/n)"} to \var{str} and displays the result at the bottom of the display. It returns \1 if the user responds with \exmp{y}, \0 with \exmp{n}, or \exmp{-1} if the user cancelled the prompt. \seealso{get_yes_no, get_mini_response} \done \function{get_yes_no} \synopsis{Get a yes or no response from the user} \usage{Integer get_yes_no (String s);} \description This function may be used to get a yes or no response from the user. The string parameter \var{s} will be used to construct the prompt by concating the string \exmp{"? (yes/no)"} to \var{s}. It returns \var{1} if the answer is yes or \exmp{0} if the answer is no. \seealso{getkey, flush, message} \done \function{read_mini} \synopsis{Read input from the mini-buffer} \usage{String read_mini (String prompt, String dflt, String init);} \description The \var{read_mini} function reads a line of input from the user in the mini-buffer. The first parameter, \var{prompt}, is used to prompt the user. The second parameter, \var{dflt}, is what is returned as a default value if the user simply presses the return key. The final parameter, \var{init}, is stuffed into the mini-buffer for editing by the user. For example, #v+ define search_whole_buffer () { variable str; str = read_mini ("Search for:", "", ""); !if (strlen (str)) return; !if (fsearch (str)) { push_mark (); bob (); if (fsearch (str)) pop_mark (0); else pop_mark (1); { pop_mark (1); error ("Not found"); } } } #v- reads a string from the user and then searches forward for it and if not found, it resumes the search from the beginning of the buffer. \notes If the user aborts the function \var{mini_read} by pressing the keyboard quit character (e.g., Ctrl-G), an error is signaled. This error can be caught by a \var{try}-\var{catch} statement and the appropriate action taken. Also if the mini-buffer is already in use, this function should not be called. The variable \var{MINIBUFFER_ACTIVE} may be checked to determine if this is the case or not. \seealso{read_with_completion, getkey, input_pending} \seealso{MINIBUFFER_ACTIVE} \done \function{read_with_completion} \synopsis{Read input from the minibuffer (with completion)} \usage{Void read_with_completion (String prt, String dflt, String s, Integer type);} \description This function may be used to read one of the objects specified by the last parameter \var{type}. The first parameter, \var{prt}, is used as a prompt, the second parameter, \var{dflt}, is used to specify a default, and the third parameter, \var{s}, is used to initialize the string to be read. \var{type} is an integer with the following meanings: #v+ 'f' file name 'b' buffer name 'F' function name 'V' variable name. #v- Finally, if \var{type} has the value \exmp{'s'}, then the set of completions will be defined by a zeroth parameter, \var{list}, to the function call. This parameter is simple a comma separated list of completions. For example, #v+ read_with_completion ("Larry,Curly,Moe", "Favorite Stooge:", "Larry", "", 's'); #v- provides completion over the set of three stooges. The function returns the string read. \seealso{read_mini} \done \function{set_expansion_hook} \synopsis{Specify a function to expand a filename upon TAB completion} \usage{Void set_expansion_hook (String fname);} \description This function may be used to specify a function that will be called to expand a filename upon TAB completion. The function \var{fname} must already be defined. When \var{fname} is called, it is given a string to be expanded. If it changes the string, it must return a non-zero value and the modified string. If the string is not modified, it must simply return zero. \done jed-0.99-19/doc/tm/rtl/move.tm0000644002657400265740000002321611311317447014774 0ustar davisdavis\function{Skip past all word characters} \synopsis{bskip_word_chars} \usage{Void bskip_word_chars ()} \description This function moves the current editing point backward past all word characters until a non-word character is encountered. Characters that make up a word are set by the \var{define_word} function. \seealso{define_word, skip_word_chars, bskip_chars, bskip_non_word_chars} \done \function{_get_point} \synopsis{Get the current offset from the beginning of the line} \usage{Int_Type _get_point ()} \description The \var{_get_point} function returns the current character offset fro the beginning of the line. \seealso{_set_point, what_column} \done \function{_set_point} \synopsis{Move to a specified offset from the beginning of the line} \usage{_set_point (Int_Type nth)} \description The \var{_set_point} function moves the current editing position to the \var{nth} character of the current line. \seealso{_get_point, goto_column} \done \function{backward_paragraph} \synopsis{Move backward to a line that is a paragraph separator} \usage{Void backward_paragraph ()} \description This function moves the current editing point backward past the current paragraph to the line that is a paragraph separator. Such a line is determined by the S-Lang hook \var{is_paragraph_separator}. This hook can be modified on a buffer by buffer basis by using the function \var{set_buffer_hook}. \seealso{forward_paragraph, set_buffer_hook} \done \function{bob} \synopsis{Go to the beginning of the buffer} \usage{Void bob ()} \description The function \var{bob} is used to move the current editing point to the beginning of the buffer. The function \var{bobp} may be used to determine if the editing point is at the beginning of the buffer or not. \seealso{bobp, eob, bol, eol} \done \function{bol} \synopsis{Go to the beginning of the line} \usage{Void bol()} \description This function moves the current editing point to the beginning of the current line. The function \var{bolp} may be used to see if one is already at the beginning of a line. \seealso{eol, bob, eob, bolp} \done \function{bskip_chars} \synopsis{Skip past all characters defined by string "str"} \usage{Void bskip_chars (String str)} \description This function may be used to skip past all characters defined by the string \var{str}. See \var{skip_chars} for the definition of \var{str}. The following example illustrates how to skip past all whitespace including newline characters: #v+ bskip_chars (" \t\n"); #v- \seealso{skip_chars, left} \done \function{bskip_non_word_chars} \synopsis{Skip past all non-word characters} \usage{Void bskip_word_chars ()} \description This function moves the current editing point backward past all non-word characters until a word character is encountered. Characters that make up a word are set by the \var{define_word} function. \seealso{define_word, skip_non_word_chars, bskip_chars, bskip_word_chars} \done \function{down} \synopsis{Move the editing point "n" lines down} \usage{Integer down(Integer n)} \description The \var{down} function is used to move the editing point down a number of lines specified by the integer \var{n}. It returns the number of lines actually moved. The number returned will be less than \var{n} only if the last line of the buffer has been reached. The editing point will be left at the beginning of the line if it succeeds in going down more than one line. Example: The function #v+ define trim_buffer { bob (); do { eol (); trim (); } while (down (1)); } #v- removes excess whitespace from the end of every line in the buffer. \seealso{down, left, right, goto_line} \done \function{eob} \synopsis{Move to the end of the buffer} \usage{Void eob()} \description The \var{eob} function is used to move the current point to the end of the buffer. The function \var{eobp} may be used to see if the current position is at the end of the buffer. \seealso{eobp, bob, bol, eol} \done \function{eol} \synopsis{Go to the end of the line} \usage{Void eol()} \description Moves the current position to the end of the current line. The function \var{eolp} may be used to see if one is at the end of a line or not. \seealso{eolp, bol, bob, eob} \done \function{forward_paragraph} \synopsis{Go to the end of the current paragraph} \usage{Void forward_paragraph ()} \description This function moves the current editing point forward past the end of the current paragraph. Paragraph delimiters are defined through either a buffer hook or via the hook \var{is_paragraph_separator}. \seealso{backward_paragraph, set_buffer_hook} \done \function{goto_column} \synopsis{Move to the column "n"} \usage{Void goto_column (Integer n)} \description This function moves the current editing point to the column specified by the parameter \var{n}. It will insert a combination of spaces and tabs if necessary to achieve the goal. Note: The actual character number offset from the beginning of the line depends upon tab settings and the visual expansion of other control characters. \seealso{goto_column_best_try, what_column, left, right, goto_line} \seealso{TAB,TAB_DEFAULT,DISPLAY_EIGHT_BIT} \done \function{goto_column_best_try} \synopsis{like "goto_column" but don't insert whitespace} \usage{Integer goto_column_best_try (Integer c)} \description This function is like \var{goto_column} except that it will not insert whitespace. This means that it may fail to achieve the column number specified by the argument \var{c}. It returns the current column number. \seealso{goto_column, what_column} \done \function{goto_line} \synopsis{Go to line number "n"} \usage{Void goto_line (Integer n)} \description The \var{goto_line} function may be used to move to a specific line number specified by the parameter \var{n}. Note: The actual column that the editing point will be left in is indeterminate. \seealso{what_line, goto_column, down, up.} \done \function{left} \synopsis{Move the editing point backward "n" characters} \usage{Integer left(Integer n)} \description \var{left} moves the editing point backward \var{n} characters and returns the number actually moved. The number returned will be less than \var{n} only if the top of the buffer is reached. \seealso{right, up, down, bol, bob} \done \function{right} \synopsis{Move the editing position forward forward "n" characters} \usage{Integer right(Integer n)} \description This function moves the editing position forward forward \var{n} characters. It returns the number of characters actually moved. The number returned will be smaller than \var{n} if the end of the buffer is reached. \seealso{left, up, down, eol, eob} \done \function{skip_chars} \synopsis{Go forward past all characters defined by "s"} \usage{Void skip_chars(String s)} \description This fnction may be used to move the editing point forward past all characters in string \var{s} which contains the chars to skip, or a range of characters. A character range is denoted by two charcters separated by a hyphen. If the first character of the string \var{s} is a \exmp{'^'} character, then the list of characters actually denotes the complement of the set of characters to be skipped. To explicitly include the hyphen character in the list, it must be either the first or the second character of the string, depending upon whether or not the \exmp{'^'} character is present. So for example, #v+ skip_chars ("- \t0-9ai-o_"); #v- will skip the hyphen, space, tab, numerals \exmp{0} to \var{9}, the letter \var{a}, the letters \var{i} to \var{o}, and underscore. An example which illustrates the complement of a range is #v+ skip_chars("^A-Za-z"); #v- which skips all characters except the letters. Note: The backslash character may be used to escape only the first character in the string. That is, \exmp{"\\\\^"} is to be used to skip over \exmp{^} characters. \seealso{bskip_chars, skip_white} \done \function{skip_non_word_chars} \synopsis{Go forward until a word character is encountered} \usage{Void skip_non_word_chars ()} \description This function moves the current editing point forward past all non-word characters until a word character is encountered. Characters that make up a word are set by the \var{define_word} function. \seealso{define_word, skip_word_chars, skip_chars, bskip_non_word_chars} \done \function{skip_white} \synopsis{Go forward until a non-whitespace character or the end of the line} \usage{Void skip_white ()} \description The \var{skip_white} function moves the current point forward until it reaches a non-whitespace character or the end of the current line, whichever happens first. In this context, whitespace is considered to be any combination of space and tab characters. To skip newline characters as well, the function \var{skip_chars} may be used. \seealso{bskip_chars, what_char, trim, right} \done \function{skip_word_chars} \synopsis{Go forward until a non-word character is encountered} \usage{Void skip_word_chars ()} \description This function moves the current editing point forward across all characters that constitute a word until a non-word character is encountered. Characters that make up a word are set by the \var{define_word} function. \seealso{define_word, skip_non_word_chars, skip_chars, bskip_word_chars} \done \function{up} \synopsis{Go up "n" lines} \usage{Integer up(Integer n)} \description This function moves the current point up \var{n} lines and returns the number of lines actually moved. The number returned will be less than \var{n} only if the top of the buffer is reached. \seealso{down, left, right} \done jed-0.99-19/doc/tm/rtl/color.tm0000644002657400265740000001407311311317447015145 0ustar davisdavis\function{add_color_object} \synopsis{Return the object number associated with "obj"} \usage{add_color_object (String_Type name)} \description This function creates a new color object with a specified name. See the \var{set_color} documentation for pre-defined color objects. \seealso{set_color, get_color, color_number} \done \function{color_number} \synopsis{Return the object number associated with "obj"} \usage{Integer color_number (String obj)} \description This function returns the object number associated with the string \var{obj}. Valid names for \var{obj} are as per \var{set_color}. \seealso{set_color, set_column_colors} \seealso{WANT_SYNTAX_HIGHLIGHT, USE_ANSI_COLORS} \done \function{get_color} \synopsis{Return the foreground and background color of an object} \usage{(String_Type fg, String_Type bg) = get_color (String_Type name)} \description This function returns the foreground and background colors of the specified color object. \seealso{set_color, color_number, add_color_object} \done \function{set_color} \synopsis{Set fore- and background colors of an object} \usage{set_color (String_Type obj, String_Type fg, String_Type bg)} \description This function sets the foreground and background colors of an object specified by the string \var{obj} to \var{fg} and \var{bg}. The exact values of the strings \var{fg} and \var{bg} are system dependent. For the X-Window system, they can be any string that the server understands, e.g., \var{"SteelBlue"}. For other systems, the color must be one of the following: #v+ "black" "gray" "red" "brightred" "green" "brightgreen" "brown" "yellow" "blue" "brightblue" "magenta" "brightmagenta" "cyan" "brightcyan" "lightgray" "white" "default" #v- One most terminals, the values in the second column have no affect when used as the background color. Using "default" as a foreground or background color instructs the editor to tell the terminal to use the default foreground and background colors of the window. If you use a terminal that uses a transparant background, then you need to specify "default" as the background color. Not all terminals support the notion of the "default" color. The valid names for \var{obj} are: #v+ "normal" Default foreground/background "status" The status window line "region" Highlighted Regions "cursor" Text Cursor (X-Windows) "cursorovr" Text Cursor in overwrite mode (X-Windows) "menu" The menu bar "error" Error messages "message" Other messages "dollar" Color of the indicator that text extends beyond the boundary of the window. "linenum" Line number field #v- If color syntax highlighting is enabled, the following object names are also meaningful: #v+ "number" Numbers in C-mode and Equations in TeX-mode "delimiter" Commas, semi-colons, etc... "keyword" Language dependent "keyword1" Language dependent "keyword2" Language dependent "keyword3" Language dependent "keyword4" Language dependent "keyword5" Language dependent "keyword6" Language dependent "keyword7" Language dependent "keyword8" Language dependent "keyword9" Language dependent "string" Literal strings "comment" Comments "operator" Such as +, -, etc... "preprocess" Preprocessor lines "tab" "trailing_whitespace" "html" and '<' syntax objects. #v- If line attributes are available, then you may also specifiy the color of the hidden line indicator: #v+ "..." Hidden line indicator #v- The color of the menu objects may be specified via #v+ "menu_char" Menu item key-shortcut color "menu_shadow" Color of the shadow "menu_selection" Selected menu-item color "menu_popup" Color of the popup box "menu_selection_char" Selected menu item key-shortcut color #v- Xjed defines the following objects: #v+ "mouse" Mouse cursor color "border" Window borde color #v- \seealso{define_syntax, set_color_esc, set_column_colors, set_color_object} \seealso{WANT_SYNTAX_HIGHLIGHT, USE_ANSI_COLORS} \done \function{set_color_esc} \synopsis{associate an escape sequence with an object} \usage{Void set_color_esc (String object, String esc_seq)} \description This function may be used to associate an escape sequence with an object. The escape sequence will be sent to the terminal prior to sending updating the object. It may be used on mono terminals to underline objects, etc... The object names are the same names used by the \var{set_color} function. Note: Care should be exercised when using this function. Also, one may need to experiment around a little to get escape sequences that work together. \seealso{set_color} \done \function{set_color_object} \synopsis{Associate colors "fg" and "bg" with object "obj"} \usage{Void set_color_object (Integer obj, String fg, String bg)} \description Associate colors \var{fg} and \var{bg} with object \var{obj}. Valid values for \var{obj} are in the range 30 to 128. All other values are reserved. Values for the strings \var{fg} and \var{bg} are as given by the description for \var{set_color}. \seealso{set_column_colors, set_color} \done \function{set_column_colors} \synopsis{Associate a color with columns \var{c0} through \var{c1}} \usage{Void set_column_colors (Integer color, Integer c0, Integer c1)} \description This function associates a color with columns \exmp{c0} through \var{c1} in the current buffer. That is, if there is no syntax highlighting already defined for the current buffer, when the current buffer is displayed, columns \exmp{c0} through \var{c1} will be displayed with the attributes of the \var{color} object. The parameters \exmp{c0} and \var{c1} are restricted to the range 1 through \var{SCREEN_WIDTH}. Use the function \var{set_color_object} to assign attributes to the \var{color} object. \seealso{set_color_object} \done jed-0.99-19/doc/tm/rtl/message.tm0000644002657400265740000000350711311317447015453 0ustar davisdavis\variable{MESSAGE_BUFFER} \synopsis{The Contents of the Message Buffer} \usage{String_Type MESSAGE_BUFFER} \description The \var{MESSAGE_BUFFER} variable is a read-only string variable whose value indicates the text to be displayed or is currently displayed in the message buffer. \seealso{message, vmessage, error, verror} \done \function{beep} \synopsis{Beep (according to the value of \var{IGNORE_BEEP})} \usage{Void beep ();} \description The \var{beep} function causes the terminal to beep according to the value of the variable \var{IGNORE_BEEP}. \seealso{tt_send} \seealso{IGNORE_BEEP} \done \function{clear_message} \synopsis{Clear the message line of the display} \usage{Void clear_message ();} \description This function may be used to clear the message line of the display. \seealso{message, update, error, flush} \done \function{flush} \synopsis{Immediately display "msg" as a message in the mini-buffer} \usage{Void flush (String msg);} \description The \var{flush} function behaves like \var{message} except that it immediately displays its argument \var{msg} as a message in the mini-buffer. That is, it is not necessary to call \var{update} to see the message appear. \seealso{message, error} \done \function{tt_send} \synopsis{Send "s" directly to the terminal} \usage{Void tt_send (String s);} \description This function may be used to send a string specified by \var{s} directly to the terminal with no interference by the editor. One should exercise caution when using this routine since it may interfere with JED's screen management routines forcing one to redraw the screen. Nevertheless, it can serve a useful purpose. For example, when run in an XTerm window, using #v+ tt_send ("\e[?9h"); #v- will enable sending mouse click information to JED encoded as keypresses. \seealso{beep} \done jed-0.99-19/doc/tm/rtl/mark.tm0000644002657400265740000001376211311317447014765 0ustar davisdavis\function{create_line_mark} \synopsis{Return a line mark (of the type User_Mark)} \usage{User_Mark create_line_mark (Integer c)} \description The function \var{create_line_mark} returns an object of the type \var{User_Mark}. This object contains information regarding the current position and current buffer. The parameter \var{c} is used to specify the color to use when the line is displayed. \seealso{create_user_mark, set_color_object} \done \function{create_user_mark} \synopsis{Return an object of the type User_Mark} \usage{User_Mark create_user_mark ()} \description The function \var{create_user_mark} returns an object of the type \var{User_Mark}. This object contains information regarding the current position and current buffer. \seealso{move_user_mark, goto_user_mark, user_mark_buffer} \done \function{dupmark} \synopsis{Duplicate the mark (if set), return success} \usage{Integer dupmark ()} \description This function returns zero if the mark is not set or, if the mark is set, a duplicate of it is pushed onto the mark stack and a non-zero value is returned. \seealso{push_mark, markp, pop_mark} \done \function{goto_user_mark} \synopsis{Return to the position of the User Mark "mark"} \usage{Void goto_user_mark (User_Mark mark)} \description This function returns to the position of the User Mark \var{mark}. Before this function may be called, the current buffer must be the buffer associated with the makr. \seealso{move_user_mark, create_user_mark, user_mark_buffer} \done \function{is_user_mark_in_narrow} \synopsis{Test if the user mark "m" is within the narrowed buffer.} \usage{Integer is_user_mark_in_narrow (User_Mark m)} \description This function returns non-zero if the user mark \var{m} refers to a position that is within the current narrow restriction of the current buffer. It returns zero if the mark lies outside the restriction. An error will be generated if \var{m} does not represent a mark for the current buffer. \seealso{goto_user_mark, move_user_mark} \done \function{is_visible_mark} \synopsis{Test if the mark is a visible mark} \usage{is_visible_mark ()} \description This function may be used to test whether or not the mark is a visible mark. A visible mar is one which causes the region defined by it to be highlighted. It returns \var{1} is the mark is visible, or \exmp{0} if the mark is not visible or does not exist. \seealso{markp, push_mark} \done \function{markp} \synopsis{Test if a mark is set} \usage{Void markp ()} \description This function returns a non-zero value if the mark is set; otherwise, it returns zero. If a mark is set, a region is defined. \seealso{push_mark, pop_mark, check_region, push_spot} \done \function{move_user_mark} \synopsis{Move the User Mark "mark" to the current position} \usage{Void move_user_mark (User_Mark mark)} \description This function call takes a previously created User Mark, \var{mark}, and moves it to the current position and buffer. This means that if one subsequently calls \var{goto_user_mark} with this mark as an argument, the the position will be set to the new position. Note: This function call is not equivalent to simply using #v+ mark = create_user_mark (); #v- because independent copies of a User Mark are not created upon assignment. That is, if one has #v+ variable mark1, mark2; setbuf ("first"); mark1 = create_user_mark (); mark2 = mark1; setbuf ("second"); #v- and then calls #v+ move_user_mark (mark1); #v- both user marks, \var{mark1} and \var{mark2} will be moved since they refer to the same mark. \seealso{goto_user_mark, create_user_mark, user_mark_buffer} \done \function{pop_mark} \synopsis{Pop the most recent mark (if "g" is non-zero, go there} \usage{pop_mark (Integer g)} \description \var{pop_mark} pops the most recent mark pushed onto the mark stack. If the argument \var{g} is non-zero, the editing position will be moved to the location of the mark. However, if \var{g} is zero, the editing position will be unchanged. \seealso{push_mark, pop_spot, markp, check_region, goto_user_mark} \done \function{pop_spot} \synopsis{Pop the last spot (and go there)} \usage{Void pop_spot ()} \description This function is used after a call to \var{push_spot} to return to the editing position at the last call to \var{push_spot} in the current buffer. \seealso{push_spot, pop_mark} \done \function{push_mark} \synopsis{Mark the current position as the beginning of a region} \usage{Void push_mark()} \description This function marks the current position as the beginning of a region. and pushes other marks onto a stack. A region is defined by this mark and the editing point. The mark is removed from the stack only when the function \var{pop_mark} is called. For example, #v+ define mark_buffer () { bob (); push_mark (); eob (); } #v- marks the entire buffer as a region. \seealso{pop_mark, push_spot, markp, dupmark, check_region} \done \function{push_spot} \synopsis{Push the current buffer location onto a stack} \usage{Void push_spot ()} \description \var{push_spot} pushes the location of the current buffer location onto a stack. This function does not set the mark. The function \var{push_mark} should be used for that purpose. The spot can be returned to using the function \var{pop_spot}. Note: Spots are local to each buffer. It is not possible to call \var{push_spot} from one buffer and then subsequently call \var{pop_spot} from another buffer to return to the position in the first buffer. For this purpose, one must use user marks instead. \seealso{pop_spot, push_mark, create_user_mark} \done \function{user_mark_buffer} \synopsis{Return the name of the buffer with User Mark "m"} \usage{String user_mark_buffer (User_Mark m)} \description This function returns the name of the buffer associated with the User Mark specified by \var{m}. \seealso{goto_user_mark, create_user_mark, move_user_mark, is_user_mark_in_narrow} \done jed-0.99-19/doc/tm/rtl/xjed.tm0000644002657400265740000001022611311317447014755 0ustar davisdavis\function{x_copy_region_to_cutbuffer} \synopsis{Copy the region to the X cutbuffer} \usage{x_copy_region_to_cutbuffer ()} \description places a copy of the region to the X cutbuffer for insertion in other X-window programs. In wjed the region is copies to the clipboard. \seealso{x_copy_region_to_selection} \done \function{x_copy_region_to_selection} \synopsis{Copy the region to the X selection} \usage{x_copy_region_to_selection ()} \description places a copy of the region to the X selection for insertion in other X-window programs. This function is only available in xjed. \seealso{x_copy_region_to_cutbuffer} \done \function{x_insert_cutbuffer} \synopsis{Insert the content of the X cutbuffer} \usage{Int_Type x_insert_cutbuffer ()} \description Inserts cutbuffer (in wjed the clipboard) into the current buffer and returns the number of characters inserted. \seealso{} \done \function{x_insert_selection} \synopsis{Insert data from the X selection owner} \usage{Int_Type x_insert_selection ()} \description This function only requests selection data from the selection owner. If Xjed received EVENT, Xjed inserts selection data into the current buffer and returns the number of characters inserted. \seealso{} \done \function{x_server_vendor} \synopsis{Return the vendor name of the X server} \usage{String_Type x_server_vendor ()} \description This function returns the vendor name of the X server. \seealso{} \done \function{x_set_icon_name} \synopsis{Set the icon do display in X windows (xjed only)} \usage{x_set_icon_name (String_Type name)} \description \seealso{} \done \function{x_set_keysym} \synopsis{Associate a string with a key} \usage{x_set_keysym (Int_Type keysym, Int_Type shift, String_Type str)} \description This function may be used to assocate a string \exmp{str} with a key \exmp{keysym} modified by mask \exmp{shift}. Pressing the key associated with \exmp{keysym} will then generate the keysequence given by \exmp{str}. The function keys are mapped to integers in the range \exmp{0xFF00} to \exmp{0xFFFF}. On most systems, the keys that these mappings refer to are located in the file \exmp{/usr/include/X11/keysymdef.h}. For example, on my system, the keysyms for the function keys \exmp{XK_F1} to \exmp{XK_F35} fall in the range \exmp{0xFFBE} to \exmp{0xFFE0}. So to make the \exmp{F1} key correspond to the string given by the two characters \exmp{Ctrl-X} \exmp{Ctrl-C}, simply use: #v+ x_set_keysym (0xFFBE, 0, "^X^C"); #v- The \exmp{shift} argument is an integer with the following meanings: #v+ 0 : unmodified key '$' : shifted '^' : control #v- Any other value for shift will default to 0 (unshifted). \seealso{x_set_meta_keys} \done \function{x_set_meta_keys} \synopsis{Specify which modifier keys are to be interpreteted as meta keys} \usage{x_set_meta_keys (Int_Type mod_mask)} \description The \var{x_set_meta_keys} function allows the user to specify which modifier keys are to be interpreteted as meta keys. The parameter \var{mod_mask} is a bitmapped value whose bits correspond to a modifier mask: #v+ 0: Mod1Mask 1: Mod2Mask 2: Mod3Mask 3: Mod4Mask 4: Mod5Mask #v- \example #v+ x_set_meta_keys ((1<<0) | (1<<3)); #v- specifies that meta keys are to be associated with Mod1Mask and Mod4Mask. \seealso{x_set_keysym} \done \function{x_toggle_visibility} \synopsis{Shows or hides the window} \usage{x_toggle_visibility([Integer_Type hide])} \description Makes the window visible or invisible. If the argument \exmp{hide} is not given, the visility of the windows is toggled, e.g. if the window is invisible it becomes visible and vice versa. If the optional argument \exmp{hide} is given the state to the window becomes visible if \exmp{hide} is non-zero or invisible if \exmp{hide} is zero, independent of the current state. \notes You can also hide the window by calling \ifun{suspend}, but you can not show it, if the window doesn't have the focus. \seealso{suspend} \done \function{x_set_window_name} \synopsis{Set the title of the xjed window} \usage{x_set_window_name (String_Type name)} \done \function{x_warp_pointer} \synopsis{warp pointer} \usage{} \description \done jed-0.99-19/doc/tm/rtl/hooks.tm0000644002657400265740000001366711311317447015162 0ustar davisdavis\function{add_to_hook} \synopsis{Add a function to a hook (as first one)} \usage{add_to_hook (String_Type hook_name, Ref_Type funct)} \description \var{add_to_hook} adds the function \var{funct} to the beginnning of the list of hooks associated with \var{hook_name}. The currently supported hooks include: #v+ _jed_append_region_hooks _jed_exit_hooks _jed_find_file_after_hooks _jed_find_file_before_hooks _jed_init_display_hooks _jed_insert_file_hooks _jed_quit_hooks _jed_read_file_hooks _jed_reset_display_hooks _jed_resume_hooks _jed_save_buffer_after_hooks _jed_save_buffer_before_hooks _jed_set_mode_hooks _jed_switch_active_buffer_hooks _jed_suspend_hooks _jed_write_region_hooks #v- See the file \var{hooks.txt} in the main \jed distribution for more information. \seealso{append_to_hook, remove_from_hook} \done \function{append_to_hook} \synopsis{Append a function to a hook} \usage{append_to_hook (String_Type hook_name, Ref_Type funct)} \description \var{append_to_hook} adds the function \var{funct} to the end of the list of hooks associated with \var{hook_name}. See \var{add_to_hook} for more information. \seealso{add_to_hook, remove_from_hook} \done \function{remove_from_hook} \synopsis{Remove a function from a list of hooks} \usage{remove_from_hook (String_Type hook_name, Ref_Type funct)} \description \var{remove_from_hook} removes the function \var{funct} from the list of hooks associated with \var{hook_name}. \seealso{add_to_hook, append_to_hook} \done \function{_jed_run_hooks} \synopsis{Execute the functions in a hook chain} \usage{_jed_run_hooks (String_Type hook_name, Integer_Type mode [,Array_Type args])} \description \ifun{_jed_run_hooks} executes the functions registered for \var{hook_name}. The argument \exmp{mode} defines which functions are called: #v+ JED_HOOKS_RUN_ALL all functions; no function should return a value. JED_HOOKS_RUN_UNTIL_0 Run until a function returns the value 0; every function must return an integer value. JED_HOOKS_RUN_UNTIL_NON_0 Run until a function returns a non-zero value; every function must return an integer value. #v- If the third argument is given, then it must be an array of strings to be passed as arguments to the the hook-functions. \seealso{append_to_hook, add_to_hook} \done \function{get_buffer_hook} \synopsis{Get the value of a specified buffer hook} \usage{Ref_Type get_buffer_hook (String_Type hook_name)} \description The \ifun{get_buffer_hook} function returns the value of the specified hook name as a function reference. If no hook was defined or the hook does not exist, then \NULL will be returned. See the documentation for \ifun{set_buffer_hook} for a list of hook-names. \example #v+ % temporarily unset the indent hook fun = get_buffer_hook ("indent_hook"); unset_buffer_hook ("indent_hook"); . . % restore the indent hook if (fun != NULL) set_buffer_hook ("indent_hook", fun); #v- \seealso{set_buffer_hook, unset_buffer_hook} \done \function{set_buffer_hook} \synopsis{Set a specified buffer hook} \usage{set_buffer_hook (String_Type hook_name, Ref_Type func)} \description This function sets the specified hook for the current buffer to the function \exmp{func}. The value of \exmp{func} may either be a string or a function reference (e.g., \exmp{&my_hook}). The use of a function reference is preferred since that allows hooks to be static or private functions. Currently supported hooks include: #v+ "par_sep" -- returns zero if the current line does not constitute the beginning or end of a paragraph. It returns non-zero otherwise. The default value of hook is is_paragraph_separator. "indent_hook" -- returns nothing. It is called by the indent line routines. "wrap_hook" hook that is called after a line is wrapped. Returns nothing. "wrapok_hook" hook that is called prior to wrapping a line. If it returns non-zero, the line will be wrapped, otherwise the line will not be wrapped. "newline_indent_hook" --- returns nothing. If this hook is defined, it will be called instead of the internal function newline_and_indent is called. "bob_eob_error_hook" --- returns nothing. If this hook is defined, it will be called whenever an error one of the internal cursor movement functions would have generated an end of buffer or beginning of buffer error. It is passed an integer that indicates which function would have generated the error. Specifically: -1 previous_line_cmd -2 previous_char_cmd -3 page_up 1 next_line_cmd 2 next_char_cmd 3 page_down "mouse_down", "mouse_up", "mouse_drag" "mouse_2click" "mouse_3click" These hooks are used to override default hooks defined by the mouse_set_default_hook function. "mark_paragraph_hook" This hook hook is called by the format_paragraph function to mark a paragraph. "forward_paragraph_hook", "backward_paragraph_hook" "format_paragraph_hook" #v- See the file jed/doc/hooks.txt for more information and examples. \seealso{unset_buffer_hook, mouse_set_default_hook, get_buffer_hook} \done \function{unset_buffer_hook} \synopsis{Remove a buffer hook} \usage{unset_buffer_hook (String_Type name)} \description The \ifun{unset_buffer_hook} function removes a specified buffer hook from the current buffer. If \exmp{name} is the empty string, then all the buffer hooks of the current buffer will be unset. See the documentation for \ifun{set_buffer_hook} for a list of hook-names. \seealso{set_buffer_hook, get_buffer_hook} \done jed-0.99-19/doc/tm/rtl/region.tm0000644002657400265740000002205711311317447015313 0ustar davisdavis\variable{KILL_ARRAY_SIZE} \synopsis{The size of the internal kill buffer array} \usage{Int_Type KILL_ARRAY_SIZE} \description This variable contains the value of the size of the internal kill array of character strings. Any number from zero up to but not including the value of \var{KILL_ARRAY_SIZE} may be used as an argument in the functions that manipulate this array. \notes This variable is a read-only varaible and may not available on 16 bit systems. \seealso{insert_from_kill_array, copy_region_to_kill_array, append_region_to_kill_array} \done \function{append_region_to_file} \synopsis{Append the region to "file"} \usage{Integer append_region_to_file (String file)} \description Appends a marked region to \var{file} returning number of lines written or \-1 on error. This does NOT modify a buffer visiting the file; however, it does flag the buffer as being changed on disk. \done \function{append_region_to_kill_array} \synopsis{Append the region to the element "n" of the kill array} \usage{Void append_region_to_kill_array (Integer n)} \description This function appends the currently defined region to the contents of nth element, specified by \var{n}, of an internal array of character strings. Note: This function is not available on 16 bit systems. \seealso{insert_from_kill_array, copy_region_to_kill_array} \seealso{KILL_ARRAY_SIZE} \done \function{bufsubstr} \synopsis{Return the region as a string} \usage{String bufsubstr ()} \description This function returns a string that contains the characters in the region specified by a mark and the current editing point. If the region crosses lines, the string will contain newline characters. \seealso{insbuf, push_mark} \done \function{check_region} \synopsis{Test if a region is defined and ensure the mark comes before point} \usage{Void check_region (Integer ps)} \description This function checks to see if a region is defined and may exchange the current editing point and the mark to define a canonical region. If the mark is not set, it signals an S-Lang error. A canonical region is one with the mark set earlier in the buffer than than the editing point. Always call this if using a region which requires such a situation. If the argument \var{ps} is non-zero, \var{push_spot} will be called, otherwise, \var{ps} is zero and it will not be called. As an example, the following function counts the number of lines in a region: #v+ define count_lines_region () { variable n; check_region (1); % spot pushed narrow (); n = what_line (); widen (); pop_spot (); return n; } #v- \seealso{markp, push_mark} \done \function{copy_region} \synopsis{copy a region to the buffer "buf"} \usage{Void copy_region (String buf)} \description This function may be used to copy a region defined by a mark and the current position to the buffered specified by the name \var{buf}. It does not delete the characters in region but it does pop the mark that determines the region. \seealso{insbuf, bufsubstr, push_mark, pop_mark, bufferp} \done \function{copy_region_to_kill_array} \synopsis{Copy the defined region to element "n" of the kill array} \usage{Void copy_region_to_kill_array (Integer n)} \description This function copies the currently defined region to the nth element, specified by \var{n}, of an internal array of character strings replacing what is currently there. Note: This function is not available on 16 bit systems. \seealso{insert_from_kill_array, append_region_kill_array} \seealso{KILL_ARRAY_SIZE} \done \function{count_narrows} \synopsis{Return the narrow depth of the current buffer} \usage{Integer count_narrows ()} \description This function returns the narrow depth of the current buffer. \seealso{narrow, widen, widen_buffer, push_narrow} \done \function{narrow} \synopsis{Restict editing to the region (complete lines)} \usage{Void narrow ()} \description This function may be used to restict editing to the region of lines between the mark and the editing point. The region includes the line containing the mark as well as the line at the current point. All other lines outside this region are completely inacessable without first lifting the restriction using the \var{widen} function. As a simple example, suppose that there is a function called \var{print_buffer} that operates on the entire buffer. Then the following function will work on a region of lines: #v+ define print_region () { narrow (); print_buffer (); widen (); } #v- The \var{narrow} function will signal an error if the mark is not set. Note also that the narrow function may be used recursively in the sense that a narrowed region may be further restricted using the \var{narrow} function. For each narrow, the \var{widen} function must be called to lift each restriction. \seealso{widen, narrow_to_region} \done \function{narrow_to_region} \synopsis{Restict editing exactly to the region} \usage{Void narrow_to_region (void)} \description The \var{narrow_to_region} function behaves like the \var{narrow} function that \var{narrow} operates on lines and \var{narrow_to_region} restricts editing to only characters within the region. \seealso{widen_region, narrow.} \done \function{pipe_region} \synopsis{Execute "cmd" as subprocess and sends the region to its stdin} \usage{Integer pipe_region (String cmd)} \description The \var{pipe_region} function executes \var{cmd} in a separate process and sends the region of characters defined by the mark and the current point to the standard input of the process. It successful, it returns the exit status of the process. Upon failure it signals an error. Note: This function is only available for Unix and OS/2 systems. \seealso{run_shell_cmd, push_mark} \done \function{pop_narrow} \synopsis{restore the last narrow context} \usage{Void pop_narrow ()} \description The purpose of this function is to restore the last narrow context that was saved via \var{push_narrow}. \seealso{push_narrow, widen, widen_buffer} \done \function{push_narrow} \synopsis{Save the current narrow context} \usage{Void push_narrow ()} \description This function saves the current narrow context. This is useful when one wants to restore this context after widening the buffer. \seealso{pop_narrow, narrow, widen, widen_buffer} \done \function{translate_region} \synopsis{translate the characters in the region according to "a"} \usage{Void translate_region (String_Type[256] a)} \description This function uses the 256 element array of strings to translate the characters in a region based on the mapping defined by the array. If an array element is \var{NULL}, then the corresponding character will not be replaced. The \var{translate_region} function leaves the editing point at the end of the region. \example #v+ variable a = String_Type[256]; a['&'] = "&"; a['<'] = "<"; a['>'] = ">"; a['$'] = "$"; bob (); push_mark (); eob (); translate_region (a); #v- uses \var{translate_region} to replace the characters \var{'&'}, \var{'<'}, \var{'>'}, and \var{'$'} by the strings \exmp{"&"}, \exmp{"<"}, \exmp{">"}, and \exmp{"$"}, respectively. \seealso{insert, delete, what_char, replace} \done \function{widen} \synopsis{Undo the effect of "narrow"} \usage{Void widen ()} \description This function undoes the effect of \var{narrow}. Consult the documentation for \var{narrow} for more information. \seealso{widen_region, narrow} \done \function{widen_buffer} \synopsis{Widen the whole buffer} \usage{Void widen_buffer ()} \description This function widens the whole buffer. If one intends to restore the narrow context after calling this function, the narrow context should be saved via \var{push_narrow}. \seealso{narrow, widen, push_narrow, pop_narrow} \done \function{widen_region} \synopsis{Undo the effect of "narrow_to_region"} \usage{Void widen_region ()} \description This function undoes the effect of \var{narrow_to_region}. Consult the documentation for \var{narrow_to_region} for more information. \seealso{widen, narrow_to_region} \done \function{write_region_to_file} \synopsis{Write the region to the file "filename"} \usage{Integer write_region_to_file (String filename)} \description This function may be used to write a region of the current buffer to the file specified by \var{filename}. It returns the number of lines written to the file or signals an error upon failure. \seealso{write_buffer, append_region_to_file, push_mark} \done \function{xform_region} \synopsis{Change the characters in the region according to "how"} \usage{Void xform_region (Integer how)} \description This function changes the characters in the region in a way specified by the parameter \var{how}. This is an integer that can be any of of the following: #v+ 'u' Upcase_region 'd' Downcase_region 'c' Capitalize region #v- Anything else will change case of region. \seealso{translate_region, define_case} \done jed-0.99-19/doc/tm/rtl/search.tm0000644002657400265740000002742411311317447015300 0ustar davisdavis\variable{CASE_SEARCH} \synopsis{Control the case-sensitivity for searches in the current buffer} \usage{Int_Type CASE_SEARCH} \description If the value of \var{CASE_SEARCH} is non-zero, text searches performed in the current buffer will be case-sensitive, otherwise case-insensitive searches will be performed. The value of this variable may vary from buffer to buffer. \seealso{CASE_SEARCH_DEFAULT, fsearch, ffind} \done \variable{CASE_SEARCH_DEFAULT} \synopsis{The default CASE_SEARCH setting for newly created buffers} \usage{Int_Type CASE_SEARCH_DEFAULT} \description Searches in a buffer are performed according to the value of the \var{CASE_SEARCH} variable. Newly created buffers are given a \var{CASE_SEARCH} value of \var{CASE_SEARCH_DEFAULT}. The default value of \var{CASE_SEARCH_DEFAULT} is 0. \seealso{CASE_SEARCH, fsearch, ffind} \done \function{bfind} \synopsis{Search backward to the beginning of the line} \usage{Integer bfind (String str)} \description \var{bfind} searches backward from the current position to the beginning of the line for the string \var{str}. If a match is found, the length of \var{str} is returned and the current point is moved to the start of the match. If no match is found, zero is returned. Note: This function respects the setting of the \var{CASE_SEARCH} variable. \seealso{bsearch, ffind, bol_bsearch, re_bsearch} \seealso{CASE_SEARCH} \done \function{bfind_char} \synopsis{Search backward on the current line for a character} \usage{Integer fsearch_char (Integer ch)} \description This function searches backward on the current line for a character \var{ch}. If it is found, \var{1} is returned; otherwise \exmp{0} is returned. \seealso{fsearch_char, ffind_char, fsearch} \seealso{CASE_SEARCH} \done \function{bol_bsearch} \synopsis{Search backward for "str" at the beginning of a line} \usage{Integer bol_bsearch (str)} \description \var{bol_bsearch} searches backward from the current point until the beginning of the buffer for the occurrences of the string \var{str} at the beginning of a line. If a match is found, the length of \var{str} is returned and the current point is moved to the start of the match. If no match is found, zero is returned. Note: \var{bol_bsearch} is much faster than using \var{re_bsearch} to perform a search that matches the beginning of a line. \seealso{bol_fsearch, bsearch, bfind, re_bsearch} \seealso{CASE_SEARCH} \done \function{bol_bsearch_char} \synopsis{Search backward for character "ch" at the beginning of a line} \usage{Integer bol_fsearch_char (Integer ch)} \description This function searches backward for a character \var{ch} at the beginning of a line. If it is found, \var{1} is returned; otherwise \exmp{0} is returned. \seealso{bol_bsearch, bol_fsearch_char, bsearch_char} \seealso{CASE_SEARCH} \done \function{bol_fsearch} \synopsis{Search forward for "str" at the beginning of a line} \usage{Integer bol_fsearch (str)} \description \var{bol_fsearch} searches forward from the current point until the end of the buffer for occurrences of the string \var{str} at the beginning of a line. If a match is found, the length of \var{str} is returned and the current point is moved to the start of the match. If no match is found, zero is returned. Note: \var{bol_fsearch} is much faster than using \var{re_fsearch} to perform a search that matches the beginning of a line. \seealso{bol_bsearch, fsearch, ffind, re_fsearch} \seealso{CASE_SEARCH} \done \function{bol_fsearch_char} \synopsis{Search forward for character "ch" at the beginning of a line} \usage{Integer bol_fsearch_char (Integer ch)} \description This function searches forward for a character \var{ch} at the beginning of a line. If it is found, \var{1} is returned; otherwise \exmp{0} is returned. \seealso{bol_fsearch, bol_bsearch_char, fsearch_char} \seealso{CASE_SEARCH} \done \function{bsearch} \synopsis{Search backward for "str"} \usage{Integer bsearch (String str)} \description The \var{bsearch} function searches backward from the current position for the string \var{str}. If \var{str} is found, this function will return the length of \var{str} and move the current position to the beginning of the matched text. If a match is not found, zero will be returned and the position will not change. It respects the value of the variable \var{CASE_SEARCH}. \seealso{fsearch, bol_bsearch, re_bsearch} \done \function{bsearch_char} \synopsis{Search backward for a character} \usage{Integer bsearch_char (Integer ch)} \description This function searches backward for a character \var{ch}. If it is found, \var{1} is returned; otherwise \exmp{0} is returned. \seealso{fsearch_char, ffind_char, fsearch} \seealso{CASE_SEARCH} \done \function{ffind} \synopsis{Search forward to the end of the line for the string "str"} \usage{Integer ffind (String s)} \description \var{ffind} searches forward from the current position to the end of the line for the string \var{str}. If a match is found, the length of \var{str} is returned and the current point is moved to the start of the match. If no match is found, zero is returned. Note: This function respects the setting of the \var{CASE_SEARCH} variable. To perform a search that includes multiple lines, use the \var{fsearch} function. \seealso{fsearch, bfind, re_fsearch, bol_fsearch} \done \function{ffind_char} \synopsis{Search forward on the current line for character "ch"} \usage{Integer ffind_char (Integer ch)} \description This function searches forward on the current line for the character \var{ch}. If it is found, \var{1} is returned; otherwise \exmp{0} is returned. \seealso{fsearch_char, bfind_char, fsearch} \seealso{CASE_SEARCH} \done \function{find_matching_delimiter} \synopsis{Look for the delimiter that matches "ch"} \usage{Integer find_matching_delimiter (Integer ch)} \description This function scans either forward or backward looking for the delimiter that matches the character specified by \var{ch}. The actual direction depends upon the syntax of the character \var{ch}. The matching delimiter pair must be declared as such by a prior call to \var{define_syntax}. This function returns one of the following values: #v+ 1 Match found 0 Match not found -1 A match was attempted from within a string. -2 A match was attempted from within a comment 2 No information #v- In addition, the current point is left either at the match or is left at the place where the routine either detected a mismatch or gave up. In the case of a comment or a string (return values of -2 or -1), the current point is left at the beginning of a comment. Note: If the of \var{ch} is zero, the character at the current point will be used. \seealso{blink_match, create_syntax_table, define_syntax, parse_to_point} \done \function{fsearch} \synopsis{Search forward for the string "str"} \usage{Integer fsearch (String str)} \description This function may be used to search forward in buffer looking for the string \var{str}. If not found, this functions returns zero. However, if found, the length of the string is returned and the current point is moved to the to the start of the match. It respects the setting of the variable \var{CASE_SEARCH}. If the string that one is searching for is known to be at the beginning of a line, the function \var{bol_fsearch} should be used instead. Note: This function cannot find a match that crosses lines. \seealso{ffind, fsearch_char, bsearch, bol_fsearch, re_fsearch, looking_at} \seealso{CASE_SEARCH} \done \function{fsearch_char} \synopsis{Search forward for a character} \usage{Integer fsearch_char (Integer ch)} \description This function searches forward for the character \var{ch}. If it is found, \var{1} is returned; otherwise \exmp{0} is returned. \seealso{fsearch, ffind_char, bsearch_char} \seealso{CASE_SEARCH} \done \function{looking_at} \synopsis{Test if the characters immediately following the point match "s"} \usage{Integer looking_at (String s)} \description This function returns non-zero if the characters immediately following the current editing point match the string specified by \var{s}. Whether the match is case-sensitive or not depends upon the value of the variable \var{CASE_SEARCH}. The function returns zero if there is no match. \seealso{ffind, fsearch, re_fsearch, bfind} \done \function{re_bsearch} \synopsis{Search backward for regular expression "pattern"} \usage{Integer re_bsearch(String pattern)} \description Search backward for regular expression \var{pattern}. This function returns the 1 + length of the string matched. If no match is found, it returns 0. \seealso{bsearch, bol_bsearch, re_fsearch} \done \function{re_fsearch} \synopsis{Search forward for regular expression "pattern"} \usage{Integer re_fsearch(String pattern)} \description Search forward for regular expression \var{pattern}. This function returns the 1 + length of the string matched. If no match is found, it returns 0. \seealso{fsearch, bol_fsearch, re_bsearch} \done \function{regexp_nth_match} \synopsis{Return the nth sub-expression from the last re search} \usage{String regexp_nth_match (Integer n)} \description This function returns the nth sub-expression matched by the last regular expression search. If the parameter \var{n} is zero, the entire match is returned. Note: The value returned by this function is meaningful only if the editing point has not been moved since the match. \seealso{re_fsearch, re_bsearch} \done \function{replace} \synopsis{Replace all occurances of "old" with "new"} \usage{Void replace(String old, String new)} \description This function may be used to replace all occurances of the string \var{old} with the string, \var{new}, from current editing point to the end of the buffer. The editing point is returned to the initial location. That is, this function does not move the editing point. \seealso{replace_chars, fsearch, re_fsearch, bsearch, ffind, del} \seealso{REPLACE_PRESERVE_CASE} \done \function{replace_chars} \synopsis{Replace the next "n" characters with another string} \usage{Int_Type replace_chars (Int_Type n, String_Type new)} \description This function may be used to replace the next \exmp{n} characters at the editing position by the string \exmp{new}. After the replacement, the editing point will be moved to the end of the inserted string. The length of the replacement string \exmp{new} is returned. \seealso{fsearch, re_fsearch, bsearch, ffind, del} \seealso{REPLACE_PRESERVE_CASE} \done \function{replace_match} \synopsis{Replace text previously matched with "re_fsearch" or "re_bsearch"} \usage{Int_Type replace_match(String_Type str, Int_Type method)} \description This function replaces text previously matched with \var{re_fsearch} or \var{re_bsearch} at the current editing point with string \exmp{str}. If \exmp{method} is zero, \exmp{str} is a specially formatted string of the form described below. If \exmp{method} is non-zero, \exmp{str} is regarded as a simple string and is used literally. If the replacement fails, this function returns zero otherwise, it returns a non-zero value. \notes This function should be used at the position of the corresponding match and nowhere else. \done \function{search_file} \synopsis{Regular expression search for strings in a disk file} \usage{Integer search_file (String filename, String re, Integer nmax)} \description This function may be used to search for strings in a disk file matching the regular expression \exmp{re}. The first argument \var{filename} specifies which file to search. The last argument \var{nmax} specifies how many matches to return. Each line that is matched is pushed onto the S-Lang stack. The number of matches (limited by \var{nmax}) is returned. If the file contains no matches, zero is returned. \done jed-0.99-19/doc/tm/rtl/terminal.tm0000644002657400265740000001013211311317447015632 0ustar davisdavis\variable{CHEAP_VIDEO} \synopsis{Control flicker on old video cards} \usage{Int_Type CHEAP_VIDEO} \description Some old video cards for MSDOS systems, most notably the CGA card, display snow when updating the card. This variable should be set to \1 to avoid the presence of snow when used with such a card. \notes This variable is not available on all systems. \seealso{SCREEN_WIDTH, SCREEN_HEIGHT} \done \variable{IGNORE_BEEP} \synopsis{Control beeping of the terminal} \usage{Int_Type IGNORE_BEEP} \description This variable determines how the terminal is to be beeped. It may be any one of the following values: #v+ 0 Do not beep the terminal in any way. 1 Produce an audible beep only. 2 Produce an visible beep only by flashing the display. 3 Produce both audible and visible bells. #v- \notes Not all terminals support visible bells. \seealso{beep} \done \variable{SCREEN_HEIGHT} \synopsis{Number of display rows} \usage{Int_Type SCREEN_HEIGHT} \description This is a read-only variable whose value represents the number of rows of the display or terminal. \seealso{SCREEN_WIDTH, window_info} \done \variable{SCREEN_WIDTH} \synopsis{Number of display columns} \usage{Int_Type SCREEN_WIDTH} \description This is a read-only variable whose value represents the number of columns of the display or terminal. \seealso{SCREEN_HEIGHT, window_info} \done \variable{TERM_BLINK_MODE} \synopsis{Enable the use of high intensity background colors} \usage{Int_Type TERM_BLINK_MODE} \description If the value of this variable is non-zero, \jed will interpret high-intensity background colors as blinking characters. On some terminals, e.g., \exmp{rxvt}, the blink bit will be mapped to an actual high intensity background color. \notes This variable is not available on all systems. \seealso{} \done \variable{TERM_CANNOT_INSERT} \synopsis{Control the use of terminal insertion} \usage{Int_Type TERM_CANNOT_INSERT} \description The value of this variable indicates whether or not the terminal is able to insert. Do disable the use of the insertion capability, set the value of this variable to \0. \notes This variable is not available on all systems. It is a good idea not to set this variable. \seealso{TERM_CANNOT_SCROLL} \done \variable{TERM_CANNOT_SCROLL} \synopsis{Control the use of the terminal's scrolling capability} \usage{Int_Type TERM_CANNOT_SCROLL} \description If this variable is set to \0, the hardware scrolling capability of the terminal will not be used. This also means that the window will be recentered if the cursor moves outside the top or bottom rows of the window. \notes This variable is not available on all systems. \seealso{TERM_CANNOT_INSERT} \done \variable{USE_ANSI_COLORS} \synopsis{Enable the use of colors} \usage{Int_Type USE_ANSI_COLORS} \description The variable \var{USE_ANSI_COLORS} may be used to enable or disable color support. If set to a non-zero value, the terminal will be assumed to support ANSI colors. This value of this variable is initially determined by examining the terminal's terminfo file, or by looking for the existence of a \var{COLORTERM} environment variable. \notes This variable is not available on all platforms. \seealso{HIGHLIGHT} \done \function{get_termcap_string} \synopsis{Return the keystring associated with the termcap capability "cap"} \usage{String get_termcap_string (String cap);} \description This function may be used to extract the string associated with the termcap capability associated with \var{cap}. Note: This function is only available on Unix systems. \done \function{set_term_vtxxx} \synopsis{Set terminal display appropriate for a vtxxx terminal} \description Set terminal display appropriate for a vtxxx terminal. This function takes a single integer parameter. If non-zero, the terminal type is set for a vt100. This means the terminal lacks the ability to insert/delete lines and characters. If the parameter is zero, the terminal is assumed to be vt102 compatable. Unless you are using a VERY old terminal or a primitive emulator, use zero as the parameter. \done jed-0.99-19/doc/tm/rtl/hidden.tm0000644002657400265740000000512711311317447015262 0ustar davisdavis\function{is_line_hidden} \synopsis{Test if the current line is hidden} \usage{Integer is_line_hidden ()} \description This function returns a non-zero value if the current line is hidden. It will return zero if the current line is visible. \seealso{set_line_hidden} \done \function{set_line_hidden} \synopsis{Set the hidden attribute: 1 hidden, 0 visible} \usage{Void set_line_hidden (Integer flag)} \description If the parameter \var{flag} is non-zero, the current line will be given the hidden attribute. This means that it will not be displayed. If the parameter is zero, the hidden attribute will be turned off. \seealso{set_region_hidden, is_line_hidden} \done \function{set_region_hidden} \synopsis{Set the hidden attribute for all lines in a region} \usage{Void set_region_hidden (Integer flag)} \description This function may be used to hide the lines in a region. If \var{flag} is non-zero, all lines in the region will be hidden. If it is zero, the lines in the region will be made visible. \seealso{set_line_hidden, is_line_hidden, skip_hidden_lines_forward} \done \function{skip_hidden_lines_backward} \synopsis{Move backward across either hidden or non-hidden lines} \usage{Void skip_hidden_lines_backward (Integer type)} \description This function may be used to move backward across either hidden or non-hidden lines depending upon whether the parameter \var{type} is non-zero or zero. If \var{type} is non-zero, the Point is moved backward across hidden lines until a visible line is reached. If \var{type} is zero, visible lines will be skipped instead. If the top of the buffer is reached before the appropriate line is reached, the Point will be left there. Note: The functions \var{up} and \var{down} are insensitive to whether or not a line is hidden. \seealso{skip_hidden_lines_forward, is_line_hidden} \done \function{skip_hidden_lines_forward} \synopsis{Move forward across either hidden or non-hidden lines} \usage{Void skip_hidden_lines_forward (Integer type)} \description This function may be used to move forward across either hidden or non-hidden lines depending upon whether the parameter \var{type} is non-zero or zero. If \var{type} is non-zero, the Point is moved forward across hidden lines until a visible line is reached. If \var{type} is zero, visible lines will be skipped instead. If the end of the buffer is reached before the appropriate line is reached, the Point will be left there. Note: The functions \var{up} and \var{down} are insensitive to whether or not a line is hidden. \seealso{skip_hidden_lines_backward, is_line_hidden} \done jed-0.99-19/doc/tm/rtl/whatelse.sl0000755002657400265740000000404111311317447015636 0ustar davisdavis#! /usr/bin/env slsh % -*- slang -*- % This file is used to determine what functions still need documenting. % I think that it provides a good example of the use of associative arrays. _debug_info = 1; variable Src_Files = "../../../src/*.c"; variable TM_Files = "*.tm"; variable Unwanted_Files = ""; define grep (pat, files) { if (strlen (files) == 0) return String_Type[0]; variable fp = popen (sprintf ("rgrep '%s' %s", pat, files), "r"); variable matches; matches = fgetslines (fp); () = pclose (fp); return matches; } static define prune_array (a, b) { foreach (b) using ("keys") { variable k = (); assoc_delete_key (a, k); } } define get_with_pattern (a, pat, white) { variable f; foreach (grep (pat, Src_Files)) { f = (); f = strtok (f, white)[1]; a [f] = 1; } if (Unwanted_Files != NULL) foreach (grep (pat, Unwanted_Files)) { f = (); f = strtok (f, white)[1]; assoc_delete_key (a, f); } } define get_src_intrinsics () { variable f; variable src = Assoc_Type[Int_Type]; get_with_pattern (src, "^[ \t]+MAKE_INTRINSIC.*(\".*\"", "\""); get_with_pattern (src, "^[ \t]+MAKE_MATH_UNARY.*(\".*\"", "\""); get_with_pattern (src, "^[ \t]+MAKE_VARIABLE.*(\".*\"", "\""); get_with_pattern (src, "^[ \t]+MAKE_DCONSTANT.*(\".*\"", "\""); get_with_pattern (src, "^[ \t]+MAKE_ICONSTANT.*(\".*\"", "\""); return src; } define get_doc_intrinsics () { variable funs; variable doc = Assoc_Type[Int_Type]; funs = grep ("^\\\\function{", TM_Files); foreach (funs) { variable f; f = (); f = strtok (f, "{}")[1]; doc [f] = 1; } funs = grep ("^\\\\variable{", TM_Files); foreach (funs) { f = (); f = strtok (f, "{}")[1]; doc [f] = 1; } return doc; } define main () { variable k; variable src, doc; doc = get_doc_intrinsics (); src = get_src_intrinsics (); prune_array (src, doc); k = assoc_get_keys (src); k = k[array_sort(k)]; foreach (k) { message (); } } main (); jed-0.99-19/doc/tm/rtl/syntax.tm0000644002657400265740000003457111311317447015362 0ustar davisdavis\function{create_syntax_table} \synopsis{Create a new syntax table "name"} \usage{Void create_syntax_table (String name);} \description This the purpose of this function is to create a new syntax table with the name specified by \var{name}. If the table already exists, this clears the table of its current syntax entries. \seealso{define_syntax, use_syntax_table, define_keywords, what_syntax_table} \done \function{define_keywords_n} \synopsis{Define a set of keywords} \usage{String define_keywords_n (String table, String kws, Integer len, Integer N);} \description This function is used to define a set of keywords for the syntax table \var{table} to be color syntax highlighted in the \exmp{"keywordN"} color, The first parameter, \var{table}, specifies which syntax table is to be used for the definition. The second parameter, \var{kws}, is a string that is the concatenation of keywords of length specified by the last parameter \var{len}. The list of keywords specified by \var{kws} must be in alphabetic order. The function returns the previous list of keywords of length \var{len}. For example, C mode uses the statement #v+ () = define_keywords_n ("C", "asmforintnewtry", 3, 0); #v- to define the four three-letter keywords \var{asm}, \var{for}, \var{int}, \var{new}, and \var{try} to be given the \exmp{"keyword0"} color. Note that in the above example, the return value is not used. \seealso{define_syntax, set_color} \seealso{WANT_SYNTAX_HIGHLIGHT,USE_ANSI_COLORS} \done \function{define_syntax} \synopsis{Add a syntax entry to the table "name"} \usage{Void define_syntax (..., Integer type, String name);} \description This function adds a syntax entry to the table specified by the last parameter \var{name}. The actual number of parameters vary according to the next to the last parameter \var{type}. If \var{type} is \exmp{'"'} or \exmp{'\\''}, a string or character delimiter syntax is defined. In this case, \var{define_syntax} only takes three parameters where the first parameter is an integer that represents the character for which the syntax is to be applied. Similarly, if \var{type} is \exmp{'\\\\'}, then a quote syntax is defined and again \var{define_syntax} only takes three parameters where the first parameter is an integer that represents the character for which the syntax is to be applied. A quote character is one in which the syntax of the following character is not treated as special. If \var{type} is \exmp{'('}, then \var{define_syntax} takes four parameters where the first two parameters are strings that represent a matching set of delimiters. The first string contains the set of opening delimiters and the second string specifies the set of closing delimiters that match the first set. If a character from the closing set is entered into the buffer, the corresponding delimiter from the opening set will be blinked. For example, if the C language syntax table is called \exmp{"C"}, then one would use #v+ define_syntax ("([{", ")]}", '(', "C"); #v- to declare the matching delimiter set. Note that the order of the characters in the two strings must correspond. That is, the above example says that \exmp{'('} matches \exmp{')'} and so on. If \var{type} is \exmp{'%'}, a comment syntax is defined. As in the previous case, \var{define_syntax} takes four parameters where there first two parameters are strings that represent the begin and end comment delimiters. If the comment syntax is such that the comment ends at the end of a line, the second string must either be the empty string, \exmp{""}, or a newline \exmp{"\\n"}. The current implementation supports at most two such types of comments. If \var{type} is \exmp{'+'}, the first parameter is a string whose characters are given the operator syntax. If type is \exmp{','}, the first parameter is a string composed of characters that are condered to be delimiters. If type is '0', the first parameter is a string composed of characters that make up a number. If \var{type} is \exmp{<}, the first parameter is a string whose successive characters form begin and end keyword highlight directives. Finally, if \var{type} is \exmp{'#'}, the first parameter is an integer whose value corresponds to the character used to begin preprocessor lines. As an example, imagine a language in which the dollar sign character \exmp{$} is used as a string delimiter, the backward quote character \exmp{`} is used as a quote character, comments begin with a semi-colon and end at the end of a line, and the characters \exmp{'<'} and \exmp{'>'} form matching delimiters. The one might use #v+ create_syntax_table ("strange"); define_syntax ('$', '"', "strange"); define_syntax ('`', '\\', "strange"); define_syntax (";", "", '%', "strange"); define_syntax ("<", ">", '(', "strange"); #v- to create a syntax table called \exmp{"strange"} and define the syntax entries for appropriate this example. \seealso{create_syntax_table, use_syntax_table, find_matching_delimiter} \seealso{BLINK} \done \function{dfa_build_highlight_table} \synopsis{Build a DFA table for the syntax table "n"} \usage{Void dfa_build_highlight_table (String n);} \description This function builds a DFA table for the enhanced syntax highlighting scheme specified for the syntax table specified by the name \var{n}. This must be called before any syntax highlighting will be done for that syntax table. \seealso{create_syntax_table, use_syntax_table, dfa_define_highlight_rule, dfa_enable_highlight_cache} \seealso{WANT_SYNTAX_HIGHLIGHT,USE_ANSI_COLORS} \done \function{dfa_define_highlight_rule} \synopsis{Add an DFA rule to the syntax table "n"} \usage{Void dfa_define_highlight_rule (String rule, String color, String n);} \description This function adds an enhanced highlighting rule to the syntax table specified by the name \var{n}. The rule is described as a regular expression by the string \var{rule}, and the associated color is given by the string \var{color}, in the same format as is passed to \var{set_color}. For example: #v+ create_syntax_table ("demo"); dfa_define_highlight_rule ("[A-Za-z][A-Za-z0-9]*", "keyword", "demo"); dfa_define_highlight_rule ("//.*$", "comment", "demo"); dfa_build_highlight_table ("demo"); #v- causes a syntax table to be defined in which any string of alphanumeric characters beginning with an alphabetic is highlighted in keyword color, and anything after "//" on a line is highlighted in comment color. The regular expression syntax understands character classes like \exmp{[a-z]} and \exmp{[^a-z0-9]}, parentheses, \exmp{+}, \exmp{*}, \exmp{?}, \exmp{|} and \exmp{.}. Any metacharacter can be escaped using a backslash so that it can be used as a normal character, but beware that due to the syntax of S-Lang strings the backslash has to be doubled when specified as a string constant. For example: #v+ dfa_define_highlight_rule ("^[ \t]*\\*+[ \t].*$", "comment", "C"); #v- defines any line beginning with optional whitespace, then one or more asterisks, then more whitespace to be a comment. Note the doubled backslash before the \exmp{*}. Note also that \var{dfa_build_highlight_table} must be called before the syntax highlighting can take effect. \seealso{create_syntax_table, use_syntax_table, dfa_build_highlight_table} \seealso{WANT_SYNTAX_HIGHLIGHT,USE_ANSI_COLORS} \done \function{dfa_enable_highlight_cache} \synopsis{Enable caching of the DFA table} \usage{Void dfa_enable_highlight_cache (String file, String n);} \description This function enables caching of the DFA table for the enhanced syntax highlighting scheme belonging to the syntax table specified by the name \var{n}. This should be called before any calls to \var{dfa_define_highlight_rule} or to \var{dfa_build_highlight_table}. The parameter \var{file} specifies the name of the file (stored in the directory set by the \var{set_highlight_cache_dir} function) which should be used as a cache. For example, in \exmp{cmode.sl} one might write #v+ dfa_enable_highlight_cache ("cmode.dfa", "C"); #v- to enable caching of the DFA. If caching were not enabled for C mode, the DFA would take possibly a couple of seconds to compute every time Jed was started. Transferring cache files between different computers is theoretically possible but not recommended. Transferring them between different versions of Jed is not guaranteed to work. \seealso{create_syntax_table, use_syntax_table, dfa_define_highlight_rule, dfa_build_highlight_table} \seealso{WANT_SYNTAX_HIGHLIGHT,USE_ANSI_COLORS} \done \function{dfa_set_init_callback} \synopsis{Set a callback to initialize a DFA syntax table} \usage{Void dfa_set_init_callback (Ref_Type func, String_Type tbl)} \description This function defines a callback function \var{func} that will be used to build a DFA syntax table for the syntax table \var{tbl}. When the \var{use_dfa_syntax} function is called to enable syntax highlighting, the callback function \var{func} will be called to to create the specified syntax table if it does not already exist. \seealso{create_syntax_table, use_syntax_table, dfa_define_highlight_rule, dfa_enable_highlight_cache} \seealso{WANT_SYNTAX_HIGHLIGHT,USE_ANSI_COLORS} \done \function{parse_to_point} \synopsis{Attempt to determine the syntactic context of the point} \usage{Integer parse_to_point ();} \description This function attempts to determine the syntactic context of the current editing point. That is, it tries to determine whether or not the current point is in a comment, a string, or elsewhere. It returns: #v+ -2 In a comment -1 In a string or a character 0 Neither of the above #v- Note: This routine is rather simplistic since it makes the assumption that the character at the beginning of the current line is not in a comment nor is in a string. \seealso{define_syntax, find_matching_delimiter} \done \function{set_fortran_comment_chars} \synopsis{Specify characters for fortran-like comments} \usage{Void set_fortran_comment_chars (String_Type table, String_Type list} \description This function may be used to specify the set of characters that denote fortran style comments. The first parameter \var{table} is the name of a previously defined syntax table, and \var{list} denotes the set of characters that specify the fortran-style comment. The string \var{list} is simply a set of characters and may include character ranges. If the first character of \var{list} is \var{'^'}, then the meaning is that only those characters that do not specify fortran sytle comments are included in the list. \example Fortran mode uses the following: #v+ set_fortran_comment_chars ("FORTRAN", "^0-9 \t\n"); #v- This means that if any line that begins with any character except the characters \exmp{0} to \exmp{9}, the space, tab, and newline characters will denote a comment. \notes The usefulness of this function is not limited to fortran modes. In fact, many languages have fortran-style comments. This function is meaningful only if the syntax table has fortran-style comments as specified via the \var{set_syntax_flags} function. \seealso{define_syntax, set_syntax_flags} \done \function{set_highlight_cache_dir} \synopsis{Set the directory for the dfa syntax highlighting cache files} \usage{Void set_highlight_cache_dir (String dir);} \description This function sets the directory where the dfa syntax highlighting cache files are located. See also: \var{dfa_enable_highlight_cache} \done \function{set_syntax_flags} \synopsis{Set the flags in the syntax table "table"} \usage{Void set_syntax_flags (String table, Integer flag);} \description This function may be used to set the flags in the syntax table specified by the \var{table} parameter. The \var{flag} parameter may take any of the following values or any combination bitwise or-ed together: #v+ 0x01 Keywords are case insensitive 0x02 Comments are Fortran-like 0x04 Ignore leading whitespace in C comments 0x08 Keywords are TeX-like 0x10 EOL style comments must be surrounded by whitespace. 0x20 Syntax highlight whole preprocessor line in same color. 0x40 Leading whitespace allowed for preprocessor lines. 0x80 Strings do not span lines #v- A Fortran-like comment means that any line that begins with certain specified characters is considered to be a comment. This special subset of characters must be specified via a call to the \var{set_fortran_comment_chars} function. If the \exmp{0x04} bit is set, then whitespace at the beginning of a line in a C comment preceeding a \exmp{'*'} character will not be highlighted. A TeX-like keyword is any word that follows the quote character. An EOL style comment is one that ends at the end of the line. \seealso{define_syntax, set_fortran_comment_chars} \done \function{use_dfa_syntax} \synopsis{Turn on/off DFA syntax highlighting for the current mode} \usage{use_syntax_table (Int_Type on_off)} \description This function may be used to turn on or off DFA syntax highlighting for the current mode according to whether or not the \var{on_off} parameter is non-zero. The most useful way of using this function is from within a mode hook. \example The following example illustrates how to use this function to enable DFA syntax highlighting for C mode: #v+ define c_mode_hook () { use_dfa_syntax (1); } #v- \seealso{enable_dfa_syntax_for_mode, disable_dfa_syntax_for_mode} \done \function{use_syntax_table} \synopsis{Associate the current buffer with the syntax table "n"} \usage{Void use_syntax_table (String n);} \description This function associates the current buffer with the syntax table specified by the name \var{n}. Until another syntax table is associated with the buffer, the syntax table named \var{n} will be used in all operations that require a syntax. This includes parenthesis matching, indentation, etc. \seealso{create_syntax_table, define_syntax} \done \function{what_syntax_table} \synopsis{Get the name of the active syntax table} \usage{String_Type what_syntax_table ()} \description This function returns of the name of the syntax table used by the current buffer. If no table is in effect it returns \NULL. \seealso{define_syntax, use_syntax_table, define_keywords} \done jed-0.99-19/doc/tm/rtl/abbrev.tm0000644002657400265740000000462011311317447015265 0ustar davisdavis\function{abbrev_table_p} \synopsis{Test whether an abbreviation table "name" exists} \usage{Integer abbrev_table_p (String name)} \description Returns non-zero if an abbreviation table with called \var{name} exists. If the table does not exist, it returns zero. \done \function{create_abbrev_table} \synopsis{Create an abbreviation table "name"} \usage{Void create_abbrev_table (String name, String word)} \description Create an abbreviation table with name \var{name}. The second parameter \var{word} is the list of characters used to represent a word for the table. If the empty string is passed for \var{word}, the characters that currently constitute a word are used. \done \function{define_abbrev} \synopsis{Define an abbreviation} \usage{Void define_abbrev (String tbl, String abbrv, String expans)} \description This function is used to define an abbreviation \var{abbrv} that will be expanded to \var{expans}. The definition will be placed in the table with name \var{tbl}. \done \function{delete_abbrev_table} \synopsis{Delete the abbrev table "name"} \usage{Void delete_abbrev_table (String name)} \description Delete the abbrev table specified by \var{name}. \done \function{dump_abbrev_table} \synopsis{Insert the abbreviation table "name"} \usage{Void dump_abbrev_table (String name)} \description This function inserts the contents of the abbreviation table called \var{name} into the current buffer. \done \function{list_abbrev_tables} \synopsis{Return the names of all defined abbreviation tables} \usage{Integer list_abbrev_tables ()} \description This function returns the names of all currently defined abbreviation tables. The top item on the stack will be the number of tables followed by the names of the tables. \done \function{use_abbrev_table} \synopsis{Use the abbreviation table "table" for the current buffer} \usage{Void use_abbrev_table (String table)} \description Use the abbreviation table named \var{table} as the abbreviation table for the current buffer. By default, the "Global" table is used. \done \function{what_abbrev_table} \synopsis{Return info about the current abbreviation table} \usage{(String, String) what_abbrev_table ()} \description This functions returns both the name of the abbreviation table and the definition of the word for the table currently associated with the current buffer. If none is defined it returns two empty strings. \done jed-0.99-19/doc/tm/rtl/misc.tm0000644002657400265740000002315011311317447014756 0ustar davisdavis\variable{BATCH} \synopsis{Non-Zero if in Batch Mode} \usage{Int_Type BATCH (read-only)} \description The value of \var{BATCH} will be 0 if the editor is run in interactive or full-screen mode. It will be \1 if the editor is in batch mode (via the \exmp{-batch} comment line argument). If the editor is in script mode (via \exmp{-script}), then the value of \var{BATCH} will be \2. \done \variable{JED_ROOT} \synopsis{Location of the JED root directory} \usage{String_Type JED_ROOT} \description This is a read-only string variable whose value indicates JED's root directory. This variable may be set using the \var{JED_ROOT} environment variable. \seealso{get_jed_library_path, set_jed_library_path, getenv} \done \variable{_jed_secure_mode (read-only)} \synopsis{Indicates if the editor is in secure mode} \usage{Int_Type _jed_secure_mode} \description The value of \var{_jed_secure_mode} will be non-zero if the editor is running in secure mode. This mode does not allow any access to the shell. \seealso{system} \done \variable{_jed_version} \synopsis{The JED version number} \usage{Int_Type _jed_version} \description The value of \var{_jed_version} represents the version number of the editor. \seealso{_jed_version_string, _slang_version} \done \variable{_jed_version_string} \synopsis{The JED version number as a string} \usage{String_Type _jed_version_string} \description The value of \var{_jed_version_string} represents the version number of the editor. \seealso{_jed_version, _slang_version_string} \done \function{call} \synopsis{Execute an internal function} \usage{Void call(String f)} \description The \var{call} function is used to execute an internal function which is not directly accessable to the S-Lang interpreter. \seealso{is_internal} \done \function{core_dump} \synopsis{Exit the editor dumping the state of some crucial variables} \usage{Void core_dump(String msg, Integer severity)} \description \var{core_dump} will exit the editor dumping the state of some crucial variables. If \var{severity} is \var{1}, a core dump will result. Immediately before dumping, \var{msg} will be displayed. \seealso{exit, exit_jed, quit_jed, message, error} \done \function{define_word} \synopsis{Define the set of characters that form a word} \usage{Void define_word (String s)} \description This function is used to define the set of characters that form a word. The string \var{s} consists of those characters or ranges of characters that define the word. For example, to define only the characters \exmp{A-Z} and \exmp{a-z} as word characters, use: #v+ define_word ("A-Za-z"); #v- To include a hyphen as part of a word, it must be the first character of the control string \var{s}. So for example, #v+ define_word ("-i-n"); #v- defines a word to consist only of the letters \var{i} to \var{n} and the hyphen character. \done \function{exit} \synopsis{Exit the editor gracefully with a status value} \usage{exit (Int_Type status)} \description This function performs the same actions as \var{exit_jed} except that the status code returned to the shell may be specified. \seealso{_exit, exit_jed} \done \function{exit_jed} \synopsis{Exit JED in a graceful and safe manner} \usage{Void exit_jed ()} \description This function should be called to exit JED in a graceful and safe manner. If any buffers have been modified but not saved, the user is queried about whether or not to save each one first. \var{exit_jed} calls the S-Lang hook \var{exit_hook} if it is defined. If \var{exit_hook} is defined, it must either call \var{quit_jed} or \var{exit_jed} to really exit the editor. If \var{exit_jed} is called from \var{exit_hook}, \var{exit_hook} will not be called again. For example: #v+ define exit_hook () { flush ("Really Exit?"); forever { switch (getkey () & 0x20) % map to lowercase { case 'y': exit_jed (); } { case 'n': return; } beep (); } } #v- may be used to prompt user for confirmation of exit. \seealso{exit, quit_jed, suspend, flush, getkey} \seealso{BATCH} \done \function{get_last_macro} \synopsis{Return characters composing the last keyboard macro} \usage{String get_last_macro ()} \description This function returns characters composing the last keyboard macro. The charactors that make up the macro are encoded as themselves except the following characters: #v+ '\n' ----> \J null ----> \@ \ ----> \\ '"' ----> \" #v- \done \function{get_passwd_info} \synopsis{Return information about the user "username"} \usage{(dir, shell, pwd, uid, gid) = get_passwd_info (String username)} \description This function returns password information about the user with name \var{username}. The returned variables have the following meaning: #v+ dir: login directory shell: login shell pwd: encripted password uid: user identification number gid: group identification number #v- If the user does not exist, or the system call fails, the function returns with \var{uid} and \var{gid} set to \exmp{-1}. \done \function{getpid} \synopsis{Return the process identification number for the editor} \usage{Integer getpid ()} \description This function returns the process identification number for the current editor process. \done \function{is_internal} \synopsis{Test if function "f" is defined as an internal function} \usage{Integer is_internal(String f)} \description \var{is_internal} returns non-zero is function \var{f} is defined as an internal function or returns zero if not. Internal functions not immediately accessable from S-Lang; rather, they must be called using the \var{call} function. See also the related S-Lang function \var{is_defined} in the S-Lang Programmer's Reference. \seealso{call} \done \function{quit_jed} \synopsis{Quit the editor immediately: no autosave, no hooks} \usage{Void quit_jed ([ status ])} \description This function quits the editor immediately without saving any buffers and without any exit hooks called. The function \ifun{exit_jed} should be called when it is desired to exit in a safe way. The exit status of the program may be specified via the optional integer argument. If called with no argument, a value of 0 will be used as the exit status. \seealso{exit_jed} \done \function{random} \synopsis{Return a random number in the range [0, "nmax"[} \usage{Integer random (Integer seed, Integer nmax)} \description The \var{random} function returns a random number in the range 0 to, but not including, \var{nmax}. If the first parameter \var{seed} is 0, the number generated depends on a previous seed. If \var{seed} is -1, the current time and process id will be used to seed the random number generator; otherwise \var{seed} will be used. Example: generate 1000 random integers in the range 0-500 and insert them into buffer: #v+ () = random (-1, 0); % seed generator usingtime and pid loop (1000) insert (Sprintf ("%d\n", random (0, 500), 1)); #v- Note: The random number is generated via the expression: #v+ r = r * 69069UL + 1013904243UL; #v- \done \function{set_line_readonly} \synopsis{Turn on or off the read-only state of the current line} \usage{Void set_line_readonly (Integer flag)} \description This function may be used to turn on or off the read-only state of the current line. If the integer parameter \var{flag} is non-zero, the line will be made read-only. If the paramter is zero, the read-only state will be turned off. \seealso{getbuf_info} \done \function{set_undo_position} \synopsis{Add the current position to the undo stack} \usage{set_undo_position ()} \description This function adds the current position to the buffer's undo stack. Ocassionally this may be necessary when using \ifun{narrow_to_region} to prevent the cursor from moving to the beginning or the end of a previously narrowed region during "undo". \seealso{narrow_to_region} \done \function{suspend} \synopsis{Suspend the editor} \usage{Void suspend ()} \description The action of this command varies with the operating system. Under Unix, the editor will be suspended and control will pass to the parent process. Under VMS and MSDOS, a new subprocess will be spawned. Before suspension, \var{suspend_hook} is called. When the editor is resumed, \var{resume_hook} will be called. These hooks are user-defined functions that take no arguments and return no values. \done \function{usleep} \synopsis{Pause for "ms" milliseconds} \usage{Void usleep (Integer ms)} \description A call to usleep will cause the editor to pause for \var{ms} milliseconds. \seealso{input_pending} \done \function{vms_get_help} \synopsis{Interact with the VMS help system from within the editor} \usage{Void vms_get_help (String hlp_file, String hlp_topic)} \description This function may be used on VMS systems to interact with the VMS help system from within the editor. \var{hlp_file} is the name of the help file to use and \var{hlp_topic} is the topic for which help is desired. \done \function{vms_send_mail} \synopsis{interface to the VMS callable mail facility} \usage{Integer vms_send_mail (String recip_lis, String subj)} \description This VMS specific function provides an interface to the VMS callable mail facility. The first argument, \var{recip_lis}, is a comma separated list of email addresses and \var{subj} is a string that represents the subject of the email. The current buffer will be emailed. It returns \var{1} upon success and \exmp{0} upon failure. \done jed-0.99-19/doc/tm/rtl/buffer.tm0000644002657400265740000002747311311317447015310 0ustar davisdavis\variable{ADD_NEWLINE} \synopsis{Add a newline to a buffer when saving} \usage{Int_Type ADD_NEWLINE} \description If the value of \var{ADD_NEWLINE} is non-zero and the buffer if the buffer does not end with a newline character, a newline character will be silently added to the end of a buffer when the buffer is written out to a file. \done \variable{MAX_HITS} \synopsis{Set the Autosave Interval} \usage{Int_Type MAX_HITS} \description The value of the \var{MAX_HITS} variable specifies how many ``hits'' a buffer can take before it is autosaved. A hit is defined as a single key sequence that could modify the buffer. \seealso{} \done \function{autosave} \synopsis{Save the current buffer to an autosave file} \usage{Void autosave ()} \description The \var{autosave} function saves the current buffer in an auto save file if the buffer has been marked for the auto save operation. \seealso{setbuf_info, autosaveall} \seealso{MAX_HITS} \done \function{autosaveall} \synopsis{Save all buffers to autosave files} \usage{Void autosaveall ()} \description This function is like \var{autosave} except that it causes all files marked for the auto save operation to be auto-saved. \seealso{autosave, setbuf_info} \seealso{MAX_HITS} \done \function{buffer_list} \synopsis{Return the names of buffers} \usage{Integer buffer_list ()} \description This function returns an integer indicating the number of buffers and leaves the names of the buffers on the stack. For example, the following function displays the names of all buffers attached to files: #v+ define show_buffers () { variable b, str = "", file; loop (buffer_list ()) { b = (); (file,,,) = getbuf_info (b); if (strlen (file)) str = strcat (str, strcat (" ", b)); } message (str); } #v- \seealso{getbuf_info, whatbuf} \done \function{buffer_visible} \synopsis{Return the number of windows containing a specified buffer} \usage{Integer buffer_visible (String buf)} \description This function is used to determine whether or not a buffer with name specified by the string \var{buf} is in a window or not. More explicitly, it returns the number of windows containing \var{buf}. This means that if \var{buf} does not occupy a window, it returns zero. For Example, #v+ define find_buffer_in_window (buf) { !if (buffer_visible (buf)) return 0; pop2buf (buf); return 1; } #v- is a function that moves to the window containing \var{buf} if \var{buf} is in a window. \seealso{bufferp, nwindows} \done \function{bufferp} \synopsis{Test if a buffer exists or not} \usage{Integer bufferp (String buf)} \description This function is used to see if a buffer exists or not. If a buffer with name \var{buf} exists, it returns a non-zero value. If it does not exist, it returns zero. \seealso{setbuf, getbuf_info} \done \function{bury_buffer} \synopsis{Make it unlikely for a specified buffer to appear in a window} \usage{Void bury_buffer (String name)} \description The \var{bury_buffer} function may be used to make it unlikely for the buffer specified by the paramter \var{name} to appear in a window. \seealso{sw2buf, getbuf_info} \done \function{check_buffers} \synopsis{Check if any buffers have been changed on disk} \usage{check_buffers ()} \description The \var{check_buffers} function checks to see whether or not any of the disk files that are associated with the editor's buffers have been modified since the assocation was made. The buffer flags are updated accordingly. \seealso{file_time_compare, file_changed_on_disk} \done \function{delbuf} \synopsis{Delete a named buffer} \usage{Void delbuf (String buf)} \description \var{delbuf} may be used to delete a buffer with the name specified by \var{buf}. If the buffer does not exist, a S-Lang error will be generated. \seealso{whatbuf, bufferp, sw2buf} \done \function{getbuf_info} \synopsis{Get basic information about a buffer} \usage{(file, dir, name, flags) = getbuf_info ([ buf ])} #v+ String_Type buf; % optional argument -- name of buffer Int_Type flags; % buffer flags String_Type name; % name of buffer String_Type dir; % directory associated with buffer String_Type file; % name of file associated with buffer (if any). #v- \description This function may be used to get some basic information about a specified buffer. If the optional argument \var{buf} is not present, the current buffer will be used, otherwise \var{buf} must be the name of an existing buffer. The integer that corresponds to the buffer flags are encoded as: #v+ bit 0: (0x001) buffer modified bit 1: (0x002) auto save mode bit 2: (0x004) file on disk modified bit 3: (0x008) read only bit bit 4: (0x010) overwrite mode bit 5: (0x020) undo enabled bit 6: (0x040) buffer buried bit 7: (0x080) Force save upon exit. bit 8: (0x100) Do not backup bit 9: (0x200) File associated with buffer is a binary file bit 10: (0x400) Add CR to end of lines when writing buffer to disk. bit 11: (0x800) Abbrev mode #v- For example, #v+ (file,,,flags) = getbuf_info(); #v- returns the file and the flags associated with the current buffer. \seealso{setbuf_info, whatbuf} \done \function{pop2buf} \synopsis{Open a specified buffer in a second window} \usage{Void pop2buf (String buf)} \description The \var{pop2buf} function will switch to another window and display the buffer specified by \var{buf} in it. If \var{buf} does not exist, it will be created. If \var{buf} already exists in a window, the window containing \var{buf} will become the active one. This function will create a new window if necessary. All that is guaranteed is that the current window will continue to display the same buffer before and after the call to \var{pop2buf}. \seealso{whatbuf, pop2buf_whatbuf, setbuf, sw2buf, nwindows} \done \function{pop2buf_whatbuf} \synopsis{pop2buf and return the old buffers name} \usage{String pop2buf_whatbuf (String buf)} \description This function performs the same function as \var{pop2buf} except that the name of the buffer that \var{buf} replaced in the window is returned. This allows one to restore the buffer in window to what it was before the call to \var{pop2buf_whatbuf}. \seealso{pop2buf, whatbuf} \done \function{set_buffer_umask} \synopsis{Set the process file creation mask for the current buffer} \usage{Integer set_buffer_umask (Integer cmask)} \description The function may be used to set the process file creation mask for the appropriate operations associated with the current buffer. This makes it possible to have a buffer-dependent umask setting. The function takes the desired umask setting and returns the previous setting. If \var{cmask} is zero, the default process umask setting will be used for operations while the buffer is current. If \var{cmask} is -1, the umask associated with the buffer will not be changed. \done \function{set_mode} \synopsis{Set mode flags and name} \usage{ Void set_mode(String mode, Integer flags)} \description This function sets buffer mode flags and status line mode name. \var{mode} is a string which is displayed on the status line if the \exmp{%m} status line format specifier is used. The second argument, \var{flags} is an integer with the possible values: #v+ 0 : no mode. Very generic 1 : Wrap mode. Lines are automatically wrapped at wrap column. 2 : C mode. 4 : Language mode. Mode does not wrap but is useful for computer languages. 8 : S-Lang mode 16: Fortran mode highlighting 32: TeX mode highlighting #v- \seealso{whatmode, getbuf_info, setbuf_info.} \done \function{setbuf} \synopsis{Temporary change the default buffer to another} \usage{Void setbuf(String buf)} \description Changes the default buffer to one named \var{buf}. If the buffer does not exist, it will be created. Note: This change only lasts until top level of editor loop is reached at which point the the buffer associated with current window will be made the default. That is this change should only be considered as temporary. To make a long lasting change, use the function \var{sw2buf}. \seealso{sw2buf, pop2buf, whatbuf, pop2buf_whatbuf} \done \function{setbuf_info} \synopsis{Change attributes for a buffer} \usage{setbuf_info([ buf, ] file, dir, name, flags)} #v+ String_Type buf; % optional argument -- name of buffer Int_Type flags; % buffer flags String_Type name; % name of buffer String_Type dir; % directory associated with buffer String_Type file; % name of file associated with buffer (if any). #v- \description This function may be used to change attributes regarding the buffer \var{buf}. If the optional argument \var{buf} is not present, the current buffer will be used. \var{setbuf_info} performs the opposite function of the related function \var{getbuf_info}. Here \var{file} is the name of the file to be associated with the buffer; \var{dir} is the directory to be associated with the buffer; \var{buf} is the name to be assigned to the buffer, and \var{flags} describe the buffer attributes. See \var{getbuf_info} for a discussion of \var{flags}. Note that the actual file associated with the buffer is located in directory \var{dir} with the name \var{file}. For example, the function #v+ define set_overwrite_mode () { variable dir, file, flags, name; (file, dir, name, flags) = getbuf_info (); flags = flags | (1 shl 4); setbuf_info (file, dir, name, flags); } #v- may be used to turn on overwrite mode for the current buffer. Advanced S-Lang programmers exploit the fact that S-Lang is a stack based language and simply write the above function as: #v+ define set_overwrite_mode () { setbuf_info (getbuf_info () | 0x10); } #v- Here, \exmp{(1 shl 4)} has been written as the hexidecimal number \exmp{0x10}. \seealso{getbuf_info, setbuf, whatbuf} \done \function{sw2buf} \synopsis{Switch to a buffer (more permanent than setbuf)} \usage{Void sw2buf (String buf)} \description This function is used to switch to another buffer whose name is specified by the parameter \var{buf}. If the buffer specified by \var{buf} does not exist, one will be created. Note: Unlike \var{setbuf}, the change to the new buffer is more permanent in the sense that when control passed back out of S-Lang to the main editor loop, if the current buffer at that time is the buffer specified here, this buffer will be attached to the window. \seealso{setbuf, pop2buf, bufferp} \done \function{what_mode} \synopsis{Get mode flags and name of the current buffer} \usage{(String name, Integer flags) = Integer what_mode ()} \description This function may be used to obtain the mode flags and mode name of the current buffer. See \var{set_mode} for more details. \seealso{set_mode, getbuf_info, setbuf_info} \done \function{whatbuf} \synopsis{Return the name of the current buffer} \usage{String what_buffer()} \description \var{whatbuf} returns the name of the current buffer. It is usually used in functions when one wants to work with more than one buffer. The function \var{setbuf_info} may be used to change the name of the buffer. \seealso{getbuf_info, bufferp} \done \function{write_buffer} \synopsis{Write the current buffer to a file} \usage{Integer write_buffer (String filename)} \description This function may be used to write the current buffer out to a file specified by \var{filename}. The buffer will then become associated with that file. The number of lines written to the file is returned. An error condition will be signaled upon error. \seealso{write_region_to_file, setbuf_info} \done jed-0.99-19/doc/tm/rtl/info.tm0000644002657400265740000000757211311317447014770 0ustar davisdavis\function{bobp} \synopsis{Test if the current position is at the beginning of the buffer} \usage{Integer bobp ();} \description The \var{bolp} function is used to determine if the current position is at the beginning of the buffer or not. If so, it returns a non-zero value. However, if it is not, it returns zero. This simple example, #v+ define is_buffer_empty () { return bobp () and eobp (); } #v- returns non-zero if the buffer is empty; otherwise, it returns zero. \seealso{bob, eobp, bolp, eolp} \done \function{bolp} \synopsis{Test if the current position is at the beginning of the line} \usage{Integer bolp ();} \description \var{bolp} is used to test if the current position is at the beginning of a line or not. It returns non-zero if the position is at the beginning of a line or zero if not. \seealso{bol, eolp, bobp, eobp} \done \function{count_chars} \synopsis{Return information about size of and position in the buffer} \usage{String count_chars ();} \description This function returns information about the size of the current buffer and current position in the buffer. The string returned is of the form: #v+ 'h'=104/0x68/0150, point 90876 of 127057 #v- \seealso{what_char} \done \function{eobp} \synopsis{Test if the current position is at the end of the buffer} \usage{Integer eobp ();} \description The functio \var{eobp} is used to determine if the current position is at the end of the buffer or not. It returns a non-zero value if at the end of the buffer or zero if not. \seealso{eob, bolp, eolp} \done \function{eolp} \synopsis{Test if the current position is at the end of the line} \usage{Integer eolp ();} \description This function may be used to determine whether or not the current position is at the end of a line ot not. If it is, the routine returns a non-zero value; otherwise it returns zero. \seealso{eol, bolp, eobp, bobp} \done \function{get_word_chars} \synopsis{Get the currently defined word range} \usage{String_Type get_word_chars ()} \description The \var{get_word_chars} returns the currently defined set of characters that constitute a word. The set may be returned as a character range. \seealso{define_word} \done \function{what_char} \synopsis{Return the ASCII-value of the character at the current position} \usage{ULong_Type what_char ()} \description The \var{what_char} function returns the value of the character at the current position as an unsigned long value. If UTF-8 mode is active and the current character is part of an illegal byte sequence, then the function returns a negative value equal in magnitude to the value of the byte. \example #v+ while (not (eolp ())) { if (what_char () == '_') { del (); insert ("\\_"); continue; } go_right (1); } #v- has the effect of replacing all underscore characters on the current line with a backslash-underscore combination. \seealso{looking_at} \done \function{what_column} \synopsis{Return the current column number} \usage{Integer what_column ();} \description The \var{what_column} function returns the current column number expanding tabs, control characters, etc... The beginning of the line is at column number one. \seealso{whatline, whatpos, goto_column, bolp, eolp} \done \variable{what_line} \synopsis{Get the current line number} \usage{Int_Type what_line} \description The value of the \var{what_line} specifies the current line number. Lines are numbered from one. \notes This is a read-only variable. The actual number is measured from the top of the buffer which is itself is affected by whether the buffer is narrowed or not. For example, #v+ define one () { push_mark (); narrow (); return what_line; } #v- always returns 1. \seealso{what_column, goto_line} \done jed-0.99-19/doc/tm/rtl/eval.tm0000644002657400265740000000337611311317447014762 0ustar davisdavis\function{_autoload} \synopsis{Specify multiple functions to autoload} \usage{Void _autoload (String fun, String fn, ..., Integer n)} \description The \var{_autoload} function is like the \var{autoload} function except that it takes \var{n} pairs of function name (\var{fun}) / filename (\var{fn}) pairs. For example, #v+ _autoload ("fun_a", "file_a", "fun_b", "file_b", 2); #v- is equivalent to #v+ autoload ("fun_a", "file_a"); autoload ("fun_b", "file_b"); #v- \seealso{autoload} \done \function{evalbuffer} \synopsis{Eval the current buffer as S-Lang script} \usage{Void evalbuffer ([String_Type namespace])} \description This function causes the current buffer to be sent to the S-Lang interpreter for evaluation. If the optional namespace argument is given, the buffer will be evaluated in the specified namespace. If an error is encountered while parsing the buffer, the cursor will be placed at the location of the error. \seealso{evalfile, require} \done \function{get_jed_library_path} \synopsis{Return the current search path for jed library files} \usage{String get_jed_library_path ()} \description This function returns the current search path for jed library files. The path may be set using the function \var{set_jed_library_path}. \seealso{set_jed_library_path} \done \function{set_jed_library_path} \synopsis{Set the search path for library files} \usage{Void set_jed_library_path (String p)} \description This function may be used to set the search path for library files. Its parameter \var{p} may be a comma separated list of directories to search. When the editor is first started, the path is initialized from the \var{JED_ROOT}, or \var{JED_LIBRARY} environment variables. \seealso{get_jed_library_path} \done jed-0.99-19/doc/tm/rtl/blocal.tm0000644002657400265740000000237211311317447015262 0ustar davisdavis\function{blocal_var_exists} \synopsis{Determine whether a buffer-local variable exists} \usage{Int_Type blocal_var_exists (String_Type name)} \description The \var{blocal_var_exists} function returns non-zero if the specified buffer-local variable exists. It returns zero of the variable does not exists. \seealso{get_blocal_var, create_blocal_var, set_blocal_var, define_blocal_var} \done \function{create_blocal_var} \synopsis{Create a buffer local variable "name"} \usage{Void create_blocal_var (String name)} \description This function is used to create a buffer local variable named \var{name}. A buffer local variable is a variable whose value is local to the current buffer. \seealso{get_blocal_var, set_blocal_var, define_blocal_var} \done \function{set_blocal_var} \synopsis{Set the buffer local variable "v" to value "val"} \usage{Void set_blocal_var (val, String v)} \description This function sets the value of the buffer local variable with name \var{v} to value \var{val}. The buffer local variable specified by \var{v} must have been previously created by the \var{create_blocal_var} function. \var{val} must have the type that was declared when \var{create_blocal_var} was called. \seealso{get_blocal_var, create_blocal_var} \done jed-0.99-19/doc/tm/rtl/insdel.tm0000644002657400265740000001450711311317447015307 0ustar davisdavis\variable{USE_TABS} \synopsis{Control use of tabs in whitespace} \usage{Int_Type USE_TABS} \description If \var{USE_TABS} is non-zero, the editor may use tab characters when creating whitespace. If the value of this variable is zero, no tabs will be used. \seealso{TAB, TAB_DEFAULT} \done \variable{WRAP} \synopsis{Set the column at which wrapping occurs} \usage{Int_Type WRAP} \description The \var{WRAP} variable determines the column number at which wrapping will occur. When entering text, if the current point goes beyond this column, the text will automatically wrap to the next line. This will only happen for those buffers for which the wrap flag is set. \seealso{WRAP_INDENTS, getbuf_info, set_mode} \done \variable{WRAP_INDENTS} \synopsis{Control indentation after wrapping} \usage{Int_Type WRAP_INDENTS} \description If this variable is non-zero, after a line is wrapped, the new line will start at the same indentation as the current one. On the other hand, if the value of \var{WRAP_INDENTS} is zero, the new line will begin in the first column. \done \function{del} \synopsis{Delete the character at the current editing position} \usage{Void del ()} \description The \var{del} function deletes the character at the current editing position. If the position is at the end of the buffer, nothing happens. If the deletion occurs at the end of a line, the next line will be joined with the current one. \seealso{eobp, erase_buffer, insert} \done \function{del_region} \synopsis{Delete the region} \usage{Void del_region ()} \description This function deletes the region defined by the mark and the current editing point. For example, #v+ define delete_this_line () { bol (); push_mark (); eol (); del_region (); } #v- defines a function that deletes all characters on the current line from the beginning of the line until the end of the line. It does not delete the line itself. \seealso{push_mark, markp, check_region} \done \function{erase_buffer} \synopsis{Erase all text from the current buffer} \usage{erase_buffer ()} \description The \var{erase_buffer} function erases all text from the current buffer. However, it does not delete the buffer itself. Note: This function destroys all undo information associated with the buffer making it impossible to undo the result of this function. \seealso{delbuf, del} \done \function{indent_line} \synopsis{Indent the current line (using the \var{indent_hook})} \usage{Void indent_line ()} \description The \var{indent_line} line function indents the current line in a manner which depends upon the current buffer. The actual function that gets called is set via a prior call the \var{set_buffer_hook} to set the indent hook. The default value is to indent the line to the indentation level of the previous line. \seealso{set_buffer_hook} \done \function{insbuf} \synopsis{Insert buffer "buf" into the current buffer} \usage{Void insbuf (String buf)} \description This function may be used to insert the contents of a buffer specified by the name \var{buf} into the current buffer. The editing position is advanced to the end of the insertion. \seealso{copy_region, narrow, narrow_to_region} \done \function{insert} \synopsis{Insert string "str" into buffer at the current position} \usage{Void insert (String str)} \description Inserts string \var{str} into buffer at the current position. The editing point is moved to the end of the of the string that was inserted. \seealso{insert_char, del, insert_file, insbuf} \done \function{insert_char} \synopsis{Insert a character at the current position} \usage{Void insert_char (ULong_Type ch)} \description This function inserts the specified character into the buffer. \seealso{what_char, insert, insert_byte} \done \function{insert_byte} \synopsis{Insert a byte into the buffer} \usage{Void insert_byte (UChar_Type ch)} \description This function inserts the specified byte into the buffer at the current position. \seealso{what_char, insert_char, insert} \done \function{insert_file_region} \synopsis{Insert a region of the file "file"} \usage{Integer insert_file_region (String file, String beg, String end)} \description This function may be used to insert a region specified by the strings \var{beg} and \var{end} of the file with name \var{file} into the current buffer. The file is scanned line by line until a line that begins with the string given by \var{beg} is encountered. Then, that line and all successive lines up to the one that starts with the string specified by \var{end} is inserted into the buffer. The line beginning with the value of \var{end} is not inserted although the one beginning with \var{beg} is. The function returns the number of lines inserted or \exmp{-1} upon failure to open the file. Note that a zero length \var{beg} corresponds to the first line and that a zero length \var{end} corresponds to the last line. \seealso{insert_file} \done \function{insert_from_kill_array} \synopsis{Insert the contents of element "n" of the kill array} \usage{Void insert_from_kill_array (Integer n)} \description This function inserts the contents of the nth element, specified by \var{n}, of an internal array of character strings. Note: This function is not available on 16 bit systems. \seealso{insert_from_kill_array, copy_region_to_kill_array} \seealso{KILL_ARRAY_SIZE} \done \function{trim} \synopsis{Remove all whitespace around the current editing point} \usage{Void trim ()} \description The \var{trim} function removes all whitespace around the current editing point. In this context, whitespace is considered to be any combination of tab and space characters. In particular, it does not include the newline character. This means that the \var{trim} function will not delete across lines. \seealso{skip_chars, skip_white, del, del_region} \done \function{whitespace} \synopsis{Insert white space of length "n"} \usage{whitespace (Integer n)} \description The \var{whitespace} function inserts white space of length \var{n} into the current buffer using a combination of spaces and tabs. The actual combination of spaces and tabs used depends upon the buffer local variable \var{TAB}. In particular, if \var{TAB} is zero, no tab characters will be used for the expansion. \seealso{insert, trim, goto_column} \seealso{TAB,TAB_DEFAULT} \done jed-0.99-19/doc/tm/rtl/rect.tm0000644002657400265740000000407111311317447014761 0ustar davisdavis\function{Replace all text in the rectangle by spaces} \synopsis{Replace the rectangle defined by point and mark with spaces} \usage{Void blank_rect ()} \description The \var{blank_rect} function replaces all text in the rectangle defined by the current editing point and the mark by spaces. \seealso{push_mark, kill_rect, insert_rect, copy_rect} \done \function{copy_rect} \synopsis{Copy the contents of the rectangle to the rectangle buffer} \usage{Void copy_rect ()} \description The \var{copy_rect} function is used to copy the contents of the currently defined rectangle to the rectangle buffer. It overwrites the previous contents of the rectangle buffer. A rectangle is defined by the diagonal formed by the mark and the current point. \seealso{insert_rect, kill_rect, blank_rect} \done \function{insert_rect} \synopsis{Insert the contents of the rectangle buffer} \usage{insert_rect ()} \description The \var{insert_rect} function inserts the contents of the rectangle buffer at the current editing point. The rectangle buffer is not modified. Any text that the rectangle would overwrite is moved to the right by an amount that is equal to the width of the rectangle. \seealso{kill_rect, blank_rect, copy_rect} \done \function{kill_rect} \synopsis{Delete the rectangle and place a copy in the rectangle buffer} \usage{Void kill_rect ()} \description This function deletes the rectangle defined by the mark and the current point. The contents of the rectangle are saved in the rectangle buffer for later retrieval via the \var{insert_rect} function. The previous contents of the rectangle buffer will be lost. \seealso{insert_rect, blank_rect, copy_rect} \done \function{open_rect} \synopsis{Insert a blank rectangle determined by mark and point} \usage{Void open_rect ()} \description The \var{open_rect} function may be used to insert a blank rectangle whose size is determined by the mark and the current editing point. Any text that lies in the region of the rectangle will be pushed to the right. \seealso{insert_rect, kill_rect, copy_rect} \done jed-0.99-19/doc/tm/rtl/mouse.tm0000644002657400265740000000754511311317447015165 0ustar davisdavis\function{gpm_disable_mouse} \synopsis{Disable support for the GPM mouse} \usage{gpm_disable_mouse ()} \description The \var{gpm_disable_mouse} function may be used to inactivate support for the GPM mouse. \notes This function may not be available on all systems. \seealso{mouse_get_event_info} \done \function{mouse_get_event_info} \synopsis{Return information about the last processed mouse event} \usage{(x, y, state) = mouse_get_event_info ()} \description This function returns the position of the last processed mouse event, and the state of the mouse buttons and shift keys before the event. \var{x} and \var{y} represent the column and row, respectively, where the event took place. They are measured with relative to the top left corner of the editor's display. \var{state} is a bitmapped integer whose bits are defined as follows: #v+ 1 Left button pressed 2 Middle button pressed 4 Right button pressed 8 Shift key pressed 16 Ctrl key pressed #v- Other information such as the button that triggered the event is available when the mouse handler is called. As a result, this information is not returned by \var{mouse_get_event_info}. \seealso{mouse_set_default_hook, set_buffer_hook.} \done \function{mouse_map_buttons} \synopsis{Map one mouse button to another} \usage{Void mouse_map_buttons (Integer x, Integer y)} \description This function may be used to map one mouse button to another. The button represented by \var{x} will appear as \var{y}. \done \function{mouse_set_current_window} \synopsis{Change to the window to that of the the mouse event} \usage{Void mouse_set_current_window ()} \description Use of this function results in changing windows to the window that was current at the time of the mouse event. \seealso{mouse_set_default_hook} \done \function{mouse_set_default_hook} \synopsis{Associate a function "fun" with the mouse event "name"} \usage{Void set_default_mouse_hook (String name, String fun)} \description This function associates a slang function \var{fun} with the mouse event specified by \var{name}. The first parameter \var{name} must be one of the following: #v+ "mouse_up" "mouse_status_up" "mouse_down" "mouse_status_down" "mouse_drag" "mouse_status_drag" "mouse_2click" "mouse_status_2click" "mouse_3click" "mouse_status_3click" #v- The meaning of these names should be obvious. The second parameter, \var{fun} must be defined as #v+ define fun (line, column, btn, shift) #v- and it must return an integer. The parameters \var{line} and \var{column} correspond to the line and column numbers in the buffer where the event took place. \var{btn} is an integer that corresonds to the button triggering the event. It can take on values \var{1}, \var{2}, and \var{4} corresponding to the left, middle, and right buttons, respectively. \var{shift} can take on values \exmp{0}, \var{1}, or \var{2} where \exmp{0} indicates that no modifier key was pressed, \var{1} indicates that the SHIFT key was pressed, and \var{2} indicates that the CTRL key was pressed. For more detailed information about the modifier keys, use the function \var{mouse_get_event_info}. When the hook is called, the editor will automatically change to the window where the event occured. The return value of the hook is used to dictate whether or not hook handled the event or whether the editor should switch back to the window prior to the event. Specifically, the return value is interpreted as follows: #v+ -1 Event not handled, pass to default hook. 0 Event handled, return active window prior to event 1 Event handled, stay in current window. #v- \seealso{mouse_get_event_info, mouse_set_current_window, set_buffer_hook} \done jed-0.99-19/doc/tm/rtl/tm-sort.sl0000755002657400265740000000475411311317447015442 0ustar davisdavis#! /usr/bin/env slsh _debug_info = 1; if (__argc < 2) { () = fprintf (stderr, "Usage: %s files....\n", __argv[0]); exit (1); } static variable Data; static define init () { Data = Assoc_Type[String_Type]; } static define warning () { variable args = __pop_args (_NARGS); () = fprintf (stderr, "***WARNING: %s\n", sprintf (__push_args ())); } static define process_function (line, fp) { variable fname; variable lines; fname = strtrim (strtok (line, "{}")[1]); lines = line; #iftrue foreach (fp) { line = (); lines = strcat (lines, line); if (0 == strncmp ("\\done", line, 5)) break; } #else while (-1 != fgets (&line, fp)) { lines += line; if (0 == strncmp ("\\done", line, 5)) break; } #endif if (assoc_key_exists (Data, fname)) { warning ("Key %s already exists", fname); return -1; } Data[fname] = lines; return 0; } static define process_variable (line, fp) { % warning ("process_variable not implemented"); process_function (line, fp); } static define read_file_contents (file) { variable fp = fopen (file, "r"); variable n = 0; variable line; if (fp == NULL) { () = fprintf (stderr, "Unable to open %s\n", file); return -1; } %while (-1 != fgets (&line, fp)) foreach (fp) { line = (); if (0 == strncmp (line, "\\function{", 10)) { if (-1 == process_function (line, fp)) return -1; continue; } if (0 == strncmp (line, "\\variable{", 10)) { if (-1 == process_variable (line, fp)) return -1; continue; } } () = fclose (fp); return 0; } static define sort_and_write_file_elements (file) { variable fp; variable i, keys; variable backup_file; backup_file = file + ".BAK"; () = remove (backup_file); () = rename (file, backup_file); fp = fopen (file, "w"); if (fp == NULL) return -1; keys = assoc_get_keys (Data); i = array_sort (keys, &strcmp); foreach (keys[i]) { variable k = (); () = fputs (Data[k], fp); () = fputs ("\n", fp); } () = fclose (fp); return 0; } static define process_file (file) { init (); () = fprintf (stdout, "Processing %s ...", file); () = fflush (stdout); if (-1 == read_file_contents (file)) return -1; if (-1 == sort_and_write_file_elements (file)) return -1; () = fputs ("done.\n", stdout); return 0; } foreach (__argv[[1:]]) process_file (); exit (0); jed-0.99-19/doc/tm/rtl/file.tm0000644002657400265740000001765611311317447014760 0ustar davisdavis\variable{BACKUP_BY_COPYING} \synopsis{Set the backup mode} \usage{Int_Type BACKUP_BY_COPYING} \description If non-zero, backup files will be made by copying the original file to the backup file. If zero, the backup file will be created by renaming the original file to the backup file. The default for \var{BACKUP_BY_COPYING} is zero because it is fastest. \seealso{rename_file, copy_file} \done \function{IsHPFSFileSystem} \synopsis{Test if drive of "path" is HPFS} \usage{Int_Type IsHPFSFileSystem(String_Type path)} \description Returns non-zero if drive of \var{path} (possibly the default drive) is HPFS. \done \function{change_default_dir} \synopsis{Change the current working directory} \usage{Int_Type change_default_dir (String_Type new_dir)} \description This function may be used to change the current working directory of the editor to \var{new_dir}. It returns zero upon success or \exmp{-1} upon failure. Note: Each buffer has its own working directory. This function does not change the working directory of the buffer. Rather, it changes the working directory of the whole editor. This has an effect on functions such as \var{rename_file} when such functions are passed relative filenames. \seealso{setbuf_info, getbuf_info, rename_file} \done \function{copy_file} \synopsis{Copy a file "src" to "dest"} \usage{Int_Type copy_file (String_Type src, String_Type dest)} \description This function may be used to copy a file named \var{src} to a new file named \var{dest}. It attempts to preserve the file access and modification times as well as the ownership and protection. It returns \exmp{0} upon success and \exmp{-1} upon failure. \seealso{rename_file, file_status} \done \function{delete_file} \synopsis{Delete the file "file"} \usage{Int_Type delete_file (String_Type file)} \description This function may be used to delete a file specified by the \var{file} parameter. It returns non-zero if the file was sucessfully deleted or zero otherwise. \seealso{rmdir} \done \function{directory} \synopsis{Return number of files and list of files matching filename} \description returns the number of files and a list of files which match filename. On unix, this defaults to filename*. It is primarily useful for DOS and VMS to expand wildcard filenames \done \function{expand_filename} \synopsis{Expand a file name to a canonical form} \usage{String_Type expand_filename (String_Type file)} \description The \var{expand_filename} function expands a file to a canonical form. For example, under Unix, if \var{file} has the value \exmp{"/a/b/../c/d"}, it returns \exmp{"/a/c/d"}. Similarly, if \var{file} has the value \exmp{"/a/b/c//d/e"}, \exmp{"/d/e"} is returned. \seealso{expand_symlink, path_concat} \done \function{expand_symlink} \synopsis{Expand a symbolic link} \usage{String_Type expand_symlink (String_Type pathname)} \description The \var{expand_symlink} is like the \var{expand_filename} function except that it also expands components of the pathname that are symbolic links. \seealso{expand_filename, path_concat, readlink} \done \function{extract_filename} \synopsis{Separate the file name from "filespec"} \usage{String_Type extract_filename (String_Type filespec)} \description This function may be used to separate the file name from the path of of a file specified by \var{filespec}. For example, under Unix, the expression #v+ extract_filename ("/tmp/name"); #v- returns the string \exmp{"name"}. \seealso{expand_filename} \done \function{file_changed_on_disk} \synopsis{Test if file "fn" is more recent than the current buffer} \usage{Int_Type file_changed_on_disk (String_Type fn)} \description This function may be used to determine if the disk file specified by the parameter \var{fn} is more recent than the current buffer. \seealso{file_time_compare, check_buffers} \done \function{file_status} \synopsis{Return information about file "filename"} \usage{Int_Type file_status (String_Type filename)} \description The \var{file_status} function returns information about a file specified by the name \var{filename}. It returns an integer describing the file type: 2 file is a directory 1 file exists and is not a directory 0 file does not exist. -1 no access. -2 path invalid -3 unknown error \done \function{file_time_compare} \synopsis{Compares the modification times of two files} \usage{Int_Type file_time_cmp (String_Type file1, String_Type file2)} \description This function compares the modification times of two files, \var{file1} and \var{file2}. It returns an integer that is either positive, negative, or zero integer for \exmp{file1 > file2}, \exmp{file1 < file2}, or \exmp{file1 == file2}, respectively. In this context, the comparison operators are comparing file modification times. That is, the operator \exmp{>} should be read ``is more recent than''. The convention adopted by this routine is that if a file does not exist, its modification time is taken to be at the beginning of time. Thus, if \var{f} exists, but \var{g} does not, the \exmp{file_time_compare (f, g)} will return a positive number. \seealso{file_status, time} \done \function{find_file} \synopsis{Open the file "name" in a buffer (or just goto buffer)} \usage{Int_Type find_file (String_Type name)} \description The \var{find_file} function switches to the buffer associated with the file specified by \var{name}. If no such buffer exists, one is created and the file specified by \var{name} is read from the disk and associated with the new buffer. The buffer will also become attached to the current window. Use the \var{read_file} function to find a file but not associate it with the current window. \seealso{read_file} \done \function{insert_file} \synopsis{Insert a file "f" into the current buffer} \usage{Int_Type insert_file (String_Type f)} \description This function may be used to insert the contents of a file named \var{f} into the buffer at the current position. The current editing point will be placed at the end of the inserted text. The function returns \exmp{-1} if the file was unable to be opened; otherwise it returns the number of lines inserted. This number can be zero if the file is empty. \seealso{read_file, find_file, insert} \done \function{msdos_fixup_dirspec} \synopsis{remove trailing backslash from "dir"} \usage{String_Type msdos_fixup_dirspec (String_Type dir)} \description The motivation behind this is that DOS does not like a trailing backslash except if it is for the root dir. This function makes \var{dir} conform to that. \done \function{read_file} \synopsis{Read file "fn" but don't open in a window} \usage{Int_Type read_file (string fn)} \description The \var{read_file} function may be used to read a file specified by \var{fn} into its own buffer. It returns a non-zero value upon success and signals an error upon failure. The hook \var{find_file_hook} is called after the file is read in. Unlike the related function, \var{find_file}, this function does not create a window for the newly created buffer. \seealso{find_file, file_status, write_buffer} \done \function{rename_file} \synopsis{Change the name of a file} \usage{Int_Type rename_file (String_Type old_name, String_Type new_name)} \description This function may be used to change the name of a disk file from \var{old_name} to \var{new_name}. Upon success, zero is returned. Any other value indicates failure. Note: Both filenames must refer to the same file system. \seealso{file_status, stat_file} \done \function{set_file_translation} \synopsis{Set the way the next file is opened: 1 binary, 0 text mode} \usage{set_file_translation (Int_Type n)} \description This function affects only the way the next file is opened. Its affect does not last beyond that. If it the value of the parameter is 1, the next file will be opened in binary mode. If the parameter is zero, the file will be opened in text mode. \done jed-0.99-19/doc/tm/rtl/window.tm0000644002657400265740000003051211311317447015332 0ustar davisdavis\variable{BLINK} \synopsis{Set whether or not parentheses will be blinked} \usage{Int_Type BLINK} \description The \var{BLINK} variable controls whether or not matching parenthesis are blinked upon the insertion of a closing parenthesis. If its value is non-zero, the matching parenthesis will be blinked; otherwise, it will not. \done \variable{DISPLAY_EIGHT_BIT} \synopsis{Set the display mode for eight-bit characters} \usage{Int_Type DISPLAY_EIGHT_BIT} \description This variable determines how characters with the high bit set are to be displayed. Specifically, any character whose value is greater than or equal to the value of \var{DISPLAY_EIGHT_BIT} is output to the terminal as is. Characters with the high bit set but less than this value are sent to the terminal in a multiple character representation. For Unix and VMS systems the value should be set to 160. This is because many terminals use the characters with values between 128 and 160 as eight bit control characters. For other systems, it can be set to zero. \seealso{META_CHAR} \done \variable{DISPLAY_TIME} \synopsis{Control the display of the current time} \usage{Int_Type DISPLAY_TIME} \description If this variable is non-zero, the current time will be displayed on the status line if the format for the status line permits it. If it is zero, the time will not be displayed even if the \exmp{%t} format string is part of the status line format. \seealso{set_status_line} \done \variable{DOLLAR_CHARACTER} \synopsis{The line continuation character} \usage{Int_Type DOLLAR_CHARACTER = '$'} \description The character represented by \var{DOLLAR_CHARACTER} is used to indicate that text extends beyond the borders of the window. This character is traditionally a dollar sign. If the value of \var{DOLLAR_CHARACTER} is 0, no character will be used for this indicator. \seealso{set_color} \done \variable{HIGHLIGHT} \synopsis{Turn on/off region highlighting} \usage{Int_Type HIGHLIGHT} \description If this variable is non-zero, marked regions will be highlighted. \seealso{WANT_SYNTAX_HIGHLIGHT, set_color} \done \variable{HORIZONTAL_PAN} \synopsis{Set the horizontal panning mode} \usage{Int_Type HORIZONTAL_PAN} \description If the value of this variable is non-zero, the window wil pan when the cursor goes outside the border of the window. More precisely, if the value is less than zero, the entire window will pan. If the value is positive, only the current line will pan. The absolute value of the number determines the panning increment. \seealso{SCREEN_WIDTH} \done \variable{LINENUMBERS} \synopsis{Enable the display of line or column numbers} \usage{Int_Type LINENUMBERS} \description The \var{LINENUMBERS} variable determines whether or not line or column numbers will be displayed on the status line. If the value of \var{LINENUMBERS} is \0, then neither the line nor column number information will be displayed. If \var{LINENUMBERS} is set to \1, then the current line number will be displayed but column numbers will not be. If \var{LINENUMBERS} is \2, the both line a column numbers will be displayed. \seealso{set_status_line} \done \variable{Simulate_Graphic_Chars} \synopsis{Specifies whether or not graphic characters are to be used} \usage{Int_Type Simulate_Graphic_Chars} \description If the value of this variable is non-zero, graphic characters will be simulated by simple ascii characters instead of trying to use the terminal's alternate character set. \notes This variable is not available on all platforms. \done \variable{Status_Line_String} \synopsis{The string used for the status line} \usage{String_Type Status_Line_String} \description \var{Status_Line_String} is a read-only string variable that specifies the format of the status line for newly created buffers. To set the status line format, use the function \var{set_status_line}. \seealso{set_status_line} \done \variable{TAB} \synopsis{Set the current buffer TAB width} \usage{Int_Type TAB} \description This variable controls the tab width associated with the current buffer. A value of zero means that tab characters are not expanded and that tabs are never used to produce whitespace. \seealso{TAB_DEFAULT, USE_TABS} \done \variable{TAB_DEFAULT} \synopsis{Set the default tab width} \usage{Int_Type TAB_DEFAULT} \description The value of \var{TAB_DEFAULT} is the default tab setting given to all newly created buffers. A value of zero means that tab characters are not expanded and that tabs are never used to produce whitespace. \notes A related variable \var{TAB} may be used to change the current buffer's tab setting. \seealso{TAB, USE_TABS, TAB_DEFAULT} \done \variable{TOP_WINDOW_ROW} \synopsis{Top window's starting row} \usage{Int_Type} \description This read-only variable gives the value of the starting row of the top window. If a menubar is present, the value will be \2, otherwise it will be \1. \seealso{enable_top_status_line, window_info} \done \variable{WANT_EOB} \synopsis{Control the display of the end of buffer indicator} \usage{Int_Type} \description If this value of this variable is non-zero, the end of buffer indicator \exmp{"[EOB]"} will be displayed at the end of the buffer. Such an indicator is used for various editor emulations such as the VAX/VMS EDT editor. \done \variable{WANT_SYNTAX_HIGHLIGHT} \synopsis{Enable or disable syntax highlighting} \usage{Int_Type WANT_SYNTAX_HIGHLIGHT} \description If the value of this variable is non-zero, syntax highlighting will be enabled. Otherwise, syntax highlighting will be turned off. \seealso{HIGHLIGHT, set_color} \done \function{blink_match} \synopsis{Blink the matching delimiter} \usage{Void blink_match ();} \description This function will attempt to blink the matching delimiter immediately before the editing point. \seealso{find_matching_delimiter, define_syntax} \done \function{enlargewin} \synopsis{Increase the size of the current window} \usage{Void enlargewin ()} \description This function increases the size of the current window by one line by adjusting the size of the other windows accordingly. \seealso{window_info, onewindow} \done \function{nwindows} \synopsis{Return the number of windows currently visible} \usage{Integer nwindows ();} \description The \var{nwindows} function returns the number of windows currently visible. If the variable \var{MINIBUFFER_ACTIVE} is non-zero, the minibuffer is busy and contributes to the number of windows. \seealso{splitwindow, onewindow, window_size} \seealso{MINIBUFFER_ACTIVE} \done \function{onewindow} \synopsis{Make current window the only one} \usage{Void onewindow ();} \description This function deletes all other windows except the current window and the mini-buffer window. \seealso{nwindows, splitwindow, enlargewin} \seealso{MINIBUFFER_ACTIVE} \done \function{otherwindow} \synopsis{Make the next window the default window} \usage{Void otherwindow ()} \description This function will make the next window in the ring of windows as the default window. For example, #v+ define zoom_next_window () { otherwindow (); onewindow (); } #v- defines a function that moves to the next window and then makes it the only window on the screen. \seealso{nwindows, onewindow} \seealso{MINIBUFFER_ACTIVE} \done \function{recenter} \synopsis{Scroll the window to make the "nth" line contain the current line} \usage{Void recenter (Integer nth);} \description This function may be used to scroll the window such that the \var{nth} line of the window contains the current line. If \var{nth} is zero, the current line will be placed at the center of the window and the screen will be completely redrawn. \seealso{nwindows, window_info} \done \function{set_status_line} \synopsis{Customize the status line of the current window} \usage{set_status_line (String format, Integer flag)} \description This function may be used to customize the status line of the current window according to the string \var{format}. If the second parameter \var{flag} is non-zero, \var{format} will apply to the global format string; otherwise it applies to current buffer only. Newly created buffer inherit the global format string when they appear in a window. The format string may contain the following format specifiers: #v+ %b buffer name %f file name (without the directory part) %F file name with directory %v JED version %t current time --- only used if variable DISPLAY_TIME is non-zero %p line number or percent string. If LINENUMBERS is 2, this expands to "line number,column number" %c column number %% literal '%' character %m mode string %a If abbrev mode, expands to "abbrev" %n If buffer is narrowed, expands to "Narrow" %o If overwrite mode, expands to "Ovwrt" %O Overwrite/Insert flag - like %o, but shows INS/OVR %l Shows current line number %L Shows number of lines in the file #v- For example, the default status line used by JED's EDT emulation uses the format string: #v+ "(Jed %v) EDT: %b (%m%a%n%o) %p,%c Advance %t" #v- \seealso{set_mode, narrow, whatbuf, getbuf_info} \seealso{DISPLAY_TIME,LINENUMBERS, Global_Top_Status_Line, Status_Line_String} \done \function{splitwindow} \synopsis{Split the current window vertically} \usage{Void splitwindow ();} \description This function splits the current window vertically creating another window that carries the current window's buffer. \seealso{onewindow, enlargewin, window_info} \done \function{update} \synopsis{Update the display} \usage{Void update (Integer f);} \description This function may be called to update the display. If the parameter \var{f} is non-zero, the display will be updated even if there is input pending. If \var{f} is zero, the display may only be partially updated if input is pending. \seealso{input_pending, flush} \done \function{update_sans_update_hook} \synopsis{Update the display without running the update hooks} \usage{update_sans_update_hook (Int_Type force)} \description The \var{update_sans_update_hook} function performs the same function as \var{update}, except that the buffer's update hook will not be run. See \var{update} for more information. \seealso{update, set_buffer_hook, unset_buffer_hook} \done \function{w132} \synopsis{Set the number of columns on a vtxxx compatable terminal to 132.} \usage{Void w132 ()} \description This function may be used to set the number of columns on a vtxxx compatable terminal to 132. \seealso{w80, set_term_vtxxx} \done \function{w80} \synopsis{Set the number of columns on a vtxxx compatable terminal to 80} \usage{Void w80 ()} \description This function may be used to set the number of columns on a vtxxx compatable terminal to 80. \seealso{w132, set_term_vtxxx} \done \function{window_info} \synopsis{Return information concerning the current window} \usage{Integer window_info(Integer item);} \description The \var{window_info} function returns information concerning the current window. The actual information that is returned depends on the \var{item} parameter. Acceptable values of \var{item} and the description of the information returned is given in the following table: #v+ 'r' : Number of rows 'w' : Width of window 'c' : Starting column (from 1) 't' : Screen line of top line of window (from 1) #v- \seealso{otherwindow, nwindows} \seealso{SCREEN_HEIGHT,SCREEN_WIDTH} \done \function{window_line} \synopsis{Return the number of rows from the top of the window} \usage{Integer window_line ();} \description This function returns the number of rows from the top of the current window for the current line. If the current line is the very first line in the window, a value of \var{1} will be returned, i.e., it is the first line of the window. \seealso{window_info, nwindows} \seealso{TOP_WINDOW_ROW} \done \function{get_scroll_column} \synopsis{Get the scroll column for the current window} \usage{Int_Type get_scroll_column ()} \description This function returns the scroll column for the current window. \seealso{set_scroll_column} \done \function{set_scroll_column} \synopsis{Set the scroll column for the current window} \usage{set_scroll_column (Int_Type col)} \description This function may be used to set the scroll column of the current window. \seealso{get_scroll_column} \done jed-0.99-19/doc/tm/rtl/menu.tm0000644002657400265740000002325711311317447014777 0ustar davisdavis\function{enable_top_status_line} \synopsis{Set the top_status_line: 1 enabled, 0 hidden} \usage{Void enable_top_status_line (Integer x);} \description If x is non-zero, the top status line is enabled. If x is zero, the top status line is disabled and hidden. \seealso{set_top_status_line} \done \function{menu_append_item} \synopsis{Append an entry to a menu} \usage{menu_append_item (menu, name, fun [,client_data])} #v+ String_Type menu, name; String_Type or Ref_Type fun; Any_Type client_data #v- \description The \var{menu_append_item} function appends a menu item called \var{name} to the menu \var{menu}. If called with \3 arguments, the third argument must be a string that will get executed or called when the menu item is selected. When called with \4 arguments, the \var{fun} argument may be either a string or a reference to a function. When the item is selected, the function will be called and \var{client_data} will be passed to it. \seealso{menu_append_popup} \done \function{menu_append_popup} \synopsis{Append a popup menu to a menu} \usage{menu_append_popup (String_Type parent_menu, String_Type popup_name)} \description The \var{menu_append_popup} function may be used to append a new popup menu with name \var{popup_name} to the menu \var{parent_menu}, which may either be another popup menu or a menu bar. \seealso{menu_append_item, menu_append_separator} \done \function{menu_append_separator} \synopsis{Append a separator to a menu} \usage{menu_append_separator (String_Type menu)} \description The \var{menu_append_separator} function appends a menu item separator to the menu \var{menu}. \seealso{menu_append_item, menu_append_popup} \done \function{menu_copy_menu} \synopsis{Copy a menu to another} \usage{menu_copy_menu (String_Type dest, String_Type src)} \description Then \var{menu_copy_menu} function copies the menu item, which may be another popup menu, to another popup menu. \seealso{menu_append_popup, menu_append_item} \done \function{menu_create_menu_bar} \synopsis{Create a menu bar} \usage{menu_create_menu_bar (String_Type name)} \description The \var{menu_create_menu_bar} function may be used to create a new menu bar called \var{name}. The new menu bar may be associated with a buffer via the \var{menu_use_menu_bar} function. \seealso{menu_use_menu_bar, menu_append_popup} \done \function{menu_delete_item} \synopsis{Delete a menu item} \usage{menu_delete_item (String_Type name)} \description The \var{menu_delete_item} function deletes the menu called \var{name} and all of its submenus. \example To delete the \exmp{System} menu from the global menu bar, use #v+ menu_delete_item ("Global.S&ystem"); #v- \seealso{menu_delete_items} \done \function{menu_delete_items} \synopsis{Delete the items from a menu} \usage{menu_delete_items (String_Type menu)} \description The \var{menu_delete_items} function deletes all the menu items attached to a specified popup menu. However, unlike the related function \var{menu_delete_item}, the popup menu itself will not be removed. \seealso{menu_delete_item, menu_append_popup} \done \function{menu_insert_item} \synopsis{Insert an entry into a menu at a specified position} \usage{menu_insert_item (position, menu, name, fun [,client_data])} #v+ Int_Type/String_Type position; String_Type menu, name; String_Type or Ref_Type fun; Any_Type client_data; #v- \description The \var{menu_insert_item} function inserts a menu item called \var{name} to the menu \var{menu} at a specified position. The insertion position may be specified as an integer, or as the name of a menu item within \var{parent_menu}. When specified as an integer, the insertion will take place at the corresponding position of the menu, where zero denotes the first item. If the position specifier is the name of a menu item, the the insertion will take place before that item. If called with \4 arguments, the third argument must be a string that will get executed or called when the menu item is selected. When called with \5 arguments, the \var{fun} argument may be either a string or a reference to a function. When the item is selected, the function will be called and \var{client_data} will be passed to it. \seealso{menu_append_item, menu_insert_popup, menu_insert_separator} \done \function{menu_insert_popup} \synopsis{Inserts a popup menu into a menu at a specified position} \usage{menu_insert_popup (position, parent_menu, popup_name)} #v+ Int_Type/String_Type position; String_Type parent_menu, popup_name; #v- \description The \var{menu_insert_popup} function will insert a popup menu with name \var{popup_name} into a pre-existing popup menu or menu bar with name given by {parent_menu}. The insertion position may be specified as an integer, or as the name of a menu item within \var{parent_menu}. When specified as an integer, the insertion will take place at the corresponding position of the menu, where zero denotes the first item. If the position specifier is the name of a menu item, the the insertion will take place before that item. \seealso{menu_append_popup, menu_insert_item, menu_insert_separator} \done \function{menu_insert_separator} \synopsis{Inserts a separator into a menu at a specified position} \usage{menu_insert_separator (position, parent_menu)} #v+ Int_Type/String_Type position; String_Type parent_menu; #v- \description The \var{menu_insert_separator} function inserts a separator into a pre-existing popup menu or menu bar with name given by \var{parent_menu}. The insertion position may be specified as an integer, or as the name of a menu item within \var{parent_menu}. When specified as an integer, the insertion will take place at the corresponding position of the menu, where zero denotes the first item. If the position specifier is the name of a menu item, the the insertion will take place before that item. \seealso{menu_append_separator, menu_insert_item, menu_insert_popup} \done \function{menu_select_menu} \synopsis{Select a menu item} \usage{menu_select_menu (String_Type menu)} \description This function allows interpreter access to a specified menu it. If the parameter specifies a popup menu, then the corresponding menu will be invoked. Otherwise the function bound to the specified menu will be called. \example menu_select_menu ("Global.&File"); menu_select_menu ("Global.&File.Save &Buffers"); \seealso{menu_insert_item} \done \function{menu_set_init_menubar_callback} \synopsis{Set the initialize menu bar callback} \usage{menu_set_init_menubar_callback (Ref_Type cb)} \description The \var{menu_set_init_menubar_callback} may be used to specify the function that is to be called whenever a menu bar may need to be updated. This may be necessary when the user switches buffers or modes. The callback function must accept a single argument which is the name of the menubar. \seealso{menu_set_select_menubar_callback, menu_create_menu_bar} \done \function{menu_set_menu_bar_prefix} \synopsis{Set the prefix string to be displayed on the menu bar} \usage{menu_set_menu_bar_prefix (String_Type menubar, String_Type prefix)} \description The \var{menu_set_menu_bar_prefix} specifies the string that is to be displayed on the specified menu bar. The default prefix is \exmp{"F10 key ==> "}. \seealso{menu_create_menu_bar} \done \function{menu_set_object_available} \synopsis{Set the availablity of a menu item} \usage{menu_set_object_available (String_Type menuitem, Int_Type flag)} \description The \var{menu_set_object_available} function may be used to activate or inactivate the specified menu item, depending upon whether \var{flag} is non-zero or zero, respectively. \seealso{menu_append_item} \done \function{menu_set_select_menubar_callback} \synopsis{Set the function to be called when the menu bar is activated} \usage{menu_set_select_menubar_callback (String_Type menubar, Ref_Type f)} \description The \var{menu_set_select_menubar_callback} function is used to indicate that the function whose reference is \var{f} should be called whenever the menu bar is selected. The callback function is called with one argument: the name of the menu bar. \seealso{menu_set_init_menubar_callback, menu_set_select_popup_callback} \done \function{menu_set_select_popup_callback} \synopsis{Specify the function to be called prior to a popup} \usage{menu_set_select_popup_callback (String_Type popup, Ref_Type f} \description The \var{menu_set_select_popup_callback} function may be used to specify a function that should be called just before a popup menu is displayed. The callback function must be defined to take a single argument, namely the name of the popup menu. The basic purpose of this function is to allow the creation of a dynamic popup menu. For this reason, the popup menu will have its items deleted before the callback function is executed. \seealso{menu_set_select_menubar_callback, menu_append_item} \done \function{menu_use_menu_bar} \synopsis{Associate a menu bar with the current buffer} \usage{menu_use_menu_bar (String_Type menubar)} \description The \var{menu_use_menu_bar} function may be used to associate a specified menu bar with the current buffer. If no menu bar has been associated with a buffer, the \exmp{"Global"} menu bar will be used. \seealso{menu_create_menu_bar} \done \function{set_top_status_line} \synopsis{Set the string to be displayed at the top of the display} \usage{String set_top_status_line (String str);} \description This functions sets the string to be displayed at the top of the display. It returns the value of the line that was previously displayed. \seealso{enable_top_status_line} \done jed-0.99-19/doc/tm/README0000644002657400265740000000112111311317447013532 0ustar davisdavisThe .tm files in this directory form the source for documentation of jed specific intrinsic functions and variables. The Makefile produces documentation in a variety formats via SGML-Tools. The documentation for the library functions (jed/lib/*.sl) are actually in the .sl files themselves. The documentation is stripped via sl2tm and then processed via tm2txt. Both these programs may be found in the slang distribution (slang/doc/tm/tools/). To produce .sgml files from the .tm source, you will need to install the text-macro distribution. See http://www.jedsoft.org/ for availablity. jed-0.99-19/doc/tm/Makefile0000644002657400265740000000244311311317447014322 0ustar davisdavis# -*- sh -*- # To create the SGML files, you will need to install the tmexpand # package. See http://www.jedsoft.org/ for more information. # TMEXPAND = tmexpand TM2SGML = $(TMEXPAND) TM2HLP = $(TMEXPAND) -Mslhlp DOCBOOK2MAN = docbook2man FILES = jedfuns libfuns # quickref SL_LIBDIR = ../../lib HLP_FILES = jedfuns.hlp libfuns.hlp TM_FILES = $(addsuffix .tm,$(FILES)) SGML_FILES = $(addsuffix .sgml,$(FILES)) HTML_FILES = $(addsuffix .html,$(FILES)) TXT_FILES = $(addsuffix .txt,$(FILES)) TEX_FILES = $(addsuffix .tex,$(FILES)) RM = /bin/rm MV = /bin/mv CP = /bin/cp SGML2LATEX = sgml2latex SGML2HTML = sgml2html SGML2TXT = sgml2txt -f SL2TM = sl2tm help: jedfuns.hlp libfuns.hlp all: $(HTML_FILES) $(TEX_FILES) jedfuns.hlp : rtl/*.tm cat rtl/*.tm | $(TM2HLP) - jedfuns.hlp libfuns.hlp : $(SL_LIBDIR)/*.sl $(SL2TM) -sl $(SL_LIBDIR)/*.sl | $(TM2HLP) - libfuns.hlp jed.1: jed.sgml $(DOCBOOK2MAN) jed.sgml jed.sgml: jed.tm $(TM2SGML) -I$(MACRODIR) jed.tm jed.sgml view: jed.1 nroff -man jed.1 | most # %.tex : %.sgml $(SGML2LATEX) $*.sgml %.html : %.sgml $(SGML2HTML) $*.sgml %.txt : %.sgml $(SGML2TXT) $*.sgml %.sgml : %.tm $(TM2SGML) -I$(MACRODIR) $*.tm $@ < /dev/null install: $(HLP_FILES) $(CP) $(HLP_FILES) ../hlp clean: -rm -f *~ *.dvi *.log *.aux *.toc rtl/*.BAK rtl/*~ *.html *.txt *.hlp jed-0.99-19/INSTALL0000644002657400265740000000434511311317447012531 0ustar davisdavisBefore reading this, read the appropriate install file for you system, e.g., INSTALL.unx. For MSDOS, WINDOWS, or OS/2, read INSTALL.pc. This file contains hints for customizing jed in such a way that it is easy to upgrade to later releases. When jed starts up, it loads the file `site.sl' which is located in the lib directory under $JED_ROOT. This file contains much of the code that defines the look of the editor. For instance, it defines how the command line parameters are to be interpreted and the name of the user's personal initialization file. One could always edit site.sl and tailor it to the needs of a given system. However, one would have to do this with every upgrade. There is a better way. Immediately after loading site.sl, the editor will attempt to load a file called `defaults.sl' from $JED_ROOT/lib. If it fails to find such a file, then on Unix systems it will look a file called jed.conf in /etc/, /usr/local/etc/, and finally in /usr/etc/. This file is not distributed with jed. It is up to the installer to create this file if that is the desire. Two examples are provided: lib/jed.conf, and lib/linux.sl. What is this file used for? It is used to modify site.sl. Since site.sl is written in S-Lang, any of the functions defined in it can simply be redefined by creating new ones. The same is true for the variables that it defines. For example, many systems have a directory where info files are kept. Let's assume that this directory is `/usr/info'. Then one should point the `Info_Directory' variable defined by `site.sl' to this directory: % defaults.sl Info_Directory = "/usr/info"; It is probably a good idea to copy the files in $JED_ROOT/info to directory where the info files are kept and edit the info DIR file appropriately. Another idea is to take advantage of the fact that jed's info reader has the ability to search along a path list. Simply edit the /usr/info/DIR file and add jed to the tree but leave jed's info files in JED_ROOT/info. Then, use something like: %defaults.sl Info_Directory = strcat ("/usr/info,", Info_Directory); Other things that may be customized include the default emulation and color scheme, e.g., _Jed_Default_Emulation = "ide"; _Jed_Default_Color_Scheme = "blue2"; Enjoy. jed-0.99-19/configure0000755002657400265740000126313211311317447013411 0ustar davisdavis#! /bin/sh # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.61 for Jed 0.99-19. # # Report bugs to . # # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, # 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. # This configure script is free software; the Free Software Foundation # gives unlimited permission to copy, distribute and modify it. ## --------------------- ## ## M4sh Initialization. ## ## --------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then emulate sh NULLCMD=: # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac fi # PATH needs CR # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then echo "#! /bin/sh" >conf$$.sh echo "exit 0" >>conf$$.sh chmod +x conf$$.sh if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then PATH_SEPARATOR=';' else PATH_SEPARATOR=: fi rm -f conf$$.sh fi # Support unset when possible. if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then as_unset=unset else as_unset=false fi # IFS # We need space, tab and new line, in precisely that order. Quoting is # there to prevent editors from complaining about space-tab. # (If _AS_PATH_WALK were called with IFS unset, it would disable word # splitting by setting IFS to empty value.) as_nl=' ' IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. case $0 in *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done IFS=$as_save_IFS ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 { (exit 1); exit 1; } fi # Work around bugs in pre-3.0 UWIN ksh. for as_var in ENV MAIL MAILPATH do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var done PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. for as_var in \ LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \ LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \ LC_TELEPHONE LC_TIME do if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then eval $as_var=C; export $as_var else ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var fi done # Required to use basename. if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi # Name of the executable. as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # CDPATH. $as_unset CDPATH if test "x$CONFIG_SHELL" = x; then if (eval ":") 2>/dev/null; then as_have_required=yes else as_have_required=no fi if test $as_have_required = yes && (eval ": (as_func_return () { (exit \$1) } as_func_success () { as_func_return 0 } as_func_failure () { as_func_return 1 } as_func_ret_success () { return 0 } as_func_ret_failure () { return 1 } exitcode=0 if as_func_success; then : else exitcode=1 echo as_func_success failed. fi if as_func_failure; then exitcode=1 echo as_func_failure succeeded. fi if as_func_ret_success; then : else exitcode=1 echo as_func_ret_success failed. fi if as_func_ret_failure; then exitcode=1 echo as_func_ret_failure succeeded. fi if ( set x; as_func_ret_success y && test x = \"\$1\" ); then : else exitcode=1 echo positional parameters were not saved. fi test \$exitcode = 0) || { (exit 1); exit 1; } ( as_lineno_1=\$LINENO as_lineno_2=\$LINENO test \"x\$as_lineno_1\" != \"x\$as_lineno_2\" && test \"x\`expr \$as_lineno_1 + 1\`\" = \"x\$as_lineno_2\") || { (exit 1); exit 1; } ") 2> /dev/null; then : else as_candidate_shells= as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. case $as_dir in /*) for as_base in sh bash ksh sh5; do as_candidate_shells="$as_candidate_shells $as_dir/$as_base" done;; esac done IFS=$as_save_IFS for as_shell in $as_candidate_shells $SHELL; do # Try only shells that exist, to save several forks. if { test -f "$as_shell" || test -f "$as_shell.exe"; } && { ("$as_shell") 2> /dev/null <<\_ASEOF if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then emulate sh NULLCMD=: # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac fi : _ASEOF }; then CONFIG_SHELL=$as_shell as_have_required=yes if { "$as_shell" 2> /dev/null <<\_ASEOF if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then emulate sh NULLCMD=: # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac fi : (as_func_return () { (exit $1) } as_func_success () { as_func_return 0 } as_func_failure () { as_func_return 1 } as_func_ret_success () { return 0 } as_func_ret_failure () { return 1 } exitcode=0 if as_func_success; then : else exitcode=1 echo as_func_success failed. fi if as_func_failure; then exitcode=1 echo as_func_failure succeeded. fi if as_func_ret_success; then : else exitcode=1 echo as_func_ret_success failed. fi if as_func_ret_failure; then exitcode=1 echo as_func_ret_failure succeeded. fi if ( set x; as_func_ret_success y && test x = "$1" ); then : else exitcode=1 echo positional parameters were not saved. fi test $exitcode = 0) || { (exit 1); exit 1; } ( as_lineno_1=$LINENO as_lineno_2=$LINENO test "x$as_lineno_1" != "x$as_lineno_2" && test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2") || { (exit 1); exit 1; } _ASEOF }; then break fi fi done if test "x$CONFIG_SHELL" != x; then for as_var in BASH_ENV ENV do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var done export CONFIG_SHELL exec "$CONFIG_SHELL" "$as_myself" ${1+"$@"} fi if test $as_have_required = no; then echo This script requires a shell more modern than all the echo shells that I found on your system. Please install a echo modern shell, or manually run the script under such a echo shell if you do have one. { (exit 1); exit 1; } fi fi fi (eval "as_func_return () { (exit \$1) } as_func_success () { as_func_return 0 } as_func_failure () { as_func_return 1 } as_func_ret_success () { return 0 } as_func_ret_failure () { return 1 } exitcode=0 if as_func_success; then : else exitcode=1 echo as_func_success failed. fi if as_func_failure; then exitcode=1 echo as_func_failure succeeded. fi if as_func_ret_success; then : else exitcode=1 echo as_func_ret_success failed. fi if as_func_ret_failure; then exitcode=1 echo as_func_ret_failure succeeded. fi if ( set x; as_func_ret_success y && test x = \"\$1\" ); then : else exitcode=1 echo positional parameters were not saved. fi test \$exitcode = 0") || { echo No shell found that supports shell functions. echo Please tell autoconf@gnu.org about your system, echo including any error possibly output before this echo message } as_lineno_1=$LINENO as_lineno_2=$LINENO test "x$as_lineno_1" != "x$as_lineno_2" && test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2" || { # Create $as_me.lineno as a copy of $as_myself, but with $LINENO # uniformly replaced by the line number. The first 'sed' inserts a # line-number line after each line using $LINENO; the second 'sed' # does the real work. The second script uses 'N' to pair each # line-number line with the line containing $LINENO, and appends # trailing '-' during substitution so that $LINENO is not a special # case at line end. # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the # scripts with optimization help from Paolo Bonzini. Blame Lee # E. McMahon (1931-1989) for sed's syntax. :-) sed -n ' p /[$]LINENO/= ' <$as_myself | sed ' s/[$]LINENO.*/&-/ t lineno b :lineno N :loop s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ t loop s/-\n.*// ' >$as_me.lineno && chmod +x "$as_me.lineno" || { echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2 { (exit 1); exit 1; }; } # Don't try to exec as it changes $[0], causing all sort of problems # (the dirname of $[0] is not the place where we might find the # original and so on. Autoconf is especially sensitive to this). . "./$as_me.lineno" # Exit status is that of the last command. exit } if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in -n*) case `echo 'x\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. *) ECHO_C='\c';; esac;; *) ECHO_N='-n';; esac if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir mkdir conf$$.dir fi echo >conf$$.file if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. # In both cases, we have to default to `cp -p'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -p' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -p' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null if mkdir -p . 2>/dev/null; then as_mkdir_p=: else test -d ./-p && rmdir ./-p as_mkdir_p=false fi if test -x / >/dev/null 2>&1; then as_test_x='test -x' else if ls -dL / >/dev/null 2>&1; then as_ls_L_option=L else as_ls_L_option= fi as_test_x=' eval sh -c '\'' if test -d "$1"; then test -d "$1/."; else case $1 in -*)set "./$1";; esac; case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in ???[sx]*):;;*)false;;esac;fi '\'' sh ' fi as_executable_p=$as_test_x # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" exec 7<&0 &1 # Name of the host. # hostname on some systems (SVR3.2, Linux) returns a bogus exit status, # so uname gets run too. ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` # # Initializations. # ac_default_prefix=/usr/local ac_clean_files= ac_config_libobj_dir=. LIBOBJS= cross_compiling=no subdirs= MFLAGS= MAKEFLAGS= SHELL=${CONFIG_SHELL-/bin/sh} # Identity of this package. PACKAGE_NAME='Jed' PACKAGE_TARNAME='jed' PACKAGE_VERSION='0.99-19' PACKAGE_STRING='Jed 0.99-19' PACKAGE_BUGREPORT='jed-users@jedsoft.org' ac_unique_file="src/ledit.c" # Factoring default headers for most tests. ac_includes_default="\ #include #ifdef HAVE_SYS_TYPES_H # include #endif #ifdef HAVE_SYS_STAT_H # include #endif #ifdef STDC_HEADERS # include # include #else # ifdef HAVE_STDLIB_H # include # endif #endif #ifdef HAVE_STRING_H # if !defined STDC_HEADERS && defined HAVE_MEMORY_H # include # endif # include #endif #ifdef HAVE_STRINGS_H # include #endif #ifdef HAVE_INTTYPES_H # include #endif #ifdef HAVE_STDINT_H # include #endif #ifdef HAVE_UNISTD_H # include #endif" ac_subst_vars='RPATH SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datarootdir datadir sysconfdir sharedstatedir localstatedir includedir oldincludedir docdir infodir htmldir dvidir pdfdir psdir libdir localedir mandir DEFS ECHO_C ECHO_N ECHO_T LIBS build_alias host_alias target_alias CONFIG_DIR build build_cpu build_vendor build_os host host_cpu host_vendor host_os SET_MAKE RANLIB INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT CPP GREP EGREP DYNAMIC_LINK_LIB ELF_CC ELF_CFLAGS ELF_LINK ELF_LINK_CMD ELF_DEP_LIBS DYNAMIC_LINK_FLAGS CC_SHARED ELFLIB ELFLIB_MAJOR ELFLIB_MAJOR_MINOR ELFLIB_MAJOR_MINOR_MICRO SLANG_LIB_FOR_MODULES DLL_IMPLIB_NAME INSTALL_MODULE INSTALL_ELFLIB_TARGET ELFLIB_BUILD_NAME SLANG_DLL_CFLAGS M_LIB PKG_CONFIG XMKMF X_CFLAGS X_PRE_LIBS X_LIBS X_EXTRA_LIBS SRCDIR OBJDIR ELFDIR nc5config TERMCAP MISC_TERMINFO_DIRS SLANG_LIB SLANG_INC XRENDERFONTLIBS PKGCONFIG MOUSELIB MOUSEDEFINES MOUSE_O_FILE MOUSE_OBJ_FILE GTK_CFLAGS GTK_LIBS BUILD_GTKJED JED_ROOT LIBOBJS LTLIBOBJS' ac_subst_files='' ac_precious_vars='build_alias host_alias target_alias CC CFLAGS LDFLAGS LIBS CPPFLAGS CPP PKG_CONFIG XMKMF GTK_CFLAGS GTK_LIBS' # Initialize some variables set by options. ac_init_help= ac_init_version=false # The variables have the same names as the options, with # dashes changed to underlines. cache_file=/dev/null exec_prefix=NONE no_create= no_recursion= prefix=NONE program_prefix=NONE program_suffix=NONE program_transform_name=s,x,x, silent= site= srcdir= verbose= x_includes=NONE x_libraries=NONE # Installation directory options. # These are left unexpanded so users can "make install exec_prefix=/foo" # and all the variables that are supposed to be based on exec_prefix # by default will actually change. # Use braces instead of parens because sh, perl, etc. also accept them. # (The list follows the same order as the GNU Coding Standards.) bindir='${exec_prefix}/bin' sbindir='${exec_prefix}/sbin' libexecdir='${exec_prefix}/libexec' datarootdir='${prefix}/share' datadir='${datarootdir}' sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' includedir='${prefix}/include' oldincludedir='/usr/include' docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' infodir='${datarootdir}/info' htmldir='${docdir}' dvidir='${docdir}' pdfdir='${docdir}' psdir='${docdir}' libdir='${exec_prefix}/lib' localedir='${datarootdir}/locale' mandir='${datarootdir}/man' ac_prev= ac_dashdash= for ac_option do # If the previous option needs an argument, assign it. if test -n "$ac_prev"; then eval $ac_prev=\$ac_option ac_prev= continue fi case $ac_option in *=*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; *) ac_optarg=yes ;; esac # Accept the important Cygnus configure options, so we can diagnose typos. case $ac_dashdash$ac_option in --) ac_dashdash=yes ;; -bindir | --bindir | --bindi | --bind | --bin | --bi) ac_prev=bindir ;; -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) bindir=$ac_optarg ;; -build | --build | --buil | --bui | --bu) ac_prev=build_alias ;; -build=* | --build=* | --buil=* | --bui=* | --bu=*) build_alias=$ac_optarg ;; -cache-file | --cache-file | --cache-fil | --cache-fi \ | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) ac_prev=cache_file ;; -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) cache_file=$ac_optarg ;; --config-cache | -C) cache_file=config.cache ;; -datadir | --datadir | --datadi | --datad) ac_prev=datadir ;; -datadir=* | --datadir=* | --datadi=* | --datad=*) datadir=$ac_optarg ;; -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \ | --dataroo | --dataro | --datar) ac_prev=datarootdir ;; -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \ | --dataroot=* | --dataroo=* | --dataro=* | --datar=*) datarootdir=$ac_optarg ;; -disable-* | --disable-*) ac_feature=`expr "x$ac_option" : 'x-*disable-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_feature" : ".*[^-._$as_cr_alnum]" >/dev/null && { echo "$as_me: error: invalid feature name: $ac_feature" >&2 { (exit 1); exit 1; }; } ac_feature=`echo $ac_feature | sed 's/[-.]/_/g'` eval enable_$ac_feature=no ;; -docdir | --docdir | --docdi | --doc | --do) ac_prev=docdir ;; -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*) docdir=$ac_optarg ;; -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv) ac_prev=dvidir ;; -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*) dvidir=$ac_optarg ;; -enable-* | --enable-*) ac_feature=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_feature" : ".*[^-._$as_cr_alnum]" >/dev/null && { echo "$as_me: error: invalid feature name: $ac_feature" >&2 { (exit 1); exit 1; }; } ac_feature=`echo $ac_feature | sed 's/[-.]/_/g'` eval enable_$ac_feature=\$ac_optarg ;; -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ | --exec | --exe | --ex) ac_prev=exec_prefix ;; -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ | --exec=* | --exe=* | --ex=*) exec_prefix=$ac_optarg ;; -gas | --gas | --ga | --g) # Obsolete; use --with-gas. with_gas=yes ;; -help | --help | --hel | --he | -h) ac_init_help=long ;; -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) ac_init_help=recursive ;; -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) ac_init_help=short ;; -host | --host | --hos | --ho) ac_prev=host_alias ;; -host=* | --host=* | --hos=* | --ho=*) host_alias=$ac_optarg ;; -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht) ac_prev=htmldir ;; -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \ | --ht=*) htmldir=$ac_optarg ;; -includedir | --includedir | --includedi | --included | --include \ | --includ | --inclu | --incl | --inc) ac_prev=includedir ;; -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ | --includ=* | --inclu=* | --incl=* | --inc=*) includedir=$ac_optarg ;; -infodir | --infodir | --infodi | --infod | --info | --inf) ac_prev=infodir ;; -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) infodir=$ac_optarg ;; -libdir | --libdir | --libdi | --libd) ac_prev=libdir ;; -libdir=* | --libdir=* | --libdi=* | --libd=*) libdir=$ac_optarg ;; -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ | --libexe | --libex | --libe) ac_prev=libexecdir ;; -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ | --libexe=* | --libex=* | --libe=*) libexecdir=$ac_optarg ;; -localedir | --localedir | --localedi | --localed | --locale) ac_prev=localedir ;; -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*) localedir=$ac_optarg ;; -localstatedir | --localstatedir | --localstatedi | --localstated \ | --localstate | --localstat | --localsta | --localst | --locals) ac_prev=localstatedir ;; -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*) localstatedir=$ac_optarg ;; -mandir | --mandir | --mandi | --mand | --man | --ma | --m) ac_prev=mandir ;; -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) mandir=$ac_optarg ;; -nfp | --nfp | --nf) # Obsolete; use --without-fp. with_fp=no ;; -no-create | --no-create | --no-creat | --no-crea | --no-cre \ | --no-cr | --no-c | -n) no_create=yes ;; -no-recursion | --no-recursion | --no-recursio | --no-recursi \ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) no_recursion=yes ;; -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ | --oldin | --oldi | --old | --ol | --o) ac_prev=oldincludedir ;; -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) oldincludedir=$ac_optarg ;; -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) ac_prev=prefix ;; -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) prefix=$ac_optarg ;; -program-prefix | --program-prefix | --program-prefi | --program-pref \ | --program-pre | --program-pr | --program-p) ac_prev=program_prefix ;; -program-prefix=* | --program-prefix=* | --program-prefi=* \ | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) program_prefix=$ac_optarg ;; -program-suffix | --program-suffix | --program-suffi | --program-suff \ | --program-suf | --program-su | --program-s) ac_prev=program_suffix ;; -program-suffix=* | --program-suffix=* | --program-suffi=* \ | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) program_suffix=$ac_optarg ;; -program-transform-name | --program-transform-name \ | --program-transform-nam | --program-transform-na \ | --program-transform-n | --program-transform- \ | --program-transform | --program-transfor \ | --program-transfo | --program-transf \ | --program-trans | --program-tran \ | --progr-tra | --program-tr | --program-t) ac_prev=program_transform_name ;; -program-transform-name=* | --program-transform-name=* \ | --program-transform-nam=* | --program-transform-na=* \ | --program-transform-n=* | --program-transform-=* \ | --program-transform=* | --program-transfor=* \ | --program-transfo=* | --program-transf=* \ | --program-trans=* | --program-tran=* \ | --progr-tra=* | --program-tr=* | --program-t=*) program_transform_name=$ac_optarg ;; -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd) ac_prev=pdfdir ;; -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*) pdfdir=$ac_optarg ;; -psdir | --psdir | --psdi | --psd | --ps) ac_prev=psdir ;; -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*) psdir=$ac_optarg ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) silent=yes ;; -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ac_prev=sbindir ;; -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ | --sbi=* | --sb=*) sbindir=$ac_optarg ;; -sharedstatedir | --sharedstatedir | --sharedstatedi \ | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ | --sharedst | --shareds | --shared | --share | --shar \ | --sha | --sh) ac_prev=sharedstatedir ;; -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ | --sha=* | --sh=*) sharedstatedir=$ac_optarg ;; -site | --site | --sit) ac_prev=site ;; -site=* | --site=* | --sit=*) site=$ac_optarg ;; -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) ac_prev=srcdir ;; -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) srcdir=$ac_optarg ;; -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ | --syscon | --sysco | --sysc | --sys | --sy) ac_prev=sysconfdir ;; -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) sysconfdir=$ac_optarg ;; -target | --target | --targe | --targ | --tar | --ta | --t) ac_prev=target_alias ;; -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) target_alias=$ac_optarg ;; -v | -verbose | --verbose | --verbos | --verbo | --verb) verbose=yes ;; -version | --version | --versio | --versi | --vers | -V) ac_init_version=: ;; -with-* | --with-*) ac_package=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_package" : ".*[^-._$as_cr_alnum]" >/dev/null && { echo "$as_me: error: invalid package name: $ac_package" >&2 { (exit 1); exit 1; }; } ac_package=`echo $ac_package | sed 's/[-.]/_/g'` eval with_$ac_package=\$ac_optarg ;; -without-* | --without-*) ac_package=`expr "x$ac_option" : 'x-*without-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_package" : ".*[^-._$as_cr_alnum]" >/dev/null && { echo "$as_me: error: invalid package name: $ac_package" >&2 { (exit 1); exit 1; }; } ac_package=`echo $ac_package | sed 's/[-.]/_/g'` eval with_$ac_package=no ;; --x) # Obsolete; use --with-x. with_x=yes ;; -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ | --x-incl | --x-inc | --x-in | --x-i) ac_prev=x_includes ;; -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) x_includes=$ac_optarg ;; -x-libraries | --x-libraries | --x-librarie | --x-librari \ | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) ac_prev=x_libraries ;; -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) x_libraries=$ac_optarg ;; -*) { echo "$as_me: error: unrecognized option: $ac_option Try \`$0 --help' for more information." >&2 { (exit 1); exit 1; }; } ;; *=*) ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` # Reject names that are not valid shell variable names. expr "x$ac_envvar" : ".*[^_$as_cr_alnum]" >/dev/null && { echo "$as_me: error: invalid variable name: $ac_envvar" >&2 { (exit 1); exit 1; }; } eval $ac_envvar=\$ac_optarg export $ac_envvar ;; *) # FIXME: should be removed in autoconf 3.0. echo "$as_me: WARNING: you should use --build, --host, --target" >&2 expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && echo "$as_me: WARNING: invalid host type: $ac_option" >&2 : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option} ;; esac done if test -n "$ac_prev"; then ac_option=--`echo $ac_prev | sed 's/_/-/g'` { echo "$as_me: error: missing argument to $ac_option" >&2 { (exit 1); exit 1; }; } fi # Be sure to have absolute directory names. for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ datadir sysconfdir sharedstatedir localstatedir includedir \ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ libdir localedir mandir do eval ac_val=\$$ac_var case $ac_val in [\\/$]* | ?:[\\/]* ) continue;; NONE | '' ) case $ac_var in *prefix ) continue;; esac;; esac { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2 { (exit 1); exit 1; }; } done # There might be people who depend on the old broken behavior: `$host' # used to hold the argument of --host etc. # FIXME: To remove some day. build=$build_alias host=$host_alias target=$target_alias # FIXME: To remove some day. if test "x$host_alias" != x; then if test "x$build_alias" = x; then cross_compiling=maybe echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host. If a cross compiler is detected then cross compile mode will be used." >&2 elif test "x$build_alias" != "x$host_alias"; then cross_compiling=yes fi fi ac_tool_prefix= test -n "$host_alias" && ac_tool_prefix=$host_alias- test "$silent" = yes && exec 6>/dev/null ac_pwd=`pwd` && test -n "$ac_pwd" && ac_ls_di=`ls -di .` && ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || { echo "$as_me: error: Working directory cannot be determined" >&2 { (exit 1); exit 1; }; } test "X$ac_ls_di" = "X$ac_pwd_ls_di" || { echo "$as_me: error: pwd does not report name of working directory" >&2 { (exit 1); exit 1; }; } # Find the source files, if location was not specified. if test -z "$srcdir"; then ac_srcdir_defaulted=yes # Try the directory containing this script, then the parent directory. ac_confdir=`$as_dirname -- "$0" || $as_expr X"$0" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$0" : 'X\(//\)[^/]' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || echo X"$0" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` srcdir=$ac_confdir if test ! -r "$srcdir/$ac_unique_file"; then srcdir=.. fi else ac_srcdir_defaulted=no fi if test ! -r "$srcdir/$ac_unique_file"; then test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." { echo "$as_me: error: cannot find sources ($ac_unique_file) in $srcdir" >&2 { (exit 1); exit 1; }; } fi ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" ac_abs_confdir=`( cd "$srcdir" && test -r "./$ac_unique_file" || { echo "$as_me: error: $ac_msg" >&2 { (exit 1); exit 1; }; } pwd)` # When building in place, set srcdir=. if test "$ac_abs_confdir" = "$ac_pwd"; then srcdir=. fi # Remove unnecessary trailing slashes from srcdir. # Double slashes in file names in object file debugging info # mess up M-x gdb in Emacs. case $srcdir in */) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;; esac for ac_var in $ac_precious_vars; do eval ac_env_${ac_var}_set=\${${ac_var}+set} eval ac_env_${ac_var}_value=\$${ac_var} eval ac_cv_env_${ac_var}_set=\${${ac_var}+set} eval ac_cv_env_${ac_var}_value=\$${ac_var} done # # Report the --help message. # if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF \`configure' configures Jed 0.99-19 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... To assign environment variables (e.g., CC, CFLAGS...), specify them as VAR=VALUE. See below for descriptions of some of the useful variables. Defaults for the options are specified in brackets. Configuration: -h, --help display this help and exit --help=short display options specific to this package --help=recursive display the short help of all the included packages -V, --version display version information and exit -q, --quiet, --silent do not print \`checking...' messages --cache-file=FILE cache test results in FILE [disabled] -C, --config-cache alias for \`--cache-file=config.cache' -n, --no-create do not create output files --srcdir=DIR find the sources in DIR [configure dir or \`..'] Installation directories: --prefix=PREFIX install architecture-independent files in PREFIX [$ac_default_prefix] --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX [PREFIX] By default, \`make install' will install all the files in \`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify an installation prefix other than \`$ac_default_prefix' using \`--prefix', for instance \`--prefix=\$HOME'. For better control, use the options below. Fine tuning of the installation directories: --bindir=DIR user executables [EPREFIX/bin] --sbindir=DIR system admin executables [EPREFIX/sbin] --libexecdir=DIR program executables [EPREFIX/libexec] --sysconfdir=DIR read-only single-machine data [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --localstatedir=DIR modifiable single-machine data [PREFIX/var] --libdir=DIR object code libraries [EPREFIX/lib] --includedir=DIR C header files [PREFIX/include] --oldincludedir=DIR C header files for non-gcc [/usr/include] --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] --datadir=DIR read-only architecture-independent data [DATAROOTDIR] --infodir=DIR info documentation [DATAROOTDIR/info] --localedir=DIR locale-dependent data [DATAROOTDIR/locale] --mandir=DIR man documentation [DATAROOTDIR/man] --docdir=DIR documentation root [DATAROOTDIR/doc/jed] --htmldir=DIR html documentation [DOCDIR] --dvidir=DIR dvi documentation [DOCDIR] --pdfdir=DIR pdf documentation [DOCDIR] --psdir=DIR ps documentation [DOCDIR] _ACEOF cat <<\_ACEOF X features: --x-includes=DIR X include files are in DIR --x-libraries=DIR X library files are in DIR System types: --build=BUILD configure for building on BUILD [guessed] --host=HOST cross-compile to build programs to run on HOST [BUILD] _ACEOF fi if test -n "$ac_init_help"; then case $ac_init_help in short | recursive ) echo "Configuration of Jed 0.99-19:";; esac cat <<\_ACEOF Optional Features: --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) --enable-FEATURE[=ARG] include FEATURE [ARG=yes] --disable-largefile omit support for large files --enable-warnings turn on GCC compiler warnings --disable-xft disable X FreeType library support (antialiased fonts) --disable-gpm disable gpm mouse support Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) --with-x use the X Window System --with-slang=DIR Use DIR/lib and DIR/include for slang --with-slanglib=DIR slang library in DIR --with-slanginc=DIR slang include files in DIR --with-gtk=PATH Directory where the pkg-config file gtk+-2.0.pc can be found. This is often /usr/lib/pkgconfig, /usr/lib64/pkgconfig or in a default garnome build of gnome $HOME/garnome/lib/pkgconfig Some influential environment variables: CC C compiler command CFLAGS C compiler flags LDFLAGS linker flags, e.g. -L if you have libraries in a nonstandard directory LIBS libraries to pass to the linker, e.g. -l CPPFLAGS C/C++/Objective C preprocessor flags, e.g. -I if you have headers in a nonstandard directory CPP C preprocessor PKG_CONFIG path to pkg-config utility XMKMF Path to xmkmf, Makefile generator for X Window System GTK_CFLAGS C compiler flags for GTK, overriding pkg-config GTK_LIBS linker flags for GTK, overriding pkg-config Use these variables to override the choices made by `configure' or to help it to find libraries and programs with nonstandard names/locations. Report bugs to . _ACEOF ac_status=$? fi if test "$ac_init_help" = "recursive"; then # If there are subdirs, report their specific --help. for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue test -d "$ac_dir" || continue ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,/..,g;s,/,,'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix cd "$ac_dir" || { ac_status=$?; continue; } # Check for guested configure. if test -f "$ac_srcdir/configure.gnu"; then echo && $SHELL "$ac_srcdir/configure.gnu" --help=recursive elif test -f "$ac_srcdir/configure"; then echo && $SHELL "$ac_srcdir/configure" --help=recursive else echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 fi || ac_status=$? cd "$ac_pwd" || { ac_status=$?; break; } done fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF Jed configure 0.99-19 generated by GNU Autoconf 2.61 Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. _ACEOF exit fi cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. It was created by Jed $as_me 0.99-19, which was generated by GNU Autoconf 2.61. Invocation command line was $ $0 $@ _ACEOF exec 5>>config.log { cat <<_ASUNAME ## --------- ## ## Platform. ## ## --------- ## hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` uname -m = `(uname -m) 2>/dev/null || echo unknown` uname -r = `(uname -r) 2>/dev/null || echo unknown` uname -s = `(uname -s) 2>/dev/null || echo unknown` uname -v = `(uname -v) 2>/dev/null || echo unknown` /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` /bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` /bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` /usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown` /bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` /bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` _ASUNAME as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. echo "PATH: $as_dir" done IFS=$as_save_IFS } >&5 cat >&5 <<_ACEOF ## ----------- ## ## Core tests. ## ## ----------- ## _ACEOF # Keep a trace of the command line. # Strip out --no-create and --no-recursion so they do not pile up. # Strip out --silent because we don't want to record it for future runs. # Also quote any args containing shell meta-characters. # Make two passes to allow for proper duplicate-argument suppression. ac_configure_args= ac_configure_args0= ac_configure_args1= ac_must_keep_next=false for ac_pass in 1 2 do for ac_arg do case $ac_arg in -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) continue ;; *\'*) ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; esac case $ac_pass in 1) ac_configure_args0="$ac_configure_args0 '$ac_arg'" ;; 2) ac_configure_args1="$ac_configure_args1 '$ac_arg'" if test $ac_must_keep_next = true; then ac_must_keep_next=false # Got value, back to normal. else case $ac_arg in *=* | --config-cache | -C | -disable-* | --disable-* \ | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ | -with-* | --with-* | -without-* | --without-* | --x) case "$ac_configure_args0 " in "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; esac ;; -* ) ac_must_keep_next=true ;; esac fi ac_configure_args="$ac_configure_args '$ac_arg'" ;; esac done done $as_unset ac_configure_args0 || test "${ac_configure_args0+set}" != set || { ac_configure_args0=; export ac_configure_args0; } $as_unset ac_configure_args1 || test "${ac_configure_args1+set}" != set || { ac_configure_args1=; export ac_configure_args1; } # When interrupted or exit'd, cleanup temporary files, and complete # config.log. We remove comments because anyway the quotes in there # would cause problems or look ugly. # WARNING: Use '\'' to represent an apostrophe within the trap. # WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug. trap 'exit_status=$? # Save into config.log some information that might help in debugging. { echo cat <<\_ASBOX ## ---------------- ## ## Cache variables. ## ## ---------------- ## _ASBOX echo # The following way of writing the cache mishandles newlines in values, ( for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do eval ac_val=\$$ac_var case $ac_val in #( *${as_nl}*) case $ac_var in #( *_cv_*) { echo "$as_me:$LINENO: WARNING: Cache variable $ac_var contains a newline." >&5 echo "$as_me: WARNING: Cache variable $ac_var contains a newline." >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( *) $as_unset $ac_var ;; esac ;; esac done (set) 2>&1 | case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #( *${as_nl}ac_space=\ *) sed -n \ "s/'\''/'\''\\\\'\'''\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p" ;; #( *) sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; esac | sort ) echo cat <<\_ASBOX ## ----------------- ## ## Output variables. ## ## ----------------- ## _ASBOX echo for ac_var in $ac_subst_vars do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac echo "$ac_var='\''$ac_val'\''" done | sort echo if test -n "$ac_subst_files"; then cat <<\_ASBOX ## ------------------- ## ## File substitutions. ## ## ------------------- ## _ASBOX echo for ac_var in $ac_subst_files do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac echo "$ac_var='\''$ac_val'\''" done | sort echo fi if test -s confdefs.h; then cat <<\_ASBOX ## ----------- ## ## confdefs.h. ## ## ----------- ## _ASBOX echo cat confdefs.h echo fi test "$ac_signal" != 0 && echo "$as_me: caught signal $ac_signal" echo "$as_me: exit $exit_status" } >&5 rm -f core *.core core.conftest.* && rm -f -r conftest* confdefs* conf$$* $ac_clean_files && exit $exit_status ' 0 for ac_signal in 1 2 13 15; do trap 'ac_signal='$ac_signal'; { (exit 1); exit 1; }' $ac_signal done ac_signal=0 # confdefs.h avoids OS command line length limits that DEFS can exceed. rm -f -r conftest* confdefs.h # Predefined preprocessor variables. cat >>confdefs.h <<_ACEOF #define PACKAGE_NAME "$PACKAGE_NAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_TARNAME "$PACKAGE_TARNAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_VERSION "$PACKAGE_VERSION" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_STRING "$PACKAGE_STRING" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" _ACEOF # Let the site file select an alternate cache file if it wants to. # Prefer explicitly selected file to automatically selected ones. if test -n "$CONFIG_SITE"; then set x "$CONFIG_SITE" elif test "x$prefix" != xNONE; then set x "$prefix/share/config.site" "$prefix/etc/config.site" else set x "$ac_default_prefix/share/config.site" \ "$ac_default_prefix/etc/config.site" fi shift for ac_site_file do if test -r "$ac_site_file"; then { echo "$as_me:$LINENO: loading site script $ac_site_file" >&5 echo "$as_me: loading site script $ac_site_file" >&6;} sed 's/^/| /' "$ac_site_file" >&5 . "$ac_site_file" fi done if test -r "$cache_file"; then # Some versions of bash will fail to source /dev/null (special # files actually), so we avoid doing that. if test -f "$cache_file"; then { echo "$as_me:$LINENO: loading cache $cache_file" >&5 echo "$as_me: loading cache $cache_file" >&6;} case $cache_file in [\\/]* | ?:[\\/]* ) . "$cache_file";; *) . "./$cache_file";; esac fi else { echo "$as_me:$LINENO: creating cache $cache_file" >&5 echo "$as_me: creating cache $cache_file" >&6;} >$cache_file fi # Check that the precious variables saved in the cache have kept the same # value. ac_cache_corrupted=false for ac_var in $ac_precious_vars; do eval ac_old_set=\$ac_cv_env_${ac_var}_set eval ac_new_set=\$ac_env_${ac_var}_set eval ac_old_val=\$ac_cv_env_${ac_var}_value eval ac_new_val=\$ac_env_${ac_var}_value case $ac_old_set,$ac_new_set in set,) { echo "$as_me:$LINENO: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} ac_cache_corrupted=: ;; ,set) { echo "$as_me:$LINENO: error: \`$ac_var' was not set in the previous run" >&5 echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} ac_cache_corrupted=: ;; ,);; *) if test "x$ac_old_val" != "x$ac_new_val"; then { echo "$as_me:$LINENO: error: \`$ac_var' has changed since the previous run:" >&5 echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} { echo "$as_me:$LINENO: former value: $ac_old_val" >&5 echo "$as_me: former value: $ac_old_val" >&2;} { echo "$as_me:$LINENO: current value: $ac_new_val" >&5 echo "$as_me: current value: $ac_new_val" >&2;} ac_cache_corrupted=: fi;; esac # Pass precious variables to config.status. if test "$ac_new_set" = set; then case $ac_new_val in *\'*) ac_arg=$ac_var=`echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; *) ac_arg=$ac_var=$ac_new_val ;; esac case " $ac_configure_args " in *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. *) ac_configure_args="$ac_configure_args '$ac_arg'" ;; esac fi done if $ac_cache_corrupted; then { echo "$as_me:$LINENO: error: changes in the environment can compromise the build" >&5 echo "$as_me: error: changes in the environment can compromise the build" >&2;} { { echo "$as_me:$LINENO: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5 echo "$as_me: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&2;} { (exit 1); exit 1; }; } fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu #These variable are initialized by JD init function CONFIG_DIR=`pwd` cd $srcdir if test "`pwd`" != "$CONFIG_DIR" then { { echo "$as_me:$LINENO: error: \"This software does not support configuring from another directory. See the INSTALL file\"" >&5 echo "$as_me: error: \"This software does not support configuring from another directory. See the INSTALL file\"" >&2;} { (exit 1); exit 1; }; } fi # Note: these will differ if one is a symbolic link if test -f /usr/bin/dirname; then JD_Above_Dir=`dirname $CONFIG_DIR` else # system is a loser JD_Above_Dir=`cd ..;pwd` fi JD_Above_Dir2=`cd ..;pwd` ac_aux_dir= for ac_dir in autoconf "$srcdir"/autoconf; do if test -f "$ac_dir/install-sh"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install-sh -c" break elif test -f "$ac_dir/install.sh"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install.sh -c" break elif test -f "$ac_dir/shtool"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/shtool install -c" break fi done if test -z "$ac_aux_dir"; then { { echo "$as_me:$LINENO: error: cannot find install-sh or install.sh in autoconf \"$srcdir\"/autoconf" >&5 echo "$as_me: error: cannot find install-sh or install.sh in autoconf \"$srcdir\"/autoconf" >&2;} { (exit 1); exit 1; }; } fi # These three variables are undocumented and unsupported, # and are intended to be withdrawn in a future Autoconf release. # They can cause serious problems if a builder's source tree is in a directory # whose full name contains unusual characters. ac_config_guess="$SHELL $ac_aux_dir/config.guess" # Please don't use this var. ac_config_sub="$SHELL $ac_aux_dir/config.sub" # Please don't use this var. ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. #dnl -*- autoconf -*- ################################################################## ################################################################## ## Begin: STOLEN FROM A AUTOMAKE/ACLOCAL call #vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv #vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv # PKG_PROG_PKG_CONFIG([MIN-VERSION]) # ---------------------------------- # PKG_PROG_PKG_CONFIG # PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) # # Check to see whether a particular set of modules exists. Similar # to PKG_CHECK_MODULES(), but does not set variables or print errors. # # # Similar to PKG_CHECK_MODULES, make sure that the first instance of # this or PKG_CHECK_MODULES is called, or make sure to call # PKG_CHECK_EXISTS manually # -------------------------------------------------------------- # _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES]) # --------------------------------------------- # _PKG_CONFIG # _PKG_SHORT_ERRORS_SUPPORTED # ----------------------------- # _PKG_SHORT_ERRORS_SUPPORTED # PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND], # [ACTION-IF-NOT-FOUND]) # # # Note that if there is a possibility the first call to # PKG_CHECK_MODULES might not happen, you should be sure to include an # explicit call to PKG_PROG_PKG_CONFIG in your configure.ac # # # -------------------------------------------------------------- # PKG_CHECK_MODULES #^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ #^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ## End: STOLEN FROM A AUTOMAKE/ACLOCAL call ################################################################## ################################################################## # Make sure we can run config.sub. $SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 || { { echo "$as_me:$LINENO: error: cannot run $SHELL $ac_aux_dir/config.sub" >&5 echo "$as_me: error: cannot run $SHELL $ac_aux_dir/config.sub" >&2;} { (exit 1); exit 1; }; } { echo "$as_me:$LINENO: checking build system type" >&5 echo $ECHO_N "checking build system type... $ECHO_C" >&6; } if test "${ac_cv_build+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_build_alias=$build_alias test "x$ac_build_alias" = x && ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"` test "x$ac_build_alias" = x && { { echo "$as_me:$LINENO: error: cannot guess build type; you must specify one" >&5 echo "$as_me: error: cannot guess build type; you must specify one" >&2;} { (exit 1); exit 1; }; } ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` || { { echo "$as_me:$LINENO: error: $SHELL $ac_aux_dir/config.sub $ac_build_alias failed" >&5 echo "$as_me: error: $SHELL $ac_aux_dir/config.sub $ac_build_alias failed" >&2;} { (exit 1); exit 1; }; } fi { echo "$as_me:$LINENO: result: $ac_cv_build" >&5 echo "${ECHO_T}$ac_cv_build" >&6; } case $ac_cv_build in *-*-*) ;; *) { { echo "$as_me:$LINENO: error: invalid value of canonical build" >&5 echo "$as_me: error: invalid value of canonical build" >&2;} { (exit 1); exit 1; }; };; esac build=$ac_cv_build ac_save_IFS=$IFS; IFS='-' set x $ac_cv_build shift build_cpu=$1 build_vendor=$2 shift; shift # Remember, the first character of IFS is used to create $*, # except with old shells: build_os=$* IFS=$ac_save_IFS case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac { echo "$as_me:$LINENO: checking host system type" >&5 echo $ECHO_N "checking host system type... $ECHO_C" >&6; } if test "${ac_cv_host+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test "x$host_alias" = x; then ac_cv_host=$ac_cv_build else ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` || { { echo "$as_me:$LINENO: error: $SHELL $ac_aux_dir/config.sub $host_alias failed" >&5 echo "$as_me: error: $SHELL $ac_aux_dir/config.sub $host_alias failed" >&2;} { (exit 1); exit 1; }; } fi fi { echo "$as_me:$LINENO: result: $ac_cv_host" >&5 echo "${ECHO_T}$ac_cv_host" >&6; } case $ac_cv_host in *-*-*) ;; *) { { echo "$as_me:$LINENO: error: invalid value of canonical host" >&5 echo "$as_me: error: invalid value of canonical host" >&2;} { (exit 1); exit 1; }; };; esac host=$ac_cv_host ac_save_IFS=$IFS; IFS='-' set x $ac_cv_host shift host_cpu=$1 host_vendor=$2 shift; shift # Remember, the first character of IFS is used to create $*, # except with old shells: host_os=$* IFS=$ac_save_IFS case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac { echo "$as_me:$LINENO: checking whether ${MAKE-make} sets \$(MAKE)" >&5 echo $ECHO_N "checking whether ${MAKE-make} sets \$(MAKE)... $ECHO_C" >&6; } set x ${MAKE-make}; ac_make=`echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'` if { as_var=ac_cv_prog_make_${ac_make}_set; eval "test \"\${$as_var+set}\" = set"; }; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.make <<\_ACEOF SHELL = /bin/sh all: @echo '@@@%%%=$(MAKE)=@@@%%%' _ACEOF # GNU make sometimes prints "make[1]: Entering...", which would confuse us. case `${MAKE-make} -f conftest.make 2>/dev/null` in *@@@%%%=?*=@@@%%%*) eval ac_cv_prog_make_${ac_make}_set=yes;; *) eval ac_cv_prog_make_${ac_make}_set=no;; esac rm -f conftest.make fi if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then { echo "$as_me:$LINENO: result: yes" >&5 echo "${ECHO_T}yes" >&6; } SET_MAKE= else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } SET_MAKE="MAKE=${MAKE-make}" fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args. set dummy ${ac_tool_prefix}ranlib; ac_word=$2 { echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_RANLIB+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$RANLIB"; then ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi RANLIB=$ac_cv_prog_RANLIB if test -n "$RANLIB"; then { echo "$as_me:$LINENO: result: $RANLIB" >&5 echo "${ECHO_T}$RANLIB" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } fi fi if test -z "$ac_cv_prog_RANLIB"; then ac_ct_RANLIB=$RANLIB # Extract the first word of "ranlib", so it can be a program name with args. set dummy ranlib; ac_word=$2 { echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_ac_ct_RANLIB+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$ac_ct_RANLIB"; then ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_RANLIB="ranlib" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB if test -n "$ac_ct_RANLIB"; then { echo "$as_me:$LINENO: result: $ac_ct_RANLIB" >&5 echo "${ECHO_T}$ac_ct_RANLIB" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } fi if test "x$ac_ct_RANLIB" = x; then RANLIB=":" else case $cross_compiling:$ac_tool_warned in yes:) { echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools whose name does not start with the host triplet. If you think this configuration is useful to you, please write to autoconf@gnu.org." >&5 echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools whose name does not start with the host triplet. If you think this configuration is useful to you, please write to autoconf@gnu.org." >&2;} ac_tool_warned=yes ;; esac RANLIB=$ac_ct_RANLIB fi else RANLIB="$ac_cv_prog_RANLIB" fi # Find a good install program. We prefer a C program (faster), # so one script is as good as another. But avoid the broken or # incompatible versions: # SysV /etc/install, /usr/sbin/install # SunOS /usr/etc/install # IRIX /sbin/install # AIX /bin/install # AmigaOS /C/install, which installs bootblocks on floppy discs # AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag # AFS /usr/afsws/bin/install, which mishandles nonexistent args # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" # OS/2's system install, which has a completely different semantic # ./install, which can be erroneously created by make from ./install.sh. { echo "$as_me:$LINENO: checking for a BSD-compatible install" >&5 echo $ECHO_N "checking for a BSD-compatible install... $ECHO_C" >&6; } if test -z "$INSTALL"; then if test "${ac_cv_path_install+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. # Account for people who put trailing slashes in PATH elements. case $as_dir/ in ./ | .// | /cC/* | \ /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ ?:\\/os2\\/install\\/* | ?:\\/OS2\\/INSTALL\\/* | \ /usr/ucb/* ) ;; *) # OSF1 and SCO ODT 3.0 have their own names for install. # Don't use installbsd from OSF since it installs stuff as root # by default. for ac_prog in ginstall scoinst install; do for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; }; then if test $ac_prog = install && grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then # AIX install. It has an incompatible calling convention. : elif test $ac_prog = install && grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then # program-specific install script used by HP pwplus--don't use. : else ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" break 3 fi fi done done ;; esac done IFS=$as_save_IFS fi if test "${ac_cv_path_install+set}" = set; then INSTALL=$ac_cv_path_install else # As a last resort, use the slow shell script. Don't cache a # value for INSTALL within a source directory, because that will # break other packages using the cache if that directory is # removed, or if the value is a relative name. INSTALL=$ac_install_sh fi fi { echo "$as_me:$LINENO: result: $INSTALL" >&5 echo "${ECHO_T}$INSTALL" >&6; } # Use test -z because SunOS4 sh mishandles braces in ${var-val}. # It thinks the first close brace ends the variable substitution. test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. set dummy ${ac_tool_prefix}gcc; ac_word=$2 { echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="${ac_tool_prefix}gcc" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { echo "$as_me:$LINENO: result: $CC" >&5 echo "${ECHO_T}$CC" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } fi fi if test -z "$ac_cv_prog_CC"; then ac_ct_CC=$CC # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 { echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_ac_ct_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_CC="gcc" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 echo "${ECHO_T}$ac_ct_CC" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } fi if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools whose name does not start with the host triplet. If you think this configuration is useful to you, please write to autoconf@gnu.org." >&5 echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools whose name does not start with the host triplet. If you think this configuration is useful to you, please write to autoconf@gnu.org." >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi else CC="$ac_cv_prog_CC" fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. set dummy ${ac_tool_prefix}cc; ac_word=$2 { echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="${ac_tool_prefix}cc" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { echo "$as_me:$LINENO: result: $CC" >&5 echo "${ECHO_T}$CC" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } fi fi fi if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 { echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else ac_prog_rejected=no as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue fi ac_cv_prog_CC="cc" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS if test $ac_prog_rejected = yes; then # We found a bogon in the path, so make sure we never use it. set dummy $ac_cv_prog_CC shift if test $# != 0; then # We chose a different compiler from the bogus one. # However, it has the same basename, so the bogon will be chosen # first if we set CC to just the basename; use the full file name. shift ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" fi fi fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { echo "$as_me:$LINENO: result: $CC" >&5 echo "${ECHO_T}$CC" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } fi fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then for ac_prog in cl.exe do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="$ac_tool_prefix$ac_prog" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { echo "$as_me:$LINENO: result: $CC" >&5 echo "${ECHO_T}$CC" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } fi test -n "$CC" && break done fi if test -z "$CC"; then ac_ct_CC=$CC for ac_prog in cl.exe do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_ac_ct_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_CC="$ac_prog" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 echo "${ECHO_T}$ac_ct_CC" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } fi test -n "$ac_ct_CC" && break done if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools whose name does not start with the host triplet. If you think this configuration is useful to you, please write to autoconf@gnu.org." >&5 echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools whose name does not start with the host triplet. If you think this configuration is useful to you, please write to autoconf@gnu.org." >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi fi fi test -z "$CC" && { { echo "$as_me:$LINENO: error: no acceptable C compiler found in \$PATH See \`config.log' for more details." >&5 echo "$as_me: error: no acceptable C compiler found in \$PATH See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; } # Provide some information about the compiler. echo "$as_me:$LINENO: checking for C compiler version" >&5 ac_compiler=`set X $ac_compile; echo $2` { (ac_try="$ac_compiler --version >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compiler --version >&5") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } { (ac_try="$ac_compiler -v >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compiler -v >&5") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } { (ac_try="$ac_compiler -V >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compiler -V >&5") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { ; return 0; } _ACEOF ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files a.out a.exe b.out" # Try to create an executable without -o first, disregard a.out. # It will help us diagnose broken compilers, and finding out an intuition # of exeext. { echo "$as_me:$LINENO: checking for C compiler default output file name" >&5 echo $ECHO_N "checking for C compiler default output file name... $ECHO_C" >&6; } ac_link_default=`echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` # # List of possible output files, starting from the most likely. # The algorithm is not robust to junk in `.', hence go to wildcards (a.*) # only as a last resort. b.out is created by i960 compilers. ac_files='a_out.exe a.exe conftest.exe a.out conftest a.* conftest.* b.out' # # The IRIX 6 linker writes into existing files which may not be # executable, retaining their permissions. Remove them first so a # subsequent execution test works. ac_rmfiles= for ac_file in $ac_files do case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.o | *.obj ) ;; * ) ac_rmfiles="$ac_rmfiles $ac_file";; esac done rm -f $ac_rmfiles if { (ac_try="$ac_link_default" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link_default") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; then # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. # So ignore a value of `no', otherwise this would lead to `EXEEXT = no' # in a Makefile. We should not override ac_cv_exeext if it was cached, # so that the user can short-circuit this test for compilers unknown to # Autoconf. for ac_file in $ac_files '' do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.o | *.obj ) ;; [ab].out ) # We found the default executable, but exeext='' is most # certainly right. break;; *.* ) if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; then :; else ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` fi # We set ac_cv_exeext here because the later test for it is not # safe: cross compilers may not add the suffix if given an `-o' # argument, so we may need to know it at that point already. # Even if this section looks crufty: it has the advantage of # actually working. break;; * ) break;; esac done test "$ac_cv_exeext" = no && ac_cv_exeext= else ac_file='' fi { echo "$as_me:$LINENO: result: $ac_file" >&5 echo "${ECHO_T}$ac_file" >&6; } if test -z "$ac_file"; then echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { echo "$as_me:$LINENO: error: C compiler cannot create executables See \`config.log' for more details." >&5 echo "$as_me: error: C compiler cannot create executables See \`config.log' for more details." >&2;} { (exit 77); exit 77; }; } fi ac_exeext=$ac_cv_exeext # Check that the compiler produces executables we can run. If not, either # the compiler is broken, or we cross compile. { echo "$as_me:$LINENO: checking whether the C compiler works" >&5 echo $ECHO_N "checking whether the C compiler works... $ECHO_C" >&6; } # FIXME: These cross compiler hacks should be removed for Autoconf 3.0 # If not cross compiling, check that we can run a simple program. if test "$cross_compiling" != yes; then if { ac_try='./$ac_file' { (case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_try") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then cross_compiling=no else if test "$cross_compiling" = maybe; then cross_compiling=yes else { { echo "$as_me:$LINENO: error: cannot run C compiled programs. If you meant to cross compile, use \`--host'. See \`config.log' for more details." >&5 echo "$as_me: error: cannot run C compiled programs. If you meant to cross compile, use \`--host'. See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; } fi fi fi { echo "$as_me:$LINENO: result: yes" >&5 echo "${ECHO_T}yes" >&6; } rm -f a.out a.exe conftest$ac_cv_exeext b.out ac_clean_files=$ac_clean_files_save # Check that the compiler produces executables we can run. If not, either # the compiler is broken, or we cross compile. { echo "$as_me:$LINENO: checking whether we are cross compiling" >&5 echo $ECHO_N "checking whether we are cross compiling... $ECHO_C" >&6; } { echo "$as_me:$LINENO: result: $cross_compiling" >&5 echo "${ECHO_T}$cross_compiling" >&6; } { echo "$as_me:$LINENO: checking for suffix of executables" >&5 echo $ECHO_N "checking for suffix of executables... $ECHO_C" >&6; } if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; then # If both `conftest.exe' and `conftest' are `present' (well, observable) # catch `conftest.exe'. For instance with Cygwin, `ls conftest' will # work properly (i.e., refer to `conftest.exe'), while it won't with # `rm'. for ac_file in conftest.exe conftest conftest.*; do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.o | *.obj ) ;; *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` break;; * ) break;; esac done else { { echo "$as_me:$LINENO: error: cannot compute suffix of executables: cannot compile and link See \`config.log' for more details." >&5 echo "$as_me: error: cannot compute suffix of executables: cannot compile and link See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; } fi rm -f conftest$ac_cv_exeext { echo "$as_me:$LINENO: result: $ac_cv_exeext" >&5 echo "${ECHO_T}$ac_cv_exeext" >&6; } rm -f conftest.$ac_ext EXEEXT=$ac_cv_exeext ac_exeext=$EXEEXT { echo "$as_me:$LINENO: checking for suffix of object files" >&5 echo $ECHO_N "checking for suffix of object files... $ECHO_C" >&6; } if test "${ac_cv_objext+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { ; return 0; } _ACEOF rm -f conftest.o conftest.obj if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; then for ac_file in conftest.o conftest.obj conftest.*; do test -f "$ac_file" || continue; case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf ) ;; *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` break;; esac done else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { echo "$as_me:$LINENO: error: cannot compute suffix of object files: cannot compile See \`config.log' for more details." >&5 echo "$as_me: error: cannot compute suffix of object files: cannot compile See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; } fi rm -f conftest.$ac_cv_objext conftest.$ac_ext fi { echo "$as_me:$LINENO: result: $ac_cv_objext" >&5 echo "${ECHO_T}$ac_cv_objext" >&6; } OBJEXT=$ac_cv_objext ac_objext=$OBJEXT { echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5 echo $ECHO_N "checking whether we are using the GNU C compiler... $ECHO_C" >&6; } if test "${ac_cv_c_compiler_gnu+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { #ifndef __GNUC__ choke me #endif ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_compiler_gnu=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_compiler_gnu=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_c_compiler_gnu=$ac_compiler_gnu fi { echo "$as_me:$LINENO: result: $ac_cv_c_compiler_gnu" >&5 echo "${ECHO_T}$ac_cv_c_compiler_gnu" >&6; } GCC=`test $ac_compiler_gnu = yes && echo yes` ac_test_CFLAGS=${CFLAGS+set} ac_save_CFLAGS=$CFLAGS { echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5 echo $ECHO_N "checking whether $CC accepts -g... $ECHO_C" >&6; } if test "${ac_cv_prog_cc_g+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_save_c_werror_flag=$ac_c_werror_flag ac_c_werror_flag=yes ac_cv_prog_cc_g=no CFLAGS="-g" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_cv_prog_cc_g=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 CFLAGS="" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then : else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_c_werror_flag=$ac_save_c_werror_flag CFLAGS="-g" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_cv_prog_cc_g=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_c_werror_flag=$ac_save_c_werror_flag fi { echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5 echo "${ECHO_T}$ac_cv_prog_cc_g" >&6; } if test "$ac_test_CFLAGS" = set; then CFLAGS=$ac_save_CFLAGS elif test $ac_cv_prog_cc_g = yes; then if test "$GCC" = yes; then CFLAGS="-g -O2" else CFLAGS="-g" fi else if test "$GCC" = yes; then CFLAGS="-O2" else CFLAGS= fi fi { echo "$as_me:$LINENO: checking for $CC option to accept ISO C89" >&5 echo $ECHO_N "checking for $CC option to accept ISO C89... $ECHO_C" >&6; } if test "${ac_cv_prog_cc_c89+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_cv_prog_cc_c89=no ac_save_CC=$CC cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include #include #include /* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ struct buf { int x; }; FILE * (*rcsopen) (struct buf *, struct stat *, int); static char *e (p, i) char **p; int i; { return p[i]; } static char *f (char * (*g) (char **, int), char **p, ...) { char *s; va_list v; va_start (v,p); s = g (p, va_arg (v,int)); va_end (v); return s; } /* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has function prototypes and stuff, but not '\xHH' hex character constants. These don't provoke an error unfortunately, instead are silently treated as 'x'. The following induces an error, until -std is added to get proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an array size at least. It's necessary to write '\x00'==0 to get something that's true only with -std. */ int osf4_cc_array ['\x00' == 0 ? 1 : -1]; /* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters inside strings and character constants. */ #define FOO(x) 'x' int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; int test (int i, double x); struct s1 {int (*f) (int a);}; struct s2 {int (*f) (double a);}; int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); int argc; char **argv; int main () { return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; ; return 0; } _ACEOF for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" do CC="$ac_save_CC $ac_arg" rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_cv_prog_cc_c89=$ac_arg else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f core conftest.err conftest.$ac_objext test "x$ac_cv_prog_cc_c89" != "xno" && break done rm -f conftest.$ac_ext CC=$ac_save_CC fi # AC_CACHE_VAL case "x$ac_cv_prog_cc_c89" in x) { echo "$as_me:$LINENO: result: none needed" >&5 echo "${ECHO_T}none needed" >&6; } ;; xno) { echo "$as_me:$LINENO: result: unsupported" >&5 echo "${ECHO_T}unsupported" >&6; } ;; *) CC="$CC $ac_cv_prog_cc_c89" { echo "$as_me:$LINENO: result: $ac_cv_prog_cc_c89" >&5 echo "${ECHO_T}$ac_cv_prog_cc_c89" >&6; } ;; esac ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { echo "$as_me:$LINENO: checking how to run the C preprocessor" >&5 echo $ECHO_N "checking how to run the C preprocessor... $ECHO_C" >&6; } # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then CPP= fi if test -z "$CPP"; then if test "${ac_cv_prog_CPP+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else # Double quotes because CPP needs to be expanded for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" do ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if { (ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then : else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 # Broken: fails on valid input. continue fi rm -f conftest.err conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include _ACEOF if { (ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then # Broken: success on invalid input. continue else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.err conftest.$ac_ext if $ac_preproc_ok; then break fi done ac_cv_prog_CPP=$CPP fi CPP=$ac_cv_prog_CPP else ac_cv_prog_CPP=$CPP fi { echo "$as_me:$LINENO: result: $CPP" >&5 echo "${ECHO_T}$CPP" >&6; } ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if { (ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then : else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 # Broken: fails on valid input. continue fi rm -f conftest.err conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include _ACEOF if { (ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then # Broken: success on invalid input. continue else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.err conftest.$ac_ext if $ac_preproc_ok; then : else { { echo "$as_me:$LINENO: error: C preprocessor \"$CPP\" fails sanity check See \`config.log' for more details." >&5 echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; } fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { echo "$as_me:$LINENO: checking for grep that handles long lines and -e" >&5 echo $ECHO_N "checking for grep that handles long lines and -e... $ECHO_C" >&6; } if test "${ac_cv_path_GREP+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else # Extract the first word of "grep ggrep" to use in msg output if test -z "$GREP"; then set dummy grep ggrep; ac_prog_name=$2 if test "${ac_cv_path_GREP+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_path_GREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in grep ggrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue # Check for GNU ac_path_GREP and select it if it is found. # Check for GNU $ac_path_GREP case `"$ac_path_GREP" --version 2>&1` in *GNU*) ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; *) ac_count=0 echo $ECHO_N "0123456789$ECHO_C" >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" echo 'GREP' >> "conftest.nl" "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break ac_count=`expr $ac_count + 1` if test $ac_count -gt ${ac_path_GREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_GREP_found && break 3 done done done IFS=$as_save_IFS fi GREP="$ac_cv_path_GREP" if test -z "$GREP"; then { { echo "$as_me:$LINENO: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&5 echo "$as_me: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&2;} { (exit 1); exit 1; }; } fi else ac_cv_path_GREP=$GREP fi fi { echo "$as_me:$LINENO: result: $ac_cv_path_GREP" >&5 echo "${ECHO_T}$ac_cv_path_GREP" >&6; } GREP="$ac_cv_path_GREP" { echo "$as_me:$LINENO: checking for egrep" >&5 echo $ECHO_N "checking for egrep... $ECHO_C" >&6; } if test "${ac_cv_path_EGREP+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 then ac_cv_path_EGREP="$GREP -E" else # Extract the first word of "egrep" to use in msg output if test -z "$EGREP"; then set dummy egrep; ac_prog_name=$2 if test "${ac_cv_path_EGREP+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_path_EGREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in egrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue # Check for GNU ac_path_EGREP and select it if it is found. # Check for GNU $ac_path_EGREP case `"$ac_path_EGREP" --version 2>&1` in *GNU*) ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; *) ac_count=0 echo $ECHO_N "0123456789$ECHO_C" >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" echo 'EGREP' >> "conftest.nl" "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break ac_count=`expr $ac_count + 1` if test $ac_count -gt ${ac_path_EGREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_EGREP_found && break 3 done done done IFS=$as_save_IFS fi EGREP="$ac_cv_path_EGREP" if test -z "$EGREP"; then { { echo "$as_me:$LINENO: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&5 echo "$as_me: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&2;} { (exit 1); exit 1; }; } fi else ac_cv_path_EGREP=$EGREP fi fi fi { echo "$as_me:$LINENO: result: $ac_cv_path_EGREP" >&5 echo "${ECHO_T}$ac_cv_path_EGREP" >&6; } EGREP="$ac_cv_path_EGREP" { echo "$as_me:$LINENO: checking for AIX" >&5 echo $ECHO_N "checking for AIX... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #ifdef _AIX yes #endif _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "yes" >/dev/null 2>&1; then { echo "$as_me:$LINENO: result: yes" >&5 echo "${ECHO_T}yes" >&6; } cat >>confdefs.h <<\_ACEOF #define _ALL_SOURCE 1 _ACEOF else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } fi rm -f conftest* ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. set dummy ${ac_tool_prefix}gcc; ac_word=$2 { echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="${ac_tool_prefix}gcc" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { echo "$as_me:$LINENO: result: $CC" >&5 echo "${ECHO_T}$CC" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } fi fi if test -z "$ac_cv_prog_CC"; then ac_ct_CC=$CC # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 { echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_ac_ct_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_CC="gcc" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 echo "${ECHO_T}$ac_ct_CC" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } fi if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools whose name does not start with the host triplet. If you think this configuration is useful to you, please write to autoconf@gnu.org." >&5 echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools whose name does not start with the host triplet. If you think this configuration is useful to you, please write to autoconf@gnu.org." >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi else CC="$ac_cv_prog_CC" fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. set dummy ${ac_tool_prefix}cc; ac_word=$2 { echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="${ac_tool_prefix}cc" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { echo "$as_me:$LINENO: result: $CC" >&5 echo "${ECHO_T}$CC" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } fi fi fi if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 { echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else ac_prog_rejected=no as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue fi ac_cv_prog_CC="cc" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS if test $ac_prog_rejected = yes; then # We found a bogon in the path, so make sure we never use it. set dummy $ac_cv_prog_CC shift if test $# != 0; then # We chose a different compiler from the bogus one. # However, it has the same basename, so the bogon will be chosen # first if we set CC to just the basename; use the full file name. shift ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" fi fi fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { echo "$as_me:$LINENO: result: $CC" >&5 echo "${ECHO_T}$CC" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } fi fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then for ac_prog in cl.exe do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="$ac_tool_prefix$ac_prog" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { echo "$as_me:$LINENO: result: $CC" >&5 echo "${ECHO_T}$CC" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } fi test -n "$CC" && break done fi if test -z "$CC"; then ac_ct_CC=$CC for ac_prog in cl.exe do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_ac_ct_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_CC="$ac_prog" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 echo "${ECHO_T}$ac_ct_CC" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } fi test -n "$ac_ct_CC" && break done if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools whose name does not start with the host triplet. If you think this configuration is useful to you, please write to autoconf@gnu.org." >&5 echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools whose name does not start with the host triplet. If you think this configuration is useful to you, please write to autoconf@gnu.org." >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi fi fi test -z "$CC" && { { echo "$as_me:$LINENO: error: no acceptable C compiler found in \$PATH See \`config.log' for more details." >&5 echo "$as_me: error: no acceptable C compiler found in \$PATH See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; } # Provide some information about the compiler. echo "$as_me:$LINENO: checking for C compiler version" >&5 ac_compiler=`set X $ac_compile; echo $2` { (ac_try="$ac_compiler --version >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compiler --version >&5") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } { (ac_try="$ac_compiler -v >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compiler -v >&5") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } { (ac_try="$ac_compiler -V >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compiler -V >&5") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } { echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5 echo $ECHO_N "checking whether we are using the GNU C compiler... $ECHO_C" >&6; } if test "${ac_cv_c_compiler_gnu+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { #ifndef __GNUC__ choke me #endif ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_compiler_gnu=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_compiler_gnu=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_c_compiler_gnu=$ac_compiler_gnu fi { echo "$as_me:$LINENO: result: $ac_cv_c_compiler_gnu" >&5 echo "${ECHO_T}$ac_cv_c_compiler_gnu" >&6; } GCC=`test $ac_compiler_gnu = yes && echo yes` ac_test_CFLAGS=${CFLAGS+set} ac_save_CFLAGS=$CFLAGS { echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5 echo $ECHO_N "checking whether $CC accepts -g... $ECHO_C" >&6; } if test "${ac_cv_prog_cc_g+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_save_c_werror_flag=$ac_c_werror_flag ac_c_werror_flag=yes ac_cv_prog_cc_g=no CFLAGS="-g" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_cv_prog_cc_g=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 CFLAGS="" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then : else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_c_werror_flag=$ac_save_c_werror_flag CFLAGS="-g" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_cv_prog_cc_g=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_c_werror_flag=$ac_save_c_werror_flag fi { echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5 echo "${ECHO_T}$ac_cv_prog_cc_g" >&6; } if test "$ac_test_CFLAGS" = set; then CFLAGS=$ac_save_CFLAGS elif test $ac_cv_prog_cc_g = yes; then if test "$GCC" = yes; then CFLAGS="-g -O2" else CFLAGS="-g" fi else if test "$GCC" = yes; then CFLAGS="-O2" else CFLAGS= fi fi { echo "$as_me:$LINENO: checking for $CC option to accept ISO C89" >&5 echo $ECHO_N "checking for $CC option to accept ISO C89... $ECHO_C" >&6; } if test "${ac_cv_prog_cc_c89+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_cv_prog_cc_c89=no ac_save_CC=$CC cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include #include #include /* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ struct buf { int x; }; FILE * (*rcsopen) (struct buf *, struct stat *, int); static char *e (p, i) char **p; int i; { return p[i]; } static char *f (char * (*g) (char **, int), char **p, ...) { char *s; va_list v; va_start (v,p); s = g (p, va_arg (v,int)); va_end (v); return s; } /* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has function prototypes and stuff, but not '\xHH' hex character constants. These don't provoke an error unfortunately, instead are silently treated as 'x'. The following induces an error, until -std is added to get proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an array size at least. It's necessary to write '\x00'==0 to get something that's true only with -std. */ int osf4_cc_array ['\x00' == 0 ? 1 : -1]; /* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters inside strings and character constants. */ #define FOO(x) 'x' int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; int test (int i, double x); struct s1 {int (*f) (int a);}; struct s2 {int (*f) (double a);}; int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); int argc; char **argv; int main () { return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; ; return 0; } _ACEOF for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" do CC="$ac_save_CC $ac_arg" rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_cv_prog_cc_c89=$ac_arg else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f core conftest.err conftest.$ac_objext test "x$ac_cv_prog_cc_c89" != "xno" && break done rm -f conftest.$ac_ext CC=$ac_save_CC fi # AC_CACHE_VAL case "x$ac_cv_prog_cc_c89" in x) { echo "$as_me:$LINENO: result: none needed" >&5 echo "${ECHO_T}none needed" >&6; } ;; xno) { echo "$as_me:$LINENO: result: unsupported" >&5 echo "${ECHO_T}unsupported" >&6; } ;; *) CC="$CC $ac_cv_prog_cc_c89" { echo "$as_me:$LINENO: result: $ac_cv_prog_cc_c89" >&5 echo "${ECHO_T}$ac_cv_prog_cc_c89" >&6; } ;; esac ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { echo "$as_me:$LINENO: checking how to run the C preprocessor" >&5 echo $ECHO_N "checking how to run the C preprocessor... $ECHO_C" >&6; } # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then CPP= fi if test -z "$CPP"; then if test "${ac_cv_prog_CPP+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else # Double quotes because CPP needs to be expanded for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" do ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if { (ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then : else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 # Broken: fails on valid input. continue fi rm -f conftest.err conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include _ACEOF if { (ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then # Broken: success on invalid input. continue else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.err conftest.$ac_ext if $ac_preproc_ok; then break fi done ac_cv_prog_CPP=$CPP fi CPP=$ac_cv_prog_CPP else ac_cv_prog_CPP=$CPP fi { echo "$as_me:$LINENO: result: $CPP" >&5 echo "${ECHO_T}$CPP" >&6; } ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if { (ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then : else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 # Broken: fails on valid input. continue fi rm -f conftest.err conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include _ACEOF if { (ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then # Broken: success on invalid input. continue else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.err conftest.$ac_ext if $ac_preproc_ok; then : else { { echo "$as_me:$LINENO: error: C preprocessor \"$CPP\" fails sanity check See \`config.log' for more details." >&5 echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; } fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu if test $ac_cv_c_compiler_gnu = yes; then { echo "$as_me:$LINENO: checking whether $CC needs -traditional" >&5 echo $ECHO_N "checking whether $CC needs -traditional... $ECHO_C" >&6; } if test "${ac_cv_prog_gcc_traditional+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_pattern="Autoconf.*'x'" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include Autoconf TIOCGETP _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "$ac_pattern" >/dev/null 2>&1; then ac_cv_prog_gcc_traditional=yes else ac_cv_prog_gcc_traditional=no fi rm -f conftest* if test $ac_cv_prog_gcc_traditional = no; then cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include Autoconf TCGETA _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "$ac_pattern" >/dev/null 2>&1; then ac_cv_prog_gcc_traditional=yes fi rm -f conftest* fi fi { echo "$as_me:$LINENO: result: $ac_cv_prog_gcc_traditional" >&5 echo "${ECHO_T}$ac_cv_prog_gcc_traditional" >&6; } if test $ac_cv_prog_gcc_traditional = yes; then CC="$CC -traditional" fi fi { echo "$as_me:$LINENO: checking for library containing strerror" >&5 echo $ECHO_N "checking for library containing strerror... $ECHO_C" >&6; } if test "${ac_cv_search_strerror+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_func_search_save_LIBS=$LIBS cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char strerror (); int main () { return strerror (); ; return 0; } _ACEOF for ac_lib in '' cposix; do if test -z "$ac_lib"; then ac_res="none required" else ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi rm -f conftest.$ac_objext conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && $as_test_x conftest$ac_exeext; then ac_cv_search_strerror=$ac_res else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext if test "${ac_cv_search_strerror+set}" = set; then break fi done if test "${ac_cv_search_strerror+set}" = set; then : else ac_cv_search_strerror=no fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi { echo "$as_me:$LINENO: result: $ac_cv_search_strerror" >&5 echo "${ECHO_T}$ac_cv_search_strerror" >&6; } ac_res=$ac_cv_search_strerror if test "$ac_res" != no; then test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" fi cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #ifdef hpux yes #endif _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "yes" >/dev/null 2>&1; then cat >>confdefs.h <<\_ACEOF #define _HPUX_SOURCE 1 _ACEOF if test "$CC" = cc; then CC="cc -Ae"; fi fi rm -f conftest* { echo "$as_me:$LINENO: checking C compiler that understands ANSI prototypes" >&5 echo $ECHO_N "checking C compiler that understands ANSI prototypes... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { extern int silly (int); ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then { echo "$as_me:$LINENO: result: $CC looks ok. Good." >&5 echo "${ECHO_T}$CC looks ok. Good." >&6; } else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { echo "$as_me:$LINENO: result: $CC is not a good enough compiler" >&5 echo "${ECHO_T}$CC is not a good enough compiler" >&6; } { { echo "$as_me:$LINENO: error: Set env variable CC to your ANSI compiler and rerun configure." >&5 echo "$as_me: error: Set env variable CC to your ANSI compiler and rerun configure." >&2;} { (exit 1); exit 1; }; } fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { echo "$as_me:$LINENO: checking for ANSI C header files" >&5 echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6; } if test "${ac_cv_header_stdc+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include #include #include int main () { ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_cv_header_stdc=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_header_stdc=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "memchr" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "free" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. if test "$cross_compiling" = yes; then : else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include #if ((' ' & 0x0FF) == 0x020) # define ISLOWER(c) ('a' <= (c) && (c) <= 'z') # define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) #else # define ISLOWER(c) \ (('a' <= (c) && (c) <= 'i') \ || ('j' <= (c) && (c) <= 'r') \ || ('s' <= (c) && (c) <= 'z')) # define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) #endif #define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) int main () { int i; for (i = 0; i < 256; i++) if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) return 2; return 0; } _ACEOF rm -f conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='./conftest$ac_exeext' { (case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_try") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then : else echo "$as_me: program exited with status $ac_status" >&5 echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) ac_cv_header_stdc=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi fi fi { echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5 echo "${ECHO_T}$ac_cv_header_stdc" >&6; } if test $ac_cv_header_stdc = yes; then cat >>confdefs.h <<\_ACEOF #define STDC_HEADERS 1 _ACEOF fi # On IRIX 5.3, sys/types and inttypes.h are conflicting. for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ inttypes.h stdint.h unistd.h do as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` { echo "$as_me:$LINENO: checking for $ac_header" >&5 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default #include <$ac_header> _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then eval "$as_ac_Header=yes" else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 eval "$as_ac_Header=no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi ac_res=`eval echo '${'$as_ac_Header'}'` { echo "$as_me:$LINENO: result: $ac_res" >&5 echo "${ECHO_T}$ac_res" >&6; } if test `eval echo '${'$as_ac_Header'}'` = yes; then cat >>confdefs.h <<_ACEOF #define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done DYNAMIC_LINK_LIB="" if test "${ac_cv_header_dlfcn_h+set}" = set; then { echo "$as_me:$LINENO: checking for dlfcn.h" >&5 echo $ECHO_N "checking for dlfcn.h... $ECHO_C" >&6; } if test "${ac_cv_header_dlfcn_h+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 fi { echo "$as_me:$LINENO: result: $ac_cv_header_dlfcn_h" >&5 echo "${ECHO_T}$ac_cv_header_dlfcn_h" >&6; } else # Is the header compilable? { echo "$as_me:$LINENO: checking dlfcn.h usability" >&5 echo $ECHO_N "checking dlfcn.h usability... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default #include _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_header_compiler=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_compiler=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 echo "${ECHO_T}$ac_header_compiler" >&6; } # Is the header present? { echo "$as_me:$LINENO: checking dlfcn.h presence" >&5 echo $ECHO_N "checking dlfcn.h presence... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include _ACEOF if { (ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then ac_header_preproc=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_preproc=no fi rm -f conftest.err conftest.$ac_ext { echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 echo "${ECHO_T}$ac_header_preproc" >&6; } # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in yes:no: ) { echo "$as_me:$LINENO: WARNING: dlfcn.h: accepted by the compiler, rejected by the preprocessor!" >&5 echo "$as_me: WARNING: dlfcn.h: accepted by the compiler, rejected by the preprocessor!" >&2;} { echo "$as_me:$LINENO: WARNING: dlfcn.h: proceeding with the compiler's result" >&5 echo "$as_me: WARNING: dlfcn.h: proceeding with the compiler's result" >&2;} ac_header_preproc=yes ;; no:yes:* ) { echo "$as_me:$LINENO: WARNING: dlfcn.h: present but cannot be compiled" >&5 echo "$as_me: WARNING: dlfcn.h: present but cannot be compiled" >&2;} { echo "$as_me:$LINENO: WARNING: dlfcn.h: check for missing prerequisite headers?" >&5 echo "$as_me: WARNING: dlfcn.h: check for missing prerequisite headers?" >&2;} { echo "$as_me:$LINENO: WARNING: dlfcn.h: see the Autoconf documentation" >&5 echo "$as_me: WARNING: dlfcn.h: see the Autoconf documentation" >&2;} { echo "$as_me:$LINENO: WARNING: dlfcn.h: section \"Present But Cannot Be Compiled\"" >&5 echo "$as_me: WARNING: dlfcn.h: section \"Present But Cannot Be Compiled\"" >&2;} { echo "$as_me:$LINENO: WARNING: dlfcn.h: proceeding with the preprocessor's result" >&5 echo "$as_me: WARNING: dlfcn.h: proceeding with the preprocessor's result" >&2;} { echo "$as_me:$LINENO: WARNING: dlfcn.h: in the future, the compiler will take precedence" >&5 echo "$as_me: WARNING: dlfcn.h: in the future, the compiler will take precedence" >&2;} ( cat <<\_ASBOX ## ------------------------------------ ## ## Report this to jed-users@jedsoft.org ## ## ------------------------------------ ## _ASBOX ) | sed "s/^/$as_me: WARNING: /" >&2 ;; esac { echo "$as_me:$LINENO: checking for dlfcn.h" >&5 echo $ECHO_N "checking for dlfcn.h... $ECHO_C" >&6; } if test "${ac_cv_header_dlfcn_h+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_cv_header_dlfcn_h=$ac_header_preproc fi { echo "$as_me:$LINENO: result: $ac_cv_header_dlfcn_h" >&5 echo "${ECHO_T}$ac_cv_header_dlfcn_h" >&6; } fi if test $ac_cv_header_dlfcn_h = yes; then cat >>confdefs.h <<\_ACEOF #define HAVE_DLFCN_H 1 _ACEOF { echo "$as_me:$LINENO: checking for dlopen in -ldl" >&5 echo $ECHO_N "checking for dlopen in -ldl... $ECHO_C" >&6; } if test "${ac_cv_lib_dl_dlopen+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ldl $LIBS" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char dlopen (); int main () { return dlopen (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && $as_test_x conftest$ac_exeext; then ac_cv_lib_dl_dlopen=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_dl_dlopen=no fi rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { echo "$as_me:$LINENO: result: $ac_cv_lib_dl_dlopen" >&5 echo "${ECHO_T}$ac_cv_lib_dl_dlopen" >&6; } if test $ac_cv_lib_dl_dlopen = yes; then DYNAMIC_LINK_LIB="-ldl" cat >>confdefs.h <<\_ACEOF #define HAVE_DLOPEN 1 _ACEOF else { echo "$as_me:$LINENO: checking for dlopen" >&5 echo $ECHO_N "checking for dlopen... $ECHO_C" >&6; } if test "${ac_cv_func_dlopen+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Define dlopen to an innocuous variant, in case declares dlopen. For example, HP-UX 11i declares gettimeofday. */ #define dlopen innocuous_dlopen /* System header to define __stub macros and hopefully few prototypes, which can conflict with char dlopen (); below. Prefer to if __STDC__ is defined, since exists even on freestanding compilers. */ #ifdef __STDC__ # include #else # include #endif #undef dlopen /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char dlopen (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined __stub_dlopen || defined __stub___dlopen choke me #endif int main () { return dlopen (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && $as_test_x conftest$ac_exeext; then ac_cv_func_dlopen=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_func_dlopen=no fi rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext fi { echo "$as_me:$LINENO: result: $ac_cv_func_dlopen" >&5 echo "${ECHO_T}$ac_cv_func_dlopen" >&6; } if test $ac_cv_func_dlopen = yes; then cat >>confdefs.h <<\_ACEOF #define HAVE_DLOPEN 1 _ACEOF fi if test "$ac_cv_func_dlopen" != yes then { echo "$as_me:$LINENO: WARNING: cannot perform dynamic linking" >&5 echo "$as_me: WARNING: cannot perform dynamic linking" >&2;} fi fi fi if test "$GCC" = yes then if test X"$CFLAGS" = X then CFLAGS="-O2" fi fi ELFLIB="lib\$(THIS_LIB).so" ELFLIB_MAJOR="\$(ELFLIB).\$(ELF_MAJOR_VERSION)" ELFLIB_MAJOR_MINOR="\$(ELFLIB_MAJOR).\$(ELF_MINOR_VERSION)" ELFLIB_MAJOR_MINOR_MICRO="\$(ELFLIB_MAJOR_MINOR).\$(ELF_MICRO_VERSION)" INSTALL_ELFLIB_TARGET="install-elf-and-links" ELFLIB_BUILD_NAME="\$(ELFLIB_MAJOR_MINOR_MICRO)" INSTALL_MODULE="\$(INSTALL_DATA)" SLANG_DLL_CFLAGS="" M_LIB="-lm" case "$host_os" in *linux*|*gnu*|k*bsd*-gnu ) DYNAMIC_LINK_FLAGS="-Wl,-export-dynamic" ELF_CC="\$(CC)" ELF_CFLAGS="\$(CFLAGS) -fPIC" ELF_LINK="\$(CC) \$(LDFLAGS) -shared -Wl,-O1 -Wl,--version-script,\$(VERSION_SCRIPT) -Wl,-soname,\$(ELFLIB_MAJOR)" ELF_DEP_LIBS="\$(DL_LIB) -lm -lc" CC_SHARED="\$(CC) \$(CFLAGS) -shared -fPIC" ;; *solaris* ) if test "$GCC" = yes then DYNAMIC_LINK_FLAGS="" ELF_CC="\$(CC)" ELF_CFLAGS="\$(CFLAGS) -fPIC" ELF_LINK="\$(CC) \$(LDFLAGS) -shared -Wl,-ztext -Wl,-h,\$(ELFLIB_MAJOR)" ELF_DEP_LIBS="\$(DL_LIB) -lm -lc" CC_SHARED="\$(CC) \$(CFLAGS) -G -fPIC" else DYNAMIC_LINK_FLAGS="" ELF_CC="\$(CC)" ELF_CFLAGS="\$(CFLAGS) -K PIC" ELF_LINK="\$(CC) \$(LDFLAGS) -G -h\$(ELFLIB_MAJOR)" ELF_DEP_LIBS="\$(DL_LIB) -lm -lc" CC_SHARED="\$(CC) \$(CFLAGS) -G -K PIC" fi ;; # osr5 or unixware7 with current or late autoconf *sco3.2v5* | *unixware-5* | *sco-sysv5uw7*) if test "$GCC" = yes then DYNAMIC_LINK_FLAGS="" ELF_CC="\$(CC)" ELF_CFLAGS="\$(CFLAGS) -fPIC" ELF_LINK="\$(CC) \$(LDFLAGS) -shared -Wl,-h,\$(ELFLIB_MAJOR)" ELF_DEP_LIBS= CC_SHARED="\$(CC) \$(CFLAGS) -G -fPIC" else DYNAMIC_LINK_FLAGS="" ELF_CC="\$(CC)" ELF_CFLAGS="\$(CFLAGS) -K pic" # ELF_LINK="ld -G -z text -h#" ELF_LINK="\$(CC) \$(LDFLAGS) -G -z text -h\$(ELFLIB_MAJOR)" ELF_DEP_LIBS= CC_SHARED="\$(CC) \$(CFLAGS) -G -K pic" fi ;; *irix6.5* ) echo "Note: ELF compiler for host_os=$host_os may not be correct" echo "double-check: 'mode_t', 'pid_t' may be wrong!" if test "$GCC" = yes then # not tested DYNAMIC_LINK_FLAGS="" ELF_CC="\$(CC)" ELF_CFLAGS="\$(CFLAGS) -fPIC" ELF_LINK="\$(CC) \$(LDFLAGS) -shared -Wl,-h,\$(ELFLIB_MAJOR)" ELF_DEP_LIBS= CC_SHARED="\$(CC) \$(CFLAGS) -shared -fPIC" else DYNAMIC_LINK_FLAGS="" ELF_CC="\$(CC)" ELF_CFLAGS="\$(CFLAGS)" # default anyhow ELF_LINK="\$(CC) \$(LDFLAGS) -shared -o \$(ELFLIB_MAJOR)" ELF_DEP_LIBS= CC_SHARED="\$(CC) \$(CFLAGS) -shared" fi ;; *darwin* ) DYNAMIC_LINK_FLAGS="" ELF_CC="\$(CC)" ELF_CFLAGS="\$(CFLAGS) -fno-common" ELF_LINK="\$(CC) \$(LDFLAGS) -dynamiclib -install_name \$(install_lib_dir)/\$(ELFLIB_MAJOR) -compatibility_version \$(ELF_MAJOR_VERSION) -current_version \$(ELF_MAJOR_VERSION).\$(ELF_MINOR_VERSION)" ELF_DEP_LIBS="\$(LDFLAGS) \$(DL_LIB)" CC_SHARED="\$(CC) -bundle -flat_namespace -undefined suppress \$(CFLAGS) -fno-common" ELFLIB="lib\$(THIS_LIB).dylib" ELFLIB_MAJOR="lib\$(THIS_LIB).\$(ELF_MAJOR_VERSION).dylib" ELFLIB_MAJOR_MINOR="lib\$(THIS_LIB).\$(ELF_MAJOR_VERSION).\$(ELF_MINOR_VERSION).dylib" ELFLIB_MAJOR_MINOR_MICRO="lib\$(THIS_LIB).\$(ELF_MAJOR_VERSION).\$(ELF_MINOR_VERSION).\$(ELF_MICRO_VERSION).dylib" ;; *freebsd* ) ELF_CC="\$(CC)" ELF_CFLAGS="\$(CFLAGS) -fPIC" #if test "X$PORTOBJFORMAT" = "Xelf" ; then # ELF_LINK="\$(CC) \$(LDFLAGS) -shared -Wl,-soname,\$(ELFLIB_MAJOR)" #else # ELF_LINK="ld -Bshareable -x" #fi ELF_LINK="\$(CC) \$(LDFLAGS) -shared -Wl,-soname,\$(ELFLIB_MAJOR)" ELF_DEP_LIBS="\$(DL_LIB) -lm" CC_SHARED="\$(CC) \$(CFLAGS) -shared -fPIC" ;; *cygwin* ) DYNAMIC_LINK_FLAGS="" ELF_CC="\$(CC)" SLANG_DLL_CFLAGS="-DSLANG_DLL=1" ELF_CFLAGS="\$(CFLAGS) -DBUILD_DLL=1" DLL_IMPLIB_NAME="lib\$(THIS_LIB)\$(ELFLIB_MAJOR_VERSION).dll.a" #ELF_LINK="\$(CC) \$(LDFLAGS) -shared -Wl,-O1 -Wl,--version-script,\$(VERSION_SCRIPT) -Wl,-soname,\$(ELFLIB_MAJOR) -Wl,--out-implib=\$(DLL_IMPLIB_NAME) -Wl,-export-all-symbols -Wl,-enable-auto-import" ELF_LINK="\$(CC) \$(LDFLAGS) -shared -Wl,-O1 -Wl,--version-script,\$(VERSION_SCRIPT) -Wl,-soname,\$(ELFLIB_MAJOR) -Wl,--out-implib=\$(DLL_IMPLIB_NAME)" ELF_DEP_LIBS="\$(DL_LIB) -lm" CC_SHARED="\$(CC) \$(CFLAGS) -shared -DSLANG_DLL=1" SLANG_LIB_FOR_MODULES="-L\$(ELFDIR) -lslang" INSTALL_MODULE="\$(INSTALL)" INSTALL_ELFLIB_TARGET="install-elf-cygwin" ELFLIB="lib\$(THIS_LIB).dll" ELFLIB_MAJOR="lib\$(THIS_LIB)\$(ELF_MAJOR_VERSION).dll" ELFLIB_MAJOR_MINOR="lib\$(THIS_LIB)\$(ELF_MAJOR_VERSION)_\$(ELF_MINOR_VERSION).dll" ELFLIB_MAJOR_MINOR_MICRO="lib\$(THIS_LIB)\$(ELF_MAJOR_VERSION)_\$(ELF_MINOR_VERSION)_\$(ELF_MICRO_VERSION).dll" ELFLIB_BUILD_NAME="\$(ELFLIB_MAJOR)" ;; *haiku* ) M_LIB="" DYNAMIC_LINK_FLAGS="-Wl,-export-dynamic" ELF_CC="\$(CC)" ELF_CFLAGS="\$(CFLAGS) -fPIC" ELF_LINK="\$(CC) \$(LDFLAGS) -shared -Wl,-O1 -Wl,--version-script,\$(VERSION_SCRIPT) -Wl,-soname,\$(ELFLIB_MAJOR)" ELF_DEP_LIBS="\$(DL_LIB)" CC_SHARED="\$(CC) \$(CFLAGS) -shared -fPIC" ;; * ) echo "Note: ELF compiler for host_os=$host_os may be wrong" ELF_CC="\$(CC)" ELF_CFLAGS="\$(CFLAGS) -fPIC" ELF_LINK="\$(CC) \$(LDFLAGS) -shared" ELF_DEP_LIBS="\$(DL_LIB) -lm -lc" CC_SHARED="\$(CC) \$(CFLAGS) -shared -fPIC" esac if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}pkg-config", so it can be a program name with args. set dummy ${ac_tool_prefix}pkg-config; ac_word=$2 { echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_path_PKG_CONFIG+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else case $PKG_CONFIG in [\\/]* | ?:[\\/]*) ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS ;; esac fi PKG_CONFIG=$ac_cv_path_PKG_CONFIG if test -n "$PKG_CONFIG"; then { echo "$as_me:$LINENO: result: $PKG_CONFIG" >&5 echo "${ECHO_T}$PKG_CONFIG" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } fi fi if test -z "$ac_cv_path_PKG_CONFIG"; then ac_pt_PKG_CONFIG=$PKG_CONFIG # Extract the first word of "pkg-config", so it can be a program name with args. set dummy pkg-config; ac_word=$2 { echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_path_ac_pt_PKG_CONFIG+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else case $ac_pt_PKG_CONFIG in [\\/]* | ?:[\\/]*) ac_cv_path_ac_pt_PKG_CONFIG="$ac_pt_PKG_CONFIG" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_ac_pt_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS ;; esac fi ac_pt_PKG_CONFIG=$ac_cv_path_ac_pt_PKG_CONFIG if test -n "$ac_pt_PKG_CONFIG"; then { echo "$as_me:$LINENO: result: $ac_pt_PKG_CONFIG" >&5 echo "${ECHO_T}$ac_pt_PKG_CONFIG" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } fi if test "x$ac_pt_PKG_CONFIG" = x; then PKG_CONFIG="" else case $cross_compiling:$ac_tool_warned in yes:) { echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools whose name does not start with the host triplet. If you think this configuration is useful to you, please write to autoconf@gnu.org." >&5 echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools whose name does not start with the host triplet. If you think this configuration is useful to you, please write to autoconf@gnu.org." >&2;} ac_tool_warned=yes ;; esac PKG_CONFIG=$ac_pt_PKG_CONFIG fi else PKG_CONFIG="$ac_cv_path_PKG_CONFIG" fi fi if test -n "$PKG_CONFIG"; then _pkg_min_version=0.14.0 { echo "$as_me:$LINENO: checking pkg-config is at least version $_pkg_min_version" >&5 echo $ECHO_N "checking pkg-config is at least version $_pkg_min_version... $ECHO_C" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then { echo "$as_me:$LINENO: result: yes" >&5 echo "${ECHO_T}yes" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } PKG_CONFIG="" fi fi # determine X include and libs for XJed { echo "$as_me:$LINENO: checking for X" >&5 echo $ECHO_N "checking for X... $ECHO_C" >&6; } # Check whether --with-x was given. if test "${with_x+set}" = set; then withval=$with_x; fi # $have_x is `yes', `no', `disabled', or empty when we do not yet know. if test "x$with_x" = xno; then # The user explicitly disabled X. have_x=disabled else case $x_includes,$x_libraries in #( *\'*) { { echo "$as_me:$LINENO: error: Cannot use X directory names containing '" >&5 echo "$as_me: error: Cannot use X directory names containing '" >&2;} { (exit 1); exit 1; }; };; #( *,NONE | NONE,*) if test "${ac_cv_have_x+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else # One or both of the vars are not set, and there is no cached value. ac_x_includes=no ac_x_libraries=no rm -f -r conftest.dir if mkdir conftest.dir; then cd conftest.dir cat >Imakefile <<'_ACEOF' incroot: @echo incroot='${INCROOT}' usrlibdir: @echo usrlibdir='${USRLIBDIR}' libdir: @echo libdir='${LIBDIR}' _ACEOF if (export CC; ${XMKMF-xmkmf}) >/dev/null 2>/dev/null && test -f Makefile; then # GNU make sometimes prints "make[1]: Entering...", which would confuse us. for ac_var in incroot usrlibdir libdir; do eval "ac_im_$ac_var=\`\${MAKE-make} $ac_var 2>/dev/null | sed -n 's/^$ac_var=//p'\`" done # Open Windows xmkmf reportedly sets LIBDIR instead of USRLIBDIR. for ac_extension in a so sl; do if test ! -f "$ac_im_usrlibdir/libX11.$ac_extension" && test -f "$ac_im_libdir/libX11.$ac_extension"; then ac_im_usrlibdir=$ac_im_libdir; break fi done # Screen out bogus values from the imake configuration. They are # bogus both because they are the default anyway, and because # using them would break gcc on systems where it needs fixed includes. case $ac_im_incroot in /usr/include) ac_x_includes= ;; *) test -f "$ac_im_incroot/X11/Xos.h" && ac_x_includes=$ac_im_incroot;; esac case $ac_im_usrlibdir in /usr/lib | /lib) ;; *) test -d "$ac_im_usrlibdir" && ac_x_libraries=$ac_im_usrlibdir ;; esac fi cd .. rm -f -r conftest.dir fi # Standard set of common directories for X headers. # Check X11 before X11Rn because it is often a symlink to the current release. ac_x_header_dirs=' /usr/X11/include /usr/X11R6/include /usr/X11R5/include /usr/X11R4/include /usr/include/X11 /usr/include/X11R6 /usr/include/X11R5 /usr/include/X11R4 /usr/local/X11/include /usr/local/X11R6/include /usr/local/X11R5/include /usr/local/X11R4/include /usr/local/include/X11 /usr/local/include/X11R6 /usr/local/include/X11R5 /usr/local/include/X11R4 /usr/X386/include /usr/x386/include /usr/XFree86/include/X11 /usr/include /usr/local/include /usr/unsupported/include /usr/athena/include /usr/local/x11r5/include /usr/lpp/Xamples/include /usr/openwin/include /usr/openwin/share/include' if test "$ac_x_includes" = no; then # Guess where to find include files, by looking for Xlib.h. # First, try using that file with no special directory specified. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include _ACEOF if { (ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then # We can compile using X headers with no special include directory. ac_x_includes= else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 for ac_dir in $ac_x_header_dirs; do if test -r "$ac_dir/X11/Xlib.h"; then ac_x_includes=$ac_dir break fi done fi rm -f conftest.err conftest.$ac_ext fi # $ac_x_includes = no if test "$ac_x_libraries" = no; then # Check for the libraries. # See if we find them without any special options. # Don't add to $LIBS permanently. ac_save_LIBS=$LIBS LIBS="-lX11 $LIBS" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include int main () { XrmInitialize () ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && $as_test_x conftest$ac_exeext; then LIBS=$ac_save_LIBS # We can link X programs with no special library path. ac_x_libraries= else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 LIBS=$ac_save_LIBS for ac_dir in `echo "$ac_x_includes $ac_x_header_dirs" | sed s/include/lib/g` do # Don't even attempt the hair of trying to link an X program! for ac_extension in a so sl; do if test -r "$ac_dir/libX11.$ac_extension"; then ac_x_libraries=$ac_dir break 2 fi done done fi rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext fi # $ac_x_libraries = no case $ac_x_includes,$ac_x_libraries in #( no,* | *,no | *\'*) # Didn't find X, or a directory has "'" in its name. ac_cv_have_x="have_x=no";; #( *) # Record where we found X for the cache. ac_cv_have_x="have_x=yes\ ac_x_includes='$ac_x_includes'\ ac_x_libraries='$ac_x_libraries'" esac fi ;; #( *) have_x=yes;; esac eval "$ac_cv_have_x" fi # $with_x != no if test "$have_x" != yes; then { echo "$as_me:$LINENO: result: $have_x" >&5 echo "${ECHO_T}$have_x" >&6; } no_x=yes else # If each of the values was on the command line, it overrides each guess. test "x$x_includes" = xNONE && x_includes=$ac_x_includes test "x$x_libraries" = xNONE && x_libraries=$ac_x_libraries # Update the cache value to reflect the command line values. ac_cv_have_x="have_x=yes\ ac_x_includes='$x_includes'\ ac_x_libraries='$x_libraries'" { echo "$as_me:$LINENO: result: libraries $x_libraries, headers $x_includes" >&5 echo "${ECHO_T}libraries $x_libraries, headers $x_includes" >&6; } fi if test "$no_x" = yes; then # Not all programs may use this symbol, but it does not hurt to define it. cat >>confdefs.h <<\_ACEOF #define X_DISPLAY_MISSING 1 _ACEOF X_CFLAGS= X_PRE_LIBS= X_LIBS= X_EXTRA_LIBS= else if test -n "$x_includes"; then X_CFLAGS="$X_CFLAGS -I$x_includes" fi # It would also be nice to do this for all -L options, not just this one. if test -n "$x_libraries"; then X_LIBS="$X_LIBS -L$x_libraries" # For Solaris; some versions of Sun CC require a space after -R and # others require no space. Words are not sufficient . . . . { echo "$as_me:$LINENO: checking whether -R must be followed by a space" >&5 echo $ECHO_N "checking whether -R must be followed by a space... $ECHO_C" >&6; } ac_xsave_LIBS=$LIBS; LIBS="$LIBS -R$x_libraries" ac_xsave_c_werror_flag=$ac_c_werror_flag ac_c_werror_flag=yes cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && $as_test_x conftest$ac_exeext; then { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } X_LIBS="$X_LIBS -R$x_libraries" else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 LIBS="$ac_xsave_LIBS -R $x_libraries" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && $as_test_x conftest$ac_exeext; then { echo "$as_me:$LINENO: result: yes" >&5 echo "${ECHO_T}yes" >&6; } X_LIBS="$X_LIBS -R $x_libraries" else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { echo "$as_me:$LINENO: result: neither works" >&5 echo "${ECHO_T}neither works" >&6; } fi rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext ac_c_werror_flag=$ac_xsave_c_werror_flag LIBS=$ac_xsave_LIBS fi # Check for system-dependent libraries X programs must link with. # Do this before checking for the system-independent R6 libraries # (-lICE), since we may need -lsocket or whatever for X linking. if test "$ISC" = yes; then X_EXTRA_LIBS="$X_EXTRA_LIBS -lnsl_s -linet" else # Martyn Johnson says this is needed for Ultrix, if the X # libraries were built with DECnet support. And Karl Berry says # the Alpha needs dnet_stub (dnet does not exist). ac_xsave_LIBS="$LIBS"; LIBS="$LIBS $X_LIBS -lX11" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char XOpenDisplay (); int main () { return XOpenDisplay (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && $as_test_x conftest$ac_exeext; then : else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { echo "$as_me:$LINENO: checking for dnet_ntoa in -ldnet" >&5 echo $ECHO_N "checking for dnet_ntoa in -ldnet... $ECHO_C" >&6; } if test "${ac_cv_lib_dnet_dnet_ntoa+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ldnet $LIBS" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char dnet_ntoa (); int main () { return dnet_ntoa (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && $as_test_x conftest$ac_exeext; then ac_cv_lib_dnet_dnet_ntoa=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_dnet_dnet_ntoa=no fi rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { echo "$as_me:$LINENO: result: $ac_cv_lib_dnet_dnet_ntoa" >&5 echo "${ECHO_T}$ac_cv_lib_dnet_dnet_ntoa" >&6; } if test $ac_cv_lib_dnet_dnet_ntoa = yes; then X_EXTRA_LIBS="$X_EXTRA_LIBS -ldnet" fi if test $ac_cv_lib_dnet_dnet_ntoa = no; then { echo "$as_me:$LINENO: checking for dnet_ntoa in -ldnet_stub" >&5 echo $ECHO_N "checking for dnet_ntoa in -ldnet_stub... $ECHO_C" >&6; } if test "${ac_cv_lib_dnet_stub_dnet_ntoa+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ldnet_stub $LIBS" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char dnet_ntoa (); int main () { return dnet_ntoa (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && $as_test_x conftest$ac_exeext; then ac_cv_lib_dnet_stub_dnet_ntoa=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_dnet_stub_dnet_ntoa=no fi rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { echo "$as_me:$LINENO: result: $ac_cv_lib_dnet_stub_dnet_ntoa" >&5 echo "${ECHO_T}$ac_cv_lib_dnet_stub_dnet_ntoa" >&6; } if test $ac_cv_lib_dnet_stub_dnet_ntoa = yes; then X_EXTRA_LIBS="$X_EXTRA_LIBS -ldnet_stub" fi fi fi rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext LIBS="$ac_xsave_LIBS" # msh@cis.ufl.edu says -lnsl (and -lsocket) are needed for his 386/AT, # to get the SysV transport functions. # Chad R. Larson says the Pyramis MIS-ES running DC/OSx (SVR4) # needs -lnsl. # The nsl library prevents programs from opening the X display # on Irix 5.2, according to T.E. Dickey. # The functions gethostbyname, getservbyname, and inet_addr are # in -lbsd on LynxOS 3.0.1/i386, according to Lars Hecking. { echo "$as_me:$LINENO: checking for gethostbyname" >&5 echo $ECHO_N "checking for gethostbyname... $ECHO_C" >&6; } if test "${ac_cv_func_gethostbyname+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Define gethostbyname to an innocuous variant, in case declares gethostbyname. For example, HP-UX 11i declares gettimeofday. */ #define gethostbyname innocuous_gethostbyname /* System header to define __stub macros and hopefully few prototypes, which can conflict with char gethostbyname (); below. Prefer to if __STDC__ is defined, since exists even on freestanding compilers. */ #ifdef __STDC__ # include #else # include #endif #undef gethostbyname /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char gethostbyname (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined __stub_gethostbyname || defined __stub___gethostbyname choke me #endif int main () { return gethostbyname (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && $as_test_x conftest$ac_exeext; then ac_cv_func_gethostbyname=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_func_gethostbyname=no fi rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext fi { echo "$as_me:$LINENO: result: $ac_cv_func_gethostbyname" >&5 echo "${ECHO_T}$ac_cv_func_gethostbyname" >&6; } if test $ac_cv_func_gethostbyname = no; then { echo "$as_me:$LINENO: checking for gethostbyname in -lnsl" >&5 echo $ECHO_N "checking for gethostbyname in -lnsl... $ECHO_C" >&6; } if test "${ac_cv_lib_nsl_gethostbyname+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lnsl $LIBS" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char gethostbyname (); int main () { return gethostbyname (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && $as_test_x conftest$ac_exeext; then ac_cv_lib_nsl_gethostbyname=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_nsl_gethostbyname=no fi rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { echo "$as_me:$LINENO: result: $ac_cv_lib_nsl_gethostbyname" >&5 echo "${ECHO_T}$ac_cv_lib_nsl_gethostbyname" >&6; } if test $ac_cv_lib_nsl_gethostbyname = yes; then X_EXTRA_LIBS="$X_EXTRA_LIBS -lnsl" fi if test $ac_cv_lib_nsl_gethostbyname = no; then { echo "$as_me:$LINENO: checking for gethostbyname in -lbsd" >&5 echo $ECHO_N "checking for gethostbyname in -lbsd... $ECHO_C" >&6; } if test "${ac_cv_lib_bsd_gethostbyname+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lbsd $LIBS" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char gethostbyname (); int main () { return gethostbyname (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && $as_test_x conftest$ac_exeext; then ac_cv_lib_bsd_gethostbyname=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_bsd_gethostbyname=no fi rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { echo "$as_me:$LINENO: result: $ac_cv_lib_bsd_gethostbyname" >&5 echo "${ECHO_T}$ac_cv_lib_bsd_gethostbyname" >&6; } if test $ac_cv_lib_bsd_gethostbyname = yes; then X_EXTRA_LIBS="$X_EXTRA_LIBS -lbsd" fi fi fi # lieder@skyler.mavd.honeywell.com says without -lsocket, # socket/setsockopt and other routines are undefined under SCO ODT # 2.0. But -lsocket is broken on IRIX 5.2 (and is not necessary # on later versions), says Simon Leinen: it contains gethostby* # variants that don't use the name server (or something). -lsocket # must be given before -lnsl if both are needed. We assume that # if connect needs -lnsl, so does gethostbyname. { echo "$as_me:$LINENO: checking for connect" >&5 echo $ECHO_N "checking for connect... $ECHO_C" >&6; } if test "${ac_cv_func_connect+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Define connect to an innocuous variant, in case declares connect. For example, HP-UX 11i declares gettimeofday. */ #define connect innocuous_connect /* System header to define __stub macros and hopefully few prototypes, which can conflict with char connect (); below. Prefer to if __STDC__ is defined, since exists even on freestanding compilers. */ #ifdef __STDC__ # include #else # include #endif #undef connect /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char connect (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined __stub_connect || defined __stub___connect choke me #endif int main () { return connect (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && $as_test_x conftest$ac_exeext; then ac_cv_func_connect=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_func_connect=no fi rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext fi { echo "$as_me:$LINENO: result: $ac_cv_func_connect" >&5 echo "${ECHO_T}$ac_cv_func_connect" >&6; } if test $ac_cv_func_connect = no; then { echo "$as_me:$LINENO: checking for connect in -lsocket" >&5 echo $ECHO_N "checking for connect in -lsocket... $ECHO_C" >&6; } if test "${ac_cv_lib_socket_connect+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lsocket $X_EXTRA_LIBS $LIBS" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char connect (); int main () { return connect (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && $as_test_x conftest$ac_exeext; then ac_cv_lib_socket_connect=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_socket_connect=no fi rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { echo "$as_me:$LINENO: result: $ac_cv_lib_socket_connect" >&5 echo "${ECHO_T}$ac_cv_lib_socket_connect" >&6; } if test $ac_cv_lib_socket_connect = yes; then X_EXTRA_LIBS="-lsocket $X_EXTRA_LIBS" fi fi # Guillermo Gomez says -lposix is necessary on A/UX. { echo "$as_me:$LINENO: checking for remove" >&5 echo $ECHO_N "checking for remove... $ECHO_C" >&6; } if test "${ac_cv_func_remove+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Define remove to an innocuous variant, in case declares remove. For example, HP-UX 11i declares gettimeofday. */ #define remove innocuous_remove /* System header to define __stub macros and hopefully few prototypes, which can conflict with char remove (); below. Prefer to if __STDC__ is defined, since exists even on freestanding compilers. */ #ifdef __STDC__ # include #else # include #endif #undef remove /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char remove (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined __stub_remove || defined __stub___remove choke me #endif int main () { return remove (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && $as_test_x conftest$ac_exeext; then ac_cv_func_remove=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_func_remove=no fi rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext fi { echo "$as_me:$LINENO: result: $ac_cv_func_remove" >&5 echo "${ECHO_T}$ac_cv_func_remove" >&6; } if test $ac_cv_func_remove = no; then { echo "$as_me:$LINENO: checking for remove in -lposix" >&5 echo $ECHO_N "checking for remove in -lposix... $ECHO_C" >&6; } if test "${ac_cv_lib_posix_remove+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lposix $LIBS" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char remove (); int main () { return remove (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && $as_test_x conftest$ac_exeext; then ac_cv_lib_posix_remove=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_posix_remove=no fi rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { echo "$as_me:$LINENO: result: $ac_cv_lib_posix_remove" >&5 echo "${ECHO_T}$ac_cv_lib_posix_remove" >&6; } if test $ac_cv_lib_posix_remove = yes; then X_EXTRA_LIBS="$X_EXTRA_LIBS -lposix" fi fi # BSDI BSD/OS 2.1 needs -lipc for XOpenDisplay. { echo "$as_me:$LINENO: checking for shmat" >&5 echo $ECHO_N "checking for shmat... $ECHO_C" >&6; } if test "${ac_cv_func_shmat+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Define shmat to an innocuous variant, in case declares shmat. For example, HP-UX 11i declares gettimeofday. */ #define shmat innocuous_shmat /* System header to define __stub macros and hopefully few prototypes, which can conflict with char shmat (); below. Prefer to if __STDC__ is defined, since exists even on freestanding compilers. */ #ifdef __STDC__ # include #else # include #endif #undef shmat /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char shmat (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined __stub_shmat || defined __stub___shmat choke me #endif int main () { return shmat (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && $as_test_x conftest$ac_exeext; then ac_cv_func_shmat=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_func_shmat=no fi rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext fi { echo "$as_me:$LINENO: result: $ac_cv_func_shmat" >&5 echo "${ECHO_T}$ac_cv_func_shmat" >&6; } if test $ac_cv_func_shmat = no; then { echo "$as_me:$LINENO: checking for shmat in -lipc" >&5 echo $ECHO_N "checking for shmat in -lipc... $ECHO_C" >&6; } if test "${ac_cv_lib_ipc_shmat+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lipc $LIBS" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char shmat (); int main () { return shmat (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && $as_test_x conftest$ac_exeext; then ac_cv_lib_ipc_shmat=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_ipc_shmat=no fi rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { echo "$as_me:$LINENO: result: $ac_cv_lib_ipc_shmat" >&5 echo "${ECHO_T}$ac_cv_lib_ipc_shmat" >&6; } if test $ac_cv_lib_ipc_shmat = yes; then X_EXTRA_LIBS="$X_EXTRA_LIBS -lipc" fi fi fi # Check for libraries that X11R6 Xt/Xaw programs need. ac_save_LDFLAGS=$LDFLAGS test -n "$x_libraries" && LDFLAGS="$LDFLAGS -L$x_libraries" # SM needs ICE to (dynamically) link under SunOS 4.x (so we have to # check for ICE first), but we must link in the order -lSM -lICE or # we get undefined symbols. So assume we have SM if we have ICE. # These have to be linked with before -lX11, unlike the other # libraries we check for below, so use a different variable. # John Interrante, Karl Berry { echo "$as_me:$LINENO: checking for IceConnectionNumber in -lICE" >&5 echo $ECHO_N "checking for IceConnectionNumber in -lICE... $ECHO_C" >&6; } if test "${ac_cv_lib_ICE_IceConnectionNumber+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lICE $X_EXTRA_LIBS $LIBS" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char IceConnectionNumber (); int main () { return IceConnectionNumber (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && $as_test_x conftest$ac_exeext; then ac_cv_lib_ICE_IceConnectionNumber=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_ICE_IceConnectionNumber=no fi rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { echo "$as_me:$LINENO: result: $ac_cv_lib_ICE_IceConnectionNumber" >&5 echo "${ECHO_T}$ac_cv_lib_ICE_IceConnectionNumber" >&6; } if test $ac_cv_lib_ICE_IceConnectionNumber = yes; then X_PRE_LIBS="$X_PRE_LIBS -lSM -lICE" fi LDFLAGS=$ac_save_LDFLAGS fi #Check these header since they cause trouble for ac_header in \ stdlib.h \ unistd.h \ memory.h \ glob.h \ malloc.h \ termios.h \ fcntl.h \ sys/fcntl.h \ sys/pty.h \ pty.h \ do as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then { echo "$as_me:$LINENO: checking for $ac_header" >&5 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then echo $ECHO_N "(cached) $ECHO_C" >&6 fi ac_res=`eval echo '${'$as_ac_Header'}'` { echo "$as_me:$LINENO: result: $ac_res" >&5 echo "${ECHO_T}$ac_res" >&6; } else # Is the header compilable? { echo "$as_me:$LINENO: checking $ac_header usability" >&5 echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default #include <$ac_header> _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_header_compiler=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_compiler=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 echo "${ECHO_T}$ac_header_compiler" >&6; } # Is the header present? { echo "$as_me:$LINENO: checking $ac_header presence" >&5 echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include <$ac_header> _ACEOF if { (ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then ac_header_preproc=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_preproc=no fi rm -f conftest.err conftest.$ac_ext { echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 echo "${ECHO_T}$ac_header_preproc" >&6; } # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in yes:no: ) { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} ac_header_preproc=yes ;; no:yes:* ) { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} ( cat <<\_ASBOX ## ------------------------------------ ## ## Report this to jed-users@jedsoft.org ## ## ------------------------------------ ## _ASBOX ) | sed "s/^/$as_me: WARNING: /" >&2 ;; esac { echo "$as_me:$LINENO: checking for $ac_header" >&5 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then echo $ECHO_N "(cached) $ECHO_C" >&6 else eval "$as_ac_Header=\$ac_header_preproc" fi ac_res=`eval echo '${'$as_ac_Header'}'` { echo "$as_me:$LINENO: result: $ac_res" >&5 echo "${ECHO_T}$ac_res" >&6; } fi if test `eval echo '${'$as_ac_Header'}'` = yes; then cat >>confdefs.h <<_ACEOF #define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done # special treatment for sys/wait.h { echo "$as_me:$LINENO: checking for sys/wait.h that is POSIX.1 compatible" >&5 echo $ECHO_N "checking for sys/wait.h that is POSIX.1 compatible... $ECHO_C" >&6; } if test "${ac_cv_header_sys_wait_h+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include #ifndef WEXITSTATUS # define WEXITSTATUS(stat_val) ((unsigned int) (stat_val) >> 8) #endif #ifndef WIFEXITED # define WIFEXITED(stat_val) (((stat_val) & 255) == 0) #endif int main () { int s; wait (&s); s = WIFEXITED (s) ? WEXITSTATUS (s) : 1; ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_cv_header_sys_wait_h=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_header_sys_wait_h=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { echo "$as_me:$LINENO: result: $ac_cv_header_sys_wait_h" >&5 echo "${ECHO_T}$ac_cv_header_sys_wait_h" >&6; } if test $ac_cv_header_sys_wait_h = yes; then cat >>confdefs.h <<\_ACEOF #define HAVE_SYS_WAIT_H 1 _ACEOF fi ac_header_dirent=no for ac_hdr in dirent.h sys/ndir.h sys/dir.h ndir.h; do as_ac_Header=`echo "ac_cv_header_dirent_$ac_hdr" | $as_tr_sh` { echo "$as_me:$LINENO: checking for $ac_hdr that defines DIR" >&5 echo $ECHO_N "checking for $ac_hdr that defines DIR... $ECHO_C" >&6; } if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include <$ac_hdr> int main () { if ((DIR *) 0) return 0; ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then eval "$as_ac_Header=yes" else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 eval "$as_ac_Header=no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi ac_res=`eval echo '${'$as_ac_Header'}'` { echo "$as_me:$LINENO: result: $ac_res" >&5 echo "${ECHO_T}$ac_res" >&6; } if test `eval echo '${'$as_ac_Header'}'` = yes; then cat >>confdefs.h <<_ACEOF #define `echo "HAVE_$ac_hdr" | $as_tr_cpp` 1 _ACEOF ac_header_dirent=$ac_hdr; break fi done # Two versions of opendir et al. are in -ldir and -lx on SCO Xenix. if test $ac_header_dirent = dirent.h; then { echo "$as_me:$LINENO: checking for library containing opendir" >&5 echo $ECHO_N "checking for library containing opendir... $ECHO_C" >&6; } if test "${ac_cv_search_opendir+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_func_search_save_LIBS=$LIBS cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char opendir (); int main () { return opendir (); ; return 0; } _ACEOF for ac_lib in '' dir; do if test -z "$ac_lib"; then ac_res="none required" else ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi rm -f conftest.$ac_objext conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && $as_test_x conftest$ac_exeext; then ac_cv_search_opendir=$ac_res else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext if test "${ac_cv_search_opendir+set}" = set; then break fi done if test "${ac_cv_search_opendir+set}" = set; then : else ac_cv_search_opendir=no fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi { echo "$as_me:$LINENO: result: $ac_cv_search_opendir" >&5 echo "${ECHO_T}$ac_cv_search_opendir" >&6; } ac_res=$ac_cv_search_opendir if test "$ac_res" != no; then test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" fi else { echo "$as_me:$LINENO: checking for library containing opendir" >&5 echo $ECHO_N "checking for library containing opendir... $ECHO_C" >&6; } if test "${ac_cv_search_opendir+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_func_search_save_LIBS=$LIBS cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char opendir (); int main () { return opendir (); ; return 0; } _ACEOF for ac_lib in '' x; do if test -z "$ac_lib"; then ac_res="none required" else ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi rm -f conftest.$ac_objext conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && $as_test_x conftest$ac_exeext; then ac_cv_search_opendir=$ac_res else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext if test "${ac_cv_search_opendir+set}" = set; then break fi done if test "${ac_cv_search_opendir+set}" = set; then : else ac_cv_search_opendir=no fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi { echo "$as_me:$LINENO: result: $ac_cv_search_opendir" >&5 echo "${ECHO_T}$ac_cv_search_opendir" >&6; } ac_res=$ac_cv_search_opendir if test "$ac_res" != no; then test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" fi fi { echo "$as_me:$LINENO: checking for mode_t" >&5 echo $ECHO_N "checking for mode_t... $ECHO_C" >&6; } if test "${ac_cv_type_mode_t+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default typedef mode_t ac__type_new_; int main () { if ((ac__type_new_ *) 0) return 0; if (sizeof (ac__type_new_)) return 0; ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_cv_type_mode_t=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_type_mode_t=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { echo "$as_me:$LINENO: result: $ac_cv_type_mode_t" >&5 echo "${ECHO_T}$ac_cv_type_mode_t" >&6; } if test $ac_cv_type_mode_t = yes; then : else cat >>confdefs.h <<_ACEOF #define mode_t int _ACEOF fi { echo "$as_me:$LINENO: checking for pid_t" >&5 echo $ECHO_N "checking for pid_t... $ECHO_C" >&6; } if test "${ac_cv_type_pid_t+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default typedef pid_t ac__type_new_; int main () { if ((ac__type_new_ *) 0) return 0; if (sizeof (ac__type_new_)) return 0; ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_cv_type_pid_t=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_type_pid_t=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { echo "$as_me:$LINENO: result: $ac_cv_type_pid_t" >&5 echo "${ECHO_T}$ac_cv_type_pid_t" >&6; } if test $ac_cv_type_pid_t = yes; then : else cat >>confdefs.h <<_ACEOF #define pid_t int _ACEOF fi { echo "$as_me:$LINENO: checking for uid_t in sys/types.h" >&5 echo $ECHO_N "checking for uid_t in sys/types.h... $ECHO_C" >&6; } if test "${ac_cv_type_uid_t+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "uid_t" >/dev/null 2>&1; then ac_cv_type_uid_t=yes else ac_cv_type_uid_t=no fi rm -f conftest* fi { echo "$as_me:$LINENO: result: $ac_cv_type_uid_t" >&5 echo "${ECHO_T}$ac_cv_type_uid_t" >&6; } if test $ac_cv_type_uid_t = no; then cat >>confdefs.h <<\_ACEOF #define uid_t int _ACEOF cat >>confdefs.h <<\_ACEOF #define gid_t int _ACEOF fi { echo "$as_me:$LINENO: checking for openpty in -lutil" >&5 echo $ECHO_N "checking for openpty in -lutil... $ECHO_C" >&6; } if test "${ac_cv_lib_util_openpty+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lutil $LIBS" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char openpty (); int main () { return openpty (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && $as_test_x conftest$ac_exeext; then ac_cv_lib_util_openpty=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_util_openpty=no fi rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { echo "$as_me:$LINENO: result: $ac_cv_lib_util_openpty" >&5 echo "${ECHO_T}$ac_cv_lib_util_openpty" >&6; } if test $ac_cv_lib_util_openpty = yes; then cat >>confdefs.h <<_ACEOF #define HAVE_LIBUTIL 1 _ACEOF LIBS="-lutil $LIBS" fi for ac_func in \ memset \ memcpy \ putenv \ setenv \ unsetenv \ getcwd \ setsid \ tcgetattr tcsetattr cfgetospeed \ grantpt \ setlocale \ utime \ symlink \ gethostname \ tcgetpgrp \ tcsetpgrp \ getpgid \ setpgid \ openpty \ snprintf vsnprintf \ do as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` { echo "$as_me:$LINENO: checking for $ac_func" >&5 echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6; } if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Define $ac_func to an innocuous variant, in case declares $ac_func. For example, HP-UX 11i declares gettimeofday. */ #define $ac_func innocuous_$ac_func /* System header to define __stub macros and hopefully few prototypes, which can conflict with char $ac_func (); below. Prefer to if __STDC__ is defined, since exists even on freestanding compilers. */ #ifdef __STDC__ # include #else # include #endif #undef $ac_func /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char $ac_func (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined __stub_$ac_func || defined __stub___$ac_func choke me #endif int main () { return $ac_func (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && $as_test_x conftest$ac_exeext; then eval "$as_ac_var=yes" else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 eval "$as_ac_var=no" fi rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext fi ac_res=`eval echo '${'$as_ac_var'}'` { echo "$as_me:$LINENO: result: $ac_res" >&5 echo "${ECHO_T}$ac_res" >&6; } if test `eval echo '${'$as_ac_var'}'` = yes; then cat >>confdefs.h <<_ACEOF #define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF fi done { echo "$as_me:$LINENO: checking for short" >&5 echo $ECHO_N "checking for short... $ECHO_C" >&6; } if test "${ac_cv_type_short+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default typedef short ac__type_new_; int main () { if ((ac__type_new_ *) 0) return 0; if (sizeof (ac__type_new_)) return 0; ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_cv_type_short=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_type_short=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { echo "$as_me:$LINENO: result: $ac_cv_type_short" >&5 echo "${ECHO_T}$ac_cv_type_short" >&6; } # The cast to long int works around a bug in the HP C Compiler # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. # This bug is HP SR number 8606223364. { echo "$as_me:$LINENO: checking size of short" >&5 echo $ECHO_N "checking size of short... $ECHO_C" >&6; } if test "${ac_cv_sizeof_short+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test "$cross_compiling" = yes; then # Depending upon the size, compute the lo and hi bounds. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default typedef short ac__type_sizeof_; int main () { static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) >= 0)]; test_array [0] = 0 ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_lo=0 ac_mid=0 while :; do cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default typedef short ac__type_sizeof_; int main () { static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) <= $ac_mid)]; test_array [0] = 0 ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_hi=$ac_mid; break else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_lo=`expr $ac_mid + 1` if test $ac_lo -le $ac_mid; then ac_lo= ac_hi= break fi ac_mid=`expr 2 '*' $ac_mid + 1` fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext done else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default typedef short ac__type_sizeof_; int main () { static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) < 0)]; test_array [0] = 0 ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_hi=-1 ac_mid=-1 while :; do cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default typedef short ac__type_sizeof_; int main () { static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) >= $ac_mid)]; test_array [0] = 0 ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_lo=$ac_mid; break else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_hi=`expr '(' $ac_mid ')' - 1` if test $ac_mid -le $ac_hi; then ac_lo= ac_hi= break fi ac_mid=`expr 2 '*' $ac_mid` fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext done else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_lo= ac_hi= fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext # Binary search between lo and hi bounds. while test "x$ac_lo" != "x$ac_hi"; do ac_mid=`expr '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo` cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default typedef short ac__type_sizeof_; int main () { static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) <= $ac_mid)]; test_array [0] = 0 ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_hi=$ac_mid else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_lo=`expr '(' $ac_mid ')' + 1` fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext done case $ac_lo in ?*) ac_cv_sizeof_short=$ac_lo;; '') if test "$ac_cv_type_short" = yes; then { { echo "$as_me:$LINENO: error: cannot compute sizeof (short) See \`config.log' for more details." >&5 echo "$as_me: error: cannot compute sizeof (short) See \`config.log' for more details." >&2;} { (exit 77); exit 77; }; } else ac_cv_sizeof_short=0 fi ;; esac else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default typedef short ac__type_sizeof_; static long int longval () { return (long int) (sizeof (ac__type_sizeof_)); } static unsigned long int ulongval () { return (long int) (sizeof (ac__type_sizeof_)); } #include #include int main () { FILE *f = fopen ("conftest.val", "w"); if (! f) return 1; if (((long int) (sizeof (ac__type_sizeof_))) < 0) { long int i = longval (); if (i != ((long int) (sizeof (ac__type_sizeof_)))) return 1; fprintf (f, "%ld\n", i); } else { unsigned long int i = ulongval (); if (i != ((long int) (sizeof (ac__type_sizeof_)))) return 1; fprintf (f, "%lu\n", i); } return ferror (f) || fclose (f) != 0; ; return 0; } _ACEOF rm -f conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='./conftest$ac_exeext' { (case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_try") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_sizeof_short=`cat conftest.val` else echo "$as_me: program exited with status $ac_status" >&5 echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) if test "$ac_cv_type_short" = yes; then { { echo "$as_me:$LINENO: error: cannot compute sizeof (short) See \`config.log' for more details." >&5 echo "$as_me: error: cannot compute sizeof (short) See \`config.log' for more details." >&2;} { (exit 77); exit 77; }; } else ac_cv_sizeof_short=0 fi fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi rm -f conftest.val fi { echo "$as_me:$LINENO: result: $ac_cv_sizeof_short" >&5 echo "${ECHO_T}$ac_cv_sizeof_short" >&6; } cat >>confdefs.h <<_ACEOF #define SIZEOF_SHORT $ac_cv_sizeof_short _ACEOF { echo "$as_me:$LINENO: checking for int" >&5 echo $ECHO_N "checking for int... $ECHO_C" >&6; } if test "${ac_cv_type_int+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default typedef int ac__type_new_; int main () { if ((ac__type_new_ *) 0) return 0; if (sizeof (ac__type_new_)) return 0; ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_cv_type_int=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_type_int=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { echo "$as_me:$LINENO: result: $ac_cv_type_int" >&5 echo "${ECHO_T}$ac_cv_type_int" >&6; } # The cast to long int works around a bug in the HP C Compiler # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. # This bug is HP SR number 8606223364. { echo "$as_me:$LINENO: checking size of int" >&5 echo $ECHO_N "checking size of int... $ECHO_C" >&6; } if test "${ac_cv_sizeof_int+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test "$cross_compiling" = yes; then # Depending upon the size, compute the lo and hi bounds. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default typedef int ac__type_sizeof_; int main () { static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) >= 0)]; test_array [0] = 0 ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_lo=0 ac_mid=0 while :; do cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default typedef int ac__type_sizeof_; int main () { static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) <= $ac_mid)]; test_array [0] = 0 ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_hi=$ac_mid; break else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_lo=`expr $ac_mid + 1` if test $ac_lo -le $ac_mid; then ac_lo= ac_hi= break fi ac_mid=`expr 2 '*' $ac_mid + 1` fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext done else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default typedef int ac__type_sizeof_; int main () { static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) < 0)]; test_array [0] = 0 ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_hi=-1 ac_mid=-1 while :; do cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default typedef int ac__type_sizeof_; int main () { static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) >= $ac_mid)]; test_array [0] = 0 ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_lo=$ac_mid; break else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_hi=`expr '(' $ac_mid ')' - 1` if test $ac_mid -le $ac_hi; then ac_lo= ac_hi= break fi ac_mid=`expr 2 '*' $ac_mid` fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext done else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_lo= ac_hi= fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext # Binary search between lo and hi bounds. while test "x$ac_lo" != "x$ac_hi"; do ac_mid=`expr '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo` cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default typedef int ac__type_sizeof_; int main () { static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) <= $ac_mid)]; test_array [0] = 0 ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_hi=$ac_mid else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_lo=`expr '(' $ac_mid ')' + 1` fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext done case $ac_lo in ?*) ac_cv_sizeof_int=$ac_lo;; '') if test "$ac_cv_type_int" = yes; then { { echo "$as_me:$LINENO: error: cannot compute sizeof (int) See \`config.log' for more details." >&5 echo "$as_me: error: cannot compute sizeof (int) See \`config.log' for more details." >&2;} { (exit 77); exit 77; }; } else ac_cv_sizeof_int=0 fi ;; esac else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default typedef int ac__type_sizeof_; static long int longval () { return (long int) (sizeof (ac__type_sizeof_)); } static unsigned long int ulongval () { return (long int) (sizeof (ac__type_sizeof_)); } #include #include int main () { FILE *f = fopen ("conftest.val", "w"); if (! f) return 1; if (((long int) (sizeof (ac__type_sizeof_))) < 0) { long int i = longval (); if (i != ((long int) (sizeof (ac__type_sizeof_)))) return 1; fprintf (f, "%ld\n", i); } else { unsigned long int i = ulongval (); if (i != ((long int) (sizeof (ac__type_sizeof_)))) return 1; fprintf (f, "%lu\n", i); } return ferror (f) || fclose (f) != 0; ; return 0; } _ACEOF rm -f conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='./conftest$ac_exeext' { (case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_try") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_sizeof_int=`cat conftest.val` else echo "$as_me: program exited with status $ac_status" >&5 echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) if test "$ac_cv_type_int" = yes; then { { echo "$as_me:$LINENO: error: cannot compute sizeof (int) See \`config.log' for more details." >&5 echo "$as_me: error: cannot compute sizeof (int) See \`config.log' for more details." >&2;} { (exit 77); exit 77; }; } else ac_cv_sizeof_int=0 fi fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi rm -f conftest.val fi { echo "$as_me:$LINENO: result: $ac_cv_sizeof_int" >&5 echo "${ECHO_T}$ac_cv_sizeof_int" >&6; } cat >>confdefs.h <<_ACEOF #define SIZEOF_INT $ac_cv_sizeof_int _ACEOF { echo "$as_me:$LINENO: checking for long" >&5 echo $ECHO_N "checking for long... $ECHO_C" >&6; } if test "${ac_cv_type_long+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default typedef long ac__type_new_; int main () { if ((ac__type_new_ *) 0) return 0; if (sizeof (ac__type_new_)) return 0; ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_cv_type_long=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_type_long=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { echo "$as_me:$LINENO: result: $ac_cv_type_long" >&5 echo "${ECHO_T}$ac_cv_type_long" >&6; } # The cast to long int works around a bug in the HP C Compiler # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. # This bug is HP SR number 8606223364. { echo "$as_me:$LINENO: checking size of long" >&5 echo $ECHO_N "checking size of long... $ECHO_C" >&6; } if test "${ac_cv_sizeof_long+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test "$cross_compiling" = yes; then # Depending upon the size, compute the lo and hi bounds. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default typedef long ac__type_sizeof_; int main () { static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) >= 0)]; test_array [0] = 0 ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_lo=0 ac_mid=0 while :; do cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default typedef long ac__type_sizeof_; int main () { static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) <= $ac_mid)]; test_array [0] = 0 ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_hi=$ac_mid; break else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_lo=`expr $ac_mid + 1` if test $ac_lo -le $ac_mid; then ac_lo= ac_hi= break fi ac_mid=`expr 2 '*' $ac_mid + 1` fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext done else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default typedef long ac__type_sizeof_; int main () { static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) < 0)]; test_array [0] = 0 ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_hi=-1 ac_mid=-1 while :; do cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default typedef long ac__type_sizeof_; int main () { static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) >= $ac_mid)]; test_array [0] = 0 ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_lo=$ac_mid; break else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_hi=`expr '(' $ac_mid ')' - 1` if test $ac_mid -le $ac_hi; then ac_lo= ac_hi= break fi ac_mid=`expr 2 '*' $ac_mid` fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext done else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_lo= ac_hi= fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext # Binary search between lo and hi bounds. while test "x$ac_lo" != "x$ac_hi"; do ac_mid=`expr '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo` cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default typedef long ac__type_sizeof_; int main () { static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) <= $ac_mid)]; test_array [0] = 0 ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_hi=$ac_mid else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_lo=`expr '(' $ac_mid ')' + 1` fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext done case $ac_lo in ?*) ac_cv_sizeof_long=$ac_lo;; '') if test "$ac_cv_type_long" = yes; then { { echo "$as_me:$LINENO: error: cannot compute sizeof (long) See \`config.log' for more details." >&5 echo "$as_me: error: cannot compute sizeof (long) See \`config.log' for more details." >&2;} { (exit 77); exit 77; }; } else ac_cv_sizeof_long=0 fi ;; esac else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default typedef long ac__type_sizeof_; static long int longval () { return (long int) (sizeof (ac__type_sizeof_)); } static unsigned long int ulongval () { return (long int) (sizeof (ac__type_sizeof_)); } #include #include int main () { FILE *f = fopen ("conftest.val", "w"); if (! f) return 1; if (((long int) (sizeof (ac__type_sizeof_))) < 0) { long int i = longval (); if (i != ((long int) (sizeof (ac__type_sizeof_)))) return 1; fprintf (f, "%ld\n", i); } else { unsigned long int i = ulongval (); if (i != ((long int) (sizeof (ac__type_sizeof_)))) return 1; fprintf (f, "%lu\n", i); } return ferror (f) || fclose (f) != 0; ; return 0; } _ACEOF rm -f conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='./conftest$ac_exeext' { (case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_try") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_sizeof_long=`cat conftest.val` else echo "$as_me: program exited with status $ac_status" >&5 echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) if test "$ac_cv_type_long" = yes; then { { echo "$as_me:$LINENO: error: cannot compute sizeof (long) See \`config.log' for more details." >&5 echo "$as_me: error: cannot compute sizeof (long) See \`config.log' for more details." >&2;} { (exit 77); exit 77; }; } else ac_cv_sizeof_long=0 fi fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi rm -f conftest.val fi { echo "$as_me:$LINENO: result: $ac_cv_sizeof_long" >&5 echo "${ECHO_T}$ac_cv_sizeof_long" >&6; } cat >>confdefs.h <<_ACEOF #define SIZEOF_LONG $ac_cv_sizeof_long _ACEOF { echo "$as_me:$LINENO: checking for float" >&5 echo $ECHO_N "checking for float... $ECHO_C" >&6; } if test "${ac_cv_type_float+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default typedef float ac__type_new_; int main () { if ((ac__type_new_ *) 0) return 0; if (sizeof (ac__type_new_)) return 0; ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_cv_type_float=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_type_float=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { echo "$as_me:$LINENO: result: $ac_cv_type_float" >&5 echo "${ECHO_T}$ac_cv_type_float" >&6; } # The cast to long int works around a bug in the HP C Compiler # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. # This bug is HP SR number 8606223364. { echo "$as_me:$LINENO: checking size of float" >&5 echo $ECHO_N "checking size of float... $ECHO_C" >&6; } if test "${ac_cv_sizeof_float+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test "$cross_compiling" = yes; then # Depending upon the size, compute the lo and hi bounds. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default typedef float ac__type_sizeof_; int main () { static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) >= 0)]; test_array [0] = 0 ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_lo=0 ac_mid=0 while :; do cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default typedef float ac__type_sizeof_; int main () { static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) <= $ac_mid)]; test_array [0] = 0 ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_hi=$ac_mid; break else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_lo=`expr $ac_mid + 1` if test $ac_lo -le $ac_mid; then ac_lo= ac_hi= break fi ac_mid=`expr 2 '*' $ac_mid + 1` fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext done else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default typedef float ac__type_sizeof_; int main () { static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) < 0)]; test_array [0] = 0 ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_hi=-1 ac_mid=-1 while :; do cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default typedef float ac__type_sizeof_; int main () { static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) >= $ac_mid)]; test_array [0] = 0 ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_lo=$ac_mid; break else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_hi=`expr '(' $ac_mid ')' - 1` if test $ac_mid -le $ac_hi; then ac_lo= ac_hi= break fi ac_mid=`expr 2 '*' $ac_mid` fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext done else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_lo= ac_hi= fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext # Binary search between lo and hi bounds. while test "x$ac_lo" != "x$ac_hi"; do ac_mid=`expr '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo` cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default typedef float ac__type_sizeof_; int main () { static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) <= $ac_mid)]; test_array [0] = 0 ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_hi=$ac_mid else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_lo=`expr '(' $ac_mid ')' + 1` fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext done case $ac_lo in ?*) ac_cv_sizeof_float=$ac_lo;; '') if test "$ac_cv_type_float" = yes; then { { echo "$as_me:$LINENO: error: cannot compute sizeof (float) See \`config.log' for more details." >&5 echo "$as_me: error: cannot compute sizeof (float) See \`config.log' for more details." >&2;} { (exit 77); exit 77; }; } else ac_cv_sizeof_float=0 fi ;; esac else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default typedef float ac__type_sizeof_; static long int longval () { return (long int) (sizeof (ac__type_sizeof_)); } static unsigned long int ulongval () { return (long int) (sizeof (ac__type_sizeof_)); } #include #include int main () { FILE *f = fopen ("conftest.val", "w"); if (! f) return 1; if (((long int) (sizeof (ac__type_sizeof_))) < 0) { long int i = longval (); if (i != ((long int) (sizeof (ac__type_sizeof_)))) return 1; fprintf (f, "%ld\n", i); } else { unsigned long int i = ulongval (); if (i != ((long int) (sizeof (ac__type_sizeof_)))) return 1; fprintf (f, "%lu\n", i); } return ferror (f) || fclose (f) != 0; ; return 0; } _ACEOF rm -f conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='./conftest$ac_exeext' { (case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_try") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_sizeof_float=`cat conftest.val` else echo "$as_me: program exited with status $ac_status" >&5 echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) if test "$ac_cv_type_float" = yes; then { { echo "$as_me:$LINENO: error: cannot compute sizeof (float) See \`config.log' for more details." >&5 echo "$as_me: error: cannot compute sizeof (float) See \`config.log' for more details." >&2;} { (exit 77); exit 77; }; } else ac_cv_sizeof_float=0 fi fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi rm -f conftest.val fi { echo "$as_me:$LINENO: result: $ac_cv_sizeof_float" >&5 echo "${ECHO_T}$ac_cv_sizeof_float" >&6; } cat >>confdefs.h <<_ACEOF #define SIZEOF_FLOAT $ac_cv_sizeof_float _ACEOF { echo "$as_me:$LINENO: checking for double" >&5 echo $ECHO_N "checking for double... $ECHO_C" >&6; } if test "${ac_cv_type_double+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default typedef double ac__type_new_; int main () { if ((ac__type_new_ *) 0) return 0; if (sizeof (ac__type_new_)) return 0; ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_cv_type_double=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_type_double=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { echo "$as_me:$LINENO: result: $ac_cv_type_double" >&5 echo "${ECHO_T}$ac_cv_type_double" >&6; } # The cast to long int works around a bug in the HP C Compiler # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. # This bug is HP SR number 8606223364. { echo "$as_me:$LINENO: checking size of double" >&5 echo $ECHO_N "checking size of double... $ECHO_C" >&6; } if test "${ac_cv_sizeof_double+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test "$cross_compiling" = yes; then # Depending upon the size, compute the lo and hi bounds. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default typedef double ac__type_sizeof_; int main () { static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) >= 0)]; test_array [0] = 0 ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_lo=0 ac_mid=0 while :; do cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default typedef double ac__type_sizeof_; int main () { static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) <= $ac_mid)]; test_array [0] = 0 ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_hi=$ac_mid; break else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_lo=`expr $ac_mid + 1` if test $ac_lo -le $ac_mid; then ac_lo= ac_hi= break fi ac_mid=`expr 2 '*' $ac_mid + 1` fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext done else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default typedef double ac__type_sizeof_; int main () { static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) < 0)]; test_array [0] = 0 ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_hi=-1 ac_mid=-1 while :; do cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default typedef double ac__type_sizeof_; int main () { static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) >= $ac_mid)]; test_array [0] = 0 ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_lo=$ac_mid; break else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_hi=`expr '(' $ac_mid ')' - 1` if test $ac_mid -le $ac_hi; then ac_lo= ac_hi= break fi ac_mid=`expr 2 '*' $ac_mid` fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext done else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_lo= ac_hi= fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext # Binary search between lo and hi bounds. while test "x$ac_lo" != "x$ac_hi"; do ac_mid=`expr '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo` cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default typedef double ac__type_sizeof_; int main () { static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) <= $ac_mid)]; test_array [0] = 0 ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_hi=$ac_mid else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_lo=`expr '(' $ac_mid ')' + 1` fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext done case $ac_lo in ?*) ac_cv_sizeof_double=$ac_lo;; '') if test "$ac_cv_type_double" = yes; then { { echo "$as_me:$LINENO: error: cannot compute sizeof (double) See \`config.log' for more details." >&5 echo "$as_me: error: cannot compute sizeof (double) See \`config.log' for more details." >&2;} { (exit 77); exit 77; }; } else ac_cv_sizeof_double=0 fi ;; esac else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default typedef double ac__type_sizeof_; static long int longval () { return (long int) (sizeof (ac__type_sizeof_)); } static unsigned long int ulongval () { return (long int) (sizeof (ac__type_sizeof_)); } #include #include int main () { FILE *f = fopen ("conftest.val", "w"); if (! f) return 1; if (((long int) (sizeof (ac__type_sizeof_))) < 0) { long int i = longval (); if (i != ((long int) (sizeof (ac__type_sizeof_)))) return 1; fprintf (f, "%ld\n", i); } else { unsigned long int i = ulongval (); if (i != ((long int) (sizeof (ac__type_sizeof_)))) return 1; fprintf (f, "%lu\n", i); } return ferror (f) || fclose (f) != 0; ; return 0; } _ACEOF rm -f conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='./conftest$ac_exeext' { (case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_try") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_sizeof_double=`cat conftest.val` else echo "$as_me: program exited with status $ac_status" >&5 echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) if test "$ac_cv_type_double" = yes; then { { echo "$as_me:$LINENO: error: cannot compute sizeof (double) See \`config.log' for more details." >&5 echo "$as_me: error: cannot compute sizeof (double) See \`config.log' for more details." >&2;} { (exit 77); exit 77; }; } else ac_cv_sizeof_double=0 fi fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi rm -f conftest.val fi { echo "$as_me:$LINENO: result: $ac_cv_sizeof_double" >&5 echo "${ECHO_T}$ac_cv_sizeof_double" >&6; } cat >>confdefs.h <<_ACEOF #define SIZEOF_DOUBLE $ac_cv_sizeof_double _ACEOF { echo "$as_me:$LINENO: checking for long long" >&5 echo $ECHO_N "checking for long long... $ECHO_C" >&6; } if test "${ac_cv_type_long_long+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default typedef long long ac__type_new_; int main () { if ((ac__type_new_ *) 0) return 0; if (sizeof (ac__type_new_)) return 0; ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_cv_type_long_long=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_type_long_long=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { echo "$as_me:$LINENO: result: $ac_cv_type_long_long" >&5 echo "${ECHO_T}$ac_cv_type_long_long" >&6; } if test $ac_cv_type_long_long = yes; then cat >>confdefs.h <<_ACEOF #define HAVE_LONG_LONG 1 _ACEOF fi { echo "$as_me:$LINENO: checking for long long" >&5 echo $ECHO_N "checking for long long... $ECHO_C" >&6; } if test "${ac_cv_type_long_long+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default typedef long long ac__type_new_; int main () { if ((ac__type_new_ *) 0) return 0; if (sizeof (ac__type_new_)) return 0; ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_cv_type_long_long=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_type_long_long=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { echo "$as_me:$LINENO: result: $ac_cv_type_long_long" >&5 echo "${ECHO_T}$ac_cv_type_long_long" >&6; } # The cast to long int works around a bug in the HP C Compiler # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. # This bug is HP SR number 8606223364. { echo "$as_me:$LINENO: checking size of long long" >&5 echo $ECHO_N "checking size of long long... $ECHO_C" >&6; } if test "${ac_cv_sizeof_long_long+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test "$cross_compiling" = yes; then # Depending upon the size, compute the lo and hi bounds. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default typedef long long ac__type_sizeof_; int main () { static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) >= 0)]; test_array [0] = 0 ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_lo=0 ac_mid=0 while :; do cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default typedef long long ac__type_sizeof_; int main () { static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) <= $ac_mid)]; test_array [0] = 0 ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_hi=$ac_mid; break else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_lo=`expr $ac_mid + 1` if test $ac_lo -le $ac_mid; then ac_lo= ac_hi= break fi ac_mid=`expr 2 '*' $ac_mid + 1` fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext done else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default typedef long long ac__type_sizeof_; int main () { static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) < 0)]; test_array [0] = 0 ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_hi=-1 ac_mid=-1 while :; do cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default typedef long long ac__type_sizeof_; int main () { static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) >= $ac_mid)]; test_array [0] = 0 ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_lo=$ac_mid; break else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_hi=`expr '(' $ac_mid ')' - 1` if test $ac_mid -le $ac_hi; then ac_lo= ac_hi= break fi ac_mid=`expr 2 '*' $ac_mid` fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext done else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_lo= ac_hi= fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext # Binary search between lo and hi bounds. while test "x$ac_lo" != "x$ac_hi"; do ac_mid=`expr '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo` cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default typedef long long ac__type_sizeof_; int main () { static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) <= $ac_mid)]; test_array [0] = 0 ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_hi=$ac_mid else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_lo=`expr '(' $ac_mid ')' + 1` fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext done case $ac_lo in ?*) ac_cv_sizeof_long_long=$ac_lo;; '') if test "$ac_cv_type_long_long" = yes; then { { echo "$as_me:$LINENO: error: cannot compute sizeof (long long) See \`config.log' for more details." >&5 echo "$as_me: error: cannot compute sizeof (long long) See \`config.log' for more details." >&2;} { (exit 77); exit 77; }; } else ac_cv_sizeof_long_long=0 fi ;; esac else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default typedef long long ac__type_sizeof_; static long int longval () { return (long int) (sizeof (ac__type_sizeof_)); } static unsigned long int ulongval () { return (long int) (sizeof (ac__type_sizeof_)); } #include #include int main () { FILE *f = fopen ("conftest.val", "w"); if (! f) return 1; if (((long int) (sizeof (ac__type_sizeof_))) < 0) { long int i = longval (); if (i != ((long int) (sizeof (ac__type_sizeof_)))) return 1; fprintf (f, "%ld\n", i); } else { unsigned long int i = ulongval (); if (i != ((long int) (sizeof (ac__type_sizeof_)))) return 1; fprintf (f, "%lu\n", i); } return ferror (f) || fclose (f) != 0; ; return 0; } _ACEOF rm -f conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='./conftest$ac_exeext' { (case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_try") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_sizeof_long_long=`cat conftest.val` else echo "$as_me: program exited with status $ac_status" >&5 echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) if test "$ac_cv_type_long_long" = yes; then { { echo "$as_me:$LINENO: error: cannot compute sizeof (long long) See \`config.log' for more details." >&5 echo "$as_me: error: cannot compute sizeof (long long) See \`config.log' for more details." >&2;} { (exit 77); exit 77; }; } else ac_cv_sizeof_long_long=0 fi fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi rm -f conftest.val fi { echo "$as_me:$LINENO: result: $ac_cv_sizeof_long_long" >&5 echo "${ECHO_T}$ac_cv_sizeof_long_long" >&6; } cat >>confdefs.h <<_ACEOF #define SIZEOF_LONG_LONG $ac_cv_sizeof_long_long _ACEOF # Check whether --enable-largefile was given. if test "${enable_largefile+set}" = set; then enableval=$enable_largefile; fi if test "$enable_largefile" != no; then { echo "$as_me:$LINENO: checking for special C compiler options needed for large files" >&5 echo $ECHO_N "checking for special C compiler options needed for large files... $ECHO_C" >&6; } if test "${ac_cv_sys_largefile_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_cv_sys_largefile_CC=no if test "$GCC" != yes; then ac_save_CC=$CC while :; do # IRIX 6.2 and later do not support large files by default, # so use the C compiler's -n32 option if that helps. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include /* Check that off_t can represent 2**63 - 1 correctly. We can't simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */ #define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1]; int main () { ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then break else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f core conftest.err conftest.$ac_objext CC="$CC -n32" rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_cv_sys_largefile_CC=' -n32'; break else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f core conftest.err conftest.$ac_objext break done CC=$ac_save_CC rm -f conftest.$ac_ext fi fi { echo "$as_me:$LINENO: result: $ac_cv_sys_largefile_CC" >&5 echo "${ECHO_T}$ac_cv_sys_largefile_CC" >&6; } if test "$ac_cv_sys_largefile_CC" != no; then CC=$CC$ac_cv_sys_largefile_CC fi { echo "$as_me:$LINENO: checking for _FILE_OFFSET_BITS value needed for large files" >&5 echo $ECHO_N "checking for _FILE_OFFSET_BITS value needed for large files... $ECHO_C" >&6; } if test "${ac_cv_sys_file_offset_bits+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else while :; do cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include /* Check that off_t can represent 2**63 - 1 correctly. We can't simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */ #define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1]; int main () { ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_cv_sys_file_offset_bits=no; break else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #define _FILE_OFFSET_BITS 64 #include /* Check that off_t can represent 2**63 - 1 correctly. We can't simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */ #define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1]; int main () { ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_cv_sys_file_offset_bits=64; break else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_sys_file_offset_bits=unknown break done fi { echo "$as_me:$LINENO: result: $ac_cv_sys_file_offset_bits" >&5 echo "${ECHO_T}$ac_cv_sys_file_offset_bits" >&6; } case $ac_cv_sys_file_offset_bits in #( no | unknown) ;; *) cat >>confdefs.h <<_ACEOF #define _FILE_OFFSET_BITS $ac_cv_sys_file_offset_bits _ACEOF ;; esac rm -f conftest* if test $ac_cv_sys_file_offset_bits = unknown; then { echo "$as_me:$LINENO: checking for _LARGE_FILES value needed for large files" >&5 echo $ECHO_N "checking for _LARGE_FILES value needed for large files... $ECHO_C" >&6; } if test "${ac_cv_sys_large_files+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else while :; do cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include /* Check that off_t can represent 2**63 - 1 correctly. We can't simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */ #define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1]; int main () { ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_cv_sys_large_files=no; break else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #define _LARGE_FILES 1 #include /* Check that off_t can represent 2**63 - 1 correctly. We can't simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */ #define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1]; int main () { ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_cv_sys_large_files=1; break else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_sys_large_files=unknown break done fi { echo "$as_me:$LINENO: result: $ac_cv_sys_large_files" >&5 echo "${ECHO_T}$ac_cv_sys_large_files" >&6; } case $ac_cv_sys_large_files in #( no | unknown) ;; *) cat >>confdefs.h <<_ACEOF #define _LARGE_FILES $ac_cv_sys_large_files _ACEOF ;; esac rm -f conftest* fi fi { echo "$as_me:$LINENO: checking for _LARGEFILE_SOURCE value needed for large files" >&5 echo $ECHO_N "checking for _LARGEFILE_SOURCE value needed for large files... $ECHO_C" >&6; } if test "${ac_cv_sys_largefile_source+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else while :; do cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include /* for off_t */ #include int main () { int (*fp) (FILE *, off_t, int) = fseeko; return fseeko (stdin, 0, 0) && fp (stdin, 0, 0); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && $as_test_x conftest$ac_exeext; then ac_cv_sys_largefile_source=no; break else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #define _LARGEFILE_SOURCE 1 #include /* for off_t */ #include int main () { int (*fp) (FILE *, off_t, int) = fseeko; return fseeko (stdin, 0, 0) && fp (stdin, 0, 0); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && $as_test_x conftest$ac_exeext; then ac_cv_sys_largefile_source=1; break else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext ac_cv_sys_largefile_source=unknown break done fi { echo "$as_me:$LINENO: result: $ac_cv_sys_largefile_source" >&5 echo "${ECHO_T}$ac_cv_sys_largefile_source" >&6; } case $ac_cv_sys_largefile_source in #( no | unknown) ;; *) cat >>confdefs.h <<_ACEOF #define _LARGEFILE_SOURCE $ac_cv_sys_largefile_source _ACEOF ;; esac rm -f conftest* # We used to try defining _XOPEN_SOURCE=500 too, to work around a bug # in glibc 2.1.3, but that breaks too many other things. # If you want fseeko and ftello with glibc, upgrade to a fixed glibc. if test $ac_cv_sys_largefile_source != unknown; then cat >>confdefs.h <<\_ACEOF #define HAVE_FSEEKO 1 _ACEOF fi { echo "$as_me:$LINENO: checking for off_t" >&5 echo $ECHO_N "checking for off_t... $ECHO_C" >&6; } if test "${ac_cv_type_off_t+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default typedef off_t ac__type_new_; int main () { if ((ac__type_new_ *) 0) return 0; if (sizeof (ac__type_new_)) return 0; ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_cv_type_off_t=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_type_off_t=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { echo "$as_me:$LINENO: result: $ac_cv_type_off_t" >&5 echo "${ECHO_T}$ac_cv_type_off_t" >&6; } if test $ac_cv_type_off_t = yes; then : else cat >>confdefs.h <<_ACEOF #define off_t long int _ACEOF fi { echo "$as_me:$LINENO: checking for off_t" >&5 echo $ECHO_N "checking for off_t... $ECHO_C" >&6; } if test "${ac_cv_type_off_t+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default typedef off_t ac__type_new_; int main () { if ((ac__type_new_ *) 0) return 0; if (sizeof (ac__type_new_)) return 0; ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_cv_type_off_t=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_type_off_t=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { echo "$as_me:$LINENO: result: $ac_cv_type_off_t" >&5 echo "${ECHO_T}$ac_cv_type_off_t" >&6; } # The cast to long int works around a bug in the HP C Compiler # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. # This bug is HP SR number 8606223364. { echo "$as_me:$LINENO: checking size of off_t" >&5 echo $ECHO_N "checking size of off_t... $ECHO_C" >&6; } if test "${ac_cv_sizeof_off_t+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test "$cross_compiling" = yes; then # Depending upon the size, compute the lo and hi bounds. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default typedef off_t ac__type_sizeof_; int main () { static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) >= 0)]; test_array [0] = 0 ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_lo=0 ac_mid=0 while :; do cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default typedef off_t ac__type_sizeof_; int main () { static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) <= $ac_mid)]; test_array [0] = 0 ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_hi=$ac_mid; break else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_lo=`expr $ac_mid + 1` if test $ac_lo -le $ac_mid; then ac_lo= ac_hi= break fi ac_mid=`expr 2 '*' $ac_mid + 1` fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext done else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default typedef off_t ac__type_sizeof_; int main () { static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) < 0)]; test_array [0] = 0 ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_hi=-1 ac_mid=-1 while :; do cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default typedef off_t ac__type_sizeof_; int main () { static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) >= $ac_mid)]; test_array [0] = 0 ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_lo=$ac_mid; break else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_hi=`expr '(' $ac_mid ')' - 1` if test $ac_mid -le $ac_hi; then ac_lo= ac_hi= break fi ac_mid=`expr 2 '*' $ac_mid` fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext done else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_lo= ac_hi= fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext # Binary search between lo and hi bounds. while test "x$ac_lo" != "x$ac_hi"; do ac_mid=`expr '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo` cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default typedef off_t ac__type_sizeof_; int main () { static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) <= $ac_mid)]; test_array [0] = 0 ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_hi=$ac_mid else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_lo=`expr '(' $ac_mid ')' + 1` fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext done case $ac_lo in ?*) ac_cv_sizeof_off_t=$ac_lo;; '') if test "$ac_cv_type_off_t" = yes; then { { echo "$as_me:$LINENO: error: cannot compute sizeof (off_t) See \`config.log' for more details." >&5 echo "$as_me: error: cannot compute sizeof (off_t) See \`config.log' for more details." >&2;} { (exit 77); exit 77; }; } else ac_cv_sizeof_off_t=0 fi ;; esac else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default typedef off_t ac__type_sizeof_; static long int longval () { return (long int) (sizeof (ac__type_sizeof_)); } static unsigned long int ulongval () { return (long int) (sizeof (ac__type_sizeof_)); } #include #include int main () { FILE *f = fopen ("conftest.val", "w"); if (! f) return 1; if (((long int) (sizeof (ac__type_sizeof_))) < 0) { long int i = longval (); if (i != ((long int) (sizeof (ac__type_sizeof_)))) return 1; fprintf (f, "%ld\n", i); } else { unsigned long int i = ulongval (); if (i != ((long int) (sizeof (ac__type_sizeof_)))) return 1; fprintf (f, "%lu\n", i); } return ferror (f) || fclose (f) != 0; ; return 0; } _ACEOF rm -f conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='./conftest$ac_exeext' { (case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_try") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_sizeof_off_t=`cat conftest.val` else echo "$as_me: program exited with status $ac_status" >&5 echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) if test "$ac_cv_type_off_t" = yes; then { { echo "$as_me:$LINENO: error: cannot compute sizeof (off_t) See \`config.log' for more details." >&5 echo "$as_me: error: cannot compute sizeof (off_t) See \`config.log' for more details." >&2;} { (exit 77); exit 77; }; } else ac_cv_sizeof_off_t=0 fi fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi rm -f conftest.val fi { echo "$as_me:$LINENO: result: $ac_cv_sizeof_off_t" >&5 echo "${ECHO_T}$ac_cv_sizeof_off_t" >&6; } cat >>confdefs.h <<_ACEOF #define SIZEOF_OFF_T $ac_cv_sizeof_off_t _ACEOF #--------------------------------------------------------------------------- # Set the source directory and object directory. The makefile assumes an # absolute path name. This is because src/Makefile cds to OBJDIR and compiles # the src file which is in SRCDIR #--------------------------------------------------------------------------- SRCDIR=$CONFIG_DIR if test "" != "." then if test -z "" then SRCDIR=$SRCDIR/src else SRCDIR=$SRCDIR/ fi fi OBJDIR=$SRCDIR/"$ARCH"objs ELFDIR=$SRCDIR/elf"$ARCH"objs # Extract the first word of "ncurses5-config", so it can be a program name with args. set dummy ncurses5-config; ac_word=$2 { echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_path_nc5config+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else case $nc5config in [\\/]* | ?:[\\/]*) ac_cv_path_nc5config="$nc5config" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_nc5config="$as_dir/$ac_word$ac_exec_ext" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS test -z "$ac_cv_path_nc5config" && ac_cv_path_nc5config="no" ;; esac fi nc5config=$ac_cv_path_nc5config if test -n "$nc5config"; then { echo "$as_me:$LINENO: result: $nc5config" >&5 echo "${ECHO_T}$nc5config" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } fi if test "$nc5config" = "no" then # Extract the first word of "ncurses5w-config", so it can be a program name with args. set dummy ncurses5w-config; ac_word=$2 { echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_path_nc5config+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else case $nc5config in [\\/]* | ?:[\\/]*) ac_cv_path_nc5config="$nc5config" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_nc5config="$as_dir/$ac_word$ac_exec_ext" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS test -z "$ac_cv_path_nc5config" && ac_cv_path_nc5config="no" ;; esac fi nc5config=$ac_cv_path_nc5config if test -n "$nc5config"; then { echo "$as_me:$LINENO: result: $nc5config" >&5 echo "${ECHO_T}$nc5config" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } fi fi { echo "$as_me:$LINENO: checking for terminfo" >&5 echo $ECHO_N "checking for terminfo... $ECHO_C" >&6; } if test "$nc5config" != "no" then MISC_TERMINFO_DIRS=`$nc5config --terminfo` else MISC_TERMINFO_DIRS="" fi JD_Terminfo_Dirs="$MISC_TERMINFO_DIRS \ /usr/lib/terminfo \ /usr/share/terminfo \ /usr/share/lib/terminfo \ /usr/local/lib/terminfo" TERMCAP=-ltermcap for terminfo_dir in $JD_Terminfo_Dirs do if test -d $terminfo_dir then { echo "$as_me:$LINENO: result: yes" >&5 echo "${ECHO_T}yes" >&6; } TERMCAP="" break fi done if test "$TERMCAP"; then { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } cat >>confdefs.h <<\_ACEOF #define USE_TERMCAP 1 _ACEOF fi if test "X$jd_prefix" = "X" then jd_prefix=$ac_default_prefix if test "X$prefix" != "XNONE" then jd_prefix="$prefix" fi jd_exec_prefix="$jd_prefix" if test "X$exec_prefix" != "XNONE" then jd_exec_prefix="$exec_prefix" fi eval `sh <&5 echo "$as_me: error: --with-slanglib requres a value" >&2;} { (exit 1); exit 1; }; } ;; *) jd_with_slang_library="yes" jd_slang_library_dir="$jd_with_slanglib_arg" ;; esac # Check whether --with-slanginc was given. if test "${with_slanginc+set}" = set; then withval=$with_slanginc; jd_with_slanginc_arg=$withval else jd_with_slanginc_arg=unspecified fi case "x$jd_with_slanginc_arg" in x) { { echo "$as_me:$LINENO: error: --with-slanginc requres a value" >&5 echo "$as_me: error: --with-slanginc requres a value" >&2;} { (exit 1); exit 1; }; } ;; xunspecified) ;; xno) ;; *) jd_with_slang_library="yes" jd_slang_include_dir="$jd_with_slanginc_arg" ;; esac { echo "$as_me:$LINENO: checking for the slang library and header files " >&5 echo $ECHO_N "checking for the slang library and header files ... $ECHO_C" >&6; } if test X"$jd_with_slang_library" != Xno then jd_slang_inc_file= if test "X$jd_slang_inc_file" = "X" then jd_slang_inc_file=slang.h fi if test X"$jd_slang_include_dir" = X then inc_and_lib_dirs="\ $jd_prefix_incdir,$jd_prefix_libdir \ /usr/local/slang/include,/usr/local/slang/lib \ /usr/local/include/slang,/usr/local/lib \ /usr/local/include,/usr/local/lib \ /usr/include/slang,/usr/lib \ /usr/slang/include,/usr/slang/lib \ /usr/include,/usr/lib \ /opt/include/slang,/opt/lib \ /opt/slang/include,/opt/slang/lib \ /opt/include,/opt/lib" if test X != X then inc_and_lib_dirs="/include,/lib $inc_and_lib_dirs" fi case "$host_os" in *darwin* ) exts="dylib so a" ;; *cygwin* ) exts="dll.a so a" ;; * ) exts="so a" esac xincfile="$jd_slang_inc_file" xlibfile="libslang" jd_with_slang_library="no" for include_and_lib in $inc_and_lib_dirs do # Yuk. Is there a better way to set these variables?? xincdir=`echo $include_and_lib | tr ',' ' ' | awk '{print $1}'` xlibdir=`echo $include_and_lib | tr ',' ' ' | awk '{print $2}'` found=0 if test -r $xincdir/$xincfile then for E in $exts do if test -r "$xlibdir/$xlibfile.$E" then jd_slang_include_dir="$xincdir" jd_slang_library_dir="$xlibdir" jd_with_slang_library="yes" found=1 break fi done fi if test $found -eq 1 then break fi done fi fi if test X"$jd_slang_include_dir" != X -a X"$jd_slang_library_dir" != X then { echo "$as_me:$LINENO: result: yes: $jd_slang_library_dir and $jd_slang_include_dir" >&5 echo "${ECHO_T}yes: $jd_slang_library_dir and $jd_slang_include_dir" >&6; } jd_with_slang_library="yes" SLANG_LIB=-L$jd_slang_library_dir if test "X$jd_slang_library_dir" = "X/usr/lib" then SLANG_LIB="" else if test "X$jd_slang_library_dir" != "X" then if test "X$RPATH" = "X" then case "$host_os" in *linux*|*solaris* ) if test "X$GCC" = Xyes then if test "X$ac_R_nospace" = "Xno" then RPATH="-Wl,-R," else RPATH="-Wl,-R" fi else if test "X$ac_R_nospace" = "Xno" then RPATH="-R " else RPATH="-R" fi fi ;; *osf*|*openbsd*) if test "X$GCC" = Xyes then RPATH="-Wl,-rpath," else RPATH="-rpath " fi ;; *netbsd*) if test "X$GCC" = Xyes then RPATH="-Wl,-R" fi ;; esac if test "X$RPATH" != "X" then RPATH="$RPATH$jd_slang_library_dir" fi else RPATH="$RPATH:$jd_slang_library_dir" fi fi fi SLANG_INC=-I$jd_slang_include_dir if test "X$jd_slang_include_dir" = "X/usr/include" then SLANG_INC="" fi else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } jd_with_slang_library="no" SLANG_INC="" SLANG_LIB="" fi if test "$jd_with_slang_library" = "no" then { { echo "$as_me:$LINENO: error: unable to find the slang library and header file $jd_slang_inc_file" >&5 echo "$as_me: error: unable to find the slang library and header file $jd_slang_inc_file" >&2;} { (exit 1); exit 1; }; } fi # Check whether --enable-warnings was given. if test "${enable_warnings+set}" = set; then enableval=$enable_warnings; gcc_warnings=$enableval fi if test -n "$GCC" then #CFLAGS="$CFLAGS -fno-strength-reduce" if test -n "$gcc_warnings" then CFLAGS="$CFLAGS -Wall -W -pedantic -Winline -Wmissing-prototypes \ -Wnested-externs -Wpointer-arith -Wcast-align -Wshadow -Wstrict-prototypes" # Now trim excess whitespace CFLAGS=`echo $CFLAGS` fi fi # Check whether --enable-xft was given. if test "${enable_xft+set}" = set; then enableval=$enable_xft; enable_xft=$enableval else enable_xft=default fi if test X"$enable_xft" = Xno then { echo "$as_me:$LINENO: checking for xft disabled" >&5 echo "$as_me: checking for xft disabled" >&6;} else { echo "$as_me:$LINENO: checking for XftFontOpen in -lXft" >&5 echo $ECHO_N "checking for XftFontOpen in -lXft... $ECHO_C" >&6; } if test "${ac_cv_lib_Xft_XftFontOpen+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lXft $LIBS" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char XftFontOpen (); int main () { return XftFontOpen (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && $as_test_x conftest$ac_exeext; then ac_cv_lib_Xft_XftFontOpen=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_Xft_XftFontOpen=no fi rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { echo "$as_me:$LINENO: result: $ac_cv_lib_Xft_XftFontOpen" >&5 echo "${ECHO_T}$ac_cv_lib_Xft_XftFontOpen" >&6; } if test $ac_cv_lib_Xft_XftFontOpen = yes; then XRENDERFONTLIBS="-lXft" cat >>confdefs.h <<\_ACEOF #define XJED_HAS_XRENDERFONT 1 _ACEOF # Extract the first word of "pkg-config", so it can be a program name with args. set dummy pkg-config; ac_word=$2 { echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_path_PKGCONFIG+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else case $PKGCONFIG in [\\/]* | ?:[\\/]*) ac_cv_path_PKGCONFIG="$PKGCONFIG" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_PKGCONFIG="$as_dir/$ac_word$ac_exec_ext" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS ;; esac fi PKGCONFIG=$ac_cv_path_PKGCONFIG if test -n "$PKGCONFIG"; then { echo "$as_me:$LINENO: result: $PKGCONFIG" >&5 echo "${ECHO_T}$PKGCONFIG" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } fi if test -n "$PKGCONFIG" then X_CFLAGS="$X_CFLAGS $($PKGCONFIG --cflags xft)" fi else if test X"$enable_xft" = Xyes then { { echo "$as_me:$LINENO: error: libXft not found See \`config.log' for more details." >&5 echo "$as_me: error: libXft not found See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; } fi fi fi # Check whether --enable-gpm was given. if test "${enable_gpm+set}" = set; then enableval=$enable_gpm; enable_gpm=$enableval else enable_gpm=default fi if test X"$enable_gpm" = Xno then { echo "$as_me:$LINENO: checking for gpm disabled" >&5 echo "$as_me: checking for gpm disabled" >&6;} MOUSELIB="" MOUSEDEFINES="" MOUSE_O_FILE="" else { echo "$as_me:$LINENO: checking for Gpm_Open in -lgpm" >&5 echo $ECHO_N "checking for Gpm_Open in -lgpm... $ECHO_C" >&6; } if test "${ac_cv_lib_gpm_Gpm_Open+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lgpm $LIBS" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char Gpm_Open (); int main () { return Gpm_Open (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && $as_test_x conftest$ac_exeext; then ac_cv_lib_gpm_Gpm_Open=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_gpm_Gpm_Open=no fi rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { echo "$as_me:$LINENO: result: $ac_cv_lib_gpm_Gpm_Open" >&5 echo "${ECHO_T}$ac_cv_lib_gpm_Gpm_Open" >&6; } if test $ac_cv_lib_gpm_Gpm_Open = yes; then MOUSELIB="-lgpm" MOUSEDEFINES="-DUSE_GPM_MOUSE" MOUSE_O_FILE="gpmmouse.o" MOUSE_OBJ_FILE="\${OBJDIR}/gpmmouse.o" else if test X"$enable_gpm" = Xyes then { { echo "$as_me:$LINENO: error: libgpm not found See \`config.log' for more details." >&5 echo "$as_me: error: libgpm not found See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; } fi fi fi #--------------------------------------------------------------------------- # gtk #--------------------------------------------------------------------------- # Check whether --with-gtk was given. if test "${with_gtk+set}" = set; then withval=$with_gtk; GTK_DIR="$withval" else GTK_DIR="" fi PKG_CONFIG_PATH="$GTK_DIR" export PKG_CONFIG_PATH pkg_failed=no { echo "$as_me:$LINENO: checking for GTK" >&5 echo $ECHO_N "checking for GTK... $ECHO_C" >&6; } if test -n "$PKG_CONFIG"; then if test -n "$GTK_CFLAGS"; then pkg_cv_GTK_CFLAGS="$GTK_CFLAGS" else if test -n "$PKG_CONFIG" && \ { (echo "$as_me:$LINENO: \$PKG_CONFIG --exists --print-errors \"gtk+-2.0 >= 2.8.0\"") >&5 ($PKG_CONFIG --exists --print-errors "gtk+-2.0 >= 2.8.0") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; then pkg_cv_GTK_CFLAGS=`$PKG_CONFIG --cflags "gtk+-2.0 >= 2.8.0" 2>/dev/null` else pkg_failed=yes fi fi else pkg_failed=untried fi if test -n "$PKG_CONFIG"; then if test -n "$GTK_LIBS"; then pkg_cv_GTK_LIBS="$GTK_LIBS" else if test -n "$PKG_CONFIG" && \ { (echo "$as_me:$LINENO: \$PKG_CONFIG --exists --print-errors \"gtk+-2.0 >= 2.8.0\"") >&5 ($PKG_CONFIG --exists --print-errors "gtk+-2.0 >= 2.8.0") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; then pkg_cv_GTK_LIBS=`$PKG_CONFIG --libs "gtk+-2.0 >= 2.8.0" 2>/dev/null` else pkg_failed=yes fi fi else pkg_failed=untried fi if test $pkg_failed = yes; then if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then _pkg_short_errors_supported=yes else _pkg_short_errors_supported=no fi if test $_pkg_short_errors_supported = yes; then GTK_PKG_ERRORS=`$PKG_CONFIG --short-errors --errors-to-stdout --print-errors "gtk+-2.0 >= 2.8.0"` else GTK_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "gtk+-2.0 >= 2.8.0"` fi # Put the nasty error message in config.log where it belongs echo "$GTK_PKG_ERRORS" >&5 { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } jd_with_gtk="no" elif test $pkg_failed = untried; then jd_with_gtk="no" else GTK_CFLAGS=$pkg_cv_GTK_CFLAGS GTK_LIBS=$pkg_cv_GTK_LIBS { echo "$as_me:$LINENO: result: yes" >&5 echo "${ECHO_T}yes" >&6; } jd_with_gtk="yes" fi echo "GTK dir: $GTK_DIR" { echo "$as_me:$LINENO: checking for gtk+-2.0 version >= 2.8.0" >&5 echo $ECHO_N "checking for gtk+-2.0 version >= 2.8.0... $ECHO_C" >&6; } { echo "$as_me:$LINENO: result: $jd_with_gtk" >&5 echo "${ECHO_T}$jd_with_gtk" >&6; } { echo "$as_me:$LINENO: result: CFlags: $GTK_CFLAGS" >&5 echo "${ECHO_T}CFlags: $GTK_CFLAGS" >&6; } { echo "$as_me:$LINENO: result: Libraries: $GTK_LIBS" >&5 echo "${ECHO_T}Libraries: $GTK_LIBS" >&6; } BUILD_GTKJED=$jd_with_gtk if test "x$prefix" != xNONE; then default_jed_root="$prefix/jed" else default_jed_root="$ac_default_prefix/jed" fi JED_ROOT="${JED_ROOT:-$default_jed_root}" ac_config_headers="$ac_config_headers src/sysconf.h:src/config.hin" ac_config_files="$ac_config_files Makefile:autoconf/Makefile.in src/Makefile" cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure # tests run on this system so they can be shared between configure # scripts and configure runs, see configure's option --config-cache. # It is not useful on other systems. If it contains results you don't # want to keep, you may remove or edit it. # # config.status only pays attention to the cache file if you give it # the --recheck option to rerun configure. # # `ac_cv_env_foo' variables (set or unset) will be overridden when # loading this file, other *unset* `ac_cv_foo' will be assigned the # following values. _ACEOF # The following way of writing the cache mishandles newlines in values, # but we know of no workaround that is simple, portable, and efficient. # So, we kill variables containing newlines. # Ultrix sh set writes to stderr and can't be redirected directly, # and sets the high bit in the cache file unless we assign to the vars. ( for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do eval ac_val=\$$ac_var case $ac_val in #( *${as_nl}*) case $ac_var in #( *_cv_*) { echo "$as_me:$LINENO: WARNING: Cache variable $ac_var contains a newline." >&5 echo "$as_me: WARNING: Cache variable $ac_var contains a newline." >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( *) $as_unset $ac_var ;; esac ;; esac done (set) 2>&1 | case $as_nl`(ac_space=' '; set) 2>&1` in #( *${as_nl}ac_space=\ *) # `set' does not quote correctly, so add quotes (double-quote # substitution turns \\\\ into \\, and sed turns \\ into \). sed -n \ "s/'/'\\\\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" ;; #( *) # `set' quotes correctly as required by POSIX, so do not add quotes. sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; esac | sort ) | sed ' /^ac_cv_env_/b end t clear :clear s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ t end s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ :end' >>confcache if diff "$cache_file" confcache >/dev/null 2>&1; then :; else if test -w "$cache_file"; then test "x$cache_file" != "x/dev/null" && { echo "$as_me:$LINENO: updating cache $cache_file" >&5 echo "$as_me: updating cache $cache_file" >&6;} cat confcache >$cache_file else { echo "$as_me:$LINENO: not updating unwritable cache $cache_file" >&5 echo "$as_me: not updating unwritable cache $cache_file" >&6;} fi fi rm -f confcache test "x$prefix" = xNONE && prefix=$ac_default_prefix # Let make expand exec_prefix. test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' DEFS=-DHAVE_CONFIG_H ac_libobjs= ac_ltlibobjs= for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue # 1. Remove the extension, and $U if already installed. ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' ac_i=`echo "$ac_i" | sed "$ac_script"` # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR # will be set to the directory where LIBOBJS objects are built. ac_libobjs="$ac_libobjs \${LIBOBJDIR}$ac_i\$U.$ac_objext" ac_ltlibobjs="$ac_ltlibobjs \${LIBOBJDIR}$ac_i"'$U.lo' done LIBOBJS=$ac_libobjs LTLIBOBJS=$ac_ltlibobjs : ${CONFIG_STATUS=./config.status} ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files $CONFIG_STATUS" { echo "$as_me:$LINENO: creating $CONFIG_STATUS" >&5 echo "$as_me: creating $CONFIG_STATUS" >&6;} cat >$CONFIG_STATUS <<_ACEOF #! $SHELL # Generated by $as_me. # Run this file to recreate the current configuration. # Compiler output produced by configure, useful for debugging # configure, is in config.log if it exists. debug=false ac_cs_recheck=false ac_cs_silent=false SHELL=\${CONFIG_SHELL-$SHELL} _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF ## --------------------- ## ## M4sh Initialization. ## ## --------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then emulate sh NULLCMD=: # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac fi # PATH needs CR # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then echo "#! /bin/sh" >conf$$.sh echo "exit 0" >>conf$$.sh chmod +x conf$$.sh if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then PATH_SEPARATOR=';' else PATH_SEPARATOR=: fi rm -f conf$$.sh fi # Support unset when possible. if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then as_unset=unset else as_unset=false fi # IFS # We need space, tab and new line, in precisely that order. Quoting is # there to prevent editors from complaining about space-tab. # (If _AS_PATH_WALK were called with IFS unset, it would disable word # splitting by setting IFS to empty value.) as_nl=' ' IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. case $0 in *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done IFS=$as_save_IFS ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 { (exit 1); exit 1; } fi # Work around bugs in pre-3.0 UWIN ksh. for as_var in ENV MAIL MAILPATH do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var done PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. for as_var in \ LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \ LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \ LC_TELEPHONE LC_TIME do if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then eval $as_var=C; export $as_var else ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var fi done # Required to use basename. if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi # Name of the executable. as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # CDPATH. $as_unset CDPATH as_lineno_1=$LINENO as_lineno_2=$LINENO test "x$as_lineno_1" != "x$as_lineno_2" && test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2" || { # Create $as_me.lineno as a copy of $as_myself, but with $LINENO # uniformly replaced by the line number. The first 'sed' inserts a # line-number line after each line using $LINENO; the second 'sed' # does the real work. The second script uses 'N' to pair each # line-number line with the line containing $LINENO, and appends # trailing '-' during substitution so that $LINENO is not a special # case at line end. # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the # scripts with optimization help from Paolo Bonzini. Blame Lee # E. McMahon (1931-1989) for sed's syntax. :-) sed -n ' p /[$]LINENO/= ' <$as_myself | sed ' s/[$]LINENO.*/&-/ t lineno b :lineno N :loop s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ t loop s/-\n.*// ' >$as_me.lineno && chmod +x "$as_me.lineno" || { echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2 { (exit 1); exit 1; }; } # Don't try to exec as it changes $[0], causing all sort of problems # (the dirname of $[0] is not the place where we might find the # original and so on. Autoconf is especially sensitive to this). . "./$as_me.lineno" # Exit status is that of the last command. exit } if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in -n*) case `echo 'x\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. *) ECHO_C='\c';; esac;; *) ECHO_N='-n';; esac if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir mkdir conf$$.dir fi echo >conf$$.file if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. # In both cases, we have to default to `cp -p'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -p' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -p' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null if mkdir -p . 2>/dev/null; then as_mkdir_p=: else test -d ./-p && rmdir ./-p as_mkdir_p=false fi if test -x / >/dev/null 2>&1; then as_test_x='test -x' else if ls -dL / >/dev/null 2>&1; then as_ls_L_option=L else as_ls_L_option= fi as_test_x=' eval sh -c '\'' if test -d "$1"; then test -d "$1/."; else case $1 in -*)set "./$1";; esac; case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in ???[sx]*):;;*)false;;esac;fi '\'' sh ' fi as_executable_p=$as_test_x # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" exec 6>&1 # Save the log message, to keep $[0] and so on meaningful, and to # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" This file was extended by Jed $as_me 0.99-19, which was generated by GNU Autoconf 2.61. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS CONFIG_LINKS = $CONFIG_LINKS CONFIG_COMMANDS = $CONFIG_COMMANDS $ $0 $@ on `(hostname || uname -n) 2>/dev/null | sed 1q` " _ACEOF cat >>$CONFIG_STATUS <<_ACEOF # Files that config.status was made for. config_files="$ac_config_files" config_headers="$ac_config_headers" _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF ac_cs_usage="\ \`$as_me' instantiates files from templates according to the current configuration. Usage: $0 [OPTIONS] [FILE]... -h, --help print this help, then exit -V, --version print version number and configuration settings, then exit -q, --quiet do not print progress messages -d, --debug don't remove temporary files --recheck update $as_me by reconfiguring in the same conditions --file=FILE[:TEMPLATE] instantiate the configuration file FILE --header=FILE[:TEMPLATE] instantiate the configuration header FILE Configuration files: $config_files Configuration headers: $config_headers Report bugs to ." _ACEOF cat >>$CONFIG_STATUS <<_ACEOF ac_cs_version="\\ Jed config.status 0.99-19 configured by $0, generated by GNU Autoconf 2.61, with options \\"`echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\" Copyright (C) 2006 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it." ac_pwd='$ac_pwd' srcdir='$srcdir' INSTALL='$INSTALL' _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF # If no file are specified by the user, then we need to provide default # value. By we need to know if files were specified by the user. ac_need_defaults=: while test $# != 0 do case $1 in --*=*) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` ac_shift=: ;; *) ac_option=$1 ac_optarg=$2 ac_shift=shift ;; esac case $ac_option in # Handling of the options. -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) ac_cs_recheck=: ;; --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) echo "$ac_cs_version"; exit ;; --debug | --debu | --deb | --de | --d | -d ) debug=: ;; --file | --fil | --fi | --f ) $ac_shift CONFIG_FILES="$CONFIG_FILES $ac_optarg" ac_need_defaults=false;; --header | --heade | --head | --hea ) $ac_shift CONFIG_HEADERS="$CONFIG_HEADERS $ac_optarg" ac_need_defaults=false;; --he | --h) # Conflict between --help and --header { echo "$as_me: error: ambiguous option: $1 Try \`$0 --help' for more information." >&2 { (exit 1); exit 1; }; };; --help | --hel | -h ) echo "$ac_cs_usage"; exit ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil | --si | --s) ac_cs_silent=: ;; # This is an error. -*) { echo "$as_me: error: unrecognized option: $1 Try \`$0 --help' for more information." >&2 { (exit 1); exit 1; }; } ;; *) ac_config_targets="$ac_config_targets $1" ac_need_defaults=false ;; esac shift done ac_configure_extra_args= if $ac_cs_silent; then exec 6>/dev/null ac_configure_extra_args="$ac_configure_extra_args --silent" fi _ACEOF cat >>$CONFIG_STATUS <<_ACEOF if \$ac_cs_recheck; then echo "running CONFIG_SHELL=$SHELL $SHELL $0 "$ac_configure_args \$ac_configure_extra_args " --no-create --no-recursion" >&6 CONFIG_SHELL=$SHELL export CONFIG_SHELL exec $SHELL "$0"$ac_configure_args \$ac_configure_extra_args --no-create --no-recursion fi _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF exec 5>>config.log { echo sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX ## Running $as_me. ## _ASBOX echo "$ac_log" } >&5 _ACEOF cat >>$CONFIG_STATUS <<_ACEOF _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF # Handling of arguments. for ac_config_target in $ac_config_targets do case $ac_config_target in "src/sysconf.h") CONFIG_HEADERS="$CONFIG_HEADERS src/sysconf.h:src/config.hin" ;; "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile:autoconf/Makefile.in" ;; "src/Makefile") CONFIG_FILES="$CONFIG_FILES src/Makefile" ;; *) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5 echo "$as_me: error: invalid argument: $ac_config_target" >&2;} { (exit 1); exit 1; }; };; esac done # If the user did not use the arguments to specify the items to instantiate, # then the envvar interface is used. Set only those that are not. # We use the long form for the default assignment because of an extremely # bizarre bug on SunOS 4.1.3. if $ac_need_defaults; then test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers fi # Have a temporary directory for convenience. Make it in the build tree # simply because there is no reason against having it here, and in addition, # creating and moving files from /tmp can sometimes cause problems. # Hook for its removal unless debugging. # Note that there is a small window in which the directory will not be cleaned: # after its creation but before its name has been assigned to `$tmp'. $debug || { tmp= trap 'exit_status=$? { test -z "$tmp" || test ! -d "$tmp" || rm -fr "$tmp"; } && exit $exit_status ' 0 trap '{ (exit 1); exit 1; }' 1 2 13 15 } # Create a (secure) tmp directory for tmp files. { tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" } || { tmp=./conf$$-$RANDOM (umask 077 && mkdir "$tmp") } || { echo "$me: cannot create a temporary directory in ." >&2 { (exit 1); exit 1; } } # # Set up the sed scripts for CONFIG_FILES section. # # No need to generate the scripts if there are no CONFIG_FILES. # This happens for instance when ./config.status config.h if test -n "$CONFIG_FILES"; then _ACEOF ac_delim='%!_!# ' for ac_last_try in false false false false false :; do cat >conf$$subs.sed <<_ACEOF RPATH!$RPATH$ac_delim SHELL!$SHELL$ac_delim PATH_SEPARATOR!$PATH_SEPARATOR$ac_delim PACKAGE_NAME!$PACKAGE_NAME$ac_delim PACKAGE_TARNAME!$PACKAGE_TARNAME$ac_delim PACKAGE_VERSION!$PACKAGE_VERSION$ac_delim PACKAGE_STRING!$PACKAGE_STRING$ac_delim PACKAGE_BUGREPORT!$PACKAGE_BUGREPORT$ac_delim exec_prefix!$exec_prefix$ac_delim prefix!$prefix$ac_delim program_transform_name!$program_transform_name$ac_delim bindir!$bindir$ac_delim sbindir!$sbindir$ac_delim libexecdir!$libexecdir$ac_delim datarootdir!$datarootdir$ac_delim datadir!$datadir$ac_delim sysconfdir!$sysconfdir$ac_delim sharedstatedir!$sharedstatedir$ac_delim localstatedir!$localstatedir$ac_delim includedir!$includedir$ac_delim oldincludedir!$oldincludedir$ac_delim docdir!$docdir$ac_delim infodir!$infodir$ac_delim htmldir!$htmldir$ac_delim dvidir!$dvidir$ac_delim pdfdir!$pdfdir$ac_delim psdir!$psdir$ac_delim libdir!$libdir$ac_delim localedir!$localedir$ac_delim mandir!$mandir$ac_delim DEFS!$DEFS$ac_delim ECHO_C!$ECHO_C$ac_delim ECHO_N!$ECHO_N$ac_delim ECHO_T!$ECHO_T$ac_delim LIBS!$LIBS$ac_delim build_alias!$build_alias$ac_delim host_alias!$host_alias$ac_delim target_alias!$target_alias$ac_delim CONFIG_DIR!$CONFIG_DIR$ac_delim build!$build$ac_delim build_cpu!$build_cpu$ac_delim build_vendor!$build_vendor$ac_delim build_os!$build_os$ac_delim host!$host$ac_delim host_cpu!$host_cpu$ac_delim host_vendor!$host_vendor$ac_delim host_os!$host_os$ac_delim SET_MAKE!$SET_MAKE$ac_delim RANLIB!$RANLIB$ac_delim INSTALL_PROGRAM!$INSTALL_PROGRAM$ac_delim INSTALL_SCRIPT!$INSTALL_SCRIPT$ac_delim INSTALL_DATA!$INSTALL_DATA$ac_delim CC!$CC$ac_delim CFLAGS!$CFLAGS$ac_delim LDFLAGS!$LDFLAGS$ac_delim CPPFLAGS!$CPPFLAGS$ac_delim ac_ct_CC!$ac_ct_CC$ac_delim EXEEXT!$EXEEXT$ac_delim OBJEXT!$OBJEXT$ac_delim CPP!$CPP$ac_delim GREP!$GREP$ac_delim EGREP!$EGREP$ac_delim DYNAMIC_LINK_LIB!$DYNAMIC_LINK_LIB$ac_delim ELF_CC!$ELF_CC$ac_delim ELF_CFLAGS!$ELF_CFLAGS$ac_delim ELF_LINK!$ELF_LINK$ac_delim ELF_LINK_CMD!$ELF_LINK_CMD$ac_delim ELF_DEP_LIBS!$ELF_DEP_LIBS$ac_delim DYNAMIC_LINK_FLAGS!$DYNAMIC_LINK_FLAGS$ac_delim CC_SHARED!$CC_SHARED$ac_delim ELFLIB!$ELFLIB$ac_delim ELFLIB_MAJOR!$ELFLIB_MAJOR$ac_delim ELFLIB_MAJOR_MINOR!$ELFLIB_MAJOR_MINOR$ac_delim ELFLIB_MAJOR_MINOR_MICRO!$ELFLIB_MAJOR_MINOR_MICRO$ac_delim SLANG_LIB_FOR_MODULES!$SLANG_LIB_FOR_MODULES$ac_delim DLL_IMPLIB_NAME!$DLL_IMPLIB_NAME$ac_delim INSTALL_MODULE!$INSTALL_MODULE$ac_delim INSTALL_ELFLIB_TARGET!$INSTALL_ELFLIB_TARGET$ac_delim ELFLIB_BUILD_NAME!$ELFLIB_BUILD_NAME$ac_delim SLANG_DLL_CFLAGS!$SLANG_DLL_CFLAGS$ac_delim M_LIB!$M_LIB$ac_delim PKG_CONFIG!$PKG_CONFIG$ac_delim XMKMF!$XMKMF$ac_delim X_CFLAGS!$X_CFLAGS$ac_delim X_PRE_LIBS!$X_PRE_LIBS$ac_delim X_LIBS!$X_LIBS$ac_delim X_EXTRA_LIBS!$X_EXTRA_LIBS$ac_delim SRCDIR!$SRCDIR$ac_delim OBJDIR!$OBJDIR$ac_delim ELFDIR!$ELFDIR$ac_delim nc5config!$nc5config$ac_delim TERMCAP!$TERMCAP$ac_delim MISC_TERMINFO_DIRS!$MISC_TERMINFO_DIRS$ac_delim SLANG_LIB!$SLANG_LIB$ac_delim SLANG_INC!$SLANG_INC$ac_delim XRENDERFONTLIBS!$XRENDERFONTLIBS$ac_delim PKGCONFIG!$PKGCONFIG$ac_delim _ACEOF if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 97; then break elif $ac_last_try; then { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5 echo "$as_me: error: could not make $CONFIG_STATUS" >&2;} { (exit 1); exit 1; }; } else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi done ac_eof=`sed -n '/^CEOF[0-9]*$/s/CEOF/0/p' conf$$subs.sed` if test -n "$ac_eof"; then ac_eof=`echo "$ac_eof" | sort -nru | sed 1q` ac_eof=`expr $ac_eof + 1` fi cat >>$CONFIG_STATUS <<_ACEOF cat >"\$tmp/subs-1.sed" <<\CEOF$ac_eof /@[a-zA-Z_][a-zA-Z_0-9]*@/!b _ACEOF sed ' s/[,\\&]/\\&/g; s/@/@|#_!!_#|/g s/^/s,@/; s/!/@,|#_!!_#|/ :n t n s/'"$ac_delim"'$/,g/; t s/$/\\/; p N; s/^.*\n//; s/[,\\&]/\\&/g; s/@/@|#_!!_#|/g; b n ' >>$CONFIG_STATUS >$CONFIG_STATUS <<_ACEOF CEOF$ac_eof _ACEOF ac_delim='%!_!# ' for ac_last_try in false false false false false :; do cat >conf$$subs.sed <<_ACEOF MOUSELIB!$MOUSELIB$ac_delim MOUSEDEFINES!$MOUSEDEFINES$ac_delim MOUSE_O_FILE!$MOUSE_O_FILE$ac_delim MOUSE_OBJ_FILE!$MOUSE_OBJ_FILE$ac_delim GTK_CFLAGS!$GTK_CFLAGS$ac_delim GTK_LIBS!$GTK_LIBS$ac_delim BUILD_GTKJED!$BUILD_GTKJED$ac_delim JED_ROOT!$JED_ROOT$ac_delim LIBOBJS!$LIBOBJS$ac_delim LTLIBOBJS!$LTLIBOBJS$ac_delim _ACEOF if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 10; then break elif $ac_last_try; then { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5 echo "$as_me: error: could not make $CONFIG_STATUS" >&2;} { (exit 1); exit 1; }; } else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi done ac_eof=`sed -n '/^CEOF[0-9]*$/s/CEOF/0/p' conf$$subs.sed` if test -n "$ac_eof"; then ac_eof=`echo "$ac_eof" | sort -nru | sed 1q` ac_eof=`expr $ac_eof + 1` fi cat >>$CONFIG_STATUS <<_ACEOF cat >"\$tmp/subs-2.sed" <<\CEOF$ac_eof /@[a-zA-Z_][a-zA-Z_0-9]*@/!b end _ACEOF sed ' s/[,\\&]/\\&/g; s/@/@|#_!!_#|/g s/^/s,@/; s/!/@,|#_!!_#|/ :n t n s/'"$ac_delim"'$/,g/; t s/$/\\/; p N; s/^.*\n//; s/[,\\&]/\\&/g; s/@/@|#_!!_#|/g; b n ' >>$CONFIG_STATUS >$CONFIG_STATUS <<_ACEOF :end s/|#_!!_#|//g CEOF$ac_eof _ACEOF # VPATH may cause trouble with some makes, so we remove $(srcdir), # ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and # trailing colons and then remove the whole line if VPATH becomes empty # (actually we leave an empty line to preserve line numbers). if test "x$srcdir" = x.; then ac_vpsub='/^[ ]*VPATH[ ]*=/{ s/:*\$(srcdir):*/:/ s/:*\${srcdir}:*/:/ s/:*@srcdir@:*/:/ s/^\([^=]*=[ ]*\):*/\1/ s/:*$// s/^[^=]*=[ ]*$// }' fi cat >>$CONFIG_STATUS <<\_ACEOF fi # test -n "$CONFIG_FILES" for ac_tag in :F $CONFIG_FILES :H $CONFIG_HEADERS do case $ac_tag in :[FHLC]) ac_mode=$ac_tag; continue;; esac case $ac_mode$ac_tag in :[FHL]*:*);; :L* | :C*:*) { { echo "$as_me:$LINENO: error: Invalid tag $ac_tag." >&5 echo "$as_me: error: Invalid tag $ac_tag." >&2;} { (exit 1); exit 1; }; };; :[FH]-) ac_tag=-:-;; :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; esac ac_save_IFS=$IFS IFS=: set x $ac_tag IFS=$ac_save_IFS shift ac_file=$1 shift case $ac_mode in :L) ac_source=$1;; :[FH]) ac_file_inputs= for ac_f do case $ac_f in -) ac_f="$tmp/stdin";; *) # Look for the file first in the build tree, then in the source tree # (if the path is not absolute). The absolute path cannot be DOS-style, # because $ac_f cannot contain `:'. test -f "$ac_f" || case $ac_f in [\\/$]*) false;; *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; esac || { { echo "$as_me:$LINENO: error: cannot find input file: $ac_f" >&5 echo "$as_me: error: cannot find input file: $ac_f" >&2;} { (exit 1); exit 1; }; };; esac ac_file_inputs="$ac_file_inputs $ac_f" done # Let's still pretend it is `configure' which instantiates (i.e., don't # use $as_me), people would be surprised to read: # /* config.h. Generated by config.status. */ configure_input="Generated from "`IFS=: echo $* | sed 's|^[^:]*/||;s|:[^:]*/|, |g'`" by configure." if test x"$ac_file" != x-; then configure_input="$ac_file. $configure_input" { echo "$as_me:$LINENO: creating $ac_file" >&5 echo "$as_me: creating $ac_file" >&6;} fi case $ac_tag in *:-:* | *:-) cat >"$tmp/stdin";; esac ;; esac ac_dir=`$as_dirname -- "$ac_file" || $as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$ac_file" : 'X\(//\)[^/]' \| \ X"$ac_file" : 'X\(//\)$' \| \ X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || echo X"$ac_file" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` { as_dir="$ac_dir" case $as_dir in #( -*) as_dir=./$as_dir;; esac test -d "$as_dir" || { $as_mkdir_p && mkdir -p "$as_dir"; } || { as_dirs= while :; do case $as_dir in #( *\'*) as_qdir=`echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" as_dir=`$as_dirname -- "$as_dir" || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" } || test -d "$as_dir" || { { echo "$as_me:$LINENO: error: cannot create directory $as_dir" >&5 echo "$as_me: error: cannot create directory $as_dir" >&2;} { (exit 1); exit 1; }; }; } ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,/..,g;s,/,,'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix case $ac_mode in :F) # # CONFIG_FILE # case $INSTALL in [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;; *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;; esac _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF # If the template does not know about datarootdir, expand it. # FIXME: This hack should be removed a few years after 2.60. ac_datarootdir_hack=; ac_datarootdir_seen= case `sed -n '/datarootdir/ { p q } /@datadir@/p /@docdir@/p /@infodir@/p /@localedir@/p /@mandir@/p ' $ac_file_inputs` in *datarootdir*) ac_datarootdir_seen=yes;; *@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) { echo "$as_me:$LINENO: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} _ACEOF cat >>$CONFIG_STATUS <<_ACEOF ac_datarootdir_hack=' s&@datadir@&$datadir&g s&@docdir@&$docdir&g s&@infodir@&$infodir&g s&@localedir@&$localedir&g s&@mandir@&$mandir&g s&\\\${datarootdir}&$datarootdir&g' ;; esac _ACEOF # Neutralize VPATH when `$srcdir' = `.'. # Shell code in configure.ac might set extrasub. # FIXME: do we really want to maintain this feature? cat >>$CONFIG_STATUS <<_ACEOF sed "$ac_vpsub $extrasub _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF :t /@[a-zA-Z_][a-zA-Z_0-9]*@/!b s&@configure_input@&$configure_input&;t t s&@top_builddir@&$ac_top_builddir_sub&;t t s&@srcdir@&$ac_srcdir&;t t s&@abs_srcdir@&$ac_abs_srcdir&;t t s&@top_srcdir@&$ac_top_srcdir&;t t s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t s&@builddir@&$ac_builddir&;t t s&@abs_builddir@&$ac_abs_builddir&;t t s&@abs_top_builddir@&$ac_abs_top_builddir&;t t s&@INSTALL@&$ac_INSTALL&;t t $ac_datarootdir_hack " $ac_file_inputs | sed -f "$tmp/subs-1.sed" | sed -f "$tmp/subs-2.sed" >$tmp/out test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && { ac_out=`sed -n '/\${datarootdir}/p' "$tmp/out"`; test -n "$ac_out"; } && { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' "$tmp/out"`; test -z "$ac_out"; } && { echo "$as_me:$LINENO: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined." >&5 echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined." >&2;} rm -f "$tmp/stdin" case $ac_file in -) cat "$tmp/out"; rm -f "$tmp/out";; *) rm -f "$ac_file"; mv "$tmp/out" $ac_file;; esac ;; :H) # # CONFIG_HEADER # _ACEOF # Transform confdefs.h into a sed script `conftest.defines', that # substitutes the proper values into config.h.in to produce config.h. rm -f conftest.defines conftest.tail # First, append a space to every undef/define line, to ease matching. echo 's/$/ /' >conftest.defines # Then, protect against being on the right side of a sed subst, or in # an unquoted here document, in config.status. If some macros were # called several times there might be several #defines for the same # symbol, which is useless. But do not sort them, since the last # AC_DEFINE must be honored. ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]* # These sed commands are passed to sed as "A NAME B PARAMS C VALUE D", where # NAME is the cpp macro being defined, VALUE is the value it is being given. # PARAMS is the parameter list in the macro definition--in most cases, it's # just an empty string. ac_dA='s,^\\([ #]*\\)[^ ]*\\([ ]*' ac_dB='\\)[ (].*,\\1define\\2' ac_dC=' ' ac_dD=' ,' uniq confdefs.h | sed -n ' t rset :rset s/^[ ]*#[ ]*define[ ][ ]*// t ok d :ok s/[\\&,]/\\&/g s/^\('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/ '"$ac_dA"'\1'"$ac_dB"'\2'"${ac_dC}"'\3'"$ac_dD"'/p s/^\('"$ac_word_re"'\)[ ]*\(.*\)/'"$ac_dA"'\1'"$ac_dB$ac_dC"'\2'"$ac_dD"'/p ' >>conftest.defines # Remove the space that was appended to ease matching. # Then replace #undef with comments. This is necessary, for # example, in the case of _POSIX_SOURCE, which is predefined and required # on some systems where configure will not decide to define it. # (The regexp can be short, since the line contains either #define or #undef.) echo 's/ $// s,^[ #]*u.*,/* & */,' >>conftest.defines # Break up conftest.defines: ac_max_sed_lines=50 # First sed command is: sed -f defines.sed $ac_file_inputs >"$tmp/out1" # Second one is: sed -f defines.sed "$tmp/out1" >"$tmp/out2" # Third one will be: sed -f defines.sed "$tmp/out2" >"$tmp/out1" # et cetera. ac_in='$ac_file_inputs' ac_out='"$tmp/out1"' ac_nxt='"$tmp/out2"' while : do # Write a here document: cat >>$CONFIG_STATUS <<_ACEOF # First, check the format of the line: cat >"\$tmp/defines.sed" <<\\CEOF /^[ ]*#[ ]*undef[ ][ ]*$ac_word_re[ ]*\$/b def /^[ ]*#[ ]*define[ ][ ]*$ac_word_re[( ]/b def b :def _ACEOF sed ${ac_max_sed_lines}q conftest.defines >>$CONFIG_STATUS echo 'CEOF sed -f "$tmp/defines.sed"' "$ac_in >$ac_out" >>$CONFIG_STATUS ac_in=$ac_out; ac_out=$ac_nxt; ac_nxt=$ac_in sed 1,${ac_max_sed_lines}d conftest.defines >conftest.tail grep . conftest.tail >/dev/null || break rm -f conftest.defines mv conftest.tail conftest.defines done rm -f conftest.defines conftest.tail echo "ac_result=$ac_in" >>$CONFIG_STATUS cat >>$CONFIG_STATUS <<\_ACEOF if test x"$ac_file" != x-; then echo "/* $configure_input */" >"$tmp/config.h" cat "$ac_result" >>"$tmp/config.h" if diff $ac_file "$tmp/config.h" >/dev/null 2>&1; then { echo "$as_me:$LINENO: $ac_file is unchanged" >&5 echo "$as_me: $ac_file is unchanged" >&6;} else rm -f $ac_file mv "$tmp/config.h" $ac_file fi else echo "/* $configure_input */" cat "$ac_result" fi rm -f "$tmp/out12" ;; esac done # for ac_tag { (exit 0); exit 0; } _ACEOF chmod +x $CONFIG_STATUS ac_clean_files=$ac_clean_files_save # configure is writing to config.log, and then calls config.status. # config.status does its own redirection, appending to config.log. # Unfortunately, on DOS this fails, as config.log is still kept open # by configure, so config.status won't be able to write to it; its # output is simply discarded. So we exec the FD to /dev/null, # effectively closing config.log, so it can be properly (re)opened and # appended to by config.status. When coming back to configure, we # need to make the FD available again. if test "$no_create" != yes; then ac_cs_success=: ac_config_status_args= test "$silent" = yes && ac_config_status_args="$ac_config_status_args --quiet" exec 5>/dev/null $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false exec 5>>config.log # Use ||, not &&, to avoid exiting from the if with $? = 1, which # would make configure fail if this is the last instruction. $ac_cs_success || { (exit 1); exit 1; } fi echo "" echo "You will need to edit src/Makefile if any of the following are not correct:" echo " CC =" "$CC" echo " CFLAGS =" "$CFLAGS" echo " LDFLAGS =" "$LDFLAGS" "$DYNAMIC_LINK_FLAGS" echo " JED_ROOT =" "$JED_ROOT" echo "" echo "Also edit src/Makefile to enable:" echo " GPM Mouse support (Linux)" echo "You may also want to edit src/jed-feat.h to enable or disable some features." echo "" echo "Before typing 'make', type 'make clean' first." echo "" jed-0.99-19/INSTALL.vms0000644002657400265740000001117211311317447013331 0ustar davisdavis0. Building and installing JED requires that you also have the S-Lang library to link to. Build it first. 1. Pick some place for JED. JED is distributed in a TREE structure: JED_ROOT: JED_ROOT:[src] JED_ROOT:[info] JED_ROOT:[doc] JED_ROOT:[lib] JED_ROOT:[bin.vms] Here JED_ROOT can be anything. Its value is up to you. It should be a concealed logical. For example, suppose that JED is unpacked in a directory dev$source:[editors.jed] You CANNOT simply define JED_ROOT to be this value. Instead, it must be a concealed logical defined as: $ define/job/trans=(concealed) jed_root dev$source:[editors.jed.] It is important to note the final `.' after jed. This logical must be placed in the job table; system managers may put it in the system table instead. Instead of the above, I recommend something like: $ jedroot = f$logical("DEV$SOURCE") - "]" + "EDITORS.JED.]" $ define/job/trans=(concealed) jed_root 'jedroot' It is best to put the definition in the appropriate startup file (systartup.com, sylogin.com, login.com). Note: If are currently using a very old version of JED and and you have JED_LIBRARY defined as a logical, please remove it. 2. Build the jed.exe executable file: After you have properly setup the JED_ROOT logical, change to the directory 'jed_root:[src]'. You should now edit the 'vmsmake.com' file to indicate the location of the S-Lang library constructed in step 0. Directions are included in VMSMAKE.COM. Currently the file is structured such that typing `@VMSMAKE' at the VMS DCL prompt will make jed.exe for systems which have DEC's VMS C compiler. For systems that use GCC, `@vmsmake gcc' might also work. That is: $ @vmsmake ! VMS CC, DEC C $ @vmsmake gcc ! GNU GCC After building the JED.EXE and XJED.EXE images, copy them into the JED_ROOT:[BIN.VMS] directory, giving them architecture-specific names such as JED.VAX_EXE or JED.ALPHA_EXE. 4. Put one of the following in either your sylogin.com for all users or in login.com. Note that JED_ROOT must be defined! $ @JED_ROOT:[bin.vms]init_jed.com 0 0 ! no kept editor/no mail $ @JED_ROOT:[bin.vms]init_jed.com 0 1 ! no kept editor/ use for mail $ @JED_ROOT:[bin.vms]init_jed.com 1 0 ! kept editor/ no mail (most systems) $ @JED_ROOT:[bin.vms]init_jed.com 1 1 ! kept editor/use for mail The first flag indicates whether jed should be installed as a standalone executable or as a kept editor. Use 1 for kepteditor or 0 for standalone. The second flag indicates whether or not mail$edit logical should be defined to point to jed. If it is set to 1, vms mail will call jed to edit the mail message. If JED is run as a kept editor, mail will simply attach to JED for editing. Most systems will probably use the 3rd choice above. 5. The file JED_ROOT:[lib]jed.rc contains some default settings for users that do not have a jed.rc file in SYS$LOGIN. If SYS$LOGIN:jed.rc exists, then it will be used instead. By default, jed starts up with EMACS keybindings. You may want to specify some other emulation, such as the Borland IDE emulation or even EDT emulation. It is not necessary for every user to have a copy of this file. 6. It may be necessary to edit site.sl if you have an info directory where info files are kept. If you do not understand this statement, then you do not have info. 7. Make sure all users who will be using JED have permission to do so. The easiest way to do this is to type: $ set file/protection=(w:re) jed_root:[000000...] 8. Optional but highly recommended. Preparse the S-Lang files. This is done by running JED as: $ jed -batch -n -l preparse This creates pre-parsed *.slc files that load quicker than *.sl files. It is also a convenient test to see if JED has been installed properly. Once you do this, make sure that you give the WORLD read permission on the files. Do: $ set file/protection=(W:RE) JED_ROOT:[lib]*.slc !!! Do not use *.*. Use *.slc. 9. It is possible that you have the PC distribution. This distribution truncates filenames to 8+3 style names. If you have JED_ROOT:[LIB]VMS_SHEL.COM, rename it to VMS_SHELL.COM. Also make sure that JED_ROOT:[INFO] contains dir.info and not dir.inf. 10. Read the bit about defaults.sl in install.all for customizing your distribution. 11. Please email bugs, installation problems, or hints about how to better install JED to `davis@space.mit.edu'. jed-0.99-19/src/0000755002657400265740000000000011311317447012261 5ustar davisdavisjed-0.99-19/src/pcmouse.c0000644002657400265740000001577411311317447014116 0ustar davisdavis/* -*- mode: C; mode: fold; -*- */ /* Copyright (c) 1992, 1998, 2000, 2002, 2003, 2004, 2005, 2006 John E. Davis * This file is part of JED editor library source. * * You may distribute this file under the terms the GNU General Public * License. See the file COPYING for more information. */ #include "config.h" #include "jed-feat.h" #include #include #if JED_HAS_MULTICLICK #include #include static int JX_MultiClick_Time = 5; /* 5/10 of sec */ #endif #ifdef __GO32__ # include # include #endif static int Mouse_X, Mouse_Y; static void generate_press (int x, int y, int type, int but) /*{{{*/ { char buf[3]; unsigned char b, s; JMouse_Type jm; int id; #if JED_HAS_MULTICLICK clock_t t; static clock_t last_press_time; static unsigned int clicks; static unsigned int last_button; t = clock (); t = t / (CLOCKS_PER_SEC / 10); /* clocks per 1/10 sec */ if (type == JMOUSE_DOWN) { if (((int)last_button == but) && (last_press_time + JX_MultiClick_Time > t)) { clicks++; if (clicks == 2) type = JMOUSE_DOUBLE_CLICK; else type = JMOUSE_TRIPLE_CLICK; } else { clicks = 1; last_button = but; } last_press_time = t; } else if ((clicks > 1) && ((int)last_button == but)) { /* Last was a multi-click. Ignore this event. */ type = JMOUSE_IGNORE_EVENT; } #endif Mouse_X = jm.x = x; Mouse_Y = jm.y = y; b = but & 0xF; s = but >> 4; if (b == 1) jm.button = JMOUSE_BUTTON_1; /* left */ else if (b == 2) jm.button = JMOUSE_BUTTON_3; /* right */ else jm.button = JMOUSE_BUTTON_2; /* middle */ if (s & 0x8) /* alt key--- use as middle */ { jm.button = JMOUSE_BUTTON_2; } if (s & 0x3) jm.state = JMOUSE_SHIFT; else if (s & 0x4) jm.state = JMOUSE_CTRL; else jm.state = 0; jm.type = type; if (-1 == (id = jed_mouse_add_event (&jm))) return; buf[0] = 27; buf[1] = 0; buf[2] = (char) id; ungetkey_string (buf, 3); } /*}}}*/ /* Mouse routines for the ibmpc */ static int Mouse_Hidden = 1; static int Last_Mouse_Hidden = 1; static void show_mouse (int show) /*{{{*/ { union REGS r; if (show) { if (Mouse_Hidden == 0) return; r.x.ax = 1; } else { if (Mouse_Hidden) return; r.x.ax = 2; } int86 (0x33, &r, &r); Mouse_Hidden = !show; } /*}}}*/ static void pc_close_mouse () /*{{{*/ { show_mouse (0); } /*}}}*/ static int pc_get_mouse_event (void) /*{{{*/ { union REGS r; static int last_press; short x, y; /* return 0; */ if (last_press) { show_mouse (1); r.x.ax = 6; r.x.bx = (last_press & 0xF) - 1; int86 (0x33, &r, &r); if (r.x.bx) { /* truncate to short because DJGPP has junk in 32 bit registers*/ x = r.x.cx; y = r.x.dx; x = x / 8 + 1; y = y / 8 + 1; generate_press (x, y, JMOUSE_UP, last_press); last_press = 0; return 1; } } r.x.ax = 3; int86 (0x33, &r, &r); x = r.x.cx; y = r.x.dx; #if 0 /* Check motion counters */ r.x.ax = 0xB; int86 (0x33, &r, &r); #endif if (last_press) { #if 0 y += (short) (int) (r.x.dx); #endif x = x / 8 + 1; y = y / 8 + 1; if ((Mouse_X == x) && (Mouse_Y == y)) return 0; generate_press (x, y, JMOUSE_DRAG, last_press); return 1; } x = x / 8 + 1; y = y / 8 + 1; /* It looks like we are looking for a press. */ if ((Mouse_X != x) || (Mouse_Y != y)) { /* mouse moved so show it. */ show_mouse (1); } Mouse_X = x; Mouse_Y = y; if (r.x.bx) { if (r.x.bx & 1) last_press = 1; /* left */ else if (r.x.bx & 2) last_press = 2; /* right */ else if (r.x.bx & 4) last_press = 3; /* middle */ else return 0; /* Find shift key status */ #ifdef __GO32__ r.h.ah = 0x12; int86 (0x16, &r, &r); last_press |= (r.x.ax & 0xF) << 4; #else last_press |= (*(unsigned char far *) 0x417) << 4; #endif generate_press (x, y, JMOUSE_DOWN, last_press); return 1; } return 0; } /*}}}*/ static void move_mouse (int x, int y) /*{{{*/ { union REGS r; r.x.ax = 4; r.x.cx = 8 * (x - 1); r.x.dx = 8 * (y - 1); int86 (0x33, &r, &r); } /*}}}*/ static void pc_update_open_hook (void) /*{{{*/ { Last_Mouse_Hidden = Mouse_Hidden; if (Mouse_Hidden == 0) show_mouse (0); } /*}}}*/ static int Warp_Pending; static void pc_update_close_hook (void) /*{{{*/ { if (Last_Mouse_Hidden == 0) show_mouse (1); if (Warp_Pending) move_mouse (Screen_Col, Screen_Row); Warp_Pending = 0; } /*}}}*/ static void warp_pointer (void) /*{{{*/ { Warp_Pending = 1; } /*}}}*/ static char *CutBuffer; static int CutBuffer_Len; static int insert_cutbuffer (void) /*{{{*/ { CHECK_READ_ONLY if (CutBuffer == NULL) return 0; if (CutBuffer_Len) jed_insert_nbytes ((unsigned char *) CutBuffer, CutBuffer_Len); return CutBuffer_Len; } /*}}}*/ static void region_to_cutbuffer (void) /*{{{*/ { int nbytes; if (CutBuffer != NULL) { SLfree (CutBuffer); } CutBuffer = make_buffer_substring(&nbytes); CutBuffer_Len = nbytes; } /*}}}*/ static SLang_Intrin_Fun_Type gpm_mouse_table[] = /*{{{*/ { MAKE_INTRINSIC("x_warp_pointer", warp_pointer, VOID_TYPE, 0), MAKE_INTRINSIC("x_insert_cutbuffer", insert_cutbuffer, INT_TYPE, 0), /* Prototype: Integer x_insert_cut_buffer (); * Inserts cutbuffer into the current buffer and returns the number * of characters inserted. */ MAKE_INTRINSIC("x_copy_region_to_cutbuffer", region_to_cutbuffer, VOID_TYPE, 0), /* Prototype: Void x_copy_region_to_cutbuffer(); */ SLANG_END_TABLE }; /*}}}*/ void (*X_Close_Mouse_Hook)(void); static int pc_open_mouse (void) /*{{{*/ { union REGS r; int rows, cols, scanlines; static int not_first_time; X_Close_Mouse_Hook = NULL; JMouse_Event_Hook = NULL; JMouse_Hide_Mouse_Hook = NULL; X_Update_Open_Hook = NULL; X_Update_Close_Hook = NULL; #ifndef __GO32__ if (getvect (0x33) == NULL) return -1; #endif /* Now see if the mouse is present */ r.x.ax = 0x21; int86 (0x33, &r, &r); if (r.x.ax == 0x21) return -1; jed_get_screen_size (&rows, &cols); #ifdef __GO32__ scanlines = _farpeekw (_go32_conventional_mem_selector (), 0x485); #else scanlines = *(int *) 0x485; #endif if (scanlines <= 0) scanlines = 8; r.x.ax = 7; r.x.cx = 0; r.x.dx = 8 * cols - 1; int86 (0x33, &r, &r); r.x.ax = 8; r.x.cx = 0; r.x.dx = scanlines * rows - 1; int86 (0x33, &r, &r); move_mouse (cols / 2 + 1, rows / 2 + 1); if (not_first_time == 0) { if (-1 == SLadd_intrin_fun_table (gpm_mouse_table, "MOUSE")) return -1; not_first_time = 1; } JMouse_Hide_Mouse_Hook = show_mouse; X_Close_Mouse_Hook = pc_close_mouse; JMouse_Event_Hook = pc_get_mouse_event; X_Update_Open_Hook = pc_update_open_hook; X_Update_Close_Hook = pc_update_close_hook; return 1; } /*}}}*/ int (*X_Open_Mouse_Hook)(void) = pc_open_mouse; jed-0.99-19/src/text.c0000644002657400265740000003047011311317447013415 0ustar davisdavis/* -*- mode: C; mode: fold; -*- */ /* Copyright (c) 1992, 1998, 2000, 2002, 2003, 2004, 2005, 2006 John E. Davis * This file is part of JED editor library source. * * You may distribute this file under the terms the GNU General Public * License. See the file COPYING for more information. */ #include "config.h" #include "jed-feat.h" /*{{{ Include Files */ #include #include #include "jdmacros.h" #include #include #include "buffer.h" #include "ins.h" #include "ledit.h" #include "text.h" #include "screen.h" #include "cmds.h" #include "paste.h" #include "misc.h" /*}}}*/ /* This routine deletes multiple spaces except those following a period, '?' * or a '!'. Returns the address of beginning of non whitespace */ static unsigned char *text_format_line(void) /*{{{*/ { unsigned char *p, *pmin, *pmax; unsigned int point_min; bol (); jed_skip_whitespace (); point_min = Point; p = CLine->data + point_min; pmax = jed_eol_position (CLine); while (p < pmax) { if (*p == '\t') { jed_position_point (p); if (-1 == _jed_replace_wchar (' ')) return NULL; /* In case the underlying pointer changed, reset these */ p = CLine->data + Point; pmax = jed_eol_position (CLine); } p++; } pmin = CLine->data + point_min; p = pmax - 1; while (p > pmin) { unsigned char *p1; unsigned int n; if ((*p != ' ') && (*p != '\t')) { p--; continue; } jed_position_point (p); p1 = jed_bskip_whitespace (); if (p == p1) { p--; /* single space */ continue; } /* multiple spaces */ n = p - p1; p = p1; p1--; if ((*p1 == '.') || (*p1 == '?') || (*p1 == '!')) n--; if (n) { jed_position_point (p); jed_del_nbytes (n); pmin = CLine->data + point_min; p = CLine->data + Point; } p--; } return pmin; } /*}}}*/ /* returns 0 if to wrapped, 1 if wrapped, -1 if error */ static int wrap_line1(int format, int trim) /*{{{*/ { unsigned char *p, *pmin; int col; if (format) pmin = text_format_line(); else { bol (); /* Ignore leading whitespace */ pmin = jed_skip_whitespace (); /* pmin = CLine->data; */ } if (pmin == NULL) return -1; point_column(Buffer_Local.wrap_column - 1); col = calculate_column(); if ((col < Buffer_Local.wrap_column) && eolp ()) return 0; p = CLine->data + Point; while(p > pmin) { if ((*p == ' ') || (*p == '\t')) break; p--; } if (p == pmin) { /* that failed, so go the other way */ p = CLine->data + CLine->len; while(pmin < p) { if ((*pmin == ' ') || (*pmin == '\t')) break; pmin++; } if (p == pmin) return 0; p = pmin; } jed_position_point (p); if (trim) (void)jed_trim_whitespace(); (void) jed_insert_newline(); jed_up(1); return 1; } /*}}}*/ int wrap_line (int format) /*{{{*/ { int ret; push_spot(); ret = wrap_line1(format, 1); pop_spot(); return ret; } /*}}}*/ static int is_paragraph_sep(void) /*{{{*/ { int ret; Jed_Buffer_Hook_Type *h = CBuf->buffer_hooks; if ((h != NULL) && (h->par_sep != NULL)) { if ((-1 == SLexecute_function(h->par_sep)) || (-1 == SLang_pop_integer(&ret))) ret = -1; return ret; } push_spot (); (void) bol (); jed_skip_whitespace (); if (eolp ()) { pop_spot (); return 1; } pop_spot (); return 0; } /*}}}*/ int backward_paragraph(void) /*{{{*/ { Jed_Buffer_Hook_Type *h = CBuf->buffer_hooks; if ((h != NULL) && (h->backward_paragraph_hook != NULL)) { if (0 == SLexecute_function (h->backward_paragraph_hook)) return 1; return -1; } bol (); while ((1 == is_paragraph_sep ()) && jed_up (1)) bol (); while ((0 == is_paragraph_sep ()) && jed_up (1)) bol (); return 1; } /*}}}*/ int forward_paragraph(void) /*{{{*/ { Jed_Buffer_Hook_Type *h = CBuf->buffer_hooks; if ((h != NULL) && (h->forward_paragraph_hook != NULL)) { if (0 == SLexecute_function (h->forward_paragraph_hook)) return 1; return -1; } while (1) { if (0 == jed_down (1)) { eol (); break; } if (is_paragraph_sep ()) break; } return(1); } /*}}}*/ static int mark_paragraph (Line **begp, Line **endp) { Jed_Buffer_Hook_Type *h = CBuf->buffer_hooks; if ((h != NULL) && (h->mark_paragraph_hook != NULL)) { int point; Line *end; if (-1 == SLexecute_function (h->mark_paragraph_hook)) return -1; point = Point; end = CLine; if (Point && eobp ()) *endp = NULL; else *endp = end; (void) jed_pop_mark (1); *begp = CLine; if ((end == CLine) && (point == Point)) return -1; return 0; } if (is_paragraph_sep()) { pop_spot(); return -1; } /* find end */ forward_paragraph(); if (Point && eobp ()) *endp = NULL; else *endp = CLine; /* find paragraph start */ backward_paragraph(); if (is_paragraph_sep()) (void) jed_down (1); *begp = CLine; return 0; } /* format paragraph and if Prefix argument justify_hook is called. */ int text_format_paragraph () /*{{{*/ { unsigned char *p; int indent_col, col; Line *end, *beg, *next; Jed_Buffer_Hook_Type *h = CBuf->buffer_hooks; CHECK_READ_ONLY if ((h != NULL) && (h->format_paragraph_hook != NULL)) return SLexecute_function (h->format_paragraph_hook); push_spot(); get_current_indent(&indent_col); if (indent_col + 1 >= Buffer_Local.wrap_column) indent_col = 0; if (-1 == mark_paragraph (&beg, &end)) return 0; get_current_indent (&col); /* col is the indentation of the first line of the paragraph-- don't change it */ bol (); while (CLine != end) { if (-1 == wrap_line1 (0, 0)) { pop_spot (); return -1; } if (0 == jed_down (1)) break; } while ((CLine != beg) && (0 != jed_up (1))) ; if (col + 1 >= Buffer_Local.wrap_column) indent_to (indent_col); bol (); /* Now loop formatting as we go until the end is reached */ while(CLine != end) { int status; /* eol(); */ if (CLine != beg) indent_to(indent_col); status = wrap_line1(1, 1); if (status == -1) { pop_spot (); return -1; } if (status == 1) { (void) jed_down(1); /* indent_to(indent_col); */ continue; } else if (CLine->next == end) break; next = CLine->next; if (next != end) { unsigned char *pmax; /* Now count the length of the word on the next line. */ (void) jed_down(1); /* at bol too */ jed_trim_whitespace(); p = CLine->data; pmax = jed_eol_position (CLine); /* FIXME for other multibyte whitespace chars */ while ((p < pmax) && (*p > ' ')) p++; jed_up(1); /* at eol too */ col = calculate_column(); /* FIXME for multibyte */ if ((p - next->data) + col < Buffer_Local.wrap_column - 1) { if (-1 == _jed_replace_wchar (' ')) return -1; } else { (void) jed_down(1); } } } if (Repeat_Factor != NULL) { SLang_run_hooks("format_paragraph_hook", 0); Repeat_Factor = NULL; } pop_spot(); return(1); } /*}}}*/ int narrow_paragraph(void) /*{{{*/ { int wrap, n; CHECK_READ_ONLY /* if (CBuf->modes != WRAP_MODE) return(0); */ get_current_indent(&n); wrap = Buffer_Local.wrap_column; if (wrap - n <= wrap/2) return(0); Buffer_Local.wrap_column -= n; text_format_paragraph(); Buffer_Local.wrap_column = wrap; return(1); } /*}}}*/ int center_line(void) /*{{{*/ { unsigned char *p, *pmax; int len; CHECK_READ_ONLY push_spot(); (void) eol_cmd(); p = CLine->data; pmax = p + CLine->len; while(p < pmax) { if (*p > ' ') break; p++; } if ((len = (int)(pmax - p)) < 0) len = 0; if ((len = (Buffer_Local.wrap_column - len) / 2) < 0) len = 0; indent_to(len); pop_spot(); return(1); } /*}}}*/ int text_smart_quote(void) /*{{{*/ { unsigned char c; int upd, last; /* Force a screen update. This help syntax highlighting */ JWindow->trashed = 1; if (Point) c = *(CLine->data + (Point - 1)); else c = 0; if (!(CBuf->modes & WRAP_MODE) || (c == '\\')) return ins_char_cmd(); last = SLang_Last_Key_Char; if ((c == '(') || (c == '[') || (c == '{') || (c <= ' ') || !Point) SLang_Last_Key_Char = '`'; else SLang_Last_Key_Char = '\''; upd = ins_char_cmd(); if (last == '"') upd = ins_char_cmd(); SLang_Last_Key_Char = last; return upd; } /*}}}*/ /* FIXME: This needs to be corrected for UTF-8 */ char Jed_Word_Range[256]; void define_word(char *w) /*{{{*/ { strncpy(Jed_Word_Range, w, sizeof (Jed_Word_Range)); Jed_Word_Range[sizeof(Jed_Word_Range) - 1] = 0; } /*}}}*/ char *jed_get_word_chars (void) { return Jed_Word_Range; } #if SLANG_VERSION < 20000 static void skip_chars_forward (char *range, int invert) { unsigned char lut[256]; SLmake_lut(lut, (unsigned char *) range, (unsigned char) invert); /* more flexibility is achieved with following line */ if (invert && lut['\n']) lut['\n'] = 0; do { unsigned char *p = CLine->data + Point; unsigned char *pmax = CLine->data + CLine->len; while (p < pmax) { if (0 == lut[*p]) { jed_position_point (p); return; } p++; } } while (jed_down (1)); eob(); } static void skip_chars_backward (char *range, int invert) { unsigned char lut[256]; SLmake_lut(lut, (unsigned char *) range, (unsigned char) invert); /* more flexibility is achieved with following line */ if (invert && lut['\n']) lut['\n'] = 0; do { unsigned char *pmin = CLine->data; unsigned char *p = pmin + Point; while (p > pmin) { p--; if (0 == lut[*p]) { jed_position_point (p+1); return; } } bol (); if (lut['\n'] == 0) return; } while (jed_up (1)); bob(); } #else /* SLANG_VERSION >= 20000 */ static void skip_chars_backward (char *range, int invert) { SLwchar_Lut_Type *lut; int ignore_combining = 1; int no_newline; if (*range == '^') { invert = !invert; range++; } if (NULL == (lut = SLwchar_strtolut ((SLuchar_Type *)range, 1, 1))) return; no_newline = (0 == SLwchar_in_lut (lut, '\n')); if (invert) no_newline = !no_newline; do { unsigned char *p = CLine->data + Point; unsigned char *pmin = CLine->data; p = SLwchar_bskip_range (lut, pmin, p, ignore_combining, invert); if (p == NULL) { SLwchar_free_lut (lut); return; } jed_position_point (p); if (p > pmin) { SLwchar_free_lut (lut); return; } if (no_newline) { SLwchar_free_lut (lut); return; } } while (jed_up (1)); SLwchar_free_lut (lut); bob (); } static void skip_chars_forward (char *range, int invert) { SLwchar_Lut_Type *lut; int ignore_combining = 1; if (*range == '^') { invert = !invert; range++; } if (NULL == (lut = SLwchar_strtolut ((SLuchar_Type *)range, 1, 1))) return; do { unsigned char *p = CLine->data + Point; unsigned char *pmax = CLine->data + CLine->len; p = SLwchar_skip_range (lut, p, pmax, ignore_combining, invert); if (p == NULL) { SLwchar_free_lut (lut); return; } if (p < pmax) { jed_position_point (p); SLwchar_free_lut (lut); return; } } while (jed_down (1)); SLwchar_free_lut (lut); eob(); } #endif void skip_word_chars(void) /*{{{*/ { skip_chars_forward (Jed_Word_Range, 0); } /*}}}*/ void skip_non_word_chars(void) /*{{{*/ { skip_chars_forward (Jed_Word_Range, 1); } /*}}}*/ void bskip_word_chars(void) /*{{{*/ { skip_chars_backward (Jed_Word_Range, 0); } /*}}}*/ void bskip_non_word_chars(void) /*{{{*/ { skip_chars_backward (Jed_Word_Range, 1); } /*}}}*/ /*{{{ skip_chars */ void jed_skip_chars (char *range) { if (*range == '^') skip_chars_forward (range + 1, 1); else { if ((*range == '\\') && (range[1] == '^')) range++; skip_chars_forward (range, 0); } } /*}}}*/ /*{{{ bskip_chars */ void jed_bskip_chars (char *range) { if (*range == '^') skip_chars_backward (range + 1, 1); else { if ((*range == '\\') && (range[1] == '^')) range++; skip_chars_backward (range, 0); } } /*}}}*/ jed-0.99-19/src/cmds.h0000644002657400265740000000407111311317447013362 0ustar davisdavis/* Copyright (c) 1992, 1998, 2000, 2005, 2006 John E. Davis * This file is part of JED editor library source. * * You may distribute this file under the terms the GNU General Public * License. See the file COPYING for more information. */ extern int jed_buffer_visible (char *b); extern int newline(void); extern int newline_cmd(void); extern int previous_char_cmd(void); extern int delete_char_cmd(void); extern int backward_delete_char_cmd(void); extern int backward_delete_char_untabify(void); extern int previous_line_cmd(void); extern int next_line_cmd(void); extern int next_char_cmd(void); extern int kill_line(void); extern void insert_line(Line *line); extern int double_line(void); extern int kill_eol_cmd(void); extern int kill_line_cmd(void); extern int jed_trim_whitespace(void); extern int indent_line(void); extern int transpose_lines(void); extern int newline_and_indent(void); extern int eol_cmd(void); extern int sys_spawn_cmd(void); extern int jed_spawn_fg_process (int (*)(VOID_STAR), VOID_STAR); extern int ins_char_cmd(void); extern int jed_exit_jed(int); extern int jed_quit_jed(int); extern int jed_exit_jed_cmd(void); extern int save_some_buffers(void); extern int pagedown_cmd(void); extern int pageup_cmd(void); extern int jed_scroll_left_cmd (void); extern int jed_scroll_right_cmd (void); extern int quoted_insert(void); extern void indent_to(int); extern int goto_column1(int *); extern void goto_column(int *); extern void goto_top_of_window (void); extern int goto_bottom_of_window (void); extern void insert_whitespace(int *); extern unsigned char *get_current_indent(int *); extern unsigned char *jed_skip_whitespace (void); extern unsigned char *jed_bskip_whitespace (void); extern int jed_looking_at(char *); extern int Blink_Flag; extern int Indented_Text_Mode; extern int Kill_Line_Feature; extern int Jed_Secure_Mode; extern int Goal_Column; extern int Jed_Tab_Default; extern int Jed_Wrap_Default; extern int Jed_Case_Search_Default; extern int Jed_Suspension_Not_Allowed; extern int Jed_Use_Tabs; #if 0 extern int new_find_matching (int *, int *); #endif jed-0.99-19/src/config.hin0000644002657400265740000000574711311317447014243 0ustar davisdavis/* -*- C -*- */ /* Copyright (c) 2007 John E. Davis * This file is part of JED editor library source. * * You may distribute this file under the terms the GNU General Public * License. See the file COPYING for more information. */ /* Note: this is for unix only. */ #ifndef JED_CONFIG_H #define JED_CONFIG_H /* define if you have stdlib.h */ #undef HAVE_STDLIB_H /* define if you have unistd.h */ #undef HAVE_UNISTD_H /* define if you have termios.h */ #undef HAVE_TERMIOS_H /* define if you have memory.h */ #undef HAVE_MEMORY_H /* define if you have malloc.h */ #undef HAVE_MALLOC_H /* define if you have limits.h */ #undef HAVE_LIMITS_H /* define if you have fcntl.h */ #undef HAVE_FCNTL_H /* define if you have sys/fcntl.h */ #undef HAVE_SYS_FCNTL_H #undef HAVE_PTY_H #undef HAVE_SYS_PTY_H /* define if you have memset */ #undef HAVE_MEMSET /* define if you have memcpy */ #undef HAVE_MEMCPY /* define if you have these. */ #undef HAVE_SETENV #undef HAVE_UNSETENV #undef HAVE_SETSID #undef HAVE_PUTENV #undef HAVE_GETCWD #undef HAVE_TCGETATTR #undef HAVE_TCSETATTR #undef HAVE_CFGETOSPEED #undef HAVE_GETPGID #undef HAVE_SETPGID #undef HAVE_TCSETPGRP #undef HAVE_TCGETPGRP #undef HAVE_OPENPTY #undef HAVE_GLOB_H #undef HAVE_SYS_WAIT_H #undef HAVE_DIRENT_H #undef HAVE_SYS_NDIR_H #undef HAVE_SYS_DIR_H #undef HAVE_NDIR_H #undef HAVE_PCRE_H #undef HAVE_DLOPEN #undef HAVE_GRANTPT #undef HAVE_UTIME #undef HAVE_SETLOCALE #undef HAVE_SYMLINK #undef HAVE_GETHOSTNAME /* Define if you have the vsnprintf, snprintf functions and they return * EOF upon failure. */ #undef HAVE_VSNPRINTF #undef HAVE_SNPRINTF #undef mode_t #undef pid_t #undef uid_t #undef gid_t #undef SIZEOF_SHORT #undef SIZEOF_INT #undef SIZEOF_LONG #undef SIZEOF_FLOAT #undef SIZEOF_DOUBLE #undef SIZEOF_LONG_LONG #undef HAVE_LONG_LONG /* The following set defines may be necessary to activate long file support */ #undef _FILE_OFFSET_BITS #undef _LARGE_FILES #undef _LARGEFILE_SOURCE /* For antialiased fonts, set this to 1 */ #undef XJED_HAS_XRENDERFONT /* Undefine this to disable floating point support. */ #define FLOAT_TYPE #if defined(ultrix) && !defined(__GNUC__) # ifndef NO_PROTOTYPES # define NO_PROTOTYPES # endif #endif #ifndef REAL_UNIX_SYSTEM # define REAL_UNIX_SYSTEM #endif #ifndef __unix__ # define __unix__ 1 #endif #ifdef _AIX # ifndef _POSIX_SOURCE # define _POSIX_SOURCE # endif # ifndef _ALL_SOURCE # define _ALL_SOURCE # endif /* This may generate warnings but the fact is that without it, xlc will * INCORRECTLY inline many str* functions. */ # undef __STR__ #endif /* #ifdef NeXT */ /* # ifndef _POSIX_SOURCE */ /* # define _POSIX_SOURCE */ /* # endif */ /* #endif */ #ifdef NeXT # undef HAVE_UTIME #endif #ifdef HAVE_TERMIOS_H # if defined(HAVE_TCGETATTR) && defined(HAVE_TCSETATTR) # define REALLY_HAVE_TERMIOS_H # endif #endif #define HAS_MOUSE 1 /* Set this to 1 if the filesystem is case-sensitive */ #define JED_FILE_PRESERVE_CASE 1 #ifndef JED # define JED #endif #endif /* JED_CONFIG_H */ jed-0.99-19/src/buffer.h0000644002657400265740000003004211311317447013702 0ustar davisdavis/* Copyright (c) 1992, 1998, 2000, 2005, 2006 John E. Davis * This file is part of JED editor library source. * * You may distribute this file under the terms the GNU General Public * License. See the file COPYING for more information. */ #ifndef __JED_BUFFER_H_ #define __JED_BUFFER_H_ #ifdef HAVE_STDLIB_H # include #endif #include #include "jedlimit.h" #if SLANG_VERSION >= 20000 # define SLANG_V2 #endif #ifdef SLANG_V2 # define JED_HAS_UTF8_SUPPORT 1 #else # define JED_HAS_UTF8_SUPPORT 0 #endif #if JED_HAS_UTF8_SUPPORT # define JED_MAX_MULTIBYTE_SIZE SLUTF8_MAX_MBLEN extern int Jed_UTF8_Mode; #else typedef unsigned long SLwchar_Type; typedef unsigned char SLuchar_Type; # define JED_MAX_MULTIBYTE_SIZE 6 #endif typedef struct _Buffer Buffer; #include "jdmacros.h" #include "keymap.h" #include "undo.h" #include "blocal.h" #if JED_HAS_MENUS # include "menu.h" #endif /* #define sprintf simple_sprintf extern char *simple_sprintf(char *, char *, ...); */ typedef struct Line { struct Line *next; /* pointer to next line */ struct Line *prev; /* pointer to prev line */ unsigned char *data; /* data for the line */ int len; /* actual length of line */ #ifdef KEEP_SPACE_INFO int space; /* space allocated for line */ #endif #if JED_HAS_LINE_ATTRIBUTES /* The first n bits of the flags field represent an n bit integer that * is used by the syntax parsing routines. The next m bits * control the various flags. The last 8 bits specify the * color of the line. * * Finally, assuming at least 32 bit integers, the last 16 bits may be * used for the syntax state of the line. For instance, if the line is in * a string, the string character may be specified by the some of the bits, * which is useful if there are more than one. */ unsigned int flags; #endif #define JED_LINE_IN_COMMENT 0x0001 #define JED_LINE_IN_STRING0 0x0002 #define JED_LINE_IN_STRING1 0x0004 #define JED_LINE_IN_HTML 0x0008 #define JED_LINE_HAS_EOL_COMMENT 0x0010 #define JED_LINE_SYNTAX_BITS 0x001F #define JED_LINE_HIDDEN 0x0020 #define JED_LINE_IS_READONLY 0x0040 #define JED_LINE_FLAG_BITS 0x0060 #define JED_LINE_COLOR_BITS 0xFF00 #define JED_GET_LINE_COLOR(line) ((line->flags & JED_LINE_COLOR_BITS) >> 8) #define JED_SET_LINE_COLOR(line,color) \ (line)->flags &= ~JED_LINE_COLOR_BITS; \ (line)->flags |= (((color) << 8) & JED_LINE_COLOR_BITS) } Line; #define LINE_HAS_NEWLINE(l) \ ((l)->len && ((l)->data[(l)->len - 1] == '\n')) /* This is the price we pay for a linked list approach. With straight buffer gap, this would be an integer. Sigh. */ typedef struct Mark { Line *line; /* line that marker points at */ int point; /* offset from beginning */ unsigned int n; /* line number in buffer */ struct Mark *next; unsigned int flags; /* visible mark if non-zero */ #define MARK_COLOR_MASK 0x00FF #define MARK_INVALID 0x0100 #define VISIBLE_MARK 0x0200 #define VISIBLE_COLUMN_MARK 0x0400 #define NARROW_REGION_MARK 0x0800 #define JED_LINE_MARK 0x1000 #define VISIBLE_MARK_MASK (VISIBLE_MARK|VISIBLE_COLUMN_MARK) } Mark; #define JED_MAX_MARK_ARRAY_SIZE 5 typedef struct Jed_Mark_Array_Type { struct Jed_Mark_Array_Type *next; unsigned int num_marks; Mark marks[JED_MAX_MARK_ARRAY_SIZE]; } Jed_Mark_Array_Type; extern unsigned int LineNum; /* current line number */ extern unsigned int Max_LineNum; /* max line number */ typedef struct Narrow_Type { struct Narrow_Type *next; unsigned int nup, ndown; /* (relative) lines above this narrow */ Line *beg, *end; /* pointers to lines to linkup with */ Line *beg1, *end1; /* beg and end before narrow */ int is_region; } Narrow_Type; #if JED_HAS_SAVE_NARROW typedef struct _Jed_Save_Narrow_Type { Mark *beg, *end; struct _Jed_Save_Narrow_Type *next; } Jed_Save_Narrow_Type; #endif /* These are buffer local variables that slang can access */ typedef struct { int tab; /* tab width */ int case_search; int is_utf8; int wrap_column; } Buffer_Local_Type; extern Buffer_Local_Type Buffer_Local; typedef struct { SLang_Name_Type *mark_paragraph_hook; SLang_Name_Type *format_paragraph_hook; SLang_Name_Type *forward_paragraph_hook; SLang_Name_Type *backward_paragraph_hook; SLang_Name_Type *par_sep; /* paragraph sep function */ SLang_Name_Type *indent_hook; SLang_Name_Type *newline_indent_hook; SLang_Name_Type *wrap_hook; SLang_Name_Type *wrapok_hook; SLang_Name_Type *bob_eob_error_hook; #ifdef HAS_MOUSE SLang_Name_Type *mouse_down_hook; SLang_Name_Type *mouse_up_hook; SLang_Name_Type *mouse_drag_hook; # if JED_HAS_MULTICLICK SLang_Name_Type *mouse_2click_hook; SLang_Name_Type *mouse_3click_hook; # endif #endif SLang_Name_Type *update_hook; SLang_Name_Type *color_region_hook; } Jed_Buffer_Hook_Type; struct _Buffer { Line *beg; /* Top line of buffer */ Line *end; /* Bottom line */ Line *line; /* current line */ int point; /* current offset */ unsigned int linenum; /* current line number */ unsigned int max_linenum; /* lines in buffer */ char *name; /* name of this buffer (slstring) */ char *file; /* filename sans dir (slstring) */ char *dir; /* directory of file (slstring) */ char *dirfile; /* dir+file sans link expansion */ char *canonical_dirfile; /* canonical filename with expanded links */ #ifdef REAL_UNIX_SYSTEM int device; /* inode and device of canonical_dirfile */ int inode; #endif int umask; unsigned int flags; /* flags (autosave, etc...) */ Narrow_Type *narrow; /* info for use by widen */ unsigned int nup; /* lines above narrow (absolute) */ unsigned int ndown; /* lines below narrow */ Mark *marks; Mark *spots; Mark *user_marks; unsigned int modes; /* c-mode, wrap, etc... */ SLKeyMap_List_Type *keymap; /* keymap attached to this buffer */ struct _Buffer *next; /* */ struct _Buffer *prev; char *mode_string; /* (slstring) */ int hits; /* number of hits on buffer since * last autosave. A hit is the number * of times the buffer was hit on at top level */ /* 0 or time when buffer first associated with a file */ unsigned long c_time; Undo_Type *undo; /* pointer to undo ring */ Buffer_Local_Type local_vars; #define SPOT_ARRAY_SIZE 4 Jed_Mark_Array_Type *spot_array; Jed_Mark_Array_Type *mark_array; int vis_marks; /* number of visible marks */ char status_line[80]; Jed_Buffer_Hook_Type *buffer_hooks; #if JED_HAS_COLOR_COLUMNS unsigned int coloring_style; unsigned char *column_colors; unsigned int num_column_colors; #endif #if JED_HAS_ABBREVS struct Abbrev_Table_Type *abbrev_table; #endif struct Syntax_Table_Type *syntax_table; #if JED_HAS_SUBPROCESSES int subprocess; /* 1 + subprocess id */ int locked; #endif #if JED_HAS_SAVE_NARROW Jed_Save_Narrow_Type *save_narrow; #endif #if JED_HAS_BUFFER_LOCAL_VARS Jed_BLocal_Table_Type *blocal_table; #endif #if JED_HAS_LINE_ATTRIBUTES unsigned int max_unparsed_line_num; unsigned int min_unparsed_line_num; #endif #if JED_HAS_MENUS Menu_Bar_Type *menubar; #endif #if JED_HAS_DISPLAY_LINE_NUMBERS int line_num_display_size; #endif }; extern char Default_Status_Line[80]; /* flags */ #define BUFFER_MODIFIED 0x0001 /* This flag cannot be used with the AUTO_SAVE_JUST_SAVE flag */ #define AUTO_SAVE_BUFFER 0x0002 /* these two flags are to tell user that the buffer and the file on disk have been modified--- see update_marks and main editor loop */ #define FILE_MODIFIED 0x0004 #define READ_ONLY 0x0008 #define OVERWRITE_MODE 0x0010 #define UNDO_ENABLED 0x0020 /* skip this buffer if looking for a pop up one. */ #define BURIED_BUFFER 0x0040 /* Instead of autosaving saving the buffer, just save it. This flag * is only used when SIGHUP or something like that hits. It is also * used when exiting the editor. It will cause the buffer to be silently * saved. It is possible that I need another flag for this. */ #define AUTO_SAVE_JUST_SAVE 0x0080 #define NO_BACKUP_FLAG 0x0100 #define BINARY_FILE 0x0200 #define ADD_CR_ON_WRITE_FLAG 0x0400 #define ABBREV_MODE 0x0800 #define SMG_EMBEDDED_ESCAPE 0x1000 #define BUFFER_NON_LOCKING 0x8000 #ifndef VMS # define MAP_CR_TO_NL_FLAG 0x10000 #endif extern char *Read_Only_Error; extern char *Line_Read_Only_Error; #if JED_HAS_LINE_ATTRIBUTES #define CHECK_READ_ONLY\ if (CBuf->flags & READ_ONLY) { msg_error(Read_Only_Error); return(1);}\ if (CLine->flags & JED_LINE_IS_READONLY) {msg_error(Line_Read_Only_Error); return 1;} #else #define CHECK_READ_ONLY\ if (CBuf->flags & READ_ONLY) { msg_error(Read_Only_Error); return(1);} #endif #if JED_HAS_LINE_ATTRIBUTES #define CHECK_READ_ONLY_VOID\ if (CBuf->flags & READ_ONLY) { msg_error(Read_Only_Error); return;}\ if (CLine->flags & JED_LINE_IS_READONLY) {msg_error(Line_Read_Only_Error); return;} #else #define CHECK_READ_ONLY_VOID\ if (CBuf->flags & READ_ONLY) { msg_error(Read_Only_Error); return;} #endif #define NO_MODE 0x00 #define WRAP_MODE 0x01 extern Buffer *CBuf; extern Line *CLine; extern void jed_set_point (int point); extern void jed_position_point (unsigned char *); extern unsigned char *jed_eol_position (Line *); extern unsigned char * jed_multibyte_chars_forward (unsigned char *p, unsigned char *pmax, unsigned int n, unsigned int *dn, int skip_combining); extern unsigned char * jed_multibyte_chars_backward (unsigned char *pmin, unsigned char *p, unsigned int n, unsigned int *dn, int skip_combining); /* This is roughly equivalent to (UPPERCASE(*a++) - UPPERCASE(*b++)) */ extern int jed_multibyte_charcasecmp (unsigned char **ap, unsigned char *amax, unsigned char **bp, unsigned char *bmax); /* Wide char equiv of *buf++ = c; */ unsigned char *jed_wchar_to_multibyte (SLwchar_Type c, unsigned char *buf); extern int jed_what_char (SLwchar_Type *); extern void jed_count_chars (void); extern int bob(void); extern int eob(void); /* point to end of buffer */ extern int bol(void); extern int eol(void); extern int bobp(void); extern int eobp(void); extern int eolp(void); extern int bolp(void); extern unsigned int jed_up (unsigned int); extern unsigned int jed_down (unsigned int); extern unsigned int jed_right (unsigned int); extern unsigned int jed_left (unsigned int); extern unsigned int jed_right_bytes (unsigned int); extern void goto_line(int *); extern Line *make_line1(unsigned int); extern unsigned char *make_line(unsigned int); extern unsigned char *remake_line(unsigned int); extern Buffer *make_buffer(char *, char *, char *); extern void uniquely_name_buffer(Buffer *, SLFUTURE_CONST char *); extern void buffer_filename(Buffer *, SLFUTURE_CONST char *, SLFUTURE_CONST char *); extern Buffer *find_file_buffer(char *); extern Buffer *find_buffer(char *); extern int delete_line(void); extern void delete_buffer(Buffer *); extern int switch_to_buffer(Buffer *); extern int get_percent(void); extern int what_line(void); extern int erase_buffer(void); extern void mark_buffer_modified (Buffer *, int, int); extern Line *dup_line(Line *); extern void free_line(Line *); extern void check_buffers(void); extern int buffer_exists(Buffer *); extern int Point; extern int Number_Zero; extern int Number_One; extern int Number_Two; extern int Number_Ten; extern void mark_undo_boundary(Buffer *); extern void delete_undo_ring(Buffer *); extern int Batch; /* JED used in batch mode. */ extern void touch_screen(void); extern void check_line(void); extern int jed_set_buffer_hook (Buffer *, char *, SLang_Name_Type *); extern int jed_unset_buffer_hook (Buffer *, char *); extern SLang_Name_Type *jed_get_buffer_hook (Buffer *, char *); extern void jed_set_buffer_flags (Buffer *, unsigned int); extern Buffer *MiniBuffer; #endif jed-0.99-19/src/lock.c0000644002657400265740000002377511311317447013373 0ustar davisdavis/* -*- mode: C; mode: fold; -*- */ /* Copyright (c) 1999, 2000, 2002, 2003, 2004, 2005, 2006 John E. Davis * This file is part of JED editor library source. * * You may distribute this file under the terms the GNU General Public * License. See the file COPYING for more information. */ #include "config.h" #include "jed-feat.h" /*{{{ Include Files */ #include #include #ifdef HAVE_STDLIB_H # include #endif #ifdef HAVE_UNISTD_H # include #endif #include #include #include #include #include #include "jdmacros.h" #include "buffer.h" #include "file.h" #include "userinfo.h" #include "ledit.h" #include "misc.h" /*}}}*/ #if JED_HAS_EMACS_LOCKING && !defined(HAVE_SYMLINK) # undef JED_HAS_EMACS_LOCKING # define JED_HAS_EMACS_LOCKING 0 #endif #if !JED_HAS_EMACS_LOCKING /*{{{*/ int jed_lock_buffer_file (Buffer *b) { (void) b; return 0; } int jed_unlock_buffer_file (Buffer *b) { (void) b; return 0; } int jed_lock_file (char *file) { (void) file; return 0; } int jed_unlock_file (char *file) { (void) file; return 0; } /*}}}*/ #else /* Rest of file */ /* The basic idea here is quite simple. Whenever a buffer is attached to * a file, and that buffer is modified, then attempt to lock the * file. Moreover, before writing to a file for any reason, lock the * file. The lock is really a protocol respected and not a real lock. * The protocol is this: If in the directory of the file is a * symbolic link with name ".#FILE", the FILE is considered to be locked * by the process specified by the link. * * Here are the scenerios requiring a lock: * * 1. When a buffer attached to a file becomes modified. * 2. When appending or writing to a file. * * Suppose that a buffer has not been modified but one appends a * region of the buffer to some file. Then while that file is being * written, it should be locked and then released when finished. * However, suppose another buffer has that file locked. Then in * order to write to it, either the lock must be stolen or ignored. * In either of these cases, the user is responsible to what happens * to the text in the other buffer. In fact, if the user elects to * steal the lock from the other buffer, then that lock will be * deleted after the file has been modfied. Of course these same comments * apply if another process owns the lock. * * Now consider the case when a buffer is modified and has the file locked. * When the buffer is saved, the file will already be locked and there is no * need to lock it again. */ typedef struct { char *host; char *user; int pid; } Lock_Info_Type; static char *make_lockfile_name (char *file) { unsigned int len; char *buf, *dir, *name; file = jed_expand_link (file); if (file == NULL) return NULL; if (-1 == jed_dirfile_to_dir_file (file, &dir, &name)) { SLfree (file); return NULL; } SLfree (file); len = strlen (dir) + strlen (name) + 3; if (NULL != (buf = SLmalloc (len))) sprintf (buf, "%s.#%s", dir, name); SLfree (dir); SLfree (name); return buf; } static void free_lock_info (Lock_Info_Type *l) { SLang_free_slstring (l->host); SLang_free_slstring (l->user); } static int create_lock_info (Lock_Info_Type *l) { char *host, *user; memset ((char *) l, 0, sizeof (Lock_Info_Type)); if (NULL == (host = jed_get_hostname ())) return -1; if (NULL == (user = jed_get_username ())) { SLang_free_slstring (host); return -1; } l->host = host; l->user = user; l->pid = getpid (); return 0; } /* * If 0 is returned, then proceed with no lock. If 1, then force * the lock, if -1 then abort with no lock. */ static int ask_about_lock (char *file, Lock_Info_Type *l) { char *buf; unsigned int len; if (Batch) { jed_verror ("%s is locked by %s@%s.d.", file, l->user, l->host, l->pid); return -1; } len = 64 + strlen (file) + strlen (l->host) + strlen (l->user); if (NULL == (buf = SLmalloc (len))) return -1; sprintf (buf, "%s is locked by %s@%s.%d. (S)teal, (P)roceed, (A)bort?", file, l->user, l->host, l->pid); while (1) { switch (jed_get_mini_response (buf)) { case 's': case 'S': SLfree (buf); return 1; case 'P': case 'p': case 'q': case 'Q': SLfree (buf); return 0; case 'A': case 'a': SLfree (buf); jed_verror ("%s is locked by another process", file); return -1; } if (SLang_get_error ()) { SLfree (buf); return -1; } jed_beep (); } } /* Returns 0 if file does not exist, or 1 with info, or -1 for error */ static int get_lock_info (char *lockfile, Lock_Info_Type *l) { struct stat st; char buf[1024]; char *b; char *user, *host; int n; memset ((char *) l, 0, sizeof (Lock_Info_Type)); if (-1 == lstat (lockfile, &st)) { if (errno == ENOENT) return 0; return -1; } if (((st.st_mode & S_IFMT) & S_IFLNK) == 0) return -1; n = readlink (lockfile, buf, sizeof (buf)-1); if ((n == -1) || (n >= (int)sizeof(buf)-1)) return -1; buf[n] = 0; /* The format is: username@host.pid:boot_time */ b = strchr (buf, '@'); if (b == NULL) return -1; *b++ = 0; user = SLang_create_slstring (buf); if (user == NULL) return -1; host = b; b += strlen (b); while (b > host) { b--; if (*b == '.') break; } if (b == host) { SLang_free_slstring (user); return -1; } *b++ = 0; if (NULL == (host = SLang_create_slstring (host))) { SLang_free_slstring (user); return -1; } l->pid = atoi (b); l->host = host; l->user = user; return 1; } /* Returns 1 upon success, 0 if lock exists, or -1 upon failure. If force * is non-zero, then this function will not return 0. */ static int perform_lock (char *lockfile, Lock_Info_Type *l, int force) { unsigned int len; char *buf; int status; int not_supported = 0; len = 32 + strlen (l->host) + strlen (l->user); if (NULL == (buf = SLmalloc (len))) return -1; sprintf (buf, "%s@%s.%d", l->user, l->host, l->pid); if (0 == symlink (buf, lockfile)) { SLfree (buf); return 1; } if (not_supported # ifdef EPERM || (errno == EPERM) # endif # ifdef EOPNOTSUPP || (errno == EOPNOTSUPP) # endif # ifdef ENOSYS || (errno == ENOSYS) # endif ) { jed_vmessage (0, "File system does not support symbolic links: file not locked."); SLfree (buf); return 1; } # ifdef EACCES if (errno == EACCES) { jed_vmessage (0, "No permission to lock file"); SLfree (buf); return 1; } #endif if (force == 0) { SLfree (buf); if (errno == EEXIST) return 0; return -1; } (void) unlink (lockfile); status = symlink (buf, lockfile); if (status == -1) jed_vmessage (0, "Unable to create lockfile %s", lockfile); else status = 1; SLfree (buf); return status; } /* Return 0 if same, -1 if same host, 1 if different host */ static int compare_lock_info (Lock_Info_Type *a, Lock_Info_Type *b) { if (a->host != b->host) return 1; if ((a->pid != b->pid) || (a->user != b->user)) return -1; return 0; } int jed_lock_file (char *file) { char *lockfile; Lock_Info_Type l0; int force; int status; lockfile = make_lockfile_name (file); if (lockfile == NULL) return -1; if (-1 == create_lock_info (&l0)) { SLfree (lockfile); return -1; } force = 0; while (1) { Lock_Info_Type l1; status = perform_lock (lockfile, &l0, force); if (status == 1) /* lock succeeded */ break; if (status == -1) /* error */ break; /* Lock already exists. Let's see who owns it */ status = get_lock_info (lockfile, &l1); if (status == -1) break; if (status == 0) /* lock nolonger exists, try again */ continue; status = compare_lock_info (&l0, &l1); if (status == 0) { /* We already own this lock */ free_lock_info (&l1); status = 1; break; } if (status == -1) { /* Some process on this machine owns it. See if the process is * alive. */ if (l1.pid <= 0) status = 2; else if (-1 == kill (l1.pid, 0)) { # ifdef ESRCH if (errno == ESRCH) /* Doesn't exist */ status = 2; # endif } } if (status != 2) status = ask_about_lock (file, &l1); free_lock_info (&l1); if (status <= 0) break; force = 1; } SLfree (lockfile); free_lock_info (&l0); if (status == -1) return -1; return 0; } int jed_unlock_file (char *file) { Lock_Info_Type l0, l1; char *lockfile; int status; lockfile = make_lockfile_name (file); if (lockfile == NULL) return -1; if (-1 == create_lock_info (&l0)) { SLfree (lockfile); return -1; } status = get_lock_info (lockfile, &l1); if (status <= 0) { free_lock_info (&l0); SLfree (lockfile); return status; } if (0 == compare_lock_info (&l0, &l1)) (void) unlink (lockfile); free_lock_info (&l0); free_lock_info (&l1); SLfree (lockfile); return 0; } int jed_lock_buffer_file (Buffer *b) { int status; char *file; if ((b->file[0] == 0) || (b->flags & BUFFER_NON_LOCKING)) return 0; file = jed_dir_file_merge (b->dir, b->file); status = jed_lock_file (file); SLfree (file); return status; } int jed_unlock_buffer_file (Buffer *b) { int status; char *file; if ((b->file[0] == 0) || (b->flags & BUFFER_NON_LOCKING)) return 0; file = jed_dir_file_merge (b->dir, b->file); status = jed_unlock_file (file); SLfree (file); return status; } int jed_unlock_buffer_files (void) { int status; Buffer *b; status = 0; b = CBuf; do { b = b->next; if (-1 == jed_unlock_buffer_file (b)) status = -1; } while (b != CBuf); return status; } #endif /* JED_HAS_EMACS_LOCKING */ jed-0.99-19/src/vfile.h0000644002657400265740000000176111311317447013544 0ustar davisdavis#ifndef _DAVIS_VFILE_H_ #define _DAVIS_VFILE_H_ /* Copyright (c) 1992, 1998, 2000, 2005, 2006 John E. Davis * This file is part of JED editor library source. * * You may distribute this file under the terms the GNU General Public * License. See the file COPYING for more information. */ #define VFILE_TEXT 1 #define VFILE_BINARY 2 extern unsigned int VFile_Mode; typedef struct { char *buf; /* buffer for stream */ char *bmax; /* pointer to end buffer */ char *bp; /* current pointer in stream */ char *eof; /* pointer to EOF if non NULL */ int fd; /* file descrip for stream */ unsigned int size; /* default buffer size */ unsigned int mode; unsigned int cr_flag; /* true if lines end in cr */ } VFILE; extern char *vgets(VFILE *, unsigned int *); extern VFILE *vopen(SLFUTURE_CONST char *, unsigned int, unsigned int); extern void vclose(VFILE *); extern VFILE *vstream(int, unsigned int, unsigned int); #endif jed-0.99-19/src/jedconf.h0000644002657400265740000000573111311317447014050 0ustar davisdavis#ifndef _JED_CONFIG_H_ #define _JED_CONFIG_H_ /* Copyright (c) 1992, 1998, 2000, 2005, 2006 John E. Davis * This file is part of JED editor library source. * * You may distribute this file under the terms the GNU General Public * License. See the file COPYING for more information. */ /* This file handles all non-Unix Operating systems */ #ifdef __VMS #include "vms_x_fix.h" #endif #if defined(__WATCOMC__) && defined(__DOS__) # define DOS386 1 #endif /* Set of the various defines for pc systems. This includes OS/2 */ #ifdef __GO32__ # ifndef __DJGPP__ # define __DJGPP__ 1 # endif #endif #if defined(__MSDOS__) || defined(__DOS__) || defined(__WIN16__) # ifndef __MSDOS__ # define __MSDOS__ # endif #endif #if defined(OS2) # ifndef __os2__ # define __os2__ 1 # endif #endif #if defined(CYGWIN32) && !defined(__CYGWIN32__) # define __CYGWIN32__ #endif #if defined(MINGW32) && !defined(__MINGW32__) # define __MINGW32__ 1 #endif #if defined(WIN32) || defined(__CYGWIN32__) || defined(__MINGW32__) # ifndef __WIN32__ # define __WIN32__ 1 # endif #endif #if defined(__WIN32__) || defined(__WIN16__) # if !defined(MSWINDOWS) # define MSWINDOWS 1 # endif #endif #ifndef VMS # ifndef IBMPC_SYSTEM # define IBMPC_SYSTEM 1 # endif #endif #if defined(__MSDOS__) && !defined(__GO32__) && !defined(DOS386) && !defined(__WIN32__) # ifndef __MSDOS_16BIT__ # define __MSDOS_16BIT__ 1 # endif # if defined(__BORLANDC__) && !defined(IBMPC_USE_ASM) # define IBMPC_USE_ASM # endif #endif #if defined(__os2_16__) || defined(__MSDOS_16BIT__) # define SIXTEEN_BIT_SYSTEM #endif #ifdef IBMPC_SYSTEM # define HAVE_STDLIB_H # define HAVE_PUTENV # if defined(__GO32__) || defined(__CYGWIN32__) # define HAVE_UNISTD_H # endif #endif #if !defined(VMS) && !defined(__WATCOMC__) # define HAVE_MEMORY_H #endif #if defined(__WIN32__) && defined(__BORLANDC__) # define HAVE_UTIME 1 #endif #define HAVE_GETCWD #if defined(_MSC_VER) || defined(__EMX__) || defined(__WATCOMC__) # define strcmpi stricmp # define strncmpi strnicmp #endif #define HAVE_MEMCPY #define HAVE_MEMSET #ifndef VMS # define HAVE_MEMCMP # define HAVE_MEMCHR #endif /* OS/2 probably has gethostname */ #undef HAVE_GETHOSTNAME #if !defined(__WATCOMC__) || defined(OS2) # define HAS_MOUSE 1 #endif #if defined(__DECC) # define HAVE_STDLIB_H # define HAVE_UNISTD_H #else # ifdef VMS # if __VMS_VER >= 60200000 # define HAVE_UNISTD_H # endif # endif #endif /* Define this if compiler has limits.h */ #define HAVE_LIMITS_H /* Set this to 1 if the filesystem is case-sensitive */ #define JED_FILE_PRESERVE_CASE 0 /* Define if you have the vsnprintf, snprintf functions and they return * EOF upon failure. */ #undef HAVE_VSNPRINTF #undef HAVE_SNPRINTF /* #define mode_t int */ /* #define pid_t int */ typedef int uid_t; typedef int gid_t; #ifdef _MSC_VER # define HAVE_DLOPEN 1 #endif /* Finally, a reality check... */ #ifdef REAL_UNIX_SYSTEM # undef REAL_UNIX_SYSTEM #endif #ifndef JED # define JED #endif #endif /* _JED_CONFIG_H_ */ jed-0.99-19/src/keymap.c0000644002657400265740000011111411311317447013712 0ustar davisdavis/* -*- mode: C; mode: fold; -*- */ /* Copyright (c) 1992, 1998, 2000, 2002, 2003, 2004, 2005, 2006 John E. Davis * This file is part of JED editor library source. * * You may distribute this file under the terms the GNU General Public * License. See the file COPYING for more information. */ #include "config.h" #include "jed-feat.h" /*{{{ Include Files */ #include #include #include "jdmacros.h" #include #include #include "buffer.h" #include "cmds.h" #include "paste.h" #include "screen.h" #include "window.h" #include "text.h" #include "ledit.h" #include "keymap.h" #include "sysdep.h" #include "misc.h" #include "display.h" #include "file.h" #include "undo.h" #include "ins.h" #include "hooks.h" #include "replace.h" #include "indent.h" #if JED_HAS_MENUS # include "menu.h" #endif #ifdef IBMPC_SYSTEM # include "doskeys.h" #endif /*}}}*/ #if (SLANG_VERSION < 20003) && defined(SLKEY_F_SLANG) # undef SLKEY_F_SLANG #endif void (*X_Define_Keys_Hook)(SLKeyMap_List_Type *); int (*X_Set_Abort_Char_Hook) (unsigned char); unsigned char Jed_Abort_Char = 7; /* ^G */ typedef struct /*{{{*/ { jmp_buf b; } /*}}}*/ jmp_buf_struct; jmp_buf_struct Jump_Buffer, *Jump_Buffer_Ptr; FVOID_STAR Last_Key_Function; FVOID_STAR Jed_This_Key_Function; int *Repeat_Factor; /* repeats a key sequence if non null */ char *Read_This_Character = NULL; /* alternate keyboard buffer */ char Jed_Key_Buffer[SLANG_MAX_KEYMAP_KEY_SEQ + 1]; char Key_Buffer[SLANG_MAX_KEYMAP_KEY_SEQ + 1]; char *Key_Bufferp = Key_Buffer; static int Last_Key_Buffer_Len; int Jed_Max_Hits = 300; int jed_beep (void) /*{{{*/ { tt_beep (); flush_output (); return 1; } /*}}}*/ static int redraw (void) { jed_redraw_screen (0); return 0; } #if HAS_MOUSE #ifndef IBMPC_SYSTEM static int xterm_mouse_cmd (void) { int b, id; static int last_down = JMOUSE_BUTTON_1; JMouse_Type m; b = my_getkey (); m.x = (unsigned char) my_getkey () - 32; m.y = (unsigned char) my_getkey () - 32; b -= 32; if ((b & 3) == 3) { m.type = JMOUSE_UP; m.button = last_down; m.state = last_down; } else { m.type = JMOUSE_DOWN; if ((b & 3) == 0) m.button = JMOUSE_BUTTON_1; else if (b & 1) m.button = JMOUSE_BUTTON_2; else if (b & 2) m.button = JMOUSE_BUTTON_3; m.state = 0; } last_down = m.button; if (-1 == (id = jed_mouse_add_event (&m))) return -1; ungetkey (&id); jed_mouse_cmd (); return 1; } #endif #endif /* HAS_MOUSE */ SLKeymap_Function_Type Jed_Functions[] = /*{{{*/ { /* Put common cases here to speedup lookup */ {"self_insert_cmd", ins_char_cmd}, {"next_char_cmd", next_char_cmd}, {"next_line_cmd", next_line_cmd}, {"previous_char_cmd", previous_char_cmd}, {"previous_line_cmd", previous_line_cmd}, {"delete_char_cmd", delete_char_cmd}, {"beg_of_line", bol}, {"eol_cmd", eol_cmd}, {"beg_of_buffer", bob}, {"end_of_buffer", eob}, {"newline_and_indent", newline_and_indent}, {"newline", newline_cmd}, {"page_down", pagedown_cmd}, {"page_up", pageup_cmd}, {"backward_delete_char", backward_delete_char_cmd}, {"backward_delete_char_untabify", backward_delete_char_untabify}, {"beep", jed_beep}, {"begin_macro", begin_keyboard_macro}, {"center_line", center_line}, {"copy_region", copy_to_pastebuffer}, #if (defined(__MSDOS__) && !defined(__WIN32__)) || (defined(__QNX__) && defined(__WATCOMC__)) {"coreleft", show_memory}, #endif {"delete_window", delete_window}, {"digit_arg", digit_arg}, /* {"double_line", double_line}, */ {"end_macro", end_keyboard_macro}, {"enlarge_window", enlarge_window}, {"evaluate_cmd", evaluate_cmd}, {"execute_macro", execute_keyboard_macro}, {"exchange",exchange_point_mark}, {"exit_jed", jed_exit_jed_cmd}, {"exit_mini", exit_minibuffer}, {"find_file", find_file}, {"format_paragraph", text_format_paragraph}, {"goto_match", goto_match}, {"indent_line", indent_line}, {"insert_file", insert_file_cmd}, #ifdef HAS_MOUSE {"mouse_cmd", jed_mouse_cmd}, #endif {"kbd_quit", kbd_quit}, {"kill_buffer", kill_buffer}, {"kill_line", kill_line}, {"kill_region", kill_region}, {"macro_query", macro_query}, {"mark_spot", mark_spot}, {"mini_complete", mini_complete}, {"narrow", narrow_to_lines}, {"narrow_paragraph", narrow_paragraph}, {"narrow_to_region", narrow_to_region}, {"one_window", one_window}, {"other_window", other_window}, {"pop_spot", pop_spot}, {"quoted_insert", quoted_insert}, {"redraw", redraw}, /* {"replace", replace}, */ {"save_some_buffers", save_some_buffers}, {"scroll_left", jed_scroll_left_cmd}, {"scroll_right", jed_scroll_right_cmd}, /* {"search_backward", search_backward_cmd}, {"search_forward", search_forward_cmd}, */ {"set_mark_cmd", set_mark_cmd}, {"split_window", split_window}, {"switch_to_buffer", get_buffer}, {"sys_spawn_cmd", sys_spawn_cmd}, {"text_smart_quote", text_smart_quote}, /* {"transpose_lines", transpose_lines}, */ {"trim_whitespace", jed_trim_whitespace}, {"undo", undo}, {"widen", widen}, {"widen_region", widen_region}, {"write_buffer", jed_save_buffer_as_cmd}, {"yank", yank}, #if JED_HAS_MENUS {"select_menubar", jed_select_menu_bar}, #endif {(char *) NULL, NULL} }; /*}}}*/ SLKeyMap_List_Type *Global_Map; int kbd_quit(void) /*{{{*/ { int sle = SLang_get_error (); SLKeyBoard_Quit = 1; #if JED_HAS_MENUS if (Jed_Menus_Active) jed_exit_menu_bar (); #endif SLang_set_error (SL_USER_BREAK); msg_error("Quit!"); if (Ignore_User_Abort) SLang_set_error (sle); #ifdef UNDO_HAS_REDO set_current_undo (); #endif return(1); } /*}}}*/ void init_keymaps(void) /*{{{*/ { int ch; char simple[2]; simple[1] = 0; if (NULL == (Global_Map = SLang_create_keymap ("global", NULL))) exit_error ("Malloc error creating keymap.", 0); Global_Map->functions = Jed_Functions; /* This breaks under some DEC ALPHA compilers (scary!) */ #ifndef __DECC for (ch = ' '; ch < 256; ch++) { simple[0] = (char) ch; SLkm_define_key (simple, (FVOID_STAR) ins_char_cmd, Global_Map); } #else ch = ' '; while (1) { simple[0] = (char) ch; SLkm_define_key (simple, (FVOID_STAR) ins_char_cmd, Global_Map); ch = ch + 1; if (ch == 256) break; } #endif SLkm_define_key ("^[1", (FVOID_STAR) digit_arg, Global_Map); SLkm_define_key ("^[2", (FVOID_STAR) digit_arg, Global_Map); SLkm_define_key ("^[3", (FVOID_STAR) digit_arg, Global_Map); SLkm_define_key ("^[4", (FVOID_STAR) digit_arg, Global_Map); SLkm_define_key ("^[5", (FVOID_STAR) digit_arg, Global_Map); SLkm_define_key ("^[6", (FVOID_STAR) digit_arg, Global_Map); SLkm_define_key ("^[7", (FVOID_STAR) digit_arg, Global_Map); SLkm_define_key ("^[8", (FVOID_STAR) digit_arg, Global_Map); SLkm_define_key ("^[9", (FVOID_STAR) digit_arg, Global_Map); SLkm_define_key ("^[0", (FVOID_STAR) digit_arg, Global_Map); #ifdef IBMPC_SYSTEM SLkm_define_key (PC_DEL, (FVOID_STAR) delete_char_cmd, Global_Map); SLkm_define_key (PC_DEL1, (FVOID_STAR) delete_char_cmd, Global_Map); SLkm_define_key (PC_NULL, (FVOID_STAR) set_mark_cmd, Global_Map); SLkm_define_key (PC_LT, (FVOID_STAR) previous_char_cmd, Global_Map); SLkm_define_key (PC_LT1, (FVOID_STAR) previous_char_cmd, Global_Map); SLkm_define_key (PC_UP, (FVOID_STAR) previous_line_cmd, Global_Map); SLkm_define_key (PC_UP1, (FVOID_STAR) previous_line_cmd, Global_Map); SLkm_define_key (PC_DN, (FVOID_STAR) next_line_cmd, Global_Map); SLkm_define_key (PC_DN1, (FVOID_STAR) next_line_cmd, Global_Map); SLkm_define_key (PC_RT, (FVOID_STAR) next_char_cmd, Global_Map); SLkm_define_key (PC_RT1, (FVOID_STAR) next_char_cmd, Global_Map); SLkm_define_key (PC_PGUP, (FVOID_STAR) pageup_cmd, Global_Map); SLkm_define_key (PC_PGUP1, (FVOID_STAR) pageup_cmd, Global_Map); SLkm_define_key (PC_PGDN, (FVOID_STAR) pagedown_cmd, Global_Map); SLkm_define_key (PC_PGDN1, (FVOID_STAR) pagedown_cmd, Global_Map); SLkm_define_key (PC_HOME, (FVOID_STAR) bol, Global_Map); SLkm_define_key (PC_HOME1, (FVOID_STAR) bol, Global_Map); SLkm_define_key (PC_END, (FVOID_STAR) eol_cmd, Global_Map); SLkm_define_key (PC_END1, (FVOID_STAR) eol_cmd, Global_Map); /* Now special keypad stuff */ SLkm_define_key (PC_ENTER, (FVOID_STAR) newline_cmd, Global_Map); /* wordperfect type stuff */ SLkm_define_key (PC_F1, (FVOID_STAR) kbd_quit, Global_Map); /* SLkm_define_key (PC_F2, (FVOID_STAR) search_forward_cmd, Global_Map); SLkm_define_key (PC_SHIFT_F2, (FVOID_STAR) search_backward_cmd, Global_Map); */ SLkm_define_key (PC_F4, (FVOID_STAR) indent_line, Global_Map); SLkm_define_key (PC_ALT_F5, (FVOID_STAR) set_mark_cmd, Global_Map); SLkm_define_key (PC_SHIFT_F4, (FVOID_STAR) narrow_paragraph, Global_Map); SLkm_define_key (PC_SHIFT_F6, (FVOID_STAR) center_line, Global_Map); SLkm_define_key (PC_F7, (FVOID_STAR) jed_exit_jed_cmd, Global_Map); #else /* give vtxxx arrow keys */ SLkm_define_key ("^[[D", (FVOID_STAR) previous_char_cmd, Global_Map); SLkm_define_key ("^[OD", (FVOID_STAR) previous_char_cmd, Global_Map); SLkm_define_key ("^[[A", (FVOID_STAR) previous_line_cmd, Global_Map); SLkm_define_key ("^[OA", (FVOID_STAR) previous_line_cmd, Global_Map); SLkm_define_key ("^[[B", (FVOID_STAR) next_line_cmd, Global_Map); SLkm_define_key ("^[OB", (FVOID_STAR) next_line_cmd, Global_Map); SLkm_define_key ("^[[C", (FVOID_STAR) next_char_cmd, Global_Map); SLkm_define_key ("^[OC", (FVOID_STAR) next_char_cmd, Global_Map); SLkm_define_key ("^[[6~", (FVOID_STAR) pagedown_cmd, Global_Map); SLkm_define_key ("^[[5~", (FVOID_STAR) pageup_cmd, Global_Map); SLkm_define_key ("^K^[[C", (FVOID_STAR) jed_scroll_left_cmd, Global_Map); SLkm_define_key ("^K^[[D", (FVOID_STAR) jed_scroll_right_cmd, Global_Map); SLkm_define_key ("^K^[[A", (FVOID_STAR) bob, Global_Map); SLkm_define_key ("^K^[[B", (FVOID_STAR)eob, Global_Map); #if HAS_MOUSE SLkm_define_key ("\033[M", (FVOID_STAR)xterm_mouse_cmd, Global_Map); #endif #ifdef sun SLkm_define_key ("\033[216z", (FVOID_STAR) pageup_cmd, Global_Map); SLkm_define_key ("\033[222z", (FVOID_STAR) pagedown_cmd, Global_Map); SLkm_define_key ("\033[214z", (FVOID_STAR) bol, Global_Map); SLkm_define_key ("\033[220z", (FVOID_STAR) eol_cmd, Global_Map); #endif #endif /* SLkm_define_key ("'", (FVOID_STAR) text_smart_quote, Global_Map); SLkm_define_key ("\"", (FVOID_STAR) text_smart_quote, Global_Map); */ SLkm_define_key ("^_", (FVOID_STAR) undo, Global_Map); SLkm_define_key ("^?", (FVOID_STAR) backward_delete_char_untabify, Global_Map); #ifndef IBMPC_SYSTEM SLkm_define_key ("^H", (FVOID_STAR) backward_delete_char_untabify, Global_Map); #endif SLkm_define_key ("^B", (FVOID_STAR) bol, Global_Map); SLkm_define_key ("^D", (FVOID_STAR) pagedown_cmd, Global_Map); SLkm_define_key ("^E", (FVOID_STAR) eol_cmd, Global_Map); /* SLkm_define_key ("^FB", (FVOID_STAR) search_backward_cmd, Global_Map); SLkm_define_key ("^FF", (FVOID_STAR) search_forward_cmd, Global_Map); */ SLkm_define_key ("^G", (FVOID_STAR) kbd_quit, Global_Map); SLkm_define_key ("^I", (FVOID_STAR) indent_line, Global_Map); SLkm_define_key ("^K(", (FVOID_STAR) begin_keyboard_macro, Global_Map); SLkm_define_key ("^K)", (FVOID_STAR) end_keyboard_macro, Global_Map); SLkm_define_key ("^KD", (FVOID_STAR) evaluate_cmd, Global_Map); SLkm_define_key ("^KE", (FVOID_STAR) jed_exit_jed_cmd, Global_Map); SLkm_define_key ("^KG", (FVOID_STAR) find_file, Global_Map); SLkm_define_key ("^KK", (FVOID_STAR) copy_to_pastebuffer, Global_Map); SLkm_define_key ("^KM", (FVOID_STAR) mark_spot, Global_Map); SLkm_define_key ("^KX", (FVOID_STAR) execute_keyboard_macro, Global_Map); SLkm_define_key ("^K^B", (FVOID_STAR) set_mark_cmd, Global_Map); SLkm_define_key ("^K^I", (FVOID_STAR) insert_file_cmd, Global_Map); /* SLang_define_key1("^K^L", (VOID_STAR) double_line, SLKEY_F_INTRINSIC, Global_Map); */ SLkm_define_key ("^K^M", (FVOID_STAR) pop_spot, Global_Map); SLkm_define_key ("^K^P", (FVOID_STAR) yank, Global_Map); /* SLang_define_key1("^K^R", (VOID_STAR) replace, SLKEY_F_INTRINSIC, Global_Map); */ SLkm_define_key ("^K^V", (FVOID_STAR) kill_region, Global_Map); SLkm_define_key ("^K^W", (FVOID_STAR) jed_save_buffer_as_cmd, Global_Map); SLkm_define_key ("^L", (FVOID_STAR) kill_line, Global_Map); SLkm_define_key ("^M", (FVOID_STAR) newline_and_indent, Global_Map); SLkm_define_key ("^R", (FVOID_STAR) redraw, Global_Map); SLkm_define_key ("^U", (FVOID_STAR) pageup_cmd, Global_Map); SLkm_define_key ("^V", (FVOID_STAR) delete_char_cmd, Global_Map); SLkm_define_key ("^W0", (FVOID_STAR) delete_window, Global_Map); SLkm_define_key ("^W1", (FVOID_STAR) one_window, Global_Map); SLkm_define_key ("^W2", (FVOID_STAR) split_window, Global_Map); SLkm_define_key ("^WO", (FVOID_STAR) other_window, Global_Map); SLkm_define_key ("^XB", (FVOID_STAR) get_buffer, Global_Map); SLkm_define_key ("^XK", (FVOID_STAR) kill_buffer, Global_Map); SLkm_define_key ("^XN", (FVOID_STAR) narrow_to_region, Global_Map); SLkm_define_key ("^XQ", (FVOID_STAR) macro_query, Global_Map); SLkm_define_key ("^XS", (FVOID_STAR) save_some_buffers, Global_Map); SLkm_define_key ("^XW", (FVOID_STAR) widen_region, Global_Map); SLkm_define_key ("^X^", (FVOID_STAR) enlarge_window, Global_Map); /* SLang_define_key1("^X^T", (VOID_STAR) transpose_lines, SLKEY_F_INTRINSIC, Global_Map); */ SLkm_define_key ("^X^[", (FVOID_STAR) evaluate_cmd, Global_Map); SLkm_define_key ("^X^X", (FVOID_STAR) exchange_point_mark, Global_Map); SLkm_define_key ("^Z", (FVOID_STAR) sys_spawn_cmd, Global_Map); SLkm_define_key ("^[<", (FVOID_STAR) bob, Global_Map); SLkm_define_key ("^[>", (FVOID_STAR) eob, Global_Map); SLkm_define_key ("^[N", (FVOID_STAR) narrow_paragraph, Global_Map); SLkm_define_key ("^[Q", (FVOID_STAR) text_format_paragraph, Global_Map); SLkm_define_key ("^[S", (FVOID_STAR) center_line, Global_Map); SLkm_define_key ("^[X", (FVOID_STAR) evaluate_cmd, Global_Map); SLkm_define_key ("^[\\", (FVOID_STAR) jed_trim_whitespace, Global_Map); SLkm_define_key ("^\\", (FVOID_STAR) goto_match, Global_Map); SLkm_define_key ("`", (FVOID_STAR) quoted_insert, Global_Map); if (X_Define_Keys_Hook != NULL) (*X_Define_Keys_Hook)(Global_Map); } /*}}}*/ char Last_Kbd_Command_String[32]; char Current_Kbd_Command_String[32]; void set_current_kbd_command (char *s) /*{{{*/ { strncpy (Current_Kbd_Command_String, s, 31); Current_Kbd_Command_String[31] = 0; } /*}}}*/ static void update_jed_keybuffer (void) /*{{{*/ { Last_Key_Buffer_Len = (int) (Key_Bufferp - Key_Buffer); if (Last_Key_Buffer_Len == 1) { *Jed_Key_Buffer = *Key_Buffer; *(Jed_Key_Buffer + 1) = 0; } else { *Key_Bufferp = 0; strcpy (Jed_Key_Buffer, Key_Buffer); } Key_Bufferp = Key_Buffer; } /*}}}*/ static int do_macro_string (char *str, int repeat) { static int macro_depth; char *rtc_save; int ret = 0; if (macro_depth > 10) { macro_depth = 0; msg_error ("Possible runaway macro aborted."); return -1; } macro_depth++; rtc_save = Read_This_Character; while (repeat > 0) { repeat--; Read_This_Character = str; while ((SLang_get_error () == 0) && (SLKeyBoard_Quit == 0) && (Read_This_Character != NULL)) jed_do_key(); if (Read_This_Character != NULL) { ret = -1; break; } } Read_This_Character = rtc_save; macro_depth--; return ret; } static int key_interpret (SLang_Key_Type *key) /*{{{*/ { char *str; int ret; strcpy (Last_Kbd_Command_String, Current_Kbd_Command_String); Jed_This_Key_Function = key->f.f; switch (key->type) { case SLKEY_F_INTRINSIC: set_current_kbd_command (Jed_Key_Buffer); ret = (key->f.f) (); break; case SLKEY_F_INTERPRET: str = key->f.s; set_current_kbd_command (str); if (*str == ' ') { /* string to insert */ (void) jed_insert_string(str + 1); } else if (*str == '@') { int repeat; if (Repeat_Factor != NULL) { repeat = *Repeat_Factor; Repeat_Factor = NULL; } else repeat = 1; (void) do_macro_string (str + 1, repeat); } else if ((*str == '.') || !SLang_execute_function(str)) SLang_load_string(str); ret = 1; break; #ifdef SLKEY_F_SLANG case SLKEY_F_SLANG: ret = SLexecute_function (key->f.slang_fun); break; #endif default: SLang_verror (SL_NOT_IMPLEMENTED, "Keymap key-type %d is not supported", (int)key->type); return -1; } Last_Key_Function = Jed_This_Key_Function; return(ret); } /*}}}*/ static char *find_function_string (FVOID_STAR f) /*{{{*/ { SLKeymap_Function_Type *fp; if (f == (FVOID_STAR) ins_char_cmd) return "self_insert_cmd"; fp = Jed_Functions; while ((fp != NULL) && (fp->name != NULL)) { if ((FVOID_STAR) fp->f == f) return (char *) fp->name; fp++; } return NULL; } /*}}}*/ static SLFUTURE_CONST char *lookup_key_function_string (SLang_Key_Type *key) { if (key == NULL) return NULL; switch (key->type) { case SLKEY_F_INTRINSIC: return find_function_string (key->f.f); case SLKEY_F_INTERPRET: return key->f.s; #ifdef SLKEY_F_SLANG case SLKEY_F_SLANG: return key->f.slang_fun->name; #endif default: return ""; } } static int do_key (void) /*{{{*/ { SLang_Key_Type *key; int repeat; if (SLang_Key_TimeOut_Flag == 0) { Key_Bufferp = Key_Buffer; *Key_Bufferp = 0; } #if JED_HAS_MENUS if (Jed_Menus_Active) { key = jed_menu_do_key (); update_jed_keybuffer (); } else #endif { key = SLang_do_key (CBuf->keymap, jed_getkey); update_jed_keybuffer (); if ((IN_MINI_WINDOW == 0) && (key != NULL) && jed_hook_exists ("_jed_before_key_hooks")) { (void) jed_va_run_hooks ("_jed_before_key_hooks", JED_HOOKS_RUN_ALL, 1, lookup_key_function_string (key)); } } if ((key != NULL) && (key->f.f != NULL)) { if (Repeat_Factor == NULL) return key_interpret (key); repeat = *Repeat_Factor; Suspend_Screen_Update = 1; /* some routines may use the repeat factor as a prefix argument */ while (repeat > 0) { repeat--; if (SLKeyBoard_Quit || SLang_get_error () || (Repeat_Factor == NULL)) break; key_interpret (key); } Repeat_Factor = NULL; return(1); } else if (!Executing_Keyboard_Macro && !SLKeyBoard_Quit) { jed_beep (); flush_input (); } if (SLKeyBoard_Quit) kbd_quit(); return(0); } /*}}}*/ int jed_do_key (void) { int ret = do_key (); if (SLang_get_error ()) { jed_abort_keyboard_macro (); Read_This_Character = NULL; Repeat_Factor = NULL; } return ret; } void do_jed(void) /*{{{*/ { char *mode; Buffer *tthis; tthis = CBuf; mode = tthis->mode_string; /* Mark Undo boundary now because this might not be valid later */ mark_undo_boundary (tthis); Repeat_Factor = NULL; Replace_Preserve_Case = 0; if (jed_do_key()) JWindow->trashed = 1; /* internal editing commands may have selected a different buffer * so put it back to the one associated with the window. */ if (CBuf != JWindow->buffer) { char *name; if (buffer_exists(JWindow->buffer)) name = JWindow->buffer->name; else name = "*scratch*"; switch_to_buffer_cmd(name); } #if JED_HAS_MENUS if ((tthis != CBuf) || (CBuf->mode_string != mode)) jed_notify_menu_buffer_changed (); #endif } /*}}}*/ static int run_switch_active_buffer_hooks (char **bnamep) { char *buffer_name = *bnamep; if (buffer_name == CBuf->name) return 0; if (buffer_name == NULL) (void) jed_va_run_hooks ("_jed_switch_active_buffer_hooks", JED_HOOKS_RUN_ALL, 1, ""); else { (void) jed_va_run_hooks ("_jed_switch_active_buffer_hooks", JED_HOOKS_RUN_ALL, 1, buffer_name); SLang_free_slstring (buffer_name); } /* This should not fail because CBuf->name is an slstring, and if it * does fail, it is not important. */ *bnamep = SLang_create_slstring (CBuf->name); return 0; } void jed (void) /*{{{*/ { /* This routine is called from main. It calls the startup-hooks before * entering the main editing loop. */ char *buffer_name; if (SLang_get_error ()) { update (NULL, 1, 1, 0); SLang_restart (1); SLang_set_error (0); jed_sleep (2); } #if JED_HAS_MENUS jed_notify_menu_buffer_changed (); #endif buffer_name = NULL; (void) run_switch_active_buffer_hooks (&buffer_name); (void) jed_va_run_hooks ("_jed_startup_hooks", JED_HOOKS_RUN_ALL, 0); (void) run_switch_active_buffer_hooks (&buffer_name); Jump_Buffer_Ptr = &Jump_Buffer; if (setjmp(Jump_Buffer.b) != 0) { SLang_restart(1); /* just in case */ } if (CBuf != JWindow->buffer) { switch_to_buffer(JWindow->buffer); window_buffer(CBuf); } #if JED_HAS_MENUS jed_notify_menu_buffer_changed (); #endif JWindow->trashed = 1; update((Line *) NULL, 0, 0, 1); Read_This_Character = NULL; while(1) { int had_err = 0; Suspend_Screen_Update = 0; do_jed(); if (SLang_get_error ()) { update (NULL, 1, 0, 0); SLang_restart (1); SLang_set_error (0); had_err = 1; } if (!SLKeyBoard_Quit && (CBuf->flags & BUFFER_MODIFIED) && (!Cursor_Motion)) CBuf->hits += 1; SLKeyBoard_Quit = 0; if (CBuf->hits > Jed_Max_Hits) { auto_save_buffer(CBuf); check_buffers(); /* check files on disk to see if they are recent */ } (void) run_switch_active_buffer_hooks (&buffer_name); if (Jed_Menus_Active == 0) (void) jed_va_run_hooks ("_jed_after_key_hooks", JED_HOOKS_RUN_ALL, 0); if ((Last_Key_Function != (FVOID_STAR) ins_char_cmd) || (JWindow->trashed) || (JWindow != JWindow->next) || Suspend_Screen_Update || (Mini_Ghost) || (*Message_Buffer) || (*Error_Buffer)) { update((Line *) NULL, 0, had_err, 1); } } } /*}}}*/ int digit_arg(void) /*{{{*/ { static int repeat; char buf[20]; int key; unsigned int i; i = 0; buf[i++] = (char) SLang_Last_Key_Char; /* After jed_do_key (what called this), Key_Bufferp is reset. However, I want * to keep it for echoing subsequent characters. I restore its previous * value so that echoing will continue. */ Key_Bufferp = Key_Buffer + Last_Key_Buffer_Len; SLang_Key_TimeOut_Flag = 1; while (i < sizeof(buf)-1) { buf[i] = 0; key = jed_getkey(); if ((key < '0') || (key > '9')) break; buf[i++] = (char) key; } buf[i] = 0; repeat = atoi(buf); Repeat_Factor = &repeat; if (Executing_Keyboard_Macro) Macro_Buffer_Ptr--; else { ungetkey (&key); if (Defining_Keyboard_Macro) Macro_Buffer_Ptr--; } if (Key_Bufferp != Key_Buffer) Key_Bufferp--; /* Key_Timeout is still active and is only reset after this call. */ jed_do_key(); return(1); } /*}}}*/ static int which_key (char *f) /*{{{*/ { int num = 0, i; SLang_Key_Type *key, *key_root; FVOID_STAR fp; unsigned char type; unsigned char buf[5]; if (NULL == (fp = (FVOID_STAR) SLang_find_key_function(f, CBuf->keymap))) type = SLKEY_F_INTERPRET; else type = SLKEY_F_INTRINSIC; i = 256; key_root = CBuf->keymap->keymap; while (i--) { key = key_root->next; if ((key == NULL) && (type == key_root->type) && (((type == SLKEY_F_INTERPRET) && (!strcmp((char *) f, key_root->f.s))) || ((type == SLKEY_F_INTRINSIC) && (fp == key_root->f.f)))) { buf[0] = 2; buf[1] = 256 - 1 - i; buf[2] = 0; SLang_push_string(SLang_make_keystring(buf)); num++; } while (key != NULL) { if ((key->type == type) && (((type == SLKEY_F_INTERPRET) && (!strcmp((char *) f, key->f.s))) || ((type == SLKEY_F_INTRINSIC) && (fp == key->f.f)))) { SLang_push_string(SLang_make_keystring(key->str)); num++; } key = key->next; } key_root++; } return(num); } /*}}}*/ static void dump_this_binding (SLang_Key_Type *key) /*{{{*/ { unsigned char ch, *s; char *str, ctrl[2]; SLFUTURE_CONST char *fun; int n, len; s = key->str; ctrl[0] = '^'; len = *s++ - 1;; while (len-- > 0) { n = 1; ch = *s++; if (ch == 127) { str = "DEL"; n = 3; } else if (ch > ' ') str = (char *) &ch; else if (ch == 27) { str = "ESC"; n = 3; } else if (ch == ' ') { str = "SPACE"; n = 5; } else if (ch == '\t') { str = "TAB"; n = 3; } else { str = ctrl; *(str + 1) = ch + '@'; n = 2; } (void) jed_quick_insert((unsigned char *) str, n); (void) jed_insert_byte (' '); } (void) jed_insert_wchar_n_times('\t', 3); fun = lookup_key_function_string (key); if (fun == NULL) fun = "** Unknown **"; (void) jed_insert_string (fun); (void) jed_insert_newline (); } /*}}}*/ static void dump_bindings(char *map) /*{{{*/ { int i; SLang_Key_Type *next, *key_root; SLKeyMap_List_Type *kml; CHECK_READ_ONLY_VOID if (NULL == (kml = SLang_find_keymap(map))) { msg_error("Keymap undefined."); return; } key_root = kml->keymap; for (i = 0; i < 256; i++) { next = key_root->next; if (next != NULL) { while (next != NULL) { dump_this_binding (next); next = next->next; } } else if (key_root->f.f != NULL) dump_this_binding (key_root); key_root++; } } /*}}}*/ static void use_keymap(char *name) /*{{{*/ { SLKeyMap_List_Type *map; if ((name == NULL) || (*name == 0) || (NULL == (map = SLang_find_keymap(name)))) { msg_error("Unknown keymap."); } else CBuf->keymap = map; } /*}}}*/ static SLFUTURE_CONST char *what_keymap (void) /*{{{*/ { return CBuf->keymap->name; } /*}}}*/ void jed_set_abort_char (int *c) /*{{{*/ { char str[2]; char ch = (char) *c; #if SLANG_VERSION >= 20000 SLkeymap_Type *km; #else int i; #endif if (X_Set_Abort_Char_Hook != NULL) (void) (*X_Set_Abort_Char_Hook) ((unsigned char) ch); Jed_Abort_Char = (int) ch; str[0] = ch; str[1] = 0; #if SLANG_VERSION < 20000 for (i = 0; i < SLANG_MAX_KEYMAPS; i++) { if (SLKeyMap_List[i].keymap == NULL) continue; SLang_undefine_key(str, &SLKeyMap_List[i]); SLkm_define_key (str, (FVOID_STAR) kbd_quit, &SLKeyMap_List[i]); } #else km = SLKeyMap_List_Root; while (km != NULL) { SLang_undefine_key(str, km); SLkm_define_key (str, (FVOID_STAR) kbd_quit, km); km = km->next; } #endif } /*}}}*/ static SLKeymap_Function_Type *Flist_Context; static int Flist_Context_Len; static char *Slang_Functions[JED_MAX_ADD_COMPLETIONS]; static char **Slang_Flist_Context; int next_function_list(char *buf) /*{{{*/ { char *name; char **max; /* Convert '-' to '_' */ name = buf; while (*name != 0) { if (*name == '-') *name = '_'; name++; } while (1) { SLKeymap_Function_Type *tthis = Flist_Context; SLFUTURE_CONST char *tname = tthis->name; if (tname == NULL) break; Flist_Context++; if (!Flist_Context_Len || !strncmp(buf, tname, Flist_Context_Len)) { strcpy(buf, tname); return(1); } } max = Slang_Functions + JED_MAX_ADD_COMPLETIONS; while (Slang_Flist_Context < max) { name = *Slang_Flist_Context; if (name == NULL) return(0); #if 0 name++; /* skip past hash mark */ #endif Slang_Flist_Context++; if (!Flist_Context_Len || !strncmp(buf, name, Flist_Context_Len)) { strcpy(buf, name); return(1); } } return(0); } /*}}}*/ int open_function_list(char *buf) /*{{{*/ { Flist_Context = Jed_Functions; Slang_Flist_Context = Slang_Functions; Flist_Context_Len = strlen(buf); return next_function_list(buf); } /*}}}*/ int add_to_completion(char *name) /*{{{*/ { static char **last = Slang_Functions; if (last == Slang_Functions + JED_MAX_ADD_COMPLETIONS) return 0; if (0 == SLang_is_defined (name)) { jed_verror ("add_completion: %s undefined", name); return -1; } name = SLang_create_slstring (name); if (name == NULL) return -1; *last++ = name; return 0; } /*}}}*/ int is_internal(char *f) /*{{{*/ { if (NULL == SLang_find_key_function(f, CBuf->keymap)) return(0); return 1; } /*}}}*/ static void copy_keymap_cmd (char *dest, char *src) { SLKeyMap_List_Type *ksrc; ksrc = SLang_find_keymap (src); if (ksrc == NULL) { jed_verror ("Keymap \"%s\" does not exist", src); return; } if (NULL != SLang_find_keymap (dest)) { jed_verror ("Keymap \"%s\" already exists", dest); return; } if (NULL == SLang_create_keymap (dest, ksrc)) jed_verror ("Unable to create keymap \"%s\"", dest); } void jed_call_cmd (char *str) { SLKeyMap_List_Type *km; int (*fp)(void); if (*str == ' ') { jed_insert_string (str + 1); return; } if (*str == '@') { (void) do_macro_string (str + 1, 1); return; } km = CBuf->keymap; if (NULL == (fp = (int (*)(void)) (SLang_find_key_function(str, km)))) jed_verror ("Internal function %s does not exist", str); else (void) (*fp)(); } typedef struct { unsigned char *key; unsigned int len; unsigned int num_read; } Getkey_Callback_Data_Type; static Getkey_Callback_Data_Type Getkey_Callback_Data; static int get_key_function_callback (void) { unsigned int i = Getkey_Callback_Data.num_read; if (i == Getkey_Callback_Data.len) return SLANG_GETKEY_ERROR; Getkey_Callback_Data.num_read += 1; return (int) Getkey_Callback_Data.key[i]; } static int push_key_binding (unsigned char *keystr) { SLang_Key_Type *key; char *fun; int type; #ifdef SLKEY_F_SLANG SLang_Name_Type *ref = NULL; #endif SLang_Key_TimeOut_Flag = 0; if (keystr == NULL) { Key_Bufferp = Key_Buffer; key = SLang_do_key (CBuf->keymap, jed_getkey); update_jed_keybuffer (); if (key == NULL) flush_input (); if (SLKeyBoard_Quit || (SLang_get_error () == USER_BREAK)) { SLang_set_error (0); SLKeyBoard_Quit = 0; } } else { Getkey_Callback_Data.len = (unsigned int) keystr[0]; Getkey_Callback_Data.key = keystr + 1; Getkey_Callback_Data.num_read = 0; key = SLang_do_key (CBuf->keymap, get_key_function_callback); } fun = NULL; type = -1; if (key != NULL) switch (key->type) { case SLKEY_F_INTRINSIC: type = 1; fun = find_function_string (key->f.f); break; case SLKEY_F_INTERPRET: fun = key->f.s; type = 0; if (fun[0] == '@') type = 2; else if (fun[0] == ' ') type = 3; break; #ifdef SLKEY_F_SLANG case SLKEY_F_SLANG: type = 4; ref = key->f.slang_fun; break; #endif } if (-1 == SLang_push_integer (type)) return -1; #ifdef SLKEY_F_SLANG if (type == 4) type = SLang_push_function (ref); else #endif type = SLang_push_string (fun); return type; } /*}}}*/ static void get_key_binding (void) { unsigned char *s = NULL; if (SLang_Num_Function_Args == 1) { char *str; if (-1 == SLang_pop_slstring (&str)) return; s = (unsigned char *) SLang_process_keystring (str); SLang_free_slstring (str); if (s == NULL) return; } (void) push_key_binding (s); } /* This is weird, Ultrix cc will not compile if set_key comes before unset_key */ static void unset_key (char *key) /*{{{*/ { if (*key) SLang_undefine_key(key, Global_Map); } /*}}}*/ static void unset_key_in_keymap(char *key, char *map) /*{{{*/ { SLKeyMap_List_Type *kmap; if (NULL == (kmap = SLang_find_keymap(map))) { jed_verror ("Unknown keymap: %s", map); return; } if (*key) SLang_undefine_key(key, kmap); } /*}}}*/ static void set_key_in_keymap_1 (SLKeyMap_List_Type *kmap) { char *key, *func; if (-1 == SLang_pop_slstring (&key)) return; #ifdef SLKEY_F_SLANG if (SLang_peek_at_stack () == SLANG_REF_TYPE) { SLang_Name_Type *nt = SLang_pop_function (); if (nt == NULL) { SLang_free_slstring (key); return; } if (-1 == SLkm_define_slkey (key, nt, kmap)) { SLang_free_function (nt); SLang_free_slstring (key); return; } SLang_free_slstring (key); return; } #endif if (-1 == SLang_pop_slstring (&func)) { SLang_free_slstring (key); return; } if (*key) (void) SLang_define_key(key, func, kmap); SLang_free_slstring (func); SLang_free_slstring (key); } static void set_key_in_keymap (void) { char *keymap; SLKeyMap_List_Type *kmap; if (-1 == SLang_pop_slstring (&keymap)) return; if (NULL == (kmap = SLang_find_keymap(keymap))) jed_verror ("Unknown keymap: %s", keymap); else set_key_in_keymap_1 (kmap); SLang_free_slstring (keymap); } /*}}}*/ static void set_key (void) { set_key_in_keymap_1 (Global_Map); } /*}}}*/ static int keymap_p(char *name) /*{{{*/ { return ! (NULL == SLang_find_keymap(name)); } /*}}}*/ static void make_keymap_cmd (char *km) { copy_keymap_cmd (km, "global"); } static void get_keymaps (void) { int j, n; char **keymaps; SLang_Array_Type *at; #if SLANG_VERSION < 20000 unsigned int i; #else SLkeymap_Type *km; #endif n = 0; #if SLANG_VERSION < 20000 for (i = 0; i < SLANG_MAX_KEYMAPS; i++) { if (SLKeyMap_List[i].keymap == NULL) continue; n++; } #else km = SLKeyMap_List_Root; while (km != NULL) { n++; km = km->next; } #endif if (NULL == (at = SLang_create_array (SLANG_STRING_TYPE, 0, NULL, &n, 1))) return; keymaps = (char **)at->data; j = 0; #if SLANG_VERSION < 20000 for (i = 0; i < SLANG_MAX_KEYMAPS; i++) { if (SLKeyMap_List[i].keymap == NULL) continue; if (j == n) break; /* keymap list changing?? */ if (NULL == (keymaps[j] = SLang_create_slstring (SLKeyMap_List[i].name))) { SLang_free_array (at); return; } j++; } #else km = SLKeyMap_List_Root; while (km != NULL) { if (j == n) break; /* keymap list changing?? */ if (NULL == (keymaps[j] = SLang_create_slstring (km->name))) { SLang_free_array (at); return; } km = km->next; j++; } #endif SLang_push_array (at, 1); } static void getkey_wchar_intrin (void) { int ch; SLwchar_Type wch; if (-1 == jed_getkey_wchar (&wch)) { ch = (int) wch; (void) SLang_push_integer (-ch); return; } (void) SLclass_push_long_obj (SLANG_LONG_TYPE, (long)wch); } static void ungetkey_wchar_intrin (long *chp) { if (*chp < 0) { int ch = -(int)*chp; ungetkey (&ch); return; } jed_ungetkey_wchar ((SLwchar_Type)*chp); } static SLang_Intrin_Fun_Type Keymap_Intrinsics [] = { MAKE_INTRINSIC_0("setkey", set_key, VOID_TYPE), MAKE_INTRINSIC_0("definekey", set_key_in_keymap, VOID_TYPE), MAKE_INTRINSIC_S("unsetkey", unset_key, VOID_TYPE), MAKE_INTRINSIC("what_keymap", what_keymap, STRING_TYPE, 0), MAKE_INTRINSIC_0("get_keymaps", get_keymaps, VOID_TYPE), MAKE_INTRINSIC_S("keymap_p", keymap_p, INT_TYPE), MAKE_INTRINSIC("get_key_binding", get_key_binding, VOID_TYPE, 0), MAKE_INTRINSIC_S("dump_bindings", dump_bindings, VOID_TYPE), MAKE_INTRINSIC_SS("undefinekey", unset_key_in_keymap, VOID_TYPE), MAKE_INTRINSIC_S("which_key", which_key, INT_TYPE), MAKE_INTRINSIC_S("make_keymap", make_keymap_cmd, VOID_TYPE), MAKE_INTRINSIC_SS("copy_keymap", copy_keymap_cmd, VOID_TYPE), MAKE_INTRINSIC_S("use_keymap", use_keymap, VOID_TYPE), MAKE_INTRINSIC("_getkey", jed_getkey, INT_TYPE, 0), MAKE_INTRINSIC_I("_ungetkey", ungetkey, VOID_TYPE), MAKE_INTRINSIC_0("getkey", getkey_wchar_intrin, VOID_TYPE), MAKE_INTRINSIC_1("ungetkey", ungetkey_wchar_intrin, VOID_TYPE, SLANG_LONG_TYPE), #ifdef REAL_UNIX_SYSTEM MAKE_INTRINSIC_1("set_default_key_wait_time", jed_set_default_key_wait_time, SLANG_INT_TYPE, SLANG_INT_TYPE), #endif SLANG_END_INTRIN_FUN_TABLE }; static char *Key_Buffer_Ptr = Jed_Key_Buffer; static char *Last_Kbd_Command_Str_Ptr = Last_Kbd_Command_String; static char *Current_Kbd_Command_Str_Ptr = Current_Kbd_Command_String; static SLang_Intrin_Var_Type Keymap_Variables [] = { MAKE_VARIABLE("LASTKEY", &Key_Buffer_Ptr, STRING_TYPE, 1), MAKE_VARIABLE("LAST_KBD_COMMAND", &Last_Kbd_Command_Str_Ptr, STRING_TYPE, 1), MAKE_VARIABLE("CURRENT_KBD_COMMAND", &Current_Kbd_Command_Str_Ptr, STRING_TYPE, 1), MAKE_VARIABLE(NULL, NULL, 0, 0) }; int jed_init_keymap_intrinsics (void) { if ((-1 == SLadd_intrin_fun_table (Keymap_Intrinsics, NULL)) || (-1 == SLadd_intrin_var_table (Keymap_Variables, NULL))) return -1; return 0; } jed-0.99-19/src/vmshelp.c0000644002657400265740000001110011311317447014074 0ustar davisdavis/* -*- mode: C; mode: fold; -*- */ /* Copyright (c) 1992, 1998, 2000, 2002, 2003, 2004, 2005, 2006 John E. Davis * This file is part of JED editor library source. * * You may distribute this file under the terms the GNU General Public * License. See the file COPYING for more information. */ /* vms_get_help.c */ #include "config.h" #include "jed-feat.h" #include #include #include "jdmacros.h" #include #include /* Not all systems have this (GCC) so I am not using it. */ /* #include */ #define HLP$M_PROMPT 1 #define HLP$M_LIBLIST 16 #include "buffer.h" #include "ins.h" #include "cmds.h" /* Need to pass strings by descriptor to LBR$OUTPUT_HELP; */ /* string descriptors in SYS$LIBRARY:DESCRIP.H. */ /* Change definition of $DESCRIPTOR macro. In descrip.h, */ /* sizeof(string)-1 used, but sizeof() bites on strings */ /* with spaces, or with '$'. That means that the filename */ /* might be truncated (i.e., 'SYS$HELP:HELPLIB.OLB' */ /* becomes 'SYS'). Ditto the topic (i.e., 'SET HOST /LOG' */ /* becomes 'SET'). */ #define $STR_DESC(x,y) \ (x).dsc$w_length = strlen(y);\ (x).dsc$b_dtype = DSC$K_DTYPE_T;\ (x).dsc$b_class = DSC$K_CLASS_S;\ (x).dsc$a_pointer = (y) /*--------------------------------------------------------------*/ /* */ /* vms_get_help: call the librarian utility to get help */ /* */ /* input: */ /* char helpfile - name of the help file to use */ /* char helptopic - name of topic to use initially */ /* (Since HLP$M_PROMPT is set, user will */ /* get interactive prompting once in.) */ /* returns: */ /* int - 0 for failure, 1 for success */ /* */ /* Translated from a FORTRAN subroutine. That subroutine */ /* was gutted from several of J.W. Pflugrath's routines */ /* for I/O, et cetera. */ /* */ /* Jim Clifton Brandeis University */ /* J.W. Pflugrath Cold Spring Harbor Laboratory */ /* */ /*--------------------------------------------------------------*/ int vms_get_help(char *helpfile, char *helptopic) /*{{{*/ { int LBR$OUTPUT_HELP(), output_help_to_buf(), input_new_helptopic(); int istat; unsigned int flags; struct dsc$descriptor_s topnam, filnam; $STR_DESC(topnam,helptopic); $STR_DESC(filnam,helpfile); flags = HLP$M_PROMPT; istat = LBR$OUTPUT_HELP(&output_help_to_buf, 0, /* output width 0 is 80 */ &topnam, /* topic */ &filnam, /* lib file */ &flags, /* Also try: M_LIBLIST M_HELP */ &input_new_helptopic); if (istat != 1) return 0; return 1; } /*}}}*/ /*----------------------------------------------------------------------*/ /* */ /* Here we mimic the syntax of LIB$PUT_OUTPUT */ /* */ /* VMS system procedures (including the RTL) pass strings by */ /* descriptor. That's what LBR$OUTPUT_HELP expects (demands!). This */ /* routine (and the next) just function to integrate LBR$OUTPUT_HELP */ /* I/O into jed I/O. */ /* */ /* Jim Clifton Brandeis University */ /* */ /*----------------------------------------------------------------------*/ int output_help_to_buf(struct dsc$descriptor_s *string) /*{{{*/ { (void) jed_insert_nbytes ((unsigned char *) string->dsc$a_pointer, string->dsc$w_length); (void) jed_insert_newline (); return(1); /* should add codes that LIB$PUT_OUTPUT can return */ } /*}}}*/ /*----------------------------------------------------------------------*/ /* */ /* Mimic the syntax of LIB$GET_INPUT() */ /* */ /* Note that the first 2 characters of the LBR$OUTPUT_HELP prompt are */ /* "^M^J", so we send read_from_minibuffer the address of the 3rd char. */ /* */ /* Jim Clifton Brandeis University */ /* */ /*----------------------------------------------------------------------*/ int input_new_helptopic(struct dsc$descriptor_s *newtopic, /*{{{*/ struct dsc$descriptor_s *prompt, unsigned int *len_newtopic) { char *newtop, prompt_buf[256]; int dofree; strncpy(prompt_buf,prompt->dsc$a_pointer,prompt->dsc$w_length); prompt_buf[prompt->dsc$w_length] = 0; newtop = ""; dofree = 0; if ((SLang_run_hooks("vms_help_newtopic", 1, prompt_buf + 2) > 0) && (0 == SLpop_string (&newtop))) dofree = 1; strcpy (newtopic->dsc$a_pointer, newtop); *len_newtopic = newtopic->dsc$w_length = strlen (newtop); newtopic->dsc$b_dtype = DSC$K_DTYPE_T; newtopic->dsc$b_class = DSC$K_CLASS_S; if (dofree) SLfree(newtop); return(1); /* should add codes that LIB$GET_INPUT can return */ } /*}}}*/ jed-0.99-19/src/wterm.c0000644002657400265740000022513011311317447013566 0ustar davisdavis/* Copyright (c) 1992, 1998, 2000, 2002, 2003, 2004, 2005, 2006 John E. Davis * This file is part of JED editor library source. * * You may distribute this file under the terms the GNU General Public * License. See the file COPYING for more information. */ #define HAS_PALETTE_CODE 0 #include "config.h" #include "jed-feat.h" #include #include #include #include "jdmacros.h" #include #include #include #include #include #include #include #include "display.h" #include "buffer.h" #include "sysdep.h" #include "screen.h" #include "keymap.h" #include "hooks.h" #include "ins.h" #include "ledit.h" #include "misc.h" #include "cmds.h" #include "sig.h" #include "win32.h" #include "colors.h" /* #include "resource.h" */ /* Where is it? */ #if JED_HAS_SUBPROCESSES # include "jprocess.h" #endif #ifdef __WIN32__ # define HAS_WHEEL_MOUSE_SUPPORT 1 #else # define HAS_WHEEL_MOUSE_SUPPORT 0 #endif #define MSW_STRING_TYPE 1 #define MSW_INT_TYPE 2 #define MSW_COLOR_TYPE 3 #define MAX_STRING_SIZE 128 #define MAX_KEYS 128 #define KEY_SHIFT 1 #define KEY_CONTROL 2 #define KEY_ALT 4 int NumLock_Is_Gold = 0; int PC_Alt_Char = 27; int PC_Fn_Char = 0; /* Last Charset used: keep track of input language changes */ static DWORD JedCharSet = DEFAULT_CHARSET; static DWORD JedACP = CP_ACP; #define SPACE_CHAR (32 | (JNORMAL_COLOR << 8)) #define MAX_MENU_ID 256 #if !defined(_MSC_VER) && !defined(__CYGWIN32__) && !defined(__MINGW32__) extern HINSTANCE _hInstance; #else HINSTANCE _hInstance; #endif #ifdef __WIN32__ HINSTANCE _hPrev; #else extern HINSTANCE _hPrev; #endif /* #define CURRENT_BG_COLOR JColors[JNORMAL_COLOR].hbrBG */ #define CURRENT_BG_COLOR This_Window.current_color->hbrBG #if HAS_WHEEL_MOUSE_SUPPORT #ifndef WM_MOUSEWHEEL # define WM_MOUSEWHEEL (WM_MOUSELAST+1) /* message that will be supported by the OS */ #endif /* Details of the mystery mouse wheel window */ #define MOUSEZ_CLASSNAME "MouseZ" /* wheel window class */ #define MOUSEZ_TITLE "Magellan MSWHEEL" /* wheel window title */ #define MSH_WHEELMODULE_CLASS (MOUSEZ_CLASSNAME) #define MSH_WHEELMODULE_TITLE (MOUSEZ_TITLE) #define MSH_MOUSEWHEEL "MSWHEEL_ROLLMSG" #define MSH_WHEELSUPPORT "MSH_WHEELSUPPORT_MSG" /* name of msg to send to query for wheel support */ #define MSH_SCROLL_LINES "MSH_SCROLL_LINES_MSG" /* Details of the mouse wheel functionality - not all currently used by Wjed */ typedef struct { HWND hwnd; UINT uiMshMsgMouseWheel, uiMshMsg3DSupport, uiMshMsgScrollLines; INT iScrollLines; BOOL fActive; } MS_Wheel_Type; static MS_Wheel_Type Wheel_Mouse; #endif /* HAS_WHEEL_MOUSE_SUPPORT */ typedef struct { char *name; int type; char *dflt; void *buf; } Msw_Ini_Type; typedef struct { COLORREF bg; COLORREF fg; HBRUSH hbrBG; } Color_Type; typedef struct { char *name; int r, g, b; } Color_Value_Type; typedef struct { char title[MAX_STRING_SIZE]; HWND w; HDC hdc; int ndc; char font_name[MAX_STRING_SIZE]; int font_height; int font_bold; int font_width; HFONT font; int x; int y; int height; int width; int scroll_r1, scroll_r2; /* scrolling region */ int cursor_row, cursor_col; /* row column of cursor (1,1) origin */ int vis_curs_row, vis_curs_col; /* position of VISIBLE cursor */ int cursor_showing; Color_Type *current_color; int focus; } MSWindow_Type; LRESULT CALLBACK JEDWndProc(HWND, UINT, WPARAM, LPARAM); static void msw_cleanup(void); static void msw_get_defaults(void); static void msw_get_default(Msw_Ini_Type *t); static void get_dc(void); static void release_dc(void); static void init_application(void); static void init_instance(void); void process_message(void); static void show_cursor(void); static void hide_cursor(void); static void msw_normal_video(void); static void set_window_name(char *s); static void msw_define_color(char *, int *, int *, int *); static void msw_select_font(char *, int *, int *); static void get_menubar(void); static void destroy_menubar(void); static void create_popup_menu(void); static void destroy_menu(void); static void append_menu_item(void); static void append_popup_menu(void); static void append_separator(void); static void insert_menu_item(void); static void insert_menu_item_pos(void); static void insert_popup_menu(void); static void insert_popup_menu_pos(void); static void insert_separator(void); static void insert_separator_pos(void); static void delete_menu_item(void); static void delete_menu_item_pos(void); static void get_menu_state(void); static void get_menu_state_pos(void); static void get_popup_menu(void); static void check_menu_item(void); static void check_menu_item_pos(void); static void enable_menu_item(void); static void enable_menu_item_pos(void); static void redraw_menubar(void); static void set_init_popup_callback(void); static void msw_help(void); static HINSTANCE hPrevInst; static HINSTANCE hInstance; static char *szJedSection = "WJED"; static int MSW_Screen_Cols; static int MSW_Screen_Rows; static int MSW_Term_Cannot_Scroll = 0; static int MSW_Term_Cannot_Insert = 0; static int MSW_Use_Ansi_Colors = 1; static int MSW_Ignore_Beep = 3; static int Performing_Update; static MSWindow_Type This_Window; static Color_Type JColors[JMAX_COLORS]; static char *InitPopup_Callback; static char *Menu_Callbacks[MAX_MENU_ID]; #if HAS_PALETTE_CODE static LPLOGPALETTE The_Lplgpl = NULL; static HPALETTE The_Hpalette = NULL; #endif static char Font_Name[MAX_STRING_SIZE]; static int Font_Height; static int Font_Bold; static Msw_Ini_Type Msw_Ini_List[] = { { "Font", MSW_STRING_TYPE, "fixed", Font_Name }, { "FontHeight", MSW_INT_TYPE, "12", &Font_Height }, { "FontBold", MSW_INT_TYPE, "-1", &Font_Bold }, { "Background", MSW_COLOR_TYPE, "0,0,0", &JColors[JNORMAL_COLOR].bg }, { "Foreground", MSW_COLOR_TYPE, "192,192,192", &JColors[JNORMAL_COLOR].fg }, { "StatusBG", MSW_COLOR_TYPE, "0,0,128", &JColors[JSTATUS_COLOR].bg }, { "StatusFG", MSW_COLOR_TYPE, "255,255,0", &JColors[JSTATUS_COLOR].fg }, { "RegionBG", MSW_COLOR_TYPE, "255,0,255", &JColors[JREGION_COLOR].bg }, { "RegionFG", MSW_COLOR_TYPE, "255,255,255", &JColors[JREGION_COLOR].fg }, { "OperatorBG", MSW_COLOR_TYPE, "0,0,0", &JColors[JOP_COLOR].bg }, { "OperatorFG", MSW_COLOR_TYPE, "255,255,255", &JColors[JOP_COLOR].fg }, { "NumberBG", MSW_COLOR_TYPE, "0,0,0", &JColors[JNUM_COLOR].bg }, { "NumberFG", MSW_COLOR_TYPE, "0,0,192", &JColors[JNUM_COLOR].fg }, { "StringBG", MSW_COLOR_TYPE, "0,0,0", &JColors[JSTR_COLOR].bg }, { "StringFG", MSW_COLOR_TYPE, "0,192,255", &JColors[JSTR_COLOR].fg }, { "CommentBG", MSW_COLOR_TYPE, "0,0,0", &JColors[JCOM_COLOR].bg }, { "CommentFG", MSW_COLOR_TYPE, "0,128,0", &JColors[JCOM_COLOR].fg }, { "KeywordBG", MSW_COLOR_TYPE, "0,0,0", &JColors[JKEY_COLOR].bg }, { "KeywordFG", MSW_COLOR_TYPE, "255,255,255", &JColors[JKEY_COLOR].fg }, { "Keyword1BG", MSW_COLOR_TYPE, "0,0,0", &JColors[JKEY_COLOR + 1].bg }, { "Keyword1FG", MSW_COLOR_TYPE, "255,255,255", &JColors[JKEY_COLOR + 1].fg }, { "DelimiterBG", MSW_COLOR_TYPE, "0,0,0", &JColors[JDELIM_COLOR].bg }, { "DelimiterFG", MSW_COLOR_TYPE, "255,255,255", &JColors[JDELIM_COLOR].fg }, { "PreprocessBG", MSW_COLOR_TYPE, "0,0,0", &JColors[JPREPROC_COLOR].bg }, { "PreprocessFG", MSW_COLOR_TYPE, "0,255,0", &JColors[JPREPROC_COLOR].fg }, { "MessageBG", MSW_COLOR_TYPE, "0,0,0", &JColors[JMESSAGE_COLOR].bg}, { "MessageFG", MSW_COLOR_TYPE, "255,255,0", &JColors[JMESSAGE_COLOR].fg}, { "ErrorFG", MSW_COLOR_TYPE, "255,0,0", &JColors[JERROR_COLOR].fg}, { "ErrorBG", MSW_COLOR_TYPE, "0,0,0", &JColors[JERROR_COLOR].bg}, { "MenuFG", MSW_COLOR_TYPE, "0,0,0", &JColors[JMENU_COLOR].fg}, { "MenuBG", MSW_COLOR_TYPE, "0,255,255", &JColors[JMENU_COLOR].bg}, {"CursorFG", MSW_COLOR_TYPE, "0,255,0", &JColors[JCURSOR_COLOR].fg}, {"CursorBG", MSW_COLOR_TYPE, "255,0,0", &JColors[JCURSOR_COLOR].bg}, {"DollarFG", MSW_COLOR_TYPE, "0,0,255", &JColors[JDOLLAR_COLOR].fg}, {"DollarBG", MSW_COLOR_TYPE, "0,0,0", &JColors[JDOLLAR_COLOR].bg}, {"CursorOvrFG", MSW_COLOR_TYPE, "255,0,0", &JColors[JCURSOROVR_COLOR].fg}, {"CursorOvrBG", MSW_COLOR_TYPE, "0,255,0", &JColors[JCURSOROVR_COLOR].bg}, { "Title", MSW_STRING_TYPE, "WJED", This_Window.title }, { "X", MSW_INT_TYPE, "0", &This_Window.x }, { "Y", MSW_INT_TYPE, "0", &This_Window.y }, { "Width", MSW_INT_TYPE, "700", &This_Window.width }, { "Height", MSW_INT_TYPE, "500", &This_Window.height }, { NULL, 0, NULL, NULL } }; static Color_Value_Type Msw_Std_Color[] = { {"black", 0, 0, 0}, {"blue", 0, 0, 192}, {"green", 0, 128, 0}, {"cyan", 0, 192, 192}, {"red", 192, 0, 0}, {"magenta", 192, 0, 192}, {"lightgray", 192, 192, 192}, {"gray", 128, 128, 128}, {"brightblue", 0, 0, 255}, {"brightred", 255, 0, 0}, {"brightgreen", 0, 255, 0}, {"brightcyan", 0, 255, 255}, {"brightmagenta", 255, 0, 255}, {"yellow", 255, 255, 0}, {"white", 255, 255, 255}, {"brown", 110, 74, 32}, {NULL, 0, 0, 0} }; #define S SLANG_STRING_TYPE #define I SLANG_INT_TYPE static SLang_Intrin_Fun_Type Jed_WinGUI_Table[] = { MAKE_INTRINSIC_SII("w32_select_font", msw_select_font, VOID_TYPE), MAKE_INTRINSIC_S("x_set_window_name", set_window_name, VOID_TYPE), MAKE_INTRINSIC_4("w32_define_color", msw_define_color, VOID_TYPE, S,I,I,I), /*Prototype: Void msw_define_color(char *, int, int, int);*/ MAKE_INTRINSIC("w32_get_menubar", get_menubar, VOID_TYPE, 0), /* Prototype: Integer get_menubar(Void); * Returns integer which is handle of menubar. If there is no * menubar, it creates it. * To show menubar, call `redraw_menu' */ MAKE_INTRINSIC("w32_destroy_menubar", destroy_menubar, VOID_TYPE, 0), /* Prototype: Void destroy_menubar(Void); * Destroys menubar */ MAKE_INTRINSIC("w32_create_popup_menu", create_popup_menu, VOID_TYPE, 0), /* Prototype: Integer create_popup_menu(Void); * Creates empty popup menu and returns integer value which is * it's handle. If popup is not appended to another menu, it must * destroyed after use. */ MAKE_INTRINSIC("w32_destroy_menu", destroy_menu, VOID_TYPE, 0), /* Prototype: Void destroy_menu(Integer hmenu); * Destroys menu and all it's popup menus. * Note: Do not destroy menubar with this function * (use `destroy_menubar') */ MAKE_INTRINSIC("w32_append_menu_item", append_menu_item, VOID_TYPE, 0), /* Prototype: Void append_menu_item(Integer hmenu, String name, Integer id, String callback); * Appends menu item with name 'name' and identifier 'id' at the end * of 'hmenu'. When item is selected, the 'callback' will be executed. * Callback can be intrinsic or internal function. */ MAKE_INTRINSIC("w32_append_popup_menu", append_popup_menu, VOID_TYPE, 0), /* Prototype: Void append_popop_menu(Integer hmenu, String name, Integer popup); * Appends popup menu with name 'name' and handle 'popup' at the end * of 'hmenu' */ MAKE_INTRINSIC("w32_append_separator", append_separator, VOID_TYPE, 0), /* Prototype: Void append_separator(Integer hmenu); * Appends menu separator at the end of 'hmenu' */ MAKE_INTRINSIC("w32_insert_menu_item", insert_menu_item, VOID_TYPE, 0), /* Prototype: Void insert_menu_item(Integer hmenu, Integer id, String name, Integer idNew, String callback); * Inserts menu item with name 'name' and identifier 'idNew' before * menu item with identifier 'id'. * When item is selected, the 'callback' will be executed. * Callback can be intrinsic or internal function. */ MAKE_INTRINSIC("w32_insert_menu_item_pos", insert_menu_item_pos, VOID_TYPE, 0), /* Prototype: Void insert_menu_item_pos(Integer hmenu, Integer pos, String name, Integer idNew, String callback); * Inserts menu item with name 'name' and identifier 'idNew' before * menu item with zero-based position 'pos' in 'hmenu'. * When item is selected, the 'callback' will be executed. * Callback can be intrinsic or internal function. */ MAKE_INTRINSIC("w32_insert_popup_menu", insert_popup_menu, VOID_TYPE, 0), /* Prototype: Void insert_popup_menu(Integer hmenu, Integer id, String name, Integer popup); * Inserts popup menu with name 'name' and handle 'popup' before * menu item with identifier 'id' */ MAKE_INTRINSIC("w32_insert_popup_menu_pos", insert_popup_menu_pos, VOID_TYPE, 0), /* Prototype: Void insert_popup_menu_pos(Integer hmenu, Integer pos, String name, Integer popup); * Inserts popup menu with name 'name' and handle 'popup' before * menu item with zero-based position 'pos' in 'hmenu' */ MAKE_INTRINSIC("w32_insert_separator", insert_separator, VOID_TYPE, 0), /* Prototype: Void insert_separator(Integer hmenu, Integer id); * Inserts menu separator before menu item with identifier 'id' */ MAKE_INTRINSIC("w32_insert_separator_pos", insert_separator_pos, VOID_TYPE, 0), /* Prototype: Void insert_separator_pos(Integer hmenu, Integer pos); * Inserts menu separator before menu item with zero-based position 'pos' */ MAKE_INTRINSIC("w32_delete_menu_item", delete_menu_item, VOID_TYPE, 0), /* Prototype: Void delete_menu_item(Integer hmenu, Integer id); * Deletes menu item with identifier id from menu with handle 'hmenu' */ MAKE_INTRINSIC("w32_delete_menu_item_pos", delete_menu_item_pos, VOID_TYPE, 0), /* Prototype: Void delete_menu_item_pos(Integer hmenu, Integer pos); * Deletes menu item at zero-based position 'pos' from menu 'hmenu' */ MAKE_INTRINSIC("w32_get_menu_state", get_menu_state, VOID_TYPE, 0), /* Prototype: Integer get_menu_state(Integer hmenu, Integer id); * Gets state of menu item with identifier 'id' * & 1 == 1 if menu item is enabled * & 2 == 1 if menu item is checked */ MAKE_INTRINSIC("w32_get_menu_state_pos", get_menu_state_pos, VOID_TYPE, 0), /* Prototype: Integer get_menu_state(Integer hmenu, Integer pos); * Gets state of menu item at zero-based position 'pos' * & 1 == 1 if menu item is enabled * & 2 == 1 if menu item is checked */ MAKE_INTRINSIC("w32_get_popup_menu", get_popup_menu, VOID_TYPE, 0), /* Prototype: Void get_popup_menu(Integer hmenu, Integer pos); * Returns handle of popup menu at zero-based position 'pos' * If return value is 0, there is no popup at the position. */ MAKE_INTRINSIC("w32_check_menu_item", check_menu_item, VOID_TYPE, 0), /* Prototype: Void check_menu_item(Integer hmenu, Integer id, Integer flag); * This functions changes check state of menu item. If flag is nonzero, * it checks menu item, otherwise it unchecks it */ MAKE_INTRINSIC("w32_check_menu_item_pos", check_menu_item_pos, VOID_TYPE, 0), /* Prototype: Void check_menu_item(Integer hmenu, Integer pos, Integer flag); * This functions changes check state of menu item. If flag is nonzero, * it checks menu item, otherwise it unchecks it */ MAKE_INTRINSIC("w32_enable_menu_item", enable_menu_item, VOID_TYPE, 0), /* Prototype: Void enable_menu_item(Integer hmenu, Integer id, Integer flag); * This functions enable or disable menu item. If flag is nonzero, the * menu item will be enabled, otherwise it'll be disabled. */ MAKE_INTRINSIC("w32_enable_menu_item_pos", enable_menu_item_pos, VOID_TYPE, 0), /* Prototype: Void enable_menu_item_pos(Integer hmenu, Integer pos, Integer flag); * This functions enable or disable menu item. If flag is nonzero, the * menu item will be enabled, otherwise it'll be disabled. */ MAKE_INTRINSIC("w32_redraw_menubar", redraw_menubar, VOID_TYPE, 0), /* Prototype: Void redraw_menubar(Void); * Redraws menubar. This functions should be called if menubar is changed */ MAKE_INTRINSIC("w32_set_init_popup_callback", set_init_popup_callback, VOID_TYPE, 0), /* Prototype: Void set_init_popup_callback(String callback); * Executes callback before menu poppup was popped up. */ MAKE_INTRINSIC("msw_help", msw_help, VOID_TYPE, 0), /* Prototype: Void msw_help(String filename, String keword, Integer Partial_Keys); * Starts Windows Help with 'filename' help file. If 'keyword' is not null * string shows topic with specified keyword. If 'Partial_Keys' != 0 * shows Search dialog if there is more than one help topic beginnig with * 'keyword' */ MAKE_INTRINSIC(NULL, NULL, 0, 0) }; #undef S #undef I static int wjed_has_unicode(void) { static int unicode = -1; if (unicode == -1) unicode = SLsmg_is_utf8_mode(); return unicode; } static void _putkey (WCHAR wc) { #if SLANG_VERSION >= 20000 if (wjed_has_unicode ()) { unsigned char buf[SLUTF8_MAX_MBLEN+1], *b; b = SLutf8_encode((SLwchar_Type)wc, buf, SLUTF8_MAX_MBLEN); buffer_keystring ((char *)buf, b-buf); } else #endif { /* 0xE0 is prefix for cursor keys, but also à on ANSI * charset. The charmap has 0xE0 0xE0 to à */ unsigned char ch = (unsigned char) wc; if (ch == 0xE0) buffer_keystring ((char *)&ch, 1); buffer_keystring ((char *)&ch, 1); } } static void send_key_sequence (unsigned int n, unsigned char c1, unsigned char c2, unsigned char c3, unsigned char c4) { unsigned char buf[4]; if (n > 4) exit_error ("n>4 in send_key_sequence", 0); buf[0] = c1; buf[1] = c2; buf[2] = c3; buf[3] = c4; buffer_keystring((char *)buf, n); } /* Getting defaults from INI file */ static COLORREF msw_get_color(char *s, char *dflt) { if (s[0] >= '0' && s[0] <= '9') { long r, g, b; char *sptr, *endptr; sptr = s; r = strtol(sptr, &endptr, 0); while ((*endptr == ' ') || (*endptr == '\t')) endptr++; /* skipping whitespace */ if ((sptr == endptr) || (*endptr++ != ',')) return msw_get_color(dflt, dflt); sptr = endptr; g = strtol(sptr, &endptr, 0); while ((*endptr == ' ') || (*endptr == '\t')) endptr++; /* skipping whitespace */ if ((sptr == endptr) || (*endptr++ != ',')) return msw_get_color(dflt, dflt); sptr = endptr; b = strtol(sptr, &endptr, 0); while ((*endptr == ' ') || (*endptr == '\t')) endptr++; /* skipping whitespace */ if ((sptr == endptr) || (*endptr++ != 0)) return msw_get_color(dflt, dflt); #if HAS_PALETTE_CODE return PALETTERGB((BYTE)r, (BYTE)g, (BYTE)b); #else return RGB((BYTE)r, (BYTE)g, (BYTE)b); #endif } else { char buf[50]; GetProfileString(szJedSection, s, dflt, buf, sizeof(buf)); if (buf[0] >='0' && buf[0] <= '9') return msw_get_color(buf, dflt); else return msw_get_color(dflt, dflt); } } static void msw_get_default(Msw_Ini_Type *t) { char s[MAX_STRING_SIZE]; GetProfileString(szJedSection, t->name, t->dflt, s, sizeof(s)); switch (t->type) { case MSW_STRING_TYPE: strncpy((char *)t->buf, s, MAX_STRING_SIZE); ((char *)t->buf)[MAX_STRING_SIZE-1] = 0; break; case MSW_INT_TYPE: *(int *)t->buf = atoi(s); break; case MSW_COLOR_TYPE: *(COLORREF *)t->buf = msw_get_color(s, t->dflt); break; } } static void msw_get_defaults(void) { int i = 0; char buf[128]; /* Check for standard color names in INI file. * Add they if cannot find. */ while (Msw_Std_Color[i].name != NULL) { if (!GetProfileString(szJedSection, Msw_Std_Color[i].name, "", buf, sizeof(buf))) msw_define_color(Msw_Std_Color[i].name, &Msw_Std_Color[i].r, &Msw_Std_Color[i].g, &Msw_Std_Color[i].b); i++; } i = 0; while (Msw_Ini_List[i].name != NULL) msw_get_default(&Msw_Ini_List[i++]); } static void get_dc(void) { if (!This_Window.ndc) { This_Window.hdc = GetDC(This_Window.w); #if HAS_PALETTE_CODE SelectPalette (This_Window.hdc, The_Hpalette, FALSE); #endif } This_Window.ndc++; } static void release_dc(void) { assert(This_Window.ndc); if (This_Window.ndc == 1) ReleaseDC(This_Window.w, This_Window.hdc); This_Window.ndc--; } void process_message(void) { MSG msg; if ( #ifdef _MSC_VER GetMessage(&msg, NULL, 0, 0) #else PeekMessage(&msg, NULL, 0, 0, PM_REMOVE) #endif ) { TranslateMessage(&msg); DispatchMessage(&msg); } } static void init_application(void) { WNDCLASS wc; wc.style = 0; wc.lpfnWndProc = JEDWndProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = hInstance; wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); wc.hCursor = LoadCursor(NULL, IDC_IBEAM); wc.hbrBackground = NULL; wc.lpszMenuName = NULL; wc.lpszClassName = "wjed"; RegisterClass(&wc); } static int select_font(char *fontname, int fontheight, int fontbold) { TEXTMETRIC tm; HFONT font; int height, weight; get_dc(); SetMapMode(This_Window.hdc, MM_TEXT); if (fontbold < 0) weight = FW_DONTCARE; else weight = fontbold > 0 ? FW_BOLD : FW_NORMAL; height = -MulDiv(fontheight, GetDeviceCaps(This_Window.hdc, LOGPIXELSY), 72); font = CreateFont(height, 0, 0, 0, weight, 0, 0, 0, JedCharSet, 0, 0, 0, FIXED_PITCH, fontname); if (font == NULL) { font = CreateFont(height, 0, 0, 0, weight, 0, 0, 0, DEFAULT_CHARSET, 0, 0, 0, FIXED_PITCH, fontname); } if (font == NULL) { /* This should never happen as we've told CreateFont to use the default */ /* character set if the requested one isn't available. */ jed_verror ("Unable to create instance of '%s' font", fontname); release_dc (); return -1; } if(This_Window.font != NULL) DeleteObject(This_Window.font); This_Window.font = font; This_Window.font_bold = fontbold; This_Window.font_height = fontheight; strncpy(This_Window.font_name, fontname, MAX_STRING_SIZE-1); This_Window.font_name[MAX_STRING_SIZE-1] = '\0'; /* retrieve font metrics (width and base) */ SelectObject(This_Window.hdc, This_Window.font); GetTextMetrics(This_Window.hdc, &tm); This_Window.font_width = tm.tmAveCharWidth; This_Window.font_height = tm.tmHeight; release_dc(); return 0; } static void init_instance (void) { int i; TEXTMETRIC tm; This_Window.hdc = NULL; This_Window.ndc = 0; for (i = 0; i < MAX_MENU_ID; i++) Menu_Callbacks[i] = NULL; InitPopup_Callback = NULL; msw_get_defaults(); /* Apparantly this is wrong */ /* if (This_Window.font_bold < 0) */ /* font_weight = FW_DONTCARE; */ /* else */ /* font_weight = (This_Window.font_bold > 0) ? FW_BOLD : FW_NORMAL; */ /* This_Window.font = CreateFont(-This_Window.font_height, 0, 0, 0, */ /* font_weight, */ /* 0, 0, 0, DEFAULT_CHARSET, 0, 0, 0, FIXED_PITCH, */ /* This_Window.font_name); */ #if !HAS_PALETTE_CODE for (i = 0; i < JMAX_COLORS; i++) JColors[i].hbrBG = CreateSolidBrush(JColors[i].bg); #endif msw_normal_video(); /* creating window */ This_Window.w = CreateWindow("wjed", This_Window.title, WS_OVERLAPPEDWINDOW, This_Window.x, This_Window.y, This_Window.width,This_Window.height, NULL, NULL, hInstance, NULL); get_dc(); #if HAS_PALETTE_CODE if ((RC_PALETTE & GetDeviceCaps (This_Window.hdc, RASTERCAPS)) && (NULL != (The_Lplgpl = malloc (sizeof(*The_Lplgpl) - sizeof(The_Lplgpl->palPalEntry) + 2*JMAX_COLORS * sizeof(PALETTEENTRY))))) { The_Lplgpl->palVersion = 0x300; The_Lplgpl->palNumEntries = JMAX_COLORS*2; for (i = 0; i < JMAX_COLORS; i++) { The_Lplgpl->palPalEntry[i*2].peRed = GetRValue (JColors[i].fg); The_Lplgpl->palPalEntry[i*2].peGreen = GetGValue (JColors[i].fg); The_Lplgpl->palPalEntry[i*2].peBlue = GetBValue (JColors[i].fg); The_Lplgpl->palPalEntry[i*2].peFlags = PC_NOCOLLAPSE; The_Lplgpl->palPalEntry[i*2+1].peRed = GetRValue (JColors[i].bg); The_Lplgpl->palPalEntry[i*2+1].peGreen = GetGValue (JColors[i].bg); The_Lplgpl->palPalEntry[i*2+1].peBlue = GetBValue (JColors[i].bg); The_Lplgpl->palPalEntry[i*2+1].peFlags = PC_NOCOLLAPSE; } The_Hpalette = CreatePalette (The_Lplgpl); if (The_Hpalette) { SelectPalette (This_Window.hdc, The_Hpalette, FALSE); RealizePalette (This_Window.hdc); } } /* ReleaseDC (This_Window.w, This_Window.hdc); */ for (i = 0; i < JMAX_COLORS; i++) JColors[i].hbrBG = CreateSolidBrush(JColors[i].bg); #endif /* HAS_PALETTE_CODE */ /* creating fonts, brushes etc */ (void) select_font (Font_Name, Font_Height, Font_Bold); #ifdef _MSC_VER SetTimer (This_Window.w, 43, 100, NULL); #endif /* function that will be called when jed exits (deletes fonts, brushes etc.) */ atexit(msw_cleanup); /* retrieve font metrics (width and base) */ /* get_dc(); */ SelectObject(This_Window.hdc, This_Window.font); GetTextMetrics(This_Window.hdc, &tm); This_Window.font_width = tm.tmAveCharWidth; This_Window.font_height = tm.tmHeight; release_dc(); ShowWindow(This_Window.w, SW_SHOW); UpdateWindow(This_Window.w); #if !defined(__WIN32__) || !JED_HAS_SUBPROCESSES SetTimer(This_Window.w, 42, 30000, NULL); /* used for updating display time */ #endif JedACP = GetACP(); } static int msw_init_term (void) { if (Batch) return 0; hInstance = _hInstance; hPrevInst = _hPrev; if (!hPrevInst) init_application(); init_instance(); return 0; } static void copy_rect(int x1, int y1, int x2, int y2, int x3, int y3) { int dx, dy; RECT rcSrc; dx = (x3 - x1) * This_Window.font_width; dy = (y3 - y1) * This_Window.font_height; SetRect(&rcSrc, x1 * This_Window.font_width, y1 * This_Window.font_height, x2 * This_Window.font_width, y2 * This_Window.font_height); ScrollWindow(This_Window.w, dx, dy, &rcSrc, NULL); #ifdef __WIN32__ UpdateWindow(This_Window.w); #endif } static void blank_rect(int x1, int y1, int x2, int y2) { char blanks[256]; memset (blanks, ' ', sizeof (blanks)); if (This_Window.cursor_showing) hide_cursor(); get_dc (); SelectObject(This_Window.hdc, This_Window.font); SetTextColor(This_Window.hdc, This_Window.current_color->fg); SetBkColor(This_Window.hdc, This_Window.current_color->bg); while (y1 < y2) { int n = x2 - x1; int xx = x1; while (n > 0) { int dn; if (n > (int) sizeof (blanks)) dn = sizeof (blanks); else dn = n; (void) TextOut(This_Window.hdc, xx * This_Window.font_width, y1 * This_Window.font_height, blanks, dn); n -= dn; xx += dn; } y1++; } release_dc (); #if 0 RECT rc; SetRect(&rc, x1 * This_Window.font_width, y1 * This_Window.font_height, x2 * This_Window.font_width, y2 * This_Window.font_height); get_dc(); FillRect(This_Window.hdc, &rc, CURRENT_BG_COLOR); release_dc(); #endif } static void msw_reverse_video(int color) { if ((color < 0) || (color >= JMAX_COLORS)) return; This_Window.current_color = &JColors[color]; } static int smg_read_at(int row, int col, SLsmg_Char_Type *s, unsigned int n) { int saverow, savecol; unsigned int rc; saverow = SLsmg_get_row(); savecol = SLsmg_get_column(); SLsmg_gotorc(row, col); rc = SLsmg_read_raw (s, n); SLsmg_gotorc(saverow, savecol); return rc; } static void _tt_writeW(WCHAR *s, int n, int color) { if (color < 0 || color > JMAX_COLORS) color = 0; get_dc(); SelectObject(This_Window.hdc, This_Window.font); SetTextColor(This_Window.hdc, JColors[color].fg); SetBkColor(This_Window.hdc, JColors[color].bg); TextOutW(This_Window.hdc, This_Window.cursor_col * This_Window.font_width, This_Window.cursor_row * This_Window.font_height, s, n); This_Window.cursor_col += n; if (This_Window.cursor_col >= MSW_Screen_Cols) This_Window.cursor_col = MSW_Screen_Cols - 1; release_dc(); } # define LEAD_OFFSET (0xD800 - (0x10000 >> 10)) static int decode_utf32 (unsigned int u, WCHAR *buf) { if (u < 0xFFFF) { *buf = u; return 1; } else { *(buf) = LEAD_OFFSET + (u >> 10); *(buf+1) = 0xDC00 + (u & 0x3FF); return 2; } } /* SLsmg_Char_Type decode/compare: the char internals changed for SLang2 */ #if SLANG_VERSION >= 20000 static int decode_smgchar(SLsmg_Char_Type *s, WCHAR *buf) { if (s->nchars > 0) return decode_utf32(s->wchars[0], buf); *buf = (WCHAR)' '; return 1; } # define SLSMGCHAR_EQUAL(o, n) \ ( ((o)->nchars == (n)->nchars) \ && ((o)->color == (n)->color) \ && (0 == memcmp((o)->wchars, (n)->wchars, (n)->nchars * sizeof(SLwchar_Type)))) # define SLSMGCHAR_SET_CHAR(sc, _char) do { (sc).nchars = 1; (sc).wchars[0] = (_char); } while (0) # define SLSMGCHAR_SET_COLOR(sc, _color) (sc).color = (_color) #else static int decode_smgchar(SLsmg_Char_Type *s, WCHAR *buf) { *buf = SLSMG_EXTRACT_CHAR(*s); return 1; } # define SLSMGCHAR_EQUAL(o, n) ((o) == (n)) # define SLSMGCHAR_SET_CHAR(sc, _char) (sc) = (sc) & 0xFF00 + (_char) # define SLSMGCHAR_SET_COLOR(sc, _color) (sc) = ((sc) & 0xFF) + ((_color)<<8) /* define this to allow using the same code for slang 1 */ # define SLSMG_COLOR_MASK 0xFF #endif /* SLANG_VERSION >= 20000 */ static void msw_write_smgchars(SLsmg_Char_Type *s, SLsmg_Char_Type *smax) { WCHAR buf[512]; WCHAR *b, *bmax; int oldcolor, color; b = buf; bmax = b + sizeof (buf)/sizeof(buf[0]); hide_cursor(); oldcolor = (SLSMG_EXTRACT_COLOR(*s) & SLSMG_COLOR_MASK); color = 0; get_dc(); for (; s < smax; s++) { color = (SLSMG_EXTRACT_COLOR(*s) & SLSMG_COLOR_MASK); if (oldcolor != color || b >= bmax-1) /* always leave room for 1 more 1 char (for surrogates) */ { _tt_writeW(buf, b - buf, oldcolor); b = buf; msw_reverse_video(color); oldcolor = color; } b += decode_smgchar(s, b); } if (b != buf) _tt_writeW(buf, b - buf, color); release_dc(); } static void msw_write_smgchar(SLsmg_Char_Type *s) { WCHAR buf[2]; int l; get_dc(); l = decode_smgchar(s, buf); _tt_writeW (buf, l, SLSMG_EXTRACT_COLOR(*s) & SLSMG_COLOR_MASK); release_dc(); } static void hide_cursor(void) { SLsmg_Char_Type sc; int col = This_Window.vis_curs_col, row = This_Window.vis_curs_row; int savecur; if (This_Window.cursor_showing == 0) return; This_Window.cursor_showing = 0; if (smg_read_at(row, col, &sc, 1) == 0) { SLSMGCHAR_SET_CHAR(sc, ' '); SLSMGCHAR_SET_COLOR(sc, JNORMAL_COLOR); } savecur = This_Window.cursor_col; msw_write_smgchar(&sc); This_Window.cursor_col = savecur; } static void show_cursor(void) { SLsmg_Char_Type sc; int color; if (This_Window.cursor_showing) hide_cursor(); This_Window.cursor_showing = 1; This_Window.vis_curs_row = This_Window.cursor_row; This_Window.vis_curs_col = This_Window.cursor_col; if (CBuf && CBuf->flags & OVERWRITE_MODE) color = JCURSOROVR_COLOR; else color = JCURSOR_COLOR; if (This_Window.focus) { int savecur; if (smg_read_at(This_Window.cursor_row, This_Window.cursor_col, &sc, 1) == 0) SLSMGCHAR_SET_CHAR(sc, ' '); SLSMGCHAR_SET_COLOR(sc, color); savecur = This_Window.cursor_col; msw_write_smgchar(&sc); This_Window.cursor_col = savecur; } else { RECT rc; rc.left = This_Window.cursor_col * This_Window.font_width; rc.top = This_Window.cursor_row * This_Window.font_height; rc.right = rc.left + This_Window.font_width; rc.bottom = rc.top + This_Window.font_height; get_dc(); FrameRect(This_Window.hdc, &rc, JColors[color].hbrBG); release_dc(); } } void sys_suspend(void) { ShowWindow(This_Window.w, SW_MINIMIZE); } void flush_output (void) { fflush (stdout); } /* Hooks */ static void msw_update_open (void) { hide_cursor (); Performing_Update = 1; } static void msw_update_close (void) { Performing_Update = 0; if (JWindow->trashed) return; show_cursor (); } static int msw_init_slang (void) { if ((-1 == SLadd_intrin_fun_table(Jed_WinGUI_Table, "WINGUI")) || (-1 == SLdefine_for_ifdef ("MOUSE"))) return -1; return 0; } static void msw_suspend (void) { WINDOWPLACEMENT wndpl; GetWindowPlacement(This_Window.w, &wndpl); if (wndpl.showCmd == SW_MINIMIZE) ShowWindow(This_Window.w, SW_NORMAL); else ShowWindow(This_Window.w, SW_MINIMIZE); } static void msw_define_xkeys (SLKeyMap_List_Type *map) { #if 0 /* This is set by doskeys.c */ SLkm_define_key ("^[Ow", (FVOID_STAR) bob, map); SLkm_define_key ("^[Oq", (FVOID_STAR) eob, map); #endif SLkm_define_key ("\xE0\xE0", (FVOID_STAR) ins_char_cmd, map); } /* This routine is called from S-Lang inner interpreter. It serves as a poor mans version of an interrupt 9 handler */ static void msw_check_kbd(void) { MSG msg; if (Batch) return; while (PeekMessage(&msg, 0, 0, 0, PM_NOREMOVE)) process_message(); } /* Terminal functions */ static void msw_goto_rc(int r, int c) { get_dc(); if (This_Window.cursor_showing) hide_cursor(); r += This_Window.scroll_r1; if (r >= MSW_Screen_Rows) r = MSW_Screen_Rows - 1; if (c >= MSW_Screen_Cols) c = MSW_Screen_Cols - 1; This_Window.cursor_row = r; This_Window.cursor_col = c; if (!Performing_Update) show_cursor(); release_dc(); } static void msw_del_eol(void) { blank_rect(This_Window.cursor_col, This_Window.cursor_row, MSW_Screen_Cols, This_Window.cursor_row + 1); } static void msw_delete_nlines(int n) { int r1, r2; r1 = This_Window.cursor_row; r2 = This_Window.scroll_r2; if (r1 <= r2 - n) copy_rect(0, r1 + n, MSW_Screen_Cols, r2 + 1, 0, r1); r2++; blank_rect(0, r2 - n, MSW_Screen_Cols, r2); } #if 0 /* UNUSED */ static void msw_delete_char(void) { copy_rect(This_Window.cursor_col + 1, This_Window.cursor_row, MSW_Screen_Cols, This_Window.cursor_row + 1, This_Window.cursor_col, This_Window.cursor_row); } static void msw_erase_line(void) { blank_rect(0, This_Window.cursor_row, MSW_Screen_Cols, This_Window.cursor_row + 1); } static void msw_begin_insert(void) { hide_cursor(); copy_rect(This_Window.cursor_col, This_Window.cursor_row, MSW_Screen_Cols - 1, This_Window.cursor_row + 1, This_Window.cursor_col + 1, This_Window.cursor_row); } static void msw_end_insert(void) { } /* This function is called assuming that cursor is in correct position */ static void msw_putchar(char ch) { if (ch == '\b') { ch = ' '; if (This_Window.cursor_col == 0) return; This_Window.cursor_col--; } get_dc(); if (Rev_Vid_Flag != JNORMAL_COLOR) msw_normal_video(); tt_write(&ch, 1); show_cursor (); release_dc(); } #endif /* UNUSED */ static void msw_normal_video(void) { msw_reverse_video (JNORMAL_COLOR); } static void msw_cls(void) { RECT rc; get_dc(); GetClientRect(This_Window.w, &rc); FillRect(This_Window.hdc, &rc, CURRENT_BG_COLOR); release_dc(); /* Unfortunately the background color produced by FillRect is slightly different * from the desired background. So patch it up with blank_rect. */ blank_rect (0, 0, MSW_Screen_Cols, MSW_Screen_Rows); } static void msw_beep(void) { if (MSW_Ignore_Beep & 0x1) MessageBeep(0); if (MSW_Ignore_Beep & 0x2) { RECT rc; get_dc(); GetClientRect(This_Window.w, &rc); InvertRect(This_Window.hdc, &rc); release_dc(); InvalidateRect(This_Window.w, NULL, TRUE); #ifdef __WIN32__ UpdateWindow(This_Window.w); #endif } } static void msw_reverse_index(int n) { int r1, r2; r1 = This_Window.scroll_r1; r2 = This_Window.scroll_r2; if (r2 >= r1 + n) copy_rect(0, r1, MSW_Screen_Cols, r2 - n + 1, 0, r1 + n); blank_rect(0, r1, MSW_Screen_Cols, r1 + n); } static void msw_write_string (char *s) { get_dc(); /* tt_write(s, strlen(s)); */ if (!Performing_Update) show_cursor (); release_dc(); } static void msw_smart_puts(SLsmg_Char_Type *neww, SLsmg_Char_Type *oldd, int len, int row) { int col; col = 0; while ((col < len) && SLSMGCHAR_EQUAL(&neww[col], &oldd[col])) col++; if (col < len) { msw_goto_rc (row, col); msw_write_smgchars(&neww[col], &neww[len]); } } static void msw_set_scroll_region(int r1, int r2) { This_Window.scroll_r1 = r1; This_Window.scroll_r2 = r2; } static void msw_reset_scroll_region (void) { msw_set_scroll_region (0, MSW_Screen_Cols - 1); } static int msw_reset_video (void) { msw_reset_scroll_region (); msw_goto_rc (0, 0); msw_normal_video (); return 0; } static int msw_init_video (void) { msw_reset_video (); if ((MSW_Screen_Rows == 0) || (MSW_Screen_Cols == 0)) { MSW_Screen_Cols = 80; MSW_Screen_Rows = 24; } return 0; } static int msw_flush_output (void) { return 0; } static char *convert_color (char *c, char *buf) { unsigned long ul; if ((*c != '#') || (7 != strlen (c))) /* e.g., #RRGGBB */ return c; if (1 != sscanf (c+1, "%lX", &ul)) return c; if (ul > 0xFFFFFFUL) return c; sprintf (buf, "%ld,%ld,%ld", (ul >> 16)&0xFF, (ul >> 8)&0xFF, ul & 0xFF); return buf; } static JX_SETXXX_RETURN_TYPE msw_set_color (int i, char *what, char *fg, char *bg) { int r, g, b; char buf[64]; char fg_buf[64]; char bg_buf[64]; HBRUSH bgbr; if ((i < 0) || (i > JMAX_COLORS)) return JX_SETXXX_RETURN_VAL; (void) what; fg = convert_color (fg, fg_buf); bg = convert_color (bg, bg_buf); r = GetRValue(JColors[i].fg); g = GetGValue(JColors[i].fg); b = GetBValue(JColors[i].fg); sprintf(buf, "%d,%d,%d", r, g, b); JColors[i].fg = msw_get_color(fg, buf); r = GetRValue(JColors[i].bg); g = GetGValue(JColors[i].bg); b = GetBValue(JColors[i].bg); sprintf(buf, "%d,%d,%d", r, g, b); JColors[i].bg = msw_get_color(bg, buf); #if HAS_PALETTE_CODE if (The_Hpalette) { The_Lplgpl->palPalEntry[i*2].peRed = GetRValue (JColors[i].fg); The_Lplgpl->palPalEntry[i*2].peGreen = GetGValue (JColors[i].fg); The_Lplgpl->palPalEntry[i*2].peBlue = GetBValue (JColors[i].fg); The_Lplgpl->palPalEntry[i*2].peFlags = PC_NOCOLLAPSE; The_Lplgpl->palPalEntry[i*2+1].peRed = GetRValue (JColors[i].bg); The_Lplgpl->palPalEntry[i*2+1].peGreen = GetGValue (JColors[i].bg); The_Lplgpl->palPalEntry[i*2+1].peBlue = GetBValue (JColors[i].bg); The_Lplgpl->palPalEntry[i*2+1].peFlags = PC_NOCOLLAPSE; SetPaletteEntries (The_Hpalette, i*2, 2, The_Lplgpl->palPalEntry+i*2); get_dc(); SelectPalette (This_Window.hdc, The_Hpalette, FALSE); RealizePalette (This_Window.hdc); release_dc(); } #endif bgbr = CreateSolidBrush(JColors[i].bg); if (bgbr != 0) { DeleteObject(JColors[i].hbrBG); JColors[i].hbrBG = bgbr; } #if SLANG_VERSION >= 10306 SLsmg_touch_screen (); #endif return JX_SETXXX_RETURN_VAL; /* InvalidateRect(This_Window.w, NULL, FALSE); */ } static void cover_exposed_area (int x, int y, int width, int height) { SLsmg_Char_Type *s; int row, save_row, save_col, max_col, max_row, col; int width_chars, len; Performing_Update++; hide_cursor (); save_row = This_Window.cursor_row; save_col = This_Window.cursor_col; col = x / This_Window.font_width; row = y / This_Window.font_height; width_chars = 2 + width / This_Window.font_width; max_col = col + width_chars; max_row = 2 + row + height / This_Window.font_height; if (max_col > MSW_Screen_Cols) max_col = MSW_Screen_Cols; if (max_row > MSW_Screen_Rows) max_row = MSW_Screen_Rows; if (NULL == (s = (SLsmg_Char_Type *)SLmalloc(width_chars*sizeof(*s)))) goto done; while (row < max_row) { msw_goto_rc (row, col); len = smg_read_at(row, col, s, width_chars); msw_write_smgchars(s, s + len); row++; } SLfree((char *)s); msw_goto_rc (save_row, save_col); done: Performing_Update--; show_cursor (); } static void push_mouse_event(int button, int x, int y, int state, int type) { unsigned int s = 0; int col, row; static int last_button; static JMouse_Type jm; #if JED_HAS_MULTICLICK static long last_press_time; static unsigned int clicks = 0; static long MultiClick_Time = -1; #endif int id; col = 1 + x / This_Window.font_width; row = 1 + y / This_Window.font_height; if ((type == JMOUSE_DRAG) && (col == jm.x) && (row == jm.y)) return; if (button == 0) button = last_button; else last_button = button; #if JED_HAS_MULTICLICK if (type == JMOUSE_DOWN) { long the_time = GetTickCount(); if (MultiClick_Time == -1) MultiClick_Time = GetDoubleClickTime(); if ((last_button == button) && (the_time - last_press_time < MultiClick_Time)) { clicks++; if (clicks == 2) type = JMOUSE_DOUBLE_CLICK; else type = JMOUSE_TRIPLE_CLICK; } else { clicks = 1; last_button = button; } last_press_time = the_time; } else if ((clicks > 1) && (last_button == button)) { /* Last was a multi-click. Ignore this event. */ type = JMOUSE_IGNORE_EVENT; } #endif jm.button = button; if ((type == JMOUSE_UP) && (0 == (jm.state & jm.button))) { /* Make sure this button was down. */ return; } if (state & MK_LBUTTON) s |= JMOUSE_BUTTON_1; if (state & MK_MBUTTON) s |= JMOUSE_BUTTON_2; if (state & MK_RBUTTON) s |= JMOUSE_BUTTON_3; if (state & MK_CONTROL) s |= JMOUSE_CTRL; if (state & MK_SHIFT) s |= JMOUSE_SHIFT; jm.state = s; jm.x = col; jm.y = row; jm.type = type; if (-1 == (id = jed_mouse_add_event (&jm))) { msg_error ("Failed!"); return; } send_key_sequence(3, 033, 0, id, 0); } static void push_wm_mouse_event (int button, int x, int y, int state, int type) { switch (button) { case WM_LBUTTONUP: case WM_LBUTTONDOWN: if (!(GetKeyState(VK_MENU) & 0x8000)) { button = JMOUSE_BUTTON_1; break; } /* drop */ case WM_MBUTTONUP: case WM_MBUTTONDOWN: button = JMOUSE_BUTTON_2; break; case WM_RBUTTONUP: case WM_RBUTTONDOWN: button = JMOUSE_BUTTON_3; break; default: return; } push_mouse_event (button, x, y, state, type); } static void msw_define_color(char *color_name, int *pr, int *pg, int *pb) { char buf[30]; sprintf(buf, "%d,%d,%d", *pr, *pg, *pb); WriteProfileString(szJedSection, color_name, buf); } static void msw_select_font (char *fontname, int *height, int *bold) { if (0 == select_font (fontname, *height, *bold)) { jed_init_display (); jed_redraw_screen (1); /* update font data, As I need it if the user changes Language */ strcpy(Font_Name, fontname); Font_Height = *height; Font_Bold = *bold; return; } jed_verror ("Unable to allocate font %s", fontname); } static void set_window_name (char *s) { if (Batch) return; strcpy(This_Window.title, s); SetWindowText(This_Window.w, s); } static void msw_cleanup(void) { int i; char buf[10]; RECT rc; GetWindowRect(This_Window.w, &rc); sprintf(buf, "%d", (int) rc.left); WriteProfileString(szJedSection, "X", buf); sprintf(buf, "%d", (int) rc.top); WriteProfileString(szJedSection, "Y", buf); sprintf(buf, "%d", (int) (rc.right - rc.left)); WriteProfileString(szJedSection, "Width", buf); sprintf(buf, "%d", (int) (rc.bottom - rc.top)); WriteProfileString(szJedSection, "Height", buf); KillTimer(This_Window.w, 42); #ifdef _MSC_VER KillTimer (This_Window.w, 43); #endif if (This_Window.w) DestroyWindow(This_Window.w); DeleteObject(This_Window.font); for(i = 0; i < JMAX_COLORS; i++) if (JColors[i].hbrBG) DeleteObject(JColors[i].hbrBG); } #if !defined(__WIN32__) || !JED_HAS_SUBPROCESSES int sys_input_pending(int *tsecs, int unused) { DWORD t = GetTickCount() + *tsecs * 100L; (void) unused; while ((!Input_Buffer_Len) && (GetTickCount() < t)) process_message(); return Input_Buffer_Len != 0; } unsigned char sys_getkey(void) { int n; while (!SLKeyBoard_Quit && !Input_Buffer_Len) process_message (); if (SLKeyBoard_Quit) { SLKeyBoard_Quit = 0; flush_input (); return Jed_Abort_Char; } n = my_getkey(); SLKeyBoard_Quit = 0; return n; } #else int sys_input_pending(int *tsecs, int all) { DWORD ret = 0; int i, n; if ((all >= 0) && (Input_Buffer_Len || Batch)) return (Input_Buffer_Len); if (all < 0) { /* Note: Input_Events[0] is only used by console jed. */ ret = WaitForMultipleObjects(Num_Subprocesses, Input_Events+1, FALSE, *tsecs * 100); } else { DWORD t; long rtime = *tsecs * 100L; msw_check_kbd (); while ((rtime > 0) && !Input_Buffer_Len) { t = GetTickCount(); ret = MsgWaitForMultipleObjects(Num_Subprocesses, Input_Events+1, FALSE, rtime, QS_ALLINPUT); if ((DWORD)(WAIT_OBJECT_0 + Num_Subprocesses) != ret) break; msw_check_kbd (); rtime -= GetTickCount() - t; } if ((rtime < 0) || Input_Buffer_Len) return Input_Buffer_Len; } if (WAIT_TIMEOUT == ret) return 0; n = 0; i = 1; /* First input event is not used by wjed. Start at 1. */ while (i <= Num_Subprocesses) { /* Check if current subprocess has input */ if (WAIT_TIMEOUT != WaitForSingleObject(Input_Events[i], 0)) { read_process_input (i); n++; } i++; } if (all < 0) return n; else return 0; } unsigned char sys_getkey(void) { int n = 450; /* sleep for 45 second and try again */ while (!SLKeyBoard_Quit && !sys_input_pending(&n, Num_Subprocesses)) { /* update status line incase user is displaying time */ if (SLKeyBoard_Quit) break; JWindow->trashed = 1; update((Line *) NULL, 0, 1, 0); } if (SLKeyBoard_Quit) { SLKeyBoard_Quit = 0; flush_input (); return Jed_Abort_Char; } return my_getkey(); } #endif static int Ignore_Wchar_Message; static unsigned char f_keys[4][12] = { { 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 133, 134 }, { 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 135, 136 }, { 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 137, 138 }, { 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 139, 140 } }; static unsigned char small_keypad_keys[4][13] = { { 'G', 'H', 'I', 0, 'K', 0, 'M', 0, 'O', 'P', 'Q', 'R', 'S' }, /* normal */ { '0', '1', '2', 0, '3', 0, '4', 0, '5', '6', '7', '8', '9' }, /* shift */ { 'w', 141, 132, 0, 's', 0, 't', 0, 'u', 145, 'v', 146, 147 }, /* ctrl */ { 151, 152, 153, 0, 155, 0, 157, 0, 159, 160, 161, 162, 163 } /* alt */ }; static unsigned char num_keypad_keys[4][13] = { { 'w', 'x', 'y', 0, 't', 'u', 'v', 0, 'q', 'r', 's', 'p', 'n' }, { '0', '1', '2', 0, '3', 0 , '4', 0, '5', '6', '7', '8', '9' }, { 'w', 141, 132, 0, 's', 143, 't', 0, 'u', 145, 'v', 146, 147 }, { 'w', 'x', 'y', 0, 't', 'u', 'v', 0, 'q', 'r', 's', 'p', 'n' } }; static LRESULT CALLBACK process_key_down (HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { unsigned int key_state = 0; unsigned int scan; unsigned char prefix, c1; int i, state; if (GetKeyState(VK_CONTROL) & 0x8000) key_state |= KEY_CONTROL; if (GetKeyState(VK_SHIFT) & 0x8000) key_state |= KEY_SHIFT; if (GetKeyState(VK_MENU) & 0x8000) key_state |= KEY_ALT; Ignore_Wchar_Message = 0; scan = (unsigned int) ((lParam >> 16) & 0x1FF); switch (scan) { default: return DefWindowProc(hWnd, msg, wParam, lParam); case 0x00E: /* backspace */ /* Ctrl-BS --> ALT-@ * Shift-BS --> ALT-? * BS --> ^? */ if ((key_state & KEY_ALT) == 0) { if ((key_state & KEY_CONTROL) != 0) send_key_sequence(2, PC_Alt_Char, '@', 0, 0); else if ((key_state & KEY_SHIFT) != 0) send_key_sequence(2, PC_Alt_Char, '?', 0, 0); else send_key_sequence(1, 127, 0, 0, 0); } Ignore_Wchar_Message = 1; return 0; case 0x039: /* space */ if (key_state & KEY_CONTROL) { Ignore_Wchar_Message = 1; buffer_keystring ("\000\003", 2); } return 0; case 0x003: /* 2 key */ if (((key_state & KEY_ALT) == 0) && (key_state & KEY_CONTROL)) { Ignore_Wchar_Message = 1; buffer_keystring ("\000\003", 2); return 0; } return DefWindowProc(hWnd, msg, wParam, lParam); case 0x00C: /* -/_ key */ if (((key_state & KEY_ALT) == 0) && (key_state & KEY_CONTROL)) { Ignore_Wchar_Message = 1; send_key_sequence(1, 31, 0, 0, 0); /* ^_ */ return 0; } return DefWindowProc(hWnd, msg, wParam, lParam); /* PF1 and PF2 codes */ /* case 0x0045: */ case 0x0145: if (NumLock_Is_Gold) { #if 0 /* does not work on xp */ BYTE keyState[256]; /* toggle the caps-lock state */ GetKeyboardState(keyState); keyState[VK_NUMLOCK] = 0;/*keyState[VK_NUMLOCK]^1;*/ SetKeyboardState(keyState); #endif buffer_keystring ("\033OP", 3); Ignore_Wchar_Message = 1 ; return 0 ; } return DefWindowProc(hWnd, msg, wParam, lParam); case 0x0135: c1 = 'Q'; break ; case 0xE02F: c1 = 'Q'; break; /* KEYPAD SLASH */ case 0x037: /* KEYPAD STAR */ c1 = 'R'; break; case 0x04A: /* KEYPAD MINUS */ c1 = 'S'; break; case 0x04E: /* KEYPAD PLUS */ c1 = 'm'; break; case 0x047: /* KEYPAD HOME */ case 0x048: /* KEYPAD UP */ case 0x049: /* KEYPAD PGUP */ case 0x04B: /* KEYPAD LEFT */ case 0x04C: /* KEYPAD 5 */ case 0x04D: /* KEYPAD RIGHT */ case 0x04F: /* KEYPAD END */ case 0x050: /* KEYPAD DOWN */ case 0x051: /* KEYPAD PGDN */ case 0x053: /* KEYPAD DEL */ case 0x052: /* KEYPAD INSERT */ if (!NumLock_Is_Gold && (GetKeyState(VK_NUMLOCK) & 0x0001)) return DefWindowProc(hWnd, msg, wParam, lParam); state = 0; if (key_state & KEY_SHIFT) state = 1; if (key_state & KEY_CONTROL) state = 2; if (key_state & KEY_ALT) state = 3; if (key_state & (KEY_CONTROL | KEY_ALT)) { Ignore_Wchar_Message = 1; send_key_sequence(2, 0, num_keypad_keys[state][scan - 0x47], 0, 0); return 0; } else c1 = num_keypad_keys[state][scan - 0x47]; break; case 0x11C: /* KEYPAD ENTER */ if (key_state & KEY_ALT) { send_key_sequence(2, 0, 166, 0, 0); Ignore_Wchar_Message = 1; return 0; } else { c1 = 'M'; break; } case 0x147: /* home */ case 0x148: /* UP */ case 0x149: /* PGUP */ case 0x14B: /* LEFT */ case 0x14D: /* RIGHT */ case 0x14F: /* END */ case 0x150: /* DOWN */ case 0x151: /* PGDN */ case 0x153: /* DEL */ case 0x152: /* INSERT */ prefix = 0xE0; state = 0; if (key_state & KEY_SHIFT) state = 1; if (key_state & KEY_CONTROL) state = 2; if (key_state & KEY_ALT) { prefix = 0; state = 3; } send_key_sequence(2, prefix, small_keypad_keys[state][scan - 0x147], 0, 0); Ignore_Wchar_Message = 1; return 0; case 0x3b: /* F1 */ case 0x3c: case 0x3d: case 0x3e: case 0x3f: case 0x40: case 0x41: case 0x42: case 0x43: case 0x44: case 0x57: case 0x58: /* F12 */ i = scan - 0x3b; if (i > 9) i -= 0x12; state = 0; if (key_state & KEY_SHIFT) state = 1; if (key_state & KEY_CONTROL) state = 2; if (key_state & KEY_ALT) { if (i == 3) /* Alt-F4 */ return DefWindowProc(hWnd, msg, wParam, lParam); else state = 3; } send_key_sequence(2, PC_Fn_Char, f_keys[state][i], 0, 0); Ignore_Wchar_Message = 1; return 0; } send_key_sequence(3, 033, 'O', c1, 0); Ignore_Wchar_Message = 1; return 0; } static int load_dropped_files(HDROP hDrop, HWND hwnd) { char szFilename[JED_MAX_PATH_LEN]; int iNumFiles; (void) hwnd; iNumFiles = DragQueryFile (hDrop, 0xFFFFFFFF, NULL, JED_MAX_PATH_LEN-1); while(--iNumFiles>=0) { DragQueryFile(hDrop, iNumFiles, szFilename, JED_MAX_PATH_LEN-1); (void) find_file_in_window(szFilename); window_buffer(CBuf); jed_redraw_screen (1); } DragFinish(hDrop); return 0; } LRESULT CALLBACK JEDWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { static int mouse_button_down; PAINTSTRUCT ps; RECT rc; switch (msg) { case WM_INPUTLANGCHANGE: { CHARSETINFO csi; JedCharSet = wParam; TranslateCharsetInfo((DWORD *)wParam, &csi, TCI_SRCCHARSET); JedACP = csi.ciACP; (void) msw_select_font (Font_Name, &Font_Height, &Font_Bold); } return 0; case WM_CREATE: This_Window.w = hWnd; DragAcceptFiles (hWnd, TRUE); mouse_button_down = 0; return 0; case WM_DROPFILES: (void) load_dropped_files ((HANDLE) wParam, hWnd); return 0; case WM_SIZE: if (wParam != SIZE_MINIMIZED) { This_Window.width = LOWORD(lParam); This_Window.height = HIWORD(lParam); jed_init_display (); jed_redraw_screen (1); } break; case WM_PAINT: BeginPaint(This_Window.w, &ps); #if HAS_PALETTE_CODE if (NULL != The_Hpalette) SelectPalette (ps.hdc, The_Hpalette, FALSE); #endif This_Window.hdc = ps.hdc; This_Window.ndc = 1; cover_exposed_area(ps.rcPaint.left, ps.rcPaint.top, ps.rcPaint.right - ps.rcPaint.left, ps.rcPaint.bottom - ps.rcPaint.top); EndPaint(This_Window.w, &ps); This_Window.hdc = NULL; This_Window.ndc = 0; break; #if HAS_PALETTE_CODE case WM_PALETTECHANGED: if (wParam != This_Window.w && The_Hpalette != NULL) { get_dc(); UpdateColors (This_Window.hdc); release_dc(); } break; case WM_QUERYNEWPALETTE: if (The_Hpalette != NULL) { get_dc(); RealizePalette (This_Window.hdc); release_dc(); } break; #endif case WM_ERASEBKGND: GetClientRect(This_Window.w, &rc); FillRect((HDC)wParam, &rc, CURRENT_BG_COLOR); break; case WM_SYSCHAR: _putkey(PC_Alt_Char); if (PC_Alt_Char != 0) _putkey (wParam); else _putkey((lParam >> 16) & 0x1FF);/* was: _putkey(wParam); */ return MAKELONG(0, 1); case WM_CHAR: if (Ignore_Wchar_Message == 0) { if ((int) wParam == (int) Jed_Abort_Char) { if (Ignore_User_Abort == 0) SLang_set_error(USER_BREAK); SLKeyBoard_Quit = 1; } /* PS 28Apr98: handle shiftTAB same as DOS */ if (wParam == 0x009) { if (GetKeyState(VK_SHIFT)<0) { send_key_sequence(2, 0, 'o' & 31, 0, 0); Ignore_Wchar_Message = 1; break; } } if (!wjed_has_unicode()) _putkey(wParam); else { static char dbcsbuf[3] = ""; WCHAR buf[10]; int i, buflen = 10; int dbcsl; /* Here I get ANSI characters, but _putkey() wants UTF-16. */ if (!dbcsbuf[0] && IsDBCSLeadByte((unsigned char)wParam)) { dbcsbuf[0] = (char)wParam; break; } dbcsl = 1; if (dbcsbuf[0]) { dbcsbuf[1] = (unsigned char) wParam; dbcsl = 2; } else { dbcsbuf[0] = (unsigned char) wParam; } dbcsbuf[2] = 0; buflen = MultiByteToWideChar(JedACP, 0, dbcsbuf, dbcsl, buf, buflen); for (i = 0; i < buflen; i++) _putkey(buf[i]); dbcsbuf[0] = 0; } break; } return DefWindowProc(hWnd, msg, wParam, lParam); case WM_SYSKEYDOWN: case WM_KEYDOWN: return process_key_down (hWnd, msg, wParam, lParam); case WM_KEYUP: Ignore_Wchar_Message = 0; break; case WM_SYSKEYUP: Ignore_Wchar_Message = 0; return DefWindowProc(hWnd, msg, wParam, lParam); case WM_LBUTTONUP: case WM_MBUTTONUP: case WM_RBUTTONUP: if (!mouse_button_down) break; push_wm_mouse_event(msg, LOWORD(lParam), HIWORD(lParam), wParam, JMOUSE_UP); mouse_button_down--; break; case WM_LBUTTONDOWN: case WM_MBUTTONDOWN: case WM_RBUTTONDOWN: mouse_button_down++; push_wm_mouse_event(msg, LOWORD(lParam), HIWORD(lParam), wParam, JMOUSE_DOWN); break; case WM_MOUSEMOVE: if (wParam & (MK_LBUTTON | MK_MBUTTON | MK_RBUTTON)) push_mouse_event(0, LOWORD(lParam), HIWORD(lParam), wParam, JMOUSE_DRAG); break; case WM_SETFOCUS: case WM_KILLFOCUS: hide_cursor(); This_Window.focus = (msg == WM_SETFOCUS); show_cursor(); break; #if 0 /* This does not quite work when coming back from a shell */ case WM_ACTIVATE: if ((wParam != WA_INACTIVE) && (CBuf != NULL)) check_buffers(); break; #endif case WM_CLOSE: jed_exit_jed(1); break; #if !defined(__WIN32__) || !JED_HAS_SUBPROCESSES case WM_TIMER: if ((wParam == 42) && Display_Time) { JWindow->trashed = 1; update((Line *) NULL, 0, 1, 0); } return 0; #endif #if defined(_MSC_VER) && JED_HAS_SUBPROCESSES case WM_TIMER: /* * just stop the GetMessage call... */ return 0; #endif case WM_COMMAND: if (wParam < MAX_MENU_ID) { int force = 1; if (Menu_Callbacks[wParam]) { if (is_internal(Menu_Callbacks[wParam])) { char buf[512]; SLsnprintf(buf, sizeof (buf), ". \"%s\" call", Menu_Callbacks[wParam]); SLang_load_string (buf); } else if (SLang_execute_function(Menu_Callbacks[wParam]) == 0) msg_error(Menu_Callbacks[wParam]); } update_cmd(&force); } return 0; case WM_INITMENUPOPUP: SLang_push_integer(wParam); if (InitPopup_Callback != NULL) if (SLang_execute_function(InitPopup_Callback) == 0) msg_error(InitPopup_Callback); return 0; default: #if HAS_WHEEL_MOUSE_SUPPORT /* Check for a mouse wheel movement message * and translate it into a fake keystroke. This has now been * tested on Win95,98,NT4,2000 */ if ((Wheel_Mouse.fActive && (msg == Wheel_Mouse.uiMshMsgMouseWheel)) || (msg == WM_MOUSEWHEEL)) { /* Under X, the wheel mouse produces JMOUSE_BUTTON_4 and * JMOUSE_BUTTON_5 events. jed/lib/mouse.sl maps JMOUSE_BUTTON_4 * events to upward movement and JMOUSE_BUTTON_5 to downward * movement in the buffer. */ if ((int) wParam < 0) push_mouse_event (JMOUSE_BUTTON_5, LOWORD(lParam), HIWORD(lParam), wParam, JMOUSE_DOWN); else push_mouse_event (JMOUSE_BUTTON_4, LOWORD(lParam), HIWORD(lParam), wParam, JMOUSE_DOWN); return 0; } #endif return DefWindowProc(hWnd, msg, wParam, lParam); } return 0; } static int pop_hmenu (HMENU *h) { int i; if (-1 == SLang_pop_integer (&i)) return -1; *h = (HMENU) i; return 0; } static int push_hmenu (HMENU h) { return SLang_push_integer ((int) h); } void get_menubar() { HMENU hmenu = GetMenu(This_Window.w); if (!hmenu) { hmenu = CreateMenu(); SetMenu(This_Window.w, hmenu); DrawMenuBar(This_Window.w); } (void) push_hmenu (hmenu); } void destroy_menubar() { int i; HMENU hmenu = GetMenu(This_Window.w); if (hmenu) { SetMenu(This_Window.w, NULL); DestroyMenu(hmenu); } for(i = 0; i < MAX_MENU_ID; i++) Menu_Callbacks[i] = NULL; } void create_popup_menu() { HMENU hmenu = CreatePopupMenu(); (void) push_hmenu (hmenu); } void destroy_menu() { HMENU hmenu; int count, i; int id; if (0 == pop_hmenu (&hmenu)) { count = GetMenuItemCount(hmenu); for(i = 0; i < count; i++) { id = GetMenuItemID(hmenu, i); if (id > 0 && Menu_Callbacks[id] != NULL) { SLfree(Menu_Callbacks[id]); Menu_Callbacks[id] = NULL; } } if (!DestroyMenu(hmenu)) msg_error("Cannot destroy menu"); } } void append_menu_item() { HMENU hmenu; char *name = NULL; char *callback = NULL; int id; if (!SLpop_string(&callback) && !SLang_pop_integer(&id) && !SLpop_string(&name) && !pop_hmenu (&hmenu)) { if ((id < 0) || (id >= MAX_MENU_ID)) msg_error("Id is out of range."); else { if (!AppendMenu(hmenu, MF_STRING, id, name)) msg_error("Cannot append menu item"); else { if (Menu_Callbacks[id] != NULL) { jed_verror ("Id %d is already used.", id); } else { Menu_Callbacks[id] = callback; callback = NULL; } } } } if (name != NULL) SLfree(name); if (callback != NULL) SLfree(callback); } void append_popup_menu() { HMENU hmenu; char *name = NULL; HMENU popup; if (!pop_hmenu(&popup) && !SLpop_string (&name) && !pop_hmenu(&hmenu)) { if (!AppendMenu(hmenu, MF_STRING | MF_POPUP, (UINT)popup, name)) msg_error("Cannot append popup menu"); } if (name != NULL) SLfree(name); } void append_separator() { HMENU hmenu; if (!pop_hmenu (&hmenu)) { if (!AppendMenu(hmenu, MF_STRING | MF_SEPARATOR, 0, 0)) msg_error("Cannot append separator"); } } void insert_menu_item() { HMENU hmenu; int id; char *name = NULL; int idNew; char *callback = NULL; if (!SLpop_string(&callback) && !SLang_pop_integer(&idNew) && !SLpop_string(&name) && !SLang_pop_integer(&id) && !pop_hmenu(&hmenu)) { if ((idNew < 0) || (idNew >= MAX_MENU_ID)) msg_error("Id is out of range"); else { if (!InsertMenu(hmenu, id, MF_STRING | MF_BYCOMMAND, idNew, name)) msg_error("Cannot insert menu item"); else { if (Menu_Callbacks[idNew] != NULL) { jed_verror ("Id %d is already used.", idNew); } else { Menu_Callbacks[idNew] = callback; callback = NULL; } } } } if (name != NULL) SLfree(name); if (callback != NULL) SLfree(callback); } void insert_popup_menu() { HMENU hmenu; int id; char *name = NULL; HMENU popup; if (!pop_hmenu(&popup) && !SLpop_string (&name) && !SLang_pop_integer(&id) && !pop_hmenu(&hmenu)) { if (!InsertMenu(hmenu, id, MF_STRING | MF_POPUP | MF_BYCOMMAND, (UINT)popup, name)) msg_error("Cannot insert popup menu"); } if (name != NULL) SLfree (name); } void insert_separator() { HMENU hmenu; int id; if (!SLang_pop_integer(&id) && !pop_hmenu (&hmenu)) { if (!InsertMenu(hmenu, id, MF_STRING | MF_SEPARATOR | MF_BYCOMMAND, 0, 0)) msg_error("Cannot insert separator"); } } void insert_menu_item_pos() { HMENU hmenu; int pos; char *name = NULL; int idNew; char *callback = NULL; if (!SLpop_string(&callback) && !SLang_pop_integer(&idNew) && !SLpop_string(&name) && !SLang_pop_integer(&pos) && !pop_hmenu(&hmenu)) { if ((idNew < 0) || (idNew >= MAX_MENU_ID)) msg_error("Id is out of range."); else { if (!InsertMenu(hmenu, pos, MF_STRING | MF_BYPOSITION, idNew, name)) msg_error("Cannot insert menu item"); else { if (Menu_Callbacks[idNew] != NULL) { jed_verror ("Id %d is already used.", idNew); } else { Menu_Callbacks[idNew] = callback; callback = NULL; } } } } if (name != NULL) SLfree(name); if (callback != NULL) SLfree(callback); } void insert_popup_menu_pos() { HMENU hmenu; int pos; char *name = NULL; HMENU popup; if (!pop_hmenu(&popup) && !SLpop_string(&name) && !SLang_pop_integer(&pos) && !pop_hmenu(&hmenu)) { if (!InsertMenu(hmenu, pos, MF_STRING | MF_POPUP | MF_BYPOSITION, (UINT)popup, name)) msg_error("Cannot insert popup menu"); } if (name != NULL) SLfree(name); } void insert_separator_pos() { HMENU hmenu; int pos; if (!SLang_pop_integer(&pos) && !pop_hmenu(&hmenu)) { if (!InsertMenu(hmenu, pos, MF_STRING | MF_SEPARATOR | MF_BYPOSITION, 0, 0)) msg_error("Cannot insert separator"); } } void delete_menu_item() { HMENU hmenu; int id; if (!SLang_pop_integer(&id) && !pop_hmenu(&hmenu)) { if ((id < 0) || (id >= MAX_MENU_ID)) { msg_error("Id is out of range."); return; } if (!DeleteMenu(hmenu, id, MF_BYCOMMAND)) msg_error("Cannot delete menu"); else { if (Menu_Callbacks[id]) { SLfree(Menu_Callbacks[id]); Menu_Callbacks[id] = NULL; } } } } void delete_menu_item_pos() { HMENU hmenu, popup; int pos; int id; if (!SLang_pop_integer(&pos) && !pop_hmenu(&hmenu)) { id = GetMenuItemID(hmenu, pos); if ((id > 0) && (Menu_Callbacks[id] != NULL)) { SLfree(Menu_Callbacks[id]); Menu_Callbacks[id] = NULL; } else if (id == -1) { popup = GetSubMenu(hmenu, pos); (void) push_hmenu (popup); destroy_menu(); } if (!DeleteMenu(hmenu, pos, MF_BYPOSITION)) msg_error("Cannot delete menu"); } } void get_menu_state() { HMENU hmenu; int id; UINT mstate; int state; if (!SLang_pop_integer(&id) && !pop_hmenu(&hmenu)) { if (-1 == (int)(mstate = GetMenuState(hmenu, id, MF_BYCOMMAND))) msg_error("Cannot get menu state"); else { state = 0; if (mstate & MF_ENABLED) state = 1; if (mstate & MF_CHECKED) state |= 2; (void)SLang_push_integer(state); } } } void get_menu_state_pos() { HMENU hmenu; int pos; UINT mstate; int state; if (!SLang_pop_integer(&pos) && !pop_hmenu(&hmenu)) { if (-1 == (int)(mstate = GetMenuState(hmenu, pos, MF_BYPOSITION))) msg_error("Cannot get menu state"); else { state = 0; if (mstate & MF_GRAYED) state = 1; if (mstate & MF_CHECKED) state |= 2; (void)SLang_push_integer(state); } } } void get_popup_menu() { HMENU hmenu; int pos; HMENU popup; if (!SLang_pop_integer(&pos) && !pop_hmenu(&hmenu)) { popup = GetSubMenu(hmenu, pos); (void) push_hmenu (popup); } } void check_menu_item() { HMENU hmenu; int id; int flag; if (!SLang_pop_integer(&flag) && !SLang_pop_integer(&id) && !pop_hmenu(&hmenu)) { if (-1 == (int) CheckMenuItem(hmenu, id, MF_BYCOMMAND | (flag)?MF_CHECKED:MF_UNCHECKED)) msg_error("Menu item does not exist"); } } void check_menu_item_pos() { HMENU hmenu; int pos; int flag; if (!SLang_pop_integer(&flag) && !SLang_pop_integer(&pos) && !pop_hmenu(&hmenu)) { if (!CheckMenuItem(hmenu, pos, MF_BYPOSITION | (flag)?MF_CHECKED:MF_UNCHECKED)) msg_error("Menu item does not exist"); } } void enable_menu_item() { HMENU hmenu; int id; int flag; if (!SLang_pop_integer(&flag) && !SLang_pop_integer(&id) && !pop_hmenu(&hmenu)) { if (-1 == EnableMenuItem(hmenu, id, MF_BYCOMMAND | ((flag)?MF_ENABLED:MF_DISABLED))) msg_error("Menu item does not exist"); } } void enable_menu_item_pos() { HMENU hmenu; int pos; int flag; if (!SLang_pop_integer(&flag) && !SLang_pop_integer(&pos) && !pop_hmenu(&hmenu)) { if (-1 == EnableMenuItem(hmenu, pos, MF_BYPOSITION | (flag)?MF_ENABLED:MF_DISABLED)) msg_error("Menu item does not exist"); } } void redraw_menubar() { DrawMenuBar(This_Window.w); } void set_init_popup_callback() { char *callback; if (SLpop_string(&callback)) return; if (InitPopup_Callback != NULL) SLfree(InitPopup_Callback); InitPopup_Callback = callback; } void msw_help (void) { char *file = NULL; char *keyword = NULL; int partial_keyword; UINT help_type; DWORD dwData; if (!SLang_pop_integer(&partial_keyword) && !SLpop_string (&keyword) && !SLpop_string(&file)) { help_type = (partial_keyword) ? HELP_PARTIALKEY : HELP_KEY; dwData = (DWORD)(LPSTR) keyword; if (*keyword == '\0') { help_type = HELP_CONTENTS; dwData = 0; } if (!WinHelp(This_Window.w, file, help_type, dwData)) { msg_error("Help file not found."); } } if (keyword != NULL) SLfree(keyword); if (file != NULL) SLfree(file); } static void msw_get_display_size (int *rows, int *cols) { *cols = MSW_Screen_Cols = This_Window.width / This_Window.font_width; *rows = MSW_Screen_Rows = This_Window.height / This_Window.font_height; } static JX_SETXXX_RETURN_TYPE msw_set_mono (int i, char *what , SLtt_Char_Type unused) { (void)i; (void)what; (void)unused; return JX_SETXXX_RETURN_VAL; } int jed_init_w32_support (void) { return w32_init_subprocess_support (1); } #if HAS_WHEEL_MOUSE_SUPPORT /* Initialise mouse wheel handling functionality */ static int init_wheel_mouse (void) { /* Find the mystery mouse window */ Wheel_Mouse.hwnd = FindWindow(MSH_WHEELMODULE_CLASS, MSH_WHEELMODULE_TITLE); /* Register messages to determine mousey information */ Wheel_Mouse.uiMshMsgMouseWheel = RegisterWindowMessage(MSH_MOUSEWHEEL); Wheel_Mouse.uiMshMsg3DSupport = RegisterWindowMessage(MSH_WHEELSUPPORT); Wheel_Mouse.uiMshMsgScrollLines = RegisterWindowMessage(MSH_SCROLL_LINES); /* If we have a wheel enquiry message, ask about the presence of a wheel */ if (Wheel_Mouse.uiMshMsg3DSupport) Wheel_Mouse.fActive = (BOOL)SendMessage(Wheel_Mouse.hwnd, Wheel_Mouse.uiMshMsg3DSupport, 0, 0); else Wheel_Mouse.fActive = FALSE; /* If we have a scroll line enquiry message ask about that */ if (Wheel_Mouse.uiMshMsgScrollLines) Wheel_Mouse.iScrollLines = (int)SendMessage(Wheel_Mouse.hwnd, Wheel_Mouse.uiMshMsgScrollLines, 0, 0); else Wheel_Mouse.iScrollLines = 3; return 0; } #endif /* HAS_WHEEL_MOUSE_SUPPORT */ #if defined(__BORLANDC__) || defined(__WIN32__) || defined(__VC__) extern int main(int, char **); int PASCAL WinMain(HINSTANCE inst, HINSTANCE pinst, LPSTR lpszCmdLine, int nCmdShow) { char **argv; int argc; int count; char *pt; int ret; char *command_line; /* add 8 for "wjed", the separating space, and a terminating '\0' */ if (NULL == (command_line = SLMALLOC (strlen(lpszCmdLine) + 6))) return 0; #ifdef _MSC_VER _hInstance = inst; #else (void) inst; #endif (void) nCmdShow; #if HAS_WHEEL_MOUSE_SUPPORT (void) init_wheel_mouse (); #endif strcpy(command_line, "wjed "); strcat(command_line, lpszCmdLine); _hPrev = pinst; /* Handle quoted filenames containing space characters. It is a pity * that the application has to do this. */ while ( (*command_line != '\0') && (*command_line == ' ')) command_line++; /* start on 1st non-space */ pt = command_line; count = 0; while ( *pt != '\0' ) { count++; /* this is an argument */ #ifdef __WIN32__ /* If the first character of the argument is a double quote, * search for a matching double-quote to end the argument, * otherwise, find the next space */ if (*pt == '"') { pt++; /* Skip the initial quote */ while ((*pt != '\0') && (*pt != '"')) pt++; if (*pt != '\0') /* Skip the end quote */ pt++; } else #endif while ((*pt != '\0') && (*pt != ' ')) pt++; /* advance until a space */ while (*pt == ' ') pt++; /* advance until a non-space */ } argv = (char **) SLMALLOC( (count+3) * sizeof(char *) ); if (argv == NULL ) return 0; /* malloc error */ argc = 0; pt = command_line; while ((argc < count) && (*pt != '\0')) { argv[ argc ] = pt; argc++; #ifdef __WIN32__ /* If the first character of the argument is a double quote, * search for a matching double-quote to end the argument, * otherwise, find the next space */ if (*pt == '"') { pt++; /* Skip the initial quote */ while ((*pt != '\0') && (*pt != '"')) pt++; if (*pt != '\0') /* Skip the end quote */ pt++; } else #endif while ( *pt != '\0' && *pt != ' ' ) pt++; /* advance until a space */ if ( *pt != '\0' ) *(pt++) = '\0'; /* parse argument here */ while ( *pt == ' ') pt++; /* advance until a non-space */ } argv [ argc ] = (char *) NULL; /* NULL terminated list */ ret = main(argc, argv); SLfree(command_line); return ret; } #endif /* __BORLANDC__ || __VC__ */ void (*tt_beep)(void); void (*tt_write_string)(char *); JX_SETXXX_RETURN_TYPE (*tt_set_color)(int, char *, char *, char *); JX_SETXXX_RETURN_TYPE (*tt_set_mono) (int, char *, SLtt_Char_Type); void (*tt_get_screen_size)(int *, int *); int *tt_Ignore_Beep; int *tt_Use_Ansi_Colors; int *tt_Term_Cannot_Scroll; int *tt_Term_Cannot_Insert; static void init_tt_hooks (void) { tt_beep = msw_beep; tt_write_string = msw_write_string; tt_get_screen_size = msw_get_display_size; tt_set_color = msw_set_color; tt_set_mono = msw_set_mono; tt_Ignore_Beep = &MSW_Ignore_Beep; tt_Use_Ansi_Colors = &MSW_Use_Ansi_Colors; tt_Term_Cannot_Scroll= &MSW_Term_Cannot_Scroll; tt_Term_Cannot_Insert= &MSW_Term_Cannot_Insert; } static void msw_get_terminfo (void) { SLsmg_Term_Type tt; init_tt_hooks (); MSW_Screen_Cols = 80; MSW_Screen_Rows = 24; (void) jed_add_init_slang_hook (msw_init_slang); /* Set this so that main will not try to read from stdin. It is quite * likely that this is started from a menu or something. */ Stdin_Is_TTY = -1; /* init hooks */ X_Update_Open_Hook = msw_update_open; X_Update_Close_Hook = msw_update_close; X_Suspend_Hook = msw_suspend; /* X_Argc_Argv_Hook = X_eval_command_line; */ X_Define_Keys_Hook = msw_define_xkeys; SLang_Interrupt = msw_check_kbd; X_Init_Term_Hook = msw_init_term; if (Batch) return; memset ((char *) &tt, 0, sizeof (SLsmg_Term_Type)); tt.tt_normal_video = msw_normal_video; tt.tt_set_scroll_region = msw_set_scroll_region; tt.tt_goto_rc = msw_goto_rc; tt.tt_reverse_index = msw_reverse_index; tt.tt_reset_scroll_region = msw_reset_scroll_region; tt.tt_delete_nlines = msw_delete_nlines; tt.tt_cls = msw_cls; tt.tt_del_eol = msw_del_eol; tt.tt_smart_puts = msw_smart_puts; tt.tt_flush_output = msw_flush_output; tt.tt_reset_video = msw_reset_video; tt.tt_init_video = msw_init_video; tt.tt_screen_rows = &MSW_Screen_Rows; tt.tt_screen_cols = &MSW_Screen_Cols; tt.tt_term_cannot_scroll = &MSW_Term_Cannot_Scroll; SLsmg_set_terminal_info (&tt); } void (*tt_get_terminfo)(void) = msw_get_terminfo; int (*X_Argc_Argv_Hook)(int, char **) = NULL; jed-0.99-19/src/line.h0000644002657400265740000000051711311317447013364 0ustar davisdavis/* Copyright (c) 1992, 1998, 2000, 2005, 2006 John E. Davis * This file is part of JED editor library source. * * You may distribute this file under the terms the GNU General Public * License. See the file COPYING for more information. */ extern void swap_lines(void); extern int split_line(void); extern void splice_line(void); jed-0.99-19/src/menu.h0000644002657400265740000000131311311317447013374 0ustar davisdavis/* Copyright (c) 2007 John E. Davis * This file is part of JED editor library source. * * You may distribute this file under the terms the GNU General Public * License. See the file COPYING for more information. */ #ifndef _JED_MENU_H_ #define _JED_MENU_H_ 1 typedef struct _Menu_Bar_Type Menu_Bar_Type; extern int jed_init_menus (void); extern int jed_redraw_menus (void); extern int jed_select_menu_bar (void); extern int jed_exit_menu_bar (void); extern void jed_delete_menu_bar (Menu_Bar_Type *); extern int jed_menu_handle_mouse (unsigned int, int, int, int, int); extern SLang_Key_Type *jed_menu_do_key (void); extern int Jed_Menus_Active; extern void jed_notify_menu_buffer_changed (void); #endif jed-0.99-19/src/cmds.c0000644002657400265740000006141511311317447013362 0ustar davisdavis/* -*- mode: c; mode: fold -*- */ /* Copyright (c) 1992, 1998, 2000, 2002, 2003, 2004, 2005, 2006 John E. Davis * This file is part of JED editor library source. * * You may distribute this file under the terms the GNU General Public * License. See the file COPYING for more information. */ #include "config.h" #include "jed-feat.h" /*{{{ #include files */ #include #ifdef HAVE_STDLIB_H # include #endif #include #include "jdmacros.h" #include #include "buffer.h" #include "screen.h" #include "window.h" #include "ins.h" #include "ledit.h" #include "cmds.h" #include "line.h" #include "paste.h" #include "display.h" #include "sysdep.h" #include "text.h" #include "file.h" #include "misc.h" #include "search.h" #include "hooks.h" #include "abbrev.h" #include "indent.h" #if JED_HAS_SUBPROCESSES # include "jprocess.h" #endif #include "sig.h" #if JED_HAS_LINE_ATTRIBUTES # include "lineattr.h" #endif /*}}}*/ /* fast insert/delete not implemented */ /*{{{ Global variables */ void (*X_Suspend_Hook)(void); int Blink_Flag = 1; int Indented_Text_Mode = 0; /* if non zero, intent line after wrap */ int Kill_Line_Feature = 1; /* non-zero means kill through eol if bolp */ int Jed_Tab_Default = 8; int Jed_Wrap_Default = 72; int Jed_Case_Search_Default = 0; int Jed_Suspension_Not_Allowed = 0; int Jed_Use_Tabs = 1; /*}}}*/ /*{{{ Static variables */ static char *Top_Of_Buffer_Error = "Top Of Buffer."; static char *End_Of_Buffer_Error = "End Of Buffer."; /*}}}*/ /*{{{ Static functions */ #if JED_HAS_LINE_ATTRIBUTES static int check_line_attr_no_modify (Line *l) { if (0 == (l->flags & JED_LINE_HIDDEN)) return 0; msg_error ("You cannot edit this hidden line."); return -1; } #endif static int next_visible_lines (int n) { #if JED_HAS_LINE_ATTRIBUTES int dn; int i; i = 0; while (i < n) { Line *l = CLine; dn = 0; do { l = l->next; dn++; } while ((l != NULL) && (l->flags & JED_LINE_HIDDEN)); if (l == NULL) break; CLine = l; LineNum += dn; i++; } if (i) Point = 0; return i; #else return jed_down(n); #endif } static int prev_visible_lines (int n) { #if JED_HAS_LINE_ATTRIBUTES int i, dn; i = 0; while (i < n) { Line *l = CLine; dn = 0; do { l = l->prev; dn++; } while ((l != NULL) && (l->flags & JED_LINE_HIDDEN)); if (l == NULL) break; CLine = l; LineNum -= dn; i++; } if (i) eol (); /* leave point at eol */ return i; #else return jed_up (n); #endif } static int prev_visible_chars (int n) { #if JED_HAS_LINE_ATTRIBUTES jed_push_mark (); n = jed_left (n); if (n && (CLine->flags & JED_LINE_HIDDEN)) { jed_skip_hidden_lines_backward (&Number_One); if (CLine->flags & JED_LINE_HIDDEN) { jed_pop_mark (1); return 0; } } jed_pop_mark (0); return n; #else return jed_left (n); #endif } static int next_visible_chars (int n) { #if JED_HAS_LINE_ATTRIBUTES jed_push_mark (); n = jed_right (n); if (n && (CLine->flags & JED_LINE_HIDDEN)) { jed_skip_hidden_lines_forward (&Number_One); if (CLine->flags & JED_LINE_HIDDEN) { jed_pop_mark (1); return 0; } } jed_pop_mark (0); return n; #else return jed_right (n); #endif } static void check_last_key_function (FVOID_STAR f) { /* For syntax highlighting */ if (Last_Key_Function != f) touch_window (); #if 0 && ((Last_Key_Function == (FVOID_STAR) ins_char_cmd) || (Last_Key_Function == (FVOID_STAR) eol_cmd) || (Last_Key_Function == (FVOID_STAR) delete_char_cmd) || (Last_Key_Function == (FVOID_STAR) backward_delete_char_cmd) || (Last_Key_Function == (FVOID_STAR) backward_delete_char_untabify))) register_change(0); #endif } static void next_line_prev_line_helper (int *gcp, int *ret, int dr, FVOID_STAR f) { int gc; (void) dr; check_line(); gc = calculate_column(); if (Cursor_Motion <= 0) Goal_Column = gc; else if (Goal_Column < gc) Goal_Column = gc; *gcp = gc; Cursor_Motion = 2; check_last_key_function (f); *ret = 1; #if 0 *ret = (JWindow->trashed || (CLine == JScreen[JWindow->sy + dr].line) #if JED_HAS_LINE_ATTRIBUTES || (CLine->flags & JED_LINE_IS_READONLY) #endif ); #endif } static void eob_bob_error (int f) { char *str; if ((CBuf->buffer_hooks != NULL) && (CBuf->buffer_hooks->bob_eob_error_hook != NULL)) { SLang_push_integer (f); SLexecute_function (CBuf->buffer_hooks->bob_eob_error_hook); return; } if (f < 0) str = Top_Of_Buffer_Error; else str = End_Of_Buffer_Error; msg_error (str); } /*}}}*/ /*{{{ interactive insert/delete functions */ /*{{{ Interactive char deletion functions */ int delete_char_cmd (void) { CHECK_READ_ONLY #if 0 ; #endif #if JED_HAS_LINE_ATTRIBUTES if (check_line_attr_no_modify (CLine)) return 0; #endif if (eobp()) { msg_error(End_Of_Buffer_Error); return(0); } (void) jed_del_wchar (); return 1; } int backward_delete_char_cmd() { /* CHECK_READ_ONLY */ if (bobp()) { msg_error(Top_Of_Buffer_Error); return(0); } #if JED_HAS_LINE_ATTRIBUTES if (check_line_attr_no_modify (CLine)) return 0; #endif if (bolp()) { #if JED_HAS_LINE_ATTRIBUTES if (check_line_attr_no_modify (CLine->prev)) return 0; #endif } jed_left (1); if (-1 == jed_del_wchar ()) jed_right (1); return 1; } int backward_delete_char_untabify() { unsigned char *p; int n; /* CHECK_READ_ONLY */ #if JED_HAS_LINE_ATTRIBUTES if (check_line_attr_no_modify (CLine)) return 0; #endif p = CLine->data + (Point - 1); if (!Point || (*p != '\t') || !Buffer_Local.tab) return backward_delete_char_cmd(); n = calculate_column() - 1; jed_left (1); if (-1 == jed_del_wchar ()) return -1; n = n - calculate_column(); (void) jed_insert_wchar_n_times (' ', n); return(1); } /*}}}*/ /*{{{ newline_and_indent */ int newline_and_indent () { static int in_function; if (in_function) return -1; #if JED_HAS_LINE_ATTRIBUTES if (check_line_attr_no_modify (CLine) || ((CLine->next != NULL) && eolp () && check_line_attr_no_modify (CLine->next))) return 0; #endif if ((CBuf->buffer_hooks != NULL) && (CBuf->buffer_hooks->newline_indent_hook != NULL)) { in_function = 1; SLexecute_function(CBuf->buffer_hooks->newline_indent_hook); in_function = 0; return 1; } if (0 == jed_insert_newline ()) indent_line(); return(1); } /*}}}*/ /*{{{ newline */ int newline (void) { CHECK_READ_ONLY #if 0 ; #endif if (CBuf == MiniBuffer) return exit_minibuffer(); (void) jed_insert_newline (); return(1); } int newline_cmd (void) { #if JED_HAS_LINE_ATTRIBUTES if (check_line_attr_no_modify (CLine) || ((CLine->next != NULL) && eolp () && check_line_attr_no_modify (CLine->next))) return 0; #endif return newline (); } /*}}}*/ static int execute_is_ok_hook (SLang_Name_Type *hook) { int ret; if (-1 == SLexecute_function (hook)) return -1; if (-1 == SLang_pop_integer (&ret)) return -1; return (ret != 0); } /*{{{ ins_char_cmd */ int ins_char_cmd (void) { unsigned char ch; int wrap = Buffer_Local.wrap_column; int do_blink; int did_abbrev = 0; SLang_Name_Type *wrapok_hook; CHECK_READ_ONLY #if 0 ; #endif #if JED_HAS_LINE_ATTRIBUTES if (check_line_attr_no_modify (CLine)) return 0; #endif ch = SLang_Last_Key_Char; if (ch == '\n') { newline(); return(1); } #if JED_HAS_ABBREVS if (CBuf->flags & ABBREV_MODE) { if (-1 == (did_abbrev = jed_expand_abbrev (ch))) return -1; } #endif if ((CBuf->flags & OVERWRITE_MODE) && !eolp()) { /* FIXME: jed_del_wchar should be called for the last byte of a * UTF-8 sequence */ if ((did_abbrev == 0) && (-1 == jed_del_wchar ())) return -1; } /* It is ok to use Point as an estimator of the current column. This * avoids the more expensive call to calculate_column. */ if (CBuf->buffer_hooks != NULL) wrapok_hook = CBuf->buffer_hooks->wrapok_hook; else wrapok_hook = NULL; if (((ch == ' ') || (Point >= wrap)) && ((CBuf->modes & WRAP_MODE) || (wrapok_hook != NULL)) && (calculate_column() > wrap) && ((wrapok_hook == NULL) || (1 == execute_is_ok_hook (wrapok_hook)))) { unsigned int this_line_num = LineNum; if ((did_abbrev == 0) && (-1 == jed_insert_byte (ch))) return -1; if (1 != wrap_line(0)) /* do not format--- just wrap */ return -1; /* line isn't wrapable */ /* There is a bug involving wrapping a very long line containing * no whitespace and then we try to insert a character. This work * arounds the bug. */ if ((this_line_num == LineNum) && (ch == ' ')) /* && (calculate_column () > wrap)) */ { if (0 == jed_right (1)) newline (); } if ((CBuf->buffer_hooks != NULL) && (CBuf->buffer_hooks->wrap_hook != NULL)) SLexecute_function(CBuf->buffer_hooks->wrap_hook); else if (Indented_Text_Mode) indent_line (); return(1); } do_blink = ((((CBuf->syntax_table != NULL) && ((CBuf->syntax_table->char_syntax[(unsigned char) ch] & CLOSE_DELIM_SYNTAX))) || ((ch == ')') || (ch == '}') || (ch == ']'))) && !input_pending(&Number_Zero)); if (did_abbrev == 0) (void) jed_insert_byte (ch); if (do_blink) blink_match (); return 1; } /*}}}*/ /*{{{ quoted_insert */ int quoted_insert() { SLwchar_Type ch; int ins_byte = 1; CHECK_READ_ONLY if (*Error_Buffer || SLKeyBoard_Quit) return(0); if (Repeat_Factor != NULL) { ch = *Repeat_Factor; ins_byte = 0; Repeat_Factor = NULL; } else { SLang_Key_TimeOut_Flag = 1; ch = jed_getkey(); SLang_Key_TimeOut_Flag = 0; } if (SLang_get_error () == SL_USER_BREAK) SLang_set_error (0); if ((ch == '\n') && (CBuf == MiniBuffer)) { (void) _jed_ins_byte ('\n'); /* msg_error("Not allowed!"); */ return (1); } SLKeyBoard_Quit = 0; if (ins_byte == 0) { if (-1 == jed_insert_wchar_n_times(ch, 1)) return -1; } else { unsigned char byte = (unsigned char) ch; if (-1 == jed_insert_nbytes (&byte, 1)) return -1; } if ((CBuf->syntax_table != NULL) && (CBuf->syntax_table->char_syntax[(unsigned char) ch] & CLOSE_DELIM_SYNTAX) && !input_pending(&Number_Zero)) blink_match (); /* (ch); */ return(1); } /*}}}*/ /*{{{ kill_line */ /* FIXME: MULTIBYTE unsafe */ int kill_line (void) { int n, pnt, flag = 0; CHECK_READ_ONLY if (eobp()) { msg_error(End_Of_Buffer_Error); return(0); } jed_push_mark(); push_spot(); pnt = Point; eol(); n = Point - pnt; if ((!pnt && Kill_Line_Feature) || !n) { /* Either of these (flag =0,1) have the same effect on the buffer. * However, the first sets the mark at the end of the line and moves * the point to the end of the previous line. This way the current * line structure is deleted and the screen update looks better. */ if (!pnt && (CLine->prev != NULL) && (CLine->next != NULL)) { flag = 1; jed_right (1); } else n += jed_right (1); } if ((Last_Key_Function == (FVOID_STAR) kill_line) && (Paste_Buffer != NULL)) { copy_region_to_buffer(Paste_Buffer); } else copy_to_pastebuffer(); pop_spot(); if (flag) n += jed_left (1); (void) jed_generic_del_nbytes (n); if (flag) (void) jed_right (1); return(1); } /*}}}*/ /*}}}*/ /*{{{ interactive cursor movement functions */ /*{{{ Interactive char/line movement functions */ int previous_line_cmd (void) { int ret, gc; next_line_prev_line_helper (&gc, &ret, 0, (FVOID_STAR) previous_line_cmd); if ((CLine == CBuf->beg) || (1 != prev_visible_lines (1))) { eob_bob_error (-1); return 1; } point_column(Goal_Column); return(ret); } int next_line_cmd (void) { int ret, gc; next_line_prev_line_helper (&gc, &ret, JWindow->rows - 1, (FVOID_STAR) next_line_cmd); if ((CLine == CBuf->end) || (1 != next_visible_lines (1))) { eob_bob_error (1); return 1; } point_column(Goal_Column); return(ret); } int previous_char_cmd (void) { int b; Cursor_Motion = 1; /* check_last_key_function ((FVOID_STAR) previous_char_cmd); */ b = bolp (); if (1 != prev_visible_chars (1)) { eob_bob_error (-2); return 1; } Goal_Column = calculate_column(); return b || JWindow->trashed; } int next_char_cmd () { Cursor_Motion = 1; /* check_last_key_function ((FVOID_STAR) next_char_cmd); */ if (1 != next_visible_chars (1)) { eob_bob_error (2); return 1; } Goal_Column = calculate_column (); return JWindow->trashed || bolp (); /* Point = 0 ==> moved a line */ } /*}}}*/ /*{{{ eol_cmd */ int eol_cmd (void) { eol(); if ((0 == (CBuf->flags & READ_ONLY)) #if JED_HAS_LINE_ATTRIBUTES && (0 == (CLine->flags & JED_LINE_IS_READONLY)) #endif ) jed_trim_whitespace(); return(1); } /*}}}*/ /*{{{ Scrolling/pageup/down functions */ int jed_buffer_visible (char *b) { return buffer_visible (find_buffer(b)); } static void scroll_completion (int dir) { Window_Type *w; if (jed_buffer_visible (Completion_Buffer)) { pop_to_buffer (Completion_Buffer); if (dir > 0) pagedown_cmd (); else pageup_cmd (); while (!IN_MINI_WINDOW) other_window (); } else { w = JWindow; other_window(); if (!IN_MINI_WINDOW) { if (dir > 0) pagedown_cmd (); else pageup_cmd (); } while (JWindow != w) other_window (); } } int goto_bottom_of_window (void) { int n; n = JWindow->rows - window_line (); return n == next_visible_lines (n); } void goto_top_of_window (void) { int n; n = window_line () - 1; (void) prev_visible_lines (n); } static int Last_Page_Line; static int Last_Page_Point; /* the page up/down commands set cursor_motion to -1 because we do not want to use any goal column information */ int pagedown_cmd() { int col, this_line, this_point; int n; Cursor_Motion = -1; if (IN_MINI_WINDOW) { scroll_completion (1); return 1; } if (eobp()) { eob_bob_error (3); return 1; } n = JWindow->rows; if ((CBuf != JWindow->buffer) || (n == 1)) { return next_visible_lines (n); } if (JWindow->trashed) { update (NULL, 0, 0, 1); if (JWindow->trashed) return next_visible_lines (n); } /* This is ugly. */ this_line = LineNum; this_point = Point; col = calculate_column (); if (goto_bottom_of_window ()) { recenter (&Number_One); } goto_column1 (&col); if ((Last_Key_Function == (FVOID_STAR) pageup_cmd) && (Jed_This_Key_Function == (FVOID_STAR) pagedown_cmd)) { goto_line (&Last_Page_Line); if (Last_Page_Point < CLine->len) Point = Last_Page_Point; } else if (CLine->next == NULL) eol(); else bol (); Last_Page_Line = this_line; Last_Page_Point = this_point; return(1); } int pageup_cmd (void) { int col, this_line, this_point; int n; Cursor_Motion = -1; if (IN_MINI_WINDOW) { scroll_completion (-1); return 1; } if (bobp()) { eob_bob_error (-3); return 1; } n = JWindow->rows; if ((CBuf != JWindow->buffer) || (n == 1)) { return prev_visible_lines (n); } if (JWindow->trashed) { update (NULL, 0, 0, 1); if (JWindow->trashed) return prev_visible_lines (n); } this_line = LineNum; this_point = Point; col = calculate_column (); goto_top_of_window (); (void) goto_column1(&col); recenter(&JWindow->rows); if ((Last_Key_Function == (FVOID_STAR) pagedown_cmd) && (Jed_This_Key_Function == (FVOID_STAR) pageup_cmd)) { goto_line (&Last_Page_Line); if (Last_Page_Point < CLine->len) Point = Last_Page_Point; } else bol (); /* something like: Point = point_column(JWindow->column) better? */ Last_Page_Line = this_line; Last_Page_Point = this_point; return(1); } /*}}}*/ int jed_scroll_left_cmd (void) { int dc = JWindow->width/2; if (Repeat_Factor != NULL) { dc = *Repeat_Factor; Repeat_Factor = NULL; } jed_scroll_left (dc); return 1; } int jed_scroll_right_cmd (void) { int dc = JWindow->width/2; if (Repeat_Factor != NULL) { dc = *Repeat_Factor; Repeat_Factor = NULL; } jed_scroll_right (dc); return 1; } /*}}}*/ /*{{{ Whitespace and Indention functions */ void insert_whitespace(int *n) { int tab = Buffer_Local.tab; int c1, c2, i, k, nspace; if ((nspace = *n) <= 0) return; CHECK_READ_ONLY_VOID c1 = calculate_column() - 1; c2 = c1 + nspace; if (tab && Jed_Use_Tabs) { i = c1 / tab; k = c2 / tab - i; if (k) nspace = c2 - (i + k) * tab; (void) jed_insert_wchar_n_times('\t', k); } (void) jed_insert_wchar_n_times(' ', nspace); } /* get indent value of current line, n is the column */ unsigned char *get_current_indent(int *np) { unsigned char *p, *pmax; int tab, n; tab = Buffer_Local.tab; p = CLine->data; pmax = CLine->data + CLine->len; n = 0; while((p < pmax) && ((*p == ' ') || (tab && (*p == '\t')))) { if (*p == '\t') n = tab * (n / tab + 1); else n++; p++; } *np = n; return p; } #define IS_WHITESPACE(p) ((*(p)==' ')||(*(p)=='\t')) int jed_trim_whitespace () { int n; unsigned char *p; /* CHECK_READ_ONLY */ p = CLine->data + Point; if ((0 == eolp ()) && (0 == IS_WHITESPACE(p))) return 0; (void) jed_skip_whitespace (); n = Point; (void) jed_bskip_whitespace (); jed_del_nbytes (n - Point); return 1; } /* indent line to column n */ void indent_to(int n) { int m; get_current_indent(&m); if (n != m) { bol (); jed_trim_whitespace(); if (n >= 0) insert_whitespace(&n); } } int indent_line () { int n, n1; static int in_function; if (in_function) return -1; if ((CBuf->buffer_hooks != NULL) && (CBuf->buffer_hooks->indent_hook != NULL)) { in_function = 1; SLexecute_function(CBuf->buffer_hooks->indent_hook); in_function = 0; return 1; } /* CHECK_READ_ONLY */ if (CLine == CBuf->beg) return(0); push_spot(); CLine = CLine->prev; get_current_indent (&n); CLine = CLine->next; indent_to(n); pop_spot(); /* This moves the cursor to the first non whitspace char if we are before it. Otherwise leave it alone */ n1 = calculate_column(); get_current_indent(&n); if (n1 <= n) point_column(n + 1); return 1; } /*}}}*/ /*{{{ goto_column and goto_column1 */ /* goto to column c, returns actual column */ int goto_column1(int *cp) { int c1, c = *cp; if (c <= 0) c = 1; eol(); c1 = calculate_column(); if (c1 > c) { point_column(c); c1 = calculate_column(); } return(c1); } /* move cursor to column c adding spaces if necessary */ void goto_column(int *c) { int c1 = *c; if (c1 <= 0) c1 = 1; c1 = c1 - goto_column1(&c1); insert_whitespace(&c1); } /*}}}*/ /*{{{ skip_whitespace */ /* does not leave current line */ unsigned char *jed_skip_whitespace (void) { unsigned char *p, *pmax; p = CLine->data + Point; pmax = jed_eol_position (CLine); while ((p < pmax) && IS_WHITESPACE(p)) p = jed_multibyte_chars_forward (p, pmax, 1, NULL, 0); jed_position_point (p); return p; } unsigned char *jed_bskip_whitespace (void) { unsigned char *p, *pmin, *pmax; pmin = CLine->data; pmax = p = CLine->data + Point; while (p > pmin) { unsigned char *p1; p1 = jed_multibyte_chars_backward (pmin, p, 1, NULL, 0); if (0 == IS_WHITESPACE(p1)) break; p = p1; } jed_position_point (p); return p; } /*}}}*/ /*{{{ looking_at */ /* MULTIBYTE OK */ int jed_looking_at (char *what) { unsigned char *p, *pmax; unsigned char *w, *wmax; Line *l = CLine; int cs = Buffer_Local.case_search; w = (unsigned char *) what; wmax = w + strlen (what); p = l->data + Point; while (1) { pmax = l->data + l->len; if (cs) { while ((w < wmax) && (p < pmax)) { if (*w++ != *p++) return 0; } } else { /* Here we have to use multibyte routines */ while ((w < wmax) && (p < pmax)) { if (0 != jed_multibyte_charcasecmp (&w, wmax, &p, pmax)) return 0; } } if (w == wmax) return 1; l = l->next; if (l == NULL) return 0; p = l->data; } } /*}}}*/ /*{{{ Exiting the editor */ /*{{{ sys_spawn_cmd */ int jed_spawn_fg_process (int (*f)(VOID_STAR), VOID_STAR cd) { int status; int inited; if ((Jed_Secure_Mode) || (Jed_Suspension_Not_Allowed)) { msg_error ("Access to shell denied."); return -1; } /* FIXME: X_Suspend_Hook should not be here. Currently, this hook is * used only by GUI jed, where suspension makes no sense. Of course in * this case, spawning a foreground process also does not make sense. */ if (Batch || (X_Suspend_Hook != NULL)) return (*f) (cd); SLsig_block_signals (); inited = Jed_Display_Initialized; SLsig_unblock_signals (); jed_reset_display(); #if !defined(IBMPC_SYSTEM) && !defined(VMS) jed_reset_signals (); #endif reset_tty(); status = (*f) (cd); if (inited) { #if !defined(IBMPC_SYSTEM) && !defined(VMS) init_signals(); #endif if (-1 == init_tty()) { exit_error ("Unable to initialize terminal.", 0); } flush_input (); jed_init_display (); } check_buffers(); return status; } static int suspend_func (void *unused) { (void) unused; if (X_Suspend_Hook != NULL) (*X_Suspend_Hook) (); else sys_suspend(); return 0; } int sys_spawn_cmd (void) { if (X_Suspend_Hook != NULL) { (*X_Suspend_Hook) (); return 0; } if (jed_va_run_hooks ("_jed_suspend_hooks", JED_HOOKS_RUN_UNTIL_0, 0) <= 0) return 0; (void) jed_spawn_fg_process (suspend_func, NULL); (void) jed_va_run_hooks ("_jed_resume_hooks", JED_HOOKS_RUN_ALL, 0); return 0; } /*}}}*/ /*{{{ jed_quit_jed */ int jed_quit_jed(int status) { Buffer *b; (void) jed_va_run_hooks ("_jed_quit_hooks", JED_HOOKS_RUN_ALL, 0); b = CBuf; /* Any buffer marked with AUTO_SAVE_JUST_SAVE flag should be saved * if it has not already been. That is what the flag is for and this * code fragment carries this out. */ do { if ((b->flags & AUTO_SAVE_JUST_SAVE) && (b->flags & BUFFER_MODIFIED) && (*b->file)) { while (b->narrow != NULL) widen_buffer(b); auto_save_buffer(b); /* actually, it will save it */ } #if defined(__WIN32__) && JED_HAS_SUBPROCESSES if (b->subprocess) jed_kill_process (b->subprocess - 1); #endif (void) jed_unlock_buffer_file (b); b = b->next; } while (b != CBuf); jed_reset_display(); reset_tty(); #ifdef VMS vms_cancel_exithandler(); #endif #ifdef SLANG_STATS SLang_dump_stats("slang.dat"); #endif #ifdef MALLOC_DEBUG SLmalloc_dump_statistics (); #endif /* SLstring_dump_stats (); */ exit (status); return(1); } /*}}}*/ /*{{{ save_some_buffers */ /* I should try it like emacs--- if prefix argument, then save all without user intervention */ int save_some_buffers (void) { Buffer *b, *tmp; int ans = 0; int err; b = CBuf; do { if ((b->flags & BUFFER_MODIFIED) && (*b->file)) { if (b->flags & AUTO_SAVE_JUST_SAVE) ans = 1; else ans = jed_vget_y_n ("Buffer %s not saved. Save it", b->name); if (ans == -1) /* warning--- bug here if user edits file at startup and forgets to save it then aborts. */ return -1; if (ans == 1) { tmp = CBuf; switch_to_buffer(b); /* It should not be necessary to do this here. Lower * level routines will do it. */ /* while (b->narrow != NULL) widen_buffer(b); */ err = jed_save_buffer_cmd (); switch_to_buffer(tmp); if (err < 0) return -1; /* b->flags &= ~BUFFER_MODIFIED; */ /* b->flags |= AUTO_SAVE_BUFFER; */ b->hits = 0; } } b = b->next; } while (b != CBuf); clear_message (); return 1; } /*}}}*/ /*{{{ exit_jed */ int jed_exit_jed (int status) { static int in_exit_jed = 0; if (in_exit_jed == 0) { in_exit_jed = 1; if (jed_va_run_hooks ("_jed_exit_hooks", JED_HOOKS_RUN_UNTIL_0, 0) <= 0) { in_exit_jed = 0; return -1; } } in_exit_jed = 0; if (SLang_get_error ()) return -1; #if JED_HAS_SUBPROCESSES if (1 != jed_processes_ok_to_exit ()) return 1; #endif if (save_some_buffers() > 0) jed_quit_jed(status); return 1; } /*}}}*/ /*}}}*/ int jed_exit_jed_cmd (void) { return jed_exit_jed (0); } jed-0.99-19/src/undo.h0000644002657400265740000000265411311317447013406 0ustar davisdavis#ifndef DAVIS_UNDO_H_ #define DAVIS_UNDO_H_ /* Copyright (c) 1992, 1998, 2000, 2005, 2006 John E. Davis * This file is part of JED editor library source. * * You may distribute this file under the terms the GNU General Public * License. See the file COPYING for more information. */ #if defined (__MSDOS_16BIT__) || defined (__os2_16__) /* size is something like 2000 x (16) = 32K */ #define MAX_UNDOS 2000 #else #define UNDO_HAS_REDO /* 24 bytes * 10K = 240K */ #define MAX_UNDOS 10000 #endif typedef struct { unsigned short type; /* type of damage */ unsigned int linenum; /* where damage was */ int point; /* */ int misc; /* misc information */ unsigned char buf[8]; /* buffer for chars */ } Undo_Object_Type; typedef struct Undo_Type { Undo_Object_Type *Last_Undo; Undo_Object_Type *First_Undo; #ifdef UNDO_HAS_REDO Undo_Object_Type *Current_Undo; #endif Undo_Object_Type Undo_Ring[MAX_UNDOS]; } Undo_Type; void record_deletion(unsigned char *, int); extern void record_insertion(int); extern void record_newline_insertion(void); extern int undo(void); extern void create_undo_ring(void); extern int Undo_Buf_Unch_Flag; /* 1 if buffer prev not modified */ #ifdef UNDO_HAS_REDO extern void set_current_undo(void); extern void update_undo_unchanged(void); #endif extern void unmark_undo_boundary (Buffer *); extern void jed_undo_record_position (void); #endif jed-0.99-19/src/ibmpc.c0000644002657400265740000002364511311317447013531 0ustar davisdavis/* -*- mode: C; mode: fold; -*- */ /* Copyright (c) 1992, 1998, 2000, 2002, 2003, 2004, 2005, 2006 John E. Davis * This file is part of JED editor library source. * * You may distribute this file under the terms the GNU General Public * License. See the file COPYING for more information. */ #include "config.h" #include "jed-feat.h" /*{{{ Include Files */ #include #include #include #include #include #include #include #include #include #include #include /* for stat */ #include #include #include "sysdep.h" /*}}}*/ #ifdef __cplusplus #define _DOTS_ ... #else #define _DOTS_ void #endif void interrupt (*oldint9)(_DOTS_); static unsigned char far *Shift_Ptr = (unsigned char far *) 0x417; static unsigned int far *kbptr = (unsigned int far *) 0x41a; static unsigned int far *kbnext = (unsigned int far *) 0x41c; static unsigned int far *kbbeg = (unsigned int far *) 0x480; static unsigned int far *kbend = (unsigned int far *) 0x482; #include "dos_os2.c" static unsigned int Abort_Scan_Code; /* Macro to get char from BIOS not dos */ void interrupt int9_handler(_DOTS_) /*{{{*/ { unsigned int scan = Abort_Scan_Code; /* 34 = scan code for ^G */ unsigned char s, s1; unsigned int offset, f1_scan = 0x3B00; /* f1 key */ unsigned int *p; unsigned int numlock = 0x45; s1 = *Shift_Ptr & 0xF; /* ignoring caps, ins, num lock, scroll lock */ s = inp(0x60); if (s1 & 0x04) /* control key */ { if (s == scan) { if (Ignore_User_Abort == 0) SLang_Error = 2; SLKeyBoard_Quit = 1; } else if (s == 28) /* Control - enter, ignore it!! */ { s = inp(0x61); outportb(0x61, s | 0x80); outportb(0x61, s); outportb(0x20, 0x20); return; } } else if (NumLock_Is_Gold && ((s & 0x7F) == numlock)) { if (s == numlock) { offset = *kbnext; offset += 2; if (offset == *kbend) offset = *kbbeg; if (offset != *kbptr) /* buffer not full */ { p = (unsigned int *) (0x400L + (*kbnext)); *p = f1_scan; *kbnext = offset; } } s = inp(0x61); outportb(0x61, s | 0x80); outportb(0x61, s); outportb(0x20, 0x20); return; } (*oldint9)(); } /*}}}*/ void init_int9_handler(void) /*{{{*/ { oldint9 = getvect(9); setvect(9, int9_handler); } /*}}}*/ void restore_int9_handler(void) /*{{{*/ { setvect(9, oldint9); } /*}}}*/ static void set_ctrl_break(int state) /*{{{*/ { static int prev = 0; asm { mov dl, byte ptr prev mov ax, state cmp ax, 0 jne L1 mov ah, 33h mov al, 0 mov dl, byte ptr prev int 21h xor ax, ax mov al, dl mov prev, ax mov dl, 0 } L1: asm { mov al, 1 mov ah, 33h int 21h } } /*}}}*/ #if 0 /* Here I just flag the error and return to the user-- hopefully jed will catch it and user will know what to do. */ static char *int24_errs[] = /*{{{*/ { "write protect", "bad unit", "drive not ready", "unknown", "CRC error", "request error", "seek error", "unknown media", "sector not found", "printer out of paper", "general write failure", "general read failure", "general failure", "reserved", "reserved", "invalid disk change" }; /*}}}*/ int int24_handler(int err, int ax, int bp, int si) /*{{{*/ { unsigned int di; di = _DI; (void) ax; (void) bp; msg_error(int24_errors[di & 0x000F]); } /*}}}*/ #endif static int ctrl_break(void) /*{{{*/ { msg_error("Control Break ignored!"); return(1); } /*}}}*/ #define BIOSKEY(x) bioskey((x) | bios_key_f) static int bios_key_f; static void (*delay_ptr) (unsigned int); static void my_delay (unsigned int ms) { union REGS r; unsigned long us; us = (unsigned long)ms * 1000; /* Micro seconds */ r.h.ah = 0x86; r.x.cx = (unsigned int) (us >> 16); r.x.dx = (unsigned int) (us & 0xFFFF); int86(0x15, &r, &r); } static int TTY_Initialized; static int ibmpc_set_abort_char (unsigned char ch) { char ch, *s, *scan = "@#$%^&*()_+?IQWERTYUIOP[]!!ASDFGHJKL!!!!\\ZXCVBNM"; ch += 64; s = scan; while (*s && (*s != ch)) s++; if (*s == 0) return; Abort_Scan_Code = (unsigned int) (s - scan) + 0x03; } int init_tty (void) /*{{{*/ { union REGS r; struct SREGS s; if (TTY_Initialized) return 0; bios_key_f = peekb(0x40,0x96) & 0x10; /* enhanced keyboard flag */ /* Check for system type */ delay_ptr = delay; r.x.ax = 0xC000; int86x (0x15, &r, &r, &s); if ((r.x.cflag == 0) && (r.h.al == 0)) { unsigned char *table; table = MK_FP(s.es, r.x.bx); switch (table[2]) { case 0xFF: /* pc */ case 0xFE: /* xt */ case 0xFB: /* xt */ case 0xFD: /* pc-jr */ break; /* AT and higher */ default: delay_ptr = my_delay; } } set_ctrl_break(0); ctrlbrk(ctrl_break); init_int9_handler(); TTY_Initialized = 1; if (Batch == 0) { if (X_Open_Mouse_Hook != NULL) (*X_Open_Mouse_Hook) (); } X_Set_Abort_Char_Hook = ibmpc_set_abort_char; return 0; } /*}}}*/ void reset_tty (void) /*{{{*/ { if (TTY_Initialized == 0) return; TTY_Initialized = 0; restore_int9_handler(); set_ctrl_break(1); if (Batch) return; #ifdef HAS_MOUSE if (X_Close_Mouse_Hook != NULL) (*X_Close_Mouse_Hook) (); #endif SLtt_reset_video(); } /*}}}*/ #include "pcscan.c" unsigned char sys_getkey() /*{{{*/ { unsigned int shift; unsigned int i; unsigned char chbuf[16]; int timeout; timeout = 300; if (BIOSKEY(1) == 0) while (!sys_input_pending(&timeout, 0)) { if (Display_Time) { JWindow->trashed = 1; update((Line *) NULL, 0, 1, 0); } } #ifdef HAS_MOUSE /* This can only be set by the mouse */ if (Input_Buffer_Len) return my_getkey (); if (JMouse_Hide_Mouse_Hook != NULL) (*JMouse_Hide_Mouse_Hook) (0); #endif shift = *Shift_Ptr & 0xF; i = BIOSKEY(0); i = jed_scan_to_key (i, shift, chbuf); while (i > 1) { int ch; i--; ch = chbuf[i]; ungetkey (&ch); } return chbuf[0]; } /*}}}*/ /* sleep for *tsecs tenths of a sec waiting for input */ int sys_input_pending(int *tsecs, int unused) /*{{{*/ { int count = *tsecs * 5; (void) unused; if (Batch || Input_Buffer_Len) return(Input_Buffer_Len); if (count) { while (count > 0) { if (BIOSKEY(1) #ifdef HAS_MOUSE || ((JMouse_Event_Hook != NULL) && ((*JMouse_Event_Hook)() > 0)) #endif ) break; (*delay_ptr) (20); count--; } return (count); } if (BIOSKEY(1) #ifdef HAS_MOUSE || ((JMouse_Event_Hook != NULL) && ((*JMouse_Event_Hook)() > 0)) #endif ) return 1; return 0; } /*}}}*/ void sys_pause (int ms) /*{{{*/ { (*delay_ptr) (ms); } /*}}}*/ int sys_chmod(SLFUTURE_CONST char *file, int what, mode_t *mode, uid_t *dum1, gid_t *dum2) /*{{{*/ { int flag = 0, m = *mode; (void) dum1; (void) dum2; file = msdos_pinhead_fix_dir (file); asm mov ah, 43h asm mov al, byte ptr what asm mov cx, m asm push ds asm lds dx, dword ptr file asm int 21h asm pop ds asm mov m, cx asm jnc L1 asm mov flag, ax /* Here if carry flag is set */ if (flag == 0x2) return(0); /* file not found */ if (flag == 0x3) return(-2); /* msg_error("Path does not exist."); */ /* else return (-3); */ /* sprintf(buf, "chmod: Unknown Error. %d", out.x.ax); msg_error(buf); */ return(-1); /* carry flag is 0 */ L1: if (what == 0) { *mode = m; } if (m & 0x10) { /* msg_error("File is a directory."); */ return(2); } return(1); } /*}}}*/ typedef struct Dos_DTA_Type /*{{{*/ { unsigned char undoc[21]; unsigned char attr; unsigned int time; unsigned int date; unsigned char low_size[2]; unsigned char high_size[2]; char name[13]; } Dos_DTA_Type; /*}}}*/ static Dos_DTA_Type Dos_DTA; static void set_dta (void) /*{{{*/ { Dos_DTA_Type *dummy = &Dos_DTA; asm mov ah, 0x1A asm push ds asm lds dx, dword ptr dummy asm int 21h asm pop ds } /*}}}*/ static int File_Attr; #define HIDDEN 0x2 #define SYSTEM 0x4 #define SUBDIR 0x10 #define READON 0x1 static char Found_Dir[JED_MAX_PATH_LEN]; #define lcase(x) if (((x) >= 'A') && ((x) <= 'Z')) (x) |= 0x20 void dta_fixup_name(char *file) /*{{{*/ { int dir; char *p, name[13]; strcpy(file, Found_Dir); strcpy(name, Dos_DTA.name); dir = (Dos_DTA.attr & SUBDIR); p = name; while (*p) { lcase(*p); p++; } strcat(file, name); if (dir) strcat(file, "\\"); } /*}}}*/ int sys_findfirst(char *thefile) /*{{{*/ { char *f, the_path[JED_MAX_PATH_LEN], *file, *f1; char *pat, *fudge; set_dta(); File_Attr = READON | SUBDIR; file = jed_standardize_filename_static(thefile); f1 = f = extract_file(file); strcpy (Found_Dir, file); Found_Dir[(int) (f - file)] = 0; strcpy(the_path, file); while (*f1 && (*f1 != '*')) f1++; if (! *f1) { while (*f && (*f != '.')) f++; if (*f) strcat(the_path, "*"); else strcat(the_path, "*.*"); } pat = the_path; /* Something is very wrong after this returns. * thefile gets trashed for some reason. Here I fudge until I figure * out what is going on * * Note: This has been fixed. I am just too lazy to remove the fudge. */ fudge = thefile; asm mov ah, 0x4e asm mov cx, File_Attr asm push ds asm lds dx, dword ptr pat asm int 21h asm pop ds asm jc L1 thefile = fudge; /* fprintf(stderr, "asm:%lu\t|%s|\n", thefile, thefile); */ dta_fixup_name(file); strcpy(thefile, file); return(1); L1: return 0; } /*}}}*/ int sys_findnext(char *file) /*{{{*/ { asm mov ah, 0x4F asm int 21h asm jc L1 dta_fixup_name(file); return(1); L1: return(0); } /*}}}*/ jed-0.99-19/src/screen.h0000644002657400265740000000505711311317447013720 0ustar davisdavis#ifndef _JED_SCREEN_H_ #define _JED_SCREEN_H_ /* Copyright (c) 1992, 1998, 2000, 2005, 2006 John E. Davis * This file is part of JED editor library source. * * You may distribute this file under the terms the GNU General Public * License. See the file COPYING for more information. */ #include "window.h" /* JED screen management routines */ extern int Screen_Row; /* cursor row */ extern int Screen_Col; /* cursor col */ extern int Cursor_Motion; /* cursor movement only */ extern void recenter(int *); extern int window_line(void); extern void scroll_down(int, int, int); extern int scroll_up(int, int, int); extern void update(Line *, int, int, int); extern void jed_init_display (void); extern void jed_reset_display(void); extern void point_cursor(int); extern void point_column(int); extern int calculate_column(void); extern void register_change(int); extern void touch_window(void); extern int cursor_visible(void); extern Line *find_top(void); extern Line *jed_find_top_to_recenter (Line *); extern char Message_Buffer[256]; extern void message(char *); extern void clear_message (void); extern void flush_message(char *); extern void jed_fillmem(char *, char, int); extern int Goal_Column; extern int User_Prefers_Line_Numbers; extern int Wants_Attributes; extern int Term_Supports_Color; extern int Wants_Syntax_Highlight; extern int Display_Time; extern int Want_Eob; extern void set_status_format(char *, int *); extern void init_syntax_highlight (void); extern void write_syntax_highlight (int, Line *, unsigned int); extern int Mode_Has_Syntax_Highlight; extern int Wants_HScroll; extern int Mini_Ghost; extern void jed_redraw_screen(int); extern void define_top_screen_line(char *); extern void jed_resize_display (void); extern volatile int Jed_Resize_Pending; extern int jed_compute_effective_length (unsigned char *, unsigned char *); extern int jed_find_line_on_screen (Line *, int); extern int jed_get_screen_size (int *, int *); #define JED_HAS_DISPLAY_TABLE 0 #if JED_HAS_DISPLAY_TABLE extern unsigned char Output_Display_Table[256]; #endif #if JED_HAS_LINE_ATTRIBUTES extern Line *jed_find_non_hidden_line (Line *); #endif extern int Jed_Version_Number; extern char *Jed_Version_String; extern int Jed_Dollar; extern int Jed_Num_Screen_Rows; extern int Jed_Num_Screen_Cols; extern int Jed_Highlight_WS; /* bitmapped */ #define HIGHLIGHT_WS_TRAILING 1 #define HIGHLIGHT_WS_TAB 2 extern char *MiniBuf_Get_Response_String; extern int Jed_Simulate_Graphic_Chars; extern int Jed_Display_Initialized; #endif /* #ifdef _JED_SCREEN_H_ */ jed-0.99-19/src/jprocess.c0000644002657400265740000007704411311317447014271 0ustar davisdavis/* -*- mode: C; mode: fold; -*- */ /* Copyright (c) 1992, 1998, 2000, 2002, 2003, 2004, 2005, 2006 John E. Davis * This file is part of JED editor library source. * * You may distribute this file under the terms the GNU General Public * License. See the file COPYING for more information. */ #include "config.h" #include "jed-feat.h" #include #if defined(__QNX__) && defined(__WATCOMC__) # include #endif #if JED_HAS_SUBPROCESSES /* Everything else here is in this '#if' */ /*{{{ Include Files */ #include #include #include #ifdef __os2__ # include # include #endif #if defined(__BORLANDC__) && (__BORLANDC__>>8)==5 /* [JMS:MISC] - needed for open/close in BC v5 */ # include # include #endif #include #include "jdmacros.h" #ifdef HAVE_UNISTD_H # include # include #endif #include #ifdef HAVE_SYS_WAIT_H # include #endif #ifdef HAVE_SYS_FCNTL_H # include #endif #ifndef WEXITSTATUS # define WEXITSTATUS(stat_val) ((unsigned)(stat_val) >> 8) #endif #ifndef WIFEXITED # define WIFEXITED(stat_val) (((stat_val) & 255) == 0) #endif #ifdef REALLY_HAVE_TERMIOS_H # if !defined(__os2__) && !defined(__APPLE__) # define USE_PTY # endif #endif #include "buffer.h" #include "ins.h" #include "ledit.h" #include "misc.h" #include "jprocess.h" #include "paste.h" #include "sysdep.h" #include "sig.h" #include "cmds.h" /*}}}*/ #define MAX_TTY_SLAVE_NAME 256 int Num_Subprocesses; int Max_Subprocess_FD; /* This also servers as a lookup table for actual system pids to the * pseudo-pids used here. See, e.g., jed_get_child_status for usage in this * fashion. */ int Subprocess_Read_fds [MAX_PROCESSES][3]; /* 0 is actual fd, 1 is our rep, 2 will be set to 1 if an EIO is present */ volatile int Child_Status_Changed_Flag;/* if this is non-zero, editor * should call the appropriate * function below to call slang * handlers. */ typedef struct /*{{{*/ { int flags; /* This is zero if the process is gone * and the status is nolonger avail */ #define PROCESS_RUNNING 1 #define PROCESS_STOPPED 2 #define PROCESS_ALIVE 3 #define PROCESS_EXITED 4 #define PROCESS_SIGNALLED 8 int return_status; /* This value depends on the flags */ int status_changed; /* non-zero if status changed. */ int rd, wd; /* read/write descriptors */ int is_pty; int pid; /* real process pid */ int output_type; #define PROCESS_USE_BUFFER 1 #define PROCESS_USE_SLANG 2 #define PROCESS_SAVE_POINT 4 #define PROCESS_AT_POINT 8 Buffer *buffer; /* buffer associated with process */ SLang_Name_Type *slang_fun; /* function to pass output to */ SLang_MMT_Type *umark; /* marks point of last output */ int process_flags; #define USE_CURRENT_BUFFER 0x1 /* use the current buffer instead of * the one associated with the process */ SLang_Name_Type *status_change_fun; /* call this if process status changes * The function should be declared like * define fun (pid, flags, status); * The flags parameter corresponds to * the flags field in this struct and * the pid is NOT the pid of this struct. * status depends upon flags. */ int quietly_kill_on_exit; } /*}}}*/ Process_Type; static Process_Type Processes[MAX_PROCESSES]; static int signal_safe_close (int fd) { while (-1 == close (fd)) { #ifdef EINTR if (errno == EINTR) continue; #endif return -1; } return 0; } static int signal_safe_open (char *file, int mode) { int fd; while (-1 == (fd = open (file, mode))) { #ifdef EINTR if (errno == EINTR) continue; #endif #ifdef EAGAIN if (errno == EAGAIN) { sleep (1); continue; } #endif return -1; } return fd; } static int signal_safe_fcntl (int fd, int cmd, int arg) { int ret; while (-1 == (ret = fcntl (fd, cmd, arg))) { #ifdef EINTR if (errno == EINTR) continue; #endif #ifdef EAGAIN if (errno == EAGAIN) { sleep (1); continue; } #endif return -1; } return ret; } static int signal_safe_dup2 (int fd1, int fd2) { while (-1 == dup2 (fd1, fd2)) { #ifdef EINTR if (errno == EINTR) continue; #endif return -1; } return 0; } static Process_Type *get_process (int fd) /*{{{*/ { Process_Type *p; if ((fd >= 0) && (fd < MAX_PROCESSES) && (p = &Processes[fd], p->flags != 0)) return p; jed_verror ("process '%d' does not exist.", fd); return NULL; } /*}}}*/ static void call_slang_status_change_hook (Process_Type *p) /*{{{*/ { Buffer *cbuf = CBuf; if ((p->status_change_fun == NULL) || (p->buffer == NULL)) return; cbuf->locked++; if (0 == (p->process_flags & USE_CURRENT_BUFFER)) switch_to_buffer (p->buffer); SLang_push_integer ((int) (p - Processes)); SLang_push_integer (p->flags); SLang_push_integer (p->return_status); SLexecute_function (p->status_change_fun); touch_screen (); if ((0 == (p->process_flags & USE_CURRENT_BUFFER)) && (CBuf != cbuf)) switch_to_buffer (cbuf); cbuf->locked--; } /*}}}*/ #if 1 int jed_signal_process (int *fd, int *sig) /*{{{*/ { Process_Type *p; if (NULL == (p = get_process (*fd))) return -1; kill (p->pid, *sig); return 0; } int jed_signal_fg_process (int *fd, int *sig) /*{{{*/ { int pid; Process_Type *p; if (NULL == (p = get_process (*fd))) return -1; #ifdef HAVE_TCGETPGRP pid = tcgetpgrp (p->rd); if (pid == -1) #endif pid = p->pid; (void) kill (-pid, *sig); return 0; } /*}}}*/ #endif static void close_rd_and_wd (Process_Type *p) /*{{{*/ { if (p->rd != -1) { signal_safe_close (p->rd); p->rd = -1; } if (p->wd != -1) { if (p->is_pty == 0) signal_safe_close (p->wd); p->wd = -1; } } /*}}}*/ /* This routine is called to clean up after the process has exited. * After getting the exit status, we call a slang hook and if the * process is dead, adjust the process arrays to delete the process. */ static void get_process_status (Process_Type *p) /*{{{*/ { int i; int fd, slfd; /* Call slang to let it know what happened. Do it first before we * really shut it down to give the hook a chance to query the state of * it before it returns. */ call_slang_status_change_hook (p); if (p->flags & PROCESS_ALIVE) return; /* Process is dead. So perform clean up. */ close_rd_and_wd (p); if (p->buffer != NULL) p->buffer->subprocess = 0; slfd = (int) (p - Processes); if (p->umark != NULL) SLang_free_mmt (p->umark); #if SLANG_VERSION > 10400 SLang_free_function (p->slang_fun); SLang_free_function (p->status_change_fun); #endif memset ((char *)p, 0, sizeof (Process_Type)); p->rd = p->wd = -1; /* Adjust the array of read descriptors */ i = 0; while (i < Num_Subprocesses) { if (Subprocess_Read_fds[i][1] == slfd) break; i++; } fd = Subprocess_Read_fds [i][0]; Num_Subprocesses--; while (i < Num_Subprocesses) { Subprocess_Read_fds[i][0] = Subprocess_Read_fds[i + 1][0]; Subprocess_Read_fds[i][1] = Subprocess_Read_fds[i + 1][1]; Subprocess_Read_fds[i][2] = Subprocess_Read_fds[i + 1][2]; i++; } if (Max_Subprocess_FD == fd) { i = 0; fd = -1; while (i < Num_Subprocesses) { if (Subprocess_Read_fds[i][0] > fd) fd = Subprocess_Read_fds[i][0]; i++; } Max_Subprocess_FD = fd; } } /*}}}*/ int jed_close_process (int *fd) /*{{{*/ { Process_Type *p; if (NULL == (p = get_process (*fd))) return -1; close_rd_and_wd (p); kill (-p->pid, SIGINT); /* This is probably a bad idea. It is better to check to see if it still * around and the set a flag indicating that the user wants it killed. */ /* Did we kill it? Make sure. */ kill (-p->pid, SIGKILL); if (p->buffer != NULL) p->buffer->subprocess = 0; /* This next function wraps things up --- no need to. Let handler do it. */ /* get_process_status (p); */ return 0; } /*}}}*/ void jed_kill_process (int fd) /*{{{*/ { /* This function is called when the buffer is going to be destroyed */ Processes[fd].buffer = NULL; jed_close_process (&fd); } /*}}}*/ void jed_get_child_status (void) /*{{{*/ { Process_Type *p, *pmax; Ignore_User_Abort++; if (SLang_get_error ()) { Ignore_User_Abort--; return; } /* FIXME: We should block SIGCHLD before trying to access this flag, * or anything in this function for that matter. */ Child_Status_Changed_Flag--; get_process_input (&Number_Zero); p = Processes; pmax = p + MAX_PROCESSES; while (p < pmax) { if (p->flags && p->status_changed) { read_process_input ((int) (p - Processes)); p->status_changed--; get_process_status (p); } p++; } Ignore_User_Abort--; } /*}}}*/ static void child_signal_handler (int sig) /*{{{*/ { int status; int found; int save_errno = errno; (void) sig; do { Process_Type *p, *pmax; found = 0; p = Processes; pmax = p + MAX_PROCESSES; while (p < pmax) { int pid; if ((pid = p->pid) <= 0) { p++; continue; } while ((-1 == (pid = (int) waitpid (p->pid, &status, WNOHANG | WUNTRACED))) && (errno == EINTR)) ; if (p->pid == pid) { int return_status; found++; if (WIFEXITED (status)) { return_status = WEXITSTATUS (status); status = PROCESS_EXITED; } else if (WIFSIGNALED (status)) { return_status = WTERMSIG (status); status = PROCESS_SIGNALLED; } #ifdef WIFSTOPPED else if (WIFSTOPPED (status)) { return_status = WSTOPSIG(status); status = PROCESS_STOPPED; } #endif p->flags = status; p->status_changed++; p->return_status = return_status; } p++; } } while (found != 0); SLsignal_intr (SIGCHLD, child_signal_handler); errno = save_errno; Child_Status_Changed_Flag++; } /*}}}*/ #ifdef USE_PTY # include "pty.c" #endif static int get_master_slave_fds (int *slave_read, int *slave_write, int *master_read, int *master_write, char *slave_tty_name, int *is_pty, int want_pty) { #ifdef USE_PTY if (want_pty) { int master; if (-1 == pty_open_master_pty (&master, slave_tty_name)) return -1; *master_read = *master_write = master; *slave_read = *slave_write = -1; *is_pty = 1; } else { #endif int fds0[2], fds1[2]; if (-1 == pipe (fds0)) return -1; if (-1 == pipe (fds1)) { signal_safe_close (fds0[0]); signal_safe_close (fds0[1]); return -1; } *master_read = fds0[0]; *slave_write = fds0[1]; *master_write = fds1[1]; *slave_read = fds1[0]; *slave_tty_name = 0; *is_pty = 0; #ifdef USE_PTY } #endif return 0; } static void my_setenv (char *what, char *value) { #ifdef HAVE_SETENV (void) setenv (what, value, 1); #else # ifdef HAVE_PUTENV char buf[512]; SLsnprintf (buf, sizeof (buf), "%s=%s", what, value); (void) putenv (buf); # endif #endif } static void my_unsetenv (char *what) { #ifdef HAVE_UNSETENV unsetenv (what); #endif } #ifdef __os2__ static int open_process (char *pgm, char **argv, int want_pty) /*{{{*/ { int val; int pd; int slave_read, slave_write, master_read, master_write, org_fd[3]; int pid, i; Process_Type *p; SLang_MMT_Type *mmt; char slave_tty_name [MAX_TTY_SLAVE_NAME]; int max_write_tries; SLSig_Fun_Type *sig_orig[NSIG]; if (Jed_Secure_Mode) { msg_error ("Access to shell denied."); return -1; } pd = 0; while ((pd < MAX_PROCESSES) && Processes[pd].flags) pd++; if (pd == MAX_PROCESSES) return -1; p = &Processes[pd]; SLMEMSET ((char *) p, 0, sizeof (Process_Type)); if (NULL == (mmt = jed_make_user_object_mark ())) return -1; if (-1 == get_master_slave_fds (&slave_read, &slave_write, &master_read, &master_write, slave_tty_name, &p->is_pty, want_pty)) { SLang_free_mmt (mmt); return -1; } SLsignal_intr (SIGCHLD, child_signal_handler); { char ch; /* At this point the slave tty is in raw mode. Make sure that * the read to synchronize with the parent blocks. */ val = signal_safe_fcntl (slave_read, F_GETFL, 0); signal_safe_fcntl (slave_read, F_SETFL, val & ~O_NONBLOCK); signal_safe_fcntl (slave_read, F_SETFL, val); org_fd[0] = dup(0); org_fd[1] = dup(1); org_fd[2] = dup(2); signal_safe_close (0); signal_safe_close (1); signal_safe_close (2); signal_safe_dup2(slave_read, 0); /* stdin */ signal_safe_dup2 (slave_write, 1); /* stdout */ signal_safe_dup2 (slave_write, 2); /* stderr */ signal_safe_close (slave_read); signal_safe_close (slave_write); setvbuf (stdout, NULL, _IONBF, 0); for (i=1 ; iflags = 0; SLang_free_mmt (mmt); return -1; } p->pid = pid; } p->flags = PROCESS_RUNNING; p->rd = master_read; p->wd = master_write; Subprocess_Read_fds[Num_Subprocesses][0] = master_read; Subprocess_Read_fds[Num_Subprocesses][1] = pd; Subprocess_Read_fds[Num_Subprocesses][2] = 0; if (master_read > Max_Subprocess_FD) Max_Subprocess_FD = master_read; Num_Subprocesses += 1; val = signal_safe_fcntl (master_read, F_GETFL, 0); val |= O_NONBLOCK; signal_safe_fcntl (master_read, F_SETFL, val); CBuf->subprocess = pd + 1; /* Processing options */ p->buffer = CBuf; p->output_type = PROCESS_USE_BUFFER; p->umark = mmt; SLang_inc_mmt (mmt); /* tell slang we are keeping a copy */ return pd; } /*}}}*/ #else /* unix and compatible OS */ static volatile int SigUsr_Flag; static void sigusr_handler (int sig) { (void) sig; SigUsr_Flag = 1; } static sigset_t Old_Signal_Mask, Zero_Signal_Mask; static int init_child_parent_sync (void) { sigset_t new_mask; if (SIG_ERR == SLsignal (SIGUSR1, sigusr_handler)) return -1; /* Get a copy of the current signal mask */ while ((-1 == sigprocmask (SIG_BLOCK, NULL, &Zero_Signal_Mask)) && (errno == EINTR)) ; /* and remove SIGUSR1 from it. */ sigdelset (&Zero_Signal_Mask, SIGUSR1); /* Add SIGUSR1 to the set of currently blocked signals */ sigemptyset (&new_mask); sigaddset (&new_mask, SIGUSR1); while ((-1 == sigprocmask (SIG_BLOCK, &new_mask, &Old_Signal_Mask)) && (errno == EINTR)) ; SigUsr_Flag = 0; return 0; } static void wait_for_parent (void) { /* Suspend this process and wait for a signal. All signals are allowed * here. */ while (SigUsr_Flag == 0) sigsuspend (&Zero_Signal_Mask); } static void tell_parent_to_go (pid_t pid) { SigUsr_Flag = 0; kill (pid, SIGUSR1); while ((-1 == sigprocmask (SIG_SETMASK, &Old_Signal_Mask, NULL)) && (errno == EINTR)) ; } static void tell_child_to_go (pid_t pid) { SigUsr_Flag = 0; kill (pid, SIGUSR1); /* Now wait for the child to setup the pty */ while (SigUsr_Flag == 0) sigsuspend (&Zero_Signal_Mask); while ((-1 == sigprocmask (SIG_SETMASK, &Old_Signal_Mask, NULL)) && (errno == EINTR)) ; } static int set_non_blocking_io (int fd) { int val; val = signal_safe_fcntl (fd, F_GETFL, 0); return signal_safe_fcntl (fd, F_SETFL, val | O_NONBLOCK); } #ifdef SIGTRAP static void sigtrap_handler (int sig) { (void) sig; } #endif static int open_process (char *pgm, char **argv, int want_pty) /*{{{*/ { int pd; int slave_read, slave_write, master_read, master_write; int pid, jed_pid, i; Process_Type *p; SLang_MMT_Type *mmt; char slave_tty_name [MAX_TTY_SLAVE_NAME]; if (Jed_Secure_Mode) { msg_error ("Access to shell denied."); return -1; } pd = 0; while ((pd < MAX_PROCESSES) && Processes[pd].flags) pd++; if (pd == MAX_PROCESSES) return -1; p = &Processes[pd]; SLMEMSET ((char *) p, 0, sizeof (Process_Type)); if (NULL == (mmt = jed_make_user_object_mark ())) return -1; if (-1 == get_master_slave_fds (&slave_read, &slave_write, &master_read, &master_write, slave_tty_name, &p->is_pty, want_pty)) { SLang_free_mmt (mmt); return -1; } SLsignal_intr (SIGCHLD, child_signal_handler); jed_pid = getpid (); /* used by slave */ if ((-1 == init_child_parent_sync ()) || ((pid = fork ()) < 0)) { signal_safe_close (master_read); if (p->is_pty == 0) { signal_safe_close (slave_read); signal_safe_close (master_write); signal_safe_close (slave_write); } p->flags = 0; SLang_free_mmt (mmt); return -1; } p->pid = pid; /* Make the child its own process group leader. Do it here too because * we are not sure which one will run first. We have to do this because * if not, a ^G will be sent to ALL child subprocesses possibly killing * them unless they catch the signal. This call means that the INTR signal * will not be sent to any child processes sent by this fork. */ if (p->is_pty == 0) setpgid(pid, pid); if (pid == 0) { /* child code */ wait_for_parent (); if (p->is_pty == 0) signal_safe_close (master_write); /* close write end of 0 */ signal_safe_close (master_read); /* close read end of 1 */ #ifdef USE_PTY /* Call set setsid so that the child will become the session leader. * This has the side effect that we will loose the controlling * terminal. For this reason, the pty slave is opened after setsid * and then for good luck, the controlling terminal is set * via the TIOCSCTTY ioctl. */ if (p->is_pty) { if (-1 == setsid ()) fprintf (stderr, "child: setsid failed.\n"); if (-1 == pty_open_slave_pty (slave_tty_name, &slave_read)) { tell_parent_to_go (jed_pid); fprintf (stderr, "child: failed to open slave."); _exit (1); } slave_write = slave_read; /* (void) pty_setup_slave_term (slave_read, 0); */ } #endif /* USE_PTY */ tell_parent_to_go (jed_pid); #ifdef USE_PTY /* Put tty back into cbreak mode. */ if (p->is_pty) (void) pty_setup_slave_term (slave_read, 0); #endif if ((signal_safe_dup2(slave_read, 0) < 0) /* stdin */ || (signal_safe_dup2 (slave_write, 1) < 0) /* stdout */ || (signal_safe_dup2 (slave_write, 2) < 0)) /* stderr */ { fprintf (stderr, "dup2 failed. errno = %d\n", errno); _exit (1); } my_setenv ("TERM", "unknown"); my_unsetenv ("TERMCAP"); for (i = 0; i < 32; i++) { #ifdef SIGTRAP /* Under Linux, subprocesses fail if run under the debugger because * something sends this child a SIGTRAP. Let's try ignoring it. */ if (i == SIGTRAP) SLsignal (i, sigtrap_handler); else #endif SLsignal (i, SIG_DFL); } #ifdef SIGTRAP SLsignal (SIGTRAP, SIG_DFL); #endif if (execvp (pgm, argv) < 0) { fprintf (stderr, "execvp of %s failed!\r\n", pgm); _exit (1); } } /* parent */ if (p->is_pty == 0) { signal_safe_close (slave_read); signal_safe_close (slave_write); } p->flags = PROCESS_RUNNING; p->rd = master_read; p->wd = master_write; Subprocess_Read_fds[Num_Subprocesses][0] = master_read; Subprocess_Read_fds[Num_Subprocesses][1] = pd; Subprocess_Read_fds[Num_Subprocesses][2] = 0; if (master_read > Max_Subprocess_FD) Max_Subprocess_FD = master_read; Num_Subprocesses += 1; CBuf->subprocess = pd + 1; /* Processing options */ p->buffer = CBuf; p->output_type = PROCESS_USE_BUFFER; p->umark = mmt; SLang_inc_mmt (mmt); /* tell slang we are keeping a copy */ set_non_blocking_io (master_read); set_non_blocking_io (master_write); /* Tell child it is ok to go. */ tell_child_to_go (pid); return pd; } /*}}}*/ #endif /* __os2__ */ static int flag_fd_as_eio_error (int fd) { unsigned int i, n; n = Num_Subprocesses; for (i = 0; i < n; i++) { if (Subprocess_Read_fds[i][0] == fd) { Subprocess_Read_fds[i][2] = 1; return 0; } } return -1; } /* This function is only called when we are reading characters from the * keyboard. Keyboard input has the highest priority and this is called only * if there is no input ready. * * It might also get called by the hooks that it calls. As a result, it must * be reentrant. * * It is possible for the user to press Ctrl-G while this routine is executing. * This could cause slang hooks to fail. It would probably be better to * block SIGINT for the duration of this routine. */ void read_process_input (int fd) /*{{{*/ { unsigned char buf[513]; /* last byte for 0 char */ int n; Buffer *b = CBuf, *pbuf; Process_Type *p; int otype, total; /* Should never happen */ if (NULL == (p = get_process (fd))) { return; } Ignore_User_Abort++; if (SLang_get_error ()) { Ignore_User_Abort--; return; } otype = p->output_type; pbuf = p->buffer; if (pbuf != NULL) { if (0 == (p->process_flags & USE_CURRENT_BUFFER)) switch_to_buffer (pbuf); pbuf->locked++; } total = 0; if (otype & PROCESS_SAVE_POINT) push_spot (); while ((n = read (p->rd, buf, 512)) > 0) { total += n; if (p->buffer == NULL) continue; if (otype & PROCESS_USE_BUFFER) { if (0 == (otype & PROCESS_AT_POINT)) eob (); (void) jed_insert_nbytes (buf, n); jed_move_user_object_mark (p->umark); } else if (otype == PROCESS_USE_SLANG) { buf[n] = 0; if ((-1 == SLang_push_integer ((int) (p - Processes))) || (-1 == SLang_push_string ((char *) buf)) || (-1 == SLexecute_function (p->slang_fun))) { /* It looks like the contents of buf may be lost */ break; } } } if (n == -1) { #ifdef EIO if (errno == EIO) (void) flag_fd_as_eio_error (p->rd); #endif } if (otype & PROCESS_SAVE_POINT) pop_spot (); else if (otype & PROCESS_USE_BUFFER) move_window_marks (0); if (p->buffer != NULL) { if ((b != CBuf) && (0 == (p->process_flags & USE_CURRENT_BUFFER))) switch_to_buffer (b); } /* Since it was locked, it cannot be deleted. So pbuf is still a good * pointer */ if (pbuf != NULL) pbuf->locked--; if (total) { #ifdef __os2__ /* Why does OS/2 need this?? -- JED */ JWindow->trashed = 1; update ((Line *)NULL, 0, 1, 0); #endif touch_screen (); } Ignore_User_Abort--; } /*}}}*/ static int write_to_process (int fd, char *buf, unsigned int len) { int n, ilen; if (len == 0) return 0; ilen = (int) len; n = 0; while (n < ilen) { int dn; int count = 0; while (-1 == (dn = write (fd, buf + n, ilen - n))) { if (errno == EINTR) continue; #ifdef EAGAIN if (errno == EAGAIN) { get_process_input (&Number_Zero); count++; if ((count % 10) == 0) { sleep (1); if (count > 20) return n; } continue; } #endif return -1; } if (dn == 0) break; n += dn; } return n; } int jed_send_process (int *fd, char *str) /*{{{*/ { unsigned int len; Process_Type *p = get_process (*fd); if ((p == NULL) || (p->wd == -1)) return -1; len = strlen (str); if (len != (unsigned int) write_to_process (p->wd, str, len)) jed_verror ("write to process failed"); return len; } /*}}}*/ void jed_send_process_eof (int *fd) /*{{{*/ { Process_Type *p = get_process (*fd); if (p == NULL) return; if (p->wd == -1) return; if (p->is_pty) write_to_process (p->wd, "\004", 1); else { signal_safe_close (p->wd); p->wd = -1; } } /*}}}*/ /* If s is NULL, then f != NULL, or visa-versa */ static int set_process (Process_Type *p, char *what, char *s, SLang_Name_Type *f) /*{{{*/ { if (!strcmp (what, "output")) { if (s != NULL) { if (0 == strcmp (s, ".")) { p->output_type = PROCESS_AT_POINT | PROCESS_USE_BUFFER; return 0; } if (0 == strcmp (s, "@")) { p->output_type = PROCESS_SAVE_POINT | PROCESS_USE_BUFFER; return 0; } if (*s == 0) { p->output_type = PROCESS_USE_BUFFER; return 0; } if (NULL == (f = SLang_get_function (s))) return -1; } p->output_type = PROCESS_USE_SLANG; p->slang_fun = f; return 0; } else if (!strcmp (what, "signal")) { if ((s != NULL) && (NULL == (f = SLang_get_function (s)))) return -1; p->status_change_fun = f; return 0; } jed_verror ("set_process: %s not supported", what); return -1; } /*}}}*/ void jed_set_process (void) { int pd; char *what, *s; Process_Type *p; SLang_Name_Type *f; f = NULL; what = NULL; s = NULL; if (SLang_peek_at_stack () == SLANG_REF_TYPE) { if (NULL == (f = SLang_pop_function ())) return; } else if (-1 == SLang_pop_slstring (&s)) return; if ((0 == SLang_pop_slstring (&what)) && (0 == SLang_pop_integer (&pd)) && (NULL != (p = get_process (pd))) && (0 == set_process (p, what, s, f))) f = NULL; SLang_free_slstring (what); SLang_free_slstring (s); #if SLANG_VERSION > 10400 SLang_free_function (f); #endif } void jed_set_process_flags (int *fd, int *oflags) { Process_Type *p; if (NULL == (p = get_process (*fd))) return; p->process_flags = *oflags; } int jed_get_process_flags (int *fd) { Process_Type *p; if (NULL == (p = get_process (*fd))) return -1; return p->process_flags; } void jed_get_process_mark (int *fd) /*{{{*/ { Process_Type *p; if (NULL == (p = get_process (*fd))) return; SLang_push_mmt (p->umark); } /*}}}*/ static int open_process_of_type (int nargs, int wantpty) /*{{{*/ { int fd = -1; char *argv[502]; int n = nargs; if (CBuf->subprocess) { msg_error ("There is already a process attached to this buffer."); return -1; } if ((n > 500) || (n < 0)) { msg_error ("Arguments out of range."); return -1; } n++; /* for argv0 since *np does not include * it. */ argv[n] = NULL; while (n--) { if (SLang_pop_slstring (&argv[n])) { n++; goto free_return; } } n = 0; if ((fd = open_process(argv[0], argv, wantpty)) < 0) { jed_verror ("Unable to open %s process.", argv[0]); } /* free up the argument strings */ free_return: while (n <= nargs) { SLang_free_slstring (argv[n]); n++; } return fd; } /*}}}*/ int jed_open_process (int *np) { return open_process_of_type (*np, 1); } int jed_open_process_pipe (int *np) { return open_process_of_type (*np, 0); } void jed_block_child_signal (int block) /*{{{*/ { static sigset_t new_mask, old_mask; if (block) { sigemptyset (&new_mask); sigaddset (&new_mask, SIGCHLD); (void) sigprocmask (SIG_BLOCK, &new_mask, &old_mask); return; } (void) sigprocmask (SIG_SETMASK, &old_mask, NULL); } /*}}}*/ /* Jed only calls these in pairs so that this should be fine. */ FILE *jed_popen (char *cmd, char *type) /*{{{*/ { FILE *pp; jed_block_child_signal (1); pp = popen (cmd, type); if (pp == NULL) jed_block_child_signal (0); return pp; } /*}}}*/ int jed_pclose (FILE *fp) /*{{{*/ { int ret; if (fp == NULL) return -1; ret = pclose (fp); jed_block_child_signal (0); return ret; } /*}}}*/ #if 0 /* These are my versions of popen/pclose. For some reason, the popen/pclose * do not work on SunOS when there are subprocesses. I think it has * something to do with the way pclose is waiting. * See Steven's book for more information. */ #ifndef OPEN_MAX #define OPEN_MAX 256 #endif static pid_t Popen_Child_Pids[OPEN_MAX]; FILE *jed_popen(char *cmd, char *type) /*{{{*/ { int i, pfd[2], fd; pid_t pid; FILE *fp; if (((*type != 'r') && (*type != 'w')) || (*(type + 1) != 0)) { errno = EINVAL; /* required by POSIX.2 */ return(NULL); } if (pipe(pfd) < 0) return(NULL); /* errno set by pipe() or fork() */ if ((pid = fork()) < 0) return(NULL); if (pid == 0) { /* child */ if (*type == 'r') { signal_safe_close(pfd[0]); if (pfd[1] != 1) signal_safe_dup2(pfd[1], 1); signal_safe_close(pfd[1]); } else { signal_safe_close(pfd[1]); if (pfd[0] != 0) { signal_safe_dup2(pfd[0], STDIN_FILENO); signal_safe_close(pfd[0]); } } /* POSIX requires that all streams open by previous popen * be closed. */ for (i = 0; i < OPEN_MAX; i++) { if (Popen_Child_Pids[i] > 0) signal_safe_close(i); } execl("/bin/sh", "sh", "-c", cmd, (char *) 0); _exit(127); } /* parent */ if (*type == 'r') { signal_safe_close(pfd[1]); if (NULL == (fp = fdopen(pfd[0], type))) return(NULL); } else { signal_safe_close(pfd[0]); if (NULL == (fp = fdopen(pfd[1], type))) return(NULL); } fd = fileno (fp); if (fd >= OPEN_MAX) { #ifdef EMFILE errno = EMFILE; #endif fclose (fp); return NULL; } Popen_Child_Pids [fd] = pid; return(fp); } /*}}}*/ int jed_pclose(FILE *fp) /*{{{*/ { int fd, stat; pid_t pid; int ret; fd = fileno(fp); if ((fd >= OPEN_MAX) || (fd < 0) || (0 == (pid = Popen_Child_Pids[fd]))) return -1; Popen_Child_Pids [fd] = 0; if (fclose(fp) == EOF) return(-1); /* This is the part that the SunOS pclose was apparantly screwing up. */ while (-1 == waitpid(pid, &stat, 0)) { if (errno != EINTR) return -1; (void) SLang_handle_interrupt (); } ret = WEXITSTATUS(stat); if (WIFEXITED (stat)) return ret; return -1; } /*}}}*/ #endif void jed_query_process_at_exit (int *pid, int *query) { Process_Type *p; if (NULL == (p = get_process (*pid))) return; p->quietly_kill_on_exit = (*query == 0); } int jed_processes_ok_to_exit (void) { Process_Type *p, *pmax; int num; char buf[64]; if (Num_Subprocesses == 0) return 1; num = 0; p = Processes; pmax = p + MAX_PROCESSES; while (p < pmax) { if ((p->flags & PROCESS_ALIVE) && (0 == p->quietly_kill_on_exit)) num++; p++; } if (num == 0) return 1; sprintf (buf, "%d Subprocesses exist. Exit anyway", num); return jed_get_y_n (buf); } int jed_fork_monitor (void) { pid_t pid; int i; while (-1 == (pid = fork ())) { if (errno == EINTR) continue; fprintf (stderr, "Unable to fork: errno=%d\n", errno); return -1; } if (pid != 0) return 0; pid = getppid (); for (i = 1; i < 32; i++) (void) SLsignal (i, SIG_IGN); SLsignal (SIGQUIT, SIG_DFL); SLsignal (SIGTERM, SIG_DFL); SLsignal (SIGCONT, SIG_DFL); SLsignal (SIGTSTP, SIG_DFL); for (i = 0; i < 256; i++) { while ((-1 == close (i)) && (errno == EINTR)) ; } while (1) { if ((-1 == kill (pid, 0)) && (errno == ESRCH)) _exit (0); sleep (10); } } #endif /* JED_HAS_SUBPROCESSES */ jed-0.99-19/src/mswshell.c0000644002657400265740000002002311311317447014260 0ustar davisdavis/* Copyright (c) 1992, 1998, 2000, 2002, 2003, 2004, 2005, 2006 John E. Davis * This file is part of JED editor library source. * * You may distribute this file under the terms the GNU General Public * License. See the file COPYING for more information. */ #include "config.h" #include "jed-feat.h" #include #include #include #include #include #include #include #include /* FIXME!!! * This file basically parses a command line looking for redirections, * and dups stdout and stderr when appropriate, then it spawns the suprocess. * For Win32, we should use CreateProcess instead of spawnvp because spawnvp * appears to be broken when using MINGW32. */ static char Error_Buffer[1024]; static void msg_error(char *msg) { unsigned int len = strlen (Error_Buffer); if (len + strlen (msg) + 2 < sizeof (Error_Buffer)) sprintf (Error_Buffer, ":%s", msg); } static char *shell = NULL, *shell_switch = NULL; static void discover_shell(void) { #ifdef SH_SHELL /* maybe some day ... */ shell_switch = "-c"; if ( (shell = getenv("SHELL")) != NULL ) return; #endif shell_switch = "/c"; if ( (shell = getenv("COMSPEC")) != NULL ) return; shell = "command.com"; /* absolute last resort! */ } /* /////////////////////////////////////////////////////////////////// // Function: static int parse_command_line( int *argc, char ***argv, // char **fname, // char *command_line ); // Descript: parse command_line // // Returns: the handles to redirect // // Caveat: requires spaces to separate each argument // ie., args>filename will NOT work ///////////////////////////////////////////////////////////////////// */ #define DIRECT_SPAWN 0x1000 /* some arbitrary number */ static int parse_command_line( int *argc, char ***argv, char **fname, char *command_line ) { int count, handles = 0; char *pt; discover_shell(); /* find which shell to use */ while ( (*command_line != '\0') && (*command_line == ' ')) command_line++; /* start on 1st non-space */ if ( *command_line == '!' ) { handles = DIRECT_SPAWN; command_line++; /* advance past '!' */ while ((*command_line != '\0') && (*command_line == ' ')) command_line++; /* start on next non-space */ } pt = command_line; count = 0; while ( *pt != '\0' ) { count++; /* this is an argument */ while ((*pt != '\0') && (*pt != ' ')) { if ( *pt == '|' ) /* cannot spawn directly */ handles = 0; /* need shell for pipes */ pt++; /* advance until a space */ } while ( *pt == ' ' ) pt++; /* advance until a non-space */ } *argv = (char **) malloc( (count+3) * sizeof(char *) ); if ( *argv == NULL ) return 0; /* malloc error */ *argc = 0; if ( !(handles & DIRECT_SPAWN) ) { (*argv)[ *argc ] = shell; (*argc)++; if ( count > 0 ) { (*argv)[ *argc ] = shell_switch; (*argc)++; } count += (*argc); } pt = command_line; while ((*argc < count) && (*pt != '\0')) { (*argv)[ *argc ] = pt; (*argc)++; while ( *pt != '\0' && *pt != ' ' ) pt++; /* advance until a space */ if ( *pt != '\0' ) *(pt++) = '\0'; /* parse argument here */ while ( *pt == ' ') pt++; /* advance until a non-space */ } (*argv) [ *argc ] = (char *) NULL; /* NULL terminated list */ /* now examine the arguments for '>' redirect */ for ( count = 0; count < *argc; count++ ) { /* find '>' char */ for ( pt = (*argv)[count]; *pt && (*pt != '>'); pt++ ) ; if ( *pt == '>' ) { if ( pt == (*argv)[count] ) { handles |= 0x01; } else { pt--; switch ( *pt ) { case '1': handles |= 0x01; break; case '2': handles |= 0x02; break; case '&': handles |= 0x03; break; } } (*argv)[count] = NULL; /* remove from the list */ count++; /* file name follows '>' */ if ( (*argv)[count] != NULL ) *fname = (*argv)[count]; } } if ((*fname == NULL) || (**fname == '\0' )) handles = 0x00; /* don't redirect if there is no name */ return handles; } /* /////////////////////////////////////////////////////////////////// // Function: int sys_System(char *command_line); // // Descript: shell wrapper that understands some common redirection syntax // command args > filename ; stdout // command args 1> filename ; stdout // command args 2> filename ; stderr // command args &> filename ; stdout+stderr // command args > filename 2>&1 ; stdout+stderr // // additionally, if command is prefixed by a '!', then the command is // spawned directly without invoking the shell // // Returns: returns error codes as per spawn*() // // Caveat: requires spaces to separate each argument // ie., command args>filename will NOT work ///////////////////////////////////////////////////////////////////// */ static int execute_the_command (char **, int, char *); static int sys_System(char *command_line) { int ret = -1, handles, argc = 0; char *fname = NULL, **argv = NULL; handles = parse_command_line( &argc, &argv, &fname, command_line ); if (argc) { ret = execute_the_command (argv, handles, fname); } return ret; } static int execute_the_command (char **argv, int handles, char *file) { int ret = 0; int fd1 = -1, fd2 = -1; int fd_err = -1, fd_out = -1; if (handles & 1) { /* save stdout file handle */ fd1 = dup (fileno (stdout)); if (fd1 == -1) { msg_error ("Unable to dup stdout"); return -1; } fd_out = open (file, O_CREAT | O_TRUNC | O_TEXT | O_WRONLY | O_APPEND, S_IREAD | S_IWRITE); if ((fd_out == -1) || (-1 == dup2 (fd_out, fileno (stdout)))) { msg_error ("Unable to redirect stdout!"); ret = -1; } } if (handles & 0x2) /* stderr */ { /* save stderr file handle */ fd2 = dup (fileno (stderr)); if (fd2 == -1) { msg_error ("Unable to dup stderr"); return -1; } if (fd_out == -1) { fd_err = open (file, O_CREAT | O_TRUNC | O_TEXT | O_RDWR | O_APPEND, S_IREAD | S_IWRITE); } else fd_err = fd_out; if ((fd_err == -1) || (-1 == dup2 (fd_err, fileno (stderr)))) { msg_error ("Unable to redirect stderr!"); ret = -1; } } if (fd_out != -1) close (fd_out); if ((fd_err != -1) && (fd_err != fd_out)) close (fd_err); if (ret == 0) { ret = spawnvp(P_WAIT, argv[0], (void *) argv); if (-1 == ret ) { switch(errno) { case ENOENT: if (handles & DIRECT_SPAWN ) msg_error("Command not found."); else msg_error("Shell not found."); break; case ENOMEM: msg_error("Insufficient Memory."); break; default: msg_error("Unknown Error."); } } } if (fd1 != -1) { if (-1 == dup2 (fd1, fileno (stdout))) { msg_error ("Unable to reattach stdout"); } close (fd1); } if (fd2 != -1) { if (-1 == dup2 (fd2, fileno (stderr))) { msg_error ("Unable to reattach stderr"); } close (fd2); } return ret; } int main(int argc, char **argv) { char *command_line, *p; int i, j; FILE *fp; int ret; Error_Buffer[0] = 0; ret = 1; if (argc == 1) msg_error ("mswshell: no arguments"); else { j = 1; for(i = 1; i < argc; i++) j += strlen(argv[i]) + 1; if (NULL == (p = command_line = malloc(j + 1))) msg_error("mswshell: Malloc Error"); else { for(i = 1; i < argc; i++) { strcpy(p, argv[i]); p += strlen(argv[i]); *p++ = ' '; } *p = 0; ret = sys_System(command_line); free(command_line); } } fp = fopen("jedshell.tmp", "w"); if (fp == NULL) { /* I realize that this does nothing... */ msg_error ("Unable to open tmp file."); return 1; } fprintf(fp, "%d\n%s", ret, Error_Buffer); fclose(fp); return ret; } jed-0.99-19/src/jprocess.h0000644002657400265740000000301511311317447014261 0ustar davisdavis/* Copyright (c) 1992, 1998, 2000, 2005, 2006 John E. Davis * This file is part of JED editor library source. * * You may distribute this file under the terms the GNU General Public * License. See the file COPYING for more information. */ #define MAX_PROCESSES 10 #ifdef __WIN32__ # ifdef VOID # undef VOID # endif # include # include /* # define WIN95BUG 1 */ /* extern CRITICAL_SECTION Critical_Section; */ extern HANDLE Input_Events[]; #else extern int Subprocess_Read_fds [MAX_PROCESSES][3]; extern int Max_Subprocess_FD; #endif extern int Num_Subprocesses; extern volatile int Child_Status_Changed_Flag; extern void read_process_input (int); extern int jed_close_process (int *); extern int jed_send_process (int *, char *); extern int jed_open_process (int *); extern int jed_open_process_pipe (int *); extern void jed_get_child_status (void); extern void jed_kill_process (int); extern void jed_get_process_mark (int *); extern void jed_set_process (void); extern void jed_send_process_eof (int *); extern void get_process_input (int *); extern int jed_signal_process (int *, int *); extern int jed_signal_fg_process (int *, int *); extern int jed_processes_ok_to_exit (void); extern void jed_query_process_at_exit (int *, int *); extern void jed_set_process_flags (int *, int *); extern int jed_get_process_flags (int *); #ifdef REAL_UNIX_SYSTEM extern void jed_block_child_signal (int); extern int jed_fork_monitor (void); #endif extern FILE *jed_popen (char *, char *); extern int jed_pclose (FILE *); jed-0.99-19/src/doskeys.h0000644002657400265740000000313311311317447014113 0ustar davisdavis/* Copyright (c) 1992, 1998, 2000, 2005, 2006 John E. Davis * This file is part of JED editor library source. * * You may distribute this file under the terms the GNU General Public * License. See the file COPYING for more information. */ #define PC_NULL "\xE0^C" #define PC_SLASH "\033OQ" #define PC_STAR "\033OR" #define PC_MINUS "\033OS" #define PC_PLUS "\033Om" #define PC_ENTER "\033OM" #define PC_KP5 "\033Ou" #define PC_UP "\xE0H" #define PC_UP1 "\033Ox" #define PC_DN "\xE0P" #define PC_DN1 "\033Or" #define PC_RT "\xE0M" #define PC_RT1 "\033Ov" #define PC_LT "\xE0K" #define PC_LT1 "\033Ot" #define PC_PGUP "\xE0I" #define PC_PGUP1 "\033Oy" #define PC_PGDN "\xE0Q" #define PC_PGDN1 "\033Os" #define PC_INS "\xE0R" #define PC_INS1 "\033Op" #define PC_DEL "\xE0S" #define PC_DEL1 "\033On" #define PC_END "\xE0O" #define PC_END1 "\033Oq" #define PC_HOME "\xE0G" #define PC_HOME1 "\033Ow" #define PC_F1 "^@;" #define PC_F2 "^@<" #define PC_F3 "^@=" #define PC_F4 "^@>" #define PC_F5 "^@?" #define PC_F6 "^@@" #define PC_F7 "^@A" #define PC_F8 "^@B" #define PC_F9 "^@C" #define PC_F10 "^@D" #define PC_ALT_F1 "^@h" #define PC_ALT_F2 "^@i" #define PC_ALT_F3 "^@j" #define PC_ALT_F4 "^@k" #define PC_ALT_F5 "^@l" #define PC_ALT_F6 "^@m" #define PC_ALT_F7 "^@n" #define PC_ALT_F8 "^@o" #define PC_ALT_F9 "^@p" #define PC_ALT_F10 "^@q" #define PC_SHIFT_F1 "^@T" #define PC_SHIFT_F2 "^@U" #define PC_SHIFT_F3 "^@V" #define PC_SHIFT_F4 "^@W" #define PC_SHIFT_F5 "^@X" #define PC_SHIFT_F6 "^@Y" #define PC_SHIFT_F7 "^@Z" #define PC_SHIFT_F8 "^@[" #define PC_SHIFT_F9 "^@\\" #define PC_SHIFT_F10 "^@]" jed-0.99-19/src/blocal.c0000644002657400265740000000543511311317447013670 0ustar davisdavis/* -*- mode: C; mode: fold; -*- */ /* Copyright (c) 1992, 1998, 2000, 2002, 2003, 2004, 2005, 2006 John E. Davis * This file is part of JED editor library source. * * You may distribute this file under the terms the GNU General Public * License. See the file COPYING for more information. */ #include #include #include "config.h" #include "jed-feat.h" #if JED_HAS_BUFFER_LOCAL_VARS #include #include "jdmacros.h" #include "buffer.h" #include "misc.h" static Jed_BLocal_Type *find_blocal_var (char *name, int err) /*{{{*/ { Jed_BLocal_Table_Type *table; Jed_BLocal_Type *lv, *lv_max; table = CBuf->blocal_table; while (table != NULL) { lv = table->local_vars; lv_max = lv + table->num; while (lv < lv_max) { if (name == lv->name) return lv; /* slstrings can be compared by pointer. * if (0 == strcmp (name, lv->name)) * return lv; */ lv++; } table = table->next; } if (err) jed_verror ("buffer local variable '%s' does not exist in buffer '%s'", name, CBuf->name); return NULL; } /*}}}*/ int jed_blocal_var_exists (char *name) { return (NULL != find_blocal_var (name, 0)); } void jed_make_blocal_var (char *name) /*{{{*/ { Jed_BLocal_Table_Type *table; Jed_BLocal_Type *lv; if (NULL != find_blocal_var (name, 0)) return; table = CBuf->blocal_table; if ((table == NULL) || (table->num == MAX_BLOCAL_VARS_PER_TABLE)) { table = (Jed_BLocal_Table_Type *) jed_malloc0 (sizeof (Jed_BLocal_Table_Type)); if (table == NULL) return; table->next = CBuf->blocal_table; CBuf->blocal_table = table; } lv = table->local_vars + table->num; /* This should not fail since name already exists */ if (NULL == (lv->name = SLang_create_slstring (name))) return; table->num += 1; } /*}}}*/ void jed_delete_blocal_vars (Jed_BLocal_Table_Type *table) /*{{{*/ { Jed_BLocal_Type *lv, *lv_max; Jed_BLocal_Table_Type *next; while (table != NULL) { lv = table->local_vars; lv_max = lv + table->num; while (lv < lv_max) { SLang_free_anytype (lv->value); SLang_free_slstring (lv->name); lv++; } next = table->next; SLfree ((char *) table); table = next; } } /*}}}*/ void jed_set_blocal_var (char *name) /*{{{*/ { Jed_BLocal_Type *lv; lv = find_blocal_var (name, 1); if (lv == NULL) return; SLang_free_anytype (lv->value); lv->value = NULL; (void) SLang_pop_anytype (&lv->value); } /*}}}*/ void jed_get_blocal_var (char *name) /*{{{*/ { Jed_BLocal_Type *lv; lv = find_blocal_var (name, 1); if (lv == NULL) return; (void) SLang_push_anytype (lv->value); } /*}}}*/ #endif /* JED_HAS_BUFFER_LOCAL_VARS */ jed-0.99-19/src/version.h0000644002657400265740000000072211311317447014120 0ustar davisdavis#ifndef JED_VERSION #define JED_VERSION 9919 #define JED_VERSION_STR "0.99.19" /* Copyright (c) 1999, 2000, 2001, 2005-2009 John E. Davis * This file is part of JED editor library source. * * You may distribute this file under the terms the GNU General Public * License. See the file COPYING for more information. */ extern int Jed_Version_Number; extern char *Jed_Version_String; extern void jed_show_version (FILE *); #endif /* JED_VERSION */ jed-0.99-19/src/userinfo.c0000644002657400265740000002077311311317447014270 0ustar davisdavis/* -*- mode: C; mode: fold; -*- */ /* Copyright (c) 1999, 2000, 2002, 2003, 2004, 2005, 2006 John E. Davis * This file is part of JED editor library source. * * You may distribute this file under the terms the GNU General Public * License. See the file COPYING for more information. */ #include "config.h" #include "jed-feat.h" /*{{{ Include Files */ #include #include #include #include #ifdef HAVE_STDLIB_H # include #endif #ifdef HAVE_UNISTD_H # include #endif #include #include "jdmacros.h" #ifdef REAL_UNIX_SYSTEM # define HAS_TCPIP_CODE 1 # include # ifndef h_errno extern int h_errno; # endif # define RESOLVE_DOT_CONF "/etc/resolv.conf" #else # define HAS_TCPIP_CODE 0 #endif #ifdef REAL_UNIX_SYSTEM # include # define HAS_PASSWORD_CODE 1 #else # define HAS_PASSWORD_CODE 0 #endif #include "userinfo.h" #include "misc.h" /*}}}*/ typedef struct { char *username; char *realname; char *hostname; } User_Info_Type; User_Info_Type User_Info; static int set_user_info (char **what, char *value) { if (NULL == (value = SLang_create_slstring (value))) return -1; SLang_free_slstring (*what); /* NULL ok */ *what = value; return 0; } static int set_hostname (char *name) { if (*name == 0) name = "localhost"; return set_user_info (&User_Info.hostname, name); } static int set_username (char *name) { return set_user_info (&User_Info.username, name); } static int set_realname (char *name) { return set_user_info (&User_Info.realname, name); } static int is_fqdn (char *h) /*{{{*/ { char *p; p = strchr (h, '.'); if ((p == NULL) || (p == h)) return 0; if ((unsigned int)((p - h) + 1) == strlen (h)) return 0; /* We may want something more sophisticated here */ return 1; } /*}}}*/ #ifdef RESOLVE_DOT_CONF static char *skip_whitespace_chars (char *b) { while ((*b == ' ') || (*b == '\t') || (*b == '\n')) b++; return b; } static char *skip_non_whitespace_chars (char *b) { while (*b && (*b != ' ') && (*b != '\t') && (*b != '\n')) b++; return b; } #endif static int get_domainname (char *dom, unsigned int domlen) { #ifdef RESOLVE_DOT_CONF FILE *fp; char buf[1024]; if (NULL == (fp = fopen (RESOLVE_DOT_CONF, "r"))) return -1; while (NULL != fgets (buf, sizeof (buf), fp)) { char *d, *b; b = buf; if (*b == '#') continue; b = skip_whitespace_chars (b); if (0 != strncmp ("domain", b, 6)) continue; b += 6; if ((*b != ' ') && (*b != '\t')) continue; b = skip_whitespace_chars (b); d = b; b = skip_non_whitespace_chars (b); if (b == d) continue; *b = 0; strncpy (dom, d, domlen); dom[domlen-1] = 0; fclose (fp); return 0; } fclose (fp); return -1; #else (void) dom; (void) domlen; return -1; #endif } static char *combine_host_and_domain (char *a, char *b) { unsigned int len; char *c, *cc; len = strlen (a) + strlen (b) + 2; if (NULL == (c = SLmalloc (len))) return NULL; if (*b == '.') b++; sprintf (c, "%s.%s", a, b); cc = SLang_create_slstring (c); SLfree (c); return cc; } #ifndef HAVE_GETHOSTNAME #define gethostname _my_gethostname static int _my_gethostname (char *buf, unsigned int len) { (void) buf; (void) len; return -1; } #endif /* Try to get a fully qualified domain name. */ static char *get_hostname (void) { #if HAS_TCPIP_CODE struct hostent *host_entry = NULL; #endif char buf[256], *b; char domain_name[256]; #ifdef JED_HOSTNAME if (is_fqdn (JED_HOSTNAME)) return SLang_create_slstring (JED_HOSTNAME); #endif b = buf; if ((-1 == gethostname (buf, sizeof (buf))) || (*buf == 0)) { b = getenv ("HOSTNAME"); if ((b == NULL) || (*b == 0)) return NULL; } #if HAS_TCPIP_CODE /* gethostname may not provide the full name so use gethostbyname * to get more information. Why isn't there a simplified interface to * get the FQDN!!!! */ host_entry = gethostbyname (b); #if defined(TRY_AGAIN) && !defined(MULTINET) if ((host_entry == NULL) && (h_errno == TRY_AGAIN)) { sleep (2); host_entry = gethostbyname (b); } #endif if ((host_entry != NULL) && (host_entry->h_name != NULL) && (host_entry->h_name[0] != 0)) { char **aliases; if (is_fqdn ((char *)host_entry->h_name)) return SLang_create_slstring ((char *)host_entry->h_name); if (NULL != (aliases = host_entry->h_aliases)) { while (*aliases != NULL) { if (is_fqdn (*aliases)) return SLang_create_slstring (*aliases); aliases++; } } /* We have no FQDN */ b = (char *)host_entry->h_name; } #endif /* HAS_TCPIP_CODE */ if (*b == 0) return NULL; if ((0 == is_fqdn (b)) && (0 == get_domainname (domain_name, sizeof (domain_name)))) { return combine_host_and_domain (b, domain_name); } /* Oh well */ return SLang_create_slstring (b); } static int get_hostname_info (void) { char *host; host = get_hostname (); if (host != NULL) { if (-1 == set_hostname (host)) { SLang_free_slstring (host); return -1; } SLang_free_slstring (host); return 0; } if (SLang_get_error ()) return -1; return set_hostname ("localhost"); } static int get_username_info (void) { char *name = NULL; #if HAS_PASSWORD_CODE struct passwd *pw; #endif #if HAS_PASSWORD_CODE /* I cannot use getlogin under Unix because some implementations * truncate the username to 8 characters. Besides, I suspect that * it is equivalent to the following line. */ /* The man page for getpwuid indicate that the pointer _may_ be to a static * area. So, there is nothing to free here. */ pw = getpwuid (getuid ()); if (pw != NULL) name = pw->pw_name; #endif if (((name == NULL) || (*name == 0)) && ((name = getenv("USER")) == NULL) && ((name = getenv("LOGNAME")) == NULL)) name = "unknown"; if (-1 == set_username (name)) return -1; name = getenv ("NAME"); #if HAS_PASSWORD_CODE if ((name == NULL) && (pw != NULL) && (pw->pw_gecos != NULL)) name = pw->pw_gecos; #endif if (name == NULL) name = ""; if (-1 == set_realname (name)) return -1; return 0; } static int get_user_info (void) { if (-1 == get_hostname_info ()) return -1; if (-1 == get_username_info ()) return -1; return 0; } char *jed_get_username (void) { return SLang_create_slstring (User_Info.username); } char *jed_get_hostname (void) { return SLang_create_slstring (User_Info.hostname); } static void get_passwd_cmd (char *name) /*{{{*/ { char *password = NULL; char *dir = NULL; char *shell = NULL; int uid = -1, gid = -1; #if HAS_PASSWORD_CODE struct passwd *pwent; if (*name == 0) pwent = getpwuid (getuid ()); else pwent = getpwnam (name); if (pwent != NULL) { password = pwent->pw_passwd; uid = pwent->pw_uid; gid = pwent->pw_gid; dir = pwent->pw_dir; shell = pwent->pw_shell; } #endif if (password == NULL) password = ""; if (dir == NULL) dir = ""; if (shell == NULL) shell = ""; (void) SLang_push_string (dir); (void) SLang_push_string (shell); (void) SLang_push_string (password); (void) SLang_push_integer (uid); (void) SLang_push_integer (gid); } /*}}}*/ static char *get_username_cmd (void) { return User_Info.username; } static char *get_realname_cmd (void) { return User_Info.realname; } static char *get_hostname_cmd (void) { return User_Info.hostname; } static void set_username_cmd (char *s) { (void) set_username (s); } static void set_realname_cmd (char *s) { (void) set_realname (s); } static void set_hostname_cmd (char *s) { (void) set_hostname (s); } static SLang_Intrin_Fun_Type User_Intrinsics [] = { MAKE_INTRINSIC_S("get_passwd_info", get_passwd_cmd, VOID_TYPE), MAKE_INTRINSIC_0("get_username", get_username_cmd, SLANG_STRING_TYPE), MAKE_INTRINSIC_0("get_hostname", get_hostname_cmd, SLANG_STRING_TYPE), MAKE_INTRINSIC_0("get_realname", get_realname_cmd, SLANG_STRING_TYPE), MAKE_INTRINSIC_S("set_username", set_username_cmd, SLANG_VOID_TYPE), MAKE_INTRINSIC_S("set_hostname", set_hostname_cmd, SLANG_VOID_TYPE), MAKE_INTRINSIC_S("set_realname", set_realname_cmd, SLANG_VOID_TYPE), MAKE_INTRINSIC_0(NULL, NULL, 0) }; int jed_init_userinfo (void) { (void) get_user_info (); if (-1 == SLadd_intrin_fun_table (User_Intrinsics, NULL)) return -1; return 0; } jed-0.99-19/src/w32cons.c0000644002657400265740000003355411311317447013735 0ustar davisdavis/* Copyright (c) 1992, 1998, 2000, 2002, 2003, 2004, 2005, 2006 John E. Davis * This file is part of JED editor library source. * * You may distribute this file under the terms the GNU General Public * License. See the file COPYING for more information. */ #include "config.h" #include "jed-feat.h" #include #include #include #include "jdmacros.h" #include #include #include #ifdef _MSC_VER # include #elif defined(__BORLANDC__) # include #endif #ifdef HAVE_UNISTD_H # include #endif #include #include #include #include #include "display.h" #include "buffer.h" #include "sysdep.h" #include "screen.h" #include "keymap.h" #include "hooks.h" #include "ins.h" #include "ledit.h" #include "misc.h" #include "cmds.h" #include "sig.h" #include "win32.h" #if JED_HAS_SUBPROCESSES # include "jprocess.h" #endif #define KEY_SHIFT 1 #define KEY_CONTROL 2 #define KEY_ALT 4 #define KEY_ALT_GR 8 int NumLock_Is_Gold = 0; int PC_Alt_Char = 27; int PC_Fn_Char = 0; #if SLANG_VERSION < 20000 # define SLw32_Hstdin _SLw32_Hstdin extern HANDLE _SLw32_Hstdin; #endif static unsigned char f_keys[4][12] = { { 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 133, 134 }, { 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 135, 136 }, { 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 137, 138 }, { 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 139, 140 } }; static unsigned char small_keypad_keys[4][13] = { { 'G', 'H', 'I', 0, 'K', 0, 'M', 0, 'O', 'P', 'Q', 'R', 'S' }, /* normal */ { '0', '1', '2', 0, '3', 0, '4', 0, '5', '6', '7', '8', '9' }, /* shift */ { 'w', 141, 132, 0, 's', 0, 't', 0, 'u', 145, 'v', 146, 147 }, /* ctrl */ { 151, 152, 153, 0, 155, 0, 157, 0, 159, 160, 161, 162, 163 } /* alt */ }; static unsigned char num_keypad_keys[4][13] = { { 'w', 'x', 'y', 0, 't', 'u', 'v', 0, 'q', 'r', 's', 'p', 'n' }, { '0', '1', '2', 0, '3', 0 , '4', 0, '5', '6', '7', '8', '9' }, { 'w', 141, 132, 0, 's', 143, 't', 0, 'u', 145, 'v', 146, 147 }, { 'w', 'x', 'y', 0, 't', 'u', 'v', 0, 'q', 'r', 's', 'p', 'n' } }; static void _putkey(unsigned char c) { buffer_keystring ((char *)&c, 1); } static void process_key_event(KEY_EVENT_RECORD *key) { unsigned int key_state = 0; unsigned int scan; unsigned char prefix, c1 = 0; int i, state; DWORD d = key->dwControlKeyState; if (!key->bKeyDown) return; if (d & LEFT_ALT_PRESSED) key_state |= KEY_ALT; if (d & RIGHT_ALT_PRESSED) key_state |= KEY_ALT_GR; if (d & (LEFT_CTRL_PRESSED | RIGHT_CTRL_PRESSED)) key_state |= KEY_CONTROL; if (d & SHIFT_PRESSED) key_state |= KEY_SHIFT; scan = key->wVirtualScanCode; if (d & ENHANCED_KEY) scan |= 0x100; switch (scan) { case 0x00F: /* TAB */ if (key_state & KEY_SHIFT) { /* Same as DOS */ buffer_keystring ("\000\017", 2); return; } break; case 0x00E: /* backspace */ _putkey (127); return; case 0x039: /* space */ if (key_state & KEY_CONTROL) { buffer_keystring ("\000\003", 2); return; } break; case 0x003: /* 2 key */ if (((key_state & KEY_ALT) == 0) && (key_state & KEY_CONTROL)) { buffer_keystring ("\000\003", 2); return; } break; case 0x007: /* 6 key */ if (((key_state & KEY_ALT) == 0) && (key_state & KEY_CONTROL)) { _putkey (30); /* Ctrl-^ */ return; } break; case 0x00C: /* -/_ key */ if (((key_state & KEY_ALT) == 0) && (key_state & KEY_CONTROL)) { _putkey (31); /* ^_ */ return; } break; /* PF1 and PF2 codes */ case 0x0045: /* NUMLOCK */ case 0x0145: if (NumLock_Is_Gold) { #if 0/* this does not appear to work on xp */ BYTE keyState[256]; /* toggle the caps-lock state */ GetKeyboardState(keyState); keyState[VK_NUMLOCK] = keyState[VK_NUMLOCK]^1; SetKeyboardState(keyState); #endif buffer_keystring ("\033OP", 3); return; } break; case 0x0135: c1 = 'Q'; break ; case 0xE02F: c1 = 'Q'; break; /* KEYPAD SLASH */ case 0x037: /* KEYPAD STAR */ c1 = 'R'; break; case 0x04A: /* KEYPAD MINUS */ c1 = 'S'; break; case 0x04E: /* KEYPAD PLUS */ c1 = 'm'; break; case 0x047: /* KEYPAD HOME */ case 0x048: /* KEYPAD UP */ case 0x049: /* KEYPAD PGUP */ case 0x04B: /* KEYPAD LEFT */ case 0x04C: /* KEYPAD 5 */ case 0x04D: /* KEYPAD RIGHT */ case 0x04F: /* KEYPAD END */ case 0x050: /* KEYPAD DOWN */ case 0x051: /* KEYPAD PGDN */ case 0x053: /* KEYPAD DEL */ case 0x052: /* KEYPAD INSERT */ if ((NumLock_Is_Gold == 0) && (d & NUMLOCK_ON)) break; state = 0; if (key_state & KEY_SHIFT) state = 1; if (key_state & KEY_CONTROL) state = 2; if (key_state & KEY_ALT) state = 3; if (key_state & (KEY_CONTROL | KEY_ALT)) { _putkey (0); _putkey (num_keypad_keys[state][scan - 0x47]); return; } else c1 = num_keypad_keys[state][scan - 0x47]; break; case 0x11C: /* KEYPAD ENTER */ if (key_state & KEY_ALT) { _putkey(0); _putkey(166); return; } else { c1 = 'M'; break; } case 0x147: /* home */ case 0x148: /* UP */ case 0x149: /* PGUP */ case 0x14B: /* LEFT */ case 0x14D: /* RIGHT */ case 0x14F: /* END */ case 0x150: /* DOWN */ case 0x151: /* PGDN */ case 0x153: /* DEL */ case 0x152: /* INSERT */ prefix = 0xE0; state = 0; if (key_state & KEY_SHIFT) state = 1; if (key_state & KEY_CONTROL) state = 2; if (key_state & KEY_ALT) { prefix = 0; state = 3; } _putkey (prefix); _putkey (small_keypad_keys[state][scan - 0x147]); return; case 0x3b: /* F1 */ case 0x3c: case 0x3d: case 0x3e: case 0x3f: case 0x40: case 0x41: case 0x42: case 0x43: case 0x44: case 0x57: case 0x58: /* F12 */ i = scan - 0x3b; if (i > 9) i -= 0x12; state = 0; if (key_state & KEY_SHIFT) state = 1; if (key_state & KEY_CONTROL) state = 2; if (key_state & KEY_ALT) #if 0 if (i == 3) /* Alt-F4 */ return DefWindowProc(hWnd, msg, wParam, lParam); else #endif state = 3; _putkey(PC_Fn_Char); _putkey(f_keys[state][i]); return; #if 0 case 0x145: /* NumLock */ c1 = 'P'; break; #endif } if (c1) { buffer_keystring ("\033O", 2); _putkey (c1); return; } #if 0 /* defined(__MINGW32__) */ c1 = key->AsciiChar; #else c1 = key->uChar.AsciiChar; #endif if (c1 != 0) { if (c1 == (char) Jed_Abort_Char) { if (Ignore_User_Abort == 0) SLang_set_error (USER_BREAK); SLKeyBoard_Quit = 1; } if (key_state & KEY_ALT) _putkey(PC_Alt_Char); _putkey(c1); return; } #if 0 if (1) { static FILE *fp; if (fp == NULL) fp = fopen ("key.log", "w"); if (fp != NULL) { fprintf (fp, "Key: scan=0x%X\n", scan); fflush (fp); } } #endif } static void process_mouse_event(MOUSE_EVENT_RECORD *mevent) { unsigned int s = 0; int col, row, type, button, b; static int last_button; static JMouse_Type jm; static DWORD last_button_state; DWORD state; #if 0 /* JED_HAS_MULTICLICK */ static DWORD last_press_time; static unsigned int clicks = 0; static unsigned long MultiClick_Time = -1; #endif int id; col = mevent->dwMousePosition.X + 1; row = mevent->dwMousePosition.Y + 1; switch (mevent->dwEventFlags) { case 0: #if JED_HAS_MULTICLICK case DOUBLE_CLICK: #endif b = mevent->dwButtonState ^ last_button_state; if (!b) return; switch (b) { case FROM_LEFT_1ST_BUTTON_PRESSED: if (!(mevent->dwControlKeyState & (LEFT_ALT_PRESSED | RIGHT_ALT_PRESSED))) { button = JMOUSE_BUTTON_1; break; } /* drop */ case FROM_LEFT_2ND_BUTTON_PRESSED: button = JMOUSE_BUTTON_2; break; case RIGHTMOST_BUTTON_PRESSED: button = JMOUSE_BUTTON_3; break; default: return; } jm.button = button; #if JED_HAS_MULTICLICK if (mevent->dwEventFlags == DOUBLE_CLICK) type = JMOUSE_DOUBLE_CLICK; else #endif if (mevent->dwButtonState & b) type = JMOUSE_DOWN; else type = JMOUSE_UP; break; case MOUSE_MOVED: button = 0; if ((col == jm.x) && (row == jm.y)) return; type = JMOUSE_DRAG; break; default: return; } if (button == 0) button = last_button; else last_button = button; #if 0 /* JED_HAS_MULTICLICK */ if (type == JMOUSE_DOWN) { DWORD the_time = GetTickCount(); if (MultiClick_Time == -1) MultiClick_Time = GetDoubleClickTime(); if ((last_button == button) && (the_time - last_press_time < MultiClick_Time)) { clicks++; if (clicks == 2) type = JMOUSE_DOUBLE_CLICK; else type = JMOUSE_TRIPLE_CLICK; } else { clicks = 1; last_button = button; } last_press_time = the_time; } else if ((clicks > 1) && (last_button == button)) { /* Last was a multi-click. Ignore this event. */ type = JMOUSE_IGNORE_EVENT; } #endif if ((type == JMOUSE_UP) && (0 == (jm.state & jm.button))) { return; } state = mevent->dwButtonState; if (state & FROM_LEFT_1ST_BUTTON_PRESSED) s |= JMOUSE_BUTTON_1; if (state & FROM_LEFT_2ND_BUTTON_PRESSED) s |= JMOUSE_BUTTON_2; if (state & RIGHTMOST_BUTTON_PRESSED) s |= JMOUSE_BUTTON_3; state = mevent->dwControlKeyState; if (state & (RIGHT_CTRL_PRESSED | LEFT_CTRL_PRESSED)) s |= JMOUSE_CTRL; if (state & SHIFT_PRESSED) s |= JMOUSE_SHIFT; jm.state = s; jm.x = col; jm.y = row; jm.type = type; last_button_state = mevent->dwButtonState; if (-1 == (id = jed_mouse_add_event (&jm))) { msg_error ("Failed!"); return; } buffer_keystring ("\033\000", 2); _putkey(id); } static void process_resize_records (WINDOW_BUFFER_SIZE_RECORD *w) { int c, r; c = w->dwSize.X; r = w->dwSize.Y; if ((r != SLtt_Screen_Rows) || (c != SLtt_Screen_Cols)) { jed_init_display (); jed_redraw_screen (1); } } static void process_console_records(void) { INPUT_RECORD record; DWORD bytesRead; DWORD n = 0; if (FALSE == GetNumberOfConsoleInputEvents(SLw32_Hstdin, &n)) return; while (n > 0) { ReadConsoleInput(SLw32_Hstdin, &record, 1, &bytesRead); switch (record.EventType) { case KEY_EVENT: process_key_event(&record.Event.KeyEvent); break; case MOUSE_EVENT: process_mouse_event(&record.Event.MouseEvent); break; case WINDOW_BUFFER_SIZE_EVENT: process_resize_records(&record.Event.WindowBufferSizeEvent); break; } n--; } } #ifdef JED_HAS_SUBPROCESSES int sys_input_pending (int *tsecs, int all) { DWORD ret = 0; int i, n; if ((all >= 0) && (Input_Buffer_Len || Batch)) return Input_Buffer_Len; if (all < 0) { ret = WaitForMultipleObjects(Num_Subprocesses, Input_Events + 1, FALSE, *tsecs * 100); } else { long rtime, t; rtime = *tsecs * 100L; process_console_records (); while ((rtime > 0) && !Input_Buffer_Len) { t = GetTickCount (); ret = WaitForMultipleObjects(Num_Subprocesses + 1, Input_Events, FALSE, rtime); if (ret != WAIT_OBJECT_0) break; process_console_records(); rtime -= GetTickCount() - t; } if ((rtime < 0) || Input_Buffer_Len) return Input_Buffer_Len; } if (WAIT_TIMEOUT == ret) return 0; i = n = 1; while (i <= Num_Subprocesses) { if (WAIT_TIMEOUT != WaitForSingleObject(Input_Events[i], 0)) { read_process_input(i - 1); n++; } i++; } if (all < 0) return n; else return 0; } #else int sys_input_pending (int *tsecs, int unused) { DWORD d; long rtime, t; if (Input_Buffer_Len) return Input_Buffer_Len; rtime = *tsecs * 100L; do { t = GetTickCount (); d = WaitForSingleObject(SLw32_Hstdin, rtime); if (d == WAIT_TIMEOUT) return 0; process_console_records(); rtime -= GetTickCount() - t; } while ((rtime > 0) && !Input_Buffer_Len); return Input_Buffer_Len; } #endif unsigned char sys_getkey (void) { int n = 450; #ifdef JED_HAS_SUBPROCESSES int all = Num_Subprocesses; #else int all = 0; #endif while (1) { if (SLKeyBoard_Quit) break; /* sleep for 45 second and try again */ if (sys_input_pending(&n, all) > 0) break; if (SLKeyBoard_Quit) break; /* update status line incase user is displaying time */ if (Display_Time || all) { JWindow->trashed = 1; update((Line *) NULL, all, 1, 0); } } if (SLKeyBoard_Quit) { SLKeyBoard_Quit = 0; flush_input (); return Jed_Abort_Char; } return (unsigned char) my_getkey(); } void sys_suspend(void) { STARTUPINFO si; PROCESS_INFORMATION pi; char *shell; shell = getenv ("COMSPEC"); if (shell == NULL) shell = "CMD"; memset ((char *) &si, 0, sizeof (STARTUPINFO)); si.cb = sizeof(STARTUPINFO); si.dwFlags = STARTF_USESTDHANDLES; si.hStdInput = GetStdHandle (STD_INPUT_HANDLE); si.hStdOutput = GetStdHandle (STD_OUTPUT_HANDLE); si.hStdError = GetStdHandle (STD_ERROR_HANDLE); if (FALSE == CreateProcess (NULL, shell, NULL, NULL, TRUE, 0, NULL, NULL, &si, &pi)) { jed_verror ("Command shell '%s' failed to run\n", shell); } WaitForSingleObject (pi.hProcess, INFINITE); CloseHandle (pi.hProcess); CloseHandle (pi.hThread); } int jed_init_w32_support (void) { SLang_Interrupt = process_console_records; return w32_init_subprocess_support (0); } jed-0.99-19/src/vmsmail.c0000644002657400265740000000551511311317447014103 0ustar davisdavis/* -*- mode: C; mode: fold; -*- */ /* Copyright (c) 1992, 1998, 2000, 2002, 2003, 2004, 2005, 2006 John E. Davis * This file is part of JED editor library source. * * You may distribute this file under the terms the GNU General Public * License. See the file COPYING for more information. */ #include "config.h" #include "jed-feat.h" #include #include #include #include "buffer.h" #include "vmsmail.h" extern int mail$send_add_bodypart (); extern int mail$send_begin (); extern int mail$send_add_attribute (); extern int mail$send_add_address (); extern int mail$send_message (); extern int mail$send_end (); static void fill_struct(Mail_Type *m, int act, char *s) /*{{{*/ { m->code = act; m->buflen = strlen(s); m->addr = (long) s; m->junk = m->ret = 0; } /*}}}*/ static int vms_send_buffer(int *context, Mail_Type *mt0, Buffer *b) /*{{{*/ { Mail_Type m; Line *l = b->beg; int n = 0, len; unsigned char *p; while (l != NULL) { m.code = MAIL$_SEND_RECORD; len = l->len; p = l->data; if (len && ('\n' == *(p + (int)(len - 1)))) len--; m.buflen = len; m.addr = (long) p; m.junk = m.ret = 0; if (SS$_NORMAL != mail$send_add_bodypart(context, &m, mt0)) return(0); l = l->next; n++; } return(n); } /*}}}*/ /* to might be a comma separated list--- parse it too */ int vms_send_mail(char *to, char *subj) /*{{{*/ { Mail_Type mt0, mt; int context = 0; char *p; mt0.code = mt0.buflen = mt0.addr = mt0.ret = mt0.junk = 0; if (SS$_NORMAL != mail$send_begin(&context, &mt0, &mt0)) { return(0); } #if 0 fill_struct(&mt, MAIL$_SEND_TO_LINE, to); if (SS$_NORMAL != mail$send_add_attribute(&context, &mt, &mt0)) { return(0); } fill_struct(&mt, MAIL$_SEND_USERNAME, to); if (SS$_NORMAL != mail$send_add_address(&context, &mt, &mt0)) { return(0); } #endif while (1) { while (*to && ((*to <= ' ') || (*to == ','))) to++; if (*to == 0) break; p = to; while ((*p > ' ') && (*p != ',')) p++; mt.code = MAIL$_SEND_TO_LINE; mt.buflen = p - to; mt.ret = mt.junk = 0; mt.addr = (long) to; if (SS$_NORMAL != mail$send_add_attribute(&context, &mt, &mt0)) { return(0); } mt.code = MAIL$_SEND_USERNAME; mt.buflen = p - to; mt.ret = mt.junk = 0; mt.addr = (long) to; if (SS$_NORMAL != mail$send_add_address(&context, &mt, &mt0)) { return(0); } to = p; } fill_struct(&mt, MAIL$_SEND_SUBJECT, subj); if (SS$_NORMAL != mail$send_add_attribute(&context, &mt, &mt0)) { return(0); } if (!vms_send_buffer(&context, &mt0, CBuf)) { return(0); } if (SS$_NORMAL != mail$send_message(&context, &mt0, &mt0)) { return(0); } if (SS$_NORMAL != mail$send_end(&context, &mt0, &mt0)) { return(0); } return(1); } /*}}}*/ jed-0.99-19/src/syntax.c0000644002657400265740000003003011311317447013747 0ustar davisdavis/* -*- mode: C; mode: fold; -*- */ /* Copyright (c) 1992, 1998, 2000, 2002, 2003, 2004, 2005, 2006 John E. Davis * This file is part of JED editor library source. * * You may distribute this file under the terms the GNU General Public * License. See the file COPYING for more information. */ #include "config.h" #include "jed-feat.h" #include #include #include "buffer.h" #include "screen.h" #include "colors.h" #include "file.h" #include "misc.h" #include "ledit.h" #include "indent.h" static unsigned short *Char_Syntax; static char **Keywords = NULL; /* array of keywords */ static int Keyword_Not_Case_Sensitive; static unsigned char *write_using_color (unsigned char *p, unsigned char *pmax, int color) { if ((color == 0) && (Jed_Highlight_WS & HIGHLIGHT_WS_TAB)) { unsigned char *p1 = p; while (p1 < pmax) { if (*p1 != '\t') { p1++; continue; } if (p1 != p) { SLsmg_set_color (0); SLsmg_write_nchars ((char *)p, (unsigned int)(p1-p)); p = p1; } while ((p1 < pmax) && (*p1 == '\t')) p1++; SLsmg_set_color (JTAB_COLOR); SLsmg_write_nchars ((char *)p, (unsigned int)(p1-p)); p = p1; } } /* drop */ SLsmg_set_color (color); #if SLANG_VERSION < 20000 SLsmg_write_nchars ((char *)p, (unsigned int) (pmax - p)); #else SLsmg_write_chars (p, pmax); #endif SLsmg_set_color (0); return pmax; } #if JED_HAS_COLOR_COLUMNS # if SLANG_VERSION < 20000 static void color_columns (int row, register unsigned char *p, register unsigned char *pmax) { unsigned char *c, *cmax, *pmin; int color; c = CBuf->column_colors; if (c != NULL) cmax = c + CBuf->num_column_colors; else cmax = c; pmin = p; color = 0; while (p < pmax) { if (c < cmax) { if (color != (int) *c) { if (pmin != p) pmin = write_using_color (pmin, p, color); color = *c; } c++; } p++; } if (pmin != p) (void) write_using_color (pmin, p, color); } # else static void color_columns (int row, register unsigned char *p, register unsigned char *pmax) { unsigned char *c; int color; int x0, x1, nx; if (p != pmax) (void) write_using_color (p, pmax, 0); if (NULL == (c = CBuf->column_colors)) return; nx = CBuf->num_column_colors; color = 0; x1 = x0 = 0; while (x1 < nx) { if (color != (int)c[x1]) { if (x0 != x1) { if (color != 0) SLsmg_set_color_in_region (color, row, x0, 1, x1 - x0); } color = (int) c[x1]; x0 = x1; } x1++; } if ((x1 != x0) && (color != 0)) SLsmg_set_color_in_region (color, row, x0, 1, x1 - x0); } # endif /* SLANG_VERSION < 20000 */ #endif /* JED_HAS_COLOR_COLUMNS */ static int try_keyword (register unsigned char *q, int n, register char *t, unsigned char color) /*{{{*/ { unsigned char *p; while (*t) { p = q - n; if (Keyword_Not_Case_Sensitive == 0) { while ((p < q) && (*t == (char) *p)) { p++; t++; } } else while ((p < q) && (*t == (char) LOWER_CASE (*p))) { p++; t++; } if (p == q) { p = q - n; write_using_color (p, q, color); return 0; } /* alphabetical */ if (*t > ((char) *p | Keyword_Not_Case_Sensitive)) break; t += (int) (q - p); } return -1; } /*}}}*/ static unsigned char *highlight_word (unsigned char *p, unsigned char *pmax) /*{{{*/ { char **kwds; register unsigned char *q; int n; int i; int color; q = p; while ((q < pmax) && (Char_Syntax[*q] & WORD_SYNTAX)) q++; n = (int) (q - p); kwds = Keywords; if ((kwds != NULL) && (n <= MAX_KEYWORD_LEN)) { for (i = 0; i < MAX_KEYWORD_TABLES; i++) { char *t; t = kwds[n - 1]; if (t != NULL) { color = (JKEY_COLOR + i); if (0 == try_keyword (q, n, t, color)) return q; } kwds += MAX_KEYWORD_LEN; } } return write_using_color (p, q, 0); } /*}}}*/ static unsigned char *highlight_string (unsigned char *p, unsigned char *pmax, /*{{{*/ unsigned char quote, unsigned char str_char, int ofs) { unsigned char ch; unsigned char *p1; p1 = p + ofs; while (p1 < pmax) { ch = (unsigned char) *p1++; if (ch == str_char) break; if ((ch == quote) && (p1 < pmax)) p1++; } return write_using_color (p, p1, JSTR_COLOR); } /*}}}*/ static unsigned char *highlight_number (unsigned char *p, unsigned char *pmax) /*{{{*/ { unsigned char *p1; unsigned char ch; ch = (unsigned char) *p; p1 = p + 1; if (ch == '-') { if ((p1 < pmax) && (Char_Syntax[*p1] & NUMBER_SYNTAX)) p1++; else return write_using_color (p, p1, JOP_COLOR); } while ((p1 < pmax) && (Char_Syntax[*p1] & NUMBER_SYNTAX)) { if ((*p1 == '-') || (*p1 == '+')) { ch = *(p1 - 1); if ((ch != 'e') && (ch != 'E')) break; } p1++; } return write_using_color (p, p1, JNUM_COLOR); } /*}}}*/ static unsigned char *highlight_comment (unsigned char *p, unsigned char *p1, unsigned char *pmax, /*{{{*/ Syntax_Table_Type *st) { unsigned char stop_char; char *s; unsigned int len; if (NULL == (s = st->comment_stop)) s = ""; stop_char = *s; len = st->comment_stop_len; while (p1 < pmax) { if (*p1 == stop_char) { if ((p1 + len < pmax) && (0 == strncmp ((char *)p1, s, len))) { p1 += len; break; } } p1++; } return write_using_color (p, p1, JCOM_COLOR); } /*}}}*/ #if JED_HAS_DFA_SYNTAX # include "dfasyntx.c" #endif static unsigned char *write_whitespace (unsigned char *p, unsigned char *pmax, int trailing_color) { unsigned char *p1; p1 = p; while ((p1 < pmax) && ((*p1 == ' ') || (*p1 == '\t'))) p1++; if (p1 == p) return p; if ((p1 == pmax) && (Jed_Highlight_WS & HIGHLIGHT_WS_TRAILING)) return write_using_color (p, pmax, trailing_color); return write_using_color (p, p1, 0); } void write_syntax_highlight (int row, Line *l, unsigned int len) { Syntax_Table_Type *st = CBuf->syntax_table; unsigned char ch; unsigned int flags; unsigned char *p1; unsigned short syntax; register unsigned char *p; register unsigned char *pmax; int context; p = l->data; pmax = p + len; #if JED_HAS_COLOR_COLUMNS if (CBuf->coloring_style) { color_columns (row, p, pmax); return; } #endif if (st == NULL) return; #if JED_HAS_DFA_SYNTAX if (st->use_dfa_syntax && (st->hilite != NULL) && (st->hilite->dfa != NULL)) { dfa_syntax_highlight (p, pmax, st); return; } #endif flags = st->flags; #if JED_HAS_LINE_ATTRIBUTES context = l->flags & JED_LINE_SYNTAX_BITS; #else context = 0; #endif if (context & JED_LINE_IN_COMMENT) { /* I do not like the whitespace that preceeds the * '*' on the current line to be highlighted. So... */ if (flags & C_COMMENT_TYPE) { p1 = p; while ((p1 < pmax) && ((*p1 == ' ') || (*p1 == '\t'))) p1++; if ((p1 < pmax) && (*p1 == '*')) p = write_using_color (p, p1, 0); } p = highlight_comment (p, p, pmax, st); } else if (context & JED_LINE_IN_STRING0) { p = highlight_string (p, pmax, st->quote_char, st->string_chars[0], 0); } else if (context & JED_LINE_IN_STRING1) { p = highlight_string (p, pmax, st->quote_char, st->string_chars[1], 0); } else if (context & JED_LINE_IN_HTML) { p1 = p; ch = st->sgml_stop_char; while ((p1 < pmax) && (*p1++ != ch)) ; p = write_using_color (p, p1, JHTML_KEY_COLOR); } else if ((flags & FORTRAN_TYPE) && st->fortran_comment_chars[*p]) { (void) write_using_color (p, pmax, JCOM_COLOR); return; } else { /* Handle the preprocessor */ if (flags & PREPROCESS_IGNORE_WHITESPACE) { p = write_whitespace (p, pmax, JTWS_COLOR); if (p == pmax) return; } if (*p == st->preprocess) { if (flags & PREPROCESS_COLOR_WHOLE_LINE) { (void) write_using_color (p, pmax, JPREPROC_COLOR); return; } p1 = p + 1; /* FIXME!!! I need to add a whitespace syntax */ while ((p1 < pmax) && ((*p1 == ' ') || (*p1 == '\t'))) p1++; while ((p1 < pmax) && (Char_Syntax[*p1] != 0)) p1++; p = write_using_color (p, p1, JPREPROC_COLOR); } } /* Now the preliminary stuff is done so do the hard part */ while (p < pmax) { syntax = Char_Syntax[*p]; /* Do comment syntax before word syntax since the comment start * may be a word. */ if (syntax & COMMENT_SYNTAX) { p1 = p + 1; ch = *p; if ((st->comment_start != NULL) && (ch == st->comment_start[0]) && (p + st->comment_start_len <= pmax) && (0 == strncmp ((char *)p, st->comment_start, st->comment_start_len))) { p = highlight_comment (p, p + st->comment_start_len, pmax, st); continue; } if (_jed_is_eol_comment_start (st, l, p, pmax, NULL)) { (void) write_using_color (p, pmax, JCOM_COLOR); return; } } if (syntax & WORD_SYNTAX) { if ((*p > '9') || (0 == (syntax & NUMBER_SYNTAX))) { p = highlight_word (p, pmax); continue; } } if (syntax == 0) { p1 = p; while ((p1 < pmax) && (Char_Syntax[*p1] == 0)) p1++; if ((p1 != pmax) || ((Jed_Highlight_WS & HIGHLIGHT_WS_TRAILING) == 0)) { p = write_using_color (p, p1, 0); continue; } while (p1 > p) { p1--; if ((*p1 != ' ') && (*p1 != '\t')) { p1++; break; } } p = write_using_color (p, p1, 0); if (p1 != pmax) (void) write_using_color (p1, pmax, JTWS_COLOR); return; } if (syntax & DELIM_SYNTAX) { p = write_using_color (p, p + 1, JDELIM_COLOR); continue; } if (syntax & STRING_SYNTAX) { p = highlight_string (p, pmax, st->quote_char, *p, 1); continue; } if (syntax & OP_SYNTAX) { p = write_using_color (p, p + 1, JOP_COLOR); continue; } if (syntax & NUMBER_SYNTAX) { p = highlight_number (p, pmax); continue; } if (syntax & HTML_START_SYNTAX) { p1 = p; while (p1 < pmax) { if (Char_Syntax[*p1] & HTML_END_SYNTAX) { p1++; break; } p1++; } p = write_using_color (p, p1, JHTML_KEY_COLOR); continue; } if (syntax & HTML_END_SYNTAX) /* missed start from previous line */ { /* FIXME!!! Start from beginning */ p = write_using_color (p, p + 1, JHTML_KEY_COLOR); continue; } if ((syntax & OPEN_DELIM_SYNTAX) || (syntax & CLOSE_DELIM_SYNTAX)) { p = write_using_color (p, p + 1, JDELIM_COLOR); continue; } if ((syntax & QUOTE_SYNTAX) && (flags & TEX_LIKE_KEYWORDS)) { p1 = p + 1; if (p1 < pmax) { if (Char_Syntax[*p1] & WORD_SYNTAX) { do { p1++; } while ((p1 < pmax) && (Char_Syntax[*p1] & WORD_SYNTAX)); } else p1++; } p = write_using_color (p, p1, JKEY_COLOR); continue; } if (syntax & QUOTE_SYNTAX) { p1 = jed_multibyte_chars_forward (p, pmax, 2, NULL, 1); /* p1 = p + 2; */ if (p1 < pmax) { p = write_using_color (p, p1, 0); continue; } } /* Undefined. */ p = write_using_color (p, p + 1, 0); } } /*}}}*/ void init_syntax_highlight (void) /*{{{*/ { Syntax_Table_Type *st = CBuf->syntax_table; Mode_Has_Syntax_Highlight = 1; if (CBuf->coloring_style) return; if ((st == NULL) || (st == Default_Syntax_Table)) { Mode_Has_Syntax_Highlight = 0; return; } #if JED_HAS_DFA_SYNTAX if (st->use_dfa_syntax && ((NULL != st->hilite) && (NULL != st->hilite->dfa))) return; #endif Char_Syntax = st->char_syntax; if (st->flags & SYNTAX_NOT_CASE_SENSITIVE) Keyword_Not_Case_Sensitive = 0x20; else Keyword_Not_Case_Sensitive = 0; Keywords = (char **) st->keywords; } /*}}}*/ jed-0.99-19/src/i386.c0000644002657400265740000001437111311317447013124 0ustar davisdavis/* Copyright (c) 1992, 1998, 2000, 2002, 2003, 2004, 2005, 2006 John E. Davis * This file is part of JED editor library source. * * You may distribute this file under the terms the GNU General Public * License. See the file COPYING for more information. */ #include "config.h" #include "jed-feat.h" #include #ifndef __WATCOMC__ #include #include #include #include #include #else #include #include #include #include #include /* for some reason _bios_keybrd seems to work better than kbhit() * even though the documentation indicates they do the same thing. */ #define kbhit() _bios_keybrd(_NKEYBRD_READY) #endif /* NOT WATCOM */ #include #include "sysdep.h" #define BIOSKEY i386_bioskey #include #include #include #include "dos_os2.c" #ifndef __WATCOMC__ unsigned int i386_bioskey(int f) { union REGS in, out; in.h.ah = f | 0x10; /* use enhanced kbd */ int86(0x16, &in, &out); return(out.x.ax & 0xFFFF); } #endif #include "pcscan.c" static void read_and_buffer_keys (void) { unsigned int scan; unsigned char keybuf[16]; unsigned int shift; unsigned int num; #ifdef __WATCOMC__ scan = _bios_keybrd(_NKEYBRD_READ); shift = _bios_keybrd(_NKEYBRD_SHIFTSTATUS) & 0xF; #else scan = (unsigned int) BIOSKEY(0); shift = BIOSKEY(2) & 0xF; #endif num = jed_scan_to_key (scan & 0xFFFF, shift, keybuf); buffer_keystring (keybuf, num); } /* Here I also map keys to edt keys */ unsigned char sys_getkey() { int wit = 300; if ( #ifdef __WATCOMC__ (!_bios_keybrd(_NKEYBRD_READY)) #else (!kbhit()) #endif ) while (!sys_input_pending(&wit, 0)) { if (Display_Time) { JWindow->trashed = 1; update((Line *) NULL, 0, 1, 0); } } #ifdef HAS_MOUSE /* This can only be set by the mouse */ if (JMouse_Hide_Mouse_Hook != NULL) (*JMouse_Hide_Mouse_Hook) (0); if (Input_Buffer_Len) return my_getkey (); #endif read_and_buffer_keys (); return my_getkey (); } void sys_pause (int ms) { /* read one of the RTC registers to ensure delay will * work as designed */ outportb(0x70,0x8c); inportb(0x71); delay (ms); } int sys_input_pending(int *tsecs, int unused) { int count = *tsecs * 5; (void) unused; if (Batch || Input_Buffer_Len) return(Input_Buffer_Len); if (kbhit()) return 1; while (count > 0) { sys_pause (20); /* 20 ms or 1/50 sec */ if (kbhit() #ifdef HAS_MOUSE || ((JMouse_Event_Hook != NULL) && ((*JMouse_Event_Hook)() > 0)) #endif ) break; count--; } return (count); } /* returns 0 if file does not exist, 1 if it is not a dir, 2 if it is */ int sys_chmod(SLFUTURE_CONST char *file, int what, mode_t *mode, uid_t *dum1, gid_t *dum2) { struct stat buf; int m; *dum1 = *dum2 = 0; file = msdos_pinhead_fix_dir (file); if (what) { chmod(file, *mode); return(0); } if (stat(file, &buf) < 0) switch (errno) { case EACCES: return(-1); /* es = "Access denied."; break; */ case ENOENT: return(0); /* ms = "File does not exist."; */ case ENOTDIR: return(-2); /* es = "Invalid Path."; */ default: return(-3); /* "stat: unknown error."; break;*/ } m = buf.st_mode; /* AIX requires this */ #ifdef _S_IFDIR #ifndef S_IFDIR #define S_IFDIR _S_IFDIR #endif #endif *mode = m & 0777; #ifndef __WATCOMC__ if (m & S_IFDIR) return (2); #else if (S_ISDIR(m)) return(2); #endif return(1); } int i386_access (char *file, int mode) { struct stat buf; if (stat(file, &buf) < 0) return -1; if (mode == W_OK) { if (buf.st_mode & S_IWRITE) return 0; return -1; } return 0; } #ifndef __WATCOMC__ # ifdef __GO32__ static int cbreak; # endif #endif void reset_tty() { #ifndef __WATCOMC__ # ifdef __GO32__ # if __DJGPP__ > 1 signal (SIGINT, SIG_IGN); /* was sig_dfl */ # endif setcbrk(cbreak); # endif #endif #ifdef HAS_MOUSE if (X_Close_Mouse_Hook != NULL) (*X_Close_Mouse_Hook) (); #endif } int init_tty() { #ifndef __WATCOMC__ # if __DJGPP__ > 1 signal (SIGINT, SIG_IGN); # endif cbreak = getcbrk(); setcbrk(0); #endif #ifdef HAS_MOUSE if (X_Open_Mouse_Hook != NULL) (*X_Open_Mouse_Hook) (); #endif return 0; } #ifndef __WATCOMC__ static struct ffblk Dos_DTA; #else static struct find_t fileinfo; #endif static char Found_Dir[JED_MAX_PATH_LEN], *Found_File; /* found_File is a pointer into found_Dir such that the * full pathname is stored in the following form * "c:/dir/path/\0filename.ext\0" */ #if JED_FILENAME_LOWERCASE #define lcase(x) ((((x) >= 'A') && ((x) <= 'Z')) ? ((x) |= 0x20) : (x)) static void lowercase_filename (char *p) { char ch; while (0 != (ch = *p)) *p++ = lcase (ch); } #endif static void dta_fixup_name (char *file) { #ifndef __WATCOMC__ strcpy (Found_File, Dos_DTA.ff_name); #else strcpy (Found_File, fileinfo.name); #endif #if JED_FILENAME_LOWERCASE lowercase_filename (Found_File); #endif strcpy(file, Found_Dir); strcat(file, Found_File); #ifndef __WATCOMC__ if (Dos_DTA.ff_attrib & FA_DIREC) strcat(file, "\\"); #else if (fileinfo.attrib & _A_SUBDIR) strcat(file, "\\"); #endif } int sys_findfirst(char *file) { char *f; strcpy(Found_Dir, jed_standardize_filename_static(file) ); Found_File = extract_file( Found_Dir ); f = Found_File; while (*f && (*f != '*')) f++; if (! *f) { f = Found_File; while (*f && (*f != '.')) f++; if (*f) strcat(Found_Dir, "*"); else strcat(Found_Dir, "*.*"); } #ifndef __WATCOMC__ if (findfirst(Found_Dir, &Dos_DTA, FA_RDONLY | FA_DIREC)) #else if (_dos_findfirst(Found_Dir, _A_RDONLY | _A_SUBDIR, &fileinfo)) #endif { *Found_File++ = 0; return 0; } *Found_File++ = 0; dta_fixup_name(file); return(1); } int sys_findnext(char *file) { #ifndef __WATCOMC__ if (findnext(&Dos_DTA)) return(0); #else if (_dos_findnext (&fileinfo)) return(0); #endif dta_fixup_name(file); return(1); } /* This routine is called from S-Lang inner interpreter. It serves as a poor mans version of an interrupt 9 handler */ void i386_check_kbd() { while (kbhit()) { read_and_buffer_keys (); } } jed-0.99-19/src/lineattr.h0000644002657400265740000000061711311317447014260 0ustar davisdavis/* Copyright (c) 1992, 1998, 2000, 2005, 2006 John E. Davis * This file is part of JED editor library source. * * You may distribute this file under the terms the GNU General Public * License. See the file COPYING for more information. */ extern SLang_Intrin_Fun_Type JedLine_Intrinsics[]; extern void jed_skip_hidden_lines_backward (int *); extern void jed_skip_hidden_lines_forward (int *); jed-0.99-19/src/vfile.c0000644002657400265740000001363211311317447013537 0ustar davisdavis/* -*- mode: C; mode: fold; -*- */ /* Copyright (c) 1992, 1998, 2000, 2002, 2003, 2004, 2005, 2006 John E. Davis * This file is part of JED editor library source. * * You may distribute this file under the terms the GNU General Public * License. See the file COPYING for more information. */ #include "config.h" #ifdef JED # include "jed-feat.h" #endif /*{{{ Include Files */ #include #include #ifdef JED # include "jdmacros.h" #endif #ifdef HAVE_STDLIB_H # include #endif #ifdef HAVE_UNISTD_H # include #endif #include #include #include #if defined(__DECC) && defined(VMS) # include #endif #ifdef VMS # include #endif #ifdef __unix__ # include # include # include # ifdef HAVE_FCNTL_H # include # endif # ifdef HAVE_SYS_FCNTL_H # include # endif #endif #if defined(__BORLANDC__) || defined(_MSC_VER) # include # include # include #endif #ifdef __os2__ # include # include # include # include #endif #ifndef O_RDONLY # ifdef VMS # include # else # include # endif #endif #include "vfile.h" #include "sig.h" #include "misc.h" /*}}}*/ unsigned int VFile_Mode = VFILE_TEXT; VFILE *vopen(SLFUTURE_CONST char *file, unsigned int size, unsigned int fmode) /*{{{*/ { int fd; unsigned int mode; #ifdef O_BINARY mode = O_BINARY; #else mode = 0; #endif while ((fd = open(file, mode | O_RDONLY, 0)) < 0) { #ifdef EINTR if (errno == EINTR) { if (-1 == jed_handle_interrupt ()) return NULL; continue; } #endif return NULL; } return vstream(fd, size, fmode); } /*}}}*/ void vclose(VFILE *v) /*{{{*/ { (void) close(v->fd); SLfree(v->buf); SLfree ((char *)v); } /*}}}*/ VFILE *vstream(int fd, unsigned int size, unsigned int mode) /*{{{*/ { VFILE *v; if (NULL == (v = (VFILE *) SLmalloc(sizeof(VFILE)))) return(NULL); v->bmax = v->bp = v->buf = NULL; v->fd = fd; v->eof = NULL; v->size = size; if (mode == 0) mode = VFile_Mode; v->mode = mode; v->cr_flag = 0; return v; } /*}}}*/ /* I malloc one extra so that I can always add a null character to last line */ char *vgets(VFILE *vp, unsigned int *num) /*{{{*/ { register char *bp, *bp1; register char *bmax, *bpmax; char *neew; int fd = vp->fd; unsigned int n, max, fmode = vp->mode; int doread = 0; n = vp->size; *num = 0; if (NULL == vp->buf) { #if defined (__MSDOS_16BIT__) if (!n) n = 512; #else if (!n) n = 64 * 1024; #endif if (NULL == (neew = SLmalloc(n + 1))) return NULL; vp->bp = vp->buf = neew; vp->bmax = neew + n; doread = 1; } bp = vp->bp; if ((vp->eof != NULL) && (bp >= vp->eof)) return (NULL); bp1 = vp->buf; bmax = vp->bmax; while (1) { if (doread) { max = (int) (vp->bmax - bp); while (max > 0) { int nread; nread = read(fd, bp, max); if (nread == 0) break; if (nread == -1) { if (SLKeyBoard_Quit || (SLang_get_error () == SL_USER_BREAK)) break; #if defined(__WIN32__) && (defined(_MSC_VER) || defined(__BORLANDC__)) # ifdef EPIPE if (errno == EPIPE) break; # endif #endif #ifndef IBMPC_SYSTEM # ifdef EINTR if (errno == EINTR) { if (-1 == jed_handle_interrupt ()) break; continue; } # endif # ifdef EAGAIN if (errno == EAGAIN) { if (-1 == jed_handle_interrupt ()) break; sleep (1); continue; } # endif #endif return NULL; } max -= nread; bp += nread; } if (max) vp->eof = bp; if (bp == bp1) { return(NULL); } bp = bp1; } else bp1 = bp; /* extract a line */ if (vp->eof != NULL) bmax = vp->eof; n = (unsigned int) (bmax - bp); #if defined(__MSDOS__) if (n) { bpmax = bp; #if defined(__BORLANDC__) && !defined(__WIN32__) asm { mov bx, di mov al, 10 mov cx, n les di, bpmax cld repne scasb inc cx sub n, cx mov di, bx } bp += n; #else if (NULL == (bpmax = SLMEMCHR(bp, '\n', n))) bp += n; else bp = bpmax; #endif /* __WIN32__ */ if (*bp != '\n') bp++; } if (bp < bmax) { vp->bp = ++bp; *num = (unsigned int) (bp - bp1); /* if it is text, replace the carriage return by a newline and adjust the number read by 1 */ bp -= 2; if ((fmode == VFILE_TEXT) && (*num > 1) && (*bp == '\r')) { *bp = '\n'; *num -= 1; vp->cr_flag = 1; } return bp1; } #else if (NULL != (bpmax = SLMEMCHR(bp, '\n', n))) { bpmax++; vp->bp = bpmax; *num = (unsigned int) (bpmax - bp1); if ((fmode == VFILE_TEXT) && (*num > 1)) { bpmax -= 2; if (*bpmax == '\r') { vp->cr_flag = 1; *bpmax = '\n'; (*num)--; } } return bp1; } bp = bp + n; #endif /* __MSDOS__ */ if (vp->eof != NULL) { *num = (unsigned int) (bp - bp1); vp->bp = bp; #if defined(IBMPC_SYSTEM) /* kill ^Z at EOF if present */ if ((fmode == VFILE_TEXT) && (*num) && (26 == *(bp - 1))) { *num -= 1; if (!*num) bp1 = NULL; } #endif return(bp1); } doread = 1; bp = bp1; bp1 = vp->buf; if (bp != bp1) { /* shift to beginning */ while (bp < bmax) *bp1++ = *bp++; bp = bp1; bp1 = vp->buf; } else { bp = bmax; vp->bmax += 2 * (int) (vp->bmax - vp->buf); neew = SLrealloc (vp->buf, 1 + (unsigned int) (vp->bmax - vp->buf)); if (neew == NULL) return NULL; bp = neew + (int) (bmax - vp->buf); bmax = vp->bmax = neew + (int) (vp->bmax - vp->buf); bp1 = vp->buf = neew; } } } /*}}}*/ jed-0.99-19/src/line.c0000644002657400265740000000357011311317447013361 0ustar davisdavis/* -*- mode: C; mode: fold; -*- */ /* Copyright (c) 1992, 1998, 2000, 2002, 2003, 2004, 2005, 2006 John E. Davis * This file is part of JED editor library source. * * You may distribute this file under the terms the GNU General Public * License. See the file COPYING for more information. */ #include "config.h" #include "jed-feat.h" #include #include #include "buffer.h" #include "ins.h" #include "misc.h" #include "paste.h" #include "undo.h" #include "line.h" /* breaks line at current point leaving point at end of current line */ int split_line (void) /*{{{*/ { int size; if (CLine == NULL) { exit_error("split_line: Null Line", 1); } size = CLine->len - Point; if (NULL == make_line(size + 1)) { exit_error("Allocation Failure in split_line", 0); } SLMEMCPY((char *) CLine->data, (char *) (CLine->prev->data + Point), size); CLine->len = size; CLine = CLine->prev; LineNum--; CLine->len = Point; remake_line(Point + 1); /* now update the marks */ jed_update_marks(NLINSERT, 1); record_newline_insertion(); return(0); } /*}}}*/ void splice_line (void) /*{{{*/ { int n1, n2; int save_point; #if JED_HAS_LINE_ATTRIBUTES unsigned int flags; #endif if (CLine->next == NULL) { exit_error("splice line: next line is Null", 1); } push_spot(); n1 = CLine->len; n2 = CLine->next->len; #ifdef KEEP_SPACE_INFO if (n1 + n2 > CLine->space) #endif remake_line(n1 + n2 + 1); SLMEMCPY((char *) (CLine->data + Point), (char *) CLine->next->data, n2); CLine->len = n1 + n2; save_point = Point; (void) jed_down (1); Point = save_point; jed_update_marks(NLDELETE, 1); #if JED_HAS_LINE_ATTRIBUTES flags = CLine->flags; #endif delete_line(); pop_spot(); #if JED_HAS_LINE_ATTRIBUTES if (n1 == 0) CLine->flags = flags; #endif } /*}}}*/ jed-0.99-19/src/os2.c0000644002657400265740000006165611311317447013146 0ustar davisdavis/* Copyright (c) 1992, 1998, 2000, 2002, 2003, 2004, 2005, 2006 John E. Davis * This file is part of JED editor library source. * * You may distribute this file under the terms the GNU General Public * License. See the file COPYING for more information. */ #include "config.h" #include "jed-feat.h" #if !defined (_MSC_VER) && !defined (__EMX__) && !defined(__WATCOMC__) && !defined(__IBMC__) # include #endif #ifdef __IBMC__ # include # include #endif #define INCL_BASE #define INCL_NOPM #define INCL_VIO #define INCL_KBD #define INCL_DOS #include #include #include #include #include #include #ifndef __IBMC__ # include #endif #include #include "sysdep.h" #include "screen.h" #include "buffer.h" #include "misc.h" #include "hooks.h" #if JED_HAS_SUBPROCESSES #include "jprocess.h" #endif #include "dos_os2.c" /* extern char *get_cwd (void); */ void delay (int time); void set_kbd (void); /* void os2_kbdhandler_thread (void); */ #define lowercase strlwr KBDINFO initialKbdInfo; /* keyboard info */ static int atEnd = 0; #ifdef __os2_16__ typedef USHORT APIRET; typedef HSEM OS2_SEM; # define DosRequestMutexSem(hmtx,timeout) DosSemRequest(hmtx,timeout) # define DosReleaseMutexSem(hmtx) DosSemClear(hmtx) # define DosCloseMutexSem(hmtx) DosCloseSem(hmtx) #else /* !defined(__os2_16__) */ typedef HMTX OS2_SEM; #endif /* Semaphore code for accessing keyboard buffers in threads*/ static OS2_SEM Hmtx_Kbd ; /* Mutex Semaphore */ APIRET CreateSem(OS2_SEM *Hmtx) { APIRET result; #ifdef __os2_16__ static SemNo = 0; char SemName[32]; sprintf(SemName, "\\SEM\\jed\\%u", getpid() + SemNo++); result = DosCreateSem (0, Hmtx, SemName); #else result = DosCreateMutexSem (NULL, Hmtx, 0, 0); #endif DosReleaseMutexSem (*Hmtx); return result; } APIRET CloseSem (OS2_SEM Hmtx) { return( DosCloseMutexSem (Hmtx) ); } /* define these using macros to improve efficiency */ #define RequestSem(Hmtx) DosRequestMutexSem (Hmtx, -1); #define ReleaseSem(Hmtx) DosReleaseMutexSem (Hmtx); #undef USING_INPUT_BUFFER #undef DONE_WITH_INPUT_BUFFER #define USING_INPUT_BUFFER RequestSem (Hmtx_Kbd); #define DONE_WITH_INPUT_BUFFER ReleaseSem (Hmtx_Kbd); /* do this using a macro to improve efficiency */ #define os2_buffer_keystring(s, n) \ if (!(n + Input_Buffer_Len > MAX_INPUT_BUFFER_LEN - 3)) { \ \ USING_INPUT_BUFFER \ memcpy ((char *) Input_Buffer + Input_Buffer_Len, s, n); \ Input_Buffer_Len += n; \ DONE_WITH_INPUT_BUFFER \ } #define THREADSTACKSIZE 32768 static TID Os2_Kbdhandler_ThreadID = (TID) 0 ; /* in a separate thread, read keyboard and put the keys into JED's keyboard * buffer */ static int enhancedKeyboard; #define keyWaiting() (Input_Buffer_Len) #include "pcscan.c" static void os2_thread_process_key (unsigned int c0, unsigned int c1, unsigned int shift) { unsigned char keybuf[16]; unsigned int scan; unsigned int num; shift = shift & 0xF; scan = ((c1 << 8) | c0) & 0xFFFF; num = jed_scan_to_key (scan, shift, keybuf); os2_buffer_keystring (keybuf, num); } static void os2_kbdhandler_thread (void) { KBDKEYINFO keyInfo; while (!atEnd) { /* at end is a flag */ KbdCharIn(&keyInfo, IO_NOWAIT, 0); /* get a character */ if (keyInfo.fbStatus & 0x040) { /* found a char process it */ if (keyInfo.chChar == Jed_Abort_Char) { if (Ignore_User_Abort == 0) SLang_Error = USER_BREAK; SLKeyBoard_Quit = 1; } /* now process them */ /* read codes from buffer */ os2_thread_process_key (keyInfo.chChar, keyInfo.chScan, keyInfo.fsState); } else { /* no char available*/ set_kbd(); /* is this necessary? */ DosSleep (50); } } } static void os2_kbdthread (void *Args) { (void) Args; os2_kbdhandler_thread (); atEnd = 0; /* reset the flag */ _endthread(); } /* The code below is in the main thread */ void set_kbd() { KBDINFO kbdInfo; kbdInfo = initialKbdInfo; kbdInfo.fsMask &= ~0x0001; /* not echo on */ kbdInfo.fsMask |= 0x0002; /* echo off */ kbdInfo.fsMask &= ~0x0008; /* cooked mode off */ kbdInfo.fsMask |= 0x0004; /* raw mode */ kbdInfo.fsMask &= ~0x0100; /* shift report off */ KbdSetStatus(&kbdInfo, 0); } int init_tty () { VIOCURSORINFO cursorInfo, OldcursorInfo; if (Batch) return 0; #ifdef HAS_MOUSE if (X_Open_Mouse_Hook != NULL) (*X_Open_Mouse_Hook) (); #endif /* set ^C off */ signal (SIGINT, SIG_IGN); signal (SIGBREAK, SIG_IGN); initialKbdInfo.cb = sizeof(initialKbdInfo); KbdGetStatus(&initialKbdInfo, 0); set_kbd(); enhancedKeyboard = 1; CreateSem (&Hmtx_Kbd); /* start a separate to read the keyboard */ #if defined(__BORLANDC__) Os2_Kbdhandler_ThreadID = _beginthread (os2_kbdthread, THREADSTACKSIZE, NULL); #else Os2_Kbdhandler_ThreadID = _beginthread (os2_kbdthread, NULL, THREADSTACKSIZE, NULL); #endif if ((int)Os2_Kbdhandler_ThreadID == -1) { exit_error ("init_tty: Error starting keyboard thread.", 0); } VioGetCurType (&OldcursorInfo, 0); cursorInfo.yStart = 1; cursorInfo.cEnd = 15; cursorInfo.cx = 1; cursorInfo.attr = 1; if (VioSetCurType (&cursorInfo, 0)) VioSetCurType (&OldcursorInfo, 0); /* reset to previous value */ return 0; } void reset_tty () { if (Batch) return; atEnd = 1; /* set flag and wait until thread ends */ #if __os2_16__ while (atEnd) { DosSleep (0); } #else DosWaitThread (&Os2_Kbdhandler_ThreadID, DCWW_WAIT); #endif /* close the keyboard */ KbdSetStatus(&initialKbdInfo, 0); /* restore original state */ #ifdef HAS_MOUSE if (X_Close_Mouse_Hook != NULL) (*X_Close_Mouse_Hook) (); #endif CloseSem (Hmtx_Kbd); } /* sleep for *tsecs tenths of a sec waiting for input */ int sys_input_pending(int *tsecs, int proc) { int count = *tsecs * 5; #if JED_HAS_SUBPROCESSES if ((proc >= 0) && (Batch || Input_Buffer_Len)) return(Input_Buffer_Len); #else if (Batch || Input_Buffer_Len) return(Input_Buffer_Len); #endif if (count) { while(count > 0) { delay(20); /* 20 ms or 1/50 sec */ #if JED_HAS_SUBPROCESSES if ((proc >= 0) && keyWaiting ()) break; if (proc) { int i = 0; while (i < Num_Subprocesses) { if (Subprocess_Read_fds[i][0]) read_process_input (Subprocess_Read_fds[i][1]); i++; } } #else if (keyWaiting ()) break; #endif count--; } return(count); } #if JED_HAS_SUBPROCESSES if (proc) { int i = 0; while (i < Num_Subprocesses) { if (Subprocess_Read_fds[i][0]) read_process_input (Subprocess_Read_fds[i][1]); i++; } } if (proc >= 0) return keyWaiting (); #else return keyWaiting (); #endif } unsigned char sys_getkey () { int weird = 300; #if JED_HAS_SUBPROCESSES int all = Num_Subprocesses; #else int all = 0; #endif while (!sys_input_pending(&weird, all)) { if (Display_Time) { JWindow->trashed = 1; update((Line *) NULL, 0, 1, 0); } } /* if (JMouse_Hide_Mouse_Hook != NULL) (*JMouse_Hide_Mouse_Hook) (0); */ return my_getkey (); } void sys_flush_input() { KbdFlushBuffer(0); } #if 0 int get_term_dimensions(int *w, int *h) { VIOMODEINFO vioModeInfo; vioModeInfo.cb = sizeof(vioModeInfo); VioGetMode (&vioModeInfo, 0); *w = vioModeInfo.col; *h = vioModeInfo.row; return 0; } #endif #if defined(_MSC_VER) || defined (__EMX__) || defined(__WATCOMC__) int sys_chmod(SLFUTURE_CONST char *file, int what, mode_t *mode, uid_t *uid, gid_t *gid) { struct stat buf; int m; # ifdef _MSC_VER /* MSC stat() is broken on directory names ending with a slash */ char path[_MAX_PATH]; safe_strcpy(path, file, sizeof (path)); deslash(file = path); # endif if (what) { chmod(file, *mode); return(0); } if (stat(file, &buf) < 0) switch (errno) { case EACCES: return(-1); /* es = "Access denied."; break; */ case ENOENT: return(0); /* ms = "File does not exist."; */ case ENOTDIR: return(-2); /* es = "Invalid Path."; */ default: return(-3); /* "stat: unknown error."; break;*/ } m = buf.st_mode; *mode = m & 0777; if (m & S_IFDIR) return (2); return(1); } #else int sys_chmod(char *file, int what, mode_t *mode, uid_t *dum1, gid_t *dum2) { FILESTATUS3 fileInfo; USHORT Result; char path[_MAX_PATH]; (void) dum1; (void) dum2; /* DosQueryPathInfo won't work with directory names ending with a slash */ safe_strcpy(path, file, sizeof(path)); deslash(file = path); Result = DosQueryPathInfo (path, FIL_STANDARD, &fileInfo, sizeof (fileInfo)); if (Result == ERROR_FILE_NOT_FOUND) return 0; else if (Result == ERROR_ACCESS_DENIED) return -1; else if (Result == ERROR_INVALID_PATH) return -2; else if (Result != NO_ERROR) return -3; *mode = fileInfo.attrFile; if (what) { fileInfo.attrFile = *mode; DosSetPathInfo (file, FIL_STANDARD, &fileInfo, sizeof (fileInfo), 0); } if (*mode & 0x10) return(2); else return (1); } #endif static char Found_Dir[JED_MAX_PATH_LEN]; static char Found_File[JED_MAX_PATH_LEN]; static int Found_FLen; #ifdef __os2_16__ # define DosFindFirst(FileName, DirHandle, Attribute, ResultBuf, \ ResultBufLen, SearchCount, Reserved) \ DosFindFirst(FileName, DirHandle, Attribute, ResultBuf, \ ResultBufLen, SearchCount, 0) #endif int sys_findfirst(char *theFile) { char *f, the_path[CCHMAXPATH], *file, *f1; char *pat; #if defined(__os2_16__) FILEFINDBUF FindBuffer; USHORT FindCount; USHORT File_Attr; #else FILEFINDBUF3 FindBuffer; ULONG FindCount; ULONG File_Attr; #endif HDIR FindHandle; File_Attr = FILE_READONLY | FILE_DIRECTORY; file = jed_standardize_filename_static(theFile); f1 = f = extract_file(file); strcpy (Found_Dir, file); strcpy (Found_File, file); Found_FLen = strlen(Found_File); Found_Dir[(int) (f - file)] = 0; strcpy(the_path, file); while (*f1 && (*f1 != '*')) f1++; if (! *f1) { while (*f && (*f != '.')) f++; if (*f) strcat(the_path, "*"); else strcat(the_path, "*.*"); } pat = the_path; FindHandle = 1; FindCount = 1; if (DosFindFirst(pat, &FindHandle, File_Attr, &FindBuffer, sizeof (FindBuffer), &FindCount, FIL_STANDARD) != NO_ERROR) return 0; strcpy (theFile, Found_Dir); strcat (theFile, FindBuffer.achName); /* OS/2 HPFS has the same problem as Windows: the filesystem is * case-insensitive so if one searches for makefi*, it will return * Makefile.in between the others, so check for wrong values and reject * them */ if (Jed_Filename_Case_Sensitive && (0 != strncmp (file, Found_File, Found_FLen)) && !sys_findnext (file)) return 0; if (FindBuffer.attrFile & FILE_DIRECTORY) fixup_dir (theFile); return 1; } int sys_findnext(char *file) { #ifdef __os2_16__ FILEFINDBUF FindBuffer; USHORT FileCount; #else FILEFINDBUF3 FindBuffer; ULONG FileCount; #endif while (1) { FileCount = 1; if (DosFindNext(1, &FindBuffer, sizeof (FindBuffer), &FileCount)) return 0; else { strcpy (file, Found_Dir); strcat (file, FindBuffer.achName); /* OS/2 HPFS has the same problem as Windows: the filesystem is * case-insensitive so if one searches for makefi*, it will return * Makefile.in between the others, so check for wrong values and * reject them */ if (Jed_Filename_Case_Sensitive && (0 != strncmp (file, Found_File, Found_FLen))) continue; if (FindBuffer.attrFile & FILE_DIRECTORY) fixup_dir (file); return 1; } } } #if 0 unsigned long sys_file_mod_time(char *file) { FILESTATUS3 fileInfo; struct time t; struct date d; if (DosQueryPathInfo (file, FIL_STANDARD, &fileInfo, sizeof (fileInfo)) != NO_ERROR) return 0; t.ti_min = fileInfo.ftimeLastWrite.minutes; t.ti_hour = fileInfo.ftimeLastWrite.hours; t.ti_hund = 0; t.ti_sec = fileInfo.ftimeLastWrite.twosecs; d.da_day = fileInfo.fdateLastWrite.day; d.da_mon = fileInfo.fdateLastWrite.month; d.da_year = fileInfo.fdateLastWrite.year; return dostounix(&d, &t); } #endif void delay (int time) { DosSleep (time); } int IsHPFSFileSystem (char *directory) { ULONG lMap; BYTE bData[128]; BYTE bName[3]; int i; char *FName; #if defined (__os2_16__) USHORT cbData; USHORT nDrive; # define DosQueryCurrentDisk DosQCurDisk #else ULONG cbData; ULONG nDrive; PFSQBUFFER2 pFSQ = (PFSQBUFFER2)bData; #endif #ifndef __WATCOMC__ if ( _osmode == DOS_MODE ) return FALSE; #endif if (isalpha (directory[0]) && (directory[1] == ':')) nDrive = toupper (directory[0]) - '@'; else DosQueryCurrentDisk (&nDrive, &lMap); /* Set up the drive name */ bName[0] = (char) (nDrive + '@'); bName[1] = ':'; bName[2] = 0; cbData = sizeof (bData); #if defined(__os2_16__) if (DosQFSAttach (bName, 0, FSAIL_QUERYNAME, bData, &cbData, 0L)) #else if (DosQueryFSAttach (bName, 0, FSAIL_QUERYNAME, pFSQ, &cbData)) #endif return FALSE; #if defined(__os2_16__) FName = bData + (*((USHORT *) (bData + 2)) + 7); #else FName = pFSQ->szName + pFSQ->cbName + 1; #endif if (strcmp(FName, "HPFS")) return FALSE; return(TRUE); } /* Code for EAs */ #if defined(__os2_16__) /* Variables and data structures used for handling EA's, these are defined in the 32 BIT API, so these will be included in os2.h */ typedef USHORT APIRET; typedef struct _FEA2 /* fea2 */ { # if 0 /* This field is in the 32 bit structure */ ULONG oNextEntryOffset; /* New field */ # endif BYTE fEA; BYTE cbName; USHORT cbValue; CHAR szName[1]; /* New field */ } FEA2; typedef FEA2 *PFEA2; typedef struct _FEA2LIST /* fea2l */ { ULONG cbList; FEA2 list[ 1 ]; } FEA2LIST; typedef FEA2LIST *PFEA2LIST; typedef struct _GEA2 /* gea2 */ { # if 0 /* New field - in the 32 bit structure */ ULONG oNextEntryOffset; # endif /* OS2_32 */ BYTE cbName; CHAR szName[ 1 ]; /* New field */ } GEA2; typedef GEA2 *PGEA2; typedef struct _GEA2LIST /* gea2l */ { ULONG cbList; GEA2 list[ 1 ]; } GEA2LIST; typedef GEA2LIST *PGEA2LIST; typedef struct _EAOP2 /* eaop2 */ { PGEA2LIST fpGEA2List; /* GEA set */ PFEA2LIST fpFEA2List; /* FEA set */ ULONG oError; /* Offset of FEA error */ } EAOP2; /* typedef EAOP2 *PEAOP2; */ # define DosSetPathInfo(PathName, PathInfoLevel, PathInfoBuf, \ PathInfoBufSize, PathInfoFlags) \ DosSetPathInfo(PathName, PathInfoLevel, PathInfoBuf, \ PathInfoBufSize, PathInfoFlags, 0) # define DosQueryPathInfo(PathName, PathInfoLevel, PathInfoBuf, \ PathInfoBufSize) \ DosQPathInfo(PathName, PathInfoLevel, PathInfoBuf, PathInfoBufSize, 0) # define DosEnumAttribute(RefType, FileRef, EntryNum, EnumBuf, \ EnumBufSize, EnumCnt, InfoLevel) \ DosEnumAttribute(RefType, FileRef, EntryNum, EnumBuf, \ EnumBufSize, EnumCnt, InfoLevel, 0) #endif /* The HoldFEA is used to hold individual EAs. The member names correspond directly to those of the FEA structure. Note however, that both szName and aValue are pointers to the values. An additional field, next, is used to link the HoldFEA's together to form a linked list. */ struct _HoldFEA { BYTE fEA; /* Flag byte */ BYTE cbName; USHORT cbValue; CHAR *szName; BYTE *aValue; struct _HoldFEA *next; }; typedef struct _HoldFEA HOLDFEA; #define MAX_GEA 500L /* Max size for a GEA List */ #define REF_ASCIIZ 1 /* Reference type for DosEnumAttribute */ #define GET_INFO_LEVEL1 1 /* Get info from SFT */ #define GET_INFO_LEVEL2 2 /* Get size of FEAlist */ #define GET_INFO_LEVEL3 3 /* Get FEAlist given the GEAlist */ #define GET_INFO_LEVEL4 4 /* Get whole FEAlist */ #define GET_INFO_LEVEL5 5 /* Get FSDname */ #define SET_INFO_LEVEL1 1 /* Set info in SFT */ #define SET_INFO_LEVEL2 2 /* Set FEAlist */ /* #define BufferSize 1024 static char FileBuffer [BufferSize]; */ static HOLDFEA *pHoldFEA; /* EA linked-list pointer */ /* Free_FEAList (pFEA) Frees the memory used by the linked list of HOLDFEA's pointed to by pFEA */ void Free_FEAList( HOLDFEA *pFEA ) { HOLDFEA *next; /* Holds the next field since we free the structure before reading the current next field */ /* Step through the list freeing all the fields */ while( pFEA ) { /* Free the fields of the struct */ next = pFEA->next; if( pFEA->szName != NULL ) /* Free if non-NULL name */ free(pFEA->szName); if( pFEA->aValue != NULL ) /* Free if non-NULL value */ free(pFEA->aValue); /* Free the pFEA struct itself and move on to the next field */ free(pFEA); pFEA = next; } } #if 0 /* Read the EA type, this is stored at the start of the EA value */ ULONG getEAType( const CHAR *Value ) { USHORT Type = *( USHORT * ) Value; return( Type ); } /* Return the EA length, stored in pFEA, this done so that it is calculated in only one place */ ULONG getEALength( const HOLDFEA *pFEA ) { return( sizeof( FEA2 ) - sizeof( CHAR ) /* Don't include the first element of aValue */ + pFEA->cbName + 1 /* Length of ASCIIZ name */ + pFEA->cbValue ); /* The value length */ } /* Set the first two words of the EA value, this is usually the EA type and EA size in pFEA, from the values Type and Size */ void setEATypeSize( const HOLDFEA *pFEA, const USHORT Type, const USHORT Size ) { USHORT *valPtr = ( USHORT * ) pFEA->aValue; valPtr[ 0 ] = Type; valPtr[ 1 ] = Size; } /* Read the first two words of the EA value, this is usually the EA type and EA size in pFEA, into the Type and Size */ void getEATypeSize( const HOLDFEA *pFEA, USHORT *Type, USHORT *Size ) { USHORT *valPtr = ( USHORT * ) pFEA->aValue; *Type = valPtr[ 0 ]; *Size = valPtr[ 1 ]; } /* Get the address of the EA value in pFEA, ie skip over the Type and Size */ void* getEADataVal (const HOLDFEA *pFEA) { /* Skip over the type and size */ return pFEA->aValue + 2 * sizeof ( USHORT ); } #endif /* QueryEAs (szFileName) find all EAs that file szFileName has return these in the linked list of HOLDFEAs if no EAs exist or the linked list cannot be created then return NULL This function is modelled after code from IBM's Toolkit */ HOLDFEA *QueryEAs( const CHAR *szFileName ) { HOLDFEA *pHoldFEA; /* The start of the linked list */ CHAR *pAllocc = NULL; /* Temp buffer used with DosEnumAttribute */ CHAR *pBigAlloc = NULL; /* Temp buffer to hold each EA as it is read in */ USHORT cbBigAlloc = 0; ULONG ulEntryNum = 1; /* Count of current EA to read (1-relative) */ ULONG ulEnumCnt; /* Number of EAs for Enum to return, always 1 */ HOLDFEA *pLastIn = 0; /* Points to last EA added, so new EA can link */ HOLDFEA *pNewFEA = NULL; /* Struct to build the new EA in */ FEA2 *pFEA; /* Used to read from Enum's return buffer */ GEA2LIST *pGEAList; /* Ptr used to set up buffer for DosQueryPathInfo() */ EAOP2 eaopGet; /* Used to call DosQueryPathInfo() */ pAllocc = malloc( MAX_GEA ); /* Allocate room for a GEA list */ pFEA = ( FEA2 * ) pAllocc; pHoldFEA = NULL; /* Initialize the linked list */ /* Loop through all the EA's adding them to the list */ while( TRUE ) { ulEnumCnt = 1; /* No of EAs to retrieve */ if( DosEnumAttribute( REF_ASCIIZ, /* Read into EA name into */ szFileName, /* pAlloc Buffer */ ulEntryNum, pAllocc, MAX_GEA, &ulEnumCnt, ( LONG ) GET_INFO_LEVEL1 ) ) break; /* An error */ /* Exit if all the EA's have been read */ if( ulEnumCnt != 1 ) break; /* Move on to next EA */ ulEntryNum++; /* Try and allocate the HoldFEA structure */ if( ( pNewFEA = malloc( sizeof( HOLDFEA ) ) ) == NULL ) { free( pAllocc ); Free_FEAList( pHoldFEA ); return( NULL ); } /* Fill in the HoldFEA structure */ pNewFEA->cbName = pFEA->cbName; pNewFEA->cbValue= pFEA->cbValue; pNewFEA->fEA = pFEA->fEA; pNewFEA->next = '\0'; /* pNewFEA->next = NULL; */ /* Allocate the two arrays */ if( ( pNewFEA->szName = malloc( pFEA->cbName + 1 ) ) == NULL || \ ( pNewFEA->aValue = malloc( pFEA->cbValue ) ) == NULL ) { /* Out of memory, clean up and exit */ if( pNewFEA->szName ) free( pNewFEA->szName ); if( pNewFEA->aValue ) free( pNewFEA->aValue ); free( pAllocc ); free( pNewFEA ); Free_FEAList( pHoldFEA ); return( NULL ); } /* Copy EA name across */ strcpy( pNewFEA->szName, pFEA->szName ); cbBigAlloc = sizeof( FEA2LIST ) + pNewFEA->cbName + 1 + pNewFEA->cbValue; /* +1 is for '\0' */ if( ( pBigAlloc = malloc( cbBigAlloc ) ) == NULL ) { free( pNewFEA->szName ); free( pNewFEA->aValue ); free( pAllocc ); free( pNewFEA ); Free_FEAList( pHoldFEA ); return( NULL ); } /* Set up GEAlist structure */ pGEAList = ( GEA2LIST * ) pAllocc; pGEAList->cbList = sizeof( GEA2LIST ) + pNewFEA->cbName; /* + 1 for NULL */ #ifndef __os2_16__ pGEAList->list[ 0 ].oNextEntryOffset = 0L; #endif pGEAList->list[ 0 ].cbName = pNewFEA->cbName; strcpy( pGEAList->list[ 0 ].szName, pNewFEA->szName ); eaopGet.fpGEA2List = ( GEA2LIST FAR * ) pAllocc; eaopGet.fpFEA2List = ( FEA2LIST FAR * ) pBigAlloc; eaopGet.fpFEA2List->cbList = cbBigAlloc; /* Get the complete EA info and copy the EA value */ DosQueryPathInfo( szFileName, FIL_QUERYEASFROMLIST, ( PVOID ) &eaopGet, \ sizeof( EAOP2 ) ); memcpy( pNewFEA->aValue, \ pBigAlloc + sizeof( FEA2LIST ) + pNewFEA->cbName, \ pNewFEA->cbValue ); /* Release the temp. Enum buffer */ free( pBigAlloc ); /* Add to the list */ if( pHoldFEA == NULL ) pHoldFEA = pNewFEA; else pLastIn->next = pNewFEA; pLastIn = pNewFEA; } /* Free up the GEA buffer for DosEnum() */ free( pAllocc ); return pHoldFEA; } /* WriteEAs(szFileName, pHoldFEA) Write the EAs contained in the linked list pointed to by pHoldFEA to the file szFileName. Returns TRUE if the write was successful, FALSE otherwise */ int WriteEAs( const char *szFileName, HOLDFEA *pHoldFEA ) { HOLDFEA *pHFEA = pHoldFEA; EAOP2 eaopWrite; CHAR *aPtr = NULL; USHORT usMemNeeded; APIRET rc; eaopWrite.fpGEA2List = NULL; while( pHFEA ) /* Go through each HoldFEA */ { usMemNeeded = sizeof( FEA2LIST ) + pHFEA->cbName + 1 + pHFEA->cbValue; if( ( aPtr = malloc( usMemNeeded ) ) == NULL ) return FALSE; /* Fill in eaop structure */ eaopWrite.fpFEA2List = ( FEA2LIST FAR * ) aPtr; eaopWrite.fpFEA2List->cbList = usMemNeeded; #ifdef __os2_16__ /* ugly hack for difference in 16-bit FEA struct */ eaopWrite.fpFEA2List->cbList -= ( sizeof(FEA2LIST) - sizeof(FEALIST) ); #else eaopWrite.fpFEA2List->list[ 0 ].oNextEntryOffset = 0L; #endif eaopWrite.fpFEA2List->list[ 0 ].fEA = pHFEA->fEA; eaopWrite.fpFEA2List->list[ 0 ].cbName = pHFEA->cbName; eaopWrite.fpFEA2List->list[ 0 ].cbValue = pHFEA->cbValue; strcpy( eaopWrite.fpFEA2List->list[ 0 ].szName, pHFEA->szName ); memcpy( eaopWrite.fpFEA2List->list[ 0 ].szName + pHFEA->cbName + 1, \ pHFEA->aValue, pHFEA->cbValue ); /* Write out the EA */ rc = DosSetPathInfo( szFileName, FIL_QUERYEASIZE, ( PVOID ) &eaopWrite, sizeof( EAOP2 ), DSPI_WRTTHRU ); /* Free up the FEALIST struct */ free( aPtr ); /* If the write failed, leave now */ if( rc ) return FALSE; pHFEA = pHFEA->next; } return( TRUE ); } void sys_pause (int ms) { DosSleep(ms); } #ifdef __IBMC__ /* Adapted from the routines posted by Jochen Friedrich */ /* Note: the pipe() function assumes that the C filedescriptors are * equal to the OS/2 API filehandles... This is true for IBM VisualAge .0, * but may be false for other compilers... */ int pipe(unsigned long fd[2]) { unsigned long status; if (DosCreatePipe(&(fd[0]), &(fd[1]), 4096) < 0) return (-1); if (DosQueryFHState(fd[0], &status) < 0) return (-1); status |= OPEN_FLAGS_NOINHERIT; status &= 0x7F88; if (DosSetFHState(fd[0], status) < 0) return (-1); if (DosQueryFHState(fd[1], &status) < 0) return (-1); status |= OPEN_FLAGS_NOINHERIT; status &= 0x7F88; if (DosSetFHState(fd[1], status) < 0) return (-1); _setmode(fd[0], O_BINARY); _setmode(fd[1], O_BINARY); return (0); } FILE *popen(char *cmd, char *mode) { FILE *our_end; unsigned long fd[2], tempfd, dupfd; char *comspec; pipe(fd); if (mode[0] == 'r') { our_end = fdopen(fd[0], mode); dupfd = 1; /* stdout */ tempfd = dup(dupfd); dup2(fd[1], dupfd); close(fd[1]); } else { our_end = fdopen(fd[1], mode); dupfd = 0; /* stdin */ tempfd = dup(dupfd); dup2(fd[0], dupfd); close(fd[0]); } comspec = getenv("COMSPEC"); if (comspec == NULL) { comspec = "C:\\OS2\\CMD.EXE"; } spawnlp(P_NOWAIT, comspec, comspec, "/c", cmd, NULL); dup2(tempfd, dupfd); close(tempfd); return (our_end); } int pclose(FILE *pip) { int i; fclose(pip); wait(&i); return (0); } #endif jed-0.99-19/src/indent.c0000644002657400265740000011065611311317447013717 0ustar davisdavis/* -*- mode: C; mode: fold; -*- */ /* Copyright (c) 1992, 1998, 2000, 2002, 2003, 2004, 2005, 2006 John E. Davis * This file is part of JED editor library source. * * You may distribute this file under the terms the GNU General Public * License. See the file COPYING for more information. */ #include "config.h" #include "jed-feat.h" /*{{{ Include Files */ #include #include #include "buffer.h" #include "window.h" #include "misc.h" #include "cmds.h" #include "display.h" #include "ledit.h" #include "screen.h" #include "sysdep.h" #include "search.h" #include "paste.h" #include "misc.h" #include "indent.h" /*}}}*/ /* Note: In this file, "UTF-8 ASCII safe" means that the routine will work * properly as long as we are dealing with ASCII characters for quotes and * comment strings. * * "UTF-8 WORD UNsafe" indicates that the routine is not safe when non-ASCII * characters are given the word syntax. * * ASCII means character codes 0-127. */ Syntax_Table_Type *Default_Syntax_Table; static Syntax_Table_Type *Syntax_Tables; /* UTF-8 ASCII safe */ static unsigned char *find_comment_end (Syntax_Table_Type *table, unsigned char *p, unsigned char *pmax) { unsigned int len; char *str; unsigned char ch; /* unsigned char quote; */ str = table->comment_stop; len = table->comment_stop_len; if ((str == NULL) || (len == 0)) return NULL; pmax -= (len - 1); ch = *str; /* quote = table->quote_char; */ while (p < pmax) { if ((*p == ch) && (0 == strncmp (str, (char *)p, len))) return p + len; p++; } return NULL; } /* UTF-8 ASCII safe */ static unsigned char *find_string_end (Syntax_Table_Type *table, unsigned char *p, unsigned char *pmax, unsigned char ch) { unsigned char quote; quote = table->quote_char; while (p < pmax) { if (*p == quote) { p = jed_multibyte_chars_forward (p+1, pmax, 1, NULL, 0); continue; } if (*p++ == ch) return p; } return NULL; } /* UTF-8 ASCII safe */ static int is_fortran_comment (Line *l, Syntax_Table_Type *table) { return l->len && table->fortran_comment_chars[l->data[0]]; } /* UTF-8 WORD unsafe */ int _jed_is_eol_comment_start (Syntax_Table_Type *table, Line *l, unsigned char *p, unsigned char *pmax, unsigned int *com) { unsigned int i; int wsc; if (p >= pmax) return 0; /* Most of the time, num_eol_comments is going to be <= 1, so just * use table->whatever. */ wsc = table->flags & EOL_COMMENT_NEEDS_WHITESPACE; for (i = 0; i < table->num_eol_comments; i++) { if (*p != table->eol_comment_starts[i][0]) continue; if (p + table->eol_comment_lens[i] > pmax) continue; if (0 == (table->flags & SYNTAX_NOT_CASE_SENSITIVE)) { if (0 != strncmp ((char *) p, table->eol_comment_starts[i], table->eol_comment_lens[i])) continue; } else { if (0 != jed_case_strncmp ((char *) p, table->eol_comment_starts[i], table->eol_comment_lens[i])) continue; } if ((table->char_syntax[*p] & WORD_SYNTAX) || wsc) { unsigned char *p1; unsigned char ch1; p1 = p + table->eol_comment_lens[i]; if (p1 < pmax) { ch1 = *p1; if (wsc) { if ((ch1 != ' ') && (ch1 != '\n') && (ch1 != '\t')) { /* This piece of code permits: #### */ if ((ch1 != *p) || (table->char_syntax[ch1] & WORD_SYNTAX) || (p1 != p + 1)) continue; } } else if (table->char_syntax[ch1] & WORD_SYNTAX) continue; } if (p > l->data) { ch1 = *(p-1); if (wsc) { if ((ch1 != ' ') && (ch1 != '\t')) { /* This piece of code permits: #### */ if ((ch1 != *p) || (table->char_syntax[ch1] & WORD_SYNTAX) || (p1 != p + 1)) continue; } } else if (table->char_syntax[ch1] & WORD_SYNTAX) continue; } } if (com != NULL) *com = i; return 1; } return 0; } static int parse_to_point1 (Syntax_Table_Type *table, Line *l, unsigned char *pmax) { unsigned char ch; int quote, cc, flags; unsigned char *p; unsigned int lflags; unsigned char com_start_char; char *comment_start; unsigned short *syntax; unsigned char *sc; unsigned char sgml_stop_char; flags = table->flags; p = l->data; if (flags & FORTRAN_TYPE) { if (is_fortran_comment (l, table)) return JED_LINE_HAS_EOL_COMMENT; } sc = table->string_chars; cc = table->char_char; syntax = table->char_syntax; sgml_stop_char = table->sgml_stop_char; lflags = l->flags & JED_LINE_SYNTAX_BITS; if (lflags) { if (lflags & JED_LINE_IN_COMMENT) { if (NULL == (p = find_comment_end (table, p, pmax))) return JED_LINE_IN_COMMENT; } else if (lflags & JED_LINE_IN_STRING0) { if (NULL == (p = find_string_end (table, p, pmax, sc[0]))) return JED_LINE_IN_STRING0; } else if (lflags & JED_LINE_IN_STRING1) { if (NULL == (p = find_string_end (table, p, pmax, sc[1]))) return JED_LINE_IN_STRING1; } else if (lflags & JED_LINE_IN_HTML) { if (NULL == (p = find_string_end (table, p, pmax, sgml_stop_char))) return JED_LINE_IN_HTML; } } /* Now we should be out of comments, strings, etc... */ quote = table->quote_char; comment_start = table->comment_start; com_start_char = (comment_start == NULL) ? 0 : *comment_start; while (p < pmax) { ch = *p; if (ch == quote) { p += 2; continue; } /* Search for a string delimiter, char delimiter, or comment start. */ #if 1 /* Check comment syntax first */ if (syntax[ch] & COMMENT_SYNTAX) { if ((ch == com_start_char) && (comment_start != NULL) && (p + table->comment_start_len <= pmax) && (0 == strncmp ((char *) p, comment_start, table->comment_start_len))) { p = find_comment_end (table, p + table->comment_start_len, pmax); if (p == NULL) return JED_LINE_IN_COMMENT; continue; } if (_jed_is_eol_comment_start (table, l, p, pmax, NULL)) return JED_LINE_HAS_EOL_COMMENT; } #endif if (syntax[ch] & (STRING_SYNTAX)) { p = find_string_end (table, p + 1, pmax, ch); if (p == NULL) { if (sc[0] == ch) return JED_LINE_IN_STRING0; if (sc[1] == ch) return JED_LINE_IN_STRING1; return JED_LINE_IN_STRING0; } continue; } if (syntax[ch] & HTML_START_SYNTAX) { p = find_string_end (table, p+1, pmax, table->sgml_stop_char); if (p == NULL) return JED_LINE_IN_HTML; continue; } #if 0 if (0 == (syntax[ch] & COMMENT_SYNTAX)) { p++; continue; } if ((ch == com_start_char) && (comment_start != NULL) && (p + table->comment_start_len <= pmax) && (0 == strncmp ((char *) p, comment_start, table->comment_start_len))) { p = find_comment_end (table, p + table->comment_start_len, pmax); if (p == NULL) return JED_LINE_IN_COMMENT; continue; } if (_jed_is_eol_comment_start (table, l, p, pmax, NULL)) return JED_LINE_HAS_EOL_COMMENT; #endif p++; } return 0; } static void goto_effective_eol (Syntax_Table_Type *table) /*{{{*/ { unsigned int flags; unsigned char *p, *pmax; unsigned short *syntax; flags = CLine->flags; if (0 == (flags & JED_LINE_HAS_EOL_COMMENT)) { eol (); return; } if (table->flags & FORTRAN_TYPE) { bol (); if (is_fortran_comment (CLine, table)) return; } if (0 == table->num_eol_comments) { /* ?? */ CLine->flags &= ~JED_LINE_HAS_EOL_COMMENT; eol (); return; } /* We know that there is an EOL style comment somewhere on this line. So, * just search for it. */ p = CLine->data; pmax = CLine->data + CLine->len; syntax = table->char_syntax; while (p < pmax) { unsigned int i; if ((syntax[*p] & COMMENT_SYNTAX) && (_jed_is_eol_comment_start (table, CLine, p, pmax, &i))) { /* Is this really a comment? Perhaps is occurs in a string * or in part of another word. Only one way to find out. */ jed_position_point (p + table->eol_comment_lens[i]); if (JED_LINE_HAS_EOL_COMMENT == parse_to_point1 (table, CLine, p + table->eol_comment_lens[i])) { jed_position_point (p); return; /* we are there */ } } p++; } /* ?? */ CLine->flags &= ~JED_LINE_HAS_EOL_COMMENT; eol (); } /*}}}*/ static Syntax_Table_Type *setup_for_match (unsigned char **pp, unsigned char *chp, unsigned char *want_chp) { register unsigned char ch, want_ch; Syntax_Table_Type *table; #if JED_HAS_LINE_ATTRIBUTES /* Make sure that the line flags are ok. */ if (CBuf->min_unparsed_line_num) jed_syntax_parse_buffer (0); #endif *pp = CLine->data + Point; ch = *chp; if (ch == 0) ch = **pp; table = CBuf->syntax_table; want_ch = 0; if (table != NULL) want_ch = table->matching_delim [ch]; if (want_ch == 0) { table = Default_Syntax_Table; if (table != NULL) want_ch = table->matching_delim [ch]; } if (want_ch == 0) return NULL; *chp = ch; *want_chp = want_ch; return table; } static int is_quoted (unsigned char *pmin, unsigned char **pp, unsigned char q) { unsigned char *p; int iq; iq = 0; p = *pp; while ((p >= pmin) && (*p == q)) { p--; iq = !iq; } if (iq) *pp = p; return iq; } static int goto_comment_begin (Syntax_Table_Type *table) { unsigned char *p, *pmin, *pmax; unsigned char ch; char *s; unsigned int len; if (NULL == (s = table->comment_start)) return -1; len = table->comment_start_len; ch = *s; while (1) { pmin = CLine->data; p = pmin + Point; pmax = pmin + CLine->len; while (p >= pmin) { if ((*p == ch) && (p + len <= pmax) && (0 == strncmp (s, (char *)p, len)) && (0 == parse_to_point1 (table, CLine, p))) { jed_position_point (p); return 0; } p--; } if (0 == jed_up (1)) { bol (); return -1; } } } static int goto_comment_end (Syntax_Table_Type *table) { unsigned char *p, *pmax; unsigned char ch; char *s; unsigned int len; if (NULL == (s = table->comment_stop)) return -1; len = table->comment_stop_len; ch = *s; while (1) { p = CLine->data + Point; pmax = CLine->data + CLine->len; while (p < pmax) { if ((*p == ch) && (p + len <= pmax) && (0 == strncmp (s, (char *)p, len))) { jed_position_point (p + len); return 0; } p++; } if (0 == jed_down (1)) { eol (); return -1; } } } /* Note that this routine may be called with p corresponding to Point = -1. * This will happen when the end quote character is at the beginning of a * line. */ static int goto_string_begin (Syntax_Table_Type *table, unsigned char ch, unsigned char *p) { unsigned char *pmin; unsigned char quote; quote = table->quote_char; pmin = CLine->data; while (1) { while (p >= pmin) { if (*p-- == ch) { if ((p >= pmin) && (*p == quote) && (is_quoted (pmin, &p, quote))) continue; jed_position_point (p + 1); return 0; } } if ((table->flags & SINGLE_LINE_STRINGS) || (0 == jed_up (1))) { bol (); return -1; } pmin = CLine->data; p = pmin + Point; } } static int goto_string_end (Syntax_Table_Type *table, unsigned char ch) { unsigned char *p, *pmax; unsigned char quote; quote = table->quote_char; while (1) { p = CLine->data + Point; pmax = CLine->data + CLine->len; while (p < pmax) { if (*p == ch) { jed_position_point (p + 1); /* go around it */ return 0; } if (*p == quote) p++; p++; } if ((table->flags & SINGLE_LINE_STRINGS) || (0 == jed_down (1))) { eol (); return -1; } } } /* Go backward looking for the matching ch--- not the char that matches ch. * Rather, ch is the matching character. * This routine returns: * 1 if found and leaves the point on the match * -2 if not found but we appear to be in a comment. In this case, the point * if left at the beginning of the comment * -1 Not found but we appear to be in a string. This leaves the point at the * beginning of the string. * 0 if not found. The point is left where we gave up * 2 if went back too far * count is the number of lines to go back */ static int backward_goto_match (int count, unsigned char ch) /*{{{*/ { unsigned char *p, *pmin, want_ch; unsigned short *syntax; int in_string, in_comment, in_html, level; int quote; Syntax_Table_Type *table; unsigned int this_syntax; unsigned char *pmax; unsigned char com_start_char, com_stop_char; unsigned char sgml_start_char, sgml_stop_char; if (NULL == (table = setup_for_match (&p, &ch, &want_ch))) return 0; syntax = table->char_syntax; quote = table->quote_char; level = 1; /* Get some context */ in_string = 0; in_comment = 0; switch (parse_to_point1 (table, CLine, CLine->data + Point)) { case JED_LINE_HAS_EOL_COMMENT: case JED_LINE_IN_COMMENT: in_comment = 1; break; case JED_LINE_IN_STRING0: in_string = (int) table->string_chars[0]; break; case JED_LINE_IN_STRING1: in_string = (int) table->string_chars[1]; break; case JED_LINE_IN_HTML: in_html = 1; break; } Point--; if (table->comment_start != NULL) com_start_char = (unsigned char) table->comment_start[0]; else com_start_char = 0; if (table->comment_stop != NULL) com_stop_char = (unsigned char) table->comment_stop[0]; else com_stop_char = 0; sgml_start_char = table->sgml_start_char; sgml_stop_char = table->sgml_stop_char; /* FIXME: handle sgml_start/stop_char */ pmax = CLine->data + CLine->len; while (count) { pmin = CLine->data; p = pmin + Point; /* This loop here is where it all happens. In this loop, we are * either in a string, a comment, or in code. If we are in a string * or comment, then that is where we started. So, upon hitting the * left boundary of the string or comment, quit parsing and return. * If in code, then skip all comments and strings because the match * must be in code. */ while (p >= pmin) { ch = *p--; if ((syntax[ch] & SYNTAX_MASK) == 0) continue; /* Check to see if it is quoted. */ if ((p >= pmin) && (*p == quote)) { if (is_quoted (pmin, &p, quote)) continue; } this_syntax = syntax[ch]; /* Check for strings and characters since those occur quite * frequently. */ if (this_syntax & STRING_SYNTAX) { /* a string is meaningless in a comment */ if (in_comment) continue; if (in_string) { if (in_string == (int) ch) { /* Match not found. Leave point at beginning * of string and return -1. */ /* Some syntaxes permit double quotes in a string * to represent a single quote. Allow that here. */ if ((p < pmin) || ((int)*p != in_string)) { jed_position_point (p + 1); return -1; } p--; } continue; } jed_position_point (p); if (-1 == goto_string_begin (table, ch, p)) { /* Can't find it. This should not happen except in the * case of a run-away character. */ return 0; } pmin = CLine->data; pmax = pmin + CLine->len; p = pmin + (Point - 1); continue; } /* Before checking for comments, check for matching * delimiters to give those a priority. */ if (this_syntax & OPEN_DELIM_SYNTAX) { if (level == 1) { jed_position_point (p+1); if (ch == want_ch) return 1; return 0; } level--; /* Drop down through because the open delimiter may also * be a comment character as in HTML and PASCAL. */ } if (this_syntax & CLOSE_DELIM_SYNTAX) { level++; /* Drop */ } /* The last thing to check is a comment. */ if ((0 == (this_syntax & COMMENT_SYNTAX)) || (in_string)) continue; if (in_comment) { /* Just look for the character that denotes the start * of the comment. In C++ this is complicated by something * like "*(no space)//". If you use such a construct then * you lose. */ p++; if (_jed_is_eol_comment_start (table, CLine, p, pmax, NULL)) { jed_position_point (p); return -2; } if ((ch == com_start_char) && (table->comment_start != NULL) && (p + table->comment_start_len <= pmax) && (0 == strncmp ((char *) p, table->comment_start, table->comment_start_len))) { jed_position_point (p); return -2; } p--; continue; } /* We are not in a comment but we may be moving into the tail * end of one. I am not going to consider eol type comments * here because if this is coded correctly and the algorithm * works, then that was already handled. */ if (ch != com_stop_char) continue; p++; if ((table->comment_stop == NULL) || (p + table->comment_stop_len > pmax) || (0 != strncmp ((char *) p, table->comment_stop, table->comment_stop_len))) { p--; continue; } jed_position_point (p); if (-1 == goto_comment_begin (table)) return 0; pmin = CLine->data; pmax = pmin + CLine->len; p = pmin + (Point - 1); } if (0 == jed_up (1)) { bol (); break; } count--; if (table->flags & SINGLE_LINE_STRINGS) in_string = 0; goto_effective_eol (table); pmax = CLine->data + Point; } /* What have we learned? */ if (Point < 0) Point = 0; if (count == 0) { /* In this case, we went back as far as permitted. Nothing much can be * said. */ bol (); return 2; } if (in_string) return -1; if (in_comment) return -2; /* If we are here, then we have a mismatch */ return 0; } /*}}}*/ static int forward_goto_match (unsigned char ch) /*{{{*/ { unsigned char *p, *pmax, want_ch; unsigned short *syntax; int in_string, in_comment, level; unsigned int this_syntax; Syntax_Table_Type *table; unsigned char com_start_char; if (NULL == (table = setup_for_match (&p, &ch, &want_ch))) return 0; syntax = table->char_syntax; /* Here we go */ in_string = 0; in_comment = 0; switch (parse_to_point1 (table, CLine, CLine->data + Point)) { case JED_LINE_HAS_EOL_COMMENT: in_comment = JED_LINE_HAS_EOL_COMMENT; break; case JED_LINE_IN_COMMENT: in_comment = JED_LINE_IN_COMMENT; break; case JED_LINE_IN_STRING0: in_string = (int) table->string_chars[0]; break; case JED_LINE_IN_STRING1: in_string = (int) table->string_chars[1]; break; } com_start_char = 0; if (table->comment_start != NULL) com_start_char = (unsigned char) table->comment_start[0]; level = 1; Point++; while (1) { p = CLine->data + Point; pmax = CLine->data + CLine->len; while (p < pmax) { ch = *p++; if ((syntax[ch] & SYNTAX_MASK) == 0) continue; this_syntax = syntax[ch]; if (this_syntax & COMMENT_SYNTAX) { if (in_string) continue; if (in_comment == JED_LINE_IN_COMMENT) { p--; if ((table->comment_stop != NULL) && (p + table->comment_stop_len <= pmax) && (0 == strncmp ((char *) p, table->comment_stop, table->comment_start_len))) { p += table->comment_stop_len; in_comment = 0; continue; } p++; continue; } /* We may have run into a comment. If so, go around */ if (in_comment == 0) { p--; if ((ch == com_start_char) && (table->comment_start != NULL) && (p + table->comment_start_len <= pmax) && (0 == strncmp ((char *) p, table->comment_start, table->comment_start_len))) { jed_position_point (p); if (-1 == goto_comment_end (table)) return 0; p = CLine->data + Point; pmax = CLine->data + CLine->len; continue; } if (_jed_is_eol_comment_start (table, CLine, p, pmax, NULL)) { p = pmax; continue; } p++; } /* drop */ } if (this_syntax & STRING_SYNTAX) { /* string/char */ if (in_comment) continue; if (in_string) { if ((int) ch == in_string) { /* Some syntaxes permit double quotes in a string * to represent a single quote. Allow that here. */ if ((p >= pmax) || ((int)*p != in_string)) in_string = 0; else p++; /* skip second quote */ } } else { jed_position_point (p); if (-1 == goto_string_end (table, ch)) return -1; p = CLine->data + Point; pmax = CLine->data + CLine->len; } continue; } if (this_syntax & OPEN_DELIM_SYNTAX) { level++; continue; } if (this_syntax & CLOSE_DELIM_SYNTAX) { if (level == 1) { jed_position_point (p-1); if (ch == want_ch) return 1; return 0; } level--; continue; } if (this_syntax & QUOTE_SYNTAX) p++; /* skip next char */ } /* END OF MAIN LOOP: while (p < pmax) */ if (in_comment == JED_LINE_HAS_EOL_COMMENT) return -2; /* Move to the next line. */ while (1) { if (0 == jed_down (1)) { eol (); if (in_string) return -1; if (in_comment) return -2; /* If we are here, then we have a mismatch */ return 0; } if (table->flags & SINGLE_LINE_STRINGS) in_string = 0; if ((0 == (table->flags & FORTRAN_TYPE)) || (0 == is_fortran_comment (CLine, table))) break; } } } /*}}}*/ static int find_matching_delimiter_1 (unsigned char ch, int nlines) { unsigned char want_ch; Syntax_Table_Type *table; unsigned char *p; table = setup_for_match (&p, &ch, &want_ch); if (table == NULL) return 0; if (table->char_syntax[ch] & OPEN_DELIM_SYNTAX) return forward_goto_match (ch); else return backward_goto_match (nlines, ch); } static int find_matching_delimiter (int *ch) { return find_matching_delimiter_1 ((unsigned char) *ch, 5000); } int goto_match (void) /*{{{*/ { if (1 != find_matching_delimiter_1 (0, LineNum)) { if (!IN_MINI_WINDOW) msg_error("Mismatch!!"); return 0; } return 1; } /*}}}*/ static int parse_to_point (void) /*{{{*/ { Syntax_Table_Type *table = CBuf->syntax_table; if (table == NULL) return 0; #if JED_HAS_LINE_ATTRIBUTES jed_syntax_parse_buffer (0); #endif switch (parse_to_point1 (table, CLine, CLine->data + Point)) { case JED_LINE_IN_COMMENT: case JED_LINE_HAS_EOL_COMMENT: return -2; case JED_LINE_IN_STRING0: case JED_LINE_IN_STRING1: return -1; } return 0; } /*}}}*/ /* blink the matching fence. This assumes that the window is ok */ void blink_match (void) /*{{{*/ { Line *save; int pnt, code, matchp; unsigned int l; char buf[600], strbuf[256]; if (!Blink_Flag || (Repeat_Factor != NULL) || Batch) return; if (JWindow->trashed) update((Line *) NULL, 0, 0, 0); if (JWindow->trashed) return; pnt = Point; save = CLine; l = LineNum; if (Point) Point--; code = backward_goto_match (1000, 0); if (code == 0) { if ((! (CBuf->modes == WRAP_MODE)) && (!IN_MINI_WINDOW)) message("Mismatch??"); } else if ((code == 1) && is_line_visible (LineNum)) { point_cursor(0); input_pending(&Number_Ten); Point = pnt; CLine = save; LineNum = l; point_cursor(0); return; } else if (code == 1) { unsigned int len; matchp = Point; bol (); strcpy(buf, "Matches "); (void) jed_skip_whitespace(); if ((matchp == Point) && jed_up(1)) { bol (); safe_strcat (buf, make_line_string(strbuf, sizeof(strbuf)), sizeof (buf)); jed_down(1); } safe_strcat(buf, make_line_string(strbuf, sizeof (strbuf)), sizeof(buf)); /* Apparantly there are some who think that it is a bug to see * ^J in the mini-buffer. Sigh. */ len = strlen (buf); if (len && (buf[len - 1] == '\n')) buf[len - 1] = 0; message(buf); } Point = pnt; CLine = save; LineNum = l; } /*}}}*/ Syntax_Table_Type *jed_find_syntax_table (char *name, int err) /*{{{*/ { Syntax_Table_Type *table = Syntax_Tables; while (table != NULL) { if (!strcmp (table->name, name)) return table; table = table->next; } if (err) msg_error ("Syntax table undefined."); return table; } /*}}}*/ static void set_syntax_flags (char *name, int *flags) /*{{{*/ { Syntax_Table_Type *table; table = jed_find_syntax_table (name, 1); if (table == NULL) return; table->flags |= *flags & 0xFF; } /*}}}*/ /* UTF-8 WORD UNsafe */ static void define_syntax (int *what, char *name) /*{{{*/ { Syntax_Table_Type *table; int c2; unsigned int i; char *s1 = NULL, *s2 = NULL; unsigned char lut[256], *s; table = jed_find_syntax_table (name, 1); if (table == NULL) return; switch (*what) { case '%': if (SLang_pop_slstring (&s2)) break; if (SLang_pop_slstring (&s1)) break; table->char_syntax[(unsigned char) *s1] |= COMMENT_SYNTAX; if ((*s2 == 0) || (*s2 == '\n')) { SLang_free_slstring (s2); i = table->num_eol_comments; if (i == MAX_EOL_COMMENTS) { SLang_free_slstring (s1); return; } table->eol_comment_starts[i] = s1; table->eol_comment_lens[i] = strlen (s1); table->num_eol_comments = i + 1; return; } table->char_syntax[(unsigned char) *s2] |= COMMENT_SYNTAX; SLang_free_slstring (table->comment_start); SLang_free_slstring (table->comment_stop); table->comment_start = s1; table->comment_stop = s2; table->comment_start_len = strlen (s1); table->comment_stop_len = strlen (s2); return; case '\\': if (SLang_pop_integer (&c2)) break; table->char_syntax[(unsigned char) c2] |= QUOTE_SYNTAX; table->quote_char = (unsigned char) c2; break; case '#': if (SLang_pop_integer (&c2)) break; table->preprocess = (unsigned char) c2; break; case '\'': if (SLang_pop_integer (&c2)) break; table->char_syntax[(unsigned char) c2] |= STRING_SYNTAX; table->char_char = (unsigned char) c2; break; case '"': if (SLang_pop_integer (&c2)) break; if (table->num_string_chars == MAX_STRING_CHARS) break; table->char_syntax[(unsigned char) c2] |= STRING_SYNTAX; table->string_chars[table->num_string_chars++] = (unsigned char) c2; break; case '<': case '>': if (SLang_pop_slstring (&s1)) break; s2 = s1; while (*s2 != 0) { if (*(s2 + 1) == 0) break; table->char_syntax[(unsigned char) *s2] |= HTML_START_SYNTAX; table->char_syntax[(unsigned char) *(s2 + 1)] |= HTML_END_SYNTAX; s2 += 2; } table->sgml_start_char = *s1; if (*s1 != 0) table->sgml_stop_char = s1[1]; else table->sgml_stop_char = 0; s2 = NULL; break; case '(': case ')': if (SLang_pop_slstring (&s2)) break; if (SLang_pop_slstring (&s1)) break; i = strlen (s1); if (i != strlen (s2)) { msg_error ("Delimiter set does not match."); } while (i > 0) { unsigned char ch1, ch2; i--; ch1 = (unsigned char) s1[i]; ch2 = (unsigned char) s2[i]; table->char_syntax[ch1] |= OPEN_DELIM_SYNTAX; table->char_syntax[ch2] |= CLOSE_DELIM_SYNTAX; table->matching_delim[ch2] = ch1; table->matching_delim[ch1] = ch2; } break; case '+': if (SLang_pop_slstring (&s1)) break; for (i = 0; i < 256; i++) table->char_syntax[i] &= ~OP_SYNTAX; s = (unsigned char *) s1; while (*s) { table->char_syntax[*s] |= OP_SYNTAX; s++; } break; case '0': if (SLang_pop_slstring (&s1)) break; SLmake_lut (lut, (unsigned char *) s1, 0); for (i = 0; i < 256; i++) { if (lut[i]) table->char_syntax[i] |= NUMBER_SYNTAX; else table->char_syntax[i] &= ~NUMBER_SYNTAX; } break; case ',': if (SLang_pop_slstring (&s1)) break; s = (unsigned char *) s1; for (i = 0; i < 256; i++) table->char_syntax[i] &= ~DELIM_SYNTAX; while (*s) { table->char_syntax[*s] |= DELIM_SYNTAX; s++; } break; case 'w': if (SLang_pop_slstring (&s1)) break; SLmake_lut (lut, (unsigned char *) s1, 0); for (i = 0; i < 256; i++) { if (lut[i]) table->char_syntax[i] |= WORD_SYNTAX; else table->char_syntax[i] &= ~WORD_SYNTAX; } break; default: msg_error ("Bad parameter to define_syntax"); } if (s1 != NULL) SLang_free_slstring (s1); if (s2 != NULL) SLang_free_slstring (s2); } /*}}}*/ static void set_fortran_comment_style (char *table_name, char *str) { Syntax_Table_Type *table; int reverse; if (NULL == (table = jed_find_syntax_table (table_name, 1))) return; reverse = 0; if ((*str == '^') && (str[1] != 0)) { str++; reverse = 1; } SLmake_lut(table->fortran_comment_chars, (unsigned char *) str, reverse); } static void use_syntax_table (char *s) /*{{{*/ { Syntax_Table_Type *table; if ((s == NULL) || (*s == 0)) { s = ""; table = Default_Syntax_Table; } else { table = jed_find_syntax_table (s, 1); if (table == NULL) return; } CBuf->syntax_table = table; (void) SLang_run_hooks ("use_syntax_table_hook", 1, s); } /*}}}*/ /* Clears everything except for the name, and links to other tables */ static void clear_syntax_table (Syntax_Table_Type *t) { unsigned int i; char *name; Syntax_Table_Type *next; for (i = 0; i < t->num_eol_comments; i++) SLang_free_slstring (t->eol_comment_starts[i]); SLang_free_slstring (t->comment_start); SLang_free_slstring (t->comment_stop); #if JED_HAS_DFA_SYNTAX if (t->init_dfa_callback != NULL) SLang_free_function (t->init_dfa_callback); if (t->hilite != NULL) jed_dfa_free_highlight_table (t->hilite); #endif for (i = 0; i < MAX_KEYWORD_TABLES; i++) { unsigned int j; for (j = 0; j < MAX_KEYWORD_LEN; j++) { char *kwds = t->keywords[i][j]; if (kwds != NULL) SLang_free_slstring (kwds); } } next = t->next; name = t->name; memset ((char *)t, 0, sizeof (Syntax_Table_Type)); t->next = next; t->name = name; } static Syntax_Table_Type *allocate_syntax_table (char *name) { Syntax_Table_Type *table; if (NULL == (table = (Syntax_Table_Type *) jed_malloc0 (sizeof (Syntax_Table_Type)))) return NULL; if (NULL == (name = SLang_create_slstring (name))) { SLfree ((char *) table); return NULL; } table->name = name; return table; } static void create_syntax_table (char *name) /*{{{*/ { Syntax_Table_Type *table; if (NULL != (table = jed_find_syntax_table (name, 0))) { clear_syntax_table (table); return; } if (NULL == (table = allocate_syntax_table (name))) return; table->next = Syntax_Tables; Syntax_Tables = table; } void init_syntax_tables (void) /*{{{*/ { unsigned short *a; unsigned char *m; Default_Syntax_Table = allocate_syntax_table ("DEFAULT"); if (Default_Syntax_Table == NULL) return; a = Default_Syntax_Table->char_syntax; m = Default_Syntax_Table->matching_delim; a [(unsigned char) '['] = OPEN_DELIM_SYNTAX; m[(unsigned char) '['] = ']'; a [(unsigned char) ']'] = CLOSE_DELIM_SYNTAX; m[(unsigned char) ']'] = '['; a [(unsigned char) '('] = OPEN_DELIM_SYNTAX; m[(unsigned char) '('] = ')'; a [(unsigned char) ')'] = CLOSE_DELIM_SYNTAX; m[(unsigned char) ')'] = '('; a [(unsigned char) '{'] = OPEN_DELIM_SYNTAX; m[(unsigned char) '{'] = '}'; a [(unsigned char) '}'] = CLOSE_DELIM_SYNTAX; m[(unsigned char) '}'] = '{'; } /*}}}*/ /* Currently this assumes byte-semantics. It should be changed to assume character * semantics. */ static void define_keywords (char *name, char *kwords, int *lenp, int *tbl_nump) /*{{{*/ { char *kw; int len; int kwlen; unsigned int table_number = (unsigned int) *tbl_nump; Syntax_Table_Type *table = jed_find_syntax_table (name, 1); if (table == NULL) return; if (table_number >= MAX_KEYWORD_TABLES) { msg_error ("Table number too high."); return; } len = *lenp; if ((len < 1) || (len > MAX_KEYWORD_LEN)) { msg_error ("Keyword length not supported."); return; } kwlen = strlen (kwords); if (kwlen % len) { msg_error ("Keyword list is improperly formed."); return; } len--; kw = table->keywords[table_number][len]; if (kw == NULL) SLang_push_string (""); else { SLang_push_string (kw); SLang_free_slstring (kw); } table->keywords[table_number][len] = SLang_create_slstring (kwords); } /*}}}*/ #if JED_HAS_LINE_ATTRIBUTES static void syntax_parse_lines (Syntax_Table_Type *table, Line *l, unsigned int num) { int state; if (l == NULL) return; if (l->prev != NULL) { l = l->prev; num++; } while (1) { state = parse_to_point1 (table, l, l->data + l->len); if (state == JED_LINE_HAS_EOL_COMMENT) { l->flags |= state; state = 0; } if (((state == JED_LINE_IN_STRING0) || (state == JED_LINE_IN_STRING1)) && (table->flags & SINGLE_LINE_STRINGS)) state = 0; l = l->next; if (l == NULL) break; if (num == 0) { if (state == (int) (l->flags & JED_LINE_SYNTAX_BITS)) return; } else num--; l->flags &= ~JED_LINE_SYNTAX_BITS; l->flags |= state; } } void jed_syntax_parse_buffer (int do_all) { unsigned int min_line_num; unsigned int max_line_num; int n; int is_narrow; Line *l; Syntax_Table_Type *table; unsigned int undo_bit = 0; SLang_Name_Type *color_region_hook = NULL; if (CBuf->buffer_hooks != NULL) color_region_hook = CBuf->buffer_hooks->color_region_hook; table = CBuf->syntax_table; if ((table == NULL) && (color_region_hook == NULL)) { CBuf->min_unparsed_line_num = 0; CBuf->max_unparsed_line_num = 0; return; } min_line_num = CBuf->min_unparsed_line_num; max_line_num = CBuf->max_unparsed_line_num; if (min_line_num == 0) { if (do_all) return; } is_narrow = (CBuf->narrow != NULL); if (is_narrow) { /* yuk--- a major hack: turn off undo temporally */ undo_bit = CBuf->flags & UNDO_ENABLED; CBuf->flags &= ~UNDO_ENABLED; jed_push_narrow (); jed_widen_whole_buffer (CBuf); } CBuf->beg->flags &= ~JED_LINE_SYNTAX_BITS; /* 0.99-17.98 */ if (do_all) { min_line_num = 1; max_line_num = Max_LineNum; } if (color_region_hook != NULL) { (void) SLang_start_arg_list (); if ((0 == SLang_push_integer ((int) min_line_num)) && (0 == SLang_push_integer ((int) max_line_num)) && (0 == SLang_end_arg_list ())) { if (-1 == SLexecute_function (color_region_hook)) CBuf->buffer_hooks->color_region_hook = NULL; } } else { n = (int) min_line_num; push_spot (); goto_line (&n); l = CLine; pop_spot (); syntax_parse_lines (table, l, 1 + (unsigned int) (max_line_num - min_line_num)); } if (is_narrow) { jed_pop_narrow (); CBuf->flags |= undo_bit; /* hack */ } CBuf->min_unparsed_line_num = CBuf->max_unparsed_line_num = 0; } #endif static char *what_syntax_table (void) { Syntax_Table_Type *s; if ((NULL == (s = CBuf->syntax_table)) && (NULL == (s = Default_Syntax_Table))) return NULL; return s->name; /* not thread safe */ } static SLang_Intrin_Fun_Type Intrinsics [] = { MAKE_INTRINSIC("parse_to_point", parse_to_point, INT_TYPE, 0), MAKE_INTRINSIC_SI("set_syntax_flags", set_syntax_flags, VOID_TYPE), MAKE_INTRINSIC_IS("define_syntax", define_syntax, VOID_TYPE), MAKE_INTRINSIC_S("use_syntax_table", use_syntax_table, VOID_TYPE), MAKE_INTRINSIC_0("what_syntax_table", what_syntax_table, STRING_TYPE), MAKE_INTRINSIC_S("create_syntax_table", create_syntax_table, VOID_TYPE), MAKE_INTRINSIC_4("define_keywords_n", define_keywords, VOID_TYPE, STRING_TYPE, STRING_TYPE, INT_TYPE, INT_TYPE), MAKE_INTRINSIC_SS("set_fortran_comment_chars", set_fortran_comment_style, SLANG_VOID_TYPE), MAKE_INTRINSIC_I("find_matching_delimiter", find_matching_delimiter, INT_TYPE), SLANG_END_INTRIN_FUN_TABLE }; int jed_init_syntax (void) { #if JED_HAS_DFA_SYNTAX if (-1 == jed_init_dfa_syntax ()) return -1; #endif return SLadd_intrin_fun_table (Intrinsics, NULL); } jed-0.99-19/src/gtkwin.c0000644002657400265740000004043311311317447013734 0ustar davisdavis/* -*- mode: C; mode: fold; -*- */ /* Copyright (c) 1992, 1998, 2000, 2002, 2003, 2004, 2005, 2006 John E. Davis * This file is part of JED editor library source. * * You may distribute this file under the terms the GNU General Public * License. See the file COPYING for more information. */ #define _BUILD_GTK_JED #include "config.h" #include "jed-feat.h" /*{{{ Include Files */ #include #include #include "buffer.h" #include "window.h" #include "screen.h" #include "misc.h" #include "ledit.h" #include "sysdep.h" #include "display.h" #include "paste.h" #include "gtkjed.h" /*}}}*/ /* window.c will call these callback functions. They need to be mapped onto * the appropriate combination of functions in gtkterm.c */ int (*jed_new_window_cb) (Window_Type *) = NULL; void (*jed_free_window_cb) (Window_Type *) = NULL; int (*jed_create_mini_window_cb) (Window_Type *) = jgtk_createEditorMiniWin; int (*jed_leave_window_cb) (Window_Type *) = NULL; int (*jed_enter_window_cb) (Window_Type *) = NULL; int (*jed_split_window_cb) (Window_Type *, Window_Type *) = NULL; int (*jed_window_geom_change_cb) (void) = NULL; #if 0 /* These rest of the file commented out */ Window_Type *JWindow; int Top_Window_SY = 1; /************************************ * create_window * * debug print: * ************************************/ Window_Type * create_window( int sy, int sx, int rows, int col, int width ) /*{{{*/ { Window_Type *w; if (NULL == (w = (Window_Type *) jed_malloc0 (sizeof(Window_Type)))) { exit_error("create_window: malloc error.", 0); } if (sy < 0) sy = 0; if (sx < 0) sx = 0; w->sx = sx; w->sy = sy; if (rows < 1) rows = 1; w->rows = rows; if (width < 1) width = 1; w->width = width; w->hscroll_column = col; createEditorMiniWin( w ); return(w); } /************************************ * createGJedwindow * * debug print: * ************************************/ static Window_Type * createGJedWindow(int sy, int sx, int rows, int col, int width) /*{{{*/ { Window_Type *w; if (NULL == (w = (Window_Type *) jed_malloc0 (sizeof(Window_Type)))) { exit_error("create_window: malloc error.", 0); } if (sy < 0) sy = 0; if (sx < 0) sx = 0; w->sx = sx; w->sy = sy; if (rows < 1) rows = 1; w->rows = rows; if (width < 1) width = 1; w->width = width; w->hscroll_column = col; return(w); } /*}}}*/ /************************************ * free_window * * debug print: * ************************************/ static void free_window (Window_Type *w) { if (w == NULL) return; if (Mini_Info.action_window == w) Mini_Info.action_window = NULL; SLfree ((char *) w); } /************************************ * window_buffer * * debug print: * ************************************/ void window_buffer(Buffer *b) /*{{{*/ { if (JWindow == NULL) { JWindow = createGJedWindow( Top_Window_SY, 0, Jed_Num_Screen_Rows - 2 - Top_Window_SY, 1, Jed_Num_Screen_Cols); JWindow->next = JWindow; createTopEdWin( JWindow, Top_Window_SY, 0, Jed_Num_Screen_Rows - 2 - Top_Window_SY, 1, Jed_Num_Screen_Cols ); } touch_window(); jed_init_mark_for_buffer (&JWindow->beg, b, 0); jed_init_mark_for_buffer (&JWindow->mark, b, 0); JWindow->hscroll_column = 1; JWindow->buffer = b; JWindow->trashed = 1; } /*}}}*/ #if JED_HAS_SUBPROCESSES /************************************ * move_window_marks * * debug print: "All: %d\n", all * ************************************/ void move_window_marks (int all) /*{{{*/ { Window_Type *w = JWindow; if (w == NULL) return; do { if (w->buffer == CBuf) { jed_init_mark (&w->mark, 0); if (all == 0) break; } w = w->next; } while (w != JWindow); } /*}}}*/ #endif /************************************ * other_window * * debug print: * ************************************/ int other_window() /*{{{*/ { switch_to_buffer( JWindow->buffer ); jed_init_mark( &JWindow->mark, 0 ); updateScrollbar( JWindow ); JWindow = JWindow->next; switch_to_buffer( JWindow->buffer ); if ( JWindow->mark.line != NULL ) ( void ) jed_goto_mark( &JWindow->mark ); /* updateScrollbar( JWindow ); */ return 1; } /*}}}*/ /************************************ * split_window * * debug print: * ************************************/ int split_window (void) /*{{{*/ { int n, sy, width, row; Window_Type *w, *neew, *tmpWin; /* Line *l, cline; */ if (JWindow->rows < 5) { msg_error("Window too small."); return(0); } switch_to_buffer(JWindow->buffer); n = JWindow->rows / 2; sy = JWindow->sy + n + 1; width = JWindow->width; n = JWindow->rows - n - 1; JWindow->rows = JWindow->rows / 2; #if 0 /* l = find_top (); */ l = jed_find_top_to_recenter (CLine); if (l == NULL) l = CLine; (void) jed_init_mark_for_line (&JWindow->beg, l, 0); #else jed_init_mark (&JWindow->beg, 0); #endif w = JWindow->next; JWindow->next = neew = createGJedWindow( sy, JWindow->sx, n, JWindow->hscroll_column, width ); neew->next = w; neew->buffer = CBuf; jed_init_mark (&neew->mark, 0); jed_copy_mark (&neew->beg, &JWindow->beg); tmpWin = JWindow; /* splitEdWin( JWindow, neew, sy, JWindow->sx, n, JWindow->hscroll_column, width ); */ n = JWindow->sy; other_window(); touch_window(); if (-1 != (row = jed_find_line_on_screen (CLine, n))) { row += 1; w = JWindow; do { if ((JWindow->buffer == CBuf) && (JWindow->sy < row) && (JWindow->sy + JWindow->rows >= row)) break; other_window(); } while (w != JWindow); } splitEdWin( tmpWin, neew, sy, tmpWin->sx, neew->rows, tmpWin->hscroll_column, width ); /* printWinList(); */ return 1; } /*}}}*/ /************************************ * one_window * * debug print: * ************************************/ int one_window( void ) /*{{{*/ { Window_Type *w, *next, *mini; Buffer *b; mini = NULL; if ( JWindow->sy + 1 == Jed_Num_Screen_Rows ) return(0); /* mini-buffer */ w = JWindow->next; b = JWindow->buffer; while( w != JWindow ) { next = w->next; if (w != The_MiniWindow) { if ( w->buffer != b ) touch_window_hard( w, 0 ); free_window (w); } else mini = w; w = next; } if (mini == NULL) mini = JWindow; JWindow->next = mini; mini->next = JWindow; updOWEdWin( w, Top_Window_SY, 0, Jed_Num_Screen_Rows - 2 - Top_Window_SY, Jed_Num_Screen_Cols ); JWindow->sy = Top_Window_SY; JWindow->sx = 0; JWindow->width = Jed_Num_Screen_Cols; JWindow->rows = Jed_Num_Screen_Rows - 2 - Top_Window_SY; /********** printf( "1 (oneWindow): vvvvvv---------------------------------------vvvvvv\n" ); printWidgetWinXRef(); printSubWins(); printf( "1:(oneWindow): ^^^^^^---------------------------------------^^^^^^\n" ); ***********/ touch_window(); return(1); } /*}}}*/ /************************************ * enlarge_window * * debug print: * ************************************/ int enlarge_window() /*{{{*/ { Window_Type *w, *w1; int min = 2; if (JWindow == The_MiniWindow) return(0); /* if (IN_MINI_WINDOW) Return(0); */ if (JWindow == JWindow->next) return(0); w = JWindow->next; while(w->rows <= min) w = w->next; if (w == JWindow) return(0); if (w->sy < JWindow->sy) { w->rows -= 1; JWindow->rows += 1; do { updEdWidgetWinXRef( w, w->sy + w->rows, 1 ); /* updEdWidgetWinXRef( w, w->sy + w->rows - 1, 1 ); */ w = w->next; w->sy -= 1; updEdWidgetWinXRef( w, w->sy, 1 ); } while (w != JWindow); } else { JWindow->rows += 1; w1 = JWindow; while(w1 != w) { updEdWidgetWinXRef( w1, w1->sy + w1->rows, 1 ); updEdWidgetWinXRef( w1, w1->sy + w1->rows - 1, 1 ); w1 = w1->next; w1->sy += 1; } w->rows -= 1; } jGtkSetWinSizes(); w = JWindow; do { touch_window(); JWindow = JWindow->next; } while (w != JWindow); return(1); } /*}}}*/ /************************************ * adjust_windows * Search for the last window, the bottom window. * Check whether num of rows > 1 * if not delete all but one window * * debug print: "Height: %d\n", height * ************************************/ static void adjust_windows( int height ) /*{{{*/ { Window_Type *w = JWindow; int rows; do { /* printf( "Win(w): %x, w->rows: %d, w->sy: %d, Jed_Num_Screen_Rows: %d\n", */ /* w, w->rows, w->sy, Jed_Num_Screen_Rows ); */ if (w->rows + w->sy + 2 == Jed_Num_Screen_Rows) { /* printf( "Win(w): %x, w->rows: %d, w->sy: %d, Jed_Num_Screen_Rows: %d\n", */ /* w, w->rows, w->sy, Jed_Num_Screen_Rows ); */ /* Db; */ /* bottom window */ rows = height - 2 - w->sy; if ( rows > 1 ) { /* if ( rows > w->rows ) */ /* { */ /* carryForwGtkWidgetWinXRefLines( w, w->rows + w->sy, w->sx, rows - w->rows, w->col ); */ /* } */ /* Update miniwindow in widgetWinXRef */ updMiniWinWidgetWinXRef( height - 1 ); if ( rows > w->rows ) updEdWidgetWinXRef( w, w->sy + w->rows + 1, rows - w->rows ); w->rows = rows; return; } /* Db; */ while( JWindow->sy != Top_Window_SY ) other_window(); one_window(); /* Adjust Height done in one window???!! */ JWindow->rows = height - 2 - Top_Window_SY; if (JWindow->rows < 1) JWindow->rows = 1; return; } /* Dbp( "w: %x\n", w ); */ w = w->next; /* Dbp( "w: %x\n", w ); */ } while (w != JWindow); /* not reached! */ } /*}}}*/ /************************************ * jed_update_window_sizes * * Jed_Num_Screen_Rows and Jed_Num_Screen_Cols still old values * * debug print: "Heigth: %d, Width: %d\n", height, width * ************************************/ void jed_update_window_sizes( int height, int width ) /*{{{*/ { Window_Type *w; /************ printf( "1 (jed_update_window_sizes): vvvvvv---------------------------------------vvvvvv\n" ); printWidgetWinXRef(); printSubWins(); printf( "1:(jed_update_window_sizes): ^^^^^^---------------------------------------^^^^^^\n" ); **************/ if ( JWindow == NULL ) return; if ( height < 5 ) height = 5; if ( width < 5 ) width = 5; jGtkCheckEdSize( height, width ); if ( height != Jed_Num_Screen_Rows ) adjust_windows( height ); /* jedGtkUpdateEdSize( height, width ); */ if ( width > JWindow->width ) { jGtkWidenEd( height, width, JWindow->width ); } w = JWindow; do { JWindow->trashed = 1; JWindow->width = width; JWindow = JWindow->next; } while ( w != JWindow ); if ( The_MiniWindow != NULL ) { /* jedGtkUpdateMiniWinSizeLoc( The_MiniWindow, height - 1, width ); */ The_MiniWindow->sy = height - 1; The_MiniWindow->width = width; } } /*}}}*/ /************************************ * buffer_visible * * debug print: * ************************************/ int buffer_visible(Buffer *b) /*{{{*/ { Window_Type *w = JWindow; int n; if ((b == NULL) || (w == NULL)) return 0; n = 0; do { if (w->buffer == b) n++; w = w->next; } while (w != JWindow); return n; } /*}}}*/ /************************************ * delete_window * * debug print: * ************************************/ int delete_window (void) /*{{{*/ { Window_Type *tthis, *prev, *next; int nr1; tthis = JWindow; next = tthis->next; if ((MiniBuffer_Active && ((tthis == The_MiniWindow) || (tthis == next->next))) || (tthis == next)) return(0); nr1 = tthis->sy + tthis->rows + 2; if (nr1 != Jed_Num_Screen_Rows) { while (JWindow->sy + 1 != nr1) other_window(); JWindow->sy = tthis->sy; } else { while(JWindow->sy + JWindow->rows + 1 != tthis->sy) other_window(); } JWindow->rows += tthis->rows + 1; touch_window(); prev = next; while(prev->next != tthis) prev = prev->next; prev->next = next; delEdWin( tthis, JWindow, tthis->sy, tthis->sx, tthis->rows, tthis->width, nr1 == Jed_Num_Screen_Rows ? JWindow->sy + JWindow->rows : tthis->sy + tthis->rows ); free_window (tthis); return(1); } /*}}}*/ /************************************ * touch_screen_for_buffer * * debug print: * ************************************/ void touch_screen_for_buffer(Buffer *b) /*{{{*/ { Window_Type *w; w = JWindow; do { if ( w->buffer == b ) { touch_window_hard( w, 0 ); } w = w->next; } while ( w != JWindow ); } /*}}}*/ /************************************ * is_line_visible * * debug print: * ************************************/ int is_line_visible (int lnum) /*{{{*/ { int n = JWindow->rows; Line *l, *beg = JWindow->beg.line; push_spot (); goto_line (&lnum); l = CLine; pop_spot (); #if JED_HAS_LINE_ATTRIBUTES if (l->flags & JED_LINE_HIDDEN) return 0; #endif while (n && (beg != NULL)) { if (l == beg) return 1; #if JED_HAS_LINE_ATTRIBUTES if (0 == (beg->flags & JED_LINE_HIDDEN)) #endif n--; beg = beg->next; } return 0; } /*}}}*/ /************************************ * jed_num_windows * * debug print: * ************************************/ int jed_num_windows (void) { Window_Type *w = JWindow; int n = 0; do { n++; w = w->next; } while (w != JWindow); return n; } /************************************ * jed_set_scroll_column * * debug print: * ************************************/ void jed_set_scroll_column (int sc) { if (sc < 1) sc = 1; JWindow->hscroll_column = sc; touch_window(); } /************************************ * jed_scroll_right * * debug print: * ************************************/ void jed_scroll_right (int dn) { jed_set_scroll_column (JWindow->hscroll_column - dn); } /************************************ * jed_scroll_left * * debug print: * ************************************/ void jed_scroll_left (int dn) { jed_set_scroll_column (JWindow->hscroll_column + dn); } /************************************ * jed_get_scroll_column * * debug print: * ************************************/ int jed_get_scroll_column (void) { return JWindow->hscroll_column; } /************************************ * set_scroll_column_intrin * * debug print: * ************************************/ static void set_scroll_column_intrin (int *sc) { jed_set_scroll_column (*sc); } /************************************ * window_info_intrin * * debug print: * ************************************/ static int window_info_intrin(int *what) { register int n = 0; switch (*what) { case 'x': n = JWindow->sx; break; case 'y': n = JWindow->sy; break; case 'r': n = JWindow->rows; break; case 'c': n = JWindow->hscroll_column; break; case 't': n = JWindow->sy + 1; break; case 'w': n = JWindow->width; break; default: SLang_set_error (SL_INVALID_PARM); } return (n); } /************************************ * printWinList * * debug print: * ************************************/ int printWinList(void) { int i = 0; Window_Type *w = JWindow; printf( "Window List: \n" ); do { ++i; printf( "I: %3d, Sx: %4d, Sy: %4d, Rows: %4d, Colums: %4d\n", i, w->sx, w->sy, w->rows, w->width ); w = w->next; } while ( w != JWindow ); return( 1 ); } static SLang_Intrin_Fun_Type Window_Intrinsics [] = { MAKE_INTRINSIC_0("printWinList", printWinList, SLANG_VOID_TYPE), MAKE_INTRINSIC_0("enlargewin", enlarge_window, SLANG_VOID_TYPE), MAKE_INTRINSIC_0("splitwindow", split_window, SLANG_VOID_TYPE), MAKE_INTRINSIC_0("window_line", window_line, INT_TYPE), MAKE_INTRINSIC_0("nwindows", jed_num_windows, SLANG_INT_TYPE), MAKE_INTRINSIC_0("otherwindow", other_window, SLANG_VOID_TYPE), MAKE_INTRINSIC_0("onewindow", one_window, SLANG_VOID_TYPE), MAKE_INTRINSIC_I("window_info", window_info_intrin, SLANG_INT_TYPE), MAKE_INTRINSIC_I("set_scroll_column", set_scroll_column_intrin, SLANG_VOID_TYPE), MAKE_INTRINSIC_0("get_scroll_column", jed_get_scroll_column, SLANG_INT_TYPE), SLANG_END_INTRIN_FUN_TABLE }; /************************************ * jed_init_window_intrinsics * * debug print: * ************************************/ int jed_init_window_intrinsics (void) { if (-1 == SLadd_intrin_fun_table (Window_Intrinsics, NULL)) return -1; return 0; } #endif /* REST of FILE */ jed-0.99-19/src/vms.c0000644002657400265740000006135311311317447013242 0ustar davisdavis/* -*- mode: C; mode: fold; -*- */ /* Copyright (c) 1992, 1998, 2000, 2002, 2003, 2004, 2005, 2006 John E. Davis * This file is part of JED editor library source. * * You may distribute this file under the terms the GNU General Public * License. See the file COPYING for more information. */ #include "config.h" #include "jed-feat.h" #include #include #include "sysdep.h" #include #include #include #include #include #include #include #include #include #include #ifdef __DECC #include #include #include #include #endif #if (__VMS_VER >= 70000000) # include #endif /* #include */ typedef struct { /* I/O status block */ short i_cond; /* Condition value */ short i_xfer; /* Transfer count */ long i_info; /* Device information */ } Iosb_Type; typedef struct { /* Terminal characteristics */ char t_class; /* Terminal class */ char t_type; /* Terminal type */ short t_width; /* Terminal width in characters */ long t_mandl; /* Terminal's mode and length */ long t_extend; /* Extended terminal characteristics */ } TermChar_Type; TermChar_Type Old_Term_Char, New_Term_Char; /* This serves to identify the channel we are reading input from. */ static short This_Term; typedef struct /*{{{*/ { short buflen; short item_code; int *buf_addr; int *len_addr; } /*}}}*/ item_list_3; static int TTY_Inited; void vms_exit_handler(int not_used) /*{{{*/ { if (TTY_Inited == 0) exit(0); auto_save_all(); jed_reset_display(); reset_tty(); exit(1); } /*}}}*/ /* * Exit Handler Control Block */ static struct argument_block { int forward_link; int (*exit_routine)(); int arg_count; int *status_address; int exit_status; } exit_block = { 0, NULL, 1, &exit_block.exit_status, 0 }; void vms_cancel_exithandler() /*{{{*/ { sys$canexh(exit_block); } /*}}}*/ #undef USING_INPUT_BUFFER #undef DONE_WITH_INPUT_BUFFER int vms_input_buffer; static struct vms_ast_iosb /*{{{*/ { short status; short offset; short termlen; short term; } vms_ast_iosb; /*}}}*/ extern void vms_que_key_ast(); static int Ast_Fired_Event_Flag; static int Timer_Event_Flag; static int Event_Flag_Mask; static int Ast_Stop_Input; static int Waiting_For_Ast; static int Using_Keyboard_Buffer_Event_Flag; #define USING_INPUT_BUFFER\ sys$setast(0); #define DONE_WITH_INPUT_BUFFER\ sys$setast(1); static int getkey_ast(int not_used) /*{{{*/ { unsigned int c = 1000; if (vms_ast_iosb.offset) { c = (unsigned int) vms_input_buffer; } if (c <= 255) { if (c == (unsigned int) Jed_Abort_Char) { if (Ignore_User_Abort == 0) SLang_set_error (SL_USER_BREAK); SLKeyBoard_Quit = 1; } USING_INPUT_BUFFER if (Input_Buffer_Len < MAX_INPUT_BUFFER_LEN - 3) Input_Buffer[Input_Buffer_Len++] = c; DONE_WITH_INPUT_BUFFER } if (Waiting_For_Ast) sys$setef (Ast_Fired_Event_Flag); Waiting_For_Ast = 0; vms_que_key_ast(); return (1); } /*}}}*/ void vms_que_key_ast() /*{{{*/ { static int trmmsk [2] = { 0, 0 }; int status; if (Ast_Stop_Input) return; status = sys$qio (0, This_Term, IO$_READVBLK | IO$M_NOECHO | IO$_TTYREADALL, &vms_ast_iosb, getkey_ast, 1, &vms_input_buffer, 1, 0, trmmsk, 0, 0); } /*}}}*/ static char TTY_Name[8]; static int This_Process_Pid; int init_tty() /*{{{*/ { Iosb_Type iostatus; int tmp, name_len, status, lastppid, ppid; item_list_3 itmlst[3]; $DESCRIPTOR ( term, TTY_Name); itmlst[0].buflen = sizeof(int); itmlst[0].item_code = JPI$_PID; itmlst[0].buf_addr = &This_Process_Pid; itmlst[0].len_addr = &tmp; itmlst[1].buflen = 7; itmlst[1].item_code = JPI$_TERMINAL; itmlst[1].buf_addr = (int *) TTY_Name; itmlst[1].len_addr = &name_len; itmlst[2].buflen = 0; itmlst[2].item_code = 0; itmlst[2].buf_addr = 0; itmlst[2].len_addr = 0; TTY_Inited = 1; ppid = 0, lastppid = -1; /* Here I get this process pid then I get the master process pid and use the controlling terminal of that process. */ while (1) { status = sys$getjpiw(0, /* event flag */ &ppid, /* pid address */ 0, /* proc name address */ itmlst, 0, 0, 0); if (status != SS$_NORMAL) { fprintf(stderr, "PID: %X, status: %X\n", This_Process_Pid, status); return -1; } if (lastppid == ppid) break; lastppid = ppid; itmlst[0].item_code = JPI$_MASTER_PID; itmlst[0].buf_addr = &ppid; } if (Batch) return 0; if (X_Init_Term_Hook != NULL) { (void) (*X_Init_Term_Hook) (); return 0; } term.dsc$w_length = name_len; status = sys$assign ( &term, &This_Term, 0, 0 ); if (status != SS$_NORMAL) { fprintf(stderr,"Unable to assign input channel\n"); fprintf(stderr,"PID: %X, DEV %s, status: %d\n", This_Process_Pid, TTY_Name, status); return -1; } if (NULL == exit_block.exit_routine) { exit_block.exit_routine = (int (*)()) vms_exit_handler; sys$dclexh(&exit_block); } /* allocate an event flag and clear it--- used by ast routines. Since * I am only using a few local event flags, there is really no need to * worry about freeing these. * * The event flags are used to avoid timing problems with the getkey AST * as well as for a form of time out. */ if (!Ast_Fired_Event_Flag) lib$get_ef (&Ast_Fired_Event_Flag); sys$clref (Ast_Fired_Event_Flag); if (!Timer_Event_Flag) lib$get_ef (&Timer_Event_Flag); sys$clref (Timer_Event_Flag); /* When no thread is using the keyboard buffer, this ev is set. It * gets cleared when the buffer is in use. */ if (!Using_Keyboard_Buffer_Event_Flag) lib$get_ef (&Using_Keyboard_Buffer_Event_Flag); sys$setef (Using_Keyboard_Buffer_Event_Flag); /* The working assumption here is that the event flags are in the same * cluster. They need not be but it is very likely that they are. */ Event_Flag_Mask = ((unsigned) 1 << (Ast_Fired_Event_Flag % 32)); Event_Flag_Mask |= ((unsigned) 1 << (Timer_Event_Flag % 32)); Waiting_For_Ast = 0; Ast_Stop_Input = 0; /* Get the startup terminal characteristics */ status = sys$qiow(0, /* Wait on event flag zero */ This_Term, /* Channel to input terminal */ IO$_SENSEMODE, /* Get current characteristic */ &iostatus, /* Status after operation */ 0, 0, /* No AST service */ &Old_Term_Char, /* Terminal characteristics buf */ sizeof(Old_Term_Char),/* Size of the buffer */ 0, 0, 0, 0); New_Term_Char = Old_Term_Char; New_Term_Char.t_mandl |= TT$M_EIGHTBIT | TT$M_NOECHO; New_Term_Char.t_extend |= TT2$M_PASTHRU | TT2$M_XON; status = sys$qiow(0, /* Wait on event flag zero */ This_Term, /* Channel to input terminal */ IO$_SETMODE, /* Set current characteristic */ &iostatus, /* Status after operation */ 0, 0, /* No AST service */ &New_Term_Char, /* Terminal characteristics buf */ sizeof(New_Term_Char),/* Size of the buffer */ 0, 0, 0, 0); /* Enable the Application Keypad */ (*tt_write_string) ("\033=\033[?1l"); /* application keys/cursor keys */ vms_que_key_ast(); /* set up the key ast */ return 0; } /*}}}*/ static void cancel_ast (void) /*{{{*/ { if (TTY_Inited == 0) return; /* stop the keyboard ast */ sys$setast (0); /* disable AST delivery */ sys$clref (Ast_Fired_Event_Flag); Waiting_For_Ast = 1; Ast_Stop_Input = 1; /* cancel all i/o on this channel. This canels pending, as well as those * already in progress and queued. In particular, according to the * manuals, cancelling I/O on the channel will cause the getkey AST * to fire even though the SYS$QIO call was aborted. This is crucial * because below we wait for the AST to set the event flag. */ sys$cancel (This_Term); sys$setast (1); /* enable ASTs again */ sys$waitfr (Ast_Fired_Event_Flag); /* sleep until it fires */ Waiting_For_Ast = 0; } /*}}}*/ static int keypad_state = 0; void reset_tty() /*{{{*/ { Iosb_Type iostatus; if (Batch) return; if (!TTY_Inited) return; if (X_Init_Term_Hook != NULL) { if (X_Reset_Term_Hook != NULL) (*X_Reset_Term_Hook) (); TTY_Inited = 0; return; } cancel_ast (); TTY_Inited = 0; /* reset the terminal characteristics */ sys$qiow(0, /* event flag 0 */ This_Term, /* Channel to input terminal */ IO$_SETMODE, /* Set current characteristic */ &iostatus, /* Status after operation */ 0, 0, /* No AST service */ &Old_Term_Char, /* Terminal characteristics buf */ sizeof(Old_Term_Char), /* Size of the buffer */ 0, 0, 0, 0); /* unused */ if (keypad_state) SLtt_write_string("\033=\033[?1l"); else SLtt_write_string("\033>"); SLtt_flush_output (); } /*}}}*/ unsigned char sys_getkey() /*{{{*/ { unsigned char c; int tsecs; if (SLKeyBoard_Quit) return(Jed_Abort_Char); /* Under DECWIndows, I do not know how to timeout so this will have to do for now */ if (X_Read_Hook != NULL) return (c = X_Read_Hook ()); /* On VMS, the keyboard ast routine should be stuffing the buffer, so do nothing except sleep */ /* clear the flag which ast will set */ Waiting_For_Ast = 0; if (Input_Buffer_Len) return(my_getkey()); tsecs = 450; /* 45 seconds */ while (!sys_input_pending(&tsecs, 0)) { if (Jed_Sig_Exit_Fun != NULL) (*Jed_Sig_Exit_Fun) (); /* update status line incase user is displaying time */ if (Display_Time) { JWindow->trashed = 1; update((Line *) NULL, 0, 1, 0); } } c = my_getkey(); return(c); } /*}}}*/ /* waits *secs tenth of seconds for input */ int sys_input_pending(int *secs, int unused) /*{{{*/ { unsigned long daytim[2]; unsigned long EFstate; float delay = 0.1; if (Batch) return(0); if (Input_Buffer_Len) return(Input_Buffer_Len); if (X_Input_Pending_Hook != NULL) { if ((*X_Input_Pending_Hook) ()) return 1; if (*secs == 0) return 0; daytim[1] = 0xFFFFFFFF; daytim[0] = -(*secs * 1000 * 1000); /* 1000 * 1000 is a tenth of a sec */ sys$setimr(Timer_Event_Flag, daytim, 0, 1); /* Loop until a key is pressed or the timer event flag gets set */ while (1) { lib$wait(&delay); /* so we don't chew up so much cpu time */ if ((*X_Input_Pending_Hook) ()) { sys$cantim(1, 3); return 1; } else { if (sys$readef(Timer_Event_Flag, &EFstate) == SS$_WASSET) return 0; } } } if (*secs) { /* takes a quad word time. If negative, use a relative time. */ daytim[1] = 0xFFFFFFFF; daytim[0] = -(*secs * 1000 * 1000); /* 1000 * 1000 is a tenth of a sec */ sys$clref (Ast_Fired_Event_Flag); /* SYS$CLREF (Timer_Event_Flag); SYS$SETIMR call clears this */ /* set up a flag for the ast so it knows to set the event flag */ Waiting_For_Ast = 1; sys$setimr(Timer_Event_Flag, daytim, 0, 1); /* this will return when ast does its job or timer expires. * The first argument simply serves to identify the cluster for * the event flag and that is all. The second argument serves * to identify the event flags to wait for. */ sys$wflor (Ast_Fired_Event_Flag, Event_Flag_Mask); Waiting_For_Ast = 0; /* cancel the timer */ sys$cantim(1, 3); /* 3 is user mode */ } return (Input_Buffer_Len); } /*}}}*/ /* This is completely untested!! */ void sys_pause (int ms) /*{{{*/ { unsigned long daytim[2]; /* takes a quad word time. If negative, use a relative time. */ daytim[1] = 0xFFFFFFFF; daytim[0] = -(ms * 10 * 1000); /* 10 * 1000 is a milli sec */ sys$setimr(Timer_Event_Flag, daytim, 0, 1); /* cancel the timer */ sys$cantim(1, 3); /* 3 is user mode */ } /*}}}*/ #if 0 /* This is to get the size of the terminal */ int get_term_dimensions(int *cols, int *rows) /*{{{*/ { int status, junk; Iosb_Type iostatus; $DESCRIPTOR(devnam, TTY_Name); item_list_3 itmlst[4]; itmlst[0].buflen = sizeof (*rows); itmlst[0].item_code = DVI$_TT_PAGE; itmlst[0].buf_addr = rows; itmlst[0].len_addr = &junk; itmlst[1].buflen = sizeof(*cols); itmlst[1].item_code = DVI$_DEVBUFSIZ; itmlst[1].buf_addr = cols; itmlst[1].len_addr = &junk; itmlst[2].buflen = sizeof (keypad_state); itmlst[2].item_code = DVI$_TT_APP_KEYPAD; itmlst[2].buf_addr = &keypad_state; itmlst[2].len_addr = &junk; itmlst[3].buflen = 0; itmlst[3].item_code = 0; itmlst[3].buf_addr = 0; itmlst[3].len_addr = 0; if (*rows <= 0) *rows = Jed_Num_Screen_Rows; if (*cols <= 0) *cols = *tt_Screen_Cols; /* Get current terminal characteristics */ status = sys$getdviw(0, /* Wait on event flag zero */ 0, /* Channel to input terminal */ &devnam, /* device name */ &itmlst, /* Item descriptor List */ &iostatus, /* Status after operation */ 0, 0, /* No AST service */ 0); /* nullarg */ if (status&1) status = iostatus.i_cond; /* Jump out if bad status */ if ((status & 1) == 0) exit(status); return 0; } /*}}}*/ #endif /* returns 0 on failure, 1 on sucess */ int sys_delete_file(char *filename) /*{{{*/ { return (1 + delete(filename)); /* 0: sucess; -1 failure */ } /*}}}*/ /* This routine converts unix type names to vms names */ int locate(char ch, char *string) /*{{{*/ { int i; char c; i = 0; while (c = string[i++], (c != ch) && (c != '\0')); if (c == ch) return(i); else return (0); } /*}}}*/ char *unix2vms(char *file) /*{{{*/ { int i,device,j,first,last; static char vms_name[80]; char ch; if (locate('[',file)) return(file); /* vms_name syntax */ if (!locate('/',file)) return(file); /* vms_name syntax */ /* search for the ':' which means a device is present */ device = locate(':',file); i = 0; if (device) { while (ch = file[i], i < device) vms_name[i++] = ch; } j = i; /* go from the end looking for a '/' and mark it */ i = strlen(file) - 1; while(ch = file[i], ch != '/' && i-- >= 0); if (ch == '/') { file[i] = ']'; last = 0; } else last = 1; i = j; vms_name[j++] = '['; vms_name[j++] = '.'; first = 0; while(ch = file[i++], ch != '\0') { switch (ch) { case '.': if (last) vms_name[j++] = '.'; if (last) break; ch = file[i++]; if (ch == '.') { if (!first) j--; /* overwrite the dot */ vms_name[j++] = '-'; } else if (ch == '/'); /* './' combinations-- do nothing */ else if (ch == ']') { last = 1; if (vms_name[j-1] == '.') j--; vms_name[j++] = ']'; } else vms_name[j++] = '.'; break; case '/': if (first) { vms_name[j++] = '.'; } else { first = 1; /* if '/' is first char or follows a colon do nothing */ if ((i!=1) && (file[i-2] != ':')) { vms_name[j++] = '.'; } else j--; /* overwrite the '.' following '[' */ } break; case ']': last = 1; if (vms_name[j-1] == '.') j--; vms_name[j++] = ']'; break; default: vms_name[j++] = ch; } } return (vms_name); } /*}}}*/ void define_logical_name (char *varname, char *string) /*{{{*/ { struct dsc$descriptor_s strdsc, envdsc, lnmdsc; strdsc.dsc$w_length = strlen (string); strdsc.dsc$b_dtype = DSC$K_DTYPE_T; strdsc.dsc$b_class = DSC$K_CLASS_S; strdsc.dsc$a_pointer = string; envdsc.dsc$w_length = strlen (varname); envdsc.dsc$b_dtype = DSC$K_DTYPE_T; envdsc.dsc$b_class = DSC$K_CLASS_S; envdsc.dsc$a_pointer = varname; lnmdsc.dsc$w_length = 7; lnmdsc.dsc$b_dtype = DSC$K_DTYPE_T; lnmdsc.dsc$b_class = DSC$K_CLASS_S; lnmdsc.dsc$a_pointer = "LNM$JOB"; lib$set_logical (&envdsc, &strdsc, &lnmdsc, 0, 0); } /*}}}*/ void delete_logical_name (char *varname) /*{{{*/ { struct dsc$descriptor_s envdsc, lnmdsc; envdsc.dsc$w_length = strlen (varname); envdsc.dsc$b_dtype = DSC$K_DTYPE_T; envdsc.dsc$b_class = DSC$K_CLASS_S; envdsc.dsc$a_pointer = varname; lnmdsc.dsc$w_length = 7; lnmdsc.dsc$b_dtype = DSC$K_DTYPE_T; lnmdsc.dsc$b_class = DSC$K_CLASS_S; lnmdsc.dsc$a_pointer = "LNM$JOB"; lib$delete_logical (&envdsc, &lnmdsc); } /*}}}*/ int do_attach_cmd() /*{{{*/ { unsigned long pid; char *pidstr; if((pidstr = getenv("JED_ATTACH_TO")) != NULL) { delete_logical_name("JED_ATTACH_TO"); (void) sscanf(pidstr,"%X",&pid); if (lib$attach(&pid) == SS$_NORMAL) return(1); else return(0); } else return(0); } /*}}}*/ unsigned long SHELL_PID = 0; /* here we try to attach to the parent otherwise just spawn a new one */ void sys_suspend() /*{{{*/ { unsigned long parent_pid; unsigned long status = 0; cancel_ast (); parent_pid = getppid(); /* try to attach to different process */ if (do_attach_cmd()) status = SS$_NORMAL; else if (parent_pid && parent_pid != 0xffffffff) /* we attach to parent */ status = lib$attach(&parent_pid); else if (SHELL_PID && SHELL_PID != 0xffffffff) /* try to attach to previous shell */ status = lib$attach (&SHELL_PID); if (status != SS$_NORMAL) /* others fail so spawn a new shell */ { status = 0; SLtt_write_string("Spawning Subprocess...\n"); flush_output (); status = lib$spawn(0,0,0,0,0,&SHELL_PID,0); /* if we attach back, status may come back unchanged */ if (!(status & 1)) /* Thanks to Hunter Goatley for this suggestion */ { jed_verror ("Unable to spawn subprocess. Error = X%X (%d)", status, status); return; } } /* if((file = getenv("JED_FILE_NAME")) != NULL) { find_file_cmd(file); delete_logical_name ("JED_FILE_NAME"); } */ } /*}}}*/ /* returns 0 on success, -1 on syntax error -2 on bad dir, -3 on bad device, 1 if something else */ int vms_parse_file(char *old) /*{{{*/ { struct FAB fab = cc$rms_fab; struct NAM nam = cc$rms_nam; char neew[JED_MAX_PATH_LEN]; int status; fab.fab$l_fna = old; fab.fab$b_fns = strlen(old); fab.fab$b_dns = 0; fab.fab$w_ifi = 0; fab.fab$l_nam = &nam; nam.nam$l_esa = neew; nam.nam$b_ess = JED_MAX_PATH_LEN - 1; nam.nam$b_nop = NAM$V_SYNCHK; /* syntax only */ nam.nam$l_rlf = 0; status = sys$parse(&fab); neew[nam.nam$b_esl] = 0; strcpy(old, neew); while(*old != 0) { if ((*old == ';') && (*(old + 1) == 0)) *old = 0; else { if ((*old >= 'A') && (*old <= 'Z')) *old |= 0x20; old++; } } switch(status) { case RMS$_NORMAL: return 0; case RMS$_SYN: return -1; case RMS$_DNF: return -2; case RMS$_DEV: return -3; return 1; } } /*}}}*/ char *jed_standardize_filename_static(char *file) /*{{{*/ { char *p, *p1, *dir; static char work [1024]; int len; if (NULL != strstr (file, "::")) goto ugly; strcpy(work, jed_get_cwd()); strcat(work, file); file = work; /* start at end and look for ']' then look for ':' */ if (0 == (len = strlen(file))) return(file); p = file + (len - 1); while (p >= file) if (*p-- == ':') { while((p >= file) && (*p != ':') && (*p != ']')) p--; p++; p1 = file; while(*p) *p1++ = *p++; *p1 = 0; break; } dir = p = p1 = file; /* look for the start of the path */ while (*p != 0) { if (*p == ':') { p++; if (*p == ':') { p++; } dir = p; break; } if (*p == '[') { dir = p++; break; } p++; } p1 = p = dir; while (*p != 0) { if (*p == '[') { /* if (*(p + 1) == '-') */ p1 = dir; } if (p1 != p) *p1 = *p; p1++; p++; } *p1 = 0; ugly: switch(vms_parse_file(file)) { case 0: break; case -1: msg_error("Filename syntax error."); break; case -2: msg_error("Directory does not exist!"); msg_error (file); break; case -3: msg_error("Bad device name."); break; default: msg_error ("Unknown directory error:"); msg_error (file); } p = file; while(*p != 0) if (*p++ == ']') { if ((*p == '.') && (*(p + 1) == 0)) *p = 0; break; } return(file); } /*}}}*/ char *jed_standardize_filename (char *file) { return SLmake_string (jed_standardize_filename_static (file)); } char *jed_expand_filename (char *file) { return jed_standardize_filename (file); } int vms_expand_filename(char *file,char *expanded_file) /*{{{*/ { static int context = 0; static char inputname[JED_MAX_PATH_LEN] = ""; $DESCRIPTOR(file_desc,inputname); $DESCRIPTOR(default_dsc,"SYS$DISK:[]*.*;"); static struct dsc$descriptor_s result = {0, DSC$K_DTYPE_T, DSC$K_CLASS_D, NULL}; if (strcmp(inputname, file)) { if (context) { lib$find_file_end(&context); } context = 0; strcpy(inputname, file); file_desc.dsc$w_length = strlen(inputname); } if (RMS$_NORMAL == lib$find_file(&file_desc,&result,&context, &default_dsc,0,0,&Number_Zero)) { SLMEMCPY(expanded_file, result.dsc$a_pointer, result.dsc$w_length); expanded_file[result.dsc$w_length] = '\0'; return (1); } else { /* expanded_file[0] = '\0'; */ /* so file comes back as zero width */ return(0); } } /*}}}*/ static int context = 0; static char inputname[JED_MAX_PATH_LEN] = ""; $DESCRIPTOR(file_desc,inputname); $DESCRIPTOR(default_dsc,"SYS$DISK:[]*.*;"); static char *VMS_Star; int sys_findnext(char *file) /*{{{*/ { char *f; static struct dsc$descriptor_s result = {0, DSC$K_DTYPE_T, DSC$K_CLASS_D, NULL}; if (RMS$_NORMAL == lib$find_file(&file_desc,&result,&context, &default_dsc,0,0,&Number_Zero)) { SLMEMCPY(file, result.dsc$a_pointer, result.dsc$w_length); file[result.dsc$w_length] = 0; f = &file[result.dsc$w_length]; if (*VMS_Star) { while ((f > file) && (*f != ';')) f--; if (*f == ';') *f = 0; } return (1); } else return(0); } /*}}}*/ int sys_findfirst(char *thefile) /*{{{*/ { char *f, *f1, *s2 = "*.*"; char *file; file = thefile; f = extract_file(file); while (*f && (*f != '*')) f++; VMS_Star = ""; /* let user choose what to match with or take mine */ if (! *f) { f = extract_file(file); while (*f && (*f != '.')) f++; if (*f) VMS_Star = "*"; else VMS_Star = s2; file = jed_standardize_filename_static(thefile); f = f1 = extract_file(file); if (VMS_Star == s2) { while (*f && (*f != '.')) f++; *f = 0; } else { while (*f1 && (*f1 != ';')) f1++; *f1 = 0; } strcpy(thefile, file); } strcpy(inputname, file); if (*VMS_Star) strcat(inputname, VMS_Star); file_desc.dsc$w_length = strlen(inputname); if (context) lib$find_file_end(&context); context = 0; return sys_findnext(thefile); } /*}}}*/ #include /* returns 0 if file does not exist, 1 if it is not a dir, 2 if it is */ int sys_chmod(SLFUTURE_CONST char *file, int what, mode_t *mode, uid_t *uid, gid_t *gid) /*{{{*/ { struct stat buf; int m; if (stat(file, &buf) < 0) switch (errno) { case EACCES: return(-1); /* es = "Access denied."; break; */ case ENOENT: return(0); /* ms = "File does not exist."; */ case ENOTDIR: return(-2); /* es = "Invalid Path."; */ default: return(-3); /* "stat: unknown error."; break;*/ } m = buf.st_mode; (void) uid; (void) gid; *mode = m & 0777; if (m & S_IFDIR) return (2); return(1); } /*}}}*/ #if (__VMS_VER < 70000000) int rmdir (const char *d) /*{{{*/ { return -1; } /*}}}*/ #endif jed-0.99-19/src/DESCRIP.MMS0000644002657400265740000000352311311317447013733 0ustar davisdavis# # MMS file to build Jed (Thanks to Hunter Goatley) # .IFDEF __MATTS_MMS__ .ELSE EXE = .EXE OBJ = .OBJ .ENDIF .IFDEF __ALPHA__ CC = CC/STANDARD=VAXC OPTFILE = OPTIONS = .ELSE OPTFILE = ,VAXCRTL.OPT OPTIONS = $(OPTFILE)/OPTIONS .ENDIF .IFDEF __DEBUG__ CFLAGS = $(CFLAGS)/DEBUG/NOOPTIMIZE LINKFLAGS = $(LINKFLAGS)/DEBUG .ELSE LINKFLAGS = $(LINKFLAGS)/NOTRACE .ENDIF .IFDEF SLANG_OLB .ELSE SLANG_DIR = [-.-.SLANG.SRC] SLANG_OLB = $(SLANG_DIR)SLANG$(OLB) .ENDIF CFLAGS = $(CFLAGS)/DEFINE=(JED)/INCLUDE=([],$(SLANG_DIR)) OBJS = ABBREV$(OBJ), - BUFFER$(OBJ), - CMDS$(OBJ), - FILE$(OBJ), - INDENT$(OBJ), - INS$(OBJ), - INTRIN$(OBJ), - KEYMAP$(OBJ), - LEDIT$(OBJ), - LOCK$(OBJ), - LINE$(OBJ), - LINEATTR$(OBJ), - MAIN$(OBJ), - MISC$(OBJ), - PASTE$(OBJ), - REPLACE$(OBJ), - SCREEN$(OBJ), - COLORS$(OBJ), - SEARCH$(OBJ), - SIG$(OBJ), - SYNTAX$(OBJ), - SYSDEP$(OBJ), - TEXT$(OBJ), - UNDO$(OBJ), - VFILE$(OBJ), - VMSHELP$(OBJ), - VMSMAIL$(OBJ), - VTERM$(OBJ), - BLOCAL$(OBJ), - MENU$(OBJ), - JEDWIN$(OBJ), - MOUSE$(OBJ), - WINDOW$(OBJ), - VERSION$(OBJ), - HOOKS$(OBJ), - USERINFO$(OBJ) JEDOBJS = $(OBJS) DISPLAY$(OBJ) HFILES = BUFFER.H,CMDS.H,DISPLAY.H,FILE.H,INS.H,KEYMAP.H,LEDIT.H,LINE.H,- MISC.H,PASTE.H,SCREEN.H,SEARCH.H,SIG.H,SYSDEP.H,TEXT.H,VTERM.H,- REPLACE.H,WINDOW.H,UNDO.H,COLORS.H JED$(EXE) : JED$(OLB)($(JEDOBJS))$(OPTFILE),$(SLANG_OLB) $(LINK)$(LINKFLAGS) JED$(OLB)/INCLUDE=main/LIBRARY$(OPTIONS),- $(SLANG_OLB)/LIBRARY # # Most modules depend on most of the .H files, so I'm going to be lazy # and just make them all depend on all of them. # SYSDEP$(OBJ) : SYSDEP.C,VMS.C $(OBJS),DISPLAY$(OBJ) : $(HFILES) # # Build the linker options file for OpenVMS VAX and VAX C. # VAXCRTL.OPT : @ open/write tmp vaxcrtl.opt @ write tmp "SYS$SHARE:VAXCRTL.EXE/SHARE" @ close tmp jed-0.99-19/src/display.c0000644002657400265740000000462111311317447014075 0ustar davisdavis/* Copyright (c) 1992, 1998, 2000, 2002, 2003, 2004, 2005, 2006 John E. Davis * This file is part of JED editor library source. * * You may distribute this file under the terms the GNU General Public * License. See the file COPYING for more information. */ #include "config.h" #include "jed-feat.h" #include #include #include "jdmacros.h" #include "buffer.h" #include "display.h" #include "hooks.h" void (*tt_beep)(void); void (*tt_write_string)(SLFUTURE_CONST char *); void (*tt_get_screen_size)(int *, int *); JX_SETXXX_RETURN_TYPE (*tt_set_color)(int, SLFUTURE_CONST char *, SLFUTURE_CONST char *, SLFUTURE_CONST char *); JX_SETXXX_RETURN_TYPE (*tt_set_mono) (int, SLFUTURE_CONST char *, SLtt_Char_Type); #ifndef IBMPC_SYSTEM # if SLANG_VERSION < 20000 void (*tt_set_color_esc)(int, char *); # endif void (*tt_wide_width)(void); void (*tt_narrow_width)(void); void (*tt_enable_cursor_keys)(void); void (*tt_set_term_vtxxx)(int *); #endif int *tt_Ignore_Beep; int *tt_Use_Ansi_Colors; int *tt_Term_Cannot_Scroll; int *tt_Term_Cannot_Insert; #ifndef IBMPC_SYSTEM int *tt_Blink_Mode; #endif void flush_output (void) { SLtt_flush_output (); } static void get_screen_size (int *r, int *c) { SLtt_get_screen_size (); *r = SLtt_Screen_Rows; *c = SLtt_Screen_Cols; } static void get_terminfo (void) { /* Placed here for windows dll support. Apparantly the windows equivalent * of the run-time linker cannot perform the proper relocations. */ tt_beep = SLtt_beep; tt_write_string = SLtt_write_string; tt_get_screen_size = get_screen_size; tt_set_color = SLtt_set_color; tt_set_mono = SLtt_set_mono; #ifndef IBMPC_SYSTEM # if SLANG_VERSION < 20000 tt_set_color_esc = SLtt_set_color_esc; # endif tt_wide_width = SLtt_wide_width; tt_narrow_width = SLtt_narrow_width; tt_enable_cursor_keys = SLtt_enable_cursor_keys; tt_set_term_vtxxx = SLtt_set_term_vtxxx; #endif tt_Ignore_Beep = &SLtt_Ignore_Beep; tt_Use_Ansi_Colors = &SLtt_Use_Ansi_Colors; tt_Term_Cannot_Scroll = &SLtt_Term_Cannot_Scroll; tt_Term_Cannot_Insert = &SLtt_Term_Cannot_Insert; #ifndef IBMPC_SYSTEM SLtt_Blink_Mode = 0; tt_Blink_Mode = &SLtt_Blink_Mode; #endif #ifdef REAL_UNIX_SYSTEM SLtt_Force_Keypad_Init = 1; #endif if (Batch == 0) SLtt_get_terminfo (); } void (*tt_get_terminfo)(void) = get_terminfo; int (*X_Argc_Argv_Hook)(int, char **) = NULL; jed-0.99-19/src/gtkterm.c0000644002657400265740000055017711311317447014121 0ustar davisdavis/* -*- mode: C; mode: fold; -*- */ /* Copyright (c) 1992, 1998, 2000, 2002, 2003, 2004, 2005, 2006 John E. Davis * This file is part of JED editor library source. * * You may distribute this file under the terms the GNU General Public * License. See the file COPYING for more information. */ #define _BUILD_GTK_JED #include "config.h" #include "jed-feat.h" #define USE_NEW_META_CODE 1 #define HAS_IBM_NUMLOCK_CODE 0 #define SKIP_LOCALE_CODE 0 #ifndef HAVE_SETLOCALE # define X_LOCALE 1 #endif #define XJED_USE_COMPOUND_TEXT 0 #ifndef XJED_HAS_XRENDERFONT # define XJED_HAS_XRENDERFONT 0 #endif /*{{{ Include Files */ #ifndef VMS # include # include /* #include */ # include # include # include # include # if XJED_HAS_XRENDERFONT # include # endif # if !SKIP_LOCALE_CODE # if XtSpecificationRelease >= 6 # define XJED_USE_R6IM # include # endif # endif #else # include # include /* #include */ # include # include # include #endif #include #include #include #include #include #include #include #include #include #include #include "jdmacros.h" #include "buffer.h" #include "display.h" #include "sysdep.h" #include "screen.h" #include "keymap.h" #include "hooks.h" #include "ins.h" #include "ledit.h" #include "misc.h" #include "cmds.h" #include "sig.h" #include "file.h" #include "vterm.h" #include "colors.h" #include "window.h" #include "menu.h" #include "gtkjed.h" /* Fixes some X headers... */ #ifndef Button6Mask # define Button6Mask (Button5Mask<<1) #endif /*}}}*/ /* X_HAVE_UTF8_STRING is defined in X11.h */ #if (SLANG_VERSION >= 20000) && defined(X_HAVE_UTF8_STRING) # define USE_XUTF8_CODE 1 #else # define USE_XUTF8_CODE 0 #endif /*{{{ Static Global Variables */ typedef struct /*{{{*/ { GdkGC *gc; GdkColor *fg, *bg; char *fgName; char *bgName; int dirty; } /*}}}*/ GCGtkInfoType; typedef struct StructGtkSubWinType { struct StructGtkSubWinType *next; Window_Type *jedWin; GtkWidget *boxWin; GtkWidget *edWin; GtkWidget *stWin; GtkWidget *sbWin; gint edX; gint edY; gint edWidth; gint edHeight; GtkAdjustment *sbAdj; int numLineSav; int curLineSav; int winHeightSav; int ppY; int ppX; int ppHeight; /* proposed height */ int ppWidth; /* proposed width */ } GtkSubWinType; typedef struct { Display *XDisplay; /*********************************************************************/ /****** Stolen from original JXWindow_Type, don't get me wrong, but **/ /****** this data is still very useful. ***************/ /*********************************************************************/ /* int height, width; */ int border; /* inside border */ int o_border; /* outside border */ int current_gc_num; int vis_curs_row, vis_curs_col; /* position of VISIBLE cursor */ int cursor_showing; /* true if widow has cursor showing */ int focus; /* true if window has focus */ int window_mapped; /* true if window is mapped */ /* Window tty parameters */ int insert_mode; /* true if inserting */ int scroll_r1, scroll_r2; /* scrolling region */ int cursor_row, cursor_col; /* row column of cursor (0, 0) origin */ int visible; /* from visibilitynotify */ /*********************************************************************/ GdkDisplay *display; GdkScreen *screen; GdkColormap *colormap; int height; /* Height of Window in Pixel */ int width; /* Width of Window in Pixel */ int edHeight; /* Total height of all editor windows in lines */ int edWidth; /* Total width of all editor windows in rows */ int hCheck; int numWin; /* Number of windows, not including the Minibuffer */ GtkSubWinType *subWins; int gutSize; /* size of handle between subWins */ GtkSubWinType ***widgetWinXRef; GtkSubWinType *miniWinSW; int inGridHeight; int inGridHeightPixel; int inGridWidthPixel; int maxEdHeight; /* Max number of Lines of all editor windows in total */ /* Needed only for preallocating memory */ int maxEdWidth; /* Max rows per line, needed for preallocation */ #if 0 int *maxWinLine; /* maximal window segments for each line */ int *actWinLine; /* actual number of windows for each line */ int **lineWinXRef; /* All lines and window segment definition */ #endif /************************************************************************ |------------------------------------------------------------------------ |appW: GTK_WINDOW_TOPLEVEL | |---------------------------------------------------------------------- | | appWGrid: vbox | | |-------------------------------------------------------------------- | | |appWMenuBar: menu_bar | | | |------------------------------------------------------------------ | | | |<<< the editor menu >>> | | | |------------------------------------------------------------------ | | |-------------------------------------------------------------------- | | |appWTBGrid: vbox, toolbar area | | | |------------------------------------------------------------------ | | | | First TB (created dynamically) | | | |------------------------------------------------------------------ | | | | Next TB (created dynamically) | | | |------------------------------------------------------------------ | | | | ... | | | |------------------------------------------------------------------ | | | | N-th TB (created dynamically) | | | |------------------------------------------------------------------ | | |-------------------------------------------------------------------- | | |appWEdGrid: vbox | | | |------------------------------------------------------------------ | | | | appWASCWin <<< currently not used, will be draw area >>> | | | |------------------------------------------------------------------ | | | | appWTopEdWin: paned Widget or box | | | | | | | | <<< editor windows, dynamically created >>> | | | | | | | | **************************************************** | | | | * Editor area widgets, implemented as vertical box | | | | * containing: | | | | * - horizontal box containing | | | | * - draw area | | | | * - scrollbar | | | | * - draw area to display status line for buffer | | | | * dynamically. All editor area widgets are hierarchically | | | | * stacked together with paned widget. If there is only one editor | | | | * area widget no paned widget is used/created. | | | | * |----------------------------------------------------- | | | | * | vertical box | | | | * | |--------------------------------------------------- | | | | * | | horizontal box | | | | * | | |------------------------------------------------| | | | | * | | | draw area (X: scrollbar) | | | | | | * | | | | | | | | | * | | | |X| | | | | * | | | |X| | | | | * | | | |X| | | | | * | | | | | | | | | * | | | | | | | | | * | | |------------------------------------------------| | | | | * | |--------------------------------------------------- | | | | * | | draw area to display buffer status line | | | | * | |--------------------------------------------------- | | | | * |----------------------------------------------------- | | | | **************************************************** | | | |------------------------------------------------------------------ | | | | appWMiniW (widget for miniWin) | | | |------------------------------------------------------------------ | | |-------------------------------------------------------------------- | | |appWSB: statusbar | | |-------------------------------------------------------------------- | |---------------------------------------------------------------------- |------------------------------------------------------------------------ ************************************************************************/ /***************************************************** * Main container widgets *****************************************************/ GtkWidget *appW; /* GTK_WINDOW_TOPLEVEL */ GtkWidget *appWGrid; /* vbox */ /***************************************************** * Default menu widgets, contain no functionality *****************************************************/ GtkWidget *appWMenuBar; /* menu_bar */ GtkWidget *appWMenu; GtkWidget *appWMenuItem; GtkWidget *appWMenuItemOpen; GtkWidget *appWMenuItemSave; GtkWidget *appWMenuItemClose; /* GHashTable *menuArray; */ /* Used to access menu items by path. The path is used as index */ /* into a hash table, that contains pointer to menu items. */ /*************************************************** * Toolbar widget container, toolbars are created * dynamically. ***************************************************/ GtkWidget *appWTbGrid; /* vbox */ /*************************************************** * Editor area widgets, implemented as vertical box * containing: * - horizontal box containing * - draw area * - scrollbar * - draw area to display status line for buffer * dynamically. All editor area widgets are hierarchically * stacked together with paned widget. For only one editor * area widget no paned widget is used. ***************************************************/ GtkWidget *appWEdGrid; /* Contains drawing Area for Menu and appWInGrid */ GtkWidget *appWASCMenu; /* Draw area containing the ASCII-based menu <<< currently */ /* not implemented >>> */ GtkWidget *appWInGrid; /* Contains Toplevel paned widget and miniWidget for minibuffer */ /* following the description above, to be removed in near */ /* future */ GtkWidget *appWTopEdWin; /* Toplevel EditorWindow (draw area / paned widget) */ GtkWidget *appWMiniW; /* miniWidget, Widget to display the minibuffer */ /***************************************************** * Status bar widget, currently not used. *****************************************************/ GtkWidget *appWSB; /* Statusbar widget */ /************************************************** * Text drawing/rendering objects **************************************************/ PangoContext *fontContext; PangoFontDescription *fontDescription; PangoFontMetrics *fontMetrics; char *fontName; int fontAscent; int fontDescent; int fontHeight; int fontWidth; GCGtkInfoType *textGC; GCGtkInfoType *currentGC; } JGtkWinType; /* extern JGtkWinType JGtkWinBuf; */ extern JGtkWinType *JGtkWin; /* #define XJED_MAP 0 */ #define MAX_EDHEIGHT 500; /* default for height of edit windows */ #define MAX_EDWIDTH 500; /* default for width of edit windows */ void jedGtkUpdateEdSize( int, int ); void updateWidgetWinXRef( GtkSubWinType *, int, int, int, int ); /* static int checkFlushXDisplay(void); */ /* static int checkFlushXDisplayST( int, const char * ); */ static int JX_Screen_Cols; static int JX_Screen_Rows; static int JX_Term_Cannot_Scroll = 0; static int JX_Term_Cannot_Insert = 0; static int JX_Use_Ansi_Colors = 1; static int JX_Ignore_Beep = 3; static int JX_Blink_Mode = 1; static int JX_MultiClick_Time = 500; /* milliseconds */ static int JX_MetaMask = Mod1Mask; #ifdef XJED_USE_R6IM static char *R6IM_Input_Method = NULL; /* static XIMStyle R6IM_Input_Style = 0; */ static char *R6IM_Preedit_Type = "Root"; /* static XIC R6IM_Xic; */ /* static void i18init(void); */ /* static XPoint R6IM_Spot; */ /* static XVaNestedList R6IM_Preedit_Attr; */ /* static void move_input_position (void); */ /* static void set_geometry (XEvent *, XIMStyle, char *); */ #endif static int updateGtkWin = 1; /* used during splitWin / showAll to prevent drawing!!! */ /* see also gtkDraw-function */ static int doColorSetup = 1; static int doCLS = 1; static gboolean sbChangeValue( GtkRange *, GtkScrollType, gdouble, gpointer ); void printGtkSubWin( GtkSubWinType * ); void printSubWins(void); static void toggle_cursor( int ); /* static char *The_Xserver_Vendor; */ /* static int Current_Color; */ static int X_Alt_Char = 27; static KeySym X_Last_Keysym; static int X_Warp_Pending = 0; static gdouble actSBVal; #define FC_CMD_KEY_SEQ "\033[FC" static gpointer actParaData; static void ( *actFunToCall )( gpointer ); static void modWidgetWinXRef( GtkSubWinType ***, GtkSubWinType *, int, int, int, int ); static void printWidgetStruct(void); /******************** Jed internal Event Queue *******************/ typedef enum { JXGtkAnyID = 1, JXGtkGdkEventID = 2, JXKeyFeedID = 3 } JXGtkEventID; typedef struct { JXGtkEventID type; } JXGtkAnyEvent; typedef struct { JXGtkEventID type; GdkEvent gdkEvent; GtkWidget *w; gpointer *data; } JXGtkGdkEvent; typedef struct { JXGtkEventID type; char *keys; } JXKeyFeedEvent; typedef union { JXGtkEventID type; JXGtkAnyEvent any; JXGtkGdkEvent gdkEvent; JXKeyFeedEvent keyFeed; } JXGtkEventType; /************************************************************************/ static int Performing_Update; static int Check_Buffers_Pending; static int No_XEvents; /* if true, do nothing */ typedef struct /*{{{*/ { char *name; char *name1; int type; char *value; char **dflt; } /*}}}*/ XWindow_Arg_Type; #define XJED_CLASS "XTerm" static char *This_App_Name = "xjed"; static char *This_App_Title = "XJed"; /* #define Default_Geometry "80x24+0-0" */ #define Default_Geometry "80x24" static char *This_Geometry = NULL; static char *This_Font_Name = "fixed"; #if XJED_HAS_XRENDERFONT static char *This_Face_Size = " "; #endif static char *This_Border_Width_Name = "0"; static char *This_Internal_Border_Name = "0"; static char *This_MFG = "green"; static char *This_MBG = "white"; static char *Iconic = NULL; /* static Atom Xjed_Prop; */ /* static Atom Compound_Text_Atom; */ /* static Atom UTF8_String_Atom; */ /* static XEvent Current_Event; */ static char *jgtkSelectionData = NULL; static char *jgtkClipboardData = NULL; /* static int receive_selection (XEvent *); */ /* static int send_selection (XEvent *); */ static GCGtkInfoType DefaultGtkGCInfo[JMAX_COLORS] = /*{{{*/ { /******************************************************************************* * GC: X11-gc * foreground (unsigned long) * background (unsigned long) * foreground color name * background color name * flag if dirty *******************************************************************************/ { NULL, NULL, NULL, "black", "white", 0 }, /* NORMAL */ { NULL, NULL, NULL, "green", "red", 0 }, /* CURSOR */ { NULL, NULL, NULL, "default", "skyblue", 0 }, /* STATUS */ { NULL, NULL, NULL, "default", "magenta", 0 }, /* REGION */ { NULL, NULL, NULL, "default", "skyblue", 0 }, /* MENU */ { NULL, NULL, NULL, "default", "default", 0 }, /* operator */ { NULL, NULL, NULL, "green", "default", 0 }, /* numbers */ { NULL, NULL, NULL, "blue", "default", 0 }, /* strings */ { NULL, NULL, NULL, "default", "gray", 0 }, /* comments */ { NULL, NULL, NULL, "default", "default", 0 }, /* delimeters */ { NULL, NULL, NULL, "magenta", "default", 0 }, /* preprocess */ { NULL, NULL, NULL, "blue", "default", 0 }, /* message */ { NULL, NULL, NULL, "red", "default", 0 }, /* error */ { NULL, NULL, NULL, "magenta", "default", 0 }, /* dollar */ { NULL, NULL, NULL, "red", "default", 0 }, /* keyword */ { NULL, NULL, NULL, "green", "default", 0 }, /* keyword1 */ { NULL, NULL, NULL, "red", "default", 0 }, /* keyword2 */ { NULL, NULL, NULL, "green", "magenta", 0 } /* ... fold mark */ }; /* cheat a little, use VOID_TYPE for boolean arguments */ static XWindow_Arg_Type jGtkArgList[] = /*{{{*/ { /* These MUST be in this order!!! */ #define XARG_DISPLAY 0 {"Display", "d", STRING_TYPE, NULL, NULL}, #define JGTK_ARG_NAME 1 {"Name", NULL, STRING_TYPE, NULL, &This_App_Name}, #define XARG_GEOMETRY 2 {"Geometry", NULL, STRING_TYPE, NULL, &This_Geometry}, #define XARG_START 2 /* Note: it's good to look for * `font', `background', `foreground' * instead of * `Font', `background', `foreground' * so that XTerm names can be used * (resource vs. class names) * * also, change order of names a little? */ {"font", "fn", STRING_TYPE, NULL, &This_Font_Name}, {"fgMouse", "mfg", STRING_TYPE, NULL, &This_MFG}, {"bgMouse", "mbg", STRING_TYPE, NULL, &This_MBG}, {"background", "bg", STRING_TYPE, NULL, &DefaultGtkGCInfo[JNORMAL_COLOR].bgName}, {"foreground", "fg", STRING_TYPE, NULL, &DefaultGtkGCInfo[JNORMAL_COLOR].fgName}, {"fgStatus", "sfg", STRING_TYPE, NULL, &DefaultGtkGCInfo[JSTATUS_COLOR].fgName}, {"bgStatus", "sbg", STRING_TYPE, NULL, &DefaultGtkGCInfo[JSTATUS_COLOR].bgName}, {"fgRegion", "rfg", STRING_TYPE, NULL, &DefaultGtkGCInfo[JREGION_COLOR].fgName}, {"bgRegion", "rbg", STRING_TYPE, NULL, &DefaultGtkGCInfo[JREGION_COLOR].bgName}, {"fgCursor", "cfg", STRING_TYPE, NULL, &DefaultGtkGCInfo[JCURSOR_COLOR].fgName}, {"bgCursor", "cbg", STRING_TYPE, NULL, &DefaultGtkGCInfo[JCURSOR_COLOR].bgName}, {"fgCursorOvr", "cofg", STRING_TYPE, NULL, &DefaultGtkGCInfo[JCURSOROVR_COLOR].fgName}, {"bgCursorOvr", "cobg", STRING_TYPE, NULL, &DefaultGtkGCInfo[JCURSOROVR_COLOR].bgName}, {"fgMenu", "fgm", STRING_TYPE, NULL, &DefaultGtkGCInfo[JMENU_COLOR].fgName}, {"bgMenu", "bgm", STRING_TYPE, NULL, &DefaultGtkGCInfo[JMENU_COLOR].bgName}, {"fgOperator", "fgop", STRING_TYPE, NULL, &DefaultGtkGCInfo[JOP_COLOR].fgName}, {"bgOperator", "bgop", STRING_TYPE, NULL, &DefaultGtkGCInfo[JOP_COLOR].bgName}, {"fgNumber", "fgnm", STRING_TYPE, NULL, &DefaultGtkGCInfo[JNUM_COLOR].fgName}, {"bgNumber", "bgnm", STRING_TYPE, NULL, &DefaultGtkGCInfo[JNUM_COLOR].bgName}, {"fgString", "fgst", STRING_TYPE, NULL, &DefaultGtkGCInfo[JSTR_COLOR].fgName}, {"bgString", "bgst", STRING_TYPE, NULL, &DefaultGtkGCInfo[JSTR_COLOR].bgName}, {"fgComments", "fgco", STRING_TYPE, NULL, &DefaultGtkGCInfo[JCOM_COLOR].fgName}, {"bgComments", "bgco", STRING_TYPE, NULL, &DefaultGtkGCInfo[JCOM_COLOR].bgName}, {"fgKeyword", "fgkw", STRING_TYPE, NULL, &DefaultGtkGCInfo[JKEY_COLOR].fgName}, {"bgKeyword", "bgkw", STRING_TYPE, NULL, &DefaultGtkGCInfo[JKEY_COLOR].bgName}, {"fgKeyword1", "fgkw1", STRING_TYPE, NULL, &DefaultGtkGCInfo[JKEY_COLOR + 1].fgName}, {"bgKeyword1", "bgkw1", STRING_TYPE, NULL, &DefaultGtkGCInfo[JKEY_COLOR + 1].bgName}, {"fgKeyword2", "fgkw2", STRING_TYPE, NULL, &DefaultGtkGCInfo[JKEY_COLOR + 2].fgName}, {"bgKeyword2", "bgkw2", STRING_TYPE, NULL, &DefaultGtkGCInfo[JKEY_COLOR + 2].bgName}, {"fgDelimiter", "fgde", STRING_TYPE, NULL, &DefaultGtkGCInfo[JDELIM_COLOR].fgName}, {"bgDelimiter", "bgde", STRING_TYPE, NULL, &DefaultGtkGCInfo[JDELIM_COLOR].bgName}, {"fgPreprocess", "fgpr", STRING_TYPE, NULL, &DefaultGtkGCInfo[JPREPROC_COLOR].fgName}, {"bgPreprocess", "bgpr", STRING_TYPE, NULL, &DefaultGtkGCInfo[JPREPROC_COLOR].bgName}, {"bgMessage", "bgms", STRING_TYPE, NULL, &DefaultGtkGCInfo[JMESSAGE_COLOR].bgName}, {"fgMessage", "fgms", STRING_TYPE, NULL, &DefaultGtkGCInfo[JMESSAGE_COLOR].fgName}, {"bgError", "bger", STRING_TYPE, NULL, &DefaultGtkGCInfo[JERROR_COLOR].bgName}, {"fgError", "fger", STRING_TYPE, NULL, &DefaultGtkGCInfo[JERROR_COLOR].fgName}, {"fgDots", "fgdt", STRING_TYPE, NULL, &DefaultGtkGCInfo[JDOTS_COLOR].bgName}, {"bgDots", "bgdt", STRING_TYPE, NULL, &DefaultGtkGCInfo[JDOTS_COLOR].bgName}, {"BorderWidth", "bw", STRING_TYPE, NULL, &This_Border_Width_Name}, {"title", NULL, STRING_TYPE, NULL, &This_App_Title}, {"BorderColor", "bd", STRING_TYPE, NULL, NULL}, {"Iconic", "ic", VOID_TYPE, NULL, &Iconic}, {"xrm", NULL, STRING_TYPE, NULL, NULL}, {"internalBorder", "ib", STRING_TYPE, NULL, &This_Internal_Border_Name}, #ifdef XJED_USE_R6IM {"inputMethod", "im", STRING_TYPE, NULL, &R6IM_Input_Method}, {"inputStyle", "is", STRING_TYPE, NULL, &R6IM_Preedit_Type}, #endif #if XJED_HAS_XRENDERFONT {"facesize", "fs", STRING_TYPE, NULL, &This_Face_Size}, #endif {NULL, NULL, 0, NULL, NULL} }; /*}}}*/ /*}}}*/ static JGtkWinType JGtkWinBuf; JGtkWinType *JGtkWin = &JGtkWinBuf; /* static int gtkButtonEvent = 0; */ static gboolean eventCallback( GtkWidget *, GdkEvent *, gpointer * ); static void jGtkCoverExposedArea( int, int, int, int, int ); static int gtkInsertSelection( void ); static void gtkSelectionReceive( GtkWidget *, GtkSelectionData *, gpointer ); static void jGtkSendSelection( GtkWidget *, GtkSelectionData *, guint, guint, gpointer ); static void jGtkSetFGBGColor( GtkWidget *, int ); typedef struct { GList *jXGtkEvList; int jXGtkNumEv; } FilterEventData; static FilterEventData *thisEventBuffer; typedef struct jGtkScrollInfoStruct { int set; /* flagging scrollInfo active (with valid infos) or not */ int tl; /* Target line */ GtkRange *rangeW; /* rangeWidget */ int sLSBeg; /* singleLineSteps (sLS) outstanding */ /* Scrolling is done by first doing a view single line steps. */ /* If target is not reached, jump to target (maybe in a view bigger */ /* steps, not only one big step). */ int sLSEnd; /* singleLineSteps at End of scrolling. */ int jF; /* jumpFlag, if set to one means, no single line steps any more */ /* to perform act scroll event, just jump to target (this should be done, */ /* if the next scroll */ /* event arrives before act scroll event is completed. */ int cnt; /* intermediate solution for slow down scrolling!!! */ struct timeval tv; } JGtkScrollInfo; #define JGTK_SCROLL_SLOW_DOWN 20 static JGtkScrollInfo jGtkSIPrim = { 0, 1, NULL, 0, 0, 0, JGTK_SCROLL_SLOW_DOWN, { 0, 0 } }; /* Primary scrollInfo (means scrollInfo for act scroll event) */ static JGtkScrollInfo jGtkSISec = { 0, 1, NULL, 0, 0, 0, JGTK_SCROLL_SLOW_DOWN, { 0, 0 } }; /* Secondary scrollInfo is queued if next scroll event arrives before */ /* actual scroll event is completed. In further scrollEvent will */ /* discard secondary scrollInfo and reset it. */ /************************************/ /************************************ * JXGtkPending * * group: event * * * debug print: * * ************************************/ static gboolean jGtkPending(void) { while ( gtk_events_pending() ) { gtk_main_iteration_do( False ); } return( thisEventBuffer->jXGtkNumEv ); } /************************************ * JXGtkPeekEvent * * group: event * * * debug print: * * ************************************/ #if 0 static int JXGtkPeekEvent( JXGtkEventType *ev ) { FilterEventData *cbData = thisEventBuffer; while ( !( thisEventBuffer->jXGtkNumEv ) ) { if ( gtk_events_pending() ) { gtk_main_iteration(); } } if ( thisEventBuffer->jXGtkNumEv ) { memcpy( ev, ( JXGtkEventType * ) thisEventBuffer->jXGtkEvList->data, sizeof( JXGtkEventType ) ); return( TRUE ); } else { return( FALSE ); } } #endif /******************************* * JXGtkNextEvent * * group: event * * * debug print: * ********************************/ static int JXGtkNextEvent( JXGtkEventType *ev ) { FilterEventData *cbData = thisEventBuffer; while ( !( thisEventBuffer->jXGtkNumEv ) ) { if ( gtk_events_pending() ) { gtk_main_iteration(); } } if ( thisEventBuffer->jXGtkNumEv ) { memcpy( ev, ( JXGtkEventType * ) thisEventBuffer->jXGtkEvList->data, sizeof( JXGtkEventType ) ); SLfree( ( char * ) thisEventBuffer->jXGtkEvList->data ); thisEventBuffer->jXGtkEvList = g_list_remove( thisEventBuffer->jXGtkEvList, thisEventBuffer->jXGtkEvList->data ); thisEventBuffer->jXGtkNumEv -= 1; if ( thisEventBuffer->jXGtkNumEv < 0 ) thisEventBuffer->jXGtkNumEv = 0; return( TRUE ); } else { return( FALSE ); } } /************************************ * JXGtkCheckMaskEvent( Display *display, long mask, JXGtkEventType *ev ) * * group: event * * * debug print: * ***********************************/ static Bool JXGtkCheckMaskEvent( long mask, JXGtkEventType *ev ) { FilterEventData *cbData = thisEventBuffer; guint sizeOfBuffer; GList *actEle; while ( gtk_events_pending() ) { gtk_main_iteration(); } if ( thisEventBuffer->jXGtkNumEv ) { actEle = thisEventBuffer->jXGtkEvList; sizeOfBuffer = g_list_length( actEle ); while ( sizeOfBuffer-- ) { if ( mask && ( ( JXGtkEventType * ) actEle->data )->gdkEvent.gdkEvent.type ) { memcpy( ev, ( JXGtkEventType * ) actEle->data, sizeof( JXGtkEventType ) ); SLfree( ( char * ) actEle->data ); thisEventBuffer->jXGtkEvList = g_list_remove( thisEventBuffer->jXGtkEvList, actEle->data ); thisEventBuffer->jXGtkNumEv -= 1; if ( thisEventBuffer->jXGtkNumEv < 0 ) thisEventBuffer->jXGtkNumEv = 0; return( TRUE ); } actEle = actEle->next; } return( False ); } else { return( False ); } } /************************************ * addGdkEvent * * group: event * * * debug print: * * ************************************/ static void addGdkEvent( GdkEvent *ev, GtkWidget *w, gpointer *data ) { FilterEventData *eB = thisEventBuffer; JXGtkEventType *newEv = ( JXGtkEventType * ) SLmalloc( sizeof( JXGtkEventType ) ); newEv->type = JXGtkGdkEventID; newEv->any.type = JXGtkGdkEventID; newEv->gdkEvent.type = JXGtkGdkEventID; memcpy( &( newEv->gdkEvent.gdkEvent ), ev, sizeof( GdkEvent ) ); newEv->gdkEvent.w = w; newEv->gdkEvent.data = data; eB->jXGtkEvList = g_list_append( eB->jXGtkEvList, newEv ); ( eB->jXGtkNumEv ) += 1; /* printf( "File: %s, Line: %d; Num JXGtkEvents: %d\n", __FILE__, __LINE__, eB->jXGtkNumEv ); */ } /*************************/ /************************************ * createGtkMiniWin * * group: win * * * debug print: "void (%d)\n", 1 * * ************************************/ static GtkWidget * createGtkMiniWin(void) { GdkColor white = { 0, 0xffff, 0xffff, 0xffff }; GtkWidget *w = gtk_drawing_area_new(); /* Edit window */ gtk_widget_modify_bg( w, GTK_STATE_NORMAL, &white ); GTK_WIDGET_SET_FLAGS( w, GTK_CAN_FOCUS ); gtk_widget_add_events( w, GDK_KEY_PRESS_MASK ); g_signal_connect( G_OBJECT( w ), "key_press_event", G_CALLBACK( eventCallback ), NULL ); gtk_widget_add_events( w, GDK_BUTTON_PRESS_MASK ); g_signal_connect( G_OBJECT( w ), "button_press_event", G_CALLBACK( eventCallback ), NULL ); gtk_widget_add_events( w, GDK_BUTTON_RELEASE_MASK ); g_signal_connect( G_OBJECT( w ), "button_release_event", G_CALLBACK( eventCallback ), NULL ); g_signal_connect( G_OBJECT( w ), "expose_event", G_CALLBACK( eventCallback ), NULL ); gtk_widget_add_events( w, GDK_BUTTON_MOTION_MASK ); g_signal_connect( G_OBJECT( w ), "motion_notify_event", G_CALLBACK( eventCallback ), NULL ); gtk_widget_add_events( w, GDK_FOCUS_CHANGE_MASK ); g_signal_connect( G_OBJECT( w ), "focus-out-event", G_CALLBACK( eventCallback ), NULL ); g_signal_connect( G_OBJECT( w ), "focus-in-event", G_CALLBACK( eventCallback ), NULL ); g_signal_connect( G_OBJECT( w ), "selection_received", G_CALLBACK( gtkSelectionReceive ), NULL ); g_signal_connect( G_OBJECT( w ), "selection_get", G_CALLBACK( jGtkSendSelection), NULL ); gtk_selection_add_target( w, GDK_SELECTION_PRIMARY, GDK_SELECTION_TYPE_STRING, 1 ); return( w ); } /************************************ * createGtkWinTmpl * * group: win * * * debug print: "ce: %d, jw(GtkSubWinType): %x\n", ce, jw * * ************************************/ static GtkSubWinType * createGtkWinTmpl( GtkSubWinType *jw ) { JGtkWinType *win = JGtkWin; /* EdWinWidgetType edWidgets; */ GdkColor white = { 0, 0xffff, 0xffff, 0xffff }; GtkWidget *w = gtk_drawing_area_new(); /* Edit window */ GtkWidget *ws = gtk_drawing_area_new(); /* Window statusbar */ GtkWidget *sb = gtk_vscrollbar_new( NULL ); GtkWidget *eb = gtk_hbox_new( False, 0 ); GtkWidget *wb = gtk_vbox_new( False, 0 ); GtkAdjustment *sbAdj = gtk_range_get_adjustment( GTK_RANGE( sb ) ); gtk_widget_set_size_request( ws, -1, win->fontHeight ); gtk_widget_modify_bg( w, GTK_STATE_NORMAL, &white ); gtk_widget_modify_bg( ws, GTK_STATE_NORMAL, &white ); GTK_WIDGET_SET_FLAGS( w, GTK_CAN_FOCUS ); GTK_WIDGET_SET_FLAGS( ws, GTK_CAN_FOCUS ); gtk_widget_add_events( w, GDK_KEY_PRESS_MASK ); g_signal_connect( G_OBJECT( w ), "key_press_event", G_CALLBACK( eventCallback ), jw ); gtk_widget_add_events( w, GDK_BUTTON_PRESS_MASK ); g_signal_connect( G_OBJECT( w ), "button_press_event", G_CALLBACK( eventCallback ), w ); gtk_widget_add_events( ws, GDK_BUTTON_PRESS_MASK ); g_signal_connect( G_OBJECT( ws ), "button_press_event", G_CALLBACK( eventCallback ), ws ); gtk_widget_add_events( w, GDK_BUTTON_RELEASE_MASK ); g_signal_connect( G_OBJECT( w ), "button_release_event", G_CALLBACK( eventCallback ), w ); gtk_widget_add_events( ws, GDK_BUTTON_RELEASE_MASK ); g_signal_connect( G_OBJECT( ws ), "button_release_event", G_CALLBACK( eventCallback ), ws ); gtk_widget_add_events( w, GDK_EXPOSURE_MASK ); g_signal_connect( G_OBJECT( w ), "expose_event", G_CALLBACK( eventCallback ), jw ); gtk_widget_add_events( ws, GDK_EXPOSURE_MASK ); g_signal_connect( G_OBJECT( ws ), "expose_event", G_CALLBACK( eventCallback ), jw ); gtk_widget_add_events( w, GDK_BUTTON_MOTION_MASK ); g_signal_connect( G_OBJECT( w ), "motion_notify_event", G_CALLBACK( eventCallback ), jw ); gtk_widget_add_events( w, GDK_FOCUS_CHANGE_MASK ); g_signal_connect( G_OBJECT( w ), "focus-out-event", G_CALLBACK( eventCallback ), jw ); g_signal_connect( G_OBJECT( w ), "focus-in-event", G_CALLBACK( eventCallback ), jw ); g_signal_connect( G_OBJECT( w ), "configure_event", G_CALLBACK( eventCallback ), jw ); g_signal_connect( G_OBJECT( w ), "selection_received", G_CALLBACK( gtkSelectionReceive ), jw ); g_signal_connect( G_OBJECT( w ), "selection_get", G_CALLBACK( jGtkSendSelection), jw ); gtk_selection_add_target( w, GDK_SELECTION_PRIMARY, GDK_SELECTION_TYPE_STRING, 1 ); g_signal_connect( G_OBJECT( sb ), "change-value", G_CALLBACK( sbChangeValue ), NULL ); /* Set initial dummy values */ sbAdj->lower = 0; sbAdj->upper = 100; sbAdj->value = 30; sbAdj->step_increment = 1; sbAdj->page_increment = 10; sbAdj->page_size = 5; g_signal_emit_by_name( G_OBJECT( sbAdj ), "changed" ); gtk_box_pack_start( GTK_BOX( eb ), w, True, True, 0 ); gtk_box_pack_start( GTK_BOX( eb ), sb, False, False, 0 ); gtk_box_pack_start( GTK_BOX( wb ), eb, True, True, 0 ); gtk_box_pack_start( GTK_BOX( wb ), ws, False, True, 0 ); jw->edWin = w; jw->stWin = ws; jw->sbWin = sb; return( jw ); } /************************************ * printWidgetWinXRef * * group: win, debug * * * debug print: "(void)", 1 * * ************************************/ #if 0 static void printWidgetWinXRef(void) { int i, i1; JGtkWinType *win = JGtkWin; printf( "Ed Height: %d, Width: %d\n", win->edHeight, win->edWidth ); printf( " Jed_Num_Screen_Cols: %d, Jed_Num_Screen_Rows: %d, Top_Window_SY: %d\n", Jed_Num_Screen_Cols, Jed_Num_Screen_Rows, Top_Window_SY ); for ( i = 0; i < win->edHeight; ++i ) { printf( "%3d:", i ); for ( i1 = 0; i1 < win->edWidth; ++i1 ) { if ( win->widgetWinXRef[i][i1] ) { if ( i != win->widgetWinXRef[i][i1]->jedWin->sy + win->widgetWinXRef[i][i1]->jedWin->rows ) { /* printf( "(%6x-E-%6x)", win->widgetWinXRef[i][i1]->jedWin, win->widgetWinXRef[i][i1]->edWin ); */ printf( "E%p-%p ", (void*)win->widgetWinXRef[i][i1]->jedWin, (void*)win->widgetWinXRef[i][i1]->edWin ); } else { /* printf( "(%6x-S-%6x)", win->widgetWinXRef[i][i1]->jedWin, win->widgetWinXRef[i][i1]->stWin ); */ printf( "S%p-%p ", (void*)win->widgetWinXRef[i][i1]->jedWin, (void*)win->widgetWinXRef[i][i1]->stWin ); } } else { /* printf( "(%6x-S-%6x)", NULL, NULL ); */ printf( "S%p-%p ", NULL, NULL ); } } printf( "\n" ); } } #endif /************************************ * printWidgetWinXRefXY * * group: win, debug * * * debug print: "x: %d, y: %d\n", x, y * * ************************************/ #if 0 static void printWidgetWinXRefXY( int x, int y ) { int i, i1; JGtkWinType *win = JGtkWin; printf( "Ed Height: %d, Width: %d\n", win->edHeight, win->edWidth ); printf( " Jed_Num_Screen_Cols: %d, Jed_Num_Screen_Rows: %d, Top_Window_SY: %d\n", Jed_Num_Screen_Cols, Jed_Num_Screen_Rows, Top_Window_SY ); for ( i = 0; i <= y; ++i ) { printf( "height[%8d]: ", i ); for ( i1 = 0; i1 <= x; ++i1 ) { if ( win->widgetWinXRef[i][i1] ) { if ( i != win->widgetWinXRef[i][i1]->jedWin->sy + win->widgetWinXRef[i][i1]->jedWin->rows ) { printf( "(%p-E-%p)", (void*)win->widgetWinXRef[i][i1]->jedWin, (void*)win->widgetWinXRef[i][i1]->edWin ); } else { printf( "(%p-S-%p)",(void*) win->widgetWinXRef[i][i1]->jedWin, (void*)win->widgetWinXRef[i][i1]->stWin ); } } else { printf( "(%p-S-%p)", NULL, NULL ); } } printf( "\n" ); } } #endif static void printWidgetStruct(void) { JGtkWinType *win = JGtkWin; GtkSubWinType *sw = win->subWins; GtkWidget *w, *pw; do { printGtkSubWin( sw ); printf( "Parents: \n" ); pw = sw->stWin; do { pw = gtk_widget_get_parent( pw ); printf( " %p(w: %d, h: %d", (void*)pw, pw->allocation.width, pw->allocation.height ); if ( pw != gtk_widget_get_parent( sw->stWin ) ) printf( ", paned-pos: %d), ", gtk_paned_get_position( GTK_PANED( pw ) ) ); else printf( ", box), " ); } while( pw != win->appWTopEdWin ); printf( "\n" ); w = sw->edWin; printf( "EdWidget: %p: x: %d, y: %d, width: %d, height: %d\n", (void*)w, w->allocation.x, w->allocation.y, w->allocation.width, w->allocation.height ); w = sw->stWin; printf( "StWidget: %p: x: %d, y: %d, width: %d, height: %d\n", (void*)w, w->allocation.x, w->allocation.y, w->allocation.width, w->allocation.height ); printf( "=========================================\n" ); sw = sw->next; } while ( sw != win->subWins ); } void printGtkSubWin( GtkSubWinType * ); /************************************ * printSubWinSizes * * group: win, debug * * * debug print: "(void)" * * ************************************/ #if 0 static void printSubWinSizes(void) { int sumHeight; JGtkWinType *win = JGtkWin; GtkSubWinType *sw = win->subWins; printf( "Font height: %d, width: %d\n", win->fontHeight, win->fontWidth ); if ( win->appWInGrid ) { printf( "appWInGrid(%p): %5d W, %5d H\n", (void*)win->appWInGrid, win->appWInGrid->allocation.width, win->appWInGrid->allocation.height ); } /* printf( "Font height: %d, width: %d\n", win->fontHeight, win->fontWidth ); */ /* sumHeight = win->fontHeight; */ sumHeight = 0; if ( sw ) do { /* printGtkSubWinSize( sw ); */ printf( "SW: %p, edWin(%p): %5d W, %5d H, stWin(%p): %5d W, %5d H\n", (void*)sw, (void*)sw->edWin, sw->edWin->allocation.width, sw->edWin->allocation.height, (void*)sw->stWin, sw->stWin->allocation.width, sw->stWin->allocation.height ); sumHeight += sw->edWin->allocation.height + sw->stWin->allocation.height; sw = sw->next; } while ( sw != win->subWins ); printf( "Sum widget height in pixel: %d\n", sumHeight ); } #endif /************************************ * printSubWins * * group: win, debug * * * debug print: "(void)" * * ************************************/ void printSubWins() { int sumHeight; JGtkWinType *win = JGtkWin; GtkSubWinType *sw = win->subWins; printf( " Jed_Num_Screen_Cols: %d, Jed_Num_Screen_Rows: %d, Top_Window_SY: %d\n", Jed_Num_Screen_Cols, Jed_Num_Screen_Rows, Top_Window_SY ); if ( win->appWInGrid ) { printf( "Win->appWInGrid: Height: %d, Width: %d\n", win->appWInGrid->allocation.height, win->appWInGrid->allocation.width ); } printf( "Font height: %d, width: %d\n", win->fontHeight, win->fontWidth ); sumHeight = win->fontHeight; if ( sw ) do { printGtkSubWin( sw ); sumHeight += sw->edWin->allocation.height + sw->stWin->allocation.height; printf( "Sum widget height in pixel: %d\n", sumHeight ); sw = sw->next; } while ( sw != win->subWins ); } /************************************ * printJedWin * * group: win, debug * * * debug print: "w(Window_Type): %p\n", w * * ************************************/ static void printJedWin( Window_Type *w ) { printf( "Jed-Win: %p\n", (void*)w ); printf( " next: %p\n", (void*)w->next ); printf( " sx: %d, sy: %d\n", w->sx, w->sy ); printf( " rows: %d, width: %d\n", w->rows, w->width ); printf( " hscroll_column: %d\n", w->hscroll_column ); printf( " buffer: %p\n", (void*)w->buffer ); printf( " trashed: %d\n", w->trashed ); printf( " flags: %d\n", w->flags ); } /************************************ * printGtkSubWin * * group: win, debug * * * debug print: "sw(GtkSubWinType): %p\n", sw * * ************************************/ void printGtkSubWin( GtkSubWinType *sw ) { printf( "GtkSubWinType: %p\n", (void*)sw ); printJedWin( sw->jedWin ); printf( " Next: %p\n", (void*)sw->next ); printf( " EdWidget: %p\n", (void*)sw->edWin ); printf( " Win: %p\n", (void*)sw->edWin->window ); printf( " Height: %d\n", sw->edWin->allocation.height ); printf( " Width: %d\n", sw->edWin->allocation.width ); printf( " StWidget: %p\n", (void*)sw->stWin ); printf( " Win: %p\n", (void*)sw->stWin->window ); printf( " Height: %d\n", sw->stWin->allocation.height ); printf( " Width: %d\n", sw->stWin->allocation.width ); printf( " SbWidget: %p\n", (void*)sw->sbWin ); printf( " SbAdj: %p\n", (void*)sw->sbAdj ); printf( " ppY: %d, ppX: %d\n", sw->ppY, sw->ppX ); printf( " ppHeight: %d, ppWidth: %d\n", sw->ppHeight, sw->ppWidth ); } /************************************ * modLineWidgetWinXRef * * debug print: "dArr(GtkSubWinType ***): %p, sArr(GtkSubWinType ***): %p, x: %d, y: %d, w: %d, source: %d", dArr, sArr, x, y, w, source * ************************************/ static void modLineWidgetWinXRef( GtkSubWinType ***dArr, GtkSubWinType ***sArr, int x, int y, int w, int source ) { int i; for ( i = 0; i < w; ++i ) dArr[y][x + i] = sArr[source][x + i]; /* printWidgetWinXRef(); */ /* printSubWins(); */ } /************************************ * updEdWidgetWinXRef * * group: win * * debug print: "WV: %p, y: %d, x: %d\n", wv, y, x * ************************************/ void jgtk_updEdWidgetWinXRef( Window_Type *wv, int y, int h ) { int m; /* GtkWidget *w = ( GtkWidget * ) wv->window; */ JGtkWinType *win = JGtkWin; GtkSubWinType *sw = win->subWins; do { if ( sw->jedWin == wv ) { break; } sw = sw->next; } while ( sw != win->subWins ); modWidgetWinXRef( win->widgetWinXRef, sw, 0, y, win->edWidth, h ); /*********** printWidgetWinXRef(); printSubWins(); *************/ } /************************************ * modWidgetWinXRef * * group: debug * * debug print: "a(GtkSubWinType ***): %p, val: %p, x: %d, y: %d, w: %d, h: %d\n", a, val, x, y, w, h * ************************************/ static void modWidgetWinXRef( GtkSubWinType ***a, GtkSubWinType *val, int x, int y, int w, int h ) { int i, i1; for ( i = 0; i < h; ++i ) for ( i1 = 0; i1 < w; ++i1 ) { a[y + i][x + i1] = val; } /* printWidgetWinXRef(); */ /* printSubWins(); */ } /************************************ * adjustSubWinPanes * * debug print: * ************************************/ static void adjustSubWinPanes(void) { /* int i = 0; */ int gutPos, accumHeight; JGtkWinType *win = JGtkWin; GtkSubWinType *sw = win->subWins, *savSW, *oldSW; GtkWidget *parBox, *parPane, *actPane; oldSW = sw; sw = sw->next; if ( gtk_widget_get_parent( sw->stWin ) != win->appWTopEdWin ) { parBox = gtk_widget_get_parent( sw->stWin ); /* Dbp2( "SW: %p, ParBox: %p\n", sw, parBox ); */ actPane = gtk_widget_get_parent( parBox ); gutPos = ( oldSW->jedWin->rows + 1 ) * win->fontHeight; accumHeight = gutPos + win->gutSize; gtk_paned_set_position( GTK_PANED( gtk_widget_get_parent( parBox ) ), gutPos ); savSW = sw; oldSW = sw; sw = sw->next; if ( sw != win->subWins ) do { parBox = gtk_widget_get_parent( sw->stWin ); parPane = gtk_widget_get_parent( parBox ); gutPos = accumHeight + ( oldSW->jedWin->rows + 1 ) * win->fontHeight; gtk_paned_set_position( GTK_PANED( parPane ), gutPos ); accumHeight = gutPos + win->gutSize; savSW = sw; parBox = gtk_widget_get_parent( sw->next->stWin ); oldSW = sw; sw = sw->next; } while ( sw != win->subWins ); } } /************************************ * jGtkCheckEdSize * * Resizes widgetWinXRef if necessary to height, width * * group: win * * debug print: "Height: %d, Width: %d\n", height, width * ************************************/ void jGtkCheckEdSize( int height, int width ) { int n, m; int cpyOld; JGtkWinType *win = JGtkWin; int newHeight = height > win->maxEdHeight ? height : win->maxEdHeight; int newWidth = width > win->maxEdWidth ? width : win->maxEdWidth; GtkSubWinType ***newEdLines; GtkSubWinType **tmpLine; /* printSubWins(); */ if ( ! ( height && width && win->edWidth && win->edHeight ) ) return; if ( width > win->maxEdWidth ) { /* Dbp1( "Window width (%d) bigger maxEdWidth!!!\n", width ); */ if ( height > win->maxEdHeight ) { /* Dbp1( "Creating new edbuffer\n", 1 ); */ newEdLines = ( GtkSubWinType *** ) SLmalloc( sizeof( GtkSubWinType ** ) * width ); } else { newEdLines = win->widgetWinXRef; } /* if height smaller than win->edHeight backup copy lines of last window */ /* below win->edHeight border. Should the lower border be part of different */ /* window, function calling this function will do one_window-call!!! */ if ( height < win->edHeight ) { for ( m = 0; m < win->edWidth; ++m ) { win->widgetWinXRef[height - 1][m] = win->widgetWinXRef[win->edWidth - 1][m]; } win->edHeight = height; } /* if height smaller than win->maxEdHeight simply create some new buffer lines */ /* without copying anything. */ for ( n = newHeight - 1; n > height; --n ) { tmpLine = ( GtkSubWinType ** ) SLmalloc( sizeof( GtkSubWinType * ) * width ); SLfree( ( char * ) win->widgetWinXRef[n] ); win->widgetWinXRef[n] = tmpLine; } for ( n = height - 1; n >= 0; --n ) { tmpLine = ( GtkSubWinType ** ) SLmalloc( sizeof( GtkSubWinType * ) * width ); cpyOld = n; if ( n == height - 1 ) cpyOld = win->edHeight - 1; else if ( win->edHeight > 1 && win->edHeight - 2 <= n && n <= height - 2 ) cpyOld = win->edHeight - 2; else cpyOld = n; for ( m = 0; m < width; ++m ) { tmpLine[m] = m < win->edWidth ? win->widgetWinXRef[cpyOld][m] : win->widgetWinXRef[cpyOld][win->edWidth - 1]; } if ( n < win->maxEdHeight ) SLfree( ( char * ) win->widgetWinXRef[n] ); newEdLines[n] = tmpLine; } SLfree( ( char * ) win->widgetWinXRef ); win->widgetWinXRef = newEdLines; } else if ( height > win->maxEdHeight ) { /* Dbp1( "Window height (%d) greater maxEdHeight\n", height ); */ newEdLines = ( GtkSubWinType *** ) SLmalloc( sizeof( GtkSubWinType ** ) * newHeight ); for ( n = height - 1; n >= 0; --n ) { if ( n >= win->maxEdHeight ) tmpLine = ( GtkSubWinType ** ) SLmalloc( sizeof( GtkSubWinType * ) * newWidth ); else tmpLine = win->widgetWinXRef[n]; if ( n == height - 1 ) cpyOld = win->edHeight - 1; else if ( win->edHeight > 1 && win->edHeight - 2 <= n && n <= height - 2 ) cpyOld = win->edHeight - 2; else cpyOld = n; if ( win->edWidth ) for ( m = 0; m < width; ++m ) { tmpLine[m] = m < win->edWidth ? win->widgetWinXRef[cpyOld][m] : win->widgetWinXRef[cpyOld][win->edWidth - 1]; } /* if ( n < win->maxEdHeight ) SLfree( win->widgetWinXRef[n] ); */ newEdLines[n] = tmpLine; } SLfree( ( char * ) win->widgetWinXRef ); win->widgetWinXRef = newEdLines; } win->maxEdWidth = newWidth; win->maxEdHeight = newHeight; win->edWidth = width; win->edHeight = height; /* Dbp( "Win->edWidth: %d\n", win->edWidth ); */ /* Dbp( "Win->edHeight: %d\n", win->edHeight ); */ /* printWidgetWinXRef(); */ } /************************************ * jGtkWidenEd * * debug print: * ************************************/ void jGtkWidenEd( int height, int newW, int oldW ) { int i, i1, n = oldW - 1; GtkSubWinType ***img = JGtkWin->widgetWinXRef; for ( i = 0; i < height; ++i ) for ( i1 = oldW; i1 < newW; ++i1 ) { img[i][i1] = img[i][n]; } } /************************************ * updateWidgetWinXRef * * Overwrites widgetWinXRef with sw for new sy, sx, nHeight, nWidth * sets subWinParameter sx, sy, width, height accordingly * * group: win * * debug print: "sw: %p, sy: %d, sx: %d, nHeight: %d, nWidth: %d\n", sw, sy, sx, nHeight, nWidth * ************************************/ void updateWidgetWinXRef( GtkSubWinType *sw, int sy, int sx, int nHeight, int nWidth ) { int i, i1; int minY, maxY; JGtkWinType *win = JGtkWin; /********* Dbp1( "--%d-------------------------------------------------\n", 1 ); printWidgetWinXRef(); printSubWins(); Dbp1( "--%d-------------------------------------------------\n", 1 ); *********/ /* printGtkSubWin( sw ); */ if ( sy > sw->jedWin->sy + sw->jedWin->rows || sy + nHeight < sw->jedWin->sy || sx > sw->jedWin->sx + sw->jedWin->width || sx + nWidth < sw->jedWin->sx ) { /* Dbp( "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n", 1 ); */ for ( i = sy; i < sy + nHeight; ++i ) { /* Dbp( "i: %d\n", i ); */ for ( i1 = sx; i1 < sx + nWidth; ++i1 ) { /* Dbp( "i1: %d\n", i1 ); */ win->widgetWinXRef[i][i1] = sw; } } } else { for ( i = sy; i < sw->jedWin->sy; ++i ) { /* Dbp( "i: %d\n", i ); */ for ( i1 = sx; i1 < sx + nWidth; ++i1 ) { /* Dbp( "i1: %d\n", i1 ); */ win->widgetWinXRef[i][i1] = sw; } } minY = sy < sw->jedWin->sy ? sw->jedWin->sy : sy; maxY = sy + nHeight < sw->jedWin->sy + sw->jedWin->rows + 1 ? sy + nHeight : sw->jedWin->sy + sw->jedWin->rows + 1; /* Dbp( "Min Y: %d\n", minY ); */ /* Dbp( "Max Y: %d\n", maxY ); */ for ( i = minY; i < maxY; ++i ) { /* Dbp( "i: %d\n", i ); */ for ( i1 = sx; i1 < sw->jedWin->sx; ++i1 ) { /* Dbp( "i1: %d\n", i1 ); */ win->widgetWinXRef[i][i1] = sw; } for ( i1 = sw->jedWin->sx + sw->jedWin->width; i1 < sx + nWidth; ++i1 ) { /* Dbp( "i1: %d\n", i1 ); */ win->widgetWinXRef[i][i1] = sw; } } for ( i = sw->jedWin->sy + sw->jedWin->rows + 1; i < sy + nHeight; ++i ) { /* Dbp( "i: %d\n", i ); */ for ( i1 = sx; i1 < sx + nWidth; ++i1 ) { /* Dbp( "i1: %d\n", i1 ); */ win->widgetWinXRef[i][i1] = sw; } } } sw->jedWin->sy = sy; sw->jedWin->sx = sx; sw->jedWin->rows = nHeight - 1; sw->jedWin->width = nWidth; /********** Dbp1( "==%d==========================================\n", 2 ); printWidgetWinXRef(); printSubWins(); Dbp1( "==%d==========================================\n", 2 ); *******/ /* printGtkSubWin( sw ); */ } void jgtk_updMiniWinWidgetWinXRef( int n ) { int i = Jed_Num_Screen_Cols - 1; JGtkWinType *win = JGtkWin; for ( ; i >= 0; --i ) { win->widgetWinXRef[n][i] = win->miniWinSW; } } /************************************ * splitEdWin * * group: win * * * debug print: "Widget (wv): %p, sy: %d, sx: %d, height: %d, scroll: %d, width: %d\n", wv, sy, sx, height, scroll, width * ************************************/ void jgtk_splitEdWin( Window_Type *wv, Window_Type *newJedW, int sy, int sx, int height, int scroll, int width ) { int n, m; int isFirstPane = 1; JGtkWinType *win = JGtkWin; GtkWidget *wEd = win->widgetWinXRef[sy][sx]->edWin; GtkWidget *wSt = win->widgetWinXRef[sy + height][sx]->stWin; GtkWidget *curEdBox = gtk_widget_get_parent( gtk_widget_get_parent( wEd ) ); GtkWidget *parW = gtk_widget_get_parent( curEdBox ); GtkWidget *newPaned = gtk_vpaned_new(); GtkSubWinType *sw, *newSW = createGtkWinTmpl( ( GtkSubWinType * ) SLmalloc( sizeof( GtkSubWinType ) ) ); /* EdWinWidgetType newW = createGtkWinTmpl( newSW ); */ GtkWidget *edBox = gtk_widget_get_parent( gtk_widget_get_parent( newSW->edWin ) ); newSW->edX = newSW->edY = newSW->edHeight = newSW->edWidth = 0; /************ printWidgetWinXRef(); printSubWins(); ********/ g_signal_connect( G_OBJECT( newPaned ), "button_press_event", G_CALLBACK( eventCallback ), NULL ); g_signal_connect( G_OBJECT( newPaned ), "button_release_event", G_CALLBACK( eventCallback ), NULL ); /* Dbp2( "win->gutSize: %d, win->numWin: %d\n", win->gutSize, win->numWin ); */ if ( !win->gutSize && win->subWins != win->subWins->next ) { GtkWidget *topPaned = win->appWTopEdWin; win->gutSize = topPaned->allocation.height - gtk_paned_get_child1( GTK_PANED( topPaned ) )->allocation.height - gtk_paned_get_child2( GTK_PANED( topPaned ) )->allocation.height; /* Dbp1( "Guttersize: %d\n", win->gutSize ); */ } /* printWidgetStruct(); */ updateGtkWin = 0; /********************************************* * Currently, as of gtk+ version 2.12.0 there is * no function to return the gutter size. So * we have to compute them ourself. *********************************************/ if ( curEdBox != win->appWTopEdWin ) { isFirstPane = ( curEdBox == gtk_paned_get_child1( GTK_PANED( parW ) ) ); } /********* gtk_paned_add1( GTK_PANED( newPaned ), curEdBox ); g_object_unref( curEdBox ); ***********/ gtk_paned_add2( GTK_PANED( newPaned ), edBox ); if ( isFirstPane ) /* also true for curEdBox == win->appWTopEdWin */ { g_object_ref( curEdBox ); gtk_container_remove( GTK_CONTAINER( parW ), curEdBox ); gtk_paned_add1( GTK_PANED( newPaned ), curEdBox ); g_object_unref( curEdBox ); if ( curEdBox == win->appWTopEdWin ) { gtk_box_pack_start( GTK_BOX( win->appWInGrid ), newPaned, True, True, 0 ); win->appWTopEdWin = newPaned; /* Dbp4( "Splitting top window: old: %p, newBox: %p, new.ed: %p, new.status: %p\n", curEdBox, edBox, newW.ed, newW.st ); */ } else { gtk_paned_add1( GTK_PANED( parW ), newPaned ); /* Dbp2( "Splitting first pane: old: %p, new: %p\n", curEdBox, edBox ); */ } } else { GtkWidget *gParW = gtk_widget_get_parent( parW ); /* Db; */ if ( parW != win->appWTopEdWin ) { isFirstPane = ( parW == gtk_paned_get_child1( GTK_PANED( gParW ) ) ); } /* Db; */ g_object_ref( parW ); gtk_container_remove( GTK_CONTAINER( gParW ), parW ); gtk_paned_add1( GTK_PANED( newPaned ), parW ); g_object_unref( parW ); /* Db; */ if ( parW == win->appWTopEdWin ) { gtk_box_pack_start( GTK_BOX( win->appWInGrid ), newPaned, True, True, 0 ); win->appWTopEdWin = newPaned; } else { gtk_paned_add1( GTK_PANED( gParW ), newPaned ); } } /******* Db; printWidgetStruct(); **********/ sw = win->subWins; do { if ( sw->jedWin == wv ) { break; } sw = sw->next; } while ( sw != win->subWins ); newSW->jedWin = newJedW; /* newSW->edWin = newW.ed; */ /* newSW->stWin = newW.st; */ /* newSW->sbWin = newW.sb; */ newSW->sbAdj = gtk_range_get_adjustment( GTK_RANGE( newSW->sbWin ) ); newSW->numLineSav = newSW->curLineSav = newSW->winHeightSav = 0; newSW->ppHeight = 0; newSW->next = sw->next; sw->next = newSW; win->numWin++; /************ gtk_widget_show_all( win->appWTopEdWin ); if ( gtk_events_pending() ) { gtk_main_iteration(); } *****************/ /********/ /* Db; */ /* printWidgetStruct(); */ /**************/ modWidgetWinXRef( win->widgetWinXRef, newSW, sx, sy, width, height + 1 ); /***** printf( "vvvvvv111111111111111111111111111111111111111111111111111111vvvvvv\n" ); printWidgetWinXRef(); printSubWins(); printf( "^^^^^^111111111111111111111111111111111111111111111111111111^^^^^^\n" ); ******/ /* Db; */ adjustSubWinPanes(); /* gtk_widget_show_all( parW ); */ /* gtk_widget_show_all( newPaned ); */ gtk_widget_grab_focus( newSW->edWin ); /********* Db; printWidgetStruct(); ************/ /*******/ /* printf( "vvvvvv2222222222222222222222222222222222222222222222222222222vvvvvv\n" ); */ /* updateInGridHeight(); */ /* printf( "^^^^^^2222222222222222222222222222222222222222222222222222222^^^^^^\n" ); */ /*****/ /*********** Db; printWidgetStruct(); **********/ /* adjustSubWinPanes(); */ updateGtkWin = 1; gtk_widget_show_all( win->appWTopEdWin ); jGtkSetFGBGColor( newSW->edWin, JNORMAL_COLOR ); jGtkSetFGBGColor( newSW->stWin, JNORMAL_COLOR ); } /************************************ * updOWEdWin * * group: win * * debug print: "WV: %p, nsy: %d, nsx: %d, nheight: %d, nwidth: %d\n", wv, nsy, nsx, nheight, nwidth * ************************************/ void jgtk_updOWEdWin( Window_Type *wv, int nsy, int nsx, int nheight, int nwidth ) { int n, m; JGtkWinType *win = JGtkWin; GtkSubWinType *winList = win->subWins; GtkWidget *actEdWin = win->widgetWinXRef[wv->sy][wv->sx]->edWin; GtkWidget *ow = gtk_widget_get_parent( gtk_widget_get_parent( actEdWin ) ); GtkWidget *parOW = gtk_widget_get_parent( ow ); /* GtkWidget *childOW = gtk_paned_get_child2( GTK_PANED( ow ) ); */ GtkSubWinType *sw, *owSW, *delSW; /* printf( "updOWEdWin: ow: %p\n", ow ); */ /* if ( childOW ) gtk_widget_destroy( childOW ); */ /* Updating list of subWins ************/ sw = win->subWins; do { if ( sw->jedWin == wv ) { owSW = sw; sw = sw->next; } else { delSW = sw; sw = sw->next; SLfree( ( char * ) delSW ); } } while ( sw != win->subWins ); owSW->ppHeight = 0; owSW->next = owSW; win->subWins = owSW; win->numWin = 1; /* Updating widgetWinXRef **************/ modWidgetWinXRef( win->widgetWinXRef, owSW, nsx, nsy, nwidth, nheight ); /************** for ( m = 0; m <= nheight; ++m ) for ( n = 0; n < nwidth; ++n ) win->widgetWinXRef[nsy + m][nsx + n] = owSW; ***************/ if ( ow != win->appWTopEdWin ) { /* printf( "Removing one window from pane: %p\n", parOW ); */ updateGtkWin = 0; g_object_ref( ow ); gtk_container_remove( GTK_CONTAINER( parOW ), ow ); gtk_widget_destroy( win->appWTopEdWin ); win->appWTopEdWin = ow; gtk_box_pack_start( GTK_BOX( win->appWInGrid ), ow, True, True, 0 ); g_object_unref( ow ); gtk_widget_show_all( win->appWTopEdWin ); gtk_widget_grab_focus( actEdWin ); updateGtkWin = 1; } /********** printf( "(updOWEdWin): -----vvv---------------\n" ); printWidgetWinXRef(); printf( "(updOWEdWin): -----^^^---------------\n" ); ********/ } /************************************ * createTopEdWin * * group: win * * * debug print: "w: %p, sy: %d, sx: %d, height: %d, scroll: %d, width: %d\n", w, sy, sx, height, scroll, width * ************************************/ void jgtk_createTopEdWin( Window_Type *w, int sy, int sx, int height, int scroll, int width ) { int n, m; JGtkWinType *win = JGtkWin; GtkSubWinType *newSW = createGtkWinTmpl( ( GtkSubWinType * ) SLmalloc( sizeof( GtkSubWinType ) ) ); newSW->next = newSW; newSW->jedWin = w; newSW->sbAdj = gtk_range_get_adjustment( GTK_RANGE( newSW->sbWin ) ); newSW->numLineSav = newSW->curLineSav = newSW->winHeightSav = 0; newSW->ppHeight = 0; win->subWins = newSW; jGtkCheckEdSize( win->edHeight + sy + height + 1, sx + width ); if ( win->appWMiniW ) { modLineWidgetWinXRef( win->widgetWinXRef, win->widgetWinXRef, 0, win->edHeight + sy + height, sx + width, 0 ); } if ( win->appWTopEdWin ) { gtk_widget_destroy( win->appWTopEdWin ); } win->appWTopEdWin = gtk_widget_get_parent( gtk_widget_get_parent( newSW->edWin ) ); gtk_box_pack_start( GTK_BOX( win->appWInGrid ), win->appWTopEdWin, True, True, 0 ); /* printf( "createTopEdWin: newDrawArea: %p\n", win->appWTopEdWin ); */ modWidgetWinXRef( win->widgetWinXRef, newSW, sx, sy, width, height + 1 ); #if 0 for ( m = 0; m <= height; ++m ) for ( n = 0; n < width; ++n ) { /* printf( "Height: %d, width: %d, n: %d, sy: %d, sx: %d\n", height, width, n, sy, sx ); */ /* printf( "win->widgetWinXRef: %p\n", win->widgetWinXRef ); */ win->widgetWinXRef[sy + m][sx + n] = newSW; } #endif /* Db; */ /* printWidgetWinXRef(); */ gtk_widget_show_all( win->appWTopEdWin ); gtk_widget_grab_focus( newSW->edWin ); jGtkSetFGBGColor( newSW->edWin, JNORMAL_COLOR ); jGtkSetFGBGColor( newSW->stWin, JNORMAL_COLOR ); /* Db; */ /* printWidgetWinXRef(); */ } /************************************ * delEdWin * * group: win * * * debug print: "WV: %p, SubW: %p, sy: %d, sx: %d, height: %d, width: %d, lastLine: %d\n", wv, subW, sy, sx, height, width, lastLine * ************************************/ void jgtk_delEdWin( Window_Type *wv, Window_Type *subW, int sy, int sx, int height, int width, int lastLine ) { int m, n; int isFirstPane; JGtkWinType *win = JGtkWin; /* GtkWidget *w = ( GtkWidget * ) wv->window; */ GtkWidget *wBox = gtk_widget_get_parent( gtk_widget_get_parent( win->widgetWinXRef[wv->sy][wv->sx]->edWin ) ); GtkWidget *parW = gtk_widget_get_parent( wBox ); GtkWidget *gParW; /* Grandparent */ GtkWidget *remW; GtkSubWinType *subWSW = win->widgetWinXRef[subW->sy][subW->sx]; GtkSubWinType *wvSW = win->widgetWinXRef[wv->sy][wv->sx]; GtkSubWinType *sw; if ( wBox == win->appWTopEdWin ) { return; } if ( subW->sy == wv->sy ) { subWSW = win->widgetWinXRef[subW->sy + subW->rows - 1][subW->sx]; } if ( subWSW->next == wvSW ) { subWSW->next = wvSW->next; } else { sw = win->subWins; do { if ( sw->next == wvSW ) break; sw = sw->next; } while ( sw != win->subWins ); sw->next = subWSW; } SLfree( ( char * ) wvSW ); if ( wvSW == win->subWins ) { win->subWins = subWSW; } --win->numWin; modWidgetWinXRef( win->widgetWinXRef, subWSW, sx, sy, width, height ); /*************** for ( n = 0; n < height; ++n ) for ( m = 0; m < width; ++m ) { win->widgetWinXRef[sy + n][sx + m] = subWSW; } ****************/ if ( wv->sy == subW->sy ) { modWidgetWinXRef( win->widgetWinXRef, subWSW, wv->sx, wv->sy + wv->rows, width, 1 ); /**************** for ( m = 0; m < width; ++m ) { win->widgetWinXRef[wv->sy + wv->rows][wv->sx + m] = subWSW; } ******************/ } else { modWidgetWinXRef( win->widgetWinXRef, subWSW, wv->sx, subW->sy + subW->rows, width, 1 ); #if 0 for ( m = 0; m < width; ++m ) { /* win->widgetWinXRef[wv->sy - 1][wv->sx + m].jedWin = subW; */ win->widgetWinXRef[subW->sy + subW->rows][wv->sx + m] = subWSW; } #endif } updateGtkWin = 0; if ( wBox == gtk_paned_get_child1( GTK_PANED( parW ) ) ) { remW = gtk_paned_get_child2( GTK_PANED( parW ) ); } else { remW = gtk_paned_get_child1( GTK_PANED( parW ) ); } g_object_ref( remW ); gtk_container_remove( GTK_CONTAINER( parW ), remW ); if ( parW == win->appWTopEdWin ) { gtk_widget_destroy( parW ); win->appWTopEdWin = remW; gtk_box_pack_start( GTK_BOX( win->appWInGrid ), remW, True, True, 0 ); g_object_unref( remW ); } else { gParW = gtk_widget_get_parent( parW ); isFirstPane = ( parW == gtk_paned_get_child1( GTK_PANED( gParW ) ) ); gtk_widget_destroy( parW ); if ( isFirstPane ) { gtk_paned_add1( GTK_PANED( gParW ), remW ); } else { gtk_paned_add2( GTK_PANED( gParW ), remW ); } } gtk_widget_show_all( remW ); gtk_widget_grab_focus( subWSW->edWin ); updateGtkWin = 1; /****************** printWidgetWinXRef(); ****************/ } /************************************ * createEditorMiniWin * * group: win * * * debug print: "mw(Window_Type): %p\n", mw * * ************************************/ int jgtk_createEditorMiniWin( Window_Type *mw ) { int i; JGtkWinType *win = JGtkWin; GtkWidget *newMiniWin = createGtkMiniWin(); jGtkCheckEdSize( 1, mw->width ); if ( win->appWMiniW ) { gtk_widget_destroy( win->appWMiniW ); } win->appWMiniW = newMiniWin; gtk_widget_set_size_request( win->appWMiniW, -1, win->fontHeight ); gtk_box_pack_start( GTK_BOX( win->appWEdGrid ), newMiniWin, False, False, 0 ); win->edWidth = mw->width; win->edHeight = 1; gtk_widget_show_all( newMiniWin ); gtk_widget_grab_focus( newMiniWin ); win->miniWinSW = ( GtkSubWinType * ) SLmalloc( sizeof( GtkSubWinType ) ); win->miniWinSW->jedWin = mw; win->miniWinSW->next = NULL; win->miniWinSW->edWin = newMiniWin; win->miniWinSW->stWin = newMiniWin; win->miniWinSW->ppHeight = 0; modWidgetWinXRef( win->widgetWinXRef, win->miniWinSW, 0, win->edHeight - 1, win->edWidth, 1 ); for ( i = 0; i < JMAX_COLORS; ++i ) { DefaultGtkGCInfo[i].gc = gdk_gc_new( win->appWMiniW->window ); } /* Db; */ /* printf( "################################################################\n" ); */ /*printWidgetWinXRef(); */ /* printGtkSubWin( sw ); */ /* printf( "################################################################\n" ); */ /* Return( newMiniWin ); */ return 0; } /************************************ * jGtkWinDestroy * * group: app * * * debug print: * * ************************************/ static void jGtkWinDestroy( GtkWidget *widget, gpointer data ) { exit( 0 ); } /************************************ * jGtkSetWinSizes * * debug print: * ************************************/ void jGtkSetWinSizes(void) { JGtkWinType *win = JGtkWin; GtkSubWinType *sw = win->subWins; adjustSubWinPanes(); return; do { /* Dbp1( "Height: %d\n", ( sw->jedWin->rows + 1 ) * win->fontHeight); */ gtk_widget_set_size_request( sw->edWin, -1, sw->jedWin->rows * win->fontHeight ); sw = sw->next; } while ( sw != win->subWins ); } /************************************ * updateHeightOfSubWinStatusWins * * debug print: * ************************************/ static void updateHeightOfSubWinStatusWins(void) { JGtkWinType *win = JGtkWin; GtkSubWinType *sw = win->subWins; if ( sw ) do { gtk_widget_set_size_request( sw->stWin, -1, win->fontHeight ); sw = sw->next; } while ( sw != win->subWins ); if ( win->miniWinSW ) { gtk_widget_set_size_request( win->miniWinSW->edWin, -1, win->fontHeight ); } } /************************************ * loadFont * * debug print: "FontName: |%s|\n", fontName * ************************************/ static void loadFont( char *fontName ) { JGtkWinType *win = JGtkWin; SLfree( win->fontName ); win->fontName = SLmalloc( strlen( fontName ) + 1 ); strcpy( win->fontName, fontName ); win->fontDescription = pango_font_description_from_string( win->fontName ); win->fontMetrics = pango_context_get_metrics( win->fontContext, win->fontDescription, NULL ); win->fontAscent = pango_font_metrics_get_ascent( win->fontMetrics ) / PANGO_SCALE; win->fontDescent = pango_font_metrics_get_descent( win->fontMetrics ) / PANGO_SCALE; /* printf( "Scale: %d; Ascent: %d, Descent: %d\n", PANGO_SCALE, win->fontAscent, win->fontDescent ); */ win->fontHeight = win->fontAscent + win->fontDescent; win->fontWidth = pango_font_metrics_get_approximate_char_width( win->fontMetrics ) / PANGO_SCALE; /* printf( "Scale: %d; charWidth: %d\n", PANGO_SCALE, win->fontWidth ); */ updateHeightOfSubWinStatusWins(); jed_init_display(); jed_redraw_screen( 1 ); } static void jGtkMenuCreateDef( JGtkWinType *win ) { jgtk_initToolbarArray(); jgtk_initMenubarStruct(); if ( !win->appWMenuBar ) { /* Dbp1( "win->appWMenuBar: %p\n", win->appWMenuBar ); */ win->appWMenuBar = gtk_menu_bar_new(); /* Db; */ win->appWMenu = gtk_menu_new(); win->appWMenuItemOpen = gtk_menu_item_new_with_label( "Open" ); win->appWMenuItemSave = gtk_menu_item_new_with_label( "Save" ); win->appWMenuItemClose = gtk_menu_item_new_with_label( "Close" ); gtk_widget_show( win->appWMenuItemOpen ); gtk_widget_show( win->appWMenuItemSave ); gtk_widget_show( win->appWMenuItemClose ); gtk_menu_shell_append( GTK_MENU_SHELL( win->appWMenu ), win->appWMenuItemOpen ); gtk_menu_shell_append( GTK_MENU_SHELL( win->appWMenu ), win->appWMenuItemSave ); gtk_menu_shell_append( GTK_MENU_SHELL( win->appWMenu ), win->appWMenuItemClose ); win->appWMenuItem = gtk_menu_item_new_with_label( "File" ); gtk_menu_item_set_submenu( GTK_MENU_ITEM( win->appWMenuItem ), win->appWMenu ); gtk_menu_bar_append( GTK_MENU_BAR( win->appWMenuBar ), win->appWMenuItem ); } gtk_widget_show_all( win->appWMenuBar ); } /************************************ * createGtkMainWindow * * group: win * * * debug print: "(void)" * * ************************************/ static void createGtkMainWindow(void) { GtkWidget *tmpFrame; JGtkWinType *win = JGtkWin; GdkColor white = { 0, 0xffff, 0xffff, 0xffff }; /******** GParamSpec *param = g_param_spec_int( "testval", "testing", "test test test", -10, 1000, 0, G_PARAM_READABLE ); GValue val; ******/ win->appW = gtk_window_new( GTK_WINDOW_TOPLEVEL ); /********* gtk_widget_class_install_style_property( GTK_WIDGET_CLASS( G_OBJECT_GET_CLASS( win->appW ) ), param ); gtk_rc_parse( "/root/.gtkjed" ); g_value_init( &val, G_PARAM_SPEC_VALUE_TYPE( param ) ); gtk_widget_style_get_property( win->appW, "testval", &val ); Dbp1( "Value: %d\n", g_value_get_int( &val ) ); ***********/ gtk_window_set_default_size( GTK_WINDOW( win->appW ), 100, 300 ); g_signal_connect( G_OBJECT( win->appW ), "destroy", G_CALLBACK( jGtkWinDestroy ), NULL ); win->appWGrid = gtk_vbox_new( False, 0 ); win->appWMenuBar = NULL; jGtkMenuCreateDef( win ); gtk_box_pack_start( GTK_BOX( win->appWGrid ), win->appWMenuBar, False, False, 0 ); win->appWTbGrid = gtk_vbox_new( False, 0 ); gtk_box_pack_start( GTK_BOX( win->appWGrid ), win->appWTbGrid, False, False, 0 ); win->appWEdGrid = gtk_vbox_new( False, 0 ); gtk_box_pack_start( GTK_BOX( win->appWGrid ), win->appWEdGrid, True, True, 0 ); g_signal_connect( G_OBJECT( win->appWEdGrid ), "configure_event", G_CALLBACK( eventCallback ), NULL ); win->widgetWinXRef = NULL; win->appWInGrid = gtk_vbox_new( False, 0 ); gtk_box_pack_start( GTK_BOX( win->appWEdGrid ), win->appWInGrid, True, True, 0 ); win->appWASCMenu = win->appWTopEdWin = win->appWMiniW = NULL; win->appWSB = gtk_statusbar_new(); gtk_widget_add_events( win->appWSB, GDK_KEY_PRESS_MASK ); gtk_box_pack_start( GTK_BOX( win->appWGrid ), win->appWSB, False, True, 0 ); gtk_container_add( GTK_CONTAINER( win->appW ), win->appWGrid ); win->fontContext = gtk_widget_create_pango_context( win->appWSB ); win->fontDescription = pango_font_description_from_string( win->fontName ); win->fontMetrics = pango_context_get_metrics( win->fontContext, win->fontDescription, NULL ); win->fontAscent = pango_font_metrics_get_ascent( win->fontMetrics ) / PANGO_SCALE; win->fontDescent = pango_font_metrics_get_descent( win->fontMetrics ) / PANGO_SCALE; win->fontHeight = win->fontAscent + win->fontDescent; win->fontWidth = pango_font_metrics_get_approximate_char_width( win->fontMetrics ) / PANGO_SCALE; gtk_widget_show_all( win->appW ); } /************************************ * getEdWinFromJedWin * * group: win * * * debug print: "Window_Type: %p\n", jWin * * ************************************/ static GtkWidget * getEdWinFromJedWin( Window_Type *jWin ) { GtkSubWinType *edWin = JGtkWin->subWins; do { if ( edWin->jedWin == jWin ) return( edWin->edWin ); edWin = edWin->next; } while ( edWin != JGtkWin->subWins ); return( NULL ); } /************************************ * getGtkSubWinFromRange * * group: scroll * * * debug print: "Range: %p\n", r * ************************************/ static GtkSubWinType * getGtkSubWinFromRange( GtkRange *r ) { GtkSubWinType *sb = JGtkWin->subWins; do { if ( sb->sbWin == ( GtkWidget * ) r ) return( sb ); sb = sb->next; } while ( sb != JGtkWin->subWins ); return( JGtkWin->subWins ); } /* Shamelessly stolen from emacsmsc.sl */ /************************************ * jGtkScrollUpN * * group: scroll * * * debug print: * * ************************************/ static void jGtkScrollUpN( int n ) { int i = window_line(); if ( jed_up( n ) ) recenter( &i ) ; bol(); /* Return( 1 ); */ } /************************************ * jGtkScrollDownN * * group: scroll * * * debug print: * * ************************************/ static int jGtkScrollDownN( int n ) { int i = window_line(); if ( jed_down( n ) ) recenter( &i ); bol(); return 0; } /************************************ * jGtkScrollUp * * group: scroll * * * debug print: * * ************************************/ static void jGtkScrollUp( void ) { int i = window_line(); if ( jed_up( 1 ) ) recenter( &i ); bol(); /* Return( 1 ); */ } /************************************ * jGtkScrollDown * * group: scroll * * * debug print: * * ************************************/ static int jGtkScrollDown( void ) { int i = window_line(); if ( jed_down( 1 ) ) recenter( &i ); bol(); return 0; } /************************************ * jGtkDiffTime * * group: scroll * * * debug print: * * ************************************/ static long jGtkDiffTime( struct timeval *st ) { struct timeval ct; long diff; gettimeofday( &ct, NULL ); /******* printf( "ct.tv_sec: %ld, ct.tv_usec: %ld, st->tv_sec: %ld, st->tv_usec: %ld\n", ct.tv_sec, ct.tv_usec, st->tv_sec, st->tv_usec ); ***************/ diff = ( 1000000 * ( ct.tv_sec - st->tv_sec ) + ( long ) ct.tv_usec - ( long ) st->tv_usec ) / 1000; /* Dbp1( "Diff: %d\n", diff ); */ return( diff ); } static void fcSBGotoLine( gpointer ); /************************************ * jGtkGotoLine * * group: scroll * * * debug print: * * ************************************/ static void jGtkGotoLine(void) { if ( jGtkSIPrim.set ) { /* The delay ( curr: 30 ) should sometime be configurable from Jed/slang */ if ( jGtkDiffTime( &jGtkSIPrim.tv ) > 30 ) { gettimeofday( &jGtkSIPrim.tv, NULL ); /* Dbp1( "jGtkSIPrim.tl: %d\n", jGtkSIPrim.tl ); */ if ( LineNum < (unsigned int) jGtkSIPrim.tl ) { if ( jGtkSIPrim.sLSBeg > 0 ) { jGtkScrollDown(); jGtkSIPrim.sLSBeg--; /* Dbp( "jGtkSIPrim.sLS: %d\n", jGtkSIPrim.sLS ); */ } else { int jumpLines = jGtkSIPrim.tl - LineNum - jGtkSIPrim.sLSEnd; if ( jumpLines > 0 ) { jGtkScrollDownN( jumpLines ); jGtkSIPrim.sLSBeg = jGtkSIPrim.sLSEnd; } else { jGtkSIPrim.sLSBeg = jGtkSIPrim.tl - LineNum; } } } else { if ( LineNum > (unsigned int) jGtkSIPrim.tl ) { if ( jGtkSIPrim.sLSBeg > 0 ) { jGtkScrollUp(); jGtkSIPrim.sLSBeg--; /* Dbp( "jGtkSIPrim.sLS: %d\n", jGtkSIPrim.sLS ); */ } else { int jumpLines = LineNum - jGtkSIPrim.tl - jGtkSIPrim.sLSEnd; if ( jumpLines > 0 ) { jGtkScrollUpN( jumpLines ); jGtkSIPrim.sLSBeg = jGtkSIPrim.sLSEnd; } else { jGtkSIPrim.sLSBeg = LineNum - jGtkSIPrim.tl; } } } } } if ( LineNum == (unsigned int) jGtkSIPrim.tl ) { if ( jGtkSISec.set ) { jGtkSIPrim = jGtkSISec; gettimeofday( &jGtkSIPrim.tv, NULL ); jGtkSISec.set = 0; } else { jGtkSIPrim.set = 0; } } if ( (unsigned int) jGtkSIPrim.tl != LineNum && jGtkSIPrim.set ) { jgtk_createKeyEvents( SLang_process_keystring( FC_CMD_KEY_SEQ ) ); actParaData = ( gpointer ) NULL; actFunToCall = fcSBGotoLine; } } } /************************************ * fcSBGotoLine * * group: scroll * * * debug print: "data: %p\n", data * * ************************************/ static void fcSBGotoLine( gpointer data ) { /* GtkRange *sbRange = ( GtkRange * ) data; */ GtkRange *sbRange = ( GtkRange * ) jGtkSIPrim.rangeW; int actLine = ( int ) actSBVal; GtkSubWinType *subWin = getGtkSubWinFromRange( sbRange ); Window_Type *actWin = JWindow; if ( subWin->jedWin != JWindow ) { do { other_window(); } while ( JWindow != subWin->jedWin && JWindow != actWin ); } /* goto_line( &actLine ); */ jGtkGotoLine(); if ( JWindow != actWin ) { do { other_window(); } while ( JWindow != actWin ); } update( NULL, 1, 0, 0 ); } /************************************ * jGtkFillScrollInfoStruct * * group: scroll * * * debug print: * * ************************************/ static void jGtkFillScrollInfoStruct( JGtkScrollInfo *si, GtkRange *w, gdouble val ) { /* struct timezone tz; */ GtkSubWinType *sw = getGtkSubWinFromRange( w ); si->set = 1; si->tl = val; /* - sw->jedWin->rows * val / Max_LineNum; */ si->tl = si->tl < 1 ? 1 : ( si->tl > (int)Max_LineNum ? (int)Max_LineNum : si->tl ); /* Dbp1( "si->tl: %d\n", si->tl ); */ si->rangeW = w; /* The value of 10 should sometime be configurable form Jed/slang */ si->sLSBeg = si->sLSEnd = sw->jedWin->rows > 10 ? 10 : sw->jedWin->rows; si->jF = 0; si->cnt = JGTK_SCROLL_SLOW_DOWN; gettimeofday( &si->tv, NULL ); } /************************************ * jGtkFillScrollInfo * * group: scroll * * * debug print: * * ************************************/ static void jGtkFillScrollInfo( GtkRange *w, gdouble val ) { if ( jGtkSIPrim.set ) { jGtkSIPrim.jF = 1; jGtkFillScrollInfoStruct( &jGtkSISec, w, val ); } else { jGtkFillScrollInfoStruct( &jGtkSIPrim, w, val ); } } /************************************ * sbChangeValue * * group: scroll * * * debug print: "GtkRange: %p, GtkStrollType: %d, val: %f, ud(gpointer): %p\n", w, st, val, ud * * ************************************/ static gboolean sbChangeValue( GtkRange *w, GtkScrollType st, gdouble val, gpointer ud ) { /* Dbp1( "Value: %f\n", ( float ) val ); */ actSBVal = val; val = val < 1 ? 1 : ( val > gtk_range_get_adjustment( w )->upper ? gtk_range_get_adjustment( w )->upper + 1 : val + 1 ); jgtk_createKeyEvents( SLang_process_keystring( FC_CMD_KEY_SEQ ) ); /* Dbp1( "val: %f\n", val ); */ jGtkFillScrollInfo( w, val ); actParaData = ( gpointer ) w; actFunToCall = fcSBGotoLine; return( True ); } #if 0 static int checkIfSizeChanged( GdkEventConfigure *ev ) { JGtkWinType *win = JGtkWin; GtkSubWinType *sw = win->subWins; do { if ( sw->edWin->window == ev->window ) { /******** if ( ev->x == sw->edX && ev->y == sw->edY && ev->width == sw->edWidth && ev->height == sw->edHeight ) *******/ /*******/ if ( sw->edWin->allocation.x == sw->edX && sw->edWin->allocation.y == sw->edY && sw->edWin->allocation.width == sw->edWidth && sw->edWin->allocation.height == sw->edHeight ) /*********/ { return( False ); } else { /*******/ sw->edX = sw->edWin->allocation.x; sw->edY = sw->edWin->allocation.y; sw->edWidth = sw->edWin->allocation.width; sw->edHeight = sw->edWin->allocation.height; /************/ /******** sw->edX = ev->x; sw->edY = ev->y; sw->edWidth = ev->width; sw->edHeight = ev->height; ********/ return( True ); } } sw = sw->next; } while ( sw != win->subWins ); return( True ); } #endif /************************************ * eventCallback * * group: event * * * debug print: * * ************************************/ static gboolean eventCallback( GtkWidget *w, GdkEvent *ev, gpointer *data ) { static int dragPaned; static GtkSubWinType *paneWin1, *paneWin2; Window_Type *jWin; int tmpInt; GtkSubWinType *actWin = ( GtkSubWinType * ) data; JGtkWinType *win = JGtkWin; int block_expose = 0; static int doNoEvents; /* printf( "EventCallback: %s, %d\n", __FILE__, __LINE__ ); */ /* printf( " Length of queue: %d\n", thisEventBuffer->numGtkEv ); */ /* printf( "Window: %p\n", win ); */ /* printf( "Windows: %p\n", win->subWins ); */ if ( doNoEvents ) return( False ); switch ( ev->type ) { case GDK_EXPOSE: /* printf( "Gdk Expose EventCallback: %s, %d\n", __FILE__, __LINE__ ); */ /* printf( " Expose event\n" ); */ if ( actWin ) { if ( block_expose == 0 ) { if ( w == actWin->edWin ) { jGtkCoverExposedArea( ev->expose.area.x + actWin->jedWin->sx * win->fontWidth, ev->expose.area.y + actWin->jedWin->sy * win->fontHeight, ev->expose.area.width, ev->expose.area.height, ev->expose.count ); } else { jGtkCoverExposedArea( ev->expose.area.x + actWin->jedWin->sx * win->fontWidth, ev->expose.area.y + ( actWin->jedWin->sy + actWin->jedWin->rows ) * win->fontHeight, ev->expose.area.width, ev->expose.area.height, ev->expose.count ); } } else { if ( ev->expose.count == 0 ) { jed_redraw_screen( 1 ); block_expose = 0; } } } break; case GDK_FOCUS_CHANGE: /* printf( "Focus change: %s, %d\n", __FILE__, __LINE__ ); */ toggle_cursor( ev->focus_change.in ); break; case GDK_CONFIGURE: /* if ( !updateGtkWin ) Return; */ /*****************/ /* printf( "Gdk Configure: %s, %d: data: %p, widget: %p\n", __FILE__, __LINE__, data, w ); */ /* printf( "File: %s, Line: %d: Width: %d, Height: %d\n", __FILE__, __LINE__, JGtkWin->width, JGtkWin->height ); */ /* printSubWins(); */ /************* printf( "vvvvvv~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~vvvvvv\n" ); printSubWinSizes(); printf( "^^^^^^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^\n" ); ************/ /* printf( "File: %s, Line: %d: Width: %d, Height: %d\n", __FILE__, __LINE__, JGtkWin->width, JGtkWin->height ); */ /* Dbp3( "Configure-Event: Widget: %p, Event: %p, data: %p\n", w, ev, data ); */ if ( /********** ( win->appWInGrid->allocation.height != win->inGridHeightPixel || win->appWInGrid->allocation.width != win->inGridWidthPixel ) && *********/ win->subWins && actWin ) { int sy, sx, i; int hCheck; int newWidth, newHeight; GtkSubWinType *sw; /* if ( !checkIfSizeChanged( ( GdkEventConfigure * ) ev ) ) break; */ /*******/ /* Dbp2( "w: %p, actWin: %p\n", w, actWin ); */ /****** printf( "1: vvvvvv---------------------------------------vvvvvv\n" ); printWidgetWinXRef(); printSubWins(); printf( "1: ^^^^^^---------------------------------------^^^^^^\n" ); **********/ /**********/ if ( !dragPaned ) { sw = win->subWins; hCheck = sy = win->subWins->jedWin->sy; sx = 0; /* printSubWins(); */ do { newHeight = sw->edWin->allocation.height / win->fontHeight + 1; hCheck += newHeight; if ( newHeight < 3 ) newHeight = 3; /* Dbp4( "sy: %d, newHeight: %d, sw->edWin->allocation.height: %d, win->fontHeight: %d\n", sy, newHeight, sw->edWin->allocation.height, win->fontHeight ); */ /* newWidth = sw->edWin->allocation.width / win->fontWidth + 1; */ newWidth = win->appWInGrid->allocation.width / win->fontWidth; if ( !newWidth ) newWidth = 1; /* Db; */ updateWidgetWinXRef( sw, sy, sx, newHeight, newWidth ); /* touch_window( sw->jedWin ); */ sy = sy + sw->jedWin->rows + 1; /* printf( "SW: %p, height: %d, sum height: %d, hCheck: %d\n", sw, newHeight, sy, hCheck ); */ sw = sw->next; /* Dbp( " --> sy: %d\n", sy ); */ } while ( sw != win->subWins ); /************************* * Update Minibuffer!!! *************************/ /* newWidth = win->miniWinSW->edWin->allocation.width / win->fontWidth + 1; */ /********/ /* Dbp( "Miniwin: sy: %d\n", sy ); */ /* Dbp( "MiniWin: win->miniWinSW: %p\n", win->miniWinSW ); */ /* printGtkSubWin( win->miniWinSW ); */ /************/ if ( win->miniWinSW ) { modWidgetWinXRef( win->widgetWinXRef, win->miniWinSW, 0, sy, newWidth, 1 ); /*************** for ( i = 0; i < newWidth; ++i ) { win->widgetWinXRef[sy][win->miniWinSW->jedWin->sx + i] = win->miniWinSW; } **************/ sy++; hCheck++; } /********** printf( "1.5: ---------------------------------------\n" ); printWidgetWinXRefXY( win->miniWinSW->jedWin->sx + newWidth, sy ); printSubWins(); printf( "1.5: ---------------------------------------\n" ); ***************/ win->hCheck = hCheck; win->inGridHeight = sy; /* Dbp( "WinGridHeight: %d\n", win->inGridHeight ); */ /* Db; */ /* printf( "win->hCheck: %d, win->inGridHeight: %d\n", win->hCheck, win->inGridHeight ); */ /* Dbp2( "win->edWidth: %d, win->edHeight: %d\n", win->edWidth, win->edHeight ); */ /* Dbp2( "newWidth: %d, sy: %d\n", newWidth, sy ); */ win->edWidth = newWidth; win->edHeight = sy; /* Dbp4( "win->hCheck: %d, win->inGridHeight: %d, win->edWidth: %d, win->edHeight: %d\n", win->hCheck, win->inGridHeight, win->edWidth, win->edHeight ); */ /***********/ JGtkWin->width = win->appWInGrid->allocation.width; JGtkWin->height = sy * win->fontHeight; /************/ win->edWidth = newWidth; win->edHeight = sy; win->inGridHeightPixel = win->appWInGrid->allocation.height; win->inGridWidthPixel = win->appWInGrid->allocation.width; #if 0 printf( "1.5: ---------------------------------------\n" ); /* printWidgetWinXRefXY( win->miniWinSW->jedWin->sx + newWidth, sy - 1 ); */ printWidgetWinXRef(); printSubWins(); printf( "1.5: ---------------------------------------\n" ); #endif /**************/ doColorSetup = 0; doCLS = 0; jed_init_display(); jed_redraw_screen( 1 ); doCLS = 1; doColorSetup = 1; /************/ /********* printf( "2: vvvvvv---------------------------------------vvvvvv\n" ); printWidgetWinXRef(); printSubWins(); printf( "2: ^^^^^^---------------------------------------^^^^^^\n" ); ********/ } else { if ( w == paneWin1->edWin || w == paneWin2->edWin ) { GtkSubWinType *subW; int resizeEdFlag = 0; int _sy, _newHeight, newHeightP1, newHeightP2, _newWidth; int sumHeight = paneWin1->jedWin->rows + 1 + paneWin2->jedWin->rows + 1; _newHeight = paneWin1->edWin->allocation.height / win->fontHeight + 1; if ( _newHeight < 3 || paneWin1->jedWin->rows <= 3 ) { if ( _newHeight < 3 ) _newHeight = 3; resizeEdFlag = 1; } _newWidth = paneWin1->edWin->allocation.width / win->fontWidth; updateWidgetWinXRef( paneWin1, paneWin1->jedWin->sy, 0, _newHeight, _newWidth ); newHeightP1 = _newHeight; _sy = paneWin1->jedWin->sy + paneWin1->jedWin->rows + 1; /*************** if ( resizeEdFlag ) { _newHeight = paneWin2->edWin->allocation.height / win->fontHeight + 1; } else _newHeight = sumHeight - _newHeight; ***************/ newHeightP2 = paneWin2->edWin->allocation.height / win->fontHeight + 1; /* Dbp2( "Allocation.height: %d, newHeightP2: %d\n", paneWin2->edWin->allocation.height, newHeightP2 ); */ if ( newHeightP2 != sumHeight - _newHeight ) { resizeEdFlag = 1; } _newHeight = newHeightP2; /********* if ( newHeightP2 > sumHeight - _newHeight ) { _newHeight = newHeightP2; resizeEdFlag = 1; } else { _newHeight = sumHeight - _newHeight; } **********/ /**************** if ( newHeightP2 < 3 ) { _newHeight = 3; resizeEdFlag = 1; } else { _newHeight = newHeightP2; } ****************/ if ( _newHeight < 3 || paneWin2->jedWin->rows <= 3 ) { if ( _newHeight < 3 ) _newHeight = 3; resizeEdFlag = 1; } updateWidgetWinXRef( paneWin2, _sy, 0, _newHeight, _newWidth ); newHeightP2 = _newHeight; /* Dbp5( "ResizeEdFlag: %d, SumHeight old: %d, SumHeight new: %d, newHeightP1: %d, newHeightP2: %d\n", resizeEdFlag, sumHeight, newHeightP1 + newHeightP2, newHeightP1, newHeightP2 ); */ if ( newHeightP1 + newHeightP2 == sumHeight ) resizeEdFlag = 0; if ( resizeEdFlag ) { /******* subW = JGtkWin->subWins; _sy = subW->jedWin->sy; **********/ subW = paneWin2->next; _sy = paneWin2->jedWin->sy + paneWin2->jedWin->rows + 1; if ( subW != JGtkWin->subWins ) do { _newHeight = subW->edWin->allocation.height / win->fontHeight + 1; if ( _newHeight < 3 ) _newHeight = 3; _newWidth = win->appWInGrid->allocation.width / win->fontWidth; if ( !_newWidth ) _newWidth = 1; updateWidgetWinXRef( subW, _sy, 0, _newHeight, _newWidth ); _sy = _sy + _newHeight; subW = subW->next; } while ( subW != JGtkWin->subWins ); if ( win->miniWinSW ) { modWidgetWinXRef( win->widgetWinXRef, win->miniWinSW, 0, _sy, _newWidth, 1 ); _sy++; } win->inGridHeight = _sy; win->edHeight = _sy; JGtkWin->height = _sy * win->fontHeight; win->edHeight = _sy; win->inGridHeightPixel = win->appWInGrid->allocation.height; /* Dbp1( "===========================================================================================%d\n", 1 ); */ /* Dbp1( "===========================================================================================%d\n", 1 ); */ /* Dbp1( "===========================================================================================%d\n", 1 ); */ doNoEvents = 1; doColorSetup = 0; doCLS = 0; jed_init_display(); update( NULL, 1, 0, 0 ); /* jed_redraw_screen( 1 ); */ doCLS = 1; doColorSetup = 1; doNoEvents = 0; /* Dbp1( "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^%d\n", 1 ); */ /* Dbp1( "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^%d\n", 1 ); */ /* Dbp1( "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^%d\n", 1 ); */ } else { /********** jWin = JWindow; do { touch_window_hard( JWindow, 0 ); JWindow = JWindow->next; } while ( jWin != JWindow ); **************/ touch_window_hard( paneWin1->jedWin, 1 ); touch_window_hard( paneWin2->jedWin, 1 ); /* touch_screen(); */ /* jed_redraw_screen( 1 ); */ update( NULL, 1, 0, 0 ); } } } } /*********** printf( "99: vvvvvv~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~vvvvvv\n" ); printWidgetWinXRef(); printSubWins(); printf( "99: ^^^^^^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^\n" ); ********/ if ( JGtkWin->appWMiniW ) gtk_widget_grab_focus( JGtkWin->appWMiniW ); break; case GDK_KEY_PRESS: /* printf( "File: %s Line: %d GDK_KEY_PRESS event!!!\n", __FILE__, __LINE__ ); */ /* printf( "KeyCode: \n" ); */ addGdkEvent( ev, w, data ); break; case GDK_BUTTON_PRESS: /* printf( "File: %s Line: %d Button press\n", __FILE__, __LINE__ ); */ if ( GTK_IS_PANED( w ) ) { GtkWidget *ch1 = gtk_paned_get_child1( GTK_PANED( w ) ); GList *childList; GtkWidget *stWidget; GtkSubWinType *sw = JGtkWin->subWins; /* GtkWidget *ch2; */ /* Dbp1( "Paned: %p Button press!!\n", w ); */ if ( GTK_IS_PANED( ch1 ) ) { ch1 = gtk_paned_get_child2( GTK_PANED( ch1 ) ); } if ( GTK_IS_BOX( ch1 ) ) { childList = gtk_container_get_children( GTK_CONTAINER( ch1 ) ); stWidget = ( GtkWidget * ) childList->next->data; g_list_free( childList ); while ( sw->stWin != stWidget && sw->next != JGtkWin->subWins ) { sw = sw->next; } if ( sw->stWin == stWidget ) { paneWin1 = sw; paneWin2 = paneWin1->next; dragPaned = 1; /* Dbp2( "Found paneWin1: %p, paneWin2: %p\n", paneWin1, paneWin2 ); */ return( False ); } } /* Dbp1( "Widget structure does not match: %p\n", ch1 ); */ paneWin1 = paneWin2 = NULL; dragPaned = 0; return( False ); } else addGdkEvent( ev, w, data ); break; case GDK_BUTTON_RELEASE: /* printf( "File: %s Line: %d Button release\n", __FILE__, __LINE__ ); */ if ( GTK_IS_PANED( w ) ) { /* Dbp1( "Paned: %p Button release!!\n", w ); */ dragPaned = 0; paneWin1 = paneWin2 = NULL; return( False ); } else addGdkEvent( ev, w, data ); break; case GDK_MOTION_NOTIFY: /* printf( "File: %s Line: %d Motion event\n", __FILE__, __LINE__ ); */ /* printf( "File: %s Line: %d x: %f, y: %f\n", __FILE__, __LINE__, ev->motion.x, ev->motion.y ); */ addGdkEvent( ev, w, data ); break; default: /* thisEventBuffer->gtkEvList = g_list_append( thisEventBuffer->gtkEvList, gdk_event_copy( ev ) ); */ /* ( thisEventBuffer->numGtkEv )++; */ /* printf( " Length of queue: %d\n", thisEventBuffer->numGtkEv ); */ break; } return( True ); } #if SLANG_VERSION >= 20000 /************************************ * bytes_to_wchars * * group: * * * debug print: * * ************************************/ static SLwchar_Type * bytes_to_wchars (unsigned char *s, unsigned int nchars ) { unsigned int i; SLwchar_Type *w = (SLwchar_Type *)SLmalloc(nchars*sizeof(SLwchar_Type)); if (w == NULL) return NULL; for (i = 0; i < nchars; i++) w[i] = s[i]; return w; } /************************************ * utf8nt_to_wchars * * group: * * * debug print: * * ************************************/ static SLwchar_Type * utf8nt_to_wchars(unsigned char *s, unsigned int len, unsigned int *ncharsp) { SLwchar_Type *w; unsigned int i, nchars; unsigned char *smax; nchars = SLutf8_strlen(s, 0); if (NULL == (w = (SLwchar_Type *)SLmalloc(nchars*sizeof(SLwchar_Type)))) { *ncharsp = 0; return NULL; } smax = s + len; for (i = 0; i < nchars; i++) { unsigned int n; if ( SLutf8_decode(s, smax, &w[i], &n ) == NULL ) w[i] = '?'; s += n; } *ncharsp = nchars; return w; } # define SLSMGCHAR_EQUAL(o, n) \ (((o)->nchars == (n)->nchars) \ && ((o)->color == (n)->color) \ && (0 == memcmp((o)->wchars, (n)->wchars, (n)->nchars * sizeof(SLwchar_Type)))) # define SLSMGCHAR_SET_CHAR(sc, _char) \ do { (sc).nchars = 1; (sc).wchars[0] = (_char); } while (0) # define SLSMGCHAR_SET_COLOR(sc, _color) \ (sc).color = (_color) # define SLSMG_COUNT_CHARS(sc) ((sc).nchars) #else /* SLang1 versions */ # define SLSMGCHAR_EQUAL(o, n) ((o) == (n)) # ifdef SLSMG_HLINE_CHAR_UNICODE /* Grrr.... hack for the slang1-utf8 version hacked by RedHat and SuSE... */ # define SLSMGCHAR_SET_CHAR(sc, _char) (sc) = ((sc) & 0xFF000000) + (_char) # define SLSMGCHAR_SET_COLOR(sc, _color) (sc) = ((sc) & 0xFF) + ((_color)<<24) # else # define SLSMGCHAR_SET_CHAR(sc, _char) (sc) = ((sc) & 0xFF00) + (_char) # define SLSMGCHAR_SET_COLOR(sc, _color) (sc) = ((sc) & 0xFF) + ((_color)<<8) # endif # define SLSMG_COUNT_CHARS(sc) (1) /* These exist in SLang 2 include, but not on SLang 1. Define here to allow * using the same code */ # define SLSMG_COLOR_MASK 0xFF # define SLwchar_Type char #endif /* SLANG_VERSION >= 20000 */ /************************************ * gtkXDrawString * * group: * * * debug print: "drawW: %p, gcNum: %d, text: %p, x: %d, y: %d\n", drawW, gcNum, text, x, y * ************************************/ static void jGtkDrawString( GtkWidget *drawW, int gcNum, char *text, int x, int y ) { JGtkWinType *win = JGtkWin; GdkColor *fg = DefaultGtkGCInfo[gcNum].fg; GdkColor *bg = DefaultGtkGCInfo[gcNum].bg; PangoRenderer *renderer; PangoLayout *layout; if ( !drawW->window ) { /* Dbp1( "Widget (%p) Window: NULL, should not occur!!!\n", drawW ); */ return; } renderer = gdk_pango_renderer_get_default( win->screen ); gdk_pango_renderer_set_drawable( GDK_PANGO_RENDERER( renderer ), drawW->window ); gdk_pango_renderer_set_gc( GDK_PANGO_RENDERER( renderer ), drawW->style->black_gc ); layout = pango_layout_new( win->fontContext ); pango_layout_set_text( layout, text, -1 ); pango_layout_set_font_description( layout, win->fontDescription ); gdk_pango_renderer_set_override_color( GDK_PANGO_RENDERER( renderer ), PANGO_RENDER_PART_FOREGROUND, fg ); gdk_pango_renderer_set_override_color( GDK_PANGO_RENDERER( renderer ), PANGO_RENDER_PART_BACKGROUND, bg ); pango_layout_context_changed( layout ); pango_renderer_draw_layout( renderer, layout, x * PANGO_SCALE, y * PANGO_SCALE ); /* free the objects we created */ g_object_unref ( layout ); } /* This function does the low-level drawing. * It can draw the new text, but setting 'overimpose' to 1 it draws the string * over the existing text (used for unicode combining characters). * It can use Xft (if configured), or plain X functions. */ /************************************ * gtkXDraw * * group: * * * debug print: "gcNum: %d, row: %d, col: %d, w: %p, nChars: %d, overimpose: %d\n", gcNum, row, col, w, nchars, overimpose * ************************************/ static int jGtkDraw( int gcNum, int row, int col, SLwchar_Type *w, int nchars, int overimpose ) { char *tmpText = "A"; char *text, *buf, *sav; int bufLen = 8*nchars + 1; int i; JGtkWinType *win = JGtkWin; int x = col * win->fontWidth; int y = row * win->fontHeight; if ( row == 0 ) return( 1 ); if ( !updateGtkWin ) return( 1 ); buf = sav = text = SLmalloc( bufLen + 1 ); for ( i = 0; i < nchars; ++i ) { if ( sav && bufLen > 0 ) { buf = sav; sav = ( char * ) SLutf8_encode( w[i], ( unsigned char * ) buf, bufLen ); bufLen -= sav - buf; } } if ( !sav ) return( 0 ); *sav = '\0'; if ( row > 0 && col >= 0 && row < Jed_Num_Screen_Rows && col < Jed_Num_Screen_Cols ) { /* row > 0 needed because routines for ascii-menu not implemented!!!! */ /* printf( "win->widgetWinXRef[%d][%d]\n", row, col ); */ /* printf( "win->widgetWinXRef[%d][%d]: %p\n", row, col, win->widgetWinXRef[row][col] ); */ if ( win->widgetWinXRef[row][col] ) { Window_Type *jedWin = win->widgetWinXRef[row][col]->jedWin; if ( row == jedWin->sy + jedWin->rows ) { /* printf( "win->widgetWinXRef[%d][%d]: StWin: %p\n", row, col, win->widgetWinXRef[row][col]->stWin ); */ jGtkDrawString( win->widgetWinXRef[row][col]->stWin, gcNum, text, x, 0 ); } else { /* printf( "win->widgetWinXRef[%d][%d]: EdWin: %p\n", row, col, win->widgetWinXRef[row][col]->edWin ); */ jGtkDrawString( win->widgetWinXRef[row][col]->edWin, gcNum, text, x, y - jedWin->sy*win->fontHeight ); } } } SLfree( text ); return 1; /* printf( "End drawing\n" ); */ } /* Get 'n' characters from SLSMG screen, at position ('row', 'col'). */ /************************************ * smg_read_at * * group: * * * debug print: * * ************************************/ static unsigned int smg_read_at( int row, int col, SLsmg_Char_Type *s, unsigned int n) { int saverow, savecol; unsigned int rc; saverow = SLsmg_get_row (); savecol = SLsmg_get_column (); SLsmg_gotorc(row, col); rc = SLsmg_read_raw (s, n); SLsmg_gotorc (saverow, savecol); return rc; } /* Write to screen a single SLsmg_Char, handling combining characters * (X doesn't seem to handle these...) to position (row, col). * This function doesn't touch the cursor position. */ /************************************ * JX_write_smgchar * * group: * * * debug print: * * ************************************/ static void JX_write_smgchar( int row, int col, SLsmg_Char_Type *s ) { int color = SLSMG_EXTRACT_COLOR(*s) & SLSMG_COLOR_MASK; if ((color >= JMAX_COLORS) || (color < 0)) color = 0; #if SLANG_VERSION >= 20000 if (s->nchars > 0) { (void) jGtkDraw( color, row, col, s->wchars, 1, 0 ); } if (Jed_UTF8_Mode) { unsigned int i; for (i = 1; i < s->nchars; i++) (void) jGtkDraw( color, row, col, &s->wchars[i], 1, 1 ); } #else { SLwchar_Type ch = SLSMG_EXTRACT_CHAR(*s); (void) jGtkDraw( color, row, col, &ch, 1, 0 ); } #endif } /* Write to screen a row of SLsmg_Chars, handling combining characters * (X doesn't seem to handle these...) to position (row, col). * This function doesn't touch the cursor position. */ /************************************ * JX_write_smgchars * * group: * * * debug print: * * ************************************/ static void JX_write_smgchars( int row, int col, SLsmg_Char_Type *s, SLsmg_Char_Type *smax ) { SLwchar_Type *b, *bend, buf[512]; int oldcolor, color; SLsmg_Char_Type *s0; int is_dual_font; b = buf; bend = buf + 510; oldcolor = (SLSMG_EXTRACT_COLOR(*s) & SLSMG_COLOR_MASK); if ((oldcolor < 0) || (oldcolor >= JMAX_COLORS)) oldcolor = 0; is_dual_font = 0; s0 = s; while (s < smax) { color = (SLSMG_EXTRACT_COLOR(*s) & SLSMG_COLOR_MASK); if ((color < 0) || (color >= JMAX_COLORS)) color = 0; if ( oldcolor != color /* Color changed. */ || (b >= bend) /* Space finished */ || SLSMG_COUNT_CHARS(*s) > 1) /* a combining character */ { (void) jGtkDraw( oldcolor, row, col, buf, b-buf, 0 ); col += (int)(s-s0); s0 = s; b = buf; oldcolor = color; } #if SLANG_VERSION >= 20000 if ( s->nchars > 1 ) { /* this cell has combining characters */ JX_write_smgchar(row, col, s); col++; s0 = s + 1; } else if ( s->nchars == 0 ) { /* SLsmg thinks this is a double width character, but the font has no such characters */ if ( is_dual_font == 0 ) *b++ = ' '; } else #endif *b++ = SLSMG_EXTRACT_CHAR(*s); s++; } if ( b != buf ) (void) jGtkDraw( color, row, col, buf, b-buf, 0 ); } /************************************ * hide_cursor * * group: * * * debug print: * * ************************************/ static void hide_cursor( void ) { SLsmg_Char_Type sc; if ( No_XEvents || ( JGtkWin->cursor_showing == 0 ) ) return; JGtkWin->cursor_showing = 0; if ( 0 == smg_read_at( JGtkWin->vis_curs_row, JGtkWin->vis_curs_col, &sc, 1 ) ) { SLSMGCHAR_SET_CHAR(sc, ' '); SLSMGCHAR_SET_COLOR(sc, JNORMAL_COLOR); sc.nchars = 1; } JX_write_smgchar( JGtkWin->vis_curs_row, JGtkWin->vis_curs_col, &sc); } /*}}}*/ /************************************ * updateScrollbar * * group: * * * debug print: * * ************************************/ void updateScrollbar( Window_Type *jw ) { int subWinNotFound = 1; GtkSubWinType *subWin = JGtkWin->subWins; /* printSubWins(); */ do { if ( subWin->jedWin == jw ) { subWinNotFound = 0; } else { subWin = subWin->next; } } while ( subWinNotFound && subWin != JGtkWin->subWins ); if ( subWinNotFound ) return; if ( subWin->numLineSav != subWin->jedWin->buffer->max_linenum || subWin->curLineSav != subWin->jedWin->buffer->linenum || subWin->winHeightSav != subWin->jedWin->rows ) { subWin->sbAdj->upper = subWin->jedWin->buffer->max_linenum - 1 > 0 ? subWin->jedWin->buffer->max_linenum - 1 : 0; subWin->sbAdj->value = subWin->jedWin->buffer->linenum - 1 > 0 ? subWin->jedWin->buffer->linenum - 1 : 0; subWin->sbAdj->page_size = subWin->jedWin->rows; subWin->numLineSav = subWin->jedWin->buffer->max_linenum; subWin->curLineSav = subWin->jedWin->buffer->linenum; subWin->winHeightSav = subWin->jedWin->rows; /* Dbp1( "Adjustment: --> %p\n", subWin->sbAdj ); */ g_signal_emit_by_name( G_OBJECT( subWin->sbAdj ), "changed" ); } } /************************************ * gtkCopyRect * * group: * * * debug print: "x1: %d, y1: %d, x2: %d, y2: %d, x3: %d, y3: %d\n", x1, y1, x2, y2, x3, y3 * ************************************/ static void gtkCopyRect( int x1, int y1, int x2, int y2, int x3, int y3 ) { int w, h; Window_Type *jedWin1 = JGtkWin->widgetWinXRef[y1][x1]->jedWin; Window_Type *jedWin3 = JGtkWin->widgetWinXRef[y3][x3]->jedWin; GtkWidget *win1 = JGtkWin->widgetWinXRef[y1][x1]->edWin; GtkWidget *win3 = JGtkWin->widgetWinXRef[y3][x3]->edWin; if ( win1 != win3 ) return; w = (x2 - x1) * JGtkWin->fontWidth; h = (y2 - y1) * JGtkWin->fontHeight; if ((w <= 0) || (h <= 0)) return; x3 = x3 * JGtkWin->fontWidth; x1 = x1 * JGtkWin->fontWidth; y3 = y3 * JGtkWin->fontHeight; y1 = y1 * JGtkWin->fontHeight; hide_cursor (); if ( win1 == win3 ) { gdk_gc_set_exposures( win1->style->white_gc, 1 ); gdk_draw_drawable( win1->window, win1->style->white_gc, win3->window, x1, y1 - jedWin1->sy * JGtkWin->fontHeight, x3, y3 - jedWin3->sy * JGtkWin->fontHeight, w, h ); } else { printf( "file: %s, Line: %d: GtkCopyRect: widgets differ!!!\n", __FILE__, __LINE__ ); } } /*}}}*/ /************************************ * gtkBlankRect * * group: * * * debug print: "x1: %d, y1: %d, x2: %d, y2: %d \n", x1, y1, x2, y2 * ************************************/ static void gtkBlankRect (int x1, int y1, int x2, int y2 ) /*{{{*/ { int w, h; Window_Type *jedWin1 = NULL; Window_Type *jedWin2 = NULL; GtkWidget *win1 = NULL; GtkWidget *win2 = NULL; /* Dbp4( "JedWin1: %p, JedWin2: %p, Win1: %p, Win2: %p\n", jedWin1, jedWin2, win1, win2 ); */ jedWin1 = JGtkWin->widgetWinXRef[y1][x1]->jedWin; /* Dbp4( "JedWin1: %p, JedWin2: %p, Win1: %p, Win2: %p\n", jedWin1, jedWin2, win1, win2 ); */ win1 = JGtkWin->widgetWinXRef[y1][x1]->edWin; /* Dbp4( "JedWin1: %p, JedWin2: %p, Win1: %p, Win2: %p\n", jedWin1, jedWin2, win1, win2 ); */ if (No_XEvents || (JGtkWin->window_mapped == 0)) return; w = (x2 - x1) * JGtkWin->fontWidth; h = (y2 - y1) * JGtkWin->fontHeight; if ((w <= 0) || (h <= 0)) return; x1 = x1 * JGtkWin->fontWidth; y1 = y1 * JGtkWin->fontHeight; hide_cursor (); gdk_gc_set_foreground( DefaultGtkGCInfo[JNORMAL_COLOR].gc, DefaultGtkGCInfo[JNORMAL_COLOR].bg ); /* gdk_draw_rectangle( win1->window, win1->style->white_gc, 1, */ gdk_draw_rectangle( win1->window, DefaultGtkGCInfo[JNORMAL_COLOR].gc, 1, x1, y1 - jedWin1->sy * JGtkWin->fontHeight, w, h ); gdk_gc_set_foreground( DefaultGtkGCInfo[JNORMAL_COLOR].gc, DefaultGtkGCInfo[JNORMAL_COLOR].fg ); } /*}}}*/ /************************************ * copy_rect * * group: * * * debug print: * * ************************************/ static void copy_rect(int x1, int y1, int x2, int y2, int x3, int y3) /*{{{*/ { int w, h; gtkCopyRect( x1, y1, x2, y2, x3, y3 ); } /*}}}*/ /************************************ * blank_rect * * group: * * * debug print: * * ************************************/ static void blank_rect (int x1, int y1, int x2, int y2 ) /*{{{*/ { int w, h; gtkBlankRect( x1, y1, x2, y2 ); } /*}}}*/ /************************************ * JX_set_scroll_region * * group: interface * * * debug print: "r1: %d, r2: %d\n", r1, r2 * * ************************************/ static void JX_set_scroll_region(int r1, int r2) { JGtkWin->scroll_r1 = r1; JGtkWin->scroll_r2 = r2; /* vterm_set_scroll_region (r1, r2); */ } /************************************ * jGtkSetFocus * * debug print: "(void) dummy: %d\n", 1 * ************************************/ void jGtkSetFocus(void) { JGtkWin->focus = 1; } /************************************ * JX_reset_scroll_region * * group: interface * * * debug print: * * ************************************/ static void JX_reset_scroll_region (void ) /*{{{*/ { JX_set_scroll_region (0, JX_Screen_Rows - 1); } /*}}}*/ /************************************ * show_cursor * * group: * * * debug print: * * ************************************/ static void show_cursor( void ) /*{{{*/ { SLsmg_Char_Type sc; int row, col, b; int color; GC gc; XGCValues gcv; /* Db; */ if ( No_XEvents ) return; /* Db; */ if ( JGtkWin->cursor_showing ) hide_cursor (); /* Db; */ JGtkWin->cursor_showing = 1; row = JGtkWin->vis_curs_row = JGtkWin->cursor_row; col = JGtkWin->vis_curs_col = JGtkWin->cursor_col; b = JGtkWin->border; /* Dbp2( ">>>>>>>>>> row: %d, col: %d\n", row, col ); */ /* Db; */ if ( ( CBuf != NULL ) && ( CBuf->flags & OVERWRITE_MODE ) ) color = JCURSOROVR_COLOR; else color = JCURSOR_COLOR; /* Db; */ if ( JGtkWin->focus ) { /* Db; */ if ( smg_read_at(row, col, &sc, 1) == 0 ) SLSMGCHAR_SET_CHAR( sc, ' ' ); SLSMGCHAR_SET_COLOR( sc, color ); JX_write_smgchar( row, col, &sc ); } else { /* Draw rectangle !!!!!!!! */ GtkWidget *w; Window_Type *jedWin; /* Dbp3( "WidgetWinXRef: %p, Row: %d, Col: %d\n", JGtkWin->widgetWinXRef, row, col ); */ if ( row > 0 && col >= 0 ) { /* Dbp3( "WidgetWinXRef: %p, Row: %d, Col: %d\n", JGtkWin->widgetWinXRef, row, col ); */ w = JGtkWin->widgetWinXRef[row][col]->edWin; jedWin = JGtkWin->widgetWinXRef[row][col]->jedWin; /* Dbp4( "Color: %d Default gc: %p, Default fg col: %p Default bg col: %p\n", */ /* color, DefaultGtkGCInfo[color].gc, DefaultGtkGCInfo[color].fg, DefaultGtkGCInfo[color].bg ); */ gdk_gc_set_foreground( DefaultGtkGCInfo[color].gc, DefaultGtkGCInfo[color].bg ); gdk_gc_set_background( DefaultGtkGCInfo[color].gc, DefaultGtkGCInfo[color].fg ); if ( w && w->window ) gdk_draw_rectangle( w->window, DefaultGtkGCInfo[color].gc, 0, (col - jedWin->sx)*JGtkWin->fontWidth, (row - jedWin->sy)*JGtkWin->fontHeight, JGtkWin->fontWidth - 1, JGtkWin->fontHeight - 1 ); gdk_gc_set_foreground( DefaultGtkGCInfo[color].gc, DefaultGtkGCInfo[color].fg ); gdk_gc_set_background( DefaultGtkGCInfo[color].gc, DefaultGtkGCInfo[color].bg ); } } } /*}}}*/ /************************************ * toggle_cursor * * group: * * * debug print: * * ************************************/ static void toggle_cursor (int on ) /*{{{*/ { /* Dbp1( ">>> %d <<<#####################################################################\n", on ); */ if (on) { if ( JGtkWin->focus) return; JGtkWin->focus = 1; } else { if ( JGtkWin->focus == 0) return; JGtkWin->focus = 0; } show_cursor (); } /*}}}*/ /* This routine assumes that cursor is in the correct location. The * cursor is placed at the end of the string. Even if we are unable to * write the string, make sure that the cursor is moved as if we did * the write. The main reason for this is that our X cursor must track * the vterm cursor so that the display gets updated properly. * Otherwise, smart_puts will call forward_cursor and then write to the * virtual display, and get that wrong because forward_cursor assumes * that the XWin cursor is correct. */ /************************************ * JX_write_string * * group: * * * debug print: * * ************************************/ static void JX_write_string (char *s ) /*{{{*/ { unsigned int nchars; SLwchar_Type *w; unsigned int nbytes = strlen(s); /* printf( "File: %s, Line: %d: JX_write_string\n", __FILE__, __LINE__ ); */ #if SLANG_VERSION >= 20000 if (Jed_UTF8_Mode) w = utf8nt_to_wchars((unsigned char *)s, nbytes, &nchars); else { w = bytes_to_wchars((unsigned char *)s, nbytes); nchars = nbytes; } if ( w == NULL ) goto write_done; #else nchars = nbytes; w = s; #endif if ((No_XEvents == 0) && JGtkWin->window_mapped) { hide_cursor (); (void) jGtkDraw( JGtkWin->current_gc_num, JGtkWin->cursor_row, JGtkWin->cursor_col, w, nchars, 0); } #if SLANG_VERSION >= 20000 SLfree((char *)w); write_done: #endif JGtkWin->cursor_col += nchars; if ( JGtkWin->cursor_col >= JX_Screen_Cols) JGtkWin->cursor_col = JX_Screen_Cols - 1; if (!Performing_Update) show_cursor(); } /************************************ * JX_goto_rc * * group: interface * * * debug print: "r: %d, c: %d\n", r, c * * ************************************/ static void JX_goto_rc(int r, int c) /*{{{*/ { /* Dbp2( ">>>>>>>>>>>>>>>> r: %d, c: %d\n", r, c ); */ if ( JGtkWin == NULL) return; if ( JGtkWin->cursor_showing) hide_cursor (); if (r >= JX_Screen_Rows) r = JX_Screen_Rows - 1; if (c >= JX_Screen_Cols) c = JX_Screen_Cols - 1; JGtkWin->cursor_row = r + JGtkWin->scroll_r1; JGtkWin->cursor_col = c; /* Dbp1( "JGtkWin->scroll_r1: %d\n", JGtkWin->scroll_r1 ); */ /* Dbp2( "JGtkWin->cursor_row: %d, JGtkWin->cursor_col: %d\n", JGtkWin->cursor_row, JGtkWin->cursor_col ); */ if (Performing_Update) return; show_cursor (); } /*}}}*/ /* Must respect scrolling region */ /************************************ * JX_delete_nlines * * group: interface * * * debug print: "n: %d\n", n * * ************************************/ static void JX_delete_nlines(int n) /*{{{*/ { int r1, r2; JGtkWinType *win = JGtkWin; r1 = JGtkWin->cursor_row; r2 = JGtkWin->scroll_r2; /* Dbp2( "JGtkWin->cursor_row: %d, JGtkWin->scroll_r2: %d\n", JGtkWin->cursor_row, JGtkWin->scroll_r2 ); */ if (r1 <= r2 - n) copy_rect(0, r1 + n, JX_Screen_Cols, r2 + 1, 0, r1); jGtkCoverExposedArea( 0, (r2 - n)*win->fontHeight, JX_Screen_Cols*win->fontWidth, win->fontHeight, 1 ); r2++; blank_rect(0, r2 - n, JX_Screen_Cols, r2); } /*}}}*/ /************************************ * JX_reverse_index * * group: interface * * * debug print: "n: %d\n", n * * ************************************/ static void JX_reverse_index( int n ) /*{{{*/ { int r1, r2; /* vterm_reverse_index (n); */ if (No_XEvents || ( JGtkWin->window_mapped == 0)) return; r1 = JGtkWin->scroll_r1; r2 = JGtkWin->scroll_r2; if (r2 >= r1 + n) copy_rect(0, r1, JX_Screen_Cols, r2 - n + 1, 0, r1 + n); blank_rect(0, r1, JX_Screen_Cols, r1 + n); } /*}}}*/ /************************************ * JX_beep * * group: * * * debug print: * * ************************************/ static void JX_beep(void) /*{{{*/ { if ( No_XEvents ) return; flush_input(); if ( JGtkWin->appWMiniW && JGtkWin->appWMiniW->window ) { if ( JX_Ignore_Beep & 0x1 ) { #if 0 /* not defined in my version of gtk */ gdk_window_beep( JGtkWin->appWMiniW->window ); #endif } if ( JX_Ignore_Beep & 0x2 ) { struct timeval bgTime; GdkColor colorWhite = { 0, 0xffff, 0xffff, 0xffff }, colorBlack = { 0, 0x0, 0x0, 0x0 }; GdkGC *gc = gdk_gc_new( JGtkWin->appWMiniW->window ); GtkSubWinType *sw = JGtkWin->subWins; gdk_gc_set_rgb_fg_color( gc, &colorWhite ); gdk_gc_set_rgb_bg_color( gc, &colorBlack ); gdk_gc_set_function( gc, GDK_INVERT ); do { if ( sw->edWin && sw->edWin->window ) { gdk_draw_rectangle( sw->edWin->window, gc, TRUE, 0, 0, sw->edWin->allocation.width, sw->edWin->allocation.height ); } if ( sw->stWin && sw->stWin->window ) { gdk_draw_rectangle( sw->stWin->window, gc, TRUE, 0, 0, sw->stWin->allocation.width, sw->stWin->allocation.height ); } sw = sw->next; } while ( sw != JGtkWin->subWins ); gdk_display_flush( JGtkWin->display ); gettimeofday( &bgTime, NULL ); /* Wait 100 ms */ while ( jGtkDiffTime( &bgTime ) < 100 ) { ; } do { if ( sw->edWin && sw->edWin->window ) { gdk_draw_rectangle( sw->edWin->window, gc, TRUE, 0, 0, sw->edWin->allocation.width, sw->edWin->allocation.height ); } if ( sw->stWin && sw->stWin->window ) { gdk_draw_rectangle( sw->stWin->window, gc, TRUE, 0, 0, sw->stWin->allocation.width, sw->stWin->allocation.height ); } sw = sw->next; } while ( sw != JGtkWin->subWins ); gdk_display_flush( JGtkWin->display ); gdk_gc_unref( gc ); } } } /*}}}*/ /************************************ * JX_del_eol * * group: interface * * * debug print: "(void %d)", 0 * * ************************************/ static void JX_del_eol(void) /*{{{*/ { blank_rect( JGtkWin->cursor_col, JGtkWin->cursor_row, JX_Screen_Cols, JGtkWin->cursor_row + 1); } /*}}}*/ /************************************ * JX_reverse_video * * group: * * * debug print: * * ************************************/ static void JX_reverse_video(int color) /*{{{*/ { if ((color < 0) || (color >= JMAX_COLORS)) return; } /*}}}*/ /************************************ * JX_normal_video * * group: interface * * * debug print: * * ************************************/ static void JX_normal_video(void) /*{{{*/ { JX_reverse_video (JNORMAL_COLOR); } /*}}}*/ /************************************ * JX_smart_puts * * group: interface * * * debug print: * * ************************************/ static void JX_smart_puts(SLsmg_Char_Type *neww, SLsmg_Char_Type *oldd, int len, int row) { int col; /* Skip equal chars at the beginning */ col = 0; while ((col < len) && SLSMGCHAR_EQUAL(&neww[col], &oldd[col])) col++; if (col < len) { hide_cursor(); JX_write_smgchars(row, col, neww+col, neww+len); JX_goto_rc (row, len); } } /*}}}*/ /************************************ * jGtkCoverExposedArea * * group: * * * debug print: * * ************************************/ static void jGtkCoverExposedArea( int x, int y, int width, int height, int count) /*{{{*/ { JGtkWinType *win = JGtkWin; SLsmg_Char_Type *s; int row, max_col, max_row, col; int width_chars, len; Performing_Update++; /* VTerm_Suspend_Update++; */ hide_cursor (); col = x / win->fontWidth; row = y / win->fontHeight; width_chars = 2 + width / win->fontWidth; max_col = col + width_chars; max_row = 2 + row + height / win->fontHeight; if (max_col > JX_Screen_Cols) max_col = JX_Screen_Cols; if (max_row > JX_Screen_Rows) max_row = JX_Screen_Rows; if (NULL != (s = (SLsmg_Char_Type *)SLmalloc(width_chars*sizeof(SLsmg_Char_Type)))) { while (row < max_row) { len = smg_read_at(row, col, s, width_chars); JX_write_smgchars(row, col, s, s + len); row++; } SLfree ((char *)s); } Performing_Update--; if (count == 0) show_cursor (); } #include "xkeys.c" /* Return 1 if event is listed in the switch or zero otherwise. The switch * events are considered harmless--- that is, processing them does not really * interfere with internal JED state (redisplay, etc...). More bluntly, * harmless means that the events can be processesed while checking for * pending input. */ static int Debug_gtkjed = 0; /*}}}*/ /************************************ * jGtkFillJMouse * * group: * * * debug print: * * ************************************/ static void jGtkFillJMouse( JMouse_Type *jmouse, /*{{{*/ unsigned char type, int x, int y, unsigned long t, unsigned int button, unsigned int state ) { unsigned char s; #if JED_HAS_MULTICLICK static unsigned long last_press_time; static unsigned int clicks; static unsigned int last_button; /* printf( "In fill_jmouse\n" ); */ if (type == JMOUSE_DOWN) { /* printf( "File: %s Line: %d\n", __FILE__, __LINE__ ); */ if ((last_button == button) && (last_press_time + JX_MultiClick_Time > t)) { /* printf( "File: %s Line: %d\n", __FILE__, __LINE__ ); */ clicks++; if (clicks == 2) type = JMOUSE_DOUBLE_CLICK; else type = JMOUSE_TRIPLE_CLICK; } else { /* printf( "File: %s Line: %d\n", __FILE__, __LINE__ ); */ clicks = 1; last_button = button; } last_press_time = t; } else if ((clicks > 1) && (last_button == button)) { /* printf( "File: %s Line: %d\n", __FILE__, __LINE__ ); */ /* Last was a multi-click. Ignore this event. */ type = JMOUSE_IGNORE_EVENT; } #endif jmouse->type = type; jmouse->x = 1 + x / JGtkWin->fontWidth; /* if ( y < XWin->border ) jmouse->y = 0; */ if ( y < JGtkWin->border ) jmouse->y = 0; else jmouse->y = 1 + y / JGtkWin->fontHeight; /* Dbp2( "Mouse y: %d jmouse->y: %d\n", y, jmouse->y ); */ if (button == Button1) jmouse->button = JMOUSE_BUTTON_1; else if (button == Button2) jmouse->button = JMOUSE_BUTTON_2; else if (button == Button3) jmouse->button = JMOUSE_BUTTON_3; else if (button == Button4) jmouse->button = JMOUSE_BUTTON_4; else if (button == Button5) jmouse->button = JMOUSE_BUTTON_5; else jmouse->button = JMOUSE_BUTTON_6; s = 0; if (state & Button1Mask) s |= JMOUSE_BUTTON_1; if (state & Button2Mask) s |= JMOUSE_BUTTON_2; if (state & Button3Mask) s |= JMOUSE_BUTTON_3; if (state & Button4Mask) s |= JMOUSE_BUTTON_4; if (state & Button5Mask) s |= JMOUSE_BUTTON_5; if (state & Button6Mask) s |= JMOUSE_BUTTON_5; if (state & ShiftMask) s |= JMOUSE_SHIFT; if (state & ControlMask) s |= JMOUSE_CTRL; jmouse->state = s; /* printf( "File: %s Line: %d\n", __FILE__, __LINE__ ); */ } /*}}}*/ /************************************ * getJGtkSubWin * * group: * * * debug print: * * ************************************/ static GtkSubWinType * getJGtkSubWin( GtkWidget *w ) { GtkSubWinType *tmpW = JGtkWin->subWins; do { if ( tmpW->edWin == w || tmpW->stWin == w ) { return( tmpW ); } tmpW = tmpW->next; } while ( tmpW != JGtkWin->subWins ); return( NULL ); } /************************************ * translateCoord * * group: * * * debug print: "FontHeight: %d, Widget: %p, x: %d, y: %d\n", JGtkWin->fontHeight, w, x, y * ************************************/ static void translateCoord( GtkWidget *w, int x, int y, int *newX, int *newY ) { /* GtkSubWinType *tmpWin = JGtkWin->subWins; */ GtkSubWinType *actSubWin = getJGtkSubWin( w ); int actSubWinSy; /* Dbp1( "ActSubWin: %p\n", actSubWin ); */ /* printSubWins(); */ *newX = x; if ( actSubWin ) { if ( actSubWin->edWin == w ) { /* edit windows */ *newY = actSubWin->jedWin->sy * JGtkWin->fontHeight + y; } else { /* status windows */ *newY = ( actSubWin->jedWin->sy + actSubWin->jedWin->rows ) * JGtkWin->fontHeight + y; } } else { /* minibuffer window */ *newY = ( Jed_Num_Screen_Rows - 1 ) * JGtkWin->fontHeight + y; } } /*************************/ #define MOUSE_DRAG_THRESHOLD 3 /* if force is true, wait for an event. If force is false, only * process events that exist. This will Return either when there * are no more events or a key/mouse event is processed Returning * 1 in the process */ /************************************ * X_process_events * * group: * * * debug print: * * ************************************/ static int X_process_events( int force, char *buf, unsigned int buflen, int *n_chars ) /*{{{*/ { char *savBuf; int xGtkPend, jXGtkPend; XEvent report; JXGtkEventType jXEv; JMouse_Type jmouse; int ch1; int block_expose = 0; char *bufp; KeySym ks = 0; int esc = 27; Window root, child; int posx, posy, rootx, rooty; unsigned int keys_buttons; int last_x, last_y; static int last_event, last_motion_down_button; static unsigned int motion_state; #if MOUSE_DRAG_THRESHOLD static int button_press_x, button_press_y; #endif int width, height; /* printf( "File: %s Line: %d X_process_events\n", __FILE__, __LINE__ ); */ /* while ( force || XGtkPending( This_XDisplay ) || jGtkPending( This_XDisplay ) ) */ /* while ( force || jGtkPending( This_XDisplay ) ) */ while ( force || jGtkPending() ) { /* printf( "File: %s Line: %d\n", __FILE__, __LINE__ ); */ /* if ( jGtkPending( This_XDisplay ) ) */ if ( jGtkPending() ) { /* JXGtkNextEvent( This_XDisplay, &jXEv ); */ JXGtkNextEvent( &jXEv ); switch ( jXEv.type ) { case JXGtkGdkEventID: switch ( jXEv.gdkEvent.gdkEvent.type ) { case GDK_KEY_PRESS: /* printf( "File: %s, Line: %d: JXEvent, KeyPress\n", __FILE__, __LINE__ ); */ bufp = buf; *n_chars = 0; if ( jXEv.gdkEvent.gdkEvent.key.keyval <= 0xFF ) { /* printf( "File: %s, Line: %d: buf: %p, bufp %p\n", __FILE__, __LINE__, buf, bufp ); */ bufp = SLutf8_encode( gdk_keyval_to_unicode( jXEv.gdkEvent.gdkEvent.key.keyval ), buf, buflen ); /* printf( "File: %s, Line: %d: buf: %p, bufp %p\n", __FILE__, __LINE__, buf, bufp ); */ if ( bufp ) { /* printf( "File: %s, Line: %d: buf: %p, bufp %p\n", __FILE__, __LINE__, buf, bufp ); */ *n_chars = bufp - buf; if ( *n_chars == 1 && ( jXEv.gdkEvent.gdkEvent.key.state & GDK_CONTROL_MASK ) ) { /* printf( "File: %s, Line: %d: buf: %p, bufp %p\n", __FILE__, __LINE__, buf, bufp ); */ if ( *buf >= 'a' && *buf <= 'z' ) *buf = *buf - 0x60; if ( *buf >= 'A' && *buf <= 'Z' ) *buf = *buf - 0x40; } } else *n_chars = 0; } else { /* I do not know why!!! */ *buf = 1; } bufp = ( char * ) map_keysym_to_keyseq( jXEv.gdkEvent.gdkEvent.key.keyval, jXEv.gdkEvent.gdkEvent.key.state & ( ShiftMask | ControlMask ) ); /* printf( "File: %s, Line: %d: bufp: %p\n", __FILE__, __LINE__, bufp ); */ if (bufp != NULL) { *n_chars = (unsigned char) *bufp++; #if USE_NEW_META_CODE if ( jXEv.gdkEvent.gdkEvent.key.state & JX_MetaMask) { buf[0] = X_Alt_Char; SLMEMCPY (buf + 1, bufp, *n_chars); *n_chars += 1; } else #endif SLMEMCPY(buf, bufp, *n_chars); } else if (*n_chars == 1) { if ( bufp == NULL ) bufp = buf; if ( jXEv.gdkEvent.gdkEvent.key.state & JX_MetaMask ) { ch1 = *bufp; if ( X_Alt_Char <= 0 ) *buf |= 0x80; else { *bufp++ = (unsigned char) X_Alt_Char; *bufp = (unsigned char) ch1; *n_chars = 2; } } else if ( jXEv.gdkEvent.gdkEvent.key.state & ControlMask ) { if (*buf == ' ') *buf = 0; else if (*buf == '-') *buf = 0x1F; } } if ( *n_chars == 0 ) break; return 1; break; case GDK_MOTION_NOTIFY: /* printf( "File: %s Line: %d GDK_MOTION_NOTIFY\n", __FILE__, __LINE__ ); */ /* Make sure we get the last event of this type */ while ( JXGtkCheckMaskEvent( GDK_MOTION_NOTIFY, &jXEv ) ) ; /* printf( "File: %s Line: %d GDK_MOTION_NOTIFY\n", __FILE__, __LINE__ ); */ if ( jXEv.gdkEvent.w ) { translateCoord( jXEv.gdkEvent.w, jXEv.gdkEvent.gdkEvent.button.x, jXEv.gdkEvent.gdkEvent.button.y, &posx, &posy ); } keys_buttons = jXEv.gdkEvent.gdkEvent.motion.state; /* This will ensure that modifier keys are not pressed while we are in motion. */ /* printf( "File: %s Line: %d GDK_MOTION_NOTIFY\n", __FILE__, __LINE__ ); */ if ( ( last_event == GDK_MOTION_NOTIFY ) && ( motion_state != keys_buttons ) ) break; /* printf( "File: %s Line: %d GDK_MOTION_NOTIFY\n", __FILE__, __LINE__ ); */ motion_state = keys_buttons; memset( ( char * ) &jmouse, 0, sizeof( jmouse ) ); last_x = jmouse.x; last_y = jmouse.y; /* printf( "File: %s Line: %d GDK_MOTION_NOTIFY\n", __FILE__, __LINE__ ); */ jGtkFillJMouse( &jmouse, JMOUSE_DRAG, posx, posy, jXEv.gdkEvent.gdkEvent.motion.time, last_motion_down_button, keys_buttons ); /* printf( "File: %s Line: %d GDK_MOTION_NOTIFY\n", __FILE__, __LINE__ ); */ /* Dbp3( " Button_press_x: %d, posx: %d: Diff abs: %d\n", button_press_x, posx, abs( button_press_x - posx ) ); */ /* Dbp3( " Button_press_y: %d, posy: %d: Diff abs: %d\n", button_press_y, posy, abs( button_press_y - posy ) ); */ #if MOUSE_DRAG_THRESHOLD if ( ( abs(button_press_x - posx ) <= MOUSE_DRAG_THRESHOLD ) && ( abs( button_press_y - posy ) <= MOUSE_DRAG_THRESHOLD ) ) { /* Db; */ break; } #endif /* printf( "File: %s Line: %d\n", __FILE__, __LINE__ ); */ if ((last_x == jmouse.x) && (last_y == jmouse.y)) break; /* printf( "File: %s Line: %d\n", __FILE__, __LINE__ ); */ if (-1 == (ch1 = jed_mouse_add_event (&jmouse))) break; /* queue full */ /* return ESC ^@ */ /* printf( "File: %s Line: %d\n", __FILE__, __LINE__ ); */ *buf++ = esc; *buf++ = 0; *buf++ = ch1; /* printf( "File: %s Line: %d\n", __FILE__, __LINE__ ); */ *n_chars = 3; /* printf( "File: %s Line: %d\n", __FILE__, __LINE__ ); */ last_event = MotionNotify; /* printf( "File: %s Line: %d\n", __FILE__, __LINE__ ); */ return 1; case GDK_BUTTON_PRESS: /* gtkButtonEvent = 1; */ /* Prohibit dragging more than one button at a time. */ /* printf( "File: %s Line: %d\n", __FILE__, __LINE__ ); */ if ( last_event == GDK_MOTION_NOTIFY ) break; /* drop */ case GDK_BUTTON_RELEASE: /* gtkButtonEvent = 1; */ /* printf( "File: %s Line: %d\n", __FILE__, __LINE__ ); */ if ( ( last_event == GDK_MOTION_NOTIFY ) && ( jXEv.gdkEvent.gdkEvent.button.button != (unsigned int) last_motion_down_button)) break; /* printf( "File: %s Line: %d Button press\n", __FILE__, __LINE__ ); */ last_event = 0; /* printf( "File: %s Line: %d Button press\n", __FILE__, __LINE__ ); */ if ( jXEv.gdkEvent.w ) { translateCoord( jXEv.gdkEvent.w, jXEv.gdkEvent.gdkEvent.button.x, jXEv.gdkEvent.gdkEvent.button.y, &rootx, &rooty ); /* Dbp2( "Posx: %d, Posy: %d\n", rootx, rooty ); */ jGtkFillJMouse (&jmouse, ((jXEv.gdkEvent.gdkEvent.type == GDK_BUTTON_RELEASE ) ? JMOUSE_UP : JMOUSE_DOWN ), rootx, rooty, jXEv.gdkEvent.gdkEvent.button.time, jXEv.gdkEvent.gdkEvent.button.button, jXEv.gdkEvent.gdkEvent.button.state); /* printf( "File: %s Line: %d\n", __FILE__, __LINE__ ); */ } else { jGtkFillJMouse (&jmouse, ((jXEv.gdkEvent.gdkEvent.type == GDK_BUTTON_RELEASE ) ? JMOUSE_UP : JMOUSE_DOWN ), jXEv.gdkEvent.gdkEvent.button.x, jXEv.gdkEvent.gdkEvent.button.y, jXEv.gdkEvent.gdkEvent.button.time, jXEv.gdkEvent.gdkEvent.button.button, jXEv.gdkEvent.gdkEvent.button.state); } #if MOUSE_DRAG_THRESHOLD if ( jXEv.gdkEvent.gdkEvent.type == GDK_BUTTON_PRESS ) { button_press_x = rootx; button_press_y = rooty; } else { button_press_x = 0; button_press_y = 0; } /* printf( "File: %s Line: %d Button press\n", __FILE__, __LINE__ ); */ #endif if ( -1 == (ch1 = jed_mouse_add_event (&jmouse))) break; /* queue full */ if ( ( jXEv.gdkEvent.gdkEvent.type == GDK_BUTTON_PRESS ) && ( 0 == ( jXEv.gdkEvent.gdkEvent.button.state & ( GDK_BUTTON1_MASK | GDK_BUTTON2_MASK | GDK_BUTTON3_MASK | GDK_BUTTON4_MASK | GDK_BUTTON5_MASK ) ) ) ) last_motion_down_button = jXEv.gdkEvent.gdkEvent.button.button; savBuf = buf; /* ESC ^@ is a mouse prefix */ *buf++ = esc; *buf++ = 0; *buf++ = ch1; *n_chars = 3; /* printf( "File: %s Line: %d Button press (%2x|%2x|%2x)\n", __FILE__, __LINE__, savBuf[0], savBuf[1], savBuf[2] ); */ return 1; default: printf( "Unknown GdkEvent: %s, %d.\n", __FILE__, __LINE__ ); break; } break; case JXKeyFeedID: /* Dbp3( "Key Feed Event: keys: |%p|: %d, %p\n", jXEv.keyFeed.keys, *( jXEv.keyFeed.keys ), *( jXEv.keyFeed.keys + 1 ) ); */ strncpy( buf, ( jXEv.keyFeed.keys ) + 1, ( *( jXEv.keyFeed.keys ) ) - 1 ); *n_chars = ( *( jXEv.keyFeed.keys ) ) - 1; SLfree( jXEv.keyFeed.keys ); /* Dbp1( "n_chars: %d\n", *n_chars ); */ return 1; break; default: printf( "Unknown JXGtkEvent: %s, %d!!!\n", __FILE__, __LINE__ ); break; } } } return 0; } /*}}}*/ /************************************ * X_read_key * * group: interface * * * debug print: * * ************************************/ static int X_read_key( void ) /*{{{*/ { int nread; char buf[64]; /* printf( "File: %s Line: %d X_read_key before\n", __FILE__, __LINE__ ); */ (void) X_process_events (1, buf, sizeof (buf), &nread); /* printf( "File: %s Line: %d X_read_key after, nread: %d\n", __FILE__, __LINE__, nread ); */ if (nread > 1) ungetkey_string(buf + 1, nread - 1); /* Dbp2( "Nread: %d, *buf: %d\n", nread, *buf ); */ if ( *buf == (char) Jed_Abort_Char ) { if ( Ignore_User_Abort == 0 ) SLang_set_error (USER_BREAK); SLKeyBoard_Quit = 1; /* Dbp2( "SLang_get_error: %d, USER_BREAK: %d\n", SLang_get_error(), USER_BREAK ); */ } return (int) *buf; } /*}}}*/ /************************************ * X_input_pending * * called by sys_input_pending * * group: interface * * * debug print: * * ************************************/ static int X_input_pending( void ) /*{{{*/ { XEvent ev; int n; while ( gtk_events_pending() ) { gtk_main_iteration_do( False ); } if ( jGtkPending() ) { return( 1 ); } return 0; } /*}}}*/ /************************************ * createKeyEvents * * group: * * * debug print: * * ************************************/ int jgtk_createKeyEvents( char *keyStr ) { FilterEventData *eB = thisEventBuffer; JXGtkEventType *newEv = ( JXGtkEventType * ) SLmalloc( sizeof( JXGtkEventType ) ); /* Dbp3( "String: |%p|-|%p|-|%p|\n", keyStr[0], keyStr[1], keyStr[2] ); */ newEv->type = JXKeyFeedID; newEv->any.type = JXKeyFeedID; newEv->keyFeed.type = JXKeyFeedID; /* newEv->keyFeed.keys = keyStr; */ newEv->keyFeed.keys = SLmalloc( sizeof( ( *keyStr ) + 1 ) ); strncpy( newEv->keyFeed.keys, keyStr, *keyStr ); newEv->keyFeed.keys[(unsigned char) *keyStr] = '\0'; eB->jXGtkEvList = g_list_append( eB->jXGtkEvList, newEv ); ( eB->jXGtkNumEv ) += 1; return 0; } /************************************ * JX_get_display_size * * group: * * * debug print: * * ************************************/ static void JX_get_display_size( int *rows, int *cols ) /*{{{*/ { int sy, sx, i; int newHeight, newWidth; int hCheck; GtkSubWinType *sw; JGtkWinType *win = JGtkWin; if ( win->subWins ) { sw = win->subWins; hCheck = sy = win->subWins->jedWin->sy; sx = 0; /******** printWidgetWinXRef(); printSubWins(); *******/ do { newHeight = sw->edWin->allocation.height / win->fontHeight + 1; hCheck += newHeight; if ( newHeight < 3 ) newHeight = 3; newWidth = win->appWInGrid->allocation.width / win->fontWidth; sy = sy + sw->jedWin->rows + 1; sw = sw->next; } while ( sw != win->subWins ); if ( win->miniWinSW ) { sy++; hCheck++; } win->hCheck = hCheck; win->inGridHeight = sy; /* printf( "win->hCheck: %d, win->inGridHeight: %d\n", hCheck, win->inGridHeight ); */ win->edWidth = newWidth; win->edHeight = sy; JX_Screen_Cols = win->edWidth; JX_Screen_Rows = win->edHeight; } else { JX_Screen_Cols = JGtkWin->width / JGtkWin->fontWidth; JX_Screen_Rows = JGtkWin->height / JGtkWin->fontHeight; } Jed_Num_Screen_Cols = JX_Screen_Cols; Jed_Num_Screen_Rows = JX_Screen_Rows; *cols = JX_Screen_Cols; *rows = JX_Screen_Rows; /* Dbp2( "Jed_Num_Screen_Cols: %d, Jed_Num_Screen_Rows: %d\n", Jed_Num_Screen_Cols, Jed_Num_Screen_Rows ); */ } /*}}}*/ /************************************ * JX_set_term_vtxxx * * group: * * * debug print: * * ************************************/ static void JX_set_term_vtxxx (int *n ) /*{{{*/ { (void) n; } /*}}}*/ /************************************ * JX_narrow_width * * group: * * * debug print: * * ************************************/ static void JX_narrow_width (void ) /*{{{*/ { } /*}}}*/ /************************************ * JX_wide_width * * group: * * * debug print: * * ************************************/ static void JX_wide_width (void ) /*{{{*/ { } /*}}}*/ /************************************ * JX_enable_cursor_keys * * group: * * * debug print: * * ************************************/ /* ???????????????????? */ static void JX_enable_cursor_keys(void) /*{{{*/ { } /*}}}*/ static void jGtkSetFGBGColor( GtkWidget *w, int c ) { /* colorChangeFlag = 1; */ gtk_widget_modify_fg( w, GTK_STATE_NORMAL, DefaultGtkGCInfo[c].fg ); gtk_widget_modify_fg( w, GTK_STATE_ACTIVE, DefaultGtkGCInfo[c].fg ); gtk_widget_modify_fg( w, GTK_STATE_PRELIGHT, DefaultGtkGCInfo[c].fg ); gtk_widget_modify_fg( w, GTK_STATE_SELECTED, DefaultGtkGCInfo[c].fg ); gtk_widget_modify_fg( w, GTK_STATE_INSENSITIVE, DefaultGtkGCInfo[c].fg ); gtk_widget_modify_bg( w, GTK_STATE_NORMAL, DefaultGtkGCInfo[c].bg ); gtk_widget_modify_bg( w, GTK_STATE_ACTIVE, DefaultGtkGCInfo[c].bg ); gtk_widget_modify_bg( w, GTK_STATE_PRELIGHT, DefaultGtkGCInfo[c].bg ); gtk_widget_modify_bg( w, GTK_STATE_SELECTED, DefaultGtkGCInfo[c].bg ); gtk_widget_modify_bg( w, GTK_STATE_INSENSITIVE, DefaultGtkGCInfo[c].bg ); /* colorChangeFlag = 0; */ } /************************************ * JX_cls * * group: interface * * * debug print: "\n" * ************************************/ static void JX_cls( void ) /*{{{*/ { GtkSubWinType *sw = JGtkWin->subWins; GtkSubWinType *swBeg = sw; if ( !sw ) return; if (No_XEvents) return; if ( !doCLS ) return; if ( JGtkWin->window_mapped == 0) return; do { /* gdk_draw_rectangle( sw->edWin, sw->edWin->style->white_gc, 1, 0, 0, xxx, yyy ); */ /* gdk_draw_rectangle( sw->stWin, sw->stWin->style->white_gc, 1, 0, 0, xxx, yyy ); */ if ( sw->edWin->window ) { if ( doColorSetup ) jGtkSetFGBGColor( sw->edWin, JNORMAL_COLOR ); gdk_window_clear( sw->edWin->window ); } else { /* Dbp1( "EdWin NULL should not occur!!!\n", 1 ); */ /******** printWidgetWinXRef(); printSubWins(); ******/ } if ( sw->stWin->window ) { if ( doColorSetup ) jGtkSetFGBGColor( sw->stWin, JNORMAL_COLOR ); gdk_window_clear( sw->stWin->window ); } else { /* Dbp1( "StWin NULL should not occur!!!\n", 1 ); */ /******* printWidgetWinXRef(); printSubWins(); ******/ } sw = sw->next; } while ( sw != swBeg ); /******** gdk_draw_rectangle( JGtkWin->appWDrawArea->window, JGtkWin->appWDrawArea->style->white_gc, 1, 0, 0, JGtkWin->width, JGtkWin->height ); *******/ } /*}}}*/ /* This routine is called from S-Lang inner interpreter. It serves as a poor mans version of an interrupt 9 handler */ /************************************ * xjed_check_kbd * * group: interface * * * debug print: * * ************************************/ static void xjed_check_kbd( void ) /*{{{*/ { char buf[64]; int n; register char *b, *bmax; if (Batch || No_XEvents) return; while ( jGtkPending() ) { /* printf( "File: %s Line: %d xjed_check_kbd before\n", __FILE__, __LINE__ ); */ if (X_process_events (0, buf, sizeof (buf), &n) == 0) continue; /* printf( "File: %s Line: %d xjed_check_kbd after\n", __FILE__, __LINE__ ); */ b = buf; bmax = b + n; while (b < bmax) { if ( *b == (char) Jed_Abort_Char ) { if ( Ignore_User_Abort == 0 ) SLang_set_error (USER_BREAK); if ( b != buf ) buffer_keystring (buf, (int) (b - buf)); SLKeyBoard_Quit = 1; /* Dbp2( "SLang_get_error: %d, USER_BREAK: %d\n", SLang_get_error(), USER_BREAK ); */ break; } b++; } if (!SLKeyBoard_Quit) buffer_keystring (buf, n); } } /*}}}*/ /************************************ * xjed_suspend * * group: interface * * * debug print: * * ************************************/ static void xjed_suspend( void ) /*{{{*/ { if ( No_XEvents ) return; /* if ( XWin->focus ) */ if ( JGtkWin->focus ) { } else { /* The window doesn't have focus which means that this was most * likely called by pressing Ctrl-Z from another window. */ fprintf (stderr, "jed stopping\n"); #ifdef SIGSTOP kill (0, SIGSTOP); #endif /* sys_suspend (); */ } } /*}}}*/ /************************************ * set_window_name * * debug print: "Name: |%s|\n", s * ************************************/ static void set_window_name( char *s ) /*{{{*/ { if ( Batch ) return; if ( JGtkWin->appW ) gtk_window_set_title( GTK_WINDOW( JGtkWin->appW ), s ); /* XStoreName (This_XDisplay, XWin->w, s); */ } /************************************ * set_icon_name * * debug print: "Icon file name: |%s|\n", s * ************************************/ static void set_icon_name( char *s ) /*{{{*/ { if ( Batch ) return; if ( JGtkWin->appW ) gtk_window_set_default_icon_from_file( s, NULL ); /* XSetIconName(This_XDisplay, XWin->w, s); */ } /************************************ * setupGtkColor * * group: * * * debug print: * * ************************************/ static char * setupGtkColor( char *colName, GdkColor **oldColP, char *defColName, GdkColor *defCol ) { char *newName; if ( *oldColP ) { SLfree( ( char * ) *oldColP ); } *oldColP = ( GdkColor * ) SLmalloc( sizeof( GdkColor ) ); if ( colName ) { if ( strcmp( colName, "default" ) ) { if ( !strncmp( colName, "bright", 6 ) ) { colName += 6; } if ( gdk_color_parse( colName, *oldColP ) ) { newName = SLmalloc( strlen( colName ) + 1 ); strcpy( newName, colName ); gdk_colormap_alloc_color( JGtkWin->colormap, *oldColP, 1, 1 ); } else { newName = SLmalloc( strlen( defColName ) + 1 ); strcpy( newName, defColName ); memcpy( *oldColP, defCol, sizeof( GdkColor ) ); } } else { newName = SLmalloc( strlen( defColName ) + 1 ); strcpy( newName, defColName ); memcpy( *oldColP, defCol, sizeof( GdkColor ) ); } } else { newName = SLmalloc( strlen( defColName ) + 1 ); strcpy( newName, defColName ); memcpy( *oldColP, defCol, sizeof( GdkColor ) ); } return( newName ); } /************************************ * setupAndParseGtkColors * * group: * * * debug print: * * ************************************/ static int setupAndParseGtkColors(void) { int i; char *savName; GdkColor *fgCol, *bgCol; GCGtkInfoType *savGtkGCInfo; savGtkGCInfo = DefaultGtkGCInfo; JGtkWin->textGC = DefaultGtkGCInfo; fgCol = ( GdkColor * ) SLmalloc( sizeof( GdkColor ) ); bgCol = ( GdkColor * ) SLmalloc( sizeof( GdkColor ) ); fgCol->pixel = 0; fgCol->red = 0x0; fgCol->green = 0x0; fgCol->blue = 0x0; bgCol->pixel = 0; bgCol->red = 0xffff; bgCol->green = 0xffff; bgCol->blue = 0xffff; JGtkWin->textGC->fg = fgCol; JGtkWin->textGC->bg = bgCol; savName = JGtkWin->textGC->fgName; JGtkWin->textGC->fgName = SLmalloc( strlen( savName ) + 1 ); strcpy( JGtkWin->textGC->fgName, savName ); savName = JGtkWin->textGC->bgName; JGtkWin->textGC->bgName = SLmalloc( strlen( savName ) + 1 ); strcpy( JGtkWin->textGC->bgName, savName ); for ( i = 1; i < JMAX_COLORS; ++i ) { /* printf( "file: %s line: %d: i: %d\n", __FILE__, __LINE__, i ); */ /* printf( "FG: %s, BG: %s\n", DefaultGtkGCInfo[i].fgName, DefaultGtkGCInfo[i].bgName ); */ DefaultGtkGCInfo[i].fgName = setupGtkColor( DefaultGtkGCInfo[i].fgName, &DefaultGtkGCInfo[i].fg, JGtkWin->textGC->fgName, JGtkWin->textGC->fg ); DefaultGtkGCInfo[i].bgName = setupGtkColor( DefaultGtkGCInfo[i].bgName, &DefaultGtkGCInfo[i].bg, JGtkWin->textGC->bgName, JGtkWin->textGC->bg ); } return( 0 ); } /* #if 0 */ /************************************ * setup_and_parse_colors * * group: * * * debug print: * * ************************************/ #if 0 static int setup_and_parse_colors (void ) /*{{{*/ { unsigned long fg, bg, tmp; char *fg_name, *bg_name; int i; setupAndParseGtkColors(); return 0; } /*}}}*/ #endif /* #endif */ /* ??????????????? */ /************************************ * set_mouse_color * * group: * * * debug print: * * ************************************/ static void set_mouse_color( char *fgc, char *bgc ) /*{{{*/ { XColor xfg, xbg; } /************************************ * create_XWindow * * group: * * * debug print: * * ************************************/ static void create_XWindow(void) /*{{{*/ { int i; int bdr, x, y, flags; unsigned int width, height; XSizeHints sizehint; XClassHint xcls; XWMHints wmhint; long key_event_type; FilterEventData *tmpData; GdkDisplay *tmpDisp; thisEventBuffer = tmpData = ( FilterEventData * ) SLmalloc( sizeof( FilterEventData ) ); /* tmpData->win = win; */ /* tmpData->evList = NULL; */ /* tmpData->numEv = 0; */ tmpData->jXGtkEvList = NULL; tmpData->jXGtkNumEv = 0; tmpDisp = gdk_display_get_default(); JGtkWin->height = /* win->height = */ 200; JGtkWin->width = /* win->width = */ 200; createGtkMainWindow(); JGtkWin->numWin = 0; JGtkWin->gutSize = 0; JGtkWin->hCheck = 0; JGtkWin->inGridHeight = 0; JGtkWin->inGridHeightPixel = 0; JGtkWin->inGridWidthPixel = 0; JGtkWin->subWins = NULL; JGtkWin->miniWinSW = NULL; JGtkWin->maxEdHeight = MAX_EDHEIGHT; JGtkWin->maxEdWidth = MAX_EDWIDTH; JGtkWin->widgetWinXRef = ( GtkSubWinType *** ) SLmalloc( sizeof( GtkSubWinType ** ) * JGtkWin->maxEdHeight ); /* printf( "JGtkWin->maxEdHeight: %d\n", JGtkWin->maxEdHeight ); */ for ( ; JGtkWin->maxEdHeight; --JGtkWin->maxEdHeight ) { JGtkWin->widgetWinXRef[JGtkWin->maxEdHeight - 1] = ( GtkSubWinType ** ) SLmalloc( sizeof( GtkSubWinType * ) * JGtkWin->maxEdWidth ); #if 0 for ( i = 0; i < JGtkWin->maxEdWidth; ++i ) { /* printf( "JGtkWin->maxEdHeigth: %d, i: %d\n", JGtkWin->maxEdHeight, i ); */ /* printf( "JGtkWin->widgetWinXRef: %p\n", JGtkWin->widgetWinXRef ); */ JGtkWin->widgetWinXRef[JGtkWin->maxEdHeight - 1][i] = NULL; } #endif } modWidgetWinXRef( JGtkWin->widgetWinXRef, NULL, 0, 0, JGtkWin->maxEdWidth, JGtkWin->maxEdHeight ); JGtkWin->maxEdHeight = MAX_EDHEIGHT; #if 0 Return( ( Window ) 5 /* DUMMY */ ); #endif } /*}}}*/ void jGtkAttachMenubar( GtkWidget *mb ) { if ( mb == JGtkWin->appWMenuBar ) return; gtk_box_pack_start( GTK_BOX( JGtkWin->appWGrid ), mb, False, False, 0 ); gtk_box_reorder_child( GTK_BOX( JGtkWin->appWGrid ), mb, 1 ); if ( JGtkWin->appWMenuBar ) gtk_container_remove( GTK_CONTAINER( JGtkWin->appWGrid ), JGtkWin->appWMenuBar ); JGtkWin->appWMenuBar = mb; gtk_widget_show_all( mb ); } /************************************ * jGtkAddToolbar * * debug print: "tb: %p, where: %d\n", tb, where * ************************************/ void jGtkAddToolbar( GtkWidget *tb, int where ) { int n; if ( !GTK_IS_CONTAINER( JGtkWin->appWTbGrid ) ) { /* Dbp1( "Internal error: appWTbGrid: %p not a container!!\n", JGtkWin->appWTbGrid ); */ } if ( where != -1 ) { n = g_list_length( gtk_container_get_children( GTK_CONTAINER( JGtkWin->appWTbGrid ) ) ); if ( where > n ) where = n; } /* Dbp1( "Where: %d\n", where ); */ gtk_box_pack_start( GTK_BOX( JGtkWin->appWTbGrid ), tb, False, False, 0 ); gtk_box_reorder_child( GTK_BOX( JGtkWin->appWTbGrid ), tb, where ); gtk_widget_show_all( tb ); } /************************************ * x_err_handler * * group: * * * debug print: * * ************************************/ #if 0 static int x_err_handler (Display *d, XErrorEvent *ev ) /*{{{*/ { char errmsg[256]; return 1; } /*}}}*/ #endif /************************************ * x_ioerr_handler * * group: * * * debug print: * * ************************************/ #if 0 static int x_ioerr_handler (Display *d ) /*{{{*/ { No_XEvents = 1; exit_error("XWindows IO error", 0); return d == NULL; /* just use d to avoid a warning */ } /*}}}*/ #endif /************************************ * open_Xdisplay * * group: * * * debug print: * * ************************************/ static int open_Xdisplay (void ) /*{{{*/ { char dname [256]; char *n; int numArg = 0; memset( (char *) JGtkWin, 0, sizeof( JGtkWinType )); /* gtk_init( &numArg, NULL ); */ JGtkWin->display = gdk_display_get_default(); JGtkWin->screen = gdk_display_get_default_screen( JGtkWin->display ); JGtkWin->colormap = gdk_screen_get_default_colormap( JGtkWin->screen ); #define FONT "monospace 6" JGtkWin->fontName = SLmalloc( strlen( FONT ) + 1 ); strcpy( JGtkWin->fontName, FONT ); JGtkWin->XDisplay = gdk_x11_display_get_xdisplay( JGtkWin->display ); return 1; } #ifdef SIXTEEN_BIT_SYSTEM # define VFILE_BUF_SIZE 1024 #else # define VFILE_BUF_SIZE 4096 #endif static char * getLibFile( char *file ) /*{{{*/ { static char retFile[JED_MAX_PATH_LEN]; char libfsl[JED_MAX_PATH_LEN], libfslc[JED_MAX_PATH_LEN]; char *lib, *tmpLib, *type, *libf; unsigned int n; /* Dbp1( "file: |%s|\n", file ); */ libf = file; /* lib = Jed_Library; */ lib = NULL; if ( ( 0 == strncmp( file, "./", 2 ) ) || #ifdef IBMPC_SYSTEM ( 0 == strncmp( file, ".\\", 2 ) ) || ( 0 == strncmp( file, "..\\", 3 ) ) || #endif ( 0 == strncmp( file, "../", 3 ) ) ) { if ( NULL == ( lib = jed_get_cwd() ) ) lib = ""; } else if ( SLpath_is_absolute_path( file ) ) lib = ""; /************** else if ( ( lib == NULL ) || ( *lib == 0 ) ) exit_error( "JED_ROOT environment variable needs set.", 0 ); ***************/ else { tmpLib = SLpath_get_load_path (); /* SLstring */ if ((tmpLib == NULL) || (*tmpLib == 0)) exit_error("The JED_ROOT environment variable needs set.", 0); else { lib = ( char * ) SLmalloc( strlen( tmpLib ) + 1 ); strcpy( lib, tmpLib ); } } /* Dbp1( "Lib: |%s|\n", lib ); */ n = 0; while ( 0 == SLextract_list_element (lib, n, ',', libfsl, sizeof( libfsl ) ) ) { n++; fixup_dir(libfsl); safe_strcat (libfsl, file, sizeof (libfsl)); safe_strcpy (libfsl, jed_standardize_filename_static(libfsl), sizeof (libfsl)); libf = libfsl; if ( ( 1 == file_status( libf ) ) ) break; libf = NULL; } if ( libf ) { safe_strcpy( retFile, libf, sizeof( retFile ) ); return( retFile ); } else { return( NULL ); } } /*}}}*/ #define JGTK_NUM_KEYFILES 2 #define JGTK_KEYFILE_BASE_NAME "gtkjed.ini" #define JGTK_KEYFILE_HOME_NAME "~/." JGTK_KEYFILE_BASE_NAME static GKeyFile ** getKeyFiles(void) { int i = 0; char *fn; char *expFn; GKeyFile **kf = ( GKeyFile ** ) SLmalloc( sizeof( GKeyFile * ) * ( JGTK_NUM_KEYFILES + 1 ) ); kf[i] = g_key_file_new(); fn = getLibFile( JGTK_KEYFILE_BASE_NAME ); /* Dbp1( "NewTest: |%s|\n", fn ? fn : "(NULL)" ); */ if ( fn ) { if ( g_key_file_load_from_file( kf[i], fn, G_KEY_FILE_KEEP_TRANSLATIONS | G_KEY_FILE_KEEP_COMMENTS, NULL ) ) { i++; kf[i] = g_key_file_new(); } } fn = jed_expand_filename( SLmake_string( JGTK_KEYFILE_HOME_NAME ) ); /* Dbp1( "Begin: %s!!\n", fn ); */ if ( g_key_file_load_from_file( kf[i], fn, G_KEY_FILE_KEEP_TRANSLATIONS | G_KEY_FILE_KEEP_COMMENTS, NULL ) ) { i++; } else { g_key_file_free( kf[i] ); } /* Dbp1( "NewTest01: %d\n", i ); */ kf[i] = NULL; return( kf ); } static void getGtkDefaults(void) { XWindow_Arg_Type *jGtkArgs = jGtkArgList + XARG_START; GKeyFile **kfs = getKeyFiles(); GKeyFile **tmpKfs; if ( *kfs ) { while ( jGtkArgs->name != NULL ) { if ( jGtkArgs->dflt == NULL ) { jGtkArgs++; continue; } if ( jGtkArgs->type != VOID_TYPE && jGtkArgs->value == NULL ) { static char *classNames[] = { "UGtkjed", "UGtkJed", "ugtkjed", NULL }; char *p, *cn; char **cnp; p = NULL; if ( Jed_UTF8_Mode ) { cnp = classNames; while( NULL != ( cn = *cnp++ ) ) { tmpKfs = kfs; while ( *tmpKfs ) { p = g_key_file_get_string( *tmpKfs, cn, jGtkArgs->name, NULL ); if ( p ) break; tmpKfs++; } if ( p != NULL ) break; } } if ( p == NULL ) { cnp = classNames; while ( NULL != ( cn = *cnp++ ) ) { cn++; /* Skip leading U */ tmpKfs = kfs; while ( *tmpKfs ) { p = g_key_file_get_string( *tmpKfs, cn, jGtkArgs->name, NULL ); if ( p ) break; tmpKfs++; } if ( p != NULL ) break; } } if ( p == NULL ) { tmpKfs = kfs; while ( *tmpKfs ) { p = g_key_file_get_string( *tmpKfs, "UXTerm", jGtkArgs->name, NULL ); if ( p ) break; tmpKfs++; } if ( p == NULL ) { tmpKfs = kfs; while ( *tmpKfs ) { p = g_key_file_get_string( *tmpKfs, "XTerm", jGtkArgs->name, NULL ); if ( p ) break; tmpKfs++; } } } if ( p != NULL ) jGtkArgs->value = p; } if ( jGtkArgs->value != NULL ) *jGtkArgs->dflt = jGtkArgs->value; /* Dbp2( "Arg: |%s|: Value: |%s|\n", jGtkArgs->name, jGtkArgs->value ? jGtkArgs->value : "(NULL)" ); */ jGtkArgs++; } } } /* returns socket descriptor */ /************************************ * init_Xdisplay * * group: interface * * * debug print: * * ************************************/ static int init_Xdisplay (void ) /*{{{*/ { #ifdef XJED_USE_R6IM setlocale(LC_ALL, ""); #endif if (jGtkArgList[JGTK_ARG_NAME].value != NULL) { This_App_Name = jGtkArgList[JGTK_ARG_NAME].value; } /* Db; */ getGtkDefaults(); JGtkWin->border = atoi(This_Internal_Border_Name); if ( JGtkWin->border < 0) JGtkWin->border = 0; #if XJED_HAS_XRENDERFONT # if 0 /* if a parameter to -fs was supplied, we assume the user wants XFT */ if (strlen(This_Face_Size)) { if ( ( JGtkWin->face_size = atof( This_Face_Size ) ) <= 0 ) JGtkWin->face_size = 0; } else /* there was no -fs, so we don't do anything */ JGtkWin->face_size = 0; /* make sure that XWin->xftdraw is null in any case */ JGtkWin->xftdraw = NULL; # endif #endif if ( -1 == setupAndParseGtkColors() ) /* This allocs and parses colors */ exit (1); create_XWindow(); JGtkWin->window_mapped = 1; return ConnectionNumber( JGtkWin->XDisplay ); } /*}}}*/ /************************************ * reset_Xdisplay * * group: interface * * * debug print: * * ************************************/ static void reset_Xdisplay (void ) /*{{{*/ { } /*}}}*/ #define UPCSE(x) (((x) <= 'z') && ((x) >= 'a') ? (x) - 32 : (x)) /************************************ * myXstrcmp * * group: * * * debug print: * * ************************************/ static int myXstrcmp(char *a, char *b) /*{{{*/ { register char cha, chb; /* do simple comparison */ cha = *a++; chb = *b++; if ((cha != chb) && (UPCSE(cha) != UPCSE(chb))) return 0; while ((cha = *a++), (chb = *b++), (cha && chb) != 0) { if (cha != chb) return 0; } return (cha == chb); } /*}}}*/ #define STREQS(a, b) myXstrcmp(a, b) /************************************ * X_eval_command_line * * group: * * * debug print: * * ************************************/ static int X_eval_command_line (int argc, char **argv ) /*{{{*/ { char *arg; int i; int cpyArgc = argc; char **cpyArgv = ( char ** ) SLmalloc ( (1+argc) * sizeof( char * ) ); int n; XWindow_Arg_Type *opt; if (cpyArgv == NULL) return -1; /****************************** * Create a copy of argv because gtk_init might modify if ******************************/ for ( i = 0; i < argc; ++i ) { cpyArgv[i] = SLmalloc( 1+strlen( argv[i] ) ); if (cpyArgv[i] == NULL) return -1; strcpy( cpyArgv[i], argv[i] ); } cpyArgv[argc] = NULL; gtk_init( &cpyArgc, &cpyArgv ); /**************************** * Overide original argv, because I don't know * what gtk did to the original cpyArgv/argv * array (might it be freed?). ****************************/ n = argc - cpyArgc; argv[0] = cpyArgv[0]; /* program name */ for ( i = 1; i < cpyArgc; ++i ) { /***************************** * Recreate the format jed likes to process * argc and argv (this means unprocessed arguments * are left at the end of argv). ******************************/ argv[i + n] = cpyArgv[i]; } for ( i = n + 1; i < argc; ++i ) { arg = argv[i]; if (*arg != '-') break; if ( 0 == strcmp( "--debug-xjed", arg ) || 0 == strcmp( "--debug-gtkjed", arg ) ) { Debug_gtkjed = 1; continue; } arg++; opt = jGtkArgList; while ( opt->name != NULL ) { if ( STREQS(opt->name, arg ) || (( opt->name1 != NULL) && STREQS(opt->name1, arg ))) break; opt++; } if ( opt->name == NULL ) break; if ( opt->type == VOID_TYPE ) opt->value = "on"; else if ( i + 1 < argc ) { i++; opt->value = argv[i]; } else break; } /******************* if ( argc > 1 ) { Return( argc - 1 ); } else { Return( argc ); } ******************/ return( i ); } /*}}}*/ /************************************ * set_border_color * * group: * * * debug print: * * ************************************/ static void set_border_color (char *fgc, char *bgc ) /*{{{*/ { XColor xfg; unsigned int bdr = atoi(bgc); } /*}}}*/ /************************************ * JX_set_mono * * group: * * * debug print: * * ************************************/ static JX_SETXXX_RETURN_TYPE JX_set_mono (int obj_unused, char *unused, SLtt_Char_Type c_unused ) { (void) obj_unused; (void) unused; (void) c_unused; return JX_SETXXX_RETURN_VAL; } /************************************ * jGtkSetColor * * group: * * * debug print: * * ************************************/ static JX_SETXXX_RETURN_TYPE jGtkSetColor (int i, char *what, char *fg, char *bg ) { char *savName; GdkColor *fgCol, *bgCol; GdkColor *savCol; /* printf( "JGtk_set_color: File: %s line: %d: i: %d FG: %s, BG: %s\n", __FILE__, __LINE__, i, fg, bg ); */ if ( JGtkWin->appW == NULL) return JX_SETXXX_RETURN_VAL; if (!Term_Supports_Color) return JX_SETXXX_RETURN_VAL; #if SLANG_VERSION >= 10306 SLsmg_touch_screen (); #endif if (i == -1) { if ( !strcmp("mouse", what) ) { set_mouse_color (fg, bg); } else if (!strcmp("border", what)) { set_border_color (fg, bg); } return JX_SETXXX_RETURN_VAL; } savName = DefaultGtkGCInfo[i].fgName; DefaultGtkGCInfo[i].fgName = setupGtkColor( fg, &( DefaultGtkGCInfo[i].fg ), JGtkWin->textGC->fgName, JGtkWin->textGC->fg ); SLfree( savName ); savName = DefaultGtkGCInfo[i].bgName; DefaultGtkGCInfo[i].bgName = setupGtkColor( bg, &( DefaultGtkGCInfo[i].bg ), JGtkWin->textGC->bgName, JGtkWin->textGC->bg ); SLfree( savName ); return JX_SETXXX_RETURN_VAL; } /*}}}*/ /************************************ * JX_set_color * * group: * * * debug print: * * ************************************/ static JX_SETXXX_RETURN_TYPE JX_set_color (int i, char *what, char *fg, char *bg ) { jGtkSetColor( i, what, fg, bg ); return JX_SETXXX_RETURN_VAL; } /*}}}*/ /************************************ * x_warp_pointer * * group: * * * debug print: * * ************************************/ static void x_warp_pointer (void ) /*{{{*/ { /* int x, y; */ /* GtkWidget *w = getEdWinFromJedWin( JWindow ); */ X_Warp_Pending = 1; #if 0 if ( w ) { X_Warp_Pending = 1; gdk_window_get_origin( w->window, &x, &y ); Dbp3( "Windows: %p, x: %d, y: %d\n", w->window, x, y ); x = JGtkWin->fontWidth*( JGtkWin->vis_curs_col + 0.5 ) + x; y = JGtkWin->fontHeight*( JGtkWin->vis_curs_row - 0.5 ) + y; Dbp3( "Windows: %p, x: %d, y: %d\n", w->window, x, y ); gdk_display_warp_pointer( gdk_drawable_get_display( ( GdkDrawable * ) w->window ), gdk_drawable_get_screen( ( GdkDrawable * ) w->window ), x, y ); } #endif } /*}}}*/ static void jgtk_clear_clipboard( GtkClipboard *clb, gpointer data ) { } static void jgtk_provide_clipboard( GtkClipboard *clb, GtkSelectionData *data, guint info, gpointer userData ) { /* gtk_clipboard_set_text( clb, jgtkClipboardData, strlen( jgtkClipboardData ) ); */ /* Dbp3( "ClipboardData: %p: len: %d, data: |%s|\n", jgtkClipboardData, strlen( jgtkClipboardData ), jgtkClipboardData ); */ gtk_selection_data_set( data, gdk_atom_intern( "STRING", FALSE ), 8, jgtkClipboardData, strlen( jgtkClipboardData ) ); } static void jgtk_receive_clipboard_targets( GtkClipboard *clb, GdkAtom *atoms, gint n, gpointer data ) { int i; /* Dbp2( "Clipboard can be provided with %d target types by atoms: %p\n", n, atoms ); */ for ( i = 0; i < n; ++i ) { /* Dbp2( "Target(%3d): |%s|\n", atoms + i, gdk_atom_name( atoms[i] ) ); */ } } static void jgtk_receive_clipboard( GtkClipboard *clb, const gchar *text, gpointer data ) { /* Dbp1( "Text: |%s|\n", text ); */ jed_insert_nbytes( text, strlen( text ) ); update( NULL, 1, 0, 0 ); } static int jgtk_insert_clipboard(void) { gtk_clipboard_request_text( gtk_clipboard_get( GDK_SELECTION_CLIPBOARD ), jgtk_receive_clipboard, NULL ); #if 0 gtk_clipboard_request_targets( gtk_clipboard_get( GDK_SELECTION_CLIPBOARD ), jgtk_receive_clipboard_targets, NULL ); #endif return( 0 ); } static void jgtk_region_2_clipboard(void) { int nbytes; GdkAtom textAtom = gdk_atom_intern( "STRING", FALSE ); static GtkTargetEntry tt = { "STRING", GTK_TARGET_SAME_WIDGET #if 0 | GTK_TARGET_OTHER_APP | GTK_TARGET_OTHER_WIDGET #endif | GTK_TARGET_SAME_APP, 8 }; /************* gtk_clipboard_set_with_data( GtkClipboard *clb, const GtkTargetEntry *targets, guint n_targets, GtkClipboardGetFunc gf: jgtk_provide_clipboard, GtkClipboardClearFunc cf, gpointer userData ); **************/ if ( jgtkClipboardData ) { SLfree( jgtkClipboardData ); } jgtkClipboardData = make_buffer_substring( &nbytes ); gtk_clipboard_set_with_data( gtk_clipboard_get( GDK_SELECTION_CLIPBOARD ), &tt, 1, jgtk_provide_clipboard, jgtk_clear_clipboard, NULL ); } /************************************ * x_insert_selection * * group: * * * debug print: * * ************************************/ static int x_insert_selection( void ) { /* if ( gtkButtonEvent ) */ /* { */ return( gtkInsertSelection() ); /* } */ /* Return 0; */ } /************************************ * gtkInsertSelection * * group: * * * debug print: * * ************************************/ static int gtkInsertSelection( void ) { GdkAtom textAtom = gdk_atom_intern( "STRING", FALSE ); /* printf( "File %s, Line %d: Insert gtk Selection!!!\n", __FILE__, __LINE__ ); */ /*********** gtk_selection_convert( JGtkWin->appWDrawArea, GDK_SELECTION_PRIMARY, textAtom, GDK_CURRENT_TIME ); ********************/ if ( JGtkWin->appWMiniW ) { gtk_selection_convert( JGtkWin->appWMiniW, GDK_SELECTION_PRIMARY, textAtom, GDK_CURRENT_TIME ); } return( 0 ); } /************************************ * gtkSelectionReceive * * group: * * * debug print: * * ************************************/ static void gtkSelectionReceive( GtkWidget *w, GtkSelectionData *selData, gpointer usrData ) { GdkAtom textAtom = gdk_atom_intern( "STRING", FALSE ); char *txt; if ( selData->length < 0 ) { /* printf( "File %s, Line %d: Selection retrieval failed!!!\n", __FILE__, __LINE__ ); */ return; } if ( selData->type != textAtom ) { /* printf( "File %s, Line %d: Selection was not return as STRING!!!\n", __FILE__, __LINE__ ); */ return; } txt = ( char * ) selData->data; jed_insert_nbytes( txt, selData->length ); /* printf( "File %s, Line %d: Selectiontext returned:\n>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n%s<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n\n", __FILE__, __LINE__, txt ); */ } /************************************ * gtkRegionToSelection * * group: * * * debug print: * * ************************************/ static void gtkRegionToSelection( void ) { int nbytes; /* printf( "File %s, Line %d: gtkRegionToSelection!!!\n", __FILE__, __LINE__ ); */ if ( jgtkSelectionData != NULL ) { SLfree( jgtkSelectionData ); } jgtkSelectionData = make_buffer_substring( &nbytes ); if ( jgtkSelectionData == NULL ) return; if ( JGtkWin->appWMiniW ) { gtk_selection_owner_set( JGtkWin->appWMiniW, GDK_SELECTION_PRIMARY, GDK_CURRENT_TIME ); } /************* gtk_selection_owner_set( JGtkWin->appWDrawArea, GDK_SELECTION_PRIMARY, GDK_CURRENT_TIME ); *******/ } /************************************ * jGtkSendSelection * * group: * * * debug print: * * ************************************/ static void jGtkSendSelection( GtkWidget *w, GtkSelectionData *selData, guint info, guint time_stamp, gpointer usrData ) { /* printf( "File %s, Line %d: jGtkSendSelection!!!\n", __FILE__, __LINE__ ); */ gtk_selection_data_set( selData, GDK_SELECTION_TYPE_STRING, 8, jgtkSelectionData, strlen( jgtkSelectionData ) ); } #if 0 typedef struct Selection_Data_Type { unsigned int len; struct Selection_Data_Type *next; unsigned char bytes[1]; } Selection_Data_Type; #endif /************************************ * x_region_2_selection * * group: * * * debug print: * * ************************************/ static void x_region_2_selection (void ) { int nbytes; /* if ( gtkButtonEvent ) */ /* { */ gtkRegionToSelection(); /* } */ } /************************************ * x_server_vendor * * group: * * * debug print: * * ************************************/ static char * x_server_vendor (void ) { return( "" ); } /************************************ * jgtk_server_vendor * * group: * * * debug print: * * ************************************/ static void jgtk_server_vendor (void ) { } #if SLANG_VERSION < 10404 /************************************ * get_termcap_string * * group: * * * debug print: * * ************************************/ static char * get_termcap_string (char *cap) { return ""; } #endif /************************************ * x_set_meta_keys * * group: * * * debug print: * * ************************************/ static void x_set_meta_keys(int *maskp ) { int mask = *maskp; JX_MetaMask = 0; if (mask & (1<<0)) JX_MetaMask |= Mod1Mask; if (mask & (1<<1)) JX_MetaMask |= Mod2Mask; if (mask & (1<<2)) JX_MetaMask |= Mod3Mask; if (mask & (1<<3)) JX_MetaMask |= Mod4Mask; if (mask & (1<<4)) JX_MetaMask |= Mod5Mask; } static SLang_Intrin_Fun_Type sl_x_table[] = /*{{{*/ { MAKE_INTRINSIC_S( "x_set_window_name", set_window_name, VOID_TYPE), MAKE_INTRINSIC_S( "jgtk_set_window_name", set_window_name, VOID_TYPE), MAKE_INTRINSIC_S( "x_set_icon_name", set_icon_name, VOID_TYPE), MAKE_INTRINSIC_S( "jgtk_set_icon_name", set_icon_name, VOID_TYPE), MAKE_INTRINSIC( "x_warp_pointer", x_warp_pointer, VOID_TYPE, 0), MAKE_INTRINSIC("jgtk_warp_pointer", x_warp_pointer, VOID_TYPE, 0), #if 0 /* Maybe some day */ MAKE_INTRINSIC_S( "jgtk_insert_clipboard_by_name", jgtk_insert_clipboard_by_name, INT_TYPE, 0 ), MAKE_INTRINSIC_S( "jgtk_get_clipboard_by_name", jgtk_get_clipboard_by_name, STRING_TYPE ), MAKE_INTRINSIC_SS( "jgtk_set_clipboard_by_name", jgtk_set_clipboard_by_name, VOID_TYPE ), MAKE_INTRINSIC_S( "jgtk_copy_region_to_clipboard_by_name", jgtk_region_2_clipboard_by_name, VOID_TYPE, 0 ), #endif /* Cutbuffer no longer supported. */ /* (see also: http://www.freedesktop.org/Standards/clipboards-spec) */ /* Instead of cutbuffer gtk clipboard is used. */ MAKE_INTRINSIC( "x_insert_cutbuffer", jgtk_insert_clipboard, INT_TYPE, 0), MAKE_INTRINSIC("jgtk_insert_clipboard", jgtk_insert_clipboard, INT_TYPE, 0), /* Prototype: Integer x_insert_cutbuffer (); * Inserts cutbuffer into the current buffer and returns the number * of characters inserted. */ MAKE_INTRINSIC("x_copy_region_to_cutbuffer", jgtk_region_2_clipboard, VOID_TYPE, 0), MAKE_INTRINSIC("jgtk_copy_region_to_clipboard", jgtk_region_2_clipboard, VOID_TYPE, 0), /*Prototype: Void x_copy_region_to_cutbuffer(); */ MAKE_INTRINSIC( "x_insert_selection", x_insert_selection, SLANG_INT_TYPE, 0), MAKE_INTRINSIC( "jgtk_insert_selection", x_insert_selection, SLANG_INT_TYPE, 0), /* Prototype: Integer x_insert_selection (); * This function only requests selection data from the selection owner. * If Xjed received EVENT, Xjed inserts selection data into the current buffer. * And returns the number of characters inserted. */ MAKE_INTRINSIC( "x_copy_region_to_selection", x_region_2_selection, VOID_TYPE, 0), MAKE_INTRINSIC( "jgtk_copy_region_to_selection", x_region_2_selection, VOID_TYPE, 0), /*Prototype: Void x_copy_region_to_selection(); */ MAKE_INTRINSIC_IIS( "x_set_keysym", x_set_keysym, VOID_TYPE), MAKE_INTRINSIC_IIS( "jgtk_set_keysym", x_set_keysym, VOID_TYPE), /*Prototype: Void x_set_keysym (Integer keysym, Integer shift, String str); * * This function may be used to assocate a string 'str' with a key * 'keysym' modified by mask @shift@. Pressing the key associated with * @keysym@ will then generate the keysequence given by @str@. The * function keys are mapped to integers in the range @0xFF00@ to @0xFFFF@. * On most systems, the keys that these mappings refer to are located in * the file @/usr/include/X11/keysymdef.h@. For example, on my system, the * keysyms for the function keys @XK_F1@ to @XK_F35@ fall in the range * @0xFFBE@ to @0xFFE0@. So to make the @F1@ key correspond to the string * given by the two characters @Ctrl-X@ @Ctrl-C@, simply use: * @ x_set_keysym (0xFFBE, 0, "^X^C"); * The @shift@ argument is an integer with the following meanings: * @ 0 : unmodified key * @ '$' : shifted * @ '^' : control * Any other value for shift will default to 0 (unshifted). */ MAKE_INTRINSIC_I( "x_set_meta_keys", x_set_meta_keys, SLANG_VOID_TYPE), MAKE_INTRINSIC_I( "jgtk_set_meta_keys", x_set_meta_keys, SLANG_VOID_TYPE), MAKE_INTRINSIC( "x_server_vendor", x_server_vendor, STRING_TYPE, 0), /* Prototype: String x_server_vendor (); * This function returns the empty string for the X server. * Only provided for compatibily reasons. */ MAKE_INTRINSIC( "jgtk_server_vendor", jgtk_server_vendor, VOID_TYPE, 0), /* Prototype: String x_server_vendor (); * Do nothing. Provided to identify gtkjed. */ MAKE_INTRINSIC( "jgtk_print_widget_struct", printWidgetStruct, VOID_TYPE, 0 ), #if 0 MAKE_INTRINSIC( "scrollDown", jGtkScrollDown, SLANG_VOID_TYPE, 0 ), /* Prototype: int jGtkScrollDown( void ); * Scrolls down one line. Cursor remains in the same line relative to * the window. */ MAKE_INTRINSIC( "scrollUp", jGtkScrollUp, SLANG_INT_TYPE, 0 ), /* Prototype: int jGtkScrollUp( void ); * Scrolls up one line. Cursor remains in the same line relative to * the window. */ #endif MAKE_INTRINSIC_S("jgtk_load_font", loadFont, VOID_TYPE ), #if SLANG_VERSION < 10404 MAKE_INTRINSIC_S("get_termcap_string", get_termcap_string, STRING_TYPE), #endif MAKE_INTRINSIC(NULL,NULL,0,0) }; /*}}}*/ static SLang_Intrin_Var_Type X_Variable_Table [] = { MAKE_VARIABLE("ALT_CHAR", &X_Alt_Char, INT_TYPE, 0), MAKE_VARIABLE("X_LAST_KEYSYM", &X_Last_Keysym, INT_TYPE, 0), MAKE_VARIABLE(NULL,NULL,0,0) }; /************************************ * X_init_slang * * group: * * * debug print: * * ************************************/ static int X_init_slang (void ) /*{{{*/ { /* cfXDVarAsk = 1; */ if ((-1 == SLadd_intrin_fun_table (sl_x_table, "XWINDOWS")) || (-1 == SLadd_intrin_var_table (X_Variable_Table, NULL))) return -1; return 0; } /*}}}*/ /************************************ * X_update_open * * group: interface * * * debug print: * * ************************************/ static void X_update_open (void ) /*{{{*/ { hide_cursor (); if (Check_Buffers_Pending) { check_buffers(); Check_Buffers_Pending = 0; } Performing_Update = 1; } /*}}}*/ /************************************ * X_update_close * * group: interface * * * debug print: * * ************************************/ static void X_update_close (void ) /*{{{*/ { Performing_Update = 0; show_cursor (); if ( X_Warp_Pending ) { int x, y; GtkWidget *w = getEdWinFromJedWin( JWindow ); if ( w ) { gdk_window_get_origin( w->window, &x, &y ); /* Dbp3( "Windows: %p, x: %d, y: %d\n", w->window, x, y ); */ x = JGtkWin->fontWidth*( JGtkWin->vis_curs_col + 0.5 ) + x; y = JGtkWin->fontHeight*( JGtkWin->vis_curs_row - 0.5 ) + y; /* Dbp3( "Windows: %p, x: %d, y: %d\n", w->window, x, y ); */ gdk_display_warp_pointer( gdk_drawable_get_display( ( GdkDrawable * ) w->window ), gdk_drawable_get_screen( ( GdkDrawable * ) w->window ), x, y ); } X_Warp_Pending = 0; } } /*}}}*/ /************************************ * funCallCB * * group: * * * debug print: * * ************************************/ static int funCallCB(void) { ( *actFunToCall )( actParaData ); return 0; } /************************************ * x_define_xkeys * * group: interface * * * debug print: * * ************************************/ static void x_define_xkeys (SLKeyMap_List_Type *map ) /*{{{*/ { SLkm_define_key ("\033[^D", (FVOID_STAR) jed_scroll_right_cmd, map); SLkm_define_key ("\033[d", (FVOID_STAR) jed_scroll_right_cmd, map); SLkm_define_key ("\033[^C", (FVOID_STAR) jed_scroll_left_cmd, map); SLkm_define_key ("\033[c", (FVOID_STAR) jed_scroll_left_cmd, map); SLkm_define_key ("\033[a", (FVOID_STAR) bob, map); SLkm_define_key ("\033[^A", (FVOID_STAR) bob, map); SLkm_define_key ("\033[b", (FVOID_STAR) eob, map); SLkm_define_key ("\033[^B", (FVOID_STAR) eob, map); SLkm_define_key ("\033[1~", (FVOID_STAR) bol, map); /* home */ SLkm_define_key ("\033[4~", (FVOID_STAR) eol, map); /* end */ SLkm_define_key( FC_CMD_KEY_SEQ, (FVOID_STAR) funCallCB, Global_Map ); } /*}}}*/ /************************************ * JX_reset_video * * group: interface * * * debug print: * * ************************************/ static int JX_reset_video (void ) /*{{{*/ { JX_reset_scroll_region (); JX_goto_rc (0, 0); JX_normal_video (); /* Return vterm_reset_display (); */ return 0; } /*}}}*/ /************************************ * JX_init_video * * group: interface * * * debug print: * * ************************************/ static int JX_init_video (void ) /*{{{*/ { JX_reset_video (); if ((JX_Screen_Rows == 0) || (JX_Screen_Cols == 0)) { JX_Screen_Cols = 80; JX_Screen_Rows = 24; } /* Return vterm_init_display (JX_Screen_Rows, JX_Screen_Cols); */ return 0; } /*}}}*/ /************************************ * flush_output * * group: * * * debug print: * * ************************************/ void flush_output (void ) /*{{{*/ { if ( JGtkWin->XDisplay == NULL) fflush (stdout); else SLtt_flush_output (); } /*}}}*/ /* a hook to parse some command line args. */ int (*X_Argc_Argv_Hook)(int, char **) = X_eval_command_line; /************************************ * JX_flush_output * * group: interface * * * debug print: * * ************************************/ static int JX_flush_output (void ) { return 0; } static int JX_Zero = 0; /************************************ * get_screen_size * * group: * * * debug print: * * ************************************/ static void get_screen_size (int *r, int *c ) { SLtt_get_screen_size (); *r = SLtt_Screen_Rows; *c = SLtt_Screen_Cols; } /* the links to functions and variables here */ void (*tt_beep)(void); void (*tt_write_string)(char *); JX_SETXXX_RETURN_TYPE (*tt_set_color)(int, char *, char *, char *); JX_SETXXX_RETURN_TYPE (*tt_set_color_esc)(int, char *); JX_SETXXX_RETURN_TYPE (*tt_set_mono) (int, char *, SLtt_Char_Type); void (*tt_wide_width)(void); void (*tt_narrow_width)(void); void (*tt_enable_cursor_keys)(void); void (*tt_set_term_vtxxx)(int *); void (*tt_get_screen_size)(int *, int *); int *tt_Ignore_Beep; int *tt_Use_Ansi_Colors; int *tt_Term_Cannot_Scroll; int *tt_Term_Cannot_Insert; int *tt_Blink_Mode; /* int *tt_Baud_Rate; */ /************************************ * set_xtt_hooks * * group: * * * debug print: * * ************************************/ static void set_xtt_hooks( void ) { tt_beep = JX_beep; tt_write_string = JX_write_string; tt_get_screen_size = JX_get_display_size; tt_set_color = JX_set_color; tt_set_mono = JX_set_mono; tt_wide_width = JX_wide_width; tt_narrow_width = JX_narrow_width; tt_enable_cursor_keys = JX_enable_cursor_keys; tt_set_term_vtxxx = JX_set_term_vtxxx; tt_Ignore_Beep = &JX_Ignore_Beep; tt_Use_Ansi_Colors = &JX_Use_Ansi_Colors; tt_Term_Cannot_Scroll = &JX_Term_Cannot_Scroll; tt_Term_Cannot_Insert = &JX_Term_Cannot_Insert; tt_Blink_Mode = &JX_Blink_Mode; } /************************************ * JX_get_terminfo * * group: * * * debug print: * * ************************************/ static void JX_get_terminfo( void ) /*{{{*/ { SLsmg_Term_Type tt; if ((Batch) || !open_Xdisplay()) { /* This function should match the corresponding function in display.c. * I should "include" it to guarantee the correspondence. */ tt_beep = SLtt_beep; tt_write_string = SLtt_write_string; tt_get_screen_size = get_screen_size; tt_set_color = SLtt_set_color; tt_set_mono = SLtt_set_mono; #if SLANG_VERSION < 20000 tt_set_color_esc = SLtt_set_color_esc; #endif tt_wide_width = SLtt_wide_width; tt_narrow_width = SLtt_narrow_width; tt_enable_cursor_keys = SLtt_enable_cursor_keys; tt_set_term_vtxxx = SLtt_set_term_vtxxx; tt_Ignore_Beep = &SLtt_Ignore_Beep; tt_Use_Ansi_Colors = &SLtt_Use_Ansi_Colors; tt_Term_Cannot_Scroll = &SLtt_Term_Cannot_Scroll; tt_Term_Cannot_Insert = &SLtt_Term_Cannot_Insert; tt_Blink_Mode = &SLtt_Blink_Mode; /* tt_Baud_Rate = &SLtt_Baud_Rate; */ if (Batch == 0) SLtt_get_terminfo (); return; } set_xtt_hooks (); if (-1 == init_xkeys ()) { } JX_Screen_Cols = 80; JX_Screen_Rows = 24; (void) jed_add_init_slang_hook (X_init_slang); /* init hooks */ X_Read_Hook = X_read_key; X_Input_Pending_Hook = X_input_pending; X_Update_Open_Hook = X_update_open; X_Update_Close_Hook = X_update_close; X_Suspend_Hook = xjed_suspend; X_Init_Term_Hook = init_Xdisplay; X_Reset_Term_Hook = reset_Xdisplay; X_Define_Keys_Hook = x_define_xkeys; SLang_Interrupt = xjed_check_kbd; /* Set this so that main will not try to read from stdin. It is quite * likely that this is started from a menu or something. */ Stdin_Is_TTY = -1; /* We do not need this since we do not have to worry about incoming * eight bit escape sequences. tt_goto_rc */ DEC_8Bit_Hack = 0; memset ((char *) &tt, 0, sizeof (SLsmg_Term_Type)); tt.tt_normal_video = JX_normal_video; tt.tt_set_scroll_region = JX_set_scroll_region; tt.tt_goto_rc = JX_goto_rc; tt.tt_reverse_index = JX_reverse_index; tt.tt_reset_scroll_region = JX_reset_scroll_region; tt.tt_delete_nlines = JX_delete_nlines; tt.tt_cls = JX_cls; tt.tt_del_eol = JX_del_eol; tt.tt_smart_puts = JX_smart_puts; tt.tt_flush_output = JX_flush_output; tt.tt_reset_video = JX_reset_video; tt.tt_init_video = JX_init_video; tt.tt_screen_rows = &JX_Screen_Rows; tt.tt_screen_cols = &JX_Screen_Cols; tt.tt_term_cannot_scroll = &JX_Term_Cannot_Scroll; tt.tt_has_alt_charset = &JX_Zero; #if SLANG_VERSION >= 20000 tt.unicode_ok = &Jed_UTF8_Mode; #endif SLsmg_set_terminal_info (&tt); Jed_Handle_SIGTSTP = 0; if ( 1 ) return; } /*}}}*/ void (*tt_get_terminfo)(void) = JX_get_terminfo; /* Unused but required. */ #ifdef USE_GPM_MOUSE int (*X_Open_Mouse_Hook)(void); void (*X_Close_Mouse_Hook)(void); #endif jed-0.99-19/src/jedwin.c0000644002657400265740000000130211311317447013701 0ustar davisdavis/* -*- default window hooks for non-GUI jed */ /* Copyright (c) 2009 John E. Davis * This file is part of JED editor library source. * * You may distribute this file under the terms the GNU General Public * License. See the file COPYING for more information. */ #include "config.h" #include "jed-feat.h" #include "window.h" int (*jed_new_window_cb) (Window_Type *) = NULL; void (*jed_free_window_cb) (Window_Type *) = NULL; int (*jed_create_mini_window_cb) (Window_Type *) = NULL; int (*jed_leave_window_cb) (Window_Type *) = NULL; int (*jed_enter_window_cb) (Window_Type *) = NULL; int (*jed_split_window_cb) (Window_Type *, Window_Type *) = NULL; int (*jed_window_geom_change_cb) (void) = NULL; jed-0.99-19/src/blocal.h0000644002657400265740000000157111311317447013672 0ustar davisdavis/* Copyright (c) 1992, 1998, 2000, 2005, 2006 John E. Davis * This file is part of JED editor library source. * * You may distribute this file under the terms the GNU General Public * License. See the file COPYING for more information. */ #if JED_HAS_BUFFER_LOCAL_VARS typedef struct { char *name; /* slstring */ SLang_Any_Type *value; } Jed_BLocal_Type; #define MAX_BLOCAL_VARS_PER_TABLE 10 typedef struct _Jed_BLocal_Table_Type { unsigned int num; Jed_BLocal_Type local_vars[MAX_BLOCAL_VARS_PER_TABLE]; struct _Jed_BLocal_Table_Type *next; } Jed_BLocal_Table_Type; extern void jed_delete_blocal_vars (Jed_BLocal_Table_Type *); extern void jed_make_blocal_var (char *); extern void jed_set_blocal_var (char *); extern void jed_get_blocal_var (char *); extern int jed_blocal_var_exists (char *); #endif /* JED_HAS_BUFFER_LOCAL_VARS */ jed-0.99-19/src/window.h0000644002657400265740000000516511311317447013750 0ustar davisdavis/* Copyright (c) 1992, 1998, 2000, 2005, 2006 John E. Davis * This file is part of JED editor library source. * * You may distribute this file under the terms the GNU General Public * License. See the file COPYING for more information. */ #ifndef __JED_WINDOW_H_ #define __JED_WINDOW_H_ #include "buffer.h" typedef struct Window_Type { struct Window_Type *next; int sx, sy; /* column/row of window start in display (from 0) */ int rows; /* number of rows (does not include status line) */ int width; int hscroll_column; /* numbered from 1 */ Buffer *buffer; Mark beg; /* buffer position of top corner */ Mark mark; /* last cursor pos in window before switch */ int trashed; /* true if one or more lines in window were changed */ #define MINIBUFFER_WINDOW 0x01 int flags; /* Note that trashed should be a bit here */ void *private_data; /* used by the callback functions */ } Window_Type; /* The mini window exists at all times. When active, it is part of the * window list. When inactive, it is not part of the list. */ extern Window_Type *JMiniWindow; extern Window_Type *JWindow; #define IN_MINI_WINDOW (JWindow->flags & MINIBUFFER_WINDOW) extern Window_Type *jed_create_minibuffer_window (void); /* Window callbacks for GUIs. If any of these return -1, it is regarded as * a fatal error, and jed will exit. */ extern int (*jed_new_window_cb) (Window_Type *); extern void (*jed_free_window_cb) (Window_Type *); extern int (*jed_create_mini_window_cb) (Window_Type *); extern int (*jed_leave_window_cb) (Window_Type *); extern int (*jed_enter_window_cb) (Window_Type *); extern int (*jed_split_window_cb) (Window_Type *oldwin, Window_Type *newwin); extern int (*jed_window_geom_change_cb) (void); extern void touch_screen_for_buffer(Buffer *); extern void touch_window_hard(Window_Type *, int); extern int is_line_visible (int); extern int split_window(void); extern int other_window(void); extern int one_window(void); extern int delete_window(void); extern int enlarge_window(void); extern void window_buffer(Buffer *); /* jed_update_window_sizes must be called before Jed_Num_Screen_Rows/Cols * has been set. */ extern void jed_update_window_sizes (int, int); extern int buffer_visible(Buffer *); extern int Top_Window_SY; extern void jed_scroll_left (int); extern void jed_scroll_right (int); extern void jed_set_scroll_column (int); extern int jed_get_scroll_column (void); extern int jed_num_windows (void); extern int jed_init_window_intrinsics (void); #if JED_HAS_SUBPROCESSES extern void move_window_marks (int); #endif #endif jed-0.99-19/src/replace.c0000644002657400265740000002207411311317447014045 0ustar davisdavis/* -*- mode: C; mode: fold; -*- */ /* Copyright (c) 1992, 1998, 2000, 2002, 2003, 2004, 2005, 2006 John E. Davis * This file is part of JED editor library source. * * You may distribute this file under the terms the GNU General Public * License. See the file COPYING for more information. */ #include "config.h" #include "jed-feat.h" /*{{{ Include Files */ #include #include #include #include "jdmacros.h" #include "buffer.h" #include "replace.h" #include "search.h" #include "screen.h" #include "ins.h" #include "ledit.h" #include "misc.h" #include "paste.h" #include "cmds.h" /*}}}*/ int Replace_Preserve_Case = 0; #define USE_PRESERVE_CASE 0 /* returns the length of the region inserted. */ static int replace_chars (int n, char *neew) /*{{{*/ { int len; #if USE_PRESERVE_CASE int preserve_case; char *old = NULL; int i; #endif CHECK_READ_ONLY if (n < 0) return 0; len = strlen (neew); #if USE_PRESERVE_CASE preserve_case = (Replace_Preserve_Case && (len == n)); #endif jed_push_mark (); #if USE_PRESERVE_CASE if (preserve_case) jed_push_mark (); #endif n = jed_right (n); #if USE_PRESERVE_CASE if (preserve_case) { if (n == len) { if (NULL == (old = make_buffer_substring(&n))) return 0; } else { preserve_case = 0; jed_pop_mark (&Number_Zero); } } #endif delete_region (); #if USE_PRESERVE_CASE if (preserve_case) { unsigned char ch; for (i = 0; i < len; i++) { ch = (unsigned char) old[i]; if (ch == UPPER_CASE(ch)) { if (ch == LOWER_CASE(ch)) old[i] = neew[i]; else old[i] = UPPER_CASE(neew[i]); } else old[i] = LOWER_CASE(neew[i]); } neew = old; } #endif (void) jed_insert_nbytes ((unsigned char *) neew, len); #if USE_PRESERVE_CASE if (preserve_case) SLfree (old); #endif return len; } /*}}}*/ static int replace_bytes (unsigned int n, unsigned char *str) { unsigned int len = strlen ((char *)str); if (-1 == jed_push_mark ()) return -1; if (n != jed_right_bytes (n)) return -1; delete_region (); if (-1 == jed_insert_nbytes (str, len)) return -1; return (int) len; } /* This code implements a kill ring of sorts. It could be done in S-Lang but * S-Lang cannot handle strings with embedded NULL characters. I do not * want to lose compatability with C or I would allow S-Lang strings to handle * the NULL chars. */ #ifndef SIXTEEN_BIT_SYSTEM # define MAX_KILL_ARRAY_SIZE 16 int Kill_Array_Size = MAX_KILL_ARRAY_SIZE; typedef struct /*{{{*/ { unsigned char *buf; int len; } /*}}}*/ Char_Array_Type; Char_Array_Type Kill_Array [MAX_KILL_ARRAY_SIZE]; void copy_region_to_kill_array (int *np) /*{{{*/ { int n = *np; if (n < 0) n = 0; n = n % MAX_KILL_ARRAY_SIZE; SLfree ((char *) Kill_Array[n].buf); Kill_Array[n].buf = (unsigned char *) make_buffer_substring (&Kill_Array[n].len); } /*}}}*/ void insert_from_kill_array (int *np) /*{{{*/ { int n = *np; unsigned char *buf; if (CBuf->flags & READ_ONLY) { msg_error (Read_Only_Error); return; } if (n < 0) n = 0; n = n % MAX_KILL_ARRAY_SIZE; if ((buf = Kill_Array[n].buf) == NULL) return; (void) jed_insert_nbytes (buf, Kill_Array[n].len); } /*}}}*/ void append_region_to_kill_array (int *np) /*{{{*/ { int n = *np, len, oldlen; unsigned char *buf, *newbuf; if (n < 0) n = 0; n = n % MAX_KILL_ARRAY_SIZE; buf = (unsigned char *) make_buffer_substring (&len); if (buf == NULL) return; oldlen = Kill_Array[n].len; newbuf = (unsigned char *) SLrealloc ((char *)Kill_Array[n].buf, oldlen + len + 1); if (newbuf != NULL) { SLMEMCPY ((char *) newbuf + oldlen, (char *) buf, len); Kill_Array[n].buf = newbuf; Kill_Array[n].len = oldlen + len; } SLfree ((char *)buf); } /*}}}*/ void prepend_region_to_kill_array (int *np) /*{{{*/ { int n = *np, len, oldlen; unsigned char *buf, *newbuf; if (n < 0) n = 0; n = n % MAX_KILL_ARRAY_SIZE; buf = (unsigned char *) make_buffer_substring (&len); if (buf == NULL) return; oldlen = Kill_Array[n].len; newbuf = (unsigned char *) SLrealloc ((char *)Kill_Array[n].buf, oldlen + len + 1); if (newbuf != NULL) { #if 0 /* there's no SLMEMMOVE - and memmove isn't always there (pre-ANSI * systems have bcopy instead, with ptr arguments swapped) */ memmove ((char *) newbuf + len, (char *) newbuf, oldlen); #else /* SLMEMCPY doesn't handle overlapping regions. */ int i; for (i = oldlen - 1; i >= 0; i--) newbuf[len + i] = newbuf[i]; #endif SLMEMCPY ((char *) newbuf, (char *) buf, len); Kill_Array[n].buf = newbuf; Kill_Array[n].len = oldlen + len; } SLfree ((char *)buf); } /*}}}*/ #endif /* NOT 16bit system */ static unsigned char *char_to_string (SLwchar_Type wch, unsigned char buf[JED_MAX_MULTIBYTE_SIZE+1]) { /* Will only fail if the buffer is too small-- it is not here */ unsigned char *b; if (NULL == (b = jed_wchar_to_multibyte (wch, buf))) return NULL; *b = 0; /* \0 terminate buf */ return buf; } static int bol_bsearch_char (SLwchar_Type *wch) /*{{{*/ { unsigned char buf[JED_MAX_MULTIBYTE_SIZE+1]; return bol_bsearch ((char *)char_to_string (*wch, buf)); } /*}}}*/ static int bol_fsearch_char (SLwchar_Type *wch) /*{{{*/ { unsigned char buf[JED_MAX_MULTIBYTE_SIZE+1]; return bol_fsearch ((char *)char_to_string (*wch, buf)); } /*}}}*/ static int fsearch_char (SLwchar_Type *wch) /*{{{*/ { unsigned char buf[JED_MAX_MULTIBYTE_SIZE+1]; return search_forward ((char *)char_to_string (*wch, buf)); } /*}}}*/ static int bsearch_char (SLwchar_Type *wch) /*{{{*/ { unsigned char buf[JED_MAX_MULTIBYTE_SIZE+1]; return search_backward ((char *)char_to_string (*wch, buf)); } /*}}}*/ static int ffind_char (SLwchar_Type *wch) /*{{{*/ { unsigned char buf[JED_MAX_MULTIBYTE_SIZE+1]; return forward_search_line ((char *)char_to_string (*wch, buf)); } /*}}}*/ static int bfind_char (SLwchar_Type *wch) /*{{{*/ { unsigned char buf[JED_MAX_MULTIBYTE_SIZE+1]; return backward_search_line ((char *)char_to_string (*wch, buf)); } /*}}}*/ static void widen_this_buffer (void) /*{{{*/ { jed_widen_whole_buffer (CBuf); } /*}}}*/ static int is_visible_mark (void) /*{{{*/ { if ((CBuf->marks == NULL) || (0 == (CBuf->marks->flags & VISIBLE_MARK))) return 0; return 1; } /*}}}*/ static int set_buffer_umask (int *cmask) { int u = CBuf->umask; if (*cmask != -1) CBuf->umask = *cmask; return u; } static int replace_chars_intrinsic (int *np, char *s) { return replace_chars (*np, s); } static int replace_next(char *old, char *neew) /*{{{*/ { int n; if (search(old, 1, 0) == 0) return(0); n = strlen (old); (void) replace_bytes (n, (unsigned char *)neew); return(1); } /*}}}*/ static void replace_cmd(char *old, char *neew) /*{{{*/ { CHECK_READ_ONLY_VOID push_spot (); if (search(old, 1, 0)) while(replace_next(old, neew)) ; pop_spot(); return; } /*}}}*/ SLang_Intrin_Fun_Type Jed_Other_Intrinsics [] = /*{{{*/ { MAKE_INTRINSIC_I("set_buffer_umask", set_buffer_umask, INT_TYPE), MAKE_INTRINSIC_S("fsearch", search_forward, INT_TYPE), MAKE_INTRINSIC_S("bsearch", search_backward, INT_TYPE), MAKE_INTRINSIC_S("bfind", backward_search_line, INT_TYPE), MAKE_INTRINSIC_S("ffind", forward_search_line, INT_TYPE), MAKE_INTRINSIC_S("bol_fsearch", bol_fsearch, INT_TYPE), MAKE_INTRINSIC_S("bol_bsearch", bol_bsearch, INT_TYPE), MAKE_INTRINSIC_1("bol_fsearch_char", bol_fsearch_char, INT_TYPE, SLANG_WCHAR_TYPE), MAKE_INTRINSIC_1("bol_bsearch_char", bol_bsearch_char, INT_TYPE, SLANG_WCHAR_TYPE), MAKE_INTRINSIC_1("fsearch_char", fsearch_char, INT_TYPE, SLANG_WCHAR_TYPE), MAKE_INTRINSIC_1("bsearch_char", bsearch_char, INT_TYPE, SLANG_WCHAR_TYPE), MAKE_INTRINSIC_1("bfind_char", bfind_char, INT_TYPE, SLANG_WCHAR_TYPE), MAKE_INTRINSIC_1("ffind_char", ffind_char, INT_TYPE, SLANG_WCHAR_TYPE), MAKE_INTRINSIC_SS("replace", replace_cmd, VOID_TYPE), MAKE_INTRINSIC_IS("replace_chars", replace_chars_intrinsic, INT_TYPE), MAKE_INTRINSIC_I("regexp_nth_match", regexp_nth_match, VOID_TYPE), MAKE_INTRINSIC_SI("replace_match", replace_match, INT_TYPE), MAKE_INTRINSIC_S("re_fsearch", re_search_forward, INT_TYPE), MAKE_INTRINSIC_S("re_bsearch", re_search_backward, INT_TYPE), MAKE_INTRINSIC("is_visible_mark", is_visible_mark, INT_TYPE, 0), #if JED_HAS_SAVE_NARROW MAKE_INTRINSIC("push_narrow", jed_push_narrow, VOID_TYPE, 0), MAKE_INTRINSIC("pop_narrow", jed_pop_narrow, VOID_TYPE, 0), #endif #if JED_HAS_BUFFER_LOCAL_VARS MAKE_INTRINSIC_S("blocal_var_exists", jed_blocal_var_exists, SLANG_INT_TYPE), MAKE_INTRINSIC_S("set_blocal_var", jed_set_blocal_var, VOID_TYPE), MAKE_INTRINSIC_S("_get_blocal_var", jed_get_blocal_var, VOID_TYPE), MAKE_INTRINSIC_S("create_blocal_var", jed_make_blocal_var, VOID_TYPE), #endif MAKE_INTRINSIC("count_narrows", jed_count_narrows, INT_TYPE, 0), MAKE_INTRINSIC("widen_buffer", widen_this_buffer, VOID_TYPE, 0), MAKE_INTRINSIC(NULL, NULL, 0, 0) }; /*}}}*/ jed-0.99-19/src/win16.c0000644002657400265740000002367211311317447013403 0ustar davisdavis/* Copyright (c) 1992, 1998, 2000, 2002, 2003, 2004, 2005, 2006 John E. Davis * This file is part of JED editor library source. * * You may distribute this file under the terms the GNU General Public * License. See the file COPYING for more information. */ #include "config.h" #include "jed-feat.h" #include #include #include #include "jdmacros.h" #include #include #include #if defined(__BORLANDC__) # include # include #endif #include #include #include #include #include "display.h" //#include "buffer.h" #include "sysdep.h" #include "screen.h" #include "keymap.h" #include "hooks.h" #include "ins.h" #include "ledit.h" #include "misc.h" #include "cmds.h" #include "sig.h" extern void process_message(void); BOOL CALLBACK EnumWndProc(HWND, LPARAM); extern HINSTANCE hPrevInst; extern HINSTANCE hInstance; extern HINSTANCE _hPrev, _hInstance; static int x_insert_cutbuffer(void); static void x_region_2_cutbuffer(void); static void x_warp_pointer(void); static int msw_system(char *, int *, int *); static SLang_Intrin_Fun_Type Jed_WinCommon_Table[] = { MAKE_INTRINSIC("x_warp_pointer", x_warp_pointer, VOID_TYPE, 0), MAKE_INTRINSIC("x_insert_cutbuffer", x_insert_cutbuffer, INT_TYPE, 0), /* Prototype: Integer x_insert_cut_buffer (); * Inserts cutbuffer into the current buffer and returns the number * of characters inserted. */ MAKE_INTRINSIC("x_copy_region_to_cutbuffer", x_region_2_cutbuffer, VOID_TYPE, 0), /*Prototype: Void x_copy_region_to_cutbuffer();*/ SLANG_END_TABLE }; int init_tty(void) { SLadd_intrinsic_function ("msw_system", (FVOID_STAR) msw_system, SLANG_INT_TYPE, 3, SLANG_STRING_TYPE, SLANG_INT_TYPE, SLANG_INT_TYPE); if ((-1 == SLadd_intrin_fun_table (Jed_WinCommon_Table, "MSWINDOWS")) || (-1 == SLdefine_for_ifdef ("MOUSE"))) return -1; return 0; } void reset_tty(void) { } typedef struct _Process_Info { HINSTANCE hInstance; HWND hWnd; HTASK hTask; } Process_Info; int msw_system(char *command_line, int *nCmdShow, int *wait) { UINT retcode; HCURSOR hcur, hcur_old; MSG msg; WNDENUMPROC enumproc; Process_Info pi; retcode = WinExec(command_line, *nCmdShow); if (retcode < 32) { switch (retcode) { case 0: case 11: case 12: case 14: case 15: msg_error("Invalid EXE file"); break; case 2: msg_error("File not found"); break; case 3: msg_error("Path not found"); break; case 8: msg_error("Out of memory"); break; case 10: msg_error("Incorrect MS Windows version"); break; case 16: msg_error("Cannot run more that one instance of application"); break; case 20: msg_error("Cannot find one of required DLL's"); break; case 21: msg_error("Application requires MS Windows 32-bit extension"); break; default: msg_error("Unknown error"); } return retcode; } if (!*wait) return 0; pi.hInstance = (HINSTANCE) retcode; pi.hWnd = NULL; pi.hTask = NULL; enumproc = (WNDENUMPROC) MakeProcInstance((FARPROC)EnumWndProc,hInstance); EnumWindows(enumproc, (LPARAM) &pi); FreeProcInstance((FARPROC)enumproc); hcur = LoadCursor(NULL, IDC_WAIT); hcur_old = SetCursor(hcur); while (1) { if (!IsWindow(pi.hWnd) || !IsTask(pi.hTask)) break; if ((HINSTANCE) GetWindowWord(pi.hWnd, GWW_HINSTANCE) != pi.hInstance) break; if (GetWindowTask(pi.hWnd) != pi.hTask) break; if (PeekMessage(&msg, 0, 0, 0, PM_NOREMOVE)) { process_message(); SetCursor(hcur); } } SetCursor(hcur_old); return 0; } BOOL CALLBACK EnumWndProc(HWND hWnd, LPARAM lParam) { Process_Info *pi = (Process_Info *) lParam; if ((HINSTANCE) GetWindowWord(hWnd, GWW_HINSTANCE) == pi->hInstance) { pi->hWnd = hWnd; pi->hTask = GetWindowTask(hWnd); return FALSE; } return TRUE; } static int dos_system(char *command_line) { char *tmp_file = "jedshell.tmp"; char buf[JED_MAX_PATH_LEN]; FILE *f; int ret; int nCmdShow = SW_SHOWMINIMIZED; int wait = TRUE; SLsnprintf(buf, sizeof(buf), "%s\\bin\\mswshell.pif %s", Jed_Root_Dir, command_line); sys_delete_file(tmp_file); if (msw_system(buf, &nCmdShow, &wait) != 0) return 1; if (NULL == (f = fopen(tmp_file, "r"))) return 1; fgets(buf, sizeof(buf), f); ret = (int) atol(buf); *buf = 0; fgets(buf, sizeof(buf), f); fclose(f); sys_delete_file(tmp_file); if (*buf != 0) msg_error(buf); return ret; } int sys_System(char *command_line) { return dos_system(command_line); } /* to make slang.lib happy * There is no definition of function system for MS Windows */ int system(const char *command) { return sys_System((char *) command); } void sys_pause (int ms) { DWORD t = GetTickCount() + ms; while (GetTickCount() < t) process_message(); } /* Delete the file NAME. returns 0 on failure, 1 on sucess * Under OS/2 and DOS, unlink()[UNIX] and remove()[ANSI] are equivalent. */ int sys_delete_file(char *name) { return(1 + remove(name)); } static struct ffblk The_ffblk; static int File_Attr; #define HIDDEN FA_HIDEN #define SYSTEM FA_SYSTEM #define SUBDIR FA_DIREC #define READON FA_RDONLY static char Found_Dir[JED_MAX_PATH_LEN]; #define lcase(x) if (((x) >= 'A') && ((x) <= 'Z')) (x) |= 0x20 static void fixup_name(char *file) { int dir; char name[JED_MAX_PATH_LEN]; char *p; strcpy (file, Found_Dir); strcpy (name, The_ffblk.ff_name); dir = (The_ffblk.ff_attrib & SUBDIR); p = name; while (*p) { lcase(*p); p++; } strcat(file, name); if (dir) strcat(file, "\\"); } int sys_findfirst(char *thefile) { char *f, the_path[JED_MAX_PATH_LEN], *file, *f1; char *pat; File_Attr = READON | SUBDIR; file = jed_standardize_filename_static(thefile); f1 = f = extract_file(file); strcpy (Found_Dir, file); Found_Dir[(int) (f - file)] = 0; strcpy(the_path, file); while (*f1 && (*f1 != '*')) f1++; if (! *f1) { while (*f && (*f != '.')) f++; if (*f) strcat(the_path, "*"); else strcat(the_path, "*.*"); } pat = the_path; if (!findfirst (pat, &The_ffblk, File_Attr)) { fixup_name(file); strcpy(thefile, file); return(1); } else return 0; } int sys_findnext(char *file) { if (!findnext (&The_ffblk)) { fixup_name(file); return 1; } return 0; } int sys_chmod(SLFUTURE_CONST char *file, int what, mode_t *mode, uid_t *dum1, gid_t *dum2) { int flag, m = *mode; (void) dum1; (void) dum2; file = msdos_pinhead_fix_dir (file); if ((m = _chmod(file, what, m)) == -1) { flag = errno; /* Here if carry flag is set */ if (flag == ENOENT) return(0);/* file not found */ return -1; } if (what == 0) { *mode = m; } if (m & 0x10) { /* msg_error("File is a directory."); */ return(2); } return(1); } extern int main(int, char **); static void x_warp_pointer (void) { } static void x_region_2_cutbuffer (void) { int i, x, nbytes; char *dat, *buf; HGLOBAL hBuf; dat = make_buffer_substring(&nbytes); if (dat == NULL) return; /* space for LF -> CR/LF translation(s) */ for (i = x = 0; i < nbytes; i++) if (dat[i] == '\n') x++; hBuf = GlobalAlloc(GHND, x + nbytes + 1); /* space for trailing nul */ buf = (char *) GlobalLock(hBuf); for (i = x = 0; i < nbytes; i++) { if (dat[i] == '\n') buf[x++] = '\r'; /* LF -> CR/LF */ buf[x++] = dat[i]; } /* since GlobalAlloc() is like calloc(), trailing nul is 'automatic' */ /* tranfer data to clipboard */ OpenClipboard(This_Window.w); EmptyClipboard(); GlobalUnlock(hBuf); SetClipboardData(CF_TEXT, hBuf); CloseClipboard(); SLfree (dat); /* discard string */ } static int x_insert_cutbuffer (void) { int nbytes = 0; char *dat; int i, x; HGLOBAL hBuf; char *buf; CHECK_READ_ONLY; OpenClipboard(NULL); hBuf = GetClipboardData(CF_TEXT); CloseClipboard(); if (hBuf) { buf = (char *)GlobalLock(hBuf); for(i = x = 0; buf[i] != 0; i++) if (buf[i] != '\r') x++; nbytes = x; dat = SLmalloc (x + 1); if (dat != NULL) { for(i = x = 0; buf[i] != 0; i++) if (buf[i] != '\r') dat[x++] = buf[i]; dat[x] = 0; jed_insert_nbytes((unsigned char *) dat, nbytes); SLfree (dat); } GlobalUnlock(hBuf); } return nbytes; } #if 0 int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInst, LPSTR lpszCmdLine, int nCmdShow) { char **argv; int argc; int count; char *pt; int ret; char *command_line; /* add 6 for "wjed", the separating space, and a terminating '\0' */ if (NULL == (command_line = SLMALLOC (strlen(lpszCmdLine) + 8))) return 0; (void) hInstance; (void) nCmdShow; strcpy(command_line, "wjed "); strcat(command_line, lpszCmdLine); _hPrev = hPrevInst; _hInstance = hInstance; while ( (*command_line != '\0') && (*command_line == ' ')) command_line++; /* start on 1st non-space */ pt = command_line; count = 0; while ( *pt != '\0' ) { count++; /* this is an argument */ while ((*pt != '\0') && (*pt != ' ')) pt++; /* advance until a space */ while ( *pt == ' ' ) pt++; /* advance until a non-space */ } argv = (char **) SLMALLOC( (count+3) * sizeof(char *) ); if (argv == NULL ) return 0; /* malloc error */ argc = 0; pt = command_line; while ((argc < count) && (*pt != '\0')) { argv[ argc ] = pt; argc++; while ( *pt != '\0' && *pt != ' ' ) pt++; /* advance until a space */ if ( *pt != '\0' ) *(pt++) = '\0'; /* parse argument here */ while ( *pt == ' ') pt++; /* advance until a non-space */ } argv [ argc ] = (char *) NULL; /* NULL terminated list */ ret = main(argc, argv); SLfree(command_line); return ret; } #endif jed-0.99-19/src/ledit.h0000644002657400265740000000517611311317447013544 0ustar davisdavis/* Copyright (c) 1992, 1998, 2000, 2004, 2005, 2006 John E. Davis * This file is part of JED editor library source. * * You may distribute this file under the terms the GNU General Public * License. See the file COPYING for more information. */ extern Buffer *The_MiniBuffer; extern int jed_ns_load_file (SLFUTURE_CONST char *, SLFUTURE_CONST char *); extern int find_file_in_window(char *); extern int find_file(void); extern int get_buffer(void); extern int evaluate_cmd(void); extern int kill_buffer(void); extern int jed_save_buffer_as_cmd (void); extern int jed_save_buffer_cmd (void); extern int jed_save_buffer_as (char *); extern int jed_save_buffer_to_file (char *, char *); extern int search_forward_cmd(void); extern int global_setkey_cmd(void); extern int search_backward_cmd(void); extern int insert_file_cmd(void); extern void init_minibuffer(void); extern int exit_minibuffer(void); extern int select_minibuffer(void); extern int mini_complete(void); extern void buffer_substring(void); extern char *make_line_string(char *, unsigned int); extern int set_buffer(char *); extern char *pop_to_buffer(char *); extern int init_jed_intrinsics(void); #if defined (__unix__) || defined (__os2__) || defined(__WIN32__) extern int shell_command(char *); extern int pipe_region(char *); #endif extern void jed_load_buffer(char *ns); extern void update_cmd(int *); extern void update_sans_update_hook_cmd (int *); extern void copy_region_cmd(char *); extern void jed_setup_minibuffer_keymap (void); #ifndef IBMPC_SYSTEM # if defined(__QNX__) extern int show_memory(void); # endif extern void screen_w80(void); extern void screen_w132(void); #else extern int show_memory(void); #endif extern int markp(void); extern int dup_mark(void); extern void mini_read(char *, char *, char *); extern void send_string_to_term(char *); extern void make_buffer_list(void); extern char *make_buffer_substring(int *); extern int expand_wildcards(char *); extern int bufferp(char *); extern int kill_buffer_cmd(char *); extern int get_doc_string(char *, char *); extern int insert_buffer_name(char *); extern int find_file_cmd(char *); extern void read_object_with_completion(char *, char *, char *, int *); extern void switch_to_buffer_cmd(char *); extern char *what_buffer(void); extern void set_tab(int *); extern char *command_line_argv(int *); extern int MiniBuffer_Active; extern FILE *jed_open_slang_file(char *, char *); extern char *Completion_Buffer; extern void set_expansion_hook (char *); extern int jed_vget_y_n (char *, char *); extern int jed_get_y_n (char *); extern int jed_get_mini_response (char *); extern int jed_get_yes_no( char *); extern int Jed_Load_Quietly; jed-0.99-19/src/jedlimit.h0000644002657400265740000000124511311317447014235 0ustar davisdavis/* Copyright (c) 2007 John E. Davis * This file is part of JED editor library source. * * You may distribute this file under the terms the GNU General Public * License. See the file COPYING for more information. */ #ifndef _JED_LIMIT_H_ #define _JED_LIMIT_H_ #include #if defined(SIXTEEN_BIT_SYSTEM) # define JED_KBD_MACRO_SIZE 256 # define JED_MAX_ADD_COMPLETIONS 32 #else # define JED_KBD_MACRO_SIZE 8192 # define JED_MAX_ADD_COMPLETIONS 512 #endif #ifdef PATH_MAX # define JED_MAX_PATH_LEN PATH_MAX #else # ifdef IBMPC_SYSTEM # define JED_MAX_PATH_LEN 256 # else # define JED_MAX_PATH_LEN 1024 # endif #endif #endif /* _JED_LIMIT_H_ */ jed-0.99-19/src/ins.h0000644002657400265740000000260111311317447013222 0ustar davisdavis/* Copyright (c) 1992, 1998, 2000, 2005, 2006 John E. Davis * This file is part of JED editor library source. * * You may distribute this file under the terms the GNU General Public * License. See the file COPYING for more information. */ /* For undo, these flags assumed to be <= 0xFF */ #define CDELETE 0x1 #define CINSERT 0x2 #define LDELETE 0x4 #define NLINSERT 0x8 /* causes marks to be moved to next line */ #define NLDELETE 0x10 /* opposite of above */ #define UNDO_POSITION 0x20 /* records position */ extern void jed_update_marks(int, int); extern int No_Screen_Update; extern int jed_del_nbytes (int); extern int jed_generic_del_nbytes (int); extern int jed_del_wchar(void); extern int jed_del_through_eol(void); extern int _jed_ins_byte (unsigned char); /* \n will not split the line */ extern int jed_insert_wchar (SLwchar_Type); extern int jed_insert_byte (unsigned char); extern void insert_buffer(Buffer *); extern int jed_quick_insert(register unsigned char *, int); extern int jed_insert_nbytes(unsigned char *, int); extern int jed_insert_wchar_n_times (SLwchar_Type, unsigned int); extern int jed_del_newline(void); extern int _jed_replace_wchar (SLwchar_Type); /* \n not allowed */ extern int jed_insert_string (SLFUTURE_CONST char *s); extern int jed_insert_newline (void); extern int Suspend_Screen_Update; extern int jed_prepare_for_modification (int); jed-0.99-19/src/sysdep.c0000644002657400265740000005274411311317447013750 0ustar davisdavis/* -*- mode: C; mode: fold; -*- */ /* Copyright (c) 1992, 1998, 2000, 2002, 2003, 2004, 2005, 2006 John E. Davis * This file is part of JED editor library source. * * You may distribute this file under the terms the GNU General Public * License. See the file COPYING for more information. */ /* This file is the interface to system specific files */ #include "config.h" #include "jed-feat.h" /*{{{ Include Files */ #include #include #ifdef HAVE_STDLIB_H # include #endif #define __USE_XOPEN_EXTENDED /* to get getpgid */ #ifdef HAVE_UNISTD_H # include #endif #ifdef __WIN32__ /* windows.h must be included before slang.h */ # include #endif #include #include "jdmacros.h" #ifdef POSIX # ifndef _POSIX_SOURCE # define _POSIX_SOURCE # endif #endif #ifdef __WIN32__ # ifdef VOID # undef VOID # endif # if !defined(__CYGWIN32__) # define sleep Sleep # endif # undef _POSIX_SOURCE # include # ifdef __BORLANDC__ # include # endif # if defined(__MINGW32__) || defined(__IBMC__) # include # endif # ifdef __IBMC__ # if SLANG_VERSION < 10308 # define sleep(x) sys_pause(1000 * (x)) # else /* sleep added to slang 10308 */ extern unsigned int sleep (unsigned int); # endif # endif #endif #include "buffer.h" #include "sysdep.h" #include "display.h" #include "file.h" #include "screen.h" #include "misc.h" #include "hooks.h" /*}}}*/ /* These are hooks for porting to other systems */ int (*X_Read_Hook) (void); int (*X_Input_Pending_Hook) (void); int (*X_Init_Term_Hook) (void); void (*X_Reset_Term_Hook) (void); int Ignore_User_Abort = 1; /* Abort char triggers S-Lang error */ char *_Jed_Backspace_Key = "\x7F"; void (*Jed_Sig_Exit_Fun) (void); #ifdef IBMPC_SYSTEM int Jed_Filename_Case_Sensitive = 0; #endif unsigned char KeyBoard_Xlate[256] = /*{{{*/ { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255 }; /*}}}*/ #if defined(__WIN32__) # define SLASH_CHAR '\\' # include "win32.c" #else # if defined (__MSDOS__) || defined(MSWINDOWS) # define SLASH_CHAR '\\' # if defined (__WATCOMC__) || defined (__GO32__) # include "i386.c" # else # if defined(MSWINDOWS) # include "win16.c" # else # include "ibmpc.c" # endif # endif # else # if defined (__os2__) # define SLASH_CHAR '\\' # include "os2.c" # else # if defined (VMS) # define SLASH_CHAR ']' # include "vms.c" # else # define SLASH_CHAR '/' # include "unix.c" # endif # endif # endif #endif int Input_Buffer_Len = 0; unsigned char Input_Buffer[MAX_INPUT_BUFFER_LEN]; void map_character(int *fromp, int *top) /*{{{*/ { int from = *fromp, to = *top; if ((from > 255) || (to > 255) || (from < 0) || (to < 0)) return; KeyBoard_Xlate[from] = to; } /*}}}*/ /* if input char arrives with hi bit set, it is replaced by 2 characters: * Meta_Char + char with hi bit off. If Meta_Char is -1, then return * full 8 bits which self inserts */ /* By default, 8 bit chars self insert. */ int Meta_Char = -1; #if !defined(IBMPC_SYSTEM) int DEC_8Bit_Hack = 64; #else int DEC_8Bit_Hack = 0; #endif int my_getkey() /*{{{*/ { char buf[10]; int i; #if 0 int imax; #endif unsigned char ch; int eightbit_hack; if (Batch) { fgets(buf, 9 ,stdin); return (int) (unsigned char)*buf; } /* Apparantly this hack causes problems when dealing with a unicode-aware * terminal. */ eightbit_hack = DEC_8Bit_Hack; #if JED_HAS_UTF8_SUPPORT if (Jed_UTF8_Mode) eightbit_hack = 0; #endif if (!Input_Buffer_Len) { /* if (Batch) ch = (unsigned char) getc(stdin); else ch = sys_getkey(); */ ch = (unsigned char) KeyBoard_Xlate[sys_getkey()]; if (ch & 0x80) { i = (ch & 0x7F); if ((i < ' ') && eightbit_hack) { i += eightbit_hack; ungetkey((int *) &i); ch = 27; } else if (Meta_Char != -1) { ungetkey((int *) &i); ch = Meta_Char; /* escape char */ } } return((int) ch); } ch = Input_Buffer[0]; if ((ch & 0x80) && ((Meta_Char != -1) || ((ch < 160) && eightbit_hack))) { ch = (ch & 0x7F); if ((ch < ' ') && eightbit_hack) { ch += eightbit_hack; i = 27; } else i = Meta_Char; Input_Buffer[0] = ch; return ((int) (unsigned int) i); } #ifdef USING_INPUT_BUFFER USING_INPUT_BUFFER #endif Input_Buffer_Len--; #if 1 memmove (Input_Buffer, Input_Buffer+1, Input_Buffer_Len); #else for (i = 0; i < imax; i++) Input_Buffer[i] = Input_Buffer[i+1]; #endif /* SLMEMCPY ((char *) Input_Buffer, (char *) (Input_Buffer + 1), imax); */ #ifdef DONE_WITH_INPUT_BUFFER DONE_WITH_INPUT_BUFFER #endif return((int) ch); } /*}}}*/ void ungetkey_string(char *s, int n) /*{{{*/ { /* int i; */ register unsigned char *bmax, *b, *b1; /* FIXME!! This should affect the keyboard macro buffer. */ if (Executing_Keyboard_Macro) return; if (n + Input_Buffer_Len > MAX_INPUT_BUFFER_LEN - 3) return; #ifdef USING_INPUT_BUFFER USING_INPUT_BUFFER #endif b = Input_Buffer; bmax = b + (Input_Buffer_Len - 1); b1 = bmax + n; while (bmax >= b) *b1-- = *bmax--; bmax = b + n; while (b < bmax) *b++ = (unsigned char) *s++; Input_Buffer_Len += n; #ifdef DONE_WITH_INPUT_BUFFER DONE_WITH_INPUT_BUFFER #endif } /*}}}*/ void buffer_keystring(char *s, int n) /*{{{*/ { if (n + Input_Buffer_Len > MAX_INPUT_BUFFER_LEN - 3) return; #ifdef USING_INPUT_BUFFER USING_INPUT_BUFFER # if 0 ; # endif #endif SLMEMCPY ((char *) Input_Buffer + Input_Buffer_Len, s, n); Input_Buffer_Len += n; #ifdef DONE_WITH_INPUT_BUFFER DONE_WITH_INPUT_BUFFER #endif } /*}}}*/ void ungetkey(int *ci) /*{{{*/ { char ch; ch = (char) *ci; ungetkey_string(&ch, 1); } /*}}}*/ int input_pending (int *tsecs) /*{{{*/ { int n; int c; /* FIXME!! This should affect the macro buffer */ if (Executing_Keyboard_Macro) return 1; if (Jed_Sig_Exit_Fun != NULL) (*Jed_Sig_Exit_Fun) (); if (Input_Buffer_Len) return Input_Buffer_Len; n = sys_input_pending (tsecs, 0); if (n < 0) { if (SLKeyBoard_Quit) n = 1; else n = 0; } if (n && (Input_Buffer_Len == 0)) { c = my_getkey (); ungetkey (&c); } return n; } /*}}}*/ #if JED_HAS_SUBPROCESSES void get_process_input (int *t) /*{{{*/ { (void) sys_input_pending (t, -1); } /*}}}*/ #endif void flush_input () /*{{{*/ { int quit = SLKeyBoard_Quit; Input_Buffer_Len = 0; SLKeyBoard_Quit = 0; if (Executing_Keyboard_Macro == 0) { #ifdef __MSDOS__ while (input_pending(&Number_Zero)) if (!my_getkey()) my_getkey(); #else # ifdef __os2__ sys_flush_input(); # endif while (input_pending(&Number_Zero)) my_getkey(); #endif #ifdef HAS_MOUSE jed_flush_mouse_queue (); #endif } SLKeyBoard_Quit = quit; } /*}}}*/ #include unsigned long sys_time(void) /*{{{*/ { return((unsigned long) time((time_t *) 0)); } /*}}}*/ char *slash2slash(char *dir) /*{{{*/ { #ifndef VMS register char *p = dir, ch; while ((ch = *p) != 0) { if ((ch == '/') || (ch == '\\')) *p = SLASH_CHAR; p++; } #endif return(dir); } /*}}}*/ /* given a canonical filename, return pointer to its name. * Note: If the file ends in a slash as in a/b/c/, then a pointer to * the END of the string is returned. */ char *extract_file(SLFUTURE_CONST char *file) /*{{{*/ { SLFUTURE_CONST char *f; f = file + strlen(file); while (f > file) { f--; if (*f == SLASH_CHAR) return (char *)f + 1; } return (char *) file; } /*}}}*/ /* given a canonical filename, return pointer to its name. * Note: If the file ends in a slash as in a/b/c/, then a pointer to * the c/ is returned. */ char *jed_extract_file_or_dir (char *file) /*{{{*/ { char *f; f = file + strlen(file); if (f > file) { f--; if (*f == SLASH_CHAR) f--; } while (f > file) { f--; if (*f == SLASH_CHAR) return f + 1; } return (file); } /*}}}*/ #ifdef IBMPC_SYSTEM /* I do not know how to do this in a portable fashion. */ static int pcsystem_getdisk (void) { #if defined(__MINGW32__) || defined(__IBMC__) return _getdrive (); #else # if defined(__DJGPP__) int d; _dos_getdrive (&d); return d; # else # if defined(__BORLANDC__) return 1 + getdisk(); # else /* This may not work */ char *cwd = jed_get_cwd (); if ((cwd == NULL) || (*cwd == 0) || (cwd[1] != ':')) cwd = "C:"; return 1 + (UPPER_CASE (*cwd) - 'A'); # endif /* __BORLANDC__ */ # endif /* __DJGPP__ */ #endif /* __MINGW32__ */ } #endif /* IBMPC_SYSTEM */ #ifndef VMS static void str_move_bytes (char *a, char *b) { while (*b != 0) *a++ = *b++; *a = 0; } static char *strcat_malloc (char *a, char *b) { char *c; unsigned int lena = strlen (a); unsigned int lenb = strlen (b); if (NULL == (c = SLmalloc (lena + lenb + 1))) return NULL; strcpy (c, a); strcpy (c+lena, b); return c; } /* file is assumed to be malloced here. Its contents may be changed. */ static int remove_slash_slash (char *file) { char *f, *g, ch; g = f = file; while ((ch = *f++) != 0) { *g++ = ch; if (ch != SLASH_CHAR) continue; while (*f == SLASH_CHAR) f++; } *g = 0; return 0; } /* /foo/blah/../bar --> /foo/bar * /foo/blah/./bar --> /foo/blah/bar */ static int remove_dot_dot_slashes (char *file) { char *f = file; while (1) { char *f1; while (*f && (*f != SLASH_CHAR)) f++; if (*f == 0) break; f++; if (*f != '.') continue; /* foo/./bar -> foo/bar */ if (f[1] == SLASH_CHAR) { str_move_bytes (f, f+2); f--; continue; } /* foo/. --> foo/ */ if (f[1] == 0) { *f = 0; continue; } if (f[1] != '.') { f++; continue; } f1 = f; if (f[2] == SLASH_CHAR) f1 = f + 3; /* /../ */ else if (f[2] == 0) f1 = f + 2; /* /.. */ else continue; /* /foo/blah/../bar. * Move bar to /blah */ f--; if (f != file) f--; while ((f != file) && (*f != SLASH_CHAR)) f--; str_move_bytes (f+1, f1); } return 0; } /* This function may free its argument and returned a new malloced copy */ static char *make_abs_filename (char *file) { # if defined(IBMPC_SYSTEM) char buf[4]; # endif char *dir, *file1; if (*file != SLASH_CHAR) { # if defined(IBMPC_SYSTEM) if (*file && (file[1] == ':')) { if (file[2] == SLASH_CHAR) return file; /* Insert a slash */ buf[0] = file[0]; buf[1] = ':'; buf[2] = SLASH_CHAR; buf[3] = 0; file1 = strcat_malloc (buf, file+2); SLfree (file); return file1; } # endif /* Otherwise it looks like a relative path. */ /* get_cwd returns an absolute path with the trailing /. */ dir = jed_get_cwd (); file1 = strcat_malloc (dir, file); SLfree (file); if (file1 == NULL) return NULL; file = file1; } # if defined(IBMPC_SYSTEM) /* If file is not //share/foo, then prepend drive specifier */ if (file[0] == SLASH_CHAR) { if (file[1] != SLASH_CHAR) { buf[0] = 'A' + (pcsystem_getdisk ()-1); buf[1] = ':'; buf[2] = 0; file1 = strcat_malloc (buf, file); SLfree (file); return file1; } /* Make sure the //share ends with a slash. */ file1 = file + 2; while (*file1 && (*file1 != SLASH_CHAR)) file1++; if (*file1 != SLASH_CHAR) { buf[0] = SLASH_CHAR; buf[1] = 0; file1 = strcat_malloc (file, buf); SLfree (file); return file1; } } # endif return file; } static char *skip_drive_specifier (char *file) { #ifdef __QNX__ /* QNX pathnames look like ///rest_of_path * -- we need to leave on the and return /rest_of_path */ if ((file[0] == SLASH_CHAR) && (file[1] == SLASH_CHAR) && (file[2] >= '1') && (file[2] <= '9')) { file += 2; while (*file && (*file != SLASH_CHAR)) file++; } return file; #endif /* __QNX__ */ #ifdef IBMPC_SYSTEM if (((file[0] != 0) && (file[1] == ':')) || ((file[0] == SLASH_CHAR) && (file[1] == SLASH_CHAR))) { file += 2; while (*file && (*file != SLASH_CHAR)) file++; } #endif return file; } static char *prep_filename (SLFUTURE_CONST char *filename) { unsigned int len; char *file; len = strlen (filename); #ifdef MSWINDOWS /* Strip quotes from around the filename, if any */ if ((len >= 2) && (filename[0] == '"') && (filename[len - 1] == '"')) { len -= 2; filename++; } #endif if (NULL == (file = SLmake_nstring (filename, len))) return NULL; #ifndef __unix__ slash2slash (file); #endif return file; } char *jed_standardize_filename (SLFUTURE_CONST char *filename) { char *file1, *file; if (NULL == (file = prep_filename (filename))) return NULL; if (NULL == (file = make_abs_filename (file))) return NULL; file1 = skip_drive_specifier (file); (void) remove_slash_slash (file1); (void) remove_dot_dot_slashes (file1); return file; } /* this routine returns a Static pointer which is considered volatile */ char *jed_standardize_filename_static (char *file) /*{{{*/ { static char filebuf [JED_MAX_PATH_LEN]; *filebuf = 0; if (NULL != (file = jed_standardize_filename (file))) { safe_strcpy (filebuf, file, JED_MAX_PATH_LEN); SLfree (file); } return filebuf; } /*}}}*/ #endif /* ! VMS */ #ifdef sequent char *my_strstr(char *a, char *b) /*{{{*/ { register char *bb, *aa, *amax; if (*b == 0) return(a); bb = b; while (*bb) bb++; aa = a; while (*aa++); amax = aa - (bb - b); while (a < amax) { bb = b; while ((a < amax) && (*a != *bb)) a++; if (a == amax) return((char *) NULL); aa = a; while (*aa && (*aa == *bb)) aa++, bb++; if (! *bb) return(a); a++; } return((char *) NULL); } /*}}}*/ #endif void deslash(char *dir) /*{{{*/ { #ifndef VMS int n; if ((n = strlen(dir)) > 1) { n--; # if defined (IBMPC_SYSTEM) if ( (dir[n] == '\\' || dir[n] == '/') && dir[n - 1] != ':' ) dir[n] = '\0'; # else if ( dir[n] == '/' ) dir[n] = '\0'; # endif } #endif /* !VMS */ } /*}}}*/ /* add trailing slash to dir */ void fixup_dir(char *dir) /*{{{*/ { #ifndef VMS int n; if ((n = strlen(dir)) >= 1) { n--; # if defined(IBMPC_SYSTEM) if ( dir[n] != '/' && dir[n] != '\\' ) strcat(dir, "\\" ); # else if ( dir[n] != '/' ) strcat(dir, "/" ); # endif } #endif /* !VMS */ } /*}}}*/ /* ch_dir routine added during OS/2 port in order to simplify script writing. */ int ch_dir(char *path) /*{{{*/ { #if defined(IBMPC_SYSTEM) || defined(__os2__) char work[JED_MAX_PATH_LEN]; safe_strcpy(work, path, sizeof (work)); deslash(work); return chdir(work); #else return chdir(path); #endif } /*}}}*/ /* generate a random number */ int make_random_number (int *seed, int *max) /*{{{*/ { static unsigned long s; int mmax; if (*seed == -1) /* generate seed */ s = (unsigned long) (time(0) + getpid()); else if (*seed != 0) s = *seed; if ((mmax = *max) < 2) mmax = 2; s = s * 69069UL + 1013904243UL; s = s & 0xFFFFFFFFUL; return (int) (mmax * (double)s/4294967296.0); } /*}}}*/ #if defined(IBMPC_SYSTEM) /* This routine converts C:\ --> C:\ and C:\subdir\ -> C:\subdir */ char *msdos_pinhead_fix_dir(char *f) /*{{{*/ { static char file[JED_MAX_PATH_LEN]; register char ch; int n; if (*f == 0) return f; strncpy (file, f, JED_MAX_PATH_LEN); file[JED_MAX_PATH_LEN - 1] = 0; f = file; /* skip past colon */ while (((ch = *f) != 0) && (ch != ':')) f++; if (ch == 0) /* no colon */ { n = (int) (f - file); f = file; } else { f++; n = strlen (f); } if (n == 0) { *f++ = '\\'; *f = 0; return file; } if ((n == 1) && (*f == '\\')) return file; f += n - 1; if (*f == '\\') *f = 0; return file; } /*}}}*/ #endif #ifdef __WIN32__ int jed_win32_rename (char *old_name, char *new_name) { /* Some versions of win95 have a bug in rename * Nick Tatham discovered this and provided the patch: * C:\> echo try1 >temp.txt * C:\> ren temp.txt temp.txt~ * C:\> echo try2 >temp.txt */ /* The work-around is to rename the file in two stages: * file.typ ==> file.~ ==> file.typ~ */ char tmp_name[1024]; char *p; unsigned int n, extlen; unsigned int num_tries; p = extract_file (old_name); while (*p && (*p != '.')) p++; /* find extension */ /* create temporary filename */ /* everything up to potential dot */ n = (unsigned int) (p - old_name); extlen = strlen (p); if ((n + 10 + extlen) > sizeof (tmp_name)) { #ifdef ENAMETOOLONG errno = ENAMETOOLONG; #endif return -1; } strncpy (tmp_name, old_name, n); num_tries = 0xFFF; while (num_tries != 0) { struct stat st; sprintf (tmp_name + n, "~~~~~~%03X%s", num_tries, p); if (0 == stat (tmp_name, &st)) { num_tries--; continue; } if (-1 == rename (old_name, tmp_name)) return -1; if (-1 == rename (tmp_name, new_name)) { (void) rename (tmp_name, old_name); return -1; } return 0; } #ifdef EFAULT /* Any better idea? */ errno = EFAULT; #endif return -1; } #endif void jed_pause (int *ms) /*{{{*/ { if (*ms < 0) return; sys_pause (*ms); } /*}}}*/ int jed_handle_interrupt (void) { #if SLANG_VERSION >= 20000 return SLang_handle_interrupt (); #else return 0; #endif } void jed_sleep (unsigned int n) { sleep (n); } char *jed_get_cwd (void) /*{{{*/ { static char cwd[JED_MAX_PATH_LEN]; char *c; #ifdef HAVE_GETCWD # if defined (__EMX__) c = _getcwd2(cwd, sizeof(cwd)); /* includes drive specifier */ # else c = getcwd(cwd, sizeof(cwd)); /* djggp includes drive specifier */ # endif #else c = (char *) getwd(cwd); #endif if (c == NULL) { #ifndef REAL_UNIX_SYSTEM exit_error ("Unable to get the current working directory.", 0); #else struct stat st1, st2; if ((NULL == (c = getenv ("PWD"))) || (-1 == stat (c, &st1)) || (-1 == stat (".", &st2)) || (st1.st_dev != st2.st_dev) || (st1.st_ino != st2.st_ino)) { jed_vmessage (1, "Unable to get CWD. Assuming /"); if (-1 == chdir ("/")) exit_error ("Unable to change directory to /", 0); c = "/"; } strncpy (cwd, c, sizeof (cwd)); cwd [sizeof (cwd) - 1] = 0; #endif } #ifndef VMS slash2slash(cwd); fixup_dir(cwd); #endif return(cwd); } /*}}}*/ #ifndef VMS static char *prepend_home_dir (char *file) { char *home; home = getenv ("HOME"); if ((home == NULL) || (*home == 0)) home = "/"; file = strcat_malloc (home, file); if (file == NULL) return file; home = jed_standardize_filename (file); SLfree (file); return home; } /* This function makes the following transformations: * * /foo/bar//root/baz --> /root/baz * /foo/bar/~/foo --> $HOME/foo * * and then converts the result to standard form. * Possible cases include: * * /foo/bar//tmp/x.c --> /tmp/x.c * /foo/bar/~/me/baz --> $HOME/me/baz * /foo/bar//tmp/~/bar --> /tmp/~/bar * ~/bar --> $HOME/bar * /tmp/~/bar//home/me --> /home/me * * DOS/Windows: * * C:/foo/bar/D:/foo --> D:/foo * //foo/bar///share/baz --> //share/baz * * For the case: /tmp/~/bar/~/foo, assume ~/foo. */ char *jed_expand_filename (char *file) { char *f; char *drive; if (NULL == (file = prep_filename (file))) return NULL; drive = NULL; f = skip_drive_specifier (file); /* Now look for // */ while (1) { char *f1; while (*f && (*f != SLASH_CHAR)) f++; if (*f == 0) break; f++; if (*f != SLASH_CHAR) { f1 = skip_drive_specifier (f); if (f1 == f) continue; } drive = f; break; } if (drive != NULL) { f = jed_standardize_filename (drive); SLfree (file); return f; } /* Now look for /~/ */ f = file + strlen (file); while (f != file) { while (f > file) { f--; if (*f == '~') break; } if (*f != '~') break; if (f[1] != SLASH_CHAR) continue; if ((f != file) && (*(f-1) != SLASH_CHAR)) continue; f = prepend_home_dir (f + 1); SLfree (file); return f; } f = jed_standardize_filename (file); SLfree (file); return f; } #endif /* !VMS */ jed-0.99-19/src/colors.c0000644002657400265740000001715511311317447013737 0ustar davisdavis/* Copyright (c) 2002, 2003, 2004, 2005, 2006 John E. Davis * This file is part of JED editor library source. * * You may distribute this file under the terms the GNU General Public * License. See the file COPYING for more information. */ #include "config.h" #include "jed-feat.h" #include #ifdef HAVE_STDLIB_H # include #endif #include #include #include "colors.h" #include "buffer.h" #include "screen.h" #include "display.h" #include "misc.h" typedef struct { char *name; /* slstring for new objects */ int color; char *fg; /* slstring */ char *bg; /* slstring */ } Color_Object_Map_Type; static Color_Object_Map_Type Color_Name_Map [JMAX_COLORS] = { /* %%% COLOR-TABLE-START %%% -- tag used by external script to sync color files */ {"normal", JNORMAL_COLOR, NULL, NULL}, {"cursor", JCURSOR_COLOR, NULL, NULL}, {"status", JSTATUS_COLOR, NULL, NULL}, {"region", JREGION_COLOR, NULL, NULL}, {"menu", JMENU_COLOR, NULL, NULL}, {"operator", JOP_COLOR, NULL, NULL}, {"number", JNUM_COLOR, NULL, NULL}, {"string", JSTR_COLOR, NULL, NULL}, {"comment", JCOM_COLOR, NULL, NULL}, {"delimiter", JDELIM_COLOR, NULL, NULL}, {"preprocess", JPREPROC_COLOR, NULL, NULL}, {"message", JMESSAGE_COLOR, NULL, NULL}, {"error", JERROR_COLOR, NULL, NULL}, {"dollar", JDOLLAR_COLOR, NULL, NULL}, #if JED_HAS_LINE_ATTRIBUTES {"...", JDOTS_COLOR, NULL, NULL}, #endif #if JED_HAS_MENUS {"menu_char", JMENU_CHAR_COLOR, NULL, NULL}, {"menu_shadow", JMENU_SHADOW_COLOR, NULL, NULL}, {"menu_selection", JMENU_SELECTION_COLOR, NULL, NULL}, {"menu_popup", JMENU_POPUP_COLOR, NULL, NULL}, {"menu_selection_char", JMENU_SELECTED_CHAR_COLOR, NULL, NULL}, #endif {"cursorovr", JCURSOROVR_COLOR, NULL, NULL}, {"linenum", JLINENUM_COLOR, NULL, NULL}, {"trailing_whitespace", JTWS_COLOR, NULL, NULL}, {"tab", JTAB_COLOR, NULL, NULL}, /* These may be useful for some modes */ {"url", JURL_COLOR, NULL, NULL}, {"italic", JITALIC_COLOR, NULL, NULL}, {"underline", JUNDERLINE_COLOR, NULL, NULL}, {"bold", JBOLD_COLOR, NULL, NULL}, {"html", JHTML_KEY_COLOR, NULL, NULL}, {"keyword", JKEY_COLOR, NULL, NULL}, {"keyword1", JKEY1_COLOR, NULL, NULL}, {"keyword2", JKEY2_COLOR, NULL, NULL}, {"keyword3", JKEY3_COLOR, NULL, NULL}, {"keyword4", JKEY4_COLOR, NULL, NULL}, {"keyword5", JKEY5_COLOR, NULL, NULL}, {"keyword6", JKEY6_COLOR, NULL, NULL}, {"keyword7", JKEY7_COLOR, NULL, NULL}, {"keyword8", JKEY8_COLOR, NULL, NULL}, {"keyword9", JKEY9_COLOR, NULL, NULL}, /* The rest of the colors are user-defined, and the strings are slstrings */ /* %%% COLOR-TABLE-STOP %%% */ {NULL, -1, NULL, NULL} }; int jed_get_color_obj (char *name) /*{{{*/ { Color_Object_Map_Type *map, *map_max; char ch; map = Color_Name_Map; map_max = Color_Name_Map + JMAX_COLORS; ch = *name; while (map < map_max) { if (map->name == NULL) { if (map < Color_Name_Map + FIRST_USER_COLOR) { map = Color_Name_Map + FIRST_USER_COLOR; continue; } break; } if ((ch == map->name[0]) && (0 == strcmp (map->name, name))) return map->color; map++; } if (0 == strcmp (name, "keyword0")) return JKEY_COLOR; return -1; } /*}}}*/ static int add_color_object (char *name) { int obj; Color_Object_Map_Type *map, *map_max; obj = jed_get_color_obj (name); if (obj != -1) return obj; map = Color_Name_Map + FIRST_USER_COLOR; map_max = Color_Name_Map + JMAX_COLORS; while (map < map_max) { if (map->name != NULL) { map++; continue; } if (NULL == (name = SLang_create_slstring (name))) return -1; map->name = name; map->color = (int) (map - Color_Name_Map); return map->color; } jed_vmessage (0, "*** Warning: no colors available for %s ***", name); return -1; } int jed_set_color (int obj, char *fg, char *bg) /*{{{*/ { Color_Object_Map_Type *map; if ((obj < 0) || (obj >= JMAX_COLORS)) return -1; tt_set_color (obj, NULL, fg, bg); map = Color_Name_Map + obj; if (NULL == (fg = SLang_create_slstring (fg))) return -1; if (NULL == (bg = SLang_create_slstring (bg))) { SLang_free_slstring (fg); return -1; } SLang_free_slstring (map->fg); map->fg = fg; SLang_free_slstring (map->bg); map->bg = bg; return 0; } /* Intrinsics */ static void set_color (char *obj, char *fg, char *bg) /*{{{*/ { int i; if (-1 != (i = jed_get_color_obj (obj))) (void) jed_set_color (i, fg, bg); } /*}}}*/ static void get_color (char *obj) { int i; Color_Object_Map_Type *map; i = jed_get_color_obj (obj); /* object may have not been allocated which in practical terms means that * the "normal" color will be used for the object. */ if (i == -1) i = JNORMAL_COLOR; map = Color_Name_Map + i; (void) SLang_push_string (map->fg == NULL ? "default" : map->fg); (void) SLang_push_string (map->bg == NULL ? "default" : map->bg); } static void add_color_object_cmd (char *name) { (void) add_color_object (name); } #ifndef IBMPC_SYSTEM static void set_color_esc (char *obj, char *esc) /*{{{*/ { # if SLANG_VERSION < 20000 int i; if (tt_set_color_esc == NULL) return; if (-1 != (i = jed_get_color_obj (obj))) tt_set_color_esc (i, esc); # else (void) obj; (void) esc; #endif } /*}}}*/ #endif static void set_color_object (int *obj, char *fg, char *bg) { (void) jed_set_color(*obj, fg, bg); } #if JED_HAS_COLOR_COLUMNS static void set_column_colors (int *color, int *c0p, int *c1p) /*{{{*/ { unsigned char *p, *pmax, ch; int c0, c1; unsigned int num; if ((*color < 0) || (*color >= JMAX_COLORS)) return; ch = (unsigned char) *color; c0 = *c0p - 1; c1 = *c1p; if (c0 < 0) c0 = 0; if (c1 <= c0) return; if ((NULL == (p = CBuf->column_colors)) || (c1 > (int) CBuf->num_column_colors)) { num = c1 + Jed_Num_Screen_Cols; p = (unsigned char *) SLrealloc ((char *)p, num); if (p == NULL) return; CBuf->column_colors = p; CBuf->num_column_colors = num; SLMEMSET ((char *) p, 0, num); } CBuf->coloring_style = 1; pmax = p + c1; p += c0; while (p < pmax) *p++ = ch; } /*}}}*/ #endif static void set_line_color (int *color) { int c = *color; if (c < 0) return; JED_SET_LINE_COLOR (CLine, c); } static int get_line_color (void) { return (int)JED_GET_LINE_COLOR(CLine); } static SLang_Intrin_Fun_Type Color_Intrinsics [] = /*{{{*/ { MAKE_INTRINSIC_I("set_line_color", set_line_color, SLANG_VOID_TYPE), MAKE_INTRINSIC_0("get_line_color", get_line_color, SLANG_INT_TYPE), MAKE_INTRINSIC_SSS("_set_color", set_color, VOID_TYPE), MAKE_INTRINSIC_S("color_number", jed_get_color_obj, INT_TYPE), MAKE_INTRINSIC_S("get_color", get_color, VOID_TYPE), MAKE_INTRINSIC_S("add_color_object", add_color_object_cmd, VOID_TYPE), #ifndef IBMPC_SYSTEM MAKE_INTRINSIC_SS("set_color_esc", set_color_esc, VOID_TYPE), #endif #if JED_HAS_COLOR_COLUMNS MAKE_INTRINSIC_III("set_column_colors", set_column_colors, VOID_TYPE), MAKE_INTRINSIC_ISS("set_color_object", set_color_object, VOID_TYPE), #endif SLANG_END_INTRIN_FUN_TABLE }; int jed_init_color_intrinsics (void) { int i; #if 1 /* Sanity check */ for (i = 0; i < JMAX_COLORS; i++) { if ((Color_Name_Map[i].name != NULL) && (i != Color_Name_Map[i].color)) { jed_verror ("Internal Error: Color Table is corrupt"); return -1; } } #endif if (-1 == SLadd_intrin_fun_table (Color_Intrinsics, NULL)) return -1; return 0; } jed-0.99-19/src/unix.c0000644002657400265740000005056611311317447013424 0ustar davisdavis/* -*- mode: C; mode: fold; -*- */ /* Copyright (c) 1992, 1998, 2000, 2002, 2003, 2004, 2005, 2006 John E. Davis * This file is part of JED editor library source. * * You may distribute this file under the terms the GNU General Public * License. See the file COPYING for more information. */ #include "config.h" #include "jed-feat.h" /*{{{ Include Files */ #include #include "sysdep.h" #ifdef HAVE_GLOB_H # include #endif #if JED_HAS_SUBPROCESSES # include "jprocess.h" #endif #include /* sequent support thanks to Kenneth Lorber */ /* SYSV (SYSV ISC R3.2 v3.0) provided by iain.lea@erlm.siemens.de */ #include #ifdef REALLY_HAVE_TERMIOS_H # include #endif #ifdef sun # ifndef PENDIN # include # endif #else # include #endif #ifdef __QNX__ /* # include */ # include #endif #ifdef SYSV # ifndef CRAY # include # include # include # include # endif #endif #include #include /* Another hack for AInt uniX (AIX) */ #if defined (_AIX) && !defined (FD_SET) # include /* for FD_ISSET, FD_SET, FD_ZERO */ #endif #include #include #ifdef HAVE_UNISTD_H # include #endif #ifdef HAVE_FCNTL_H # include #endif #include #ifdef HAVE_SYS_FCNTL_H # include #endif #ifndef F_GETFL # include #endif #include "sig.h" /*}}}*/ #define TTY_DESC 2 static int Read_FD = TTY_DESC; static int Max_Fd = TTY_DESC; static int Flow_Control; #ifndef REALLY_HAVE_TERMIOS_H typedef struct /*{{{*/ { struct tchars t; struct ltchars lt; struct sgttyb s; } /*}}}*/ TTY_Termio_Type; #else typedef struct termios TTY_Termio_Type; #endif static TTY_Termio_Type Old_TTY; #ifdef REALLY_HAVE_TERMIOS_H # define GET_TERMIOS(fd, x) tcgetattr(fd, x) # if 0 # define SET_TERMIOS(fd, x) tcsetattr(fd, TCSAFLUSH, x) # else # define SET_TERMIOS(fd, x) tcsetattr(fd, TCSADRAIN, x) # endif #else # ifdef TCGETS # define GET_TERMIOS(fd, x) ioctl(fd, TCGETS, x) # define SET_TERMIOS(fd, x) ioctl(fd, TCSETS, x) # else # define X(x,m) &(((TTY_Termio_Type *)(x))->m) # define GET_TERMIOS(fd, x) \ ((ioctl(fd, TIOCGETC, X(x,t)) || \ ioctl(fd, TIOCGLTC, X(x,lt)) || \ ioctl(fd, TIOCGETP, X(x,s))) ? -1 : 0) # define SET_TERMIOS(fd, x) \ ((ioctl(fd, TIOCSETC, X(x,t)) ||\ ioctl(fd, TIOCSLTC, X(x,lt)) || \ ioctl(fd, TIOCSETP, X(x,s))) ? -1 : 0) # endif #endif #define NEED_BAUDRATES 0 #if NEED_BAUDRATES static int Baud_Rates[20] = /*{{{*/ { 0, 50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800, 2400, 4800, 9600, 19200, 38400, 0, 0, 0, 0 }; /*}}}*/ #endif #ifdef HAS_MOUSE static int JMouse_Fd = -1; #endif static int TTY_Inited = 0; #ifdef ultrix /* Ultrix gets _POSIX_VDISABLE wrong! */ # define NULL_VALUE -1 #else # ifdef _POSIX_VDISABLE # define NULL_VALUE _POSIX_VDISABLE # else # define NULL_VALUE 255 # endif #endif static int Updating_Screen; static void unix_update_open (void) { Updating_Screen = 1; } static void unix_update_close (void) { Updating_Screen = 0; } static void handle_interrupt (void) { (void) jed_handle_interrupt (); if (Jed_Sig_Exit_Fun != NULL) (*Jed_Sig_Exit_Fun) (); if (Updating_Screen) return; while (Jed_Resize_Pending) jed_resize_display (); } static int unix_set_abort_char (unsigned char ch) { if (Jed_Abort_Char == ch) return 0; reset_tty (); Jed_Abort_Char = ch; init_tty (); return 0; } #define HAS_GETSETPGID (defined(HAVE_GETPGID) && defined(HAVE_SETPGID)) #define HAS_TCGETSETPGRP (defined(HAVE_TCSETPGRP) && defined(HAVE_TCGETPGRP)) #if HAS_TCGETSETPGRP static pid_t Terminal_PGID = -1; #endif #if HAS_GETSETPGID static pid_t Startup_PGID = -1; #endif static void set_process_group (void) { #if HAS_GETSETPGID && HAS_TCGETSETPGRP if (-1 != (Terminal_PGID = tcgetpgrp (Read_FD))) { pid_t pid = getpid (); Startup_PGID = getpgid (pid); (void) tcsetpgrp (Read_FD, pid); (void) setpgid (pid, pid); } #endif } static void reset_process_group (void) { #if HAS_GETSETPGID && HAS_TCGETSETPGRP if (Terminal_PGID != -1) { (void) tcsetpgrp (Read_FD, Terminal_PGID); setpgid (0, Startup_PGID); } #endif } int init_tty (void) /*{{{*/ { TTY_Termio_Type newtty; static char bskey[2]; bskey [1] = 0; if (Batch) return 0; if (X_Init_Term_Hook != NULL) { Read_FD = (*X_Init_Term_Hook) (); Max_Fd = Read_FD; if (Read_FD == -1) return -1; TTY_Inited = 1; return 0; } if (0 == isatty (Read_FD)) return -1; if ((0 == isatty (fileno (stdin))) && (0 == isatty (fileno (stdout)))) return -1; tt_enable_cursor_keys(); while (-1 == GET_TERMIOS(Read_FD, &Old_TTY)) { if (errno != EINTR) return -1; } while (-1 == GET_TERMIOS(Read_FD, &newtty)) { if (errno != EINTR) return -1; } TTY_Inited = 1; #ifndef REALLY_HAVE_TERMIOS_H newtty.s.sg_flags &= ~(ECHO); newtty.s.sg_flags &= ~(CRMOD); /* if (Flow_Control == 0) newtty.s.sg_flags &= ~IXON; */ newtty.t.t_eofc = 1; newtty.t.t_intrc = Jed_Abort_Char; /* ^G */ newtty.t.t_quitc = 255; newtty.lt.t_suspc = 255; /* to ignore ^Z */ newtty.lt.t_dsuspc = 255; /* to ignore ^Y */ newtty.lt.t_lnextc = 255; newtty.s.sg_flags |= CBREAK; /* do I want cbreak or raw????? */ bskey[0] = (char) newtty.s.sg_erase; _Jed_Backspace_Key = bskey; #else # if NEED_BAUDRATES /* No need for this anymore since SLsmg is used */ if (*tt_Baud_Rate == 0) { /* Note: if this generates an compiler error, simply remove the statement */ # ifdef HAVE_CFGETOSPEED *tt_Baud_Rate = cfgetospeed (&newtty); # endif *tt_Baud_Rate = (*tt_Baud_Rate > 0) && (*tt_Baud_Rate < 19) ? Baud_Rates[*tt_Baud_Rate] : -1; } # endif newtty.c_iflag &= ~(ECHO | INLCR | ICRNL); # ifdef ISTRIP /* allow 8 bit chars to pass through */ /* newtty.c_iflag &= ~ISTRIP; */ # endif newtty.c_oflag &= ~OPOST; /* (ONLCR | OPOST); */ /* do not map newline to cr/newline on out */ if (Flow_Control == 0) newtty.c_iflag &= ~IXON; newtty.c_cc[VMIN] = 1; newtty.c_cc[VTIME] = 0; newtty.c_cc[VEOF] = 1; newtty.c_lflag = ISIG | NOFLSH; newtty.c_cc[VINTR] = Jed_Abort_Char; /* ^G */ newtty.c_cc[VQUIT] = NULL_VALUE; newtty.c_cc[VSUSP] = NULL_VALUE; /* to ignore ^Z */ bskey [0] = (char) newtty.c_cc[VERASE]; _Jed_Backspace_Key = bskey; # ifdef VDSUSP newtty.c_cc[VDSUSP] = NULL_VALUE; /* to ignore ^Y */ # endif # ifdef VSWTCH newtty.c_cc[VSWTCH] = NULL_VALUE; /* to ignore who knows what */ # endif #endif /* NOT REALLY_HAVE_TERMIOS_H */ while (-1 == SET_TERMIOS(Read_FD, &newtty)) { if (errno != EINTR) return -1; } #ifdef HAS_MOUSE if ((X_Open_Mouse_Hook != NULL) && ((JMouse_Fd = (*X_Open_Mouse_Hook)()) >= 0)) { if (JMouse_Fd > Read_FD) Max_Fd = JMouse_Fd; } #endif X_Update_Open_Hook = unix_update_open; X_Update_Close_Hook = unix_update_close; X_Set_Abort_Char_Hook = unix_set_abort_char; set_process_group (); return 0; } /*}}}*/ void reset_tty (void) /*{{{*/ { if (Batch) return; if (!TTY_Inited) return; if (X_Init_Term_Hook != NULL) { if (X_Reset_Term_Hook != NULL) (*X_Reset_Term_Hook) (); return; } while (-1 == SET_TERMIOS(Read_FD, &Old_TTY)) { if (errno != EINTR) break; } reset_process_group (); /* This statement ensures init_tty will not try to change output_rate (when coming back from suspension) */ #if NEED_BAUDRATES if (*tt_Baud_Rate == 0) *tt_Baud_Rate = -1; #endif #ifdef HAS_MOUSE if (X_Close_Mouse_Hook != NULL) X_Close_Mouse_Hook (); JMouse_Fd = -1; #endif } /*}}}*/ int Key_Wait_Time = 450; int jed_set_default_key_wait_time (const int *tsecs) { int tmp = Key_Wait_Time; if (*tsecs > 0) Key_Wait_Time = *tsecs; return tmp; } unsigned char sys_getkey (void) /*{{{*/ { int n = Key_Wait_Time; unsigned char c; #if JED_HAS_SUBPROCESSES int all = Num_Subprocesses; #else int all = 0; #endif int kb; while (1) { handle_interrupt (); kb = SLKeyBoard_Quit; if (kb) break; /* sleep for 45 second and try again */ if (sys_input_pending(&n, all) > 0) break; kb = SLKeyBoard_Quit; if (kb) break; /* update status line in case user is displaying time */ if (Display_Time || all) { JWindow->trashed = 1; update((Line *) NULL, 0, 1, 0); } } kb = SLKeyBoard_Quit; if (kb) { SLKeyBoard_Quit = 0; return Jed_Abort_Char; } if (X_Read_Hook != NULL) return (X_Read_Hook ()); /* Something may have stuffed it, e.g., mouse */ if (Input_Buffer_Len) return my_getkey (); #ifdef HAS_MOUSE if (JMouse_Hide_Mouse_Hook != NULL) (*JMouse_Hide_Mouse_Hook) (0); #endif while (1) { int nread; if (SLKeyBoard_Quit) { SLKeyBoard_Quit = 0; return Jed_Abort_Char; } if (-1 == (nread = read (Read_FD, (char *) &c, 1))) { #ifdef EINTR if (errno == EINTR) { handle_interrupt (); continue; } #endif exit_error ("getkey: read failed.", 0); } if (nread > 0) return c; if (nread == 0) exit_error ("getkey: EOF seen!", 0); } } /*}}}*/ #ifndef FD_SET # define FD_SET(fd, tthis) *(tthis) |= 1 << fd # define FD_ZERO(tthis) *(tthis) = 0 # define FD_ISSET(fd, tthis) (*(tthis) & (1 << fd)) typedef int fd_set; #endif static fd_set Read_FD_Set; #ifdef __BEOS__ static int beos_tty_select(int fd, fd_set *mask, struct timeval *wait) { int ret; int howmany; long long usecs; extern void snooze(long long); if (wait == NULL) usecs = 1000000LL * 60 * 60 * 24 * 365; else usecs = wait->tv_usec + wait->tv_sec * 1000000LL; while (usecs >= 0) { if (wait == NULL) howmany = 1; else howmany = 0; ret = ioctl(fd, 'ichr', &howmany); if (ret < 0) { FD_CLR(fd, mask); return -1; } if ((ret >= 0) && (howmany > 0)) return 1; snooze(1000LL); usecs -= 1000; } FD_CLR(fd, mask); return 0; } #endif /* __BEOS__ */ /* If all is zero, only check for mouse or keyboard input. If all is -1, * check for only subprocess input. Otherwise, check all input. */ int sys_input_pending(int *tsecs, int all) /*{{{*/ { struct timeval wait; long usecs, secs; int ret, maxfd; #if JED_HAS_SUBPROCESSES int i; #endif static int bad_select; if ((all >= 0) && (Input_Buffer_Len || Batch)) return(Input_Buffer_Len); if (bad_select) return -1; top: FD_ZERO(&Read_FD_Set); secs = *tsecs / 10; usecs = (*tsecs % 10) * 100000; wait.tv_sec = secs; wait.tv_usec = usecs; if (all >= 0) { if ((X_Input_Pending_Hook != NULL) && (*X_Input_Pending_Hook) ()) return 1; FD_SET(Read_FD, &Read_FD_Set); #ifdef HAS_MOUSE if ((JMouse_Fd >= 0) && (JMouse_Event_Hook != NULL)) { FD_SET (JMouse_Fd, &Read_FD_Set); } #endif maxfd = Max_Fd; } else maxfd = -1; #if JED_HAS_SUBPROCESSES if (all) { i = 0; while (i < Num_Subprocesses) { if (Subprocess_Read_fds[i][2] == 0) /* If non-0, fd has an EIO error */ { int fd = Subprocess_Read_fds[i][0]; FD_SET(fd, &Read_FD_Set); if (fd > maxfd) maxfd = fd; } i++; } } #endif #ifdef __BEOS__ ret = beos_tty_select (Read_FD, &Read_FD_Set, &wait); #else ret = select(maxfd + 1, &Read_FD_Set, NULL, NULL, &wait); #endif if (ret == 0) return 0; if ((ret == -1) && (errno == EINTR)) handle_interrupt (); #ifdef ENODEV if ((ret == -1) && (errno == ENODEV)) { bad_select = 1; return -1; } #endif #ifdef EBADF if ((ret < 0) && (errno == EBADF)) { /* Oh Geez. We have an invalid file descriptor. Well, there are * several options. Here is what I am choosing: If we are selecting * on subprocesses and the bad descriptor appears to be the subprocess * then ignore select on suprocesses. Hopefully the subprocess child * handlers will fire and illiminate this situation. If it is the * mouse, then turn off the mouse. If it is the keyboard, then exit. */ FD_ZERO (&Read_FD_Set); if (all >= 0) { # ifdef HAS_MOUSE if ((JMouse_Fd >= 0) && (JMouse_Event_Hook != NULL)) { if ((-1 == fcntl (JMouse_Fd, F_GETFL, 0)) && (errno == EBADF)) { JMouse_Event_Hook = NULL; goto top; } } # endif if ((-1 == fcntl (Read_FD, F_GETFL, 0)) && (errno == EBADF)) { exit_error ("select: keyboard file descriptor is bad!!!", 1); } } if (all == -1) return 0; all = 0; goto top; } #endif /* EBADF */ if (all >= 0) { if ((X_Input_Pending_Hook != NULL) && (ret > 0) && (FD_ISSET(Read_FD, &Read_FD_Set))) { if ((*X_Input_Pending_Hook) ()) return 1; /* Nothing there so try to time out again --- too bad select does * not inform of of how far we got. */ goto top; #if 0 FD_SET(Read_FD, &Read_FD_Set); (void) select(Read_FD + 1, &Read_FD_Set, NULL, NULL, &wait); /* try again, it could be more bogus Xpackets. Event driven systems * are not always the way to go. */ return (*X_Input_Pending_Hook) (); #endif } if (ret < 0) return ret; if (FD_ISSET(Read_FD, &Read_FD_Set)) return ret; /* Nothing to read from the terminal so while we are waiting * for tty input, read from those that are available. TTY input * always gets preference. */ #ifdef HAS_MOUSE if ((JMouse_Event_Hook != NULL) && (JMouse_Fd >= 0) && (FD_ISSET (JMouse_Fd, &Read_FD_Set))) { if ((*JMouse_Event_Hook) () > 0) { return 1; } /* This is ugly. */ goto top; } #endif } /* all >= 0 */ if (ret <= 0) return ret; #if JED_HAS_SUBPROCESSES i = 0; while (i < Num_Subprocesses) { if ((Subprocess_Read_fds[i][2] == 0) /* If non-0, fd has an EIO error */ && FD_ISSET(Subprocess_Read_fds[i][0], &Read_FD_Set)) read_process_input (Subprocess_Read_fds[i][1]); i++; } #endif if (all < 0) return ret; return 0; /* no keyboard input */ } /*}}}*/ void sys_pause (int ms) /*{{{*/ { struct timeval wait; long usecs, secs; secs = ms / 1000; usecs = (ms % 1000) * 1000; wait.tv_sec = secs; wait.tv_usec = usecs; (void) select (0, NULL, NULL, NULL, &wait); } /*}}}*/ /* returns 0 on failure, 1 on sucess */ int sys_delete_file(char *filename) /*{{{*/ { return(1 + unlink(filename)); } /*}}}*/ #ifdef __QNX__ # include #endif void sys_suspend (void) /*{{{*/ { #ifdef __QNX__ char *shell= getenv("SHELL"); if (shell == NULL) shell = "sh"; spawnlp(P_WAIT, shell, shell, 0); #else /* (void) SLsignal_intr (SIGTSTP, SIG_DFL); */ if (Signal_Sys_Spawn_Flag) kill(0, SIGSTOP); else kill(0, SIGTSTP); /* (void) SLsignal_intr (SIGTSTP, sig_sys_spawn_cmd); */ #endif } /*}}}*/ /* returns 0 if file does not exist, 1 if it is not a dir, 2 if it is */ int sys_chmod(SLFUTURE_CONST char *file, int what, mode_t *mode, uid_t *uid, gid_t *gid) /*{{{*/ { struct stat buf; mode_t m; if (what) { if (-1 == chmod(file, *mode)) goto return_error; if (-1 == chown(file, *uid, *gid)) { if (-1 == stat (file, &buf)) goto return_error; (void) chown(file, buf.st_uid, *gid); } return 0; } if (-1 == stat(file, &buf)) goto return_error; m = buf.st_mode; *uid = buf.st_uid; *gid = buf.st_gid; /* AIX requires this */ #ifdef _S_IFDIR # ifndef S_IFDIR # define S_IFDIR _S_IFDIR # endif #endif #ifndef S_ISDIR # ifdef S_IFDIR # define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) # else # define S_ISDIR(m) 0 # endif #endif *mode = m & 07777; if (S_ISDIR(m)) return (2); return(1); return_error: switch (errno) { case EACCES: return(-1); /* es = "Access denied."; break; */ case ENOENT: return(0); /* ms = "File does not exist."; */ case ENOTDIR: return(-2); /* es = "Invalid Path."; */ default: return(-3); /* "stat: unknown error."; break;*/ } } /*}}}*/ #ifdef HAVE_GLOB_H static glob_t Globbuf; static int Glob_Count = -1; int sys_findnext(char *file) /*{{{*/ { while ((unsigned int) Glob_Count < (unsigned int) Globbuf.gl_pathc) { char *f = Globbuf.gl_pathv[Glob_Count++]; if (strlen (f) < JED_MAX_PATH_LEN) { strcpy (file, f); return 1; } } Glob_Count = -1; globfree(&Globbuf); return 0; } /*}}}*/ int sys_findfirst(char *the_file) /*{{{*/ { char *f, the_path[JED_MAX_PATH_LEN+2], *file; unsigned int len; file = jed_standardize_filename_static(the_file); f = extract_file(file); len = strlen (file); if (len >= JED_MAX_PATH_LEN) { jed_verror ("path name is too long"); return 0; } safe_strcpy (the_path, file, sizeof (the_path)); if (NULL == strchr(f, '*')) safe_strcat (the_path, "*", sizeof (the_path)); if (Glob_Count != -1) { Glob_Count = -1; globfree(&Globbuf); } if (glob(the_path, GLOB_MARK, NULL, &Globbuf) != 0) return 0; Glob_Count = 0; return sys_findnext (the_file); } /*}}}*/ #else static char Found_Dir[JED_MAX_PATH_LEN]; static char Found_File[JED_MAX_PATH_LEN]; static int File_Len; # if HAVE_DIRENT_H # include # define NAMLEN(dirent) strlen((dirent)->d_name) # else # define dirent direct # define NAMLEN(dirent) (dirent)->d_namlen # define NEED_D_NAMLEN # if HAVE_SYS_NDIR_H # include # endif # if HAVE_SYS_DIR_H # include # endif # if HAVE_NDIR_H # include # endif # endif static DIR *Dirp; /* These routines should be fixed to work with wildcards like the DOS and VMS * versions do. Unfortunately, it is a sad fact of life that Unix does NOT * support wildcards. Strangely enough, many Unix users are totally unaware * of this fact. * * To add wild card support, I need to use the regular expression package. * Specifically, in sys_findfirst, I would need to scan the file spec for * wild cards making the replacements: . --> \., ? -> ., and * -> .* in that * order. I should also quote the special characters ($, etc...) but I will * not worry about this. Finally, I will have to prefix it with '^' since * the match will start at the beginning of the string. * * Remark: to implement something like a real wildcard file renaming routine * would require even more processing. Consider something like: * rename *.c~ *.bak * This mean that the first expression (*.c~) would have to be converted to: * \(.*\)\.c~ * and the second (*.bak) would be determined to be: \1.bak where \1 is * the expression matched by the first wildcard. * * After converting the wildcard file name to a regexp file name, I would then * have to compile it and save the compiled expression for use in sys_findnext. * There, I would use the regexp string matching routine instead of the * strcmp which is now used. * * Mainly, the findfirst/findnext are used by the completion routines. This * means that there is an implicit '.*' attached to the end of the filespec. * This will have to be dealt with. */ int sys_findnext(char *file) /*{{{*/ { struct dirent *dp; if (Dirp == NULL) return 0; while (1) { if (NULL == (dp = readdir(Dirp))) { closedir (Dirp); Dirp = NULL; return 0; } # ifdef NEED_D_NAMLEN dp->d_name[dp->d_namlen] = 0; # endif if (!strncmp(Found_File, dp->d_name, File_Len)) break; } safe_strcpy (file, Found_Dir, JED_MAX_PATH_LEN); safe_strcat (file, dp->d_name, JED_MAX_PATH_LEN); if (2 == file_status(file)) safe_strcat (file, "/", JED_MAX_PATH_LEN); return(1); } /*}}}*/ int sys_findfirst(char *the_file) /*{{{*/ { char *f, *file; file = jed_standardize_filename_static(the_file); safe_strcpy (Found_Dir, file, sizeof (Found_Dir)); f = extract_file(Found_Dir); safe_strcpy (Found_File, f, sizeof (Found_File)); File_Len = strlen(Found_File); *f = 0; /* truncate Found_Dir to dirname */ if (Dirp != NULL) closedir(Dirp); if (NULL == (Dirp = (DIR *) opendir(Found_Dir))) return(0); safe_strcpy(the_file, file, JED_MAX_PATH_LEN); return sys_findnext(the_file); } /*}}}*/ #endif /* GLOB_H */ /* if non-zero, Flow control is enabled */ void enable_flow_control (int *mode) /*{{{*/ { /* This kills X windows. For the time being, work around it as follows */ if (X_Init_Term_Hook != NULL) return; Flow_Control = *mode; reset_tty(); init_tty(); } /*}}}*/ jed-0.99-19/src/misc.h0000644002657400265740000000472111311317447013371 0ustar davisdavis/* Copyright (c) 1992, 1998, 2000, 2004, 2005, 2006 John E. Davis * This file is part of JED editor library source. * * You may distribute this file under the terms the GNU General Public * License. See the file COPYING for more information. */ #ifndef JED_MISC_H_ #define JED_MISC_H_ #include "window.h" extern void exit_error(char *, int); extern void jed_error_hook (SLFUTURE_CONST char *); extern void msg_error(char *); extern void jed_verror (char *, ...); extern void jed_vmessage (int, char *, ...); extern void read_string(char *, int *); extern void clear_error(void); extern int jed_getkey(void); extern int jed_check_string_key_buffer (void); extern int jed_getkey_wchar (SLwchar_Type *); extern void jed_ungetkey_wchar (SLwchar_Type); extern char *jed_malloc0 (unsigned int); extern int begin_keyboard_macro(void); extern int macro_query(void); extern int end_keyboard_macro(void); extern void jed_abort_keyboard_macro (void); extern int execute_keyboard_macro(void); extern void get_last_macro(void); extern int Defining_Keyboard_Macro; extern int Executing_Keyboard_Macro; extern char Error_Buffer[256]; /* information needed by minibuffer and display routines */ typedef struct MiniInfo_Type { Window_Type *action_window; /* buffer for minibuffer action */ unsigned char prompt[132]; int prompt_len; int effective_prompt_len; /* length when tabs/etc are expanded */ } MiniInfo_Type; extern MiniInfo_Type Mini_Info; extern Buffer *jed_get_mini_action_buffer (void); extern int get_macro(void); extern int Exit_From_MiniBuffer; extern unsigned char *Macro_Buffer_Ptr; extern char *read_from_minibuffer(char *, char *, char *, int *); extern char *safe_strcat (char *, SLFUTURE_CONST char *, unsigned int); extern char *safe_strcpy (char *, SLFUTURE_CONST char *, unsigned int); extern int jed_case_strncmp (char *, char *, unsigned int); extern int jed_case_strcmp (char *, char *); extern char **_Jed_Startup_Argv; extern int _Jed_Startup_Argc; #if SLANG_VERSION < 20000 # ifdef HAVE_VSNPRINTF # define SLvsnprintf vsnprintf # else # define SLvsnprintf _SLvsnprintf extern int _SLvsnprintf (char *, unsigned int, char *, va_list); # endif # ifdef HAVE_SNPRINTF # define SLsnprintf snprintf # else # define SLsnprintf _SLsnprintf extern int _SLsnprintf (char *, unsigned int, char *, ...); # endif #endif #if SLANG_VERSION < 10410 extern int SLang_get_error (void); extern int SLang_set_error (int); #endif #endif /* JED_MISC_H_ */ jed-0.99-19/src/menu.c0000644002657400265740000015144011311317447013376 0ustar davisdavis/* Drop-down menus (tty) */ /* Copyright (c) 1999, 2000, 2002-2009 John E. Davis * This file is part of JED editor library source. * * You may distribute this file under the terms the GNU General Public * License. See the file COPYING for more information. */ #include "config.h" #include "jed-feat.h" #include #if JED_HAS_MENUS #include #include "jdmacros.h" #include #include "buffer.h" #include "screen.h" #include "misc.h" #include "sysdep.h" #include "cmds.h" #include "menu.h" #include "colors.h" typedef struct _Menu_Node_Type { char *name; int type; #define MENU_NODE_FUN_SLANG 1 #define MENU_NODE_FUN_C 2 #define MENU_NODE_POPUP 3 #define MENU_NODE_SEPARATOR 4 #define MENU_NODE_MENUBAR 5 #define MENU_NODE_KEYSTRING 6 unsigned int flags; #define MENU_ACTIVE 1 #define MENU_SELECTION 2 #define MENU_ITEM_UNAVAILABLE 4 #define MENU_POPUP_PREPARED 8 } Menu_Node_Type; typedef struct _Menu_Popup_Type { char *name; int type; /* =MENU_NODE */ unsigned int flags; /* Private data */ /* These 5 must match Menu_Bar_Type */ Menu_Node_Type **subnodes; unsigned int num_subnodes; unsigned int max_subnodes; struct _Menu_Popup_Type *parent; unsigned int active_node; SLang_Name_Type *select_popup_callback; SLang_Name_Type *tweak_popup_callback; int column; /* meaningful when active */ int row; int max_row; int max_col; unsigned int min_width; int visible_node_offset; } Menu_Popup_Type; struct _Menu_Bar_Type { char *name; int type; /* =MENU_NODE */ unsigned int flags; /* Private data */ /* These 5 must match Menu_Popup_Type */ Menu_Node_Type **subnodes; unsigned int num_subnodes; unsigned int max_subnodes; struct _Menu_Popup_Type *parent; unsigned int active_node; SLang_Name_Type *init_callback; SLang_Name_Type *select_callback; /* Void select_callback (name) */ int *item_columns; /* locations of items on menu bar */ unsigned int num_refs; #define DEFAULT_MENU_PREFIX "F10 key ==> " char *prefix_string; struct _Menu_Bar_Type *next; }; typedef struct { char *name; int type; unsigned int flags; SLang_Name_Type *slang_fun; SLang_Any_Type *client_data; } Menu_SLang_Fun_Type; typedef struct { char *name; int type; unsigned int flags; int (*c_fun)(void); } Menu_C_Fun_Type; typedef struct { char *name; int type; unsigned int flags; char *keystring; } Menu_Keystring_Fun_Type; int Jed_Menus_Active; static Menu_Bar_Type *Global_Menu_Bar; static Menu_Bar_Type *Menu_Bar_Root; static Menu_Bar_Type *Active_Menu_Bar; static Menu_Popup_Type *Active_Popup; static void free_menu_node (Menu_Node_Type *); static int select_menu_cmd (void); static void free_menu_popup_subnodes (Menu_Popup_Type *m) { Menu_Node_Type **l, **lmax; l = m->subnodes; lmax = l + m->num_subnodes; while (l < lmax) { free_menu_node (*l); l++; } SLfree ((char *) m->subnodes); m->subnodes = NULL; m->num_subnodes = 0; m->max_subnodes = 0; } static void free_menu_popup_private_data (Menu_Popup_Type *m) { free_menu_popup_subnodes (m); #if SLANG_VERSION > 10400 SLang_free_function (m->select_popup_callback); SLang_free_function (m->tweak_popup_callback); m->select_popup_callback = NULL; m->tweak_popup_callback = NULL; #endif } static void free_menu_bar_private_data (Menu_Bar_Type *m) { Menu_Node_Type **l, **lmax; if (m == Active_Menu_Bar) Active_Menu_Bar = NULL; if (m == Global_Menu_Bar) Global_Menu_Bar = NULL; if (m == Menu_Bar_Root) Menu_Bar_Root = m->next; else { Menu_Bar_Type *prev; prev = Menu_Bar_Root; while (prev->next != m) prev = prev->next; prev->next = m->next; } l = m->subnodes; lmax = l + m->num_subnodes; while (l < lmax) { free_menu_node (*l); l++; } SLfree ((char *) m->subnodes); SLfree ((char *) m->item_columns); SLang_free_slstring (m->prefix_string); #if SLANG_VERSION > 10400 SLang_free_function (m->init_callback); SLang_free_function (m->select_callback); #endif } static void free_keystring_private_data (Menu_Keystring_Fun_Type *m) { SLang_free_slstring (m->keystring); } static void free_slangfun_private_data (Menu_SLang_Fun_Type *m) { if (m->client_data != NULL) SLang_free_anytype (m->client_data); #if SLANG_VERSION > 10400 SLang_free_function (m->slang_fun); #endif } static void free_menu_node (Menu_Node_Type *m) { Menu_Bar_Type *b; if (m == NULL) return; switch (m->type) { case MENU_NODE_SEPARATOR: case MENU_NODE_FUN_C: break; case MENU_NODE_FUN_SLANG: free_slangfun_private_data ((Menu_SLang_Fun_Type *) m); break; case MENU_NODE_KEYSTRING: free_keystring_private_data ((Menu_Keystring_Fun_Type *) m); break; case MENU_NODE_MENUBAR: b = (Menu_Bar_Type *)m; if (b->num_refs > 1) { b->num_refs -= 1; return; } free_menu_bar_private_data ((Menu_Bar_Type *) m); break; case MENU_NODE_POPUP: free_menu_popup_private_data ((Menu_Popup_Type *) m); break; } SLang_free_slstring (m->name); SLfree ((char *) m); } static Menu_Node_Type *create_menu_node (char *name, int node_type, unsigned int sizeof_node) { Menu_Node_Type *m; m = (Menu_Node_Type *) jed_malloc0 (sizeof_node); if (m == NULL) return NULL; m->type = node_type; if (NULL == (m->name = SLang_create_slstring (name))) { SLfree ((char *)m); return NULL; } return m; } static Menu_Popup_Type *create_menu_popup (char *name, unsigned int num_items) { Menu_Popup_Type *m; m = (Menu_Popup_Type *) create_menu_node (name, MENU_NODE_POPUP, sizeof (Menu_Popup_Type)); if (m == NULL) return NULL; if (num_items == 0) num_items = 5; if (NULL == (m->subnodes = (Menu_Node_Type **)SLmalloc (num_items * sizeof (Menu_Node_Type *)))) { free_menu_node ((Menu_Node_Type *) m); return NULL; } m->max_subnodes = num_items; return m; } static Menu_Bar_Type *create_menu_bar (char *name, unsigned int num_items) { Menu_Bar_Type *m; char *prefix; m = (Menu_Bar_Type *) create_menu_node (name, MENU_NODE_MENUBAR, sizeof (Menu_Bar_Type)); if (m == NULL) return NULL; if (num_items == 0) num_items = 5; if ((NULL == (m->subnodes = (Menu_Node_Type **)SLmalloc (num_items * sizeof (Menu_Node_Type *)))) || (NULL == (m->item_columns = (int *)jed_malloc0 (num_items * sizeof (int))))) { free_menu_node ((Menu_Node_Type *) m); return NULL; } m->max_subnodes = num_items; if (Menu_Bar_Root != NULL) m->next = Menu_Bar_Root; Menu_Bar_Root = m; m->num_refs = 1; prefix = DEFAULT_MENU_PREFIX; if ((Global_Menu_Bar != NULL) && (Global_Menu_Bar->prefix_string != NULL)) prefix = Global_Menu_Bar->prefix_string; prefix = SLang_create_slstring (prefix); if (prefix == NULL) { jed_delete_menu_bar (m); return NULL; } m->prefix_string = prefix; return m; } void jed_delete_menu_bar (Menu_Bar_Type *m) { if (m == NULL) return; free_menu_node ((Menu_Node_Type *)m); } static int menu_name_eqs (char *a, char *b, char *bmax) { while (*a) { if ((b == bmax) || (*a != *b)) return 0; a++; b++; } return (b == bmax); } static Menu_Bar_Type *menu_find_menu_bar (char *name, int do_error) { Menu_Bar_Type *b; char *name_max; name_max = strchr (name, '.'); if (name_max == NULL) name_max = name + strlen (name); b = Menu_Bar_Root; while (b != NULL) { if (menu_name_eqs (b->name, name, name_max)) return b; b = b->next; } if (do_error) SLang_verror (SL_INTRINSIC_ERROR, "Unable to a find menu bar called %s", name); return NULL; } static Menu_Node_Type *find_subnode (Menu_Popup_Type *m, char *name) { Menu_Node_Type **l, **lmax; if (m == NULL) return NULL; l = m->subnodes; lmax = l + m->num_subnodes; while (l < lmax) { if (0 == strcmp (name, (*l)->name)) return *l; l++; } return NULL; } static int check_subnode_space (Menu_Popup_Type *m, unsigned int dn) { Menu_Node_Type **subnodes; unsigned int num; if (m->num_subnodes + dn <= m->max_subnodes) return 0; num = m->max_subnodes + dn; subnodes = (Menu_Node_Type **)SLrealloc ((char *)m->subnodes, num * sizeof (Menu_Node_Type *)); if (subnodes == NULL) return -1; m->subnodes = subnodes; if (m->type == MENU_NODE_MENUBAR) { Menu_Bar_Type *b = (Menu_Bar_Type *)m; int *item_columns; unsigned int i; item_columns = (int *)SLrealloc ((char *)b->item_columns, num * sizeof(int)); if (item_columns == NULL) return -1; for (i = m->max_subnodes; i < num; i++) item_columns [i] = 0; b->item_columns = item_columns; } m->max_subnodes = num; return 0; } /* This function assumes that there is enough space to insert one item */ static void insert_node_to_popup (Menu_Popup_Type *p, Menu_Node_Type *m, unsigned int where) { unsigned int len; unsigned int n; n = p->num_subnodes; if (where > n) where = n; while (n > where) { p->subnodes[n] = p->subnodes[n-1]; n--; } p->subnodes[where] = m; p->num_subnodes += 1; /* p could be a menu-bar */ if (p->type != MENU_NODE_POPUP) return; len = strlen (m->name); if (len > p->min_width) p->min_width = len; } #if 0 static void append_node_to_popup (Menu_Popup_Type *p, Menu_Node_Type *m) { insert_node_to_popup (p, m, p->num_subnodes); } #endif static Menu_Popup_Type *insert_popup_menu (Menu_Popup_Type *m, char *name, int where) { Menu_Popup_Type *p; if (NULL != (p = (Menu_Popup_Type *)find_subnode (m, name))) return p; if (-1 == check_subnode_space (m, 1)) return NULL; p = create_menu_popup (name, 5); if (p == NULL) return NULL; p->parent = m; insert_node_to_popup (m, (Menu_Node_Type *)p, where); return p; } static Menu_Popup_Type *append_popup_menu (Menu_Popup_Type *m, char *name) { return insert_popup_menu (m, name, m->num_subnodes); } static Menu_Node_Type *insert_separator (Menu_Popup_Type *m, int where) { Menu_Node_Type *l; if (-1 == check_subnode_space (m, 1)) return NULL; l = create_menu_node ("", MENU_NODE_SEPARATOR, sizeof (Menu_Node_Type)); if (l == NULL) return NULL; insert_node_to_popup (m, l, where); return l; } static Menu_Node_Type *append_separator (Menu_Popup_Type *m) { return insert_separator (m, m->num_subnodes); } static Menu_SLang_Fun_Type *insert_slang_fun_item (Menu_Popup_Type *m, char *name, SLang_Name_Type *nt, SLang_Any_Type *cd, int where) { Menu_SLang_Fun_Type *l; if (NULL != (l = (Menu_SLang_Fun_Type *)find_subnode (m, name))) { if (l->type != MENU_NODE_FUN_SLANG) return NULL; free_slangfun_private_data (l); l->slang_fun = nt; l->client_data = cd; return l; } if (-1 == check_subnode_space (m, 1)) return NULL; l = (Menu_SLang_Fun_Type *) create_menu_node (name, MENU_NODE_FUN_SLANG, sizeof (Menu_SLang_Fun_Type)); if (l == NULL) return NULL; l->slang_fun = nt; l->client_data = cd; insert_node_to_popup (m, (Menu_Node_Type *)l, where); return l; } static Menu_SLang_Fun_Type *append_slang_fun_item (Menu_Popup_Type *m, char *name, SLang_Name_Type *nt, SLang_Any_Type *cd) { return insert_slang_fun_item (m, name, nt, cd, m->num_subnodes); } static Menu_Keystring_Fun_Type *insert_keystring_item (Menu_Popup_Type *m, char *name, char *k, int where) { Menu_Keystring_Fun_Type *l; if (NULL != (l = (Menu_Keystring_Fun_Type *)find_subnode (m, name))) { if (l->type != MENU_NODE_KEYSTRING) return NULL; if (NULL == (k = SLang_create_slstring (k))) return NULL; free_keystring_private_data (l); l->keystring = k; return l; } if (-1 == check_subnode_space (m, 1)) return NULL; l = (Menu_Keystring_Fun_Type *) create_menu_node (name, MENU_NODE_KEYSTRING, sizeof (Menu_Keystring_Fun_Type)); if (l == NULL) return NULL; if (NULL == (l->keystring = SLang_create_slstring (k))) { free_menu_node ((Menu_Node_Type *) l); return NULL; } insert_node_to_popup (m, (Menu_Node_Type *)l, where); return l; } static Menu_Keystring_Fun_Type *append_keystring_item (Menu_Popup_Type *m, char *name, char *k) { return insert_keystring_item (m, name, k, m->num_subnodes); } static Menu_Node_Type *get_selected_menu_item (Menu_Popup_Type *p) { Menu_Node_Type *m; if (p == NULL) return NULL; if (p->num_subnodes <= p->active_node) { p->active_node = 0; return NULL; } m = p->subnodes[p->active_node]; if (m->flags & MENU_ITEM_UNAVAILABLE) { p->active_node = 0; return NULL; } /* Make sure this is selected. */ m->flags |= MENU_SELECTION; return m; } static int unselect_active_node (Menu_Popup_Type *b) { Menu_Node_Type *m; if (NULL == (m = get_selected_menu_item (b))) return -1; m->flags &= ~(MENU_SELECTION|MENU_ACTIVE); return 0; } static int select_next_active_node (Menu_Popup_Type *b, unsigned int active_node, unsigned int flags) { int wrapped; unsigned int num_subnodes; if (b == NULL) return -1; num_subnodes = b->num_subnodes; if (num_subnodes == 0) { b->active_node = 0; return -1; } unselect_active_node (b); wrapped = 0; while (1) { Menu_Node_Type *node; active_node++; if (active_node >= num_subnodes) { active_node = 0; if (wrapped) return -1; wrapped = 1; } node = b->subnodes[active_node]; if ((node->type != MENU_NODE_SEPARATOR) && (0 == (node->flags & MENU_ITEM_UNAVAILABLE))) { node->flags |= MENU_SELECTION|flags; break; } } b->active_node = active_node; return 0; } static int select_prev_active_node (Menu_Popup_Type *b, unsigned int active_node, unsigned int flags) { int wrapped; unsigned int num_subnodes; if (b == NULL) return -1; num_subnodes = b->num_subnodes; if (num_subnodes == 0) { b->active_node = 0; return -1; } unselect_active_node (b); wrapped = 0; while (1) { Menu_Node_Type *node; if (active_node == 0) { active_node = num_subnodes; if (wrapped) return -1; wrapped = 1; } active_node--; node = b->subnodes[active_node]; if ((node->type != MENU_NODE_SEPARATOR) && (0 == (node->flags & MENU_ITEM_UNAVAILABLE))) { node->flags |= MENU_SELECTION|flags; break; } } b->active_node = active_node; return 0; } static int set_node_selection (Menu_Popup_Type *p, Menu_Node_Type *m) { unsigned int i, imax; Menu_Node_Type **subnodes; if ((p == NULL) || (m == NULL) || (m->type == MENU_NODE_SEPARATOR) || (m->flags & MENU_ITEM_UNAVAILABLE)) return -1; subnodes = p->subnodes; imax = p->num_subnodes; for (i = 0; i < imax; i++) { if (subnodes[i] == m) { unselect_active_node (p); p->active_node = i; m->flags |= MENU_SELECTION; return 0; } } return -1; } static unsigned int get_active_node_flags (Menu_Popup_Type *p) { Menu_Node_Type *m; m = get_selected_menu_item (p); if (m == NULL) return 0; return m->flags; } static int menu_delete_node (Menu_Popup_Type *p, Menu_Node_Type *m) { unsigned int i, imax; if ((p == NULL) || (m == NULL)) return -1; imax = p->num_subnodes; for (i = 0; i < imax; i++) { if (p->subnodes[i] != m) continue; if (i == p->active_node) p->active_node = 0; while (++i < imax) p->subnodes[i-1] = p->subnodes[i]; p->num_subnodes -= 1; (void) unselect_active_node (p); free_menu_node (m); return 0; } return -1; } static int menu_delete_nodes (Menu_Popup_Type *p) { unsigned int i, imax; if (p == NULL) return -1; imax = p->num_subnodes; for (i = 0; i < imax; i++) free_menu_node (p->subnodes[i]); p->num_subnodes = 0; p->active_node = 0; return 0; } static int copy_menu (Menu_Popup_Type *dest, Menu_Node_Type *src) { Menu_Node_Type **l, **lmax; Menu_Popup_Type *p; Menu_Node_Type *m; SLang_Any_Type *any; Menu_SLang_Fun_Type *sl; if (src == (Menu_Node_Type *)dest) { SLang_verror (SL_INTRINSIC_ERROR, "Unable to copy a menu onto itself"); return -1; } switch (src->type) { case MENU_NODE_POPUP: p = (Menu_Popup_Type *) src; l = p->subnodes; lmax = l + p->num_subnodes; p = append_popup_menu (dest, src->name); if (p == NULL) return -1; while (l < lmax) { if (-1 == copy_menu (p, *l)) { menu_delete_node (dest, (Menu_Node_Type *)p); return -1; } l++; } m = (Menu_Node_Type *)p; break; case MENU_NODE_SEPARATOR: m = append_separator (dest); break; case MENU_NODE_FUN_SLANG: sl = (Menu_SLang_Fun_Type *) src; /* Need a s-lang fun for this !!! */ if ((-1 == SLang_push_anytype (sl->client_data)) || (-1 == SLang_pop_anytype (&any))) return -1; m = (Menu_Node_Type *) append_slang_fun_item (dest, sl->name, sl->slang_fun, any); if (m == NULL) SLang_free_anytype (any); break; case MENU_NODE_KEYSTRING: m = (Menu_Node_Type *) append_keystring_item (dest, src->name, ((Menu_Keystring_Fun_Type *)src)->keystring); break; case MENU_NODE_MENUBAR: SLang_verror (SL_INTRINSIC_ERROR, "Unable to copy a menu-bar"); return -1; case MENU_NODE_FUN_C: default: SLang_verror (SL_APPLICATION_ERROR, "Menu Type %d not supported", src->type); return -1; } if (m == NULL) return -1; m->flags = src->flags; return 0; } /* * SLsmg MenuBar interface */ static void simulate_hline (unsigned int n) { while (n--) SLsmg_write_string ("-"); } static void simulate_box (int r, int c, unsigned int dr, unsigned int dc) { int rr, rmax; if ((dr < 1) || (dc < 2)) return; dr--; dc--; SLsmg_gotorc (r, c); SLsmg_write_string ("+"); simulate_hline (dc-1); SLsmg_write_string ("+"); SLsmg_gotorc (r + dr, c); SLsmg_write_string ("+"); simulate_hline (dc-1); SLsmg_write_string ("+"); rmax = r + dr; for (rr = r + 1; rr < rmax; rr++) { SLsmg_gotorc (rr, c); SLsmg_write_string ("|"); SLsmg_gotorc (rr, c + dc); SLsmg_write_string ("|"); } } /* I would prefer to use real up/down arrows but I cannot depend upon their * portability. */ static void draw_up_arrow (int r, int c) { SLsmg_gotorc (r, c); SLsmg_write_string ("(-)"); } static void draw_down_arrow (int r, int c) { SLsmg_gotorc (r, c); SLsmg_write_string ("(+)"); } static void draw_name (char *name, int color0, int color1, unsigned int field_width) { unsigned char *s, *smax; unsigned int name_width; s = (unsigned char *) name; smax = s + strlen (name); #if SLANG_VERSION >= 20000 name_width = SLsmg_strwidth (s, smax); #else name_width = smax - s; #endif while ((s < smax) && (*s != '&')) s++; SLsmg_set_color (color0); SLsmg_write_chars ((unsigned char *) name, s); if (s < smax) { unsigned char *s1; name_width--; s++; /* skip & */ SLsmg_set_color (color1); s1 = jed_multibyte_chars_forward (s, smax, 1, NULL, 1); SLsmg_write_chars (s, s1); SLsmg_set_color (color0); s = s1; if (s < smax) SLsmg_write_chars (s, smax); } if (name_width < field_width) SLsmg_write_nstring ("", field_width - name_width); } static int draw_menu_bar (Menu_Bar_Type *b) { Menu_Node_Type **m; unsigned int i, imax; int active; SLsmg_gotorc (0, 0); SLsmg_set_color (JMENU_COLOR); SLsmg_write_string (b->prefix_string); m = b->subnodes; imax = b->num_subnodes; active = -1; for (i = 0; i < imax; i++) { Menu_Popup_Type *p; char *name; p = (Menu_Popup_Type *) m[i]; if (p->flags & MENU_ITEM_UNAVAILABLE) continue; b->item_columns[i] = SLsmg_get_column (); if (p->type == MENU_NODE_SEPARATOR) name = " "; else name = p->name; if (p->flags & MENU_SELECTION) { if (p->type == MENU_NODE_POPUP) active = i; draw_name (name, JMENU_SELECTION_COLOR, JMENU_SELECTED_CHAR_COLOR, 0); } else draw_name (name, JMENU_COLOR, JMENU_CHAR_COLOR, 0); SLsmg_set_color (JMENU_COLOR); SLsmg_write_string (" "); } SLsmg_set_color (JMENU_COLOR); SLsmg_erase_eol (); return active; } static int draw_keystring (Menu_Keystring_Fun_Type *k, int color0, int color1, unsigned int field_width) { int i; SLang_Key_Type *key, *key_root; FVOID_STAR fp; unsigned char type; char buf[3]; unsigned int best_len; char *best_keystring; SLang_Key_Type *best_key; char *name; draw_name (k->name, color0, color1, field_width); name = k->keystring; /* Now try to draw the binding */ if (NULL == (fp = (FVOID_STAR) SLang_find_key_function(name, CBuf->keymap))) type = SLKEY_F_INTERPRET; else type = SLKEY_F_INTRINSIC; best_keystring = NULL; best_len = 0xFFFF; best_key = NULL; key_root = CBuf->keymap->keymap; for (i = 0; i < 256; i++, key_root++) { #ifdef IBMPC_SYSTEM if ((i == 0) || (i == 0xE0)) continue; #endif key = key_root->next; if ((key == NULL) && (type == key_root->type)) { if (type == SLKEY_F_INTERPRET) { if (strcmp (name, key_root->f.s)) continue; } else if ((type != SLKEY_F_INTRINSIC) || (fp != key_root->f.f)) continue; buf[0] = i; buf[1] = 0; #ifndef IBMPC_SYSTEM if (i == 0) { buf[0] = '^'; buf[1] = '@'; buf[2] = 0; } #endif best_keystring = buf; break; } while (key != NULL) { char *s; SLang_Key_Type *this_key = key; key = key->next; if (this_key->type != type) continue; if (type == SLKEY_F_INTERPRET) { if (strcmp (name, this_key->f.s)) continue; } else if ((type != SLKEY_F_INTRINSIC) || (fp != this_key->f.f)) continue; s = SLang_make_keystring (this_key->str); if (s == NULL) continue; if (strlen (s) < best_len) { best_key = this_key; best_len = strlen (s); } } } if (best_keystring == NULL) { if (best_key == NULL) return 0; best_keystring = SLang_make_keystring (best_key->str); if (best_keystring == NULL) return 0; } best_len = strlen (best_keystring); if (best_len > 4) return 0; SLsmg_forward (-4); SLsmg_set_color (color0); SLsmg_write_nchars (best_keystring, best_len); return 0; } static int draw_popup_menu (Menu_Popup_Type *p, int r, int c) { int active_row, active_col; unsigned int dr, dc; Menu_Node_Type **l, **lmax; Menu_Popup_Type *p_active; Active_Popup = p; if (r == 0) r = 1; dr = p->num_subnodes + 2; dc = p->min_width + 5 + 4; /* allow room for keystring */ if (c + (int)dc >= Jed_Num_Screen_Cols) { if ((int)dc > Jed_Num_Screen_Cols) c = 0; else c = Jed_Num_Screen_Cols - (int)dc; } if (r + (int)dr >= Jed_Num_Screen_Rows) { if ((int)dr >= Jed_Num_Screen_Rows) { r = 1; dr = Jed_Num_Screen_Rows - 1; } else r = Jed_Num_Screen_Rows - (int)dr; } SLsmg_set_color_in_region (JMENU_SHADOW_COLOR, r + 1, c + 1, dr, dc); SLsmg_set_color (JMENU_POPUP_COLOR); /* SLsmg_fill_region (r, c, dr, dc, ' '); */ if (Jed_Simulate_Graphic_Chars) simulate_box (r, c, dr, dc); else SLsmg_draw_box (r, c, dr, dc); p->row = r; p->column = c; p->max_row = r + dr; p->max_col = c + dc; /* Make sure a selection is present */ (void) get_selected_menu_item (p); l = p->subnodes; lmax = l + p->num_subnodes; if (p->num_subnodes + 2 > dr) { unsigned int page; unsigned int nr = dr - 2; unsigned int col; col = c + dc - 4; page = p->active_node / nr; if (page) { l += page * nr; draw_up_arrow (r, col); } if (lmax > l + nr) { lmax = l + nr; draw_down_arrow (r + dr - 1, col); } else l = lmax - nr; } p->visible_node_offset = (int) (l - p->subnodes); c++; r++; p_active = NULL; active_row = r; active_col = c; dc -= 3; while (l < lmax) { Menu_Node_Type *m; int color0, color1; m = *l; SLsmg_gotorc (r, c); color0 = JMENU_POPUP_COLOR; color1 = JMENU_CHAR_COLOR; if (m->flags & MENU_SELECTION) { active_row = r; active_col = c + dc; color0 = JMENU_SELECTION_COLOR; color1 = JMENU_SELECTED_CHAR_COLOR; } if ((m->flags & MENU_ACTIVE) && (m->type == MENU_NODE_POPUP)) { p_active = (Menu_Popup_Type *)m; p_active->row = active_row; p_active->column = active_col - dc/2; } SLsmg_set_color (color0); switch (m->type) { case MENU_NODE_SEPARATOR: SLsmg_write_nchars (" ", 1); if (Jed_Simulate_Graphic_Chars) simulate_hline (dc - 1); else SLsmg_draw_hline (dc-1); SLsmg_write_nchars (" ", 1); break; case MENU_NODE_POPUP: SLsmg_write_nchars (" ", 1); draw_name (m->name, color0, color1, dc); SLsmg_gotorc (r, c + (dc - 2)); SLsmg_write_nchars (">>>", 3); break; case MENU_NODE_KEYSTRING: SLsmg_write_nchars (" ", 1); draw_keystring ((Menu_Keystring_Fun_Type *)m, color0, color1, dc); break; default: SLsmg_write_nchars (" ", 1); draw_name (m->name, color0, color1, dc); break; } l++; r++; } if (p_active != NULL) return draw_popup_menu (p_active, p_active->row, p_active->column); SLsmg_gotorc (active_row, active_col); return 0; } static Menu_Bar_Type *get_active_menubar (void) { Menu_Bar_Type *b; /* Active_Popup = NULL; */ b = Active_Menu_Bar; if (b == NULL) { Buffer *buf = CBuf; if (IN_MINI_WINDOW) { if (NULL == (buf = jed_get_mini_action_buffer ())) return NULL; } if (NULL == (b = buf->menubar)) b = Global_Menu_Bar; if (b == NULL) return NULL; } /* Active_Popup = (Menu_Popup_Type *) b; */ return b; } int jed_redraw_menus (void) { Menu_Popup_Type *p; Menu_Bar_Type *b; int active; #if 0 if (NULL == (b = CBuf->menubar)) b = Global_Menu_Bar; #else b = get_active_menubar (); #endif Active_Popup = (Menu_Popup_Type *) b; if (b == NULL) { SLsmg_gotorc (0, 0); SLsmg_set_color (0); SLsmg_erase_eol (); return 0; } active = draw_menu_bar (b); if (active == -1) return 0; touch_screen (); p = (Menu_Popup_Type *)b->subnodes[active]; if (0 == (p->flags & MENU_ACTIVE)) { SLsmg_gotorc (0, b->item_columns[active]); return 1; } draw_popup_menu (p, 0, b->item_columns[active]); return 1; } /* Keyboard Interface */ static int find_active_popup (void) { Menu_Popup_Type *p; if (Active_Menu_Bar == NULL) return -1; p = (Menu_Popup_Type *) Active_Menu_Bar; while (1) { Active_Popup = p; p = (Menu_Popup_Type *) get_selected_menu_item (p); if ((p == NULL) || (p->type != MENU_NODE_POPUP)) return 0; if (0 == (p->flags & MENU_ACTIVE)) return 0; if (0 == (p->flags & MENU_POPUP_PREPARED)) return select_menu_cmd (); } } static int next_menubar_cmd (void) { unsigned int flags; Menu_Popup_Type *p; if (NULL == (p = (Menu_Popup_Type *) Active_Menu_Bar)) return -1; flags = get_active_node_flags (p) & MENU_ACTIVE; /* (void) unselect_active_node ((Menu_Popup_Type *)Active_Menu_Bar); */ (void) select_next_active_node (p, p->active_node, flags); (void) find_active_popup (); return 1; } static int prev_menubar_cmd (void) { unsigned int flags; Menu_Popup_Type *p; if (NULL == (p = (Menu_Popup_Type *) Active_Menu_Bar)) return -1; flags = get_active_node_flags (p) & MENU_ACTIVE; /* (void) unselect_active_node ((Menu_Popup_Type *)Active_Menu_Bar); */ (void) select_prev_active_node (p, p->active_node, flags); (void) find_active_popup (); return 1; } int jed_exit_menu_bar (void) { while (Active_Popup != NULL) { unselect_active_node (Active_Popup); Active_Popup->active_node = 0; Active_Popup->flags &= ~MENU_POPUP_PREPARED; Active_Popup = Active_Popup->parent; } Active_Menu_Bar = NULL; Jed_Menus_Active = 0; return 1; } static int down_menu_cmd (void) { if (Active_Popup == NULL) return -1; /* unselect_active_node (Active_Popup); */ select_next_active_node (Active_Popup, Active_Popup->active_node, 0); return 1; } static int up_menu_cmd (void) { if (Active_Popup == NULL) return -1; /* unselect_active_node (Active_Popup); */ select_prev_active_node (Active_Popup, Active_Popup->active_node, 0); return 1; } static int pgup_menu_cmd (void) { if (Active_Popup == NULL) return -1; select_next_active_node (Active_Popup, Active_Popup->num_subnodes, 0); return 1; } static int pgdn_menu_cmd (void) { if (Active_Popup == NULL) return -1; select_prev_active_node (Active_Popup, 0, 0); return 1; } static int execute_keystring (char *s) { int (*f)(void); if (NULL != (f = (int (*)(void)) (SLang_find_key_function(s, CBuf->keymap)))) return (*f) (); if ((*s == '.') || !SLang_execute_function(s)) SLang_load_string(s); return 1; } static char *get_full_popup_name (Menu_Popup_Type *p) { Menu_Popup_Type *parent; unsigned int len; char *name; char *s; len = strlen (p->name); parent = p->parent; while (parent != NULL) { len += 1 + strlen (parent->name); parent = parent->parent; } name = SLmalloc (len + 1); if (name == NULL) return NULL; s = (name + len) - strlen (p->name); strcpy (s, p->name); parent = p->parent; while (parent != NULL) { s--; *s = '.'; len = strlen (parent->name); s -= len; strncpy (s, parent->name, len); parent = parent->parent; } return name; } static int run_popup_callback (Menu_Popup_Type *p, SLang_Name_Type *cb) { char *name; if (NULL == (name = get_full_popup_name (p))) return -1; if (-1 == SLang_push_string (name)) { SLfree (name); return -1; } SLfree (name); if (0 != SLexecute_function (cb)) return -1; return 0; } static int prepare_popup (Menu_Popup_Type *p) { SLang_Name_Type *cb; if (NULL != (cb = p->select_popup_callback)) { free_menu_popup_subnodes (p); if (-1 == run_popup_callback (p, cb)) return -1; } if (NULL != (cb = p->tweak_popup_callback)) { if (-1 == run_popup_callback (p, cb)) return -1; } p->flags |= MENU_POPUP_PREPARED; return 0; } static int select_menu_cmd (void) { Menu_Node_Type *m; Menu_Popup_Type *p; Menu_C_Fun_Type *c; SLang_Name_Type *nt; char *str; m = get_selected_menu_item (Active_Popup); if (m == NULL) return -1; switch (m->type) { case MENU_NODE_POPUP: #if 0 m->flags |= MENU_ACTIVE; p = (Menu_Popup_Type *) m; #else /* Do it this way to avoid DEC C ansi-aliasing warning. */ p = (Menu_Popup_Type *) m; p->flags |= MENU_ACTIVE; #endif if (-1 == prepare_popup (p)) return -1; Active_Popup = p; select_next_active_node (p, p->num_subnodes, 0); return 1; case MENU_NODE_FUN_SLANG: nt = ((Menu_SLang_Fun_Type *) m)->slang_fun; jed_exit_menu_bar (); if (nt == NULL) return -1; if ((-1 == SLang_start_arg_list ()) || (-1 == SLang_push_anytype (((Menu_SLang_Fun_Type*)m)->client_data)) || (-1 == SLang_end_arg_list ())) return -1; return SLexecute_function (nt); case MENU_NODE_KEYSTRING: str = ((Menu_Keystring_Fun_Type *) m)->keystring; /* Grab a copy while it is still available */ if (NULL == SLang_create_slstring (str)) return -1; jed_exit_menu_bar (); (void) execute_keystring (str); SLang_free_slstring (str); break; case MENU_NODE_FUN_C: c = (Menu_C_Fun_Type *) m; jed_exit_menu_bar (); if (c->c_fun != NULL) return -1; return c->c_fun (); } return 0; } static int back_menu_cmd (void) { if ((Active_Popup == NULL) || (Active_Popup == (Menu_Popup_Type *)Active_Menu_Bar) || (Active_Popup->parent == (Menu_Popup_Type *) Active_Menu_Bar)) return jed_exit_menu_bar (); Active_Popup->flags &= ~(MENU_ACTIVE|MENU_POPUP_PREPARED); Active_Popup = Active_Popup->parent; return 1; } static Menu_Node_Type *find_subnode_via_char (Menu_Popup_Type *p, char ch) { Menu_Node_Type **l, **lmax; unsigned int two; if (p == NULL) return NULL; two = 2; while (two) { l = p->subnodes; lmax = l + p->num_subnodes; while (l < lmax) { Menu_Node_Type *m; char *s; m = *l++; if (m->type == MENU_NODE_SEPARATOR) continue; if (m->flags & MENU_ITEM_UNAVAILABLE) continue; s = strchr (m->name, '&'); if (s == NULL) continue; if (s[1] == ch) return m; } ch = (char) CHANGE_CASE(ch); two--; } return NULL; } static int select_via_char_cmd (void) { Menu_Node_Type *m; m = find_subnode_via_char (Active_Popup, (char) SLang_Last_Key_Char); if (m == NULL) return -1; set_node_selection (Active_Popup, m); return select_menu_cmd (); } static SLKeyMap_List_Type *Menu_Keymap; static SLKeymap_Function_Type Menu_Keymap_Functions [] = { {"next_menubar_menu", next_menubar_cmd}, {"prev_menubar_menu", prev_menubar_cmd}, {"exit_menubar", jed_exit_menu_bar}, {"next_menu_item", down_menu_cmd}, {"prev_menu_item", up_menu_cmd}, {"top_menu_item", pgup_menu_cmd}, {"bot_menu_item", pgdn_menu_cmd}, {"select_menu_item", select_menu_cmd}, {"back_menu", back_menu_cmd}, {NULL, NULL} }; #ifndef IBMPC_SYSTEM # ifdef HAS_MOUSE static int xterm_mouse_cmd (void); # endif #endif static int init_menu_keymap (void) { int ch; char simple[3]; if (NULL == (Menu_Keymap = SLang_create_keymap ("menu", NULL))) return -1; Menu_Keymap->functions = Menu_Keymap_Functions; simple[1] = 0; for (ch = 0; ch < 256; ch++) { simple[0] = (char) ch; SLkm_define_key (simple, (FVOID_STAR) select_via_char_cmd, Menu_Keymap); } simple [0] = 27; simple [2] = 0; for (ch = 'a'; ch <= 'z'; ch++) { simple [1] = (char) ch; SLkm_define_key (simple, (FVOID_STAR) select_via_char_cmd, Menu_Keymap); } SLkm_define_key (" ", (FVOID_STAR) back_menu_cmd, Menu_Keymap); SLkm_define_key ("^?", (FVOID_STAR) back_menu_cmd, Menu_Keymap); SLkm_define_key ("^H", (FVOID_STAR) back_menu_cmd, Menu_Keymap); SLkm_define_key ("^G", (FVOID_STAR) jed_exit_menu_bar, Menu_Keymap); SLkm_define_key ("^Z", (FVOID_STAR) sys_spawn_cmd, Menu_Keymap); SLkm_define_key ("^M", (FVOID_STAR) select_menu_cmd, Menu_Keymap); #ifndef IBMPC_SYSTEM SLkm_define_key ("\033[A", (FVOID_STAR) up_menu_cmd, Menu_Keymap); SLkm_define_key ("\033OA", (FVOID_STAR) up_menu_cmd, Menu_Keymap); SLkm_define_key ("\033[B", (FVOID_STAR) down_menu_cmd, Menu_Keymap); SLkm_define_key ("\033OB", (FVOID_STAR) down_menu_cmd, Menu_Keymap); SLkm_define_key ("\033[C", (FVOID_STAR) next_menubar_cmd, Menu_Keymap); SLkm_define_key ("\033OC", (FVOID_STAR) next_menubar_cmd, Menu_Keymap); SLkm_define_key ("\033[D", (FVOID_STAR) prev_menubar_cmd, Menu_Keymap); SLkm_define_key ("\033OD", (FVOID_STAR) prev_menubar_cmd, Menu_Keymap); SLkm_define_key ("\033[5~", (FVOID_STAR) pgup_menu_cmd, Menu_Keymap); SLkm_define_key ("\033[6~", (FVOID_STAR) pgdn_menu_cmd, Menu_Keymap); # ifdef __unix__ SLkm_define_key ("^(ku)", (FVOID_STAR) up_menu_cmd, Menu_Keymap); SLkm_define_key ("^(kd)", (FVOID_STAR) down_menu_cmd, Menu_Keymap); SLkm_define_key ("^(kr)", (FVOID_STAR) next_menubar_cmd, Menu_Keymap); SLkm_define_key ("^(kl)", (FVOID_STAR) prev_menubar_cmd, Menu_Keymap); SLkm_define_key ("^(kP)", (FVOID_STAR) pgup_menu_cmd, Menu_Keymap); SLkm_define_key ("^(kN)", (FVOID_STAR) pgdn_menu_cmd, Menu_Keymap); # endif # ifdef HAS_MOUSE SLkm_define_key ("\033[M", (FVOID_STAR) xterm_mouse_cmd, Menu_Keymap); # endif #else /* IBMPC_SYSTEM */ #include "doskeys.h" SLkm_define_key (PC_UP, (FVOID_STAR) up_menu_cmd, Menu_Keymap); SLkm_define_key (PC_UP1, (FVOID_STAR) up_menu_cmd, Menu_Keymap); SLkm_define_key (PC_DN, (FVOID_STAR) down_menu_cmd, Menu_Keymap); SLkm_define_key (PC_DN1, (FVOID_STAR) down_menu_cmd, Menu_Keymap); SLkm_define_key (PC_RT, (FVOID_STAR) next_menubar_cmd, Menu_Keymap); SLkm_define_key (PC_RT1, (FVOID_STAR) next_menubar_cmd, Menu_Keymap); SLkm_define_key (PC_LT, (FVOID_STAR) prev_menubar_cmd, Menu_Keymap); SLkm_define_key (PC_LT1, (FVOID_STAR) prev_menubar_cmd, Menu_Keymap); SLkm_define_key (PC_PGUP, (FVOID_STAR) pgup_menu_cmd, Menu_Keymap); SLkm_define_key (PC_PGUP1, (FVOID_STAR) pgup_menu_cmd, Menu_Keymap); SLkm_define_key (PC_PGDN, (FVOID_STAR) pgdn_menu_cmd, Menu_Keymap); SLkm_define_key (PC_PGDN1, (FVOID_STAR) pgdn_menu_cmd, Menu_Keymap); #endif #ifdef HAS_MOUSE SLkm_define_key ("\033^@", (FVOID_STAR) jed_mouse_cmd, Menu_Keymap); #endif return 0; } SLang_Key_Type *jed_menu_do_key (void) { int ch; if (Executing_Keyboard_Macro || (Read_This_Character != NULL)) return SLang_do_key (Menu_Keymap, jed_getkey); ch = my_getkey (); if (SLKeyBoard_Quit || SLang_get_error ()) { jed_exit_menu_bar (); return NULL; } if (ch == 27) /* ESC */ { int tsecs = 2; if (0 == input_pending (&tsecs)) ch = 127; } ungetkey (&ch); return SLang_do_key (Menu_Keymap, jed_getkey); } static int exec_menubar_callback (Menu_Bar_Type *b, SLang_Name_Type **ntp) { SLang_Name_Type *nt; nt = *ntp; if (nt == NULL) return 0; if (SLang_get_error ()) return -1; if (-1 == SLang_push_string (b->name)) return -1; if (-1 == SLexecute_function (nt)) { if (Active_Menu_Bar == b) /* disable callback */ { #if SLANG_VERSION > 10400 SLang_free_function (nt); #endif *ntp = NULL; } return -1; } return 0; } void jed_notify_menu_buffer_changed (void) { Menu_Bar_Type *b; int err; if (NULL == (b = get_active_menubar ())) return; err = SLang_get_error (); SLang_set_error (0); (void) exec_menubar_callback (b, &b->init_callback); if (SLang_get_error () == 0) SLang_set_error (err); } int jed_select_menu_bar (void) { Menu_Popup_Type *p; Menu_Node_Type **l, **lmax; if (IN_MINI_WINDOW) { /* For now do not allow access to menus from the minibuffer * since the minibuffer is not recursive */ return -1; } if (NULL == (Active_Menu_Bar = get_active_menubar ())) return -1; p = (Menu_Popup_Type *) Active_Menu_Bar; Active_Popup = p; l = p->subnodes; lmax = l + p->num_subnodes; /* Reset each sub-node to its default value. This is necessary * to ensure that keyboard macros will work when one switches from * one node to another via next/prev_menubar_cmd functions. */ while (l < lmax) { Menu_Popup_Type *pp = (Menu_Popup_Type *) *l++; if (pp->type == MENU_NODE_POPUP) { (void) unselect_active_node (pp); pp->active_node = 0; } } p->active_node = 0; if (-1 == exec_menubar_callback (Active_Menu_Bar, &Active_Menu_Bar->select_callback)) { jed_exit_menu_bar (); return -1; } (void) get_selected_menu_item (p); touch_screen (); Jed_Menus_Active = 1; return 0; } /* Interpreter interface */ static Menu_Node_Type *find_menu_node1 (Menu_Popup_Type *m, char *name, int stop_at_last_popup) { char *name_end; Menu_Node_Type **l, **lmax; name_end = strchr (name, '.'); if (name_end == NULL) name_end = name + strlen (name); l = m->subnodes; lmax = l + m->num_subnodes; while (l < lmax) { Menu_Popup_Type *p; p = (Menu_Popup_Type *) *l++; if (0 == menu_name_eqs (p->name, name, name_end)) continue; if (*name_end == 0) { if (stop_at_last_popup && ((p->type != MENU_NODE_POPUP) || (p->type != MENU_NODE_MENUBAR))) return (Menu_Node_Type *)m; return (Menu_Node_Type *)p; } if (p->type == MENU_NODE_POPUP) return find_menu_node1 (p, name_end + 1, stop_at_last_popup); return NULL; } return NULL; } static Menu_Node_Type *find_menu_node (char *name, int stop_at_last_popup) { char *s; Menu_Node_Type *m; m = (Menu_Node_Type *) menu_find_menu_bar (name, 1); if (m == NULL) return m; s = strchr (name, '.'); if (s == NULL) return m; m = find_menu_node1 ((Menu_Popup_Type *)m, s + 1, stop_at_last_popup); if (m == NULL) SLang_verror (SL_INTRINSIC_ERROR, "Unable to find menu node %s", name); return m; } static Menu_Popup_Type *find_menu_popup (char *name) { Menu_Popup_Type *m; m = (Menu_Popup_Type *) find_menu_node (name, 0); if (m == NULL) return m; if ((m->type != MENU_NODE_POPUP) && (m->type != MENU_NODE_MENUBAR)) { SLang_verror (SL_INVALID_PARM, "%s is not a menu node", name); return NULL; } return m; } /* If name is NULL or non-existent, then insert at end */ static unsigned int find_where_to_insert (Menu_Popup_Type *p, char *name) { unsigned int i, num; num = p->num_subnodes; if (name != NULL) for (i = 0; i < num; i++) { if (0 == strcmp (name, p->subnodes[i]->name)) return i; } return num; } static void create_menu_bar_cmd (char *name) { if (0 == strcmp ("Global", name)) { Menu_Bar_Type *g = create_menu_bar (name, 5); if (g != NULL) jed_delete_menu_bar (Global_Menu_Bar); Global_Menu_Bar = g; return; } if (NULL != menu_find_menu_bar (name, 0)) return; (void) create_menu_bar (name, 5); } static void set_buffer_menu_bar_cmd (char *name) { Menu_Bar_Type *b; b = menu_find_menu_bar (name, 1); if (b == NULL) return; jed_delete_menu_bar (CBuf->menubar); CBuf->menubar = b; b->num_refs += 1; } static int pop_where_to_insert (Menu_Popup_Type *p, unsigned int *where) { if (SLang_peek_at_stack () == SLANG_STRING_TYPE) { char *s; if (-1 == SLang_pop_slstring (&s)) return -1; *where = find_where_to_insert (p, s); SLang_free_slstring (s); return 0; } if (-1 == SLang_pop_uinteger (where)) return -1; return 0; } static void insert_popup_menu_cmd (char *dest, char *menu) { Menu_Popup_Type *m; unsigned int where; m = find_menu_popup (dest); if (m == NULL) return; if (-1 == pop_where_to_insert (m, &where)) return; insert_popup_menu (m, menu, where); } static void append_popup_menu_cmd (char *dest, char *menu) { Menu_Popup_Type *m; m = find_menu_popup (dest); if (m == NULL) return; insert_popup_menu (m, menu, m->num_subnodes); } static void insert_separator_cmd (char *name) { Menu_Popup_Type *m; unsigned int where; m = find_menu_popup (name); if (m == NULL) return; if (-1 == pop_where_to_insert (m, &where)) return; insert_separator (m, where); } static void append_separator_cmd (char *name) { Menu_Popup_Type *m; m = find_menu_popup (name); if (m != NULL) insert_separator (m, m->num_subnodes); } static void insert_menu_item_cmd_internal (int is_fun, int do_append) { Menu_Popup_Type *m; SLang_Name_Type *nt = NULL; SLang_Any_Type *client_data = NULL; char *str = NULL; char *menu = NULL; char *name = NULL; unsigned int where; if (is_fun) { if (-1 == SLang_pop_anytype (&client_data)) return; if (NULL == (nt = SLang_pop_function ())) goto free_and_return; } else if (-1 == SLang_pop_slstring (&str)) return; if (-1 == SLang_pop_slstring (&name)) goto free_and_return; if (-1 == SLang_pop_slstring (&menu)) goto free_and_return; if (NULL == (m = find_menu_popup (menu))) goto free_and_return; if (do_append) where = m->num_subnodes; else if (-1 == pop_where_to_insert (m, &where)) goto free_and_return; if (nt != NULL) { if (NULL != insert_slang_fun_item (m, name, nt, client_data, where)) { client_data = NULL; nt = NULL; } } else (void) insert_keystring_item (m, name, str, where); /* drop */ free_and_return: if (client_data != NULL) SLang_free_anytype (client_data); SLang_free_slstring (str); SLang_free_slstring (menu); SLang_free_slstring (name); #if SLANG_VERSION > 10400 SLang_free_function (nt); #endif } static void insert_menu_item_cmd (void) { insert_menu_item_cmd_internal ((SLang_Num_Function_Args == 5), 0); } static void append_menu_item_cmd (void) { insert_menu_item_cmd_internal ((SLang_Num_Function_Args == 4), 1); } static void menu_delete_item_cmd (char *menu) { Menu_Popup_Type *parent; Menu_Node_Type *child; parent = (Menu_Popup_Type *)find_menu_node (menu, 1); child = find_menu_node (menu, 0); if ((parent == NULL) || (child == NULL)) { SLang_verror (SL_INVALID_PARM, "Menu %s does not exist", menu); return; } menu_delete_node (parent, child); } static void menu_delete_items_cmd (char *menu) { Menu_Popup_Type *p; if (NULL == (p = find_menu_popup (menu))) return; menu_delete_nodes (p); } static void set_object_available_cmd (char *name, int *flag) { Menu_Node_Type *m; if (NULL == (m = find_menu_node (name, 0))) return; if (*flag) m->flags &= ~MENU_ITEM_UNAVAILABLE; else m->flags |= MENU_ITEM_UNAVAILABLE; } static int pop_popup_callback (Menu_Popup_Type **pp, int type, SLang_Name_Type **ntp) { SLang_Name_Type *nt; char *popup; Menu_Popup_Type *p; if (SLang_peek_at_stack () == SLANG_NULL_TYPE) { (void) SLang_pop_null (); nt = NULL; } else if (NULL == (nt = SLang_pop_function ())) return -1; if (-1 == SLang_pop_slstring (&popup)) { #if SLANG_VERSION > 10400 SLang_free_function (nt); #endif return -1; } p = find_menu_popup (popup); if (p == NULL) { #if SLANG_VERSION > 10400 SLang_free_function (nt); #endif SLang_free_slstring (popup); return -1; } if (type && (p->type != type)) { SLang_verror (SL_INVALID_PARM, "%s does not specify the proper menu type", popup); #if SLANG_VERSION > 10400 SLang_free_function (nt); #endif SLang_free_slstring (popup); return -1; } SLang_free_slstring (popup); *ntp = nt; *pp = p; return 0; } static int pop_menubar_callback (Menu_Bar_Type **bp, SLang_Name_Type **nt) { return pop_popup_callback ((Menu_Popup_Type **)bp, MENU_NODE_MENUBAR, nt); } static void set_select_menubar_callback (void) { Menu_Bar_Type *b; SLang_Name_Type *nt; if (-1 == pop_menubar_callback (&b, &nt)) return; b->select_callback = nt; } static void set_init_menubar_callback (void) { Menu_Bar_Type *b; SLang_Name_Type *nt; if (-1 == pop_menubar_callback (&b, &nt)) return; b->init_callback = nt; } static void set_select_popup_callback (void) { Menu_Popup_Type *p; SLang_Name_Type *nt; if (-1 == pop_popup_callback (&p, MENU_NODE_POPUP, &nt)) return; p->select_popup_callback = nt; } static void set_tweak_popup_callback (void) { Menu_Popup_Type *p; SLang_Name_Type *nt; if (-1 == pop_popup_callback (&p, MENU_NODE_POPUP, &nt)) return; p->tweak_popup_callback = nt; } static void copy_menu_cmd (char *destname, char *srcname) { Menu_Popup_Type *dest; Menu_Node_Type *src; dest = find_menu_popup (destname); if (dest == NULL) return; src = find_menu_node (srcname, 0); if (src == NULL) return; (void) copy_menu (dest, src); } static void set_menu_bar_prefix_string (char *menubar, char *s) { Menu_Bar_Type *b; if (NULL == (b = menu_find_menu_bar (menubar, 1))) return; s = SLang_create_slstring (s); if (s == NULL) return; SLang_free_slstring (b->prefix_string); b->prefix_string = s; } static void popup_menu_cmd (char *menu) { char *popup; (void) jed_exit_menu_bar (); if (-1 == jed_select_menu_bar ()) return; if (NULL == (menu = SLmake_string (menu))) return; /* for now ignore the menubar name and use default */ popup = strchr (menu, '.'); if (popup != NULL) popup++; while ((popup != NULL) && (Active_Popup != NULL)) { Menu_Node_Type *m; char *next_popup; next_popup = strchr (popup, '.'); if (next_popup != NULL) *next_popup++ = 0; if (NULL == (m = find_subnode (Active_Popup, popup))) { SLang_verror (SL_INVALID_PARM, "Unable to find a popup menu called %s", menu); break; } set_node_selection (Active_Popup, m); if (-1 == select_menu_cmd ()) break; popup = next_popup; } SLfree (menu); } static SLang_Intrin_Fun_Type Menu_Table[] = { MAKE_INTRINSIC_S("menu_create_menu_bar", create_menu_bar_cmd, VOID_TYPE), MAKE_INTRINSIC_SS("menu_append_popup", append_popup_menu_cmd, VOID_TYPE), MAKE_INTRINSIC_SS("menu_insert_popup", insert_popup_menu_cmd, VOID_TYPE), MAKE_INTRINSIC_S("menu_use_menu_bar", set_buffer_menu_bar_cmd, VOID_TYPE), MAKE_INTRINSIC_S("menu_append_separator", append_separator_cmd, VOID_TYPE), MAKE_INTRINSIC_S("menu_insert_separator", insert_separator_cmd, VOID_TYPE), MAKE_INTRINSIC_0("menu_append_item", append_menu_item_cmd, VOID_TYPE), MAKE_INTRINSIC_0("menu_insert_item", insert_menu_item_cmd, VOID_TYPE), MAKE_INTRINSIC_S("menu_delete_item", menu_delete_item_cmd, VOID_TYPE), MAKE_INTRINSIC_S("menu_delete_items", menu_delete_items_cmd, VOID_TYPE), MAKE_INTRINSIC_SI("menu_set_object_available", set_object_available_cmd, VOID_TYPE), MAKE_INTRINSIC_0("menu_set_select_menubar_callback", set_select_menubar_callback, VOID_TYPE), MAKE_INTRINSIC_0("menu_set_init_menubar_callback", set_init_menubar_callback, VOID_TYPE), MAKE_INTRINSIC_0("menu_set_select_popup_callback", set_select_popup_callback, VOID_TYPE), MAKE_INTRINSIC_0("menu_set_tweak_popup_callback", set_tweak_popup_callback, VOID_TYPE), MAKE_INTRINSIC_SS("menu_copy_menu", copy_menu_cmd, VOID_TYPE), MAKE_INTRINSIC_SS("menu_set_menu_bar_prefix", set_menu_bar_prefix_string, VOID_TYPE), MAKE_INTRINSIC_S("menu_select_menu", popup_menu_cmd, VOID_TYPE), MAKE_INTRINSIC(NULL,NULL,0,0) }; int jed_init_menus (void) { if (-1 == init_menu_keymap ()) return -1; if (-1 == SLadd_intrin_fun_table (Menu_Table, NULL)) return -1; #if 0 if (-1 == make_global_menubar ()) return -1; #endif return 0; } #ifdef HAS_MOUSE static int select_menu_via_rc (int type, int r, int c) { Menu_Popup_Type *p; p = Active_Popup; while (p != (Menu_Popup_Type *)Active_Menu_Bar) { if ((r >= p->row) && (r < p->max_row) && (c >= p->column) && (c < p->max_col)) break; p = p->parent; } if ((p == NULL) || (p->type == MENU_NODE_MENUBAR)) { unsigned int i; int *item_columns; if (Active_Popup == NULL) return -1; if (r != 0) { if (type != JMOUSE_DRAG) return -1; if (Active_Popup->type != MENU_NODE_MENUBAR) return 0; } unselect_active_node ((Menu_Popup_Type *) Active_Menu_Bar); i = Active_Menu_Bar->num_subnodes; item_columns = Active_Menu_Bar->item_columns; while (i > 0) { i--; if ((i != 0) && (item_columns[i] > c)) continue; p = (Menu_Popup_Type *)Active_Menu_Bar->subnodes[i]; if (p->type == MENU_NODE_SEPARATOR) continue; if (p->flags & MENU_ITEM_UNAVAILABLE) continue; if (-1 == set_node_selection ((Menu_Popup_Type *) Active_Menu_Bar, (Menu_Node_Type *) p)) return -1; if (-1 == find_active_popup ()) return -1; if (p->type == MENU_NODE_POPUP) return select_menu_cmd (); } return -1; } if (p == Active_Popup) { r -= (p->row + 1); r += p->visible_node_offset; if ((r >= (int)p->num_subnodes) || (r < 0)) return 0; if (-1 == set_node_selection (p, p->subnodes[r])) return 0; if ((type != JMOUSE_DRAG) || ((p->subnodes[r]->type == MENU_NODE_POPUP) && (c + 1 >= p->max_col))) select_menu_cmd (); return 0; } while (Active_Popup != p) back_menu_cmd (); return 0; } int jed_menu_handle_mouse (unsigned int type, int x, int y, int button, int shift) { (void) shift; (void) button; if ((type != JMOUSE_UP) && (type != JMOUSE_DRAG)) return -1; if ((Jed_Menus_Active == 0) && (-1 == jed_select_menu_bar ())) return -1; if (-1 == select_menu_via_rc (type, y-1, x-1)) { if (type != JMOUSE_DRAG) jed_exit_menu_bar (); } return 0; } #ifndef IBMPC_SYSTEM static int xterm_mouse_cmd (void) { int x, y, b; b = my_getkey (); x = (unsigned char) my_getkey () - 32; y = (unsigned char) my_getkey () - 32; /* We need to trigger on the button release event */ b -= 32; if ((b & 3) != 3) return -1; return jed_menu_handle_mouse (JMOUSE_UP, x, y, 0, 0); } #endif /* !IBMPC_SYSTEM */ #endif /* HAS_MOUSE */ #endif /* JED_HAS_MENUS */ jed-0.99-19/src/copyright0000644002657400265740000000136211311317447014216 0ustar davisdavis/* Copyright (c) 1992, 1993 by John E. Davis davis@space.mit.edu Permission to use, copy, modify, and distribute this software and its documentation for any non-commercial purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation. This software is provided AS IS with no warranties of any kind. The author shall have no liability with respect to the infringement of copyrights, trade secrets or any patents by this software or any part thereof. In no event will the author be liable for any lost revenue or profits or other special, indirect and consequential damages. */ jed-0.99-19/src/undo.c0000644002657400265740000002120611311317447013373 0ustar davisdavis/* -*- mode: C; mode: fold; -*- */ /* Copyright (c) 1992, 1998, 2000, 2002, 2003, 2004, 2005, 2006 John E. Davis * This file is part of JED editor library source. * * You may distribute this file under the terms the GNU General Public * License. See the file COPYING for more information. */ #include "config.h" #include "jed-feat.h" #include #include "buffer.h" #include "undo.h" #include "ins.h" #include "line.h" #include "misc.h" #include "screen.h" #define LAST_UNDO CBuf->undo->Last_Undo #define FIRST_UNDO CBuf->undo->First_Undo #define UNDO_RING CBuf->undo->Undo_Ring #ifdef UNDO_HAS_REDO # define CURRENT_UNDO CBuf->undo->Current_Undo #endif static int Undo_In_Progress = 0; int Undo_Buf_Unch_Flag; /* 1 if buffer prev not modified */ #ifdef UNDO_HAS_REDO #define DONT_RECORD_UNDO (!(CBuf->flags & UNDO_ENABLED)\ || (CBuf->undo == NULL)) #else #define DONT_RECORD_UNDO (!(CBuf->flags & UNDO_ENABLED)\ || (CBuf->undo == NULL) || Undo_In_Progress) #endif #define UNDO_BD_FLAG 0x8000 #define UNDO_UNCHANGED_FLAG 0x4000 #ifdef UNDO_HAS_REDO # define IS_UNDO_BD (CURRENT_UNDO->type & UNDO_BD_FLAG) #else # define IS_UNDO_BD (LAST_UNDO->type & UNDO_BD_FLAG) #endif static void prepare_next_undo(void) /*{{{*/ { LAST_UNDO++; if (LAST_UNDO >= UNDO_RING + MAX_UNDOS) LAST_UNDO = UNDO_RING; if (LAST_UNDO == FIRST_UNDO) { FIRST_UNDO++; #ifdef UNDO_HAS_REDO if (FIRST_UNDO >= UNDO_RING + MAX_UNDOS) FIRST_UNDO = UNDO_RING; #endif } #ifdef UNDO_HAS_REDO if (LAST_UNDO == CURRENT_UNDO) /* undo-ring overflow will trash */ CURRENT_UNDO = NULL; /* further undos */ #else if (FIRST_UNDO >= UNDO_RING + MAX_UNDOS) FIRST_UNDO = UNDO_RING; #endif LAST_UNDO->type = 0; LAST_UNDO->misc = 0; } /*}}}*/ #ifdef UNDO_HAS_REDO /* Returns True if there is still undo info to be processed. */ #define MORE_UNDO_INFO (CURRENT_UNDO && (CURRENT_UNDO->type)) #endif void record_deletion (unsigned char *p, int n) /*{{{*/ { int misc; unsigned char *pb; if (DONT_RECORD_UNDO || (n == 0)) return; while (1) { if (((LAST_UNDO->type & 0xFF) == 0) || ((LAST_UNDO->type & CDELETE) && (LAST_UNDO->linenum == LineNum + CBuf->nup) && (LAST_UNDO->point == Point))) { if (LAST_UNDO->type != 0) misc = LAST_UNDO->misc; else misc = 0; pb = LAST_UNDO->buf + misc; while ((misc < 8) && n) { *pb++ = *p++; misc++; n--; } LAST_UNDO->misc = misc; LAST_UNDO->type |= CDELETE; LAST_UNDO->linenum = LineNum + CBuf->nup; LAST_UNDO->point = Point; if (Undo_Buf_Unch_Flag) LAST_UNDO->type |= UNDO_UNCHANGED_FLAG; Undo_Buf_Unch_Flag = 0; } if (n == 0) break; prepare_next_undo(); } if (Undo_Buf_Unch_Flag) LAST_UNDO->type |= UNDO_UNCHANGED_FLAG; #ifdef UNDO_HAS_REDO set_current_undo (); #endif } /*}}}*/ int undo (void) /*{{{*/ { int line; CHECK_READ_ONLY if (!(CBuf->flags & UNDO_ENABLED)) { msg_error("Undo not enabled for this buffer."); return(0); } else if ((CBuf->undo == NULL) #ifdef UNDO_HAS_REDO || (0 == MORE_UNDO_INFO) #else || (LAST_UNDO->type == 0) #endif ) { msg_error("No more undo information."); return(0); } Undo_In_Progress = 1; do { int undo_type; #ifdef UNDO_HAS_REDO line = (int) CURRENT_UNDO->linenum; undo_type = CURRENT_UNDO->type & 0xFF; #else line = (int) LAST_UNDO->linenum; undo_type = LAST_UNDO->type & 0xFF; #endif if ((line <= (int) CBuf->nup) || ((unsigned int) line >= CBuf->nup + Max_LineNum)) { if (((unsigned int) line != CBuf->nup + Max_LineNum) || (undo_type == NLINSERT)) { msg_error("Next undo lies outside visible buffer."); break; } } line -= CBuf->nup; goto_line(&line); #ifdef UNDO_HAS_REDO Point = CURRENT_UNDO->point; #else Point = LAST_UNDO->point; #endif if (Point > CLine->len) { Point = 0; msg_error ("Internal Error in undo: Point > CLine->len"); break; } switch (undo_type) { #ifdef UNDO_HAS_REDO case CDELETE: (void) jed_insert_nbytes (CURRENT_UNDO->buf, CURRENT_UNDO->misc); /* Point = CURRENT_UNDO->point; */ #else case CDELETE: (void) jed_insert_nbytes (LAST_UNDO->buf, LAST_UNDO->misc); /* Point = LAST_UNDO->point; */ #endif break; #ifdef UNDO_HAS_REDO case CINSERT: (void) jed_del_nbytes (CURRENT_UNDO->misc); #else case CINSERT: (void) jed_del_nbytes (LAST_UNDO->misc); #endif break; case UNDO_POSITION: break; case NLINSERT: jed_del_wchar (); break; default: return(1); } #ifdef UNDO_HAS_REDO if (CURRENT_UNDO == NULL) break; /* no more undo info after overflow */ /* above calls to ins_chars/deln/del may overflow the undo-ring */ if (CURRENT_UNDO->type & UNDO_UNCHANGED_FLAG) { mark_buffer_modified (CBuf, 0, 1); } if (CURRENT_UNDO == FIRST_UNDO) { CURRENT_UNDO = NULL ; break ; /* no more undo info */ } CURRENT_UNDO--; if (CURRENT_UNDO < UNDO_RING) CURRENT_UNDO = UNDO_RING + MAX_UNDOS - 1; #else if (LAST_UNDO->type & UNDO_UNCHANGED_FLAG) { mark_buffer_modified (CBuf, 0, 1); } if (LAST_UNDO == FIRST_UNDO) LAST_UNDO->type = 0; else { LAST_UNDO--; if (LAST_UNDO < UNDO_RING) LAST_UNDO = UNDO_RING + MAX_UNDOS - 1; } #endif } #ifdef UNDO_HAS_REDO while ((!IS_UNDO_BD) && (CURRENT_UNDO->type)); #else while ((!IS_UNDO_BD) && (LAST_UNDO->type)); #endif message("Undo!"); Undo_In_Progress = 0; return(1); } /*}}}*/ void record_insertion(int n) /*{{{*/ { if (DONT_RECORD_UNDO || !n) return; if ((Undo_Buf_Unch_Flag) && (LAST_UNDO->type)) { prepare_next_undo (); } if (LAST_UNDO->type == 0) { LAST_UNDO->misc = n; LAST_UNDO->point = Point; } else if ((LAST_UNDO->type & CINSERT) && (LAST_UNDO->linenum == LineNum + CBuf->nup) && (LAST_UNDO->point + LAST_UNDO->misc == Point) && (LAST_UNDO->misc <= 32)) { LAST_UNDO->misc += n; } else { prepare_next_undo(); LAST_UNDO->point = Point; LAST_UNDO->misc = n; } LAST_UNDO->type |= CINSERT; if (Undo_Buf_Unch_Flag) LAST_UNDO->type |= UNDO_UNCHANGED_FLAG; LAST_UNDO->linenum = LineNum + CBuf->nup; #ifdef UNDO_HAS_REDO set_current_undo (); #endif } /*}}}*/ void record_newline_insertion() /*{{{*/ { if (DONT_RECORD_UNDO) return; if (LAST_UNDO->type != 0) prepare_next_undo(); if (Undo_Buf_Unch_Flag) LAST_UNDO->type |= UNDO_UNCHANGED_FLAG; LAST_UNDO->point = Point; LAST_UNDO->misc = 0; LAST_UNDO->type |= NLINSERT; LAST_UNDO->linenum = LineNum + CBuf->nup; #ifdef UNDO_HAS_REDO set_current_undo (); #endif } /*}}}*/ void jed_undo_record_position (void) { if (DONT_RECORD_UNDO) return; if (LAST_UNDO->type != 0) prepare_next_undo(); if (Undo_Buf_Unch_Flag) LAST_UNDO->type |= UNDO_UNCHANGED_FLAG; LAST_UNDO->point = Point; LAST_UNDO->misc = 0; LAST_UNDO->type |= UNDO_POSITION; LAST_UNDO->linenum = LineNum + CBuf->nup; #ifdef UNDO_HAS_REDO set_current_undo (); #endif } void delete_undo_ring(Buffer *b) /*{{{*/ { SLfree ((char *)b->undo); } /*}}}*/ void create_undo_ring() /*{{{*/ { Undo_Type *ur; Undo_Object_Type *uo; int n; if (NULL == (ur = (Undo_Type *) SLmalloc (sizeof(Undo_Type)))) { msg_error("Unable to malloc space for undo!"); return; } CBuf->undo = ur; uo = ur->Undo_Ring; ur->Last_Undo = ur->First_Undo = uo; #ifdef UNDO_HAS_REDO ur->Current_Undo = NULL; #endif n = MAX_UNDOS; while (n--) { uo->type = 0; uo++; } } /*}}}*/ void mark_undo_boundary (Buffer *b) /*{{{*/ { Buffer *s = CBuf; CBuf = b; if (!DONT_RECORD_UNDO && (LAST_UNDO->type != 0)) { LAST_UNDO->type |= UNDO_BD_FLAG; } CBuf = s; } /*}}}*/ void unmark_undo_boundary (Buffer *b) /*{{{*/ { #if 0 (void) b; #else Buffer *s = CBuf; CBuf = b; if (!DONT_RECORD_UNDO && (LAST_UNDO->type != 0)) { LAST_UNDO->type &= ~UNDO_BD_FLAG; } CBuf = s; #endif } /*}}}*/ #ifdef UNDO_HAS_REDO void set_current_undo() /* Called when text is inserted, deleted, */ /*{{{*/ { /* or the abort key is pressed. */ if ((!Undo_In_Progress) && CBuf->undo) { CURRENT_UNDO = LAST_UNDO ; } } /*}}}*/ void update_undo_unchanged (void) /*{{{*/ /* Update unchange flags after a buffer save. The reason for this is * that after a save, undoing on the buffer does not affect the disk file. */ { Undo_Object_Type *uo; int n; if (DONT_RECORD_UNDO) return; uo = UNDO_RING ; n = MAX_UNDOS; while (n--) { uo->type &= ~UNDO_UNCHANGED_FLAG; uo++; } CURRENT_UNDO = LAST_UNDO ; } /*}}}*/ #endif jed-0.99-19/src/paste.h0000644002657400265740000000377011311317447013555 0ustar davisdavis/* Copyright (c) 1992, 1998, 2000, 2005, 2006 John E. Davis * This file is part of JED editor library source. * * You may distribute this file under the terms the GNU General Public * License. See the file COPYING for more information. */ extern int set_mark_cmd(void); extern int push_spot(void); extern int jed_push_mark (void); extern int jed_goto_mark(Mark *); extern int jed_pop_mark (int); extern int mark_spot(void); extern int pop_spot(void); extern int widen_buffer(Buffer *); extern int widen(void); extern int widen_region (void); extern int narrow_to_region (void); extern int narrow_to_lines (void); extern void jed_widen_whole_buffer (Buffer *); extern void jed_init_mark (Mark *, unsigned int); extern void jed_init_mark_for_buffer (Mark *, Buffer *, unsigned int); extern int jed_init_mark_for_line (Mark *, Line *, unsigned int); extern void jed_copy_mark (Mark *dest, Mark *src); #if JED_HAS_SAVE_NARROW extern void jed_free_saved_narrow (Buffer *); extern void jed_push_narrow (void); extern void jed_pop_narrow (void); #endif extern int jed_count_narrows (void); extern int exchange_point_mark(void); extern int yank(void); extern int check_region(int *); extern int copy_region_to_buffer(Buffer *); extern int delete_region(void); extern int copy_to_pastebuffer(void); extern int kill_region(void); extern int insert_rectangle(void); extern int kill_rectangle(void); extern int blank_rectangle(void); extern int open_rectangle(void); extern int copy_rectangle(void); extern void goto_user_mark (void); extern void create_user_mark (void); extern void free_user_marks (Buffer *); extern void move_user_mark (void); extern int jed_is_user_mark_in_narrow (void); extern int jed_move_user_object_mark (SLang_MMT_Type *); extern SLang_MMT_Type *jed_make_user_object_mark (void); extern char *user_mark_buffer (void); extern int register_jed_classes (void); #if JED_HAS_LINE_MARKS extern void jed_create_line_mark (int *); #endif extern unsigned int jed_count_lines_in_region (void); extern Buffer *Paste_Buffer; jed-0.99-19/src/test/0000755002657400265740000000000011311317447013240 5ustar davisdavisjed-0.99-19/src/test/test_cmode.sl0000644002657400265740000000170411311317447015730 0ustar davisdavisprivate variable Input_File = path_concat (path_dirname (__FILE__), "test_cmode.dat"); private variable Log_File = path_sans_extname (__FILE__) + ".log"; define test_cmode (file) { setbuf ("*test*"); erase_buffer (); c_set_style ("jed"); c_mode (); TAB = 0; () = insert_file (file); bob (); variable failures = {}; do { bol_skip_white (); if (not eolp ()) { variable col = what_column (); indent_line (); bol_skip_white (); if (col != what_column ()) list_append (failures, what_line()); } } while (down_1()); if (length (failures)) { () = fprintf (stderr, "cmode.sl failed to properly indent the following lines:\n"); foreach (failures) { variable line = (); () = fprintf (stdout, " %d", line); } () = fprintf (stdout, "\n"); () = remove (Log_File); () = write_buffer (Log_File); exit (1); } exit (0); } test_cmode (Input_File); jed-0.99-19/src/test/runtests.sh0000755002657400265740000000052111311317447015464 0ustar davisdavis#!/bin/sh jed="$1" if [ ! -x "$jed" ]; then echo "Usage: $0 /path/to/jed" exit 1 fi test_dir=`dirname "$0"` jed_root=$test_dir/../.. export JED_ROOT="$jed_root" jedscript="$jed -script" failed=0 for X in $test_dir/test_*.sl do echo Running $jedscript $X if ! $jedscript ./$X then failed=1 fi done exit $failed jed-0.99-19/src/test/test_expand.sl0000644002657400265740000000337011311317447016121 0ustar davisdavis() = chdir ("/tmp"); private variable Failed = 0; define test_expand_filename (a, b) { variable b1 = expand_filename (a); if (b != b1) { Failed = 1; message ("expand_filename ($a) -> $b1, expected $b"$); } } test_expand_filename ("", "/tmp/"); test_expand_filename ("./", "/tmp/"); test_expand_filename (".", "/tmp/"); test_expand_filename ("..", "/"); test_expand_filename ("../", "/"); test_expand_filename (".././", "/"); test_expand_filename ("foo.././", "/tmp/foo../"); test_expand_filename ("f.././", "/tmp/f../"); test_expand_filename ("fo.././", "/tmp/fo../"); test_expand_filename ("fo.././bar", "/tmp/fo../bar"); test_expand_filename ("././bar", "/tmp/bar"); test_expand_filename ("/./bar", "/bar"); test_expand_filename ("/./bar//gamma", "/gamma"); test_expand_filename ("//./bar//gamma", "/bar/gamma"); test_expand_filename ("//./bar//gamma/.", "/bar/gamma/"); test_expand_filename ("//./bar//gamma/..", "/bar/"); test_expand_filename ("/..", "/"); test_expand_filename ("/.", "/"); test_expand_filename ("~/foo", "$HOME/foo"$); test_expand_filename ("/foo/bar/~/xx/..", "$HOME/"$); test_expand_filename ("/foo/bar/~/~/xx/..", "$HOME/"$); test_expand_filename ("~/foo/bar/~/~/xx/..", "$HOME/"$); test_expand_filename ("~/foo/bar/~/~xx", "$HOME/~xx"$); test_expand_filename ("~/foo/bar/~/xx~", "$HOME/xx~"$); test_expand_filename ("~/foo/bar/~", "$HOME/foo/bar/~"$); #ifntrue % Only for __QNX__ test_expand_filename ("/foo/bar///1/foo/bar", "//1/foo/bar"); test_expand_filename ("//23", "//23"); test_expand_filename ("//23/bar///1/foo/bar", "//1/foo/bar"); test_expand_filename ("//23/bar///12/foo/bar", "//12/foo/bar"); test_expand_filename ("//23/bar/~/baz", "$HOME/baz"$); #endif %test_expand_filename ("~dph/foo", "/home/dph"); exit (Failed); jed-0.99-19/src/test/test_cmode.dat0000644002657400265740000000561311311317447016065 0ustar davisdavis/* -*- mode: C; TAB: 0; -*- * This file is used to test jed's c-mode indentation routines */ #ifdef this # define that this #else # define that notthis # ifndef those # define those this,that # endif #endif struct _pSLang_Ref_Type { int is_global; union { SLang_Name_Type *nt; SLang_Object_Type *local_obj; } v; }; typedef struct { int foo; double bar; /* bar */ union { int i; double j; } u; } Some_Type; typedef struct Some_Tag { int foo; double bar; /* bar */ union { int i; double j; } u; } Some_Type; namespace foobar { int foo; T bar = { {1, 2, 3}; }; } int main (int argc, char **argv) { int X[] = { 1,2,3,4, 5,6,7,8 9,10 }; Foo_Type foo []= { // comment {foo, bar}, {baz,bam}, }; /* * Unbalanced { */ // not C, but is used in slang X = struct { foo, bar, baz }; typedef enum { X = 1, Y, Z } Foo; if ((x == 3) || (y == 2) || ((z == 1) && (y == 3))) dothis (); else if ((y == 3) && (z != 4)) dothat (); #define silly(fun,x) /* a macro */ \ int fun(x) \ { \ return x \ + 7;\ } x = 1 + 2 + 3 + 4 /* =7 */ + 5 * 6; y = 1 + 2 //add 6 + (3 * 4 //12 * fun (5 + 6) ); switch (foo) { case A: B = 3; break; case B: C = 4; break; default: X = bar () + 2; switch (X) { case 4: X++; break; } } cout >> foo >> bar//foo >> x //x >> y;//y // This is a test of some of "foam" style indentation while ( x + 10 == 3 ) { if ( x + 10 != 3 ) problem (); } // I am not happy with the indentation of the following if (debug) cout >> foo >> bar >> bam; if (this) x = 3 + 4 + 5 + 6; else if (that || those) x = 3 + 4 + 5 + 6; else y = 3 + 4 + 5 + 6; foo ( { elem1, elem2 }); x = [ e1, e2 ]; if (this_condition) if (that_condition) do_that (); switch (val) { case 0: if (foo ()) { bar (); } else if (baz ()) /* comment */ { this (); if (that != 3) those (); } } // The following do not indent properly. if (foo) name += bar + baz; if (bar) name = foo + bar; (foo) = bar; (bar) = foo; } jed-0.99-19/src/test/test_replace.sl0000644002657400265740000000156011311317447016254 0ustar davisdavisprivate variable Failed = 0; private define new_buffer (str) { setbuf ("*scratch*"); erase_buffer (); insert (str); bob (); } private define buffer_contents () { bob (); push_mark (); eob (); return bufsubstr (); } private define test_replace (str, s, t) { variable new_s; new_buffer (str); replace (s, t); (new_s,) = strreplace (str, s, t, strlen (str)); if (new_s != buffer_contents ()) { (s,) = strreplace (s, "\n", "\\n", strlen(s)); (t,) = strreplace (t, "\n", "\\n", strlen(t)); () = fprintf (stderr, "failed to replace \"$s\" with \"$t\"\n"$, s, t); Failed++; } } private define main () { test_replace ("\n\n\n\n\nx\n\ny", "x", "t"); test_replace ("\n\n\n\n\nx\n\ny", "\n", "t"); test_replace ("\n\n\n\n\nx\n\ny", "\n", "\ny"); test_replace ("\n\n\n\n\nx\n\ny", "\n", "x"); } main (); exit (Failed); jed-0.99-19/src/test/test_links.sl0000644002657400265740000000661711311317447015771 0ustar davisdavisprivate variable Failed = 0; private variable Tmp_Root = make_tmp_file ("/tmp/jedtest"); % Creates the following directory layout under Tmp_Root: % /tmp/jedtest/ : % A/ % dev/ % dev/foo % dev/hoo (hard link to foo) % file.c -> dev/foo % B/ % dev2 -> /tmp/jedtest/A/dev private variable Tmp_A = path_concat (Tmp_Root, "A"); private variable Tmp_A_dev = path_concat (Tmp_A, "dev"); private variable Tmp_A_dev_foo = path_concat (Tmp_A_dev, "foo"); private variable Tmp_A_dev_hoo = path_concat (Tmp_A_dev, "hoo"); private variable Tmp_A_filec = path_concat (Tmp_A, "file.c"); private variable Tmp_B = path_concat (Tmp_Root, "B"); private variable Tmp_B_dev2 = path_concat (Tmp_B, "dev2"); private define make_layout () { () = mkdir (Tmp_Root); () = mkdir (Tmp_A); () = mkdir (Tmp_A_dev); () = append_string_to_file (Tmp_A_dev_foo, Tmp_A_dev_foo); () = symlink (Tmp_A_dev_foo, Tmp_A_filec); () = hardlink (Tmp_A_dev_foo, Tmp_A_dev_hoo); () = mkdir (Tmp_B); () = symlink (Tmp_A_dev, Tmp_B_dev2); } private define test_expand_link () { variable a = expand_symlink (Tmp_B_dev2); variable b = Tmp_A_dev; if (a != b) { vmessage ("expand_symlink returned %S, not %S", a, b); Failed++; } a = expand_symlink (Tmp_A_filec); b = Tmp_A_dev_foo; if (a != b) { vmessage ("expand_symlink returned %S, not %S", a, b); Failed++; } } % Tests read/write of /tmp/jedtest/A/file.c which is a % symlink to /tmp/jedtest/A/dev/foo. % Then it tries to read % /tmp/jedtest/B/dev2/../file.c % where /tmp/jedtest/B/dev2 is a symlink to /tmp/jedtest/A/dev private define test_link_read_write_1 () { () = read_file (Tmp_A_filec); bob (); !if (looking_at (Tmp_A_dev_foo)) { message ("Failed to read $Tmp_A_dev_foo via $Tmp_A_filec"$); Failed++; return; } if (buffer_filename () != Tmp_A_filec) { message ("Failed to get proper filename for %s, found %s", Tmp_A_filec, buffer_filename ()); Failed++; } variable name; (,,name,) = getbuf_info (); if (name != path_basename (Tmp_A_filec)) { Failed++; vmessage ("Failed to get proper buffer name for link, found %s", name); } bob (); insert (Tmp_A_dev_foo); save_buffer (); delbuf (whatbuf()); () = read_file (Tmp_A_filec); bob (); !if (looking_at (Tmp_A_dev_foo+Tmp_A_dev_foo)) { Failed++; vmessage ("Failed to write symlink file"); } if (1 != file_status (Tmp_A_dev_foo + "~")) { Failed++; vmessage ("Unable to find backup file %s", Tmp_A_dev_foo); } delbuf (whatbuf ()); % Second part of test variable dev2_file = path_concat (Tmp_B_dev2, "../file.c"); () = read_file (dev2_file); bob(); !if (looking_at (Tmp_A_dev_foo)) { Failed++; vmessage ("failed to read %s via %s", Tmp_A_dev_foo, dev2_file); } } private define test_read_hard_link () { () = read_file (Tmp_A_dev_foo); variable a = whatbuf (); variable afile = buffer_filename (); () = read_file (Tmp_A_dev_hoo); variable b = whatbuf (); variable bfile = buffer_filename (); if ((a != b) or (afile != bfile)) { Failed++; message ("failed to read hardlink $Tmp_A_dev_hoo as $Tmp_A_dev_foo"$); message (" Got buffers $a and $b"$); delbuf (a); delbuf (b); return; } delbuf (a); } make_layout (); test_link_read_write_1 (); test_read_hard_link (); test_expand_link (); exit (Failed); jed-0.99-19/src/test/test_search.sl0000644002657400265740000000216511311317447016110 0ustar davisdavisprivate variable Failed = 0; private define test_rebsearch () { setbuf ("*scratch*"); erase_buffer (); variable n = 20; loop(20) newline (); loop (n) { if (0 == re_bsearch ("^\n")) { ()=fprintf (stderr, "re_bsearch for newlines failed"); Failed++; return; } } !if (bobp ()) { ()=fprintf(stderr,"re_bsearch: expected to be at the bob"); Failed++; return; } } test_rebsearch (); private define test_search_char () { if (0 == _slang_utf8_ok ()) { () = fprintf (stdout, "UTF-8 mode not enabled-- test_search_char not run.\n"); return; } setbuf ("*scratch*"); erase_buffer (); insert ("foo\x{ABCD}bar\n"); bob (); if (1 != ffind_char (0xABCD)) { () = fprintf (stderr, "ffind_char: failed to find a wide-character\n"); Failed++; } eol (); if (1 != bfind_char (0xABCD)) { () = fprintf (stderr, "ffind_char: failed to find a wide-character\n"); Failed++; } if (1 != looking_at_char (0xABCD)) { () = fprintf (stderr, "looking_at_char: failed\n"); Failed++; } } test_search_char (); exit (Failed); jed-0.99-19/src/test/test_narrow.sl0000644002657400265740000000156111311317447016152 0ustar davisdavisprivate variable Failed = 0; public define test_narrow (str, narrow_str) { setbuf ("*scratch*"); c_mode (); erase_buffer (); insert (str); bob (); !if (fsearch (narrow_str)) error ("fsearch failed"); push_mark (); go_right (strlen (narrow_str)); narrow_to_region (); () = parse_to_point (); bob (); push_mark (); eob (); variable b = bufsubstr (); if (b != narrow_str) { Failed++; () = fprintf (stderr, "narrow_to_region produced %s\n", b); } widen_region (); bob (); push_mark (); eob (); b = bufsubstr (); if (b != str) { Failed++; () = fprintf (stderr, "widen_region failed %s\n", b); } } test_narrow ("A single line", "single"); test_narrow ("\nNewline + A single line", "single"); test_narrow ("\nNewline + A single line+newline", "single"); exit (Failed); jed-0.99-19/src/main.c0000644002657400265740000003016611311317447013357 0ustar davisdavis/* -*- mode: C; mode: fold; -*- */ /* Copyright (c) 1992, 1998, 2000, 2002, 2003, 2004, 2005, 2006 John E. Davis * This file is part of JED editor library source. * * You may distribute this file under the terms the GNU General Public * License. See the file COPYING for more information. */ #include "config.h" #include "jed-feat.h" /*{{{ Include Files */ #ifdef __WIN32__ /* This needs to go first before stdio is included. */ # include # if !defined(__CYGWIN32__) # define sleep Sleep # endif #endif #include #include #include "jdmacros.h" #ifdef HAVE_STDLIB_H # include #endif #ifdef REAL_UNIX_SYSTEM # include # include #endif #include #ifdef HAVE_UNISTD_H # include #endif #include #include #ifdef __unix__ # ifdef SYSV # include # include # endif # include #endif #ifdef __MSDOS__ # include # if !defined(__WATCOMC__) # include # ifdef __BORLANDC__ extern unsigned _stklen = 10000U; # endif # else # include # endif #endif #if (defined(__WIN32__) && !defined(__CYGWIN32__)) || defined(__IBMC__) # include # include #endif #if defined(__DECC) && defined(VMS) #include #include #endif #ifndef O_RDWR #ifndef VMS # include #endif #endif #include "file.h" #include "buffer.h" #include "display.h" #include "sysdep.h" #include "sig.h" #include "misc.h" #include "keymap.h" #include "screen.h" #include "ledit.h" #include "search.h" #include "text.h" #include "hooks.h" #include "paste.h" #include "version.h" #include "indent.h" #include "colors.h" #include "jprocess.h" #ifdef __WIN32__ # include "win32.h" #endif /*}}}*/ int Jed_Secure_Mode; int Jed_Load_Quietly = 0; #if JED_HAS_UTF8_SUPPORT int Jed_UTF8_Mode; #endif char Jed_Root_Dir [JED_MAX_PATH_LEN]; typedef struct /*{{{*/ { jmp_buf b; } /*}}}*/ jmp_buf_struct; extern jmp_buf_struct Jump_Buffer, *Jump_Buffer_Ptr; int Batch = 0; #ifdef MSWINDOWS static char *get_win32_root(void) { static char base_path[JED_MAX_PATH_LEN]; char *p; base_path[0] = 0; if (GetModuleFileName(NULL, base_path, JED_MAX_PATH_LEN-10) > 0) { /* drop file name */ p = strrchr(base_path, '\\'); if (p != NULL) { *p = '\0'; /* drop also 'bin' */ p = strrchr(base_path, '\\'); if (p != NULL) *p = '\0'; } } return base_path; } #endif static void set_jed_root (char *pgm) { char *jr, *jl; char jed_lib [JED_MAX_PATH_LEN + 1]; *jed_lib = 0; #ifdef VMS jr = "JED_ROOT:"; #else jr = (char *) getenv("JED_ROOT"); #endif #ifdef JED_ROOT if ((jr == NULL) && (file_status(JED_ROOT) == 2)) { jr = JED_ROOT; } #endif #ifdef MSWINDOWS if (jr == NULL) jr = get_win32_root (); #endif if (jr != NULL) { strcpy (Jed_Root_Dir, jr); strcpy (jed_lib, jr); #ifndef VMS fixup_dir (jed_lib); strcat (jed_lib, "lib"); #else strcat(jed_lib, "[lib]"); #endif } jl = (char *) getenv("JED_LIBRARY"); if (jl == NULL) { if (*jed_lib == 0) { unsigned int len; jl = extract_file (pgm); len = (unsigned int) (jl - pgm); strncpy (jed_lib, pgm, len); jed_lib [len] = 0; } } else strcpy(jed_lib, jl); if (-1 == SLpath_set_load_path (jed_lib)) exit_error ("Out of memory", 0); } void (*X_Init_Global_Structures_Hook)(void); int Stdin_Is_TTY; int _Jed_Startup_Argc; char **_Jed_Startup_Argv; static void script_usage (void) { (void) fputs ("\ Usage: Running jed in script mode requires one of the following forms:\n\ jed-script SCRIPT_FILE [args...]\n\ jed --script SCRIPT_FILE [args...]\n\ \n\ If the script contains a public function called `jedscript_main`, then it\n\ will be called after the script has been loaded. The value of __argv[0] will\n\ be the name of the script, and __argv[[1:]] will be set to the script\n\ arguments.\n\ ", stderr); } static int main_initialize (int argc, char **argv) { char *cmd_hook = ".()command_line_hook"; int i, fd; char *script_file; int read_stdin_to_buffer = 0; _Jed_Startup_Argv = argv; _Jed_Startup_Argc = argc; #ifdef __EMX__ _response(&argc, &argv); _wildcard(&argc, &argv); #endif #ifdef WINDOWS if (NULL == getenv ("JED_ROOT")) { MessageBox(NULL, "RTFM: You must set the JED_ROOT environment variable.\nAborting\n", "Jed", MB_ICONEXCLAMATION | MB_TASKMODAL | MB_SETFOREGROUND | MB_OK); exit(1); } #endif #if JED_HAS_DISPLAY_TABLE for (i = 0; i < 256; i++) Output_Display_Table[i] = i; #endif if ((argc > 1) && ((0 == strcmp (argv[1], "-secure")) || (0 == strcmp (argv[1], "--secure")))) { Jed_Secure_Mode = 1; argc--; argv[1] = argv[0]; argv++; } /* If this hook is defined, let it peel off what ever arguments it wants. It should return the number of remaining arguments */ if (X_Argc_Argv_Hook != NULL) { i = (*X_Argc_Argv_Hook)(argc, argv) - 1; argv[i] = argv[0]; argc -= i; argv += i; } /* If jed-script is a symbolic link to jed, then treat this as equivalent * to jed -script args... */ script_file = NULL; if (0 == strcmp (extract_file (argv[0]), "jed-script")) { Batch = 2; SLang_Traceback = 1; Jed_Load_Quietly = 1; if (argc > 1) script_file = argv[1]; else { script_usage (); return -1; } argv++; /* make argv[0] the name of the script */ argc--; } else if (argc > 1) { char *argv1 = argv[1]; /* Allow, e.g., --batch */ if ((argv1[0] == '-') && (argv1[1] == '-')) argv1++; if (!strcmp(argv1, "-batch")) { Batch = 1; SLang_Traceback = 1; } else if (!strcmp(argv1, "-script")) { Batch = 2; SLang_Traceback = 1; Jed_Load_Quietly = 1; if (argc > 2) { script_file = argv[2]; argv += 2; /* make argv[0] the name of the script */ argc -= 2; } } else if (!strcmp (argv1, "-help")) { Batch = 1; SLang_Traceback = 1; Jed_Load_Quietly = 1; } } #if JED_HAS_UTF8_SUPPORT Jed_UTF8_Mode = SLutf8_enable (-1); if (Jed_UTF8_Mode == 0) { char *u = getenv ("JED_UTF8"); if (u != NULL) { if ((0 == strcmp (u, "1")) || (0 == strcmp (u, "FORCE"))) { Jed_UTF8_Mode = 1; /* force jed to use UTF-8 internally */ SLsmg_utf8_enable (1); SLinterp_utf8_enable (1); } if (0 == strcmp (u, "FORCE")) SLtt_utf8_enable (1); } } #endif #if JED_HAS_UTF8_SUPPORT if (Jed_UTF8_Mode) define_word ("\\w"); else { #endif #ifdef __MSDOS__ define_word("0-9a-zA-Z\200-\232\240-\245\341-\353"); #else define_word("0-9a-zA-Z\300-\326\330-\366\370-\377"); #endif #if JED_HAS_UTF8_SUPPORT } #endif (*tt_get_terminfo) (); fd = 2; /* 2 is stderr, assume it is ok */ #if defined(REAL_UNIX_SYSTEM) && !defined(__APPLE__) if (Batch == 0) { int dev_tty_fd; if ((dev_tty_fd = open("/dev/tty", O_RDWR)) >= 0) { fd = dev_tty_fd; while (-1 == dup2(fd, 2)) /* tty uses 2 as the descriptor */ { # ifdef EINTR if (errno == EINTR) continue; # endif fd = 2; break; } close (dev_tty_fd); } } #endif /* REAL_UNIX_SYSTEM */ #if defined(__WIN32__) if (-1 == jed_init_w32_support ()) return -1; #endif if (Stdin_Is_TTY == 0) Stdin_Is_TTY = isatty (0); if ((Stdin_Is_TTY == 0) && (Batch != 2)) { read_stdin_to_buffer = 1; #ifdef REAL_UNIX_SYSTEM /* Since stdin is not a terminal, jed is being used in a pipe such * as `ls | jed`. A problem occurs when when `ls` exits and * the user suspends `jed`. To deal with signals such as * SIGINT generated at the controlling terminal, jed puts * itself into its own process group. This way pressing ^G * will cause SIGINT to get sent only to jed and not a * program that spawned it (e.g., `git`). However, to play * nicely with the shell's job control, jed puts itself back * into the original process group prior to suspending. * However, that group will disappear if the other processes * in the pipe have exited. The only way I know how to deal * with this is to fork another process. * * Better ideas are welcome. */ (void) jed_fork_monitor (); #endif } if (-1 == init_tty ()) exit_error ("Unable to initialize tty.", 0); jed_init_display (); /* sets up virtual screen */ (*tt_set_mono) (JMESSAGE_COLOR, NULL, 0); (*tt_set_mono) (JERROR_COLOR, NULL, SLTT_BOLD_MASK); (*tt_set_mono) (JDOLLAR_COLOR, NULL, SLTT_BOLD_MASK); (*tt_set_mono) (JDOTS_COLOR, NULL, SLTT_BOLD_MASK); (*tt_set_mono) (JMENU_CHAR_COLOR, NULL, SLTT_BOLD_MASK); (*tt_set_mono) (JMENU_SELECTION_COLOR, NULL, SLTT_REV_MASK|SLTT_BOLD_MASK); (*tt_set_mono) (JMENU_POPUP_COLOR, NULL, 0); (*tt_set_mono) (JMENU_SELECTED_CHAR_COLOR, NULL, SLTT_BOLD_MASK); (void) jed_set_color (JMENU_SHADOW_COLOR, "blue", "black"); (void) jed_set_color (JMENU_POPUP_COLOR, "lightgray", "blue"); (*tt_set_mono) (JMENU_SHADOW_COLOR, NULL, 0); (void) jed_set_color (JMENU_SHADOW_COLOR, "blue", "black"); init_syntax_tables (); /* This order here is crucial! */ init_keymaps(); if (NULL == (CBuf = make_buffer(NULL, NULL, NULL))) { exit_error("main: Allocation Failure", 0); } CLine = NULL; init_minibuffer(); set_file_modes(); /* what if someone pipes something to jed, allow it unless if is a * jed script. */ if (read_stdin_to_buffer) /* 1 if stdin is a terminal, 0 otherwise */ { set_buffer("*stdin*"); read_file_pointer(fileno(stdin)); bob(); fclose(stdin); dup2(fd, 0); } if (CLine == NULL) make_line(25); bol (); window_buffer(CBuf); #if !defined(IBMPC_SYSTEM) && !defined(VMS) init_signals(); #endif (void) SLang_set_argc_argv (argc, argv); if ((0 != jed_ns_load_file("site", NULL)) && Batch) return -1; if (Batch) Ignore_User_Abort = 0; if (Batch == 2) { if (script_file == NULL) { script_usage (); return -1; } #if SLANG_VERSION >= 20000 { char *file = SLpath_find_file_in_path (".", script_file); if (file == NULL) { fprintf (stderr, "%s not found.\n", script_file); return -1; } if (0 != SLns_load_file (file, NULL)) { SLfree (file); return -1; } SLfree (file); } #else if (0 != jed_ns_load_file (script_file, NULL)) return -1; #endif if (-1 == SLang_run_hooks ("jedscript_main", 0)) return -1; } else { if (SLang_is_defined(cmd_hook + 3)) { SLang_run_hooks(cmd_hook + 3, 0); if (SLang_get_error () && Batch) return -1; /* This has the effect of removing the memory that cmd_hook * is using. */ SLang_load_string (cmd_hook); } else if (!SLang_get_error () && (argc > 2)) { find_file_in_window(argv[2]); } } if (SLang_get_error () && Batch) return -1; /* after we have possible loaded key definitions, we can fix up * the minibuffer map. This way user definitions are used. */ jed_setup_minibuffer_keymap (); return 0; } int main(int argc, char **argv) /*{{{*/ { int err; if (SLang_Version < SLANG_VERSION) { fprintf (stderr, "***Warning: Executable compiled against S-Lang %d but linked to %d\n", SLANG_VERSION, SLang_Version); fflush (stderr); sleep (2); } set_jed_root (argv[0]); if (argc > 1) { if (!strcmp (argv[1], "--version")) { jed_show_version (stdout); fprintf (stdout, "\nUsing JED_ROOT=%s\n", Jed_Root_Dir); exit (0); } } Jump_Buffer_Ptr = &Jump_Buffer; /* incase something goes wrong before we even get started... */ if (setjmp(Jump_Buffer_Ptr->b) != 0) { /* hmm.... just exit I guess */ exit_error("main: Fatal Error", 0); exit (1); } if ((0 == main_initialize (argc, argv)) && (Batch == 0)) jed (); /* edit_loop -- never returns */ jed_reset_display(); reset_tty(); if (0 != (err = SLang_get_error ())) SLang_restart (1); return err; } /*}}}*/ jed-0.99-19/src/display.h0000644002657400265740000000262611311317447014105 0ustar davisdavis/* Copyright (c) 1992, 1998, 2000, 2005, 2006 John E. Davis * This file is part of JED editor library source. * * You may distribute this file under the terms the GNU General Public * License. See the file COPYING for more information. */ #if SLANG_VERSION < 20000 # define JX_SETXXX_RETURN_TYPE void # define JX_SETXXX_RETURN_VAL #else # define JX_SETXXX_RETURN_TYPE int # define JX_SETXXX_RETURN_VAL 0 #endif /* This is the main hook that must be set at compile-time. */ extern void (*tt_get_terminfo)(void); /* These hooks should be set during run-time by the tt_get_terminfo hook */ extern void (*tt_beep)(void); extern void (*tt_write_string)(SLFUTURE_CONST char *); extern void (*tt_get_screen_size)(int *, int *); extern JX_SETXXX_RETURN_TYPE (*tt_set_color)(int, SLFUTURE_CONST char *, SLFUTURE_CONST char *, SLFUTURE_CONST char *); extern JX_SETXXX_RETURN_TYPE (*tt_set_mono) (int, SLFUTURE_CONST char *, SLtt_Char_Type); #ifndef IBMPC_SYSTEM extern void (*tt_wide_width)(void); extern void (*tt_narrow_width)(void); extern void (*tt_enable_cursor_keys)(void); extern void (*tt_set_term_vtxxx)(int *); # if SLANG_VERSION < 20000 extern void (*tt_set_color_esc)(int, char *); # endif #endif extern int *tt_Ignore_Beep; extern int *tt_Use_Ansi_Colors; extern int *tt_Term_Cannot_Scroll; extern int *tt_Term_Cannot_Insert; #ifndef IBMPC_SYSTEM extern int *tt_Blink_Mode; #endif extern void flush_output (void); jed-0.99-19/src/gpmmouse.c0000644002657400265740000001350411311317447014264 0ustar davisdavis/* This is the interface to the GPM mouse under Linux */ /* Copyright (c) 1992, 1998, 2000, 2002, 2003, 2004, 2005, 2006, 2008 John E. Davis * This file is part of JED editor library source. * * You may distribute this file under the terms the GNU General Public * License. See the file COPYING for more information. */ #include "config.h" #include "jed-feat.h" #include #include #include #include #include "jdmacros.h" #include "buffer.h" #include "sysdep.h" #include "keymap.h" #include "misc.h" #include "paste.h" #include "screen.h" #include "ledit.h" #include "ins.h" #include "display.h" #include "hooks.h" #define MOD_SHIFT 1 #define MOD_CTRL 4 static int Mouse_Showing; static int MouseX, MouseY; static int Suspend_Mouse_Events; #if 0 /* This is needed to get the link to work with gpm. */ int wgetch (void) { return 0; } int *stdscr; #endif static void draw_mouse (void) { Gpm_Event event; if (MouseX < 1) MouseX = 1; else if (MouseX >= Jed_Num_Screen_Cols) MouseX = Jed_Num_Screen_Cols; if (MouseY < 1) MouseY = 1; else if (MouseY >= Jed_Num_Screen_Rows) MouseY = Jed_Num_Screen_Rows; event.x = MouseX; event.y = MouseY; GPM_DRAWPOINTER(&event); Mouse_Showing = 1; } static int mouse_handler_2 (void) { int b = 0, nbuttons; Gpm_Event event; unsigned char buf[3]; JMouse_Type jm; if (Gpm_GetEvent (&event) <= 0) return -1; if (Suspend_Mouse_Events) { if (Suspend_Mouse_Events == -1) Suspend_Mouse_Events = 0; return -1; } MouseX += event.dx; MouseY += event.dy; draw_mouse (); if (event.type & GPM_MOVE) return 0; nbuttons = 0; if (event.buttons & GPM_B_LEFT) { b = JMOUSE_BUTTON_1; nbuttons++; } if (event.buttons & GPM_B_MIDDLE) { b = JMOUSE_BUTTON_2; nbuttons++; } if (event.buttons & GPM_B_RIGHT) { b = JMOUSE_BUTTON_3; nbuttons++; } if (nbuttons != 1) return 0; jm.button = b; if ((event.type & GPM_DOUBLE) && (event.type & GPM_DOWN)) jm.type = JMOUSE_DOUBLE_CLICK; else if ((event.type & GPM_TRIPLE) && (event.type & GPM_DOWN)) jm.type = JMOUSE_TRIPLE_CLICK; else if (event.type & GPM_DRAG) jm.type = JMOUSE_DRAG; else if (event.type & GPM_DOWN) jm.type = JMOUSE_DOWN; else if (event.type & GPM_UP) jm.type = JMOUSE_UP; else return 0; if (event.modifiers & MOD_SHIFT) { jm.state = JMOUSE_SHIFT; } else if (event.modifiers & MOD_CTRL) { jm.state = JMOUSE_CTRL; } else jm.state = 0; jm.x = MouseX; jm.y = MouseY; b = jed_mouse_add_event (&jm); if (b == -1) return 0; buf[0] = 27; buf[1] = 0; buf[2] = (char) b; ungetkey_string ((char *)buf, 3); return 1; } static int Warp_Pending; static void close_update (void) { if (Warp_Pending || Mouse_Showing) { if (Warp_Pending) { MouseX = Screen_Col; MouseY = Screen_Row; } draw_mouse (); Warp_Pending = 0; } else Mouse_Showing = 0; } static void warp_pointer (void) { Warp_Pending = 1; } static char *CutBuffer; static int CutBuffer_Len; static int insert_cutbuffer (void) { CHECK_READ_ONLY if (CutBuffer == NULL) return 0; if (CutBuffer_Len) jed_insert_nbytes ((unsigned char *) CutBuffer, CutBuffer_Len); return CutBuffer_Len; } static void region_to_cutbuffer (void) { int nbytes; if (CutBuffer != NULL) { SLfree (CutBuffer); } CutBuffer = make_buffer_substring(&nbytes); CutBuffer_Len = nbytes; } static void close_mouse (void) { JMouse_Hide_Mouse_Hook = NULL; X_Update_Close_Hook = NULL; if (JMouse_Event_Hook == NULL) return; JMouse_Event_Hook = NULL; Gpm_Close (); } static void disable_mouse (void) { reset_tty (); /* closes mouse */ X_Open_Mouse_Hook = NULL; X_Close_Mouse_Hook = NULL; init_tty (); } static SLang_Intrin_Fun_Type gpm_mouse_table[] = { MAKE_INTRINSIC("x_warp_pointer", warp_pointer, VOID_TYPE, 0), MAKE_INTRINSIC("x_insert_cutbuffer", insert_cutbuffer, INT_TYPE, 0), /* Prototype: Integer x_insert_cut_buffer (); * Inserts cutbuffer into the current buffer and returns the number * of characters inserted. */ MAKE_INTRINSIC("x_copy_region_to_cutbuffer", region_to_cutbuffer, VOID_TYPE, 0), /* Prototype: Void x_copy_region_to_cutbuffer(); */ MAKE_INTRINSIC("gpm_disable_mouse", disable_mouse, VOID_TYPE, 0), SLANG_END_INTRIN_FUN_TABLE }; static void hide_mouse (int show) { Mouse_Showing = show; } static int open_mouse (void) { static int not_first_time; Gpm_Connect conn; char *term; SLSig_Fun_Type *sigtstp_fun; int status; /* Unbelievable. If we are running in an Xterm, gpm will turn on mouse * reporting. Nice huh? NOT!!! */ term = getenv ("TERM"); if ((term != NULL) && (!strncmp (term, "xterm", 5) || !strncmp (term, "rxvt", 4))) return -1; /* Another libgpm annoyance. gpm installs a signal handler for SIGTSTP. * I am going to un-install it. */ sigtstp_fun = SLsignal (SIGTSTP, (SLSig_Fun_Type *)SIG_DFL); conn.eventMask = ~0; conn.defaultMask = 0; conn.maxMod = MOD_CTRL | MOD_SHIFT; conn.minMod = 0; Mouse_Showing = 0; Suspend_Mouse_Events = -1; MouseX = Jed_Num_Screen_Cols / 2; MouseY = Jed_Num_Screen_Rows / 2; status = Gpm_Open (&conn, 0); /* Uninstall the gpm signal handler */ (void) SLsignal (SIGTSTP, sigtstp_fun); if (status == -1) return -1; if (not_first_time == 0) { if (-1 == SLadd_intrin_fun_table (gpm_mouse_table, "MOUSE")) return -1; not_first_time = 1; } JMouse_Event_Hook = mouse_handler_2; X_Update_Close_Hook = close_update; JMouse_Hide_Mouse_Hook = hide_mouse; return gpm_fd; } int (*X_Open_Mouse_Hook)(void) = open_mouse; void (*X_Close_Mouse_Hook)(void) = close_mouse; jed-0.99-19/src/pcscan.c0000644002657400265740000001222011311317447013671 0ustar davisdavis/* This file is included by ibmpc.c, i386.c, and os2.c. It provides a * mapping from the scan code/shift state to an escape sequence. */ /* Copyright (c) 1992, 1998, 2000, 2002, 2003, 2004, 2005, 2006 John E. Davis * This file is part of JED editor library source. * * You may distribute this file under the terms the GNU General Public * License. See the file COPYING for more information. */ #define RSHIFT_MASK 0x1 #define LSHIFT_MASK 0x2 #define CTRL_KEY_MASK 0x4 #define ALT_KEY_MASK 0x8 #define SHIFT_MASK (RSHIFT_MASK|LSHIFT_MASK) static unsigned char F_Keys[4][12] = { { 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 133, 134 }, { 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 135, 136 }, { 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 137, 138 }, { 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 139, 140 } }; static unsigned char Small_Keypad_Keys[4][13] = { { 'G', 'H', 'I', 0, 'K', 0, 'M', 0, 'O', 'P', 'Q', 'R', 'S' }, /* normal */ { '0', '1', '2', 0, '3', 0, '4', 0, '5', '6', '7', '8', '9' }, /* shift */ { 'w', 141, 132, 0, 's', 0, 't', 0, 'u', 145, 'v', 146, 147 }, /* ctrl */ { 151, 152, 153, 0, 155, 0, 157, 0, 159, 160, 161, 162, 163 } /* alt */ }; static unsigned char Num_Keypad_Keys[4][13] = { { 'w', 'x', 'y', 0, 't', 'u', 'v', 0, 'q', 'r', 's', 'p', 'n' }, { '0', '1', '2', 0, '3', 0 , '4', 0, '5', '6', '7', '8', '9' }, { 'w', 141, 132, 0, 's', 143, 't', 0, 'u', 145, 'v', 146, 147 }, { 'w', 'x', 'y', 0, 't', 'u', 'v', 0, 'q', 'r', 's', 'p', 'n' } }; static char *Alt_Map = "!@#$%^&*()-=\t*\0177QWERTYUIOP[]\r*ASDFGHJKL;'`*\\ZXCVBNM<>/"; static unsigned int default_scan_to_key (unsigned int scan, unsigned int shift, unsigned char *chp) { unsigned char ch; ch = (scan & 0xFF); chp[0] = ch; if ((ch != 0) && (ch != 0xE0)) return 1; ch = (scan >> 8); if ((PC_Alt_Char == 0) || (shift != ALT_KEY_MASK)) { chp[1] = ch; return 2; } if ((ch >= 14) && (ch <= 53)) ch = (unsigned char) Alt_Map[ch]; else if ((ch >= 120) && (ch <= 131)) ch = (unsigned char) Alt_Map[ch - 120]; else if (ch == 165) /* tab */ ch = (unsigned char) Alt_Map[12]; chp[0] = PC_Alt_Char; chp[1] = ch; return 2; } static unsigned int jed_scan_to_key (unsigned int scan, unsigned int shift, unsigned char *chbuf) { unsigned int i; unsigned int state; int c1; switch (scan) { case 0x0E08: /* backspace */ *chbuf = 127; return 1; case 0xE02F: /* KEYPAD SLASH */ c1 = 'Q'; break; case 0x372A: /* KEYPAD STAR */ c1 = 'R'; break; case 0x4A2D: /* KEYPAD MINUS */ c1 = 'S'; break; case 0x4E2B: /* KEYPAD PLUS */ c1 = 'm'; break; case 0xE00D: /* KEYPAD ENTER */ c1 = 'M'; break; case 0x4700: /* KEYPAD HOME */ case 0x4800: /* KEYPAD UP */ case 0x4900: /* KEYPAD PGUP */ case 0x4B00: /* KEYPAD LEFT */ case 0x4C00: /* KEYPAD 5 */ case 0x4D00: /* KEYPAD RIGHT */ case 0x4F00: /* KEYPAD END */ case 0x5000: /* KEYPAD DOWN */ case 0x5100: /* KEYPAD PGDN */ case 0x5300: /* KEYPAD DEL */ case 0x5200: /* KEYPAD INSERT */ state = 0; if (shift & SHIFT_MASK) state = 1; if (shift & CTRL_KEY_MASK) state = 2; if (shift & ALT_KEY_MASK) state = 3; i = (scan >> 8); c1 = Num_Keypad_Keys[state][i - 0x47]; if (shift & (CTRL_KEY_MASK | ALT_KEY_MASK)) { chbuf[0] = 0; chbuf[1] = c1; return 2; } break; case 0x47E0: /* home */ case 0x48E0: /* UP */ case 0x49E0: /* PGUP */ case 0x4BE0: /* LEFT */ case 0x4DE0: /* RIGHT */ case 0x4FE0: /* END */ case 0x50E0: /* DOWN */ case 0x51E0: /* PGDN */ case 0x53E0: /* DEL */ case 0x52E0: /* INSERT */ chbuf[0] = 0xE0; state = 0; i = (scan >> 8) - 0x47; if (shift & SHIFT_MASK) state = 1; if (shift & CTRL_KEY_MASK) state = 2; if (shift & ALT_KEY_MASK) { chbuf[0] = 0; state = 3; } chbuf[1] = Small_Keypad_Keys[state][i]; return 2; case 0x8500: /* F11 */ case 0x8600: /* F12 */ scan = 0x4500 + (scan - 0x8500); /* Drop */ case 0x3b00: /* F1 */ case 0x3c00: case 0x3d00: case 0x3e00: case 0x3f00: case 0x4000: case 0x4100: case 0x4200: case 0x4300: case 0x4400: /* F10 */ i = scan >> 8; i = i - 0x3b; state = 0; if (shift & SHIFT_MASK) state = 1; if (shift & CTRL_KEY_MASK) state = 2; if (shift & ALT_KEY_MASK) state = 3; chbuf[0] = 0; chbuf[1] = F_Keys[state][i]; return 2; case 0x1C0A: /* Ctrl-RETURN */ return default_scan_to_key (0x1C0D, shift, chbuf); case 0x3920: /* space */ if (shift & CTRL_KEY_MASK) scan = 0x0300; /* drop */ default: return default_scan_to_key (scan, shift, chbuf); } chbuf[0] = 27; chbuf[1] = 'O'; chbuf[2] = c1; return 3; } jed-0.99-19/src/ledit.c0000644002657400265740000013163411311317447013536 0ustar davisdavis/* -*- mode: C; mode: fold; -*- */ /* Copyright (c) 1992, 1998, 2000, 2002, 2003, 2004, 2005, 2006 John E. Davis * This file is part of JED editor library source. * * You may distribute this file under the terms the GNU General Public * License. See the file COPYING for more information. */ #include "config.h" #include "jed-feat.h" /*{{{ Include Files */ #ifdef MSWINDOWS # ifndef __WIN32__ # include # else # include # endif #endif #include #ifdef HAVE_SYS_WAIT_H # include # include #endif #ifndef WEXITSTATUS # define WEXITSTATUS(stat_val) ((unsigned)(stat_val) >> 8) #endif #ifndef WIFEXITED # define WIFEXITED(stat_val) (((stat_val) & 255) == 0) #endif #include #include "jdmacros.h" #include #ifdef IBMPC_SYSTEM # include #endif #include #include "buffer.h" #include "keymap.h" #include "file.h" #include "ins.h" #include "ledit.h" #include "screen.h" #include "window.h" #include "display.h" #include "search.h" #include "misc.h" #include "replace.h" #include "paste.h" #include "sysdep.h" #include "cmds.h" #include "text.h" #include "hooks.h" #include "undo.h" #include "menu.h" #include "userinfo.h" #include "indent.h" #ifdef __WIN32__ # include "win32.h" #endif #define JED_PROMPT "S-Lang>" #if JED_HAS_SUBPROCESSES # include "jprocess.h" #endif /*}}}*/ Buffer *MiniBuffer; Buffer *The_MiniBuffer; /* this never gets deleted since we may need it */ static Buffer *Last_Buffer; /* extern char *get_cwd(void); */ int Ignore_Beep = 0; int MiniBuffer_Active = 0; /* Do not change this value without changing file_findfirst/next. */ #define JED_MAX_COMPLETION_LEN JED_MAX_PATH_LEN static int (*complete_open)(char *); static int (*complete_next)(char *); static int Buf_List_Len; Buffer *Buf_Context; static char *Expect_File_Error = "Expecting filename."; static int next_bufflist(char *buf) /*{{{*/ { Buffer *tthis; while (1) { tthis = Buf_Context; if (tthis == MiniBuffer) return(0); Buf_Context = Buf_Context->next; if ((Buf_List_Len == 0) #if JED_FILE_PRESERVE_CASE || (0 == strncmp (buf, tthis->name, Buf_List_Len)) #else || (0 == jed_case_strncmp (buf, tthis->name, Buf_List_Len)) #endif ) { if (*tthis->name == ' ') continue; /* internal buffers */ safe_strcpy (buf, tthis->name, JED_MAX_COMPLETION_LEN); return 1; } } } /*}}}*/ static int open_bufflist(char *buf) /*{{{*/ { if ((Buf_Context = MiniBuffer) == NULL) return(0); Buf_Context = Buf_Context->next; Buf_List_Len = strlen(buf); return next_bufflist(buf); } /*}}}*/ char *what_buffer() /*{{{*/ { return (CBuf->name); } /*}}}*/ int bufferp(char *name) /*{{{*/ { if (NULL == find_buffer(name)) return(0); else return(1); } /*}}}*/ int insert_buffer_name(char *name) /*{{{*/ { Buffer *buf; if (NULL != (buf = find_buffer(name))) { insert_buffer(buf); return(1); } else msg_error("Unable to find buffer."); return(0); } /*}}}*/ static Buffer *find_scratch_buffer (void) /*{{{*/ { char *sname = "*scratch*"; Buffer *scratch; scratch = find_buffer (sname); if (NULL == scratch) scratch = make_buffer (sname, CBuf->dir, NULL); return scratch; } /*}}}*/ /* Try to find any other buffer but kill_buf such that the buffer is not * visible, not scratch and not buried. */ static Buffer *find_non_visible_buffer (Buffer *kill_buf) /*{{{*/ { Buffer *buf, *scratch; buf = kill_buf->next; scratch = find_scratch_buffer (); while ((buf != kill_buf) && ((*buf->name == ' ') || (buf->flags & BURIED_BUFFER) || (buf == scratch) || (buffer_visible(buf)))) { buf = buf->next; } if ((buf == kill_buf) || (buf->flags & BURIED_BUFFER)) buf = scratch; return buf; } /*}}}*/ int kill_buffer_cmd(char *name) /*{{{*/ { Buffer *this_buf, *kill_buf, *scratch, *buf; Window_Type *w; int do_kill; if (NULL == (kill_buf = find_buffer(name))) { msg_error("Buffer does not exist."); return(0); } /* Do not allow the minibuffer to be deleted. Otherwise, the whole * minibuffer creation/selection needs to be cleaned up. */ if (kill_buf == The_MiniBuffer) return 0; this_buf = CBuf; switch_to_buffer(kill_buf); #if JED_HAS_SUBPROCESSES if (kill_buf->locked) { erase_buffer (); switch_to_buffer (this_buf); return 0; } #endif do_kill = 1; if ((*name != ' ') && (kill_buf->flags & BUFFER_MODIFIED)) { jed_vmessage (1, "Buffer %s modified. (K)ill, (S)ave first, (A)bort:", name); /* This does not go through keyboard macro routines * on purpose! */ switch (my_getkey()) { case 'k': case 'K': do_kill = 1; break; case 's': case 'S': do_kill = 2; break; default: msg_error("Aborted."); return(0); } clear_message (); } if (do_kill == 2) { jed_save_buffer_as_cmd (); if (SLang_get_error ()) { switch_to_buffer(this_buf); return(0); } } /* if it is the scratch buffer, just erase it since we are going to recreate it anyway. */ scratch = find_scratch_buffer (); if (kill_buf == scratch) { erase_buffer(); #if JED_HAS_SUBPROCESSES if (kill_buf->subprocess) jed_kill_process (kill_buf->subprocess - 1); kill_buf->subprocess = 0; #endif switch_to_buffer(this_buf); return 1; } buf = find_non_visible_buffer (kill_buf); /* search through windows looking for the buffer and replace it */ w = JWindow; do { if (kill_buf == JWindow->buffer) { touch_window_hard (JWindow, 0); window_buffer(buf); buf = find_non_visible_buffer (kill_buf); } JWindow = JWindow->next; } while (w != JWindow); if (kill_buf == Last_Buffer) Last_Buffer = NULL; if (kill_buf == this_buf) this_buf = buf; switch_to_buffer(this_buf); delete_buffer(kill_buf); return 1; } /*}}}*/ int jed_save_buffer_to_file (char *dir, char *file) { int status, state; char *dirfile, *canonical_file; if ((file == NULL) || (*file == 0)) { file = CBuf->file; if (*file == 0) { msg_error ("Filename Required."); return -1; } } if (NULL == (dirfile = jed_dir_file_merge (dir, file))) return -1; state = 0; canonical_file = jed_get_canonical_pathname (dirfile); if (canonical_file == NULL) { SLfree (dirfile); return -1; } if (file_changed_on_disk (CBuf, dirfile) > 0) state |= BUFFER_MODIFIED; if (jed_file_is_readonly (canonical_file, 0)) state |= READ_ONLY; if (0 != strcmp (canonical_file, CBuf->dirfile)) state |= OVERWRITE_MODE; if (state) { char *prompt = NULL; switch (state) { default: case OVERWRITE_MODE: prompt = NULL; break; case BUFFER_MODIFIED: prompt = "File changed on disk. Save anyway?"; break; case READ_ONLY: prompt = "No permission to write to file. Try to save anyway?"; break; case BUFFER_MODIFIED|READ_ONLY: prompt = "File changed on disk and no permission to write. Save anyway?"; break; case BUFFER_MODIFIED|OVERWRITE_MODE: prompt = "File exists and changed on disk. Overwrite?"; break; case READ_ONLY|OVERWRITE_MODE: prompt = "File exists and no permission to write. Try to overwrite anyway?"; break; case READ_ONLY|OVERWRITE_MODE|BUFFER_MODIFIED: prompt = "File changed on disk and no permission to write. Overwrite anyway?"; break; } if ((prompt != NULL) && (1 != jed_get_yes_no(prompt))) { SLfree (canonical_file); SLfree (dirfile); return -1; } } SLfree (canonical_file); if (-1 == jed_va_run_hooks ("_jed_save_buffer_before_hooks", JED_HOOKS_RUN_ALL, 1, dirfile)) { auto_save_buffer (CBuf); SLfree (dirfile); return -1; } if (((status = write_file_with_backup (dirfile)) >= 0) && (Batch != 2)) jed_vmessage (0, "Wrote %d lines to %s", status, dirfile); if (status < 0) { jed_verror ("Error writing file %s", dirfile); SLfree (dirfile); return -1; } CBuf->flags |= AUTO_SAVE_BUFFER; CBuf->hits = 0; #ifdef UNDO_HAS_REDO update_undo_unchanged (); #endif visit_file (dir, file); if (-1 == jed_va_run_hooks ("_jed_save_buffer_after_hooks", JED_HOOKS_RUN_ALL, 1, dirfile)) { SLfree (dirfile); return -1; } SLfree (dirfile); return 0; } int jed_save_buffer_as (char *filestr) { char *dir, *file; int status; filestr = jed_standardize_filename (filestr); if (-1 == jed_dirfile_to_dir_file (filestr, &dir, &file)) { SLfree (filestr); return -1; } status = jed_save_buffer_to_file (dir, file); SLfree (filestr); SLfree (dir); SLfree (file); if (status == -1) return status; /* This function is an intrinsic and is documented to return the * number of lines written out. * */ return 0; } int jed_save_buffer_cmd (void) { if ((CBuf->file == NULL) || (CBuf->file[0] == 0)) return jed_save_buffer_as_cmd (); return jed_save_buffer_to_file (CBuf->dir, CBuf->file); } #if defined(__BORLANDC__) && !defined(MSWINDOWS) int show_memory() /*{{{*/ { struct farheapinfo hi; char *c; unsigned long total = 0, core, used = 0; unsigned long max = 0; int i = 0; hi.ptr = NULL; if (farheapcheck() == _HEAPCORRUPT) c = "corrupt"; else c = "ok"; while (farheapwalk(&hi) == _HEAPOK) { if (hi.in_use) used += hi.size; else { total += hi.size; if (hi.size > max) max = hi.size; i++; } } core = farcoreleft(); jed_vmessage (0, "used:%lu, core:%lu, free:%lu, grand:%lu, max:%lu, frag:%d (%s)", used, core, total, core + total, max, i, c); return 0; } /*}}}*/ #endif #ifdef MSWINDOWS int show_memory (void) /*{{{*/ { #ifndef __WIN32__ MEMMANINFO mmi; if (MemManInfo(&mmi)) { jed_vmessage (0, "tot pages: %lu, free pages: %lu", mmi.dwTotalLinearSpace, mmi.dwFreeLinearSpace); } #else MEMORYSTATUS mst; GlobalMemoryStatus(&mst); jed_vmessage (0, "avail space: %lu, tot phys space: %lu, avail phys space: %lu", mst.dwAvailPhys + mst.dwAvailPageFile, mst.dwTotalPhys, mst.dwAvailPhys); #endif return 0; } /*}}}*/ #endif #ifdef __WATCOMC__ #include int show_memory() /*{{{*/ { jed_vmessage (0, "avail mem: %lu, tot phys pgs: ???, free lin space: %lu", _memavl (), _memmax ()); return 0; } /*}}}*/ #endif #ifdef __GO32__ #include int show_memory() /*{{{*/ { unsigned long mem; _go32_dpmi_meminfo info; _go32_dpmi_get_free_memory_information(&info); if ((long)info.available_physical_pages != -1L) mem = info.available_physical_pages * 4096UL; else mem = info.available_memory; jed_vmessage (0, "avail mem: %lu, tot phys pgs: %lu, free lin space: %lu", mem, info.total_physical_pages, info.free_linear_space); return 0; } /*}}}*/ #endif int set_buffer(char *name) /*{{{*/ { Buffer *buf; if ((name == NULL) || (*name == 0)) { msg_error("set_buffer: Buffer name is NULL"); return (0); } /* Last_Buffer = CBuf; */ if (NULL == (buf = find_buffer(name))) buf = make_buffer (name, CBuf->dir, NULL); switch_to_buffer(buf); return 1; } /*}}}*/ int jed_get_mini_response (char *s) { int ch; int len; if (Batch) { if (EOF == fputs (s, stdout)) exit_error ("Failed to write to stdout", 0); return jed_getkey (); } len = strlen (s); if (len > Jed_Num_Screen_Cols) s += (len - Jed_Num_Screen_Cols); MiniBuf_Get_Response_String = s; update (NULL, 0, 0, 0); ch = jed_getkey (); MiniBuf_Get_Response_String = NULL; return ch; } static char *strcat_malloc (char *a, char *b) { unsigned int len; char *c; len = strlen (a); if (NULL == (c = SLmalloc (len + strlen (b) + 1))) return NULL; strcpy (c, a); strcpy (c + len, b); return c; } int jed_get_y_n (char *question) { int ans; char *yn_quest; if (NULL == (yn_quest = strcat_malloc (question, "? (y/n)"))) return -1; ans = jed_get_mini_response (yn_quest); SLfree (yn_quest); if ((ans == 'y') || (ans == 'Y')) return 1; if ((ans == 'n') || (ans == 'N')) return 0; if (SLKeyBoard_Quit || (SLang_get_error () == SL_USER_BREAK)) return -1; jed_beep (); flush_input (); return jed_get_yes_no (question); } int jed_vget_y_n (char *fmt, char *arg) { char msg [1024]; if (arg == NULL) { arg = fmt; fmt = "%s"; } SLsnprintf (msg, sizeof (msg), fmt, arg); return jed_get_y_n (msg); } int jed_get_yes_no (char *question) /*{{{*/ { char *yn_quest; char *tmp; int n; if (NULL == (yn_quest = strcat_malloc (question, "? (yes or no)"))) return -1; while (1) { if (NULL == (tmp = read_from_minibuffer(yn_quest, 0, NULL, &n))) { SLfree (yn_quest); return -1; } if (!strcmp(tmp, "yes")) { SLfree(tmp); SLfree (yn_quest); return 1; } if (!strcmp(tmp, "no")) { SLfree(tmp); SLfree (yn_quest); return 0; } msg_error("Answer `yes' or `no'."); SLfree(tmp); } } /*}}}*/ int find_file_cmd (char *filestr) /* filestr is const ! */ /*{{{*/ { Buffer *buf; int status; char *dirfile, *dir, *file; char *name; #ifdef REAL_UNIX_SYSTEM char *dir1; /* Handle the case where /foo/bar/../baz may not be the same as /foo/baz */ if (-1 == jed_dirfile_to_dir_file (filestr, &dir, &file)) return -1; if (NULL == (dir1 = jed_expand_link (dir))) { SLfree (dir); SLfree (file); return -1; } SLfree (dir); filestr = jed_dir_file_merge (dir1, file); SLfree (dir1); SLfree (file); #else filestr = jed_standardize_filename (filestr); #endif if (filestr == NULL) return -1; /* If this hook returns 1, then the file is considered to be found. */ if (1 == jed_va_run_hooks ("_jed_find_file_before_hooks", JED_HOOKS_RUN_UNTIL_NON_0, 1, filestr)) { SLfree (filestr); return 0; } dirfile = jed_expand_link(filestr); if (dirfile == NULL) { SLfree (filestr); return -1; } if (-1 == jed_dirfile_to_dir_file (filestr, &dir, &file)) { SLfree (filestr); SLfree (dirfile); return -1; } status = -1; if (*file == 0) { jed_verror (Expect_File_Error); goto free_and_return; } check_buffers (); /* search for the file in current buffer list */ if (NULL != (buf = find_file_buffer (dirfile))) { if ((file_changed_on_disk (buf, dirfile) > 0) && (1 == jed_get_yes_no("File changed on disk. Read from disk"))) { int n = (int) buf->linenum; mark_buffer_modified (buf, 0, 1); kill_buffer_cmd (buf->name); status = find_file_cmd (filestr); goto_line (&n); goto free_and_return; } if (SLang_get_error ()) goto free_and_return; status = 1; switch_to_buffer (buf); goto free_and_return; } /* Make a buffer but do not attach it to a file yet. */ name = extract_file (filestr); buf = make_buffer (name, dir, NULL); switch_to_buffer(buf); status = read_file (dirfile); switch (status) { case -2: jed_verror ("File %s not readable.", dirfile); status = -1; break; case -1: if (Batch == 0) message ("New file."); status = 0; break; default: if (Batch == 0) jed_vmessage (0, "%d lines read", status); status = 1; } if (buf == CBuf) /* check this in case the hook switches buffers */ { mark_buffer_modified (CBuf, 0, 0); /* Now attach it to a file */ visit_file (dir, file); uniquely_name_buffer (CBuf, name); (void) bob (); set_file_modes(); CBuf->flags |= UNDO_ENABLED; } if (-1 == jed_va_run_hooks ("_jed_find_file_after_hooks", JED_HOOKS_RUN_ALL, 0)) status = -1; free_and_return: SLfree (dirfile); SLfree (filestr); SLfree (dir); SLfree (file); return status; } /*}}}*/ int find_file_in_window(char *file) /*{{{*/ { int ret; Buffer *b = CBuf; ret = find_file_cmd (file); if ((b != CBuf) && (*CBuf->name != ' ')) Last_Buffer = CBuf; window_buffer(CBuf); return(ret); } /*}}}*/ /* create a minibuffer with window and switch to it. */ static void create_minibuffer(void) /*{{{*/ { Window_Type *w; MiniBuffer = The_MiniBuffer; /* We may get called before the keymap has been set up. Make sure that * we have a keymap. */ if ((The_MiniBuffer->keymap == NULL) || (The_MiniBuffer->keymap == Global_Map)) jed_setup_minibuffer_keymap (); /* I want to make Mini_Window->next = Current Window so that scroll other window routines will scroll it. */ w = JWindow; do other_window(); while (JWindow->next != w); JWindow->next = JMiniWindow; JMiniWindow->next = w; JMiniWindow->hscroll_column = 1; Mini_Info.action_window = w; other_window(); /* now in minibuffer window */ window_buffer(MiniBuffer); switch_to_buffer(MiniBuffer); MiniBuffer_Active = 1; erase_buffer (); #if JED_HAS_MENUS jed_notify_menu_buffer_changed (); #endif /* allow kill region to kill to beginning of minibuffer. * Suggested by stefen@uni-paderborn.de */ jed_push_mark (); } /*}}}*/ char *Completion_Buffer = "*Completions*"; static char *Last_Completion_Buffer; static int Last_Completion_Windows; /* evaluate command in minibuffer and leave */ int exit_minibuffer() /*{{{*/ { if (IN_MINI_WINDOW) { if (Last_Completion_Buffer != NULL) { pop_to_buffer (Completion_Buffer); mark_buffer_modified (CBuf, 0, 0); switch_to_buffer_cmd (Last_Completion_Buffer); kill_buffer_cmd (Completion_Buffer); touch_window_hard (JWindow, 0); if (Last_Completion_Windows == 1) one_window (); } select_minibuffer (); Exit_From_MiniBuffer = 1; } Last_Completion_Buffer = NULL; return(0); } /*}}}*/ /* return 1 if minibuffer already exists otherwise returns 0 */ int select_minibuffer (void) /*{{{*/ { Window_Type *w; /* Try to find active minibuffer and go there */ w = JWindow; while (MiniBuffer != NULL) { if (IN_MINI_WINDOW) return(1); other_window(); if (w == JWindow) exit_error("Internal Error: no window!", 1); } /* switchs to minibuffer too */ create_minibuffer(); return(0); } /*}}}*/ /* if cmd != NULL, insert it into minibuffer and then send the result to the appropriate routine. */ static int ledit(void) /*{{{*/ { int n; char *tmp; if (MiniBuffer == NULL) complete_open = NULL; if (NULL == (tmp = read_from_minibuffer(JED_PROMPT, 0, NULL, &n))) return(0); /* SLang_Error = 0; ??? Why? 0.99-16 and earlier */ Suspend_Screen_Update = 1; SLang_load_string(tmp); SLfree(tmp); if (SLang_get_error () == SL_USER_BREAK) msg_error("Quit!"); /* SLang_set_error (0); */ return(1); } /*}}}*/ static int File_Expansion_Happened = 0; static int file_findfirst (char *buf) { char *file; File_Expansion_Happened = 1; if (NULL == (file = jed_expand_filename (buf))) return -1; safe_strcpy (buf, file, JED_MAX_COMPLETION_LEN); SLfree (file); return sys_findfirst (buf); } static int file_findnext (char *file) { return sys_findnext (file); } static char *read_file_from_minibuffer(char *prompt, char *def, char *stuff) /*{{{*/ { int n; char *file, *file1; File_Expansion_Happened = 0; complete_open = file_findfirst; complete_next = file_findnext; if ((stuff == NULL) || (*stuff == 0)) { if (*CBuf->dir == 0) buffer_filename (CBuf, NULL, CBuf->file); stuff = CBuf->dir; } if (NULL == (file = read_from_minibuffer (prompt, def, stuff, &n))) return NULL; if (File_Expansion_Happened) file1 = jed_standardize_filename (file); else file1 = jed_expand_filename (file); SLfree (file); return file1; } /*}}}*/ static char *String_Completion_Str; static char *String_Completion_Str_Next; static int String_Completion_Str_Len; static int next_string_list (char *buf) /*{{{*/ { register char *s = String_Completion_Str_Next; int len; while (*s) { while (*s && (*s != ',')) s++; len = (int) (s - String_Completion_Str_Next); if (*s == ',') s++; if (!len || strncmp (buf, String_Completion_Str_Next, String_Completion_Str_Len)) { String_Completion_Str_Next = s; continue; } if (len >= JED_MAX_PATH_LEN) len = JED_MAX_PATH_LEN - 1; strncpy (buf, String_Completion_Str_Next, len); buf[len] = 0; String_Completion_Str_Next = s; return 1; } String_Completion_Str_Next = s; return 0; } /*}}}*/ static int open_string_list (char *buf) /*{{{*/ { String_Completion_Str_Next = String_Completion_Str; String_Completion_Str_Len = strlen (buf); return next_string_list (buf); } /*}}}*/ void read_object_with_completion(char *prompt, char *dflt, char *stuff, int *typep) /*{{{*/ { int type = *typep, n; char buf[JED_MAX_COMPLETION_LEN], *tmp; char *str = NULL; *buf = 0; if (type == 'f') /* file */ { char *file = read_file_from_minibuffer (prompt, dflt, stuff); if (file != NULL) (void) SLang_push_malloced_string (file); return; } else if (type == 'b') /* buffer */ { complete_open = open_bufflist; complete_next = next_bufflist; } else if (type == 'F') /* function */ { complete_open = open_function_list; complete_next = next_function_list; } else if (type == 's') { complete_open = open_string_list; complete_next = next_string_list; if (SLpop_string (&str)) return; String_Completion_Str = str; } else { complete_open = NULL; } safe_strcat (buf, stuff, sizeof (buf)); if (NULL != (tmp = read_from_minibuffer(prompt, dflt, buf, &n))) { (void) SLang_push_string(tmp); SLfree(tmp); if (str != NULL) SLfree (str); } } /*}}}*/ int insert_file_cmd (void) /*{{{*/ { char *f, *file; CHECK_READ_ONLY if (NULL == (file = read_file_from_minibuffer("Insert file:", NULL, NULL))) return -1; f = extract_file(file); if ((*file == 0) || (*f == 0)) { SLfree (file); msg_error(Expect_File_Error); return(1); } if (insert_file(file) < 0) msg_error("Error inserting file."); SLfree (file); return(1); } /*}}}*/ int find_file (void) /*{{{*/ { char *file, *f; int status; if (NULL == (file = read_file_from_minibuffer("Find file:", NULL, NULL))) return 0; f = extract_file (file); if (*f == 0) { char *dirfile = jed_dir_file_merge (file, CBuf->file); SLfree (file); if (dirfile == NULL) return -1; file = dirfile; } status = find_file_in_window (file); SLfree (file); return status; } /*}}}*/ int jed_save_buffer_as_cmd (void) /*{{{*/ { char *tmp; if (NULL == (tmp = read_file_from_minibuffer("Save as:", NULL, NULL))) return(0); (void) jed_save_buffer_as (tmp); SLfree(tmp); return(1); } /*}}}*/ void switch_to_buffer_cmd (char *name) /*{{{*/ { Buffer *tthis = CBuf; set_buffer(name); window_buffer(CBuf); if ((CBuf != tthis) && (*CBuf->name != ' ')) Last_Buffer = tthis; } /*}}}*/ static void get_last_buffer(void) /*{{{*/ { if ((Last_Buffer == CBuf) || (Last_Buffer == NULL) || (*Last_Buffer->name == ' ') || (Last_Buffer->flags & BURIED_BUFFER)) { Last_Buffer = find_non_visible_buffer (CBuf); } } /*}}}*/ int get_buffer() /*{{{*/ { char *tmp; int n; complete_open = open_bufflist; complete_next = next_bufflist; get_last_buffer (); if (NULL == (tmp = read_from_minibuffer("Switch to buffer:", Last_Buffer->name, NULL, &n))) return(0); switch_to_buffer_cmd(tmp); SLfree(tmp); return(1); } /*}}}*/ int kill_buffer (void) /*{{{*/ { char *tmp; int n; complete_open = open_bufflist; complete_next = next_bufflist; tmp = read_from_minibuffer("Kill buffer:", (char *) CBuf->name, NULL, &n); if (tmp != NULL) { #if JED_HAS_SUBPROCESSES Buffer *b = find_buffer(tmp); if ((b != NULL) && (b->subprocess)) { if (0 == jed_get_yes_no("Buffer has a subprocess attached. Delete anyway")) { SLfree(tmp); return 0; } } #endif kill_buffer_cmd(tmp); SLfree(tmp); return(1); } return 0; } /*}}}*/ int evaluate_cmd() /*{{{*/ { return(!ledit()); } /*}}}*/ char *pop_to_buffer(char *name) /*{{{*/ { Window_Type *w, *action, *use_this; char *bname; Line *line, *oldline; int p, oldp, lnum, oldlnum; Buffer *b, *oldb; if (!strcmp(name, " ")) { select_minibuffer (); return CBuf->name; } /* save position so we can pop back to it if buffer already exists in window */ oldb = CBuf; oldline = CLine; oldp = Point; oldlnum = LineNum; set_buffer(name); line = CLine; p = Point; lnum = LineNum; use_this = NULL; if (MiniBuffer != NULL) { action = Mini_Info.action_window; } else action = NULL; if (Batch) return CBuf->name; w = JWindow; /* find a window to use */ do { if (0 == (w->flags & MINIBUFFER_WINDOW)) { if (action != NULL) { if (w != action) use_this = w; } else if (w != JWindow) use_this = w; if (w->buffer == CBuf) { use_this = w; break; } } w = w->next; } while (w != JWindow); b = CBuf; if (use_this != NULL) { while(JWindow != use_this) other_window(); /* This is a good reason for haveing otherwindow avoid switching buffers */ if (CBuf == oldb) { CLine = oldline; Point = oldp; LineNum = oldlnum; } } else { if (action != NULL) while(JWindow != action) other_window(); split_window(); /* * doing it this way makes screen update look better */ w = JWindow; do { other_window(); } while (JWindow->buffer != w->buffer); JWindow->hscroll_column = 1; } bname = CBuf->name; switch_to_buffer(b); b->line = CLine = line; b->point = Point = p; b->linenum = LineNum = lnum; if (b != JWindow->buffer) window_buffer(b); return bname; } /*}}}*/ #if defined (REAL_UNIX_SYSTEM) || defined(__WIN32__) || (defined (__os2__) && !defined(__WATCOMC__)) # if defined (__WIN32__) /* defined (__BORLANDC__) || defined (_MSC_VER) */ # undef popen # undef pclose # define popen w32_popen # define pclose w32_pclose # endif # ifdef __IBMC__ extern FILE *popen(char *, char *); extern int pclose(FILE *); # endif # if !JED_HAS_SUBPROCESSES # define jed_popen popen # define jed_pclose pclose # endif static char *Process_Error = "Unable to open process."; int shell_command(char *cmd) /*{{{*/ { FILE *pp; VFILE *vp; int status; if (Jed_Secure_Mode) { msg_error ("Access denied."); return -1; } if (NULL == (pp = jed_popen(cmd, "r"))) { msg_error(Process_Error); return -1; } if (NULL != (vp = vstream(fileno(pp), 0, VFILE_TEXT))) { (void) insert_file_pointer(vp); SLfree(vp->buf); SLfree ((char *)vp); } else msg_error("Malloc Error."); status = jed_pclose (pp); #if defined(WIFEXITED) && defined(WEXITSTATUS) if ((status != -1) && WIFEXITED(status)) { status = WEXITSTATUS(status); } #endif return status; } /*}}}*/ int pipe_region(char *cmd) /*{{{*/ { FILE *pp; int n; if (Jed_Secure_Mode) { msg_error ("Access denied."); return -1; } if (NULL == (pp = jed_popen (cmd, "w"))) { msg_error(Process_Error); return(-1); } n = write_region_to_fp(fileno(pp)); if (n == -1) msg_error ("pipe_region: write failed"); return jed_pclose (pp); } /*}}}*/ #endif /* * Try to open a .slc then a .sl */ #ifdef SIXTEEN_BIT_SYSTEM #define VFILE_BUF_SIZE 1024 #else #define VFILE_BUF_SIZE 4096 #endif static VFILE *jed_open_lib_file (SLFUTURE_CONST char *file, char **dirfile) /*{{{*/ { char libfsl[JED_MAX_PATH_LEN], libfslc[JED_MAX_PATH_LEN]; SLFUTURE_CONST char *lib, *type, *libf; unsigned int n; VFILE *vp = NULL; int free_lib; int delimiter; libf = file; lib = NULL; free_lib = 0; /* If file begins with ./,then read it from the current directory */ if ((0 == strncmp (file, "./", 2)) #ifdef IBMPC_SYSTEM || (0 == strncmp (file, ".\\", 2)) || (0 == strncmp (file, "..\\", 3)) #endif || (0 == strncmp (file, "../", 3))) { if (NULL == (lib = jed_get_cwd ())) lib = ""; } else if (SLpath_is_absolute_path (file)) lib = ""; else { lib = SLpath_get_load_path (); /* SLstring */ free_lib = 1; if ((lib == NULL) || (*lib == 0)) exit_error("The JED_ROOT environment variable needs set.", 0); } if ((NULL != (type = file_type(file))) && ((*type == 0) || ((0 != strcmp (type, "sl")) && (0 != strcmp (type, "slc"))))) type = NULL; delimiter = SLpath_get_delimiter (); n = 0; while (0 == SLextract_list_element (lib, n, delimiter, libfsl, sizeof(libfsl))) { n++; fixup_dir(libfsl); safe_strcat (libfsl, file, sizeof (libfsl)); safe_strcpy (libfsl, jed_standardize_filename_static(libfsl), sizeof (libfsl)); libf = libfsl; if ((1 == file_status (libf)) && (NULL != (vp = vopen(libf, VFILE_BUF_SIZE, VFILE_TEXT)))) break; if (type == NULL) { #ifdef VMS int vmsn; /* remove trailing '.' */ if (0 != (vmsn = strlen(libfsl))) { vmsn--; if (libfsl[vmsn] == '.') libfsl[vmsn] = 0; } #endif /* Try .sl and .slc */ safe_strcat (libfsl, ".sl", sizeof (libfsl)); safe_strcpy (libfslc, libfsl, sizeof (libfslc)); safe_strcat (libfslc, "c", sizeof (libfslc)); if (file_time_cmp(libfslc, libfsl) >= 0) libf = libfslc; if ((1 == file_status (libf)) && (NULL != (vp = vopen(libf, VFILE_BUF_SIZE, VFILE_TEXT)))) break; } } if (free_lib) SLang_free_slstring ((char *) lib); if (vp == NULL) { *dirfile = NULL; return NULL; } if (NULL == (*dirfile = SLang_create_slstring (libf))) { vclose (vp); return NULL; } if (0 == Jed_Load_Quietly) jed_vmessage (1, "loading %s", libf); return (vp); } /*}}}*/ static char *jed_read_from_file(SLang_Load_Type *x) /*{{{*/ { char *s; unsigned int n; if ((s = vgets((VFILE *) x->client_data, &n)) != NULL) { if (s[n - 1] != '\n') s[n] = 0; } return s; } /*}}}*/ int jed_ns_load_file (SLFUTURE_CONST char *file, SLFUTURE_CONST char *ns) { VFILE *vp; SLang_Load_Type *x; int ret; char *dirfile; if (NULL == (vp = jed_open_lib_file (file, &dirfile))) { SLang_verror (SL_OBJ_NOPEN, "Unable to open %s. Check the value of the S-Lang load path.", file); return -1; } #if SLANG_VERSION >= 10409 x = SLns_allocate_load_type (dirfile, ns); #else if ((ns != NULL) && (0 != strcmp (ns, "Global"))) { SLang_verror (SL_NOT_IMPLEMENTED, "loading a file into a namespace is not supported"); x = NULL; } else x = SLallocate_load_type (dirfile); #endif SLang_free_slstring (dirfile); if (x == NULL) { vclose (vp); return -1; } x->client_data = (VOID_STAR) vp; x->read = jed_read_from_file; ret = SLang_load_object (x); SLdeallocate_load_type (x); vclose (vp); return ret; } #if SLANG_VERSION < 10409 static int jed_load_file (char *file) { return jed_ns_load_file (file, NULL); } #endif typedef struct { Line *l; char buf[256]; } Buffer_Client_Type; static char *jed_read_from_buffer (SLang_Load_Type *x) /*{{{*/ { Buffer_Client_Type *b; char *buf; Line *l; unsigned int len; b = (Buffer_Client_Type *)x->client_data; if (NULL == (l = b->l)) return NULL; len = (unsigned int) l->len; if (len > 255) { #if SLANG_VERSION >= 20000 SLang_verror (SL_BUILTIN_LIMIT_EXCEEDED, "Line too long"); #else SLang_verror (0, "Line too long"); #endif return NULL; } buf = b->buf; SLMEMCPY(buf, (char *) l->data, len); buf [len] = 0; b->l = l->next; return buf; } /*}}}*/ void jed_load_buffer (char *ns) /*{{{*/ { SLang_Load_Type *x; Buffer_Client_Type client_data; Buffer *cbuf = CBuf; int flags = CBuf->flags; Line *l, *lwant; char *file; if (cbuf->file[0] == 0) file = cbuf->name; else file = cbuf->file; file = jed_dir_file_merge (CBuf->dir, file); if (file == NULL) return; x = SLns_allocate_load_type (file, ns); SLfree (file); if (x == NULL) return; x->read = jed_read_from_buffer; x->client_data = (VOID_STAR) &client_data; client_data.l = CBuf->beg; cbuf->flags |= READ_ONLY; SLang_load_object(x); SLdeallocate_load_type (x); if (buffer_exists (cbuf)) cbuf->flags = flags; else cbuf = NULL; if (SLang_get_error () == 0) return; if (cbuf == NULL) return; pop_to_buffer (cbuf->name); lwant = client_data.l; if (lwant == NULL) { eob(); return; } bob(); while (1) { l = CLine->next; if ((l == NULL) || (l == lwant)) break; (void) jed_down(1); } (void) jed_skip_whitespace(); } /*}}}*/ static SLang_Name_Type *Expand_File_Hook; void set_expansion_hook (char *s) /*{{{*/ { if (NULL == (Expand_File_Hook = SLang_get_function (s))) { msg_error ("The expansion hook has not been defined."); } } /*}}}*/ int mini_complete (void) /*{{{*/ { char *pl, *pb; char last[JED_MAX_PATH_LEN], buf[JED_MAX_PATH_LEN], *tmp; static char prev[JED_MAX_PATH_LEN]; int n, last_key_char = SLang_Last_Key_Char; static int flag = 0; /* when flag goes 0, we call open */ if (complete_open == NULL) return ins_char_cmd(); bol (); jed_push_mark(); eob(); if (NULL == (tmp = make_buffer_substring(&n))) return(1); safe_strcpy(buf, tmp, sizeof (buf)); SLfree(tmp); if ((last_key_char == ' ') && ((long) Last_Key_Function == (long) mini_complete)) { if (flag) flag = (*complete_next)(buf); if (flag == 0) { safe_strcpy(buf, prev, sizeof (buf)); flag = (*complete_open)(buf); } safe_strcpy(last, buf, sizeof (last)); n = -1; } else { n = 0; safe_strcpy (prev, buf, sizeof (prev)); /* save this search context */ } if (!n) { if ((Repeat_Factor != NULL) || (complete_open != file_findfirst) || (Expand_File_Hook == NULL)) flag = (*complete_open)(buf); else { int do_free; SLang_push_string (buf); SLexecute_function (Expand_File_Hook); if (SLang_get_error () == 0) SLang_pop_integer (&do_free); if (SLang_get_error () == 0) { if (do_free == 0) { flag = (*complete_open) (buf); goto start_loop; } } if (SLang_get_error () || SLang_pop_slstring (&tmp)) { msg_error ("Error encounter during expansion. Disabling expansion hook."); Expand_File_Hook = NULL; return 1; } safe_strcpy (last, tmp, sizeof (last)); safe_strcpy (prev, last, sizeof (prev)); SLang_free_slstring (tmp); flag = 0; /* So we do not call complete_next */ n = -1; } } start_loop: if (!n && flag) { safe_strcpy(last, buf, sizeof (last)); /* This do loop tests all values from complete_next and returns the smallest length match of initial characters of buf */ do { if ((n == 0) && (last_key_char == '\t')) { set_buffer (Completion_Buffer); erase_buffer (); CBuf->flags |= BURIED_BUFFER; (void) jed_insert_string ("!!! Use Page Up/Down keys to scroll this window. !!!\n"); } n++; pl = last; pb = buf; #if !JED_FILE_PRESERVE_CASE if ((complete_open == open_bufflist) #if !JED_FILENAME_CASE_SENSITIVE || (complete_open == file_findfirst) #endif ) while (*pl && (UPPER_CASE(*pl) == UPPER_CASE(*pb))) { pl++; pb++; } else /* next statement */ #endif while (*pl && (*pl == *pb)) { pl++; pb++; } *pl = 0; if (last_key_char == '\t') { if (complete_open == file_findfirst) { char *file = jed_extract_file_or_dir (buf); (void) jed_quick_insert ((unsigned char *) file, strlen(file)); } else { while (*pb) pb++; (void) jed_quick_insert ((unsigned char *)buf, (int) (pb - buf)); } newline (); } } while(0 != (flag = (*complete_next)(buf))); #if JED_FILE_PRESERVE_CASE /* OS/2 uses case-insensitive search on buffer-names. Set the * flag if there is an exact match, so that completion will * cycle without repeats through all the matches. */ if (complete_open == open_bufflist) { safe_strcpy(buf, last, sizeof (buf)); (*complete_open)(buf); do { if (!strcmp(buf, last)) { flag = 1; break; } } while ((*complete_next)(buf)); } #endif } if ((n > 1) && (last_key_char == '\t') && (Last_Completion_Buffer == NULL)) { Last_Completion_Windows = jed_num_windows () - 1; /* not including mini */ Last_Completion_Buffer = pop_to_buffer (Completion_Buffer); bob (); } while ((CBuf != MiniBuffer) || !IN_MINI_WINDOW) other_window (); if (n) { erase_buffer(); (void) jed_insert_string(last); if ((n == 1) && ((long) Last_Key_Function == (long) mini_complete)) message("[Sole Completion.]"); } else msg_error("No Match!"); return(1); } /*}}}*/ void copy_region_cmd(char *name) /*{{{*/ { Buffer *buf; if (NULL != (buf = find_buffer(name))) { copy_region_to_buffer(buf); } else msg_error("Unable to find buffer."); } /*}}}*/ #ifndef IBMPC_SYSTEM void screen_w80 (void) /*{{{*/ { tt_narrow_width (); jed_resize_display (); } /*}}}*/ void screen_w132 (void) /*{{{*/ { tt_wide_width(); jed_resize_display (); } /*}}}*/ #endif char *make_line_string(char *string, unsigned int buflen) /*{{{*/ { unsigned char *tmp, *p1, *p2; unsigned int n; if (CBuf->marks == NULL) { p1 = CLine->data + Point; p2 = CLine->data + CLine->len; } else { p1 = CLine->data + CBuf->marks->point; p2 = CLine->data + Point; if (p2 < p1) { tmp = p1; p1 = p2; p2 = tmp; } jed_pop_mark(0); } n = (unsigned int) (p2 - p1); if (n >= buflen) n = buflen - 1; SLMEMCPY(string, (char *) p1, n); string[n] = 0; return(string); } /*}}}*/ char *make_buffer_substring(int *np) /*{{{*/ { Line *tthis, *beg; int n = 1, dn, thisp; unsigned char *buf; if (!check_region(&n)) return (NULL); /* spot pushed */ /* Point now at end of the region */ beg = tthis = CBuf->marks->line; thisp = CBuf->marks->point; n = 0; jed_pop_mark(0); while (tthis != CLine) { n += tthis->len; tthis = tthis->next; } n -= thisp; n += Point; if (NULL == (buf = (unsigned char *) SLmalloc (n + 1))) { pop_spot(); return (NULL); } if (CLine == (tthis = beg)) { SLMEMCPY((char *)buf, (char *) (tthis->data + thisp), n); } else { n = 0; while (tthis != CLine) { dn = tthis->len - thisp; SLMEMCPY((char *)(buf + n), (char *) (tthis->data + thisp), dn); tthis = tthis->next; thisp = 0; n += dn; } SLMEMCPY((char *)(buf + n), (char *) tthis->data, Point); n += Point; } buf[n] = 0; *np = n; pop_spot(); return ((char *) buf); } /*}}}*/ void buffer_substring() /*{{{*/ { char *buf; int n; if (NULL == (buf = make_buffer_substring(&n))) return; SLang_push_malloced_string((char *)buf); } /*}}}*/ int markp(void) /*{{{*/ { return (CBuf->marks != NULL); } /*}}}*/ int dup_mark(void) /*{{{*/ { if (CBuf->marks == NULL) return(0); push_spot(); jed_goto_mark(CBuf->marks); jed_push_mark(); pop_spot(); return(1); } /*}}}*/ void mini_read(char *prompt, char *def, char *stuff) /*{{{*/ { char *buf; int n; complete_open = NULL; if (NULL == (buf = read_from_minibuffer(prompt, def, stuff, &n))) SLang_push_string (""); else SLang_push_malloced_string(buf); } /*}}}*/ void make_buffer_list(void) /*{{{*/ { int n = 0; Buffer *b; b = CBuf; do { SLang_push_string(b->name); b = b->next; n++; } while (b != CBuf); SLang_push_integer(n); } /*}}}*/ static void jed_traceback (SLFUTURE_CONST char *s) /*{{{*/ { char *n; if (Batch) { (void) fputs (s, stderr); return; } n = CBuf->name; set_buffer("*traceback*"); CBuf->flags |= BURIED_BUFFER; eob(); (void) jed_insert_string(s); set_buffer(n); } /*}}}*/ #if 0 static struct /*{{{*/ { int depth = 0; char *name[20]; int marks[20]; } /*}}}*/ FName_Stack; void enter_function(char *name) /*{{{*/ { if (depth > 20) { msg_error("Function Stack too deep."); return; } FName_Stack->name[depth] = name; FName_Stack->marks[depth] = 0; } /*}}}*/ void exit_function(char *name) /*{{{*/ { int n = FName_Stack->marks[depth]; } /*}}}*/ #endif static void jed_clear_error(void) /*{{{*/ { *Error_Buffer = 0; SLKeyBoard_Quit = 0; } /*}}}*/ typedef struct _Init_SLang_Hook_Type { int (*hook)(void); struct _Init_SLang_Hook_Type *next; } Init_SLang_Hook_Type; static Init_SLang_Hook_Type *Init_SLang_Hooks; int jed_add_init_slang_hook (int (*hook)(void)) { Init_SLang_Hook_Type *h; if (hook == NULL) return 0; h = (Init_SLang_Hook_Type *)SLmalloc (sizeof (Init_SLang_Hook_Type)); if (h == NULL) return -1; h->hook = hook; h->next = Init_SLang_Hooks; Init_SLang_Hooks = h; return 0; } static int run_init_slang_hooks (void) { Init_SLang_Hook_Type *h; h = Init_SLang_Hooks; while (h != NULL) { if (-1 == (*h->hook)()) return -1; h = h->next; } while (Init_SLang_Hooks != NULL) { h = Init_SLang_Hooks->next; SLfree ((char *) Init_SLang_Hooks); Init_SLang_Hooks = h; } return 0; } static void slang_exit_error_handler (SLFUTURE_CONST char *fmt, va_list ap) { char buf [2048]; SLvsnprintf (buf, sizeof (buf), fmt, ap); exit_error (buf, 0); } static void vmsg_hook (SLFUTURE_CONST char *fmt, va_list ap) { char buf [2048]; SLvsnprintf (buf, sizeof (buf), fmt, ap); message (buf); } void jed_setup_minibuffer_keymap (void) { SLKeyMap_List_Type *m; if (NULL == (m = SLang_find_keymap ("Mini_Map"))) { if (NULL == (m = SLang_create_keymap("Mini_Map", Global_Map))) exit_error("Unable to create minibuffer keymap", 0); SLang_undefine_key("\r", m); SLkm_define_key ("\r", (FVOID_STAR) exit_minibuffer, m); SLkm_define_key ("\t", (FVOID_STAR) mini_complete, m); SLkm_define_key (" ", (FVOID_STAR) mini_complete, m); } The_MiniBuffer->keymap = m; } #if SLANG_VERSION < 10405 /* Work around a slang bug triggered by jed. Apps which use slang's * load_file function do not have this problem. */ extern int (*_SLprep_eval_hook) (char *); static int bug_fixed_prep_eval_expr (char *expr) { int ret; char *end; end = strchr (expr, '\n'); if (end == NULL) end = expr + strlen (expr); expr = SLmake_nstring (expr, (unsigned int) (end - expr)); if (expr == NULL) return -1; if ((0 != SLang_load_string (expr)) || (-1 == SLang_pop_integer (&ret))) ret = -1; else ret = (ret != 0); SLfree (expr); return ret; } #endif void init_minibuffer() /*{{{*/ { Buffer *tmp; tmp = CBuf; The_MiniBuffer = make_buffer (" ", NULL, NULL); The_MiniBuffer->modes = 0; /* do some initializing */ switch_to_buffer(The_MiniBuffer); remake_line(132); JMiniWindow = jed_create_minibuffer_window (); JMiniWindow->buffer = CBuf; Buffer_Local.tab = 0; switch_to_buffer(tmp); SLang_Dump_Routine = jed_traceback; SLang_Exit_Error_Hook = slang_exit_error_handler; #ifdef __GO32__ SLang_Interrupt = i386_check_kbd; #endif #if 0 SLang_Enter_Function = enter_function; SLang_Exit_Function = exit_function; #endif #if SLANG_VERSION < 10405 _SLprep_eval_hook = bug_fixed_prep_eval_expr; #endif if ((-1 == SLang_init_slang ()) #ifndef SIXTEEN_BIT_SYSTEM || (-1 == SLang_init_slmath ()) || (-1 == SLang_init_array ()) #endif || (-1 == SLang_init_posix_process ()) || (-1 == SLang_init_posix_dir ()) /* || (-1 == SLang_init_slassoc ()) -- handled by SLang_init_slang */ || (-1 == SLang_init_stdio ()) || (-1 == SLang_init_posix_io ()) || (-1 == SLang_init_ospath ()) #if JED_HAS_IMPORT || (-1 == SLang_init_import ()) #endif || (-1 == init_jed_intrinsics ()) || (-1 == jed_init_userinfo ()) #if JED_HAS_MENUS || (-1 == jed_init_menus ()) #endif || (-1 == jed_init_syntax ()) || (-1 == register_jed_classes ()) || (-1 == jed_init_user_hooks ()) || (-1 == run_init_slang_hooks ())) { exit_error("Unable to initialize S-Lang!", 0); } /* use jed rouotines instead of default slang ones */ SLang_Error_Hook = jed_error_hook; SLang_VMessage_Hook = vmsg_hook; SLang_User_Clear_Error = jed_clear_error; #if SLANG_VERSION < 10409 SLang_Load_File_Hook = jed_load_file; #else SLns_Load_File_Hook = jed_ns_load_file; #endif } /*}}}*/ jed-0.99-19/src/misc.c0000644002657400265740000003576111311317447013374 0ustar davisdavis/* -*- mode: C; mode: fold; -*- */ /* Copyright (c) 1992, 1998, 2000, 2002, 2003, 2004, 2005, 2006 John E. Davis * This file is part of JED editor library source. * * You may distribute this file under the terms the GNU General Public * License. See the file COPYING for more information. */ #include "config.h" #include "jed-feat.h" /*{{{ Include Files */ #include #include #include "jdmacros.h" #include #include #include #include "buffer.h" #include "screen.h" #include "window.h" #include "display.h" #include "sysdep.h" #include "file.h" #include "keymap.h" #include "ledit.h" #include "misc.h" #include "ins.h" #include "paste.h" /*}}}*/ /*{{{ Global Variables */ /* Do not malloc these without changing occurances of sizeof() first */ char Error_Buffer[256]; int Exit_From_MiniBuffer; static unsigned char Macro_Buffer[JED_KBD_MACRO_SIZE]; unsigned char *Macro_Buffer_Ptr = Macro_Buffer; static unsigned char *Macro_Ptr_Max = Macro_Buffer; int Defining_Keyboard_Macro = 0; int Executing_Keyboard_Macro = 0; MiniInfo_Type Mini_Info; /*}}}*/ typedef struct /*{{{*/ { jmp_buf b; } /*}}}*/ jmp_buf_struct; extern jmp_buf_struct Jump_Buffer, *Jump_Buffer_Ptr; static struct /*{{{*/ { int def; int exe; } /*}}}*/ Macro_State; static void macro_store_key(char ch) /*{{{*/ { /* I need to put something here to increase the size of the Macro_Buffer in case of overflow */ if (Macro_Buffer_Ptr - Macro_Buffer >= JED_KBD_MACRO_SIZE) msg_error("Macro Size exceeded."); else *Macro_Buffer_Ptr++ = ch; } /*}}}*/ static void restore_macro_state(void) /*{{{*/ { Defining_Keyboard_Macro = Macro_State.def; Executing_Keyboard_Macro = Macro_State.exe; } /*}}}*/ static void set_macro_state(void) /*{{{*/ { Macro_State.def = Defining_Keyboard_Macro; Macro_State.exe = Executing_Keyboard_Macro; } /*}}}*/ void jed_abort_keyboard_macro (void) { Defining_Keyboard_Macro = Executing_Keyboard_Macro = 0; set_macro_state(); } /* if not in the mini buffer and if during keyboard macro, allow user to enter different text each time macro is executed */ int macro_query() /*{{{*/ { char *s; int n; /* macro state is already set */ Defining_Keyboard_Macro = 0; Executing_Keyboard_Macro = 0; if (!IN_MINI_WINDOW) { if (NULL == (s = read_from_minibuffer("Enter String:", (char *) NULL, NULL, &n))) return(0); (void) jed_insert_nbytes ((unsigned char *) s, n); SLfree(s); } /* exit from mini restores the state */ return(1); } /*}}}*/ int jed_check_string_key_buffer (void) { int ch, ch1; if (Read_This_Character == NULL) return -1; ch = *Read_This_Character++; if (ch == 0) { Read_This_Character = NULL; return -1; } if ((ch1 = *Read_This_Character) == 0) { Read_This_Character = NULL; return ch; } if (ch == '^') { if (ch1 == '?') ch = 127; else ch = ch1 - '@'; Read_This_Character++; } else if (ch == '\\') { ch = ch1; Read_This_Character++; } if (*Read_This_Character == 0) Read_This_Character = NULL; return ch; } int jed_getkey (void) /*{{{*/ { int ch, diff; static int mini_flag = 0; int *srf; ch = jed_check_string_key_buffer (); if (ch != -1) return ch; if (Executing_Keyboard_Macro) { if (Macro_Buffer_Ptr < Macro_Ptr_Max) return (*Macro_Buffer_Ptr++); Executing_Keyboard_Macro = 0; #if JED_HAS_MENUS /* This means that the macro was stopped from a menu */ if (Jed_Menus_Active) (void) jed_exit_menu_bar (); #endif update((Line *) NULL, 0, 0, 1); } diff = (int) (Key_Bufferp - Key_Buffer); if ((SLang_get_error () == 0) && SLang_Key_TimeOut_Flag && ((mini_flag && (diff > 0)) || !input_pending(&Number_Ten))) { message(Key_Buffer); safe_strcat(Message_Buffer, "-", sizeof(Message_Buffer)); /* This ensures that the update is performed if we are echoing from * digit argument */ srf = Repeat_Factor; Repeat_Factor = NULL; update((Line *)NULL, 0, 0, 1); Repeat_Factor = srf; clear_message (); mini_flag = 1; } else (mini_flag = 0); ch = my_getkey(); if (diff < SLANG_MAX_KEYMAP_KEY_SEQ) { *Key_Bufferp++ = (char) ch; *Key_Bufferp = 0; } else { /* msg_error("KeyBuffer overflow!"); */ Key_Bufferp = Key_Buffer; } if (Defining_Keyboard_Macro) { /* starting a new keysequence to save this point */ if (diff == 0) { Macro_Ptr_Max = Macro_Buffer_Ptr; } macro_store_key(ch); } return(ch); } /*}}}*/ void jed_error_hook (SLFUTURE_CONST char *msg) { if ((JWindow == NULL) || Batch) fprintf(stderr, "%s\r\n", msg); else JWindow->trashed = 1; if (Error_Buffer[0] == 0) safe_strcpy(Error_Buffer, msg, sizeof (Error_Buffer)); } void msg_error(char *msg) /*{{{*/ { #if 0 Defining_Keyboard_Macro = Executing_Keyboard_Macro = 0; Read_This_Character = NULL; Repeat_Factor = NULL; set_macro_state(); #endif SLang_verror (SL_INTRINSIC_ERROR, "%s", msg); } /*}}}*/ /* read from minibuffer using prompt providing a default, and stuffing the minibuffer with init if necessary */ /* I should make recursive mini buffers */ static char *read_from_minibuffer_1 (char *prompt, char *deflt, char *what, int *n) /*{{{*/ { char buf[JED_MAX_PATH_LEN]; jmp_buf_struct *mini_jmp_save, mini_jmp_buf; unsigned char *ps; unsigned char *p, ch; static Window_Type *current_window; /* may get changed if user leaves minibuffer and returns from other * window which means that the new window becomes target * of minibuffer action */ Window_Type *w; char *ret; int len; Buffer *start_buffer; if (Batch) { if (prompt != NULL) fputs (prompt, stdout); if ((deflt != NULL) && (*deflt != 0)) fprintf (stdout, "(default %s)", deflt); fflush (stdout); *n = 0; if (NULL == fgets (buf, sizeof(buf), stdin)) { SLang_verror (SL_Read_Error, "Read from stdin failed"); return NULL; } if (NULL == (ret = SLmake_string (buf))) return NULL; len = strlen (ret); if (len && (ret[len-1] == '\n')) { len--; ret[len] = 0; } *n = (int) len; return ret; } if (!IN_MINI_WINDOW) { current_window = JWindow; start_buffer = CBuf; } else { current_window = NULL; start_buffer = NULL; } if (select_minibuffer()) return(NULL); /* we should be on a new line of mini buffer */ ps = Mini_Info.prompt; p = (unsigned char *) prompt; len = 0; if (p != NULL) { while (0 != (ch = *p++)) { *ps++ = ch; len++; } *ps++ = ' '; len++; } if ((deflt != NULL) && (*deflt != 0)) { SLsnprintf (buf, sizeof (buf), "(default: %s) ", deflt); p = (unsigned char *) buf; while (0 != (ch = *p++)) { *ps++ = ch; len++; } } *ps = 0; Mini_Info.prompt_len = len; Mini_Info.effective_prompt_len = jed_compute_effective_length (Mini_Info.prompt, Mini_Info.prompt + len); touch_window(); if (what != NULL) jed_insert_string(what); update((Line *) NULL, 0, 0, 1); mini_jmp_save = Jump_Buffer_Ptr; Jump_Buffer_Ptr = &mini_jmp_buf; if (setjmp(mini_jmp_buf.b) != 0) { /* Do not call the restart function from here, in case this function * has been called from the interpreter. */ /* SLang_restart(1); */ update((Line *) NULL, 0, 0, 1); } while(!Exit_From_MiniBuffer) { int err = 0; do_jed(); err = SLang_get_error (); if (((err == SL_USER_BREAK) || SLKeyBoard_Quit) && IN_MINI_WINDOW) break; update((Line *) NULL, 0, 0, 1); if (err) { SLang_restart (0); SLang_set_error (0); SLKeyBoard_Quit = 0; } } if (Exit_From_MiniBuffer && !Executing_Keyboard_Macro && (Repeat_Factor == NULL) && !JWindow->trashed && !input_pending(&Number_Zero)) { SLsmg_gotorc (Jed_Num_Screen_Rows - 1, 0); SLsmg_refresh (); } Jump_Buffer_Ptr = mini_jmp_save; exit_minibuffer (); /* be graceful */ Exit_From_MiniBuffer = 0; MiniBuffer_Active = 0; restore_macro_state(); if (!SLKeyBoard_Quit) { if (CLine->len == 0) { if (deflt != NULL) jed_insert_string(deflt); } bob(); jed_push_mark(); eob(); ret = make_buffer_substring(n); } else { SLKeyBoard_Quit = 0; ret = NULL; } /* we should be in minibuffer so delete marks and spots */ while (CBuf->spots) pop_spot(); while (CBuf->marks) jed_pop_mark(0); erase_buffer(); /* Remove MiniWindow from the ring */ w = JWindow; while (w->next != JWindow) w = w->next; other_window(); w->next = JWindow; if (current_window != NULL) { /* Note that by this time, current_window might not exist. */ while((JWindow != current_window) && (JWindow != w)) other_window(); } if ((start_buffer != NULL) && (buffer_exists (start_buffer))) switch_to_buffer (start_buffer); JWindow->trashed = 1; /* delete_buffer(MiniBuffer); */ MiniBuffer = NULL; #if JED_HAS_MENUS jed_notify_menu_buffer_changed (); #endif return(ret); } /*}}}*/ char *read_from_minibuffer (char *prompt, char *deflt, char *what, int *n) { int *rf = Repeat_Factor; int repeat = 0; char *s; if (rf != NULL) repeat = *rf; s = read_from_minibuffer_1 (prompt, deflt, what, n); if (rf != NULL) { Repeat_Factor = rf; *rf = repeat; } return s; } static int Macro_Illegal_Now = 0; static int check_macro_legality(void) /*{{{*/ { if (Macro_Illegal_Now) { msg_error("Illegal context for Macro definition."); return (0); } return (1); } /*}}}*/ int begin_keyboard_macro() /*{{{*/ { if (!check_macro_legality()) return (0); Macro_Buffer_Ptr = Macro_Buffer; message("Defining Macro."); Defining_Keyboard_Macro = 1; set_macro_state(); return(1); } /*}}}*/ int end_keyboard_macro() /*{{{*/ { if (Defining_Keyboard_Macro) message("Macro Defined."); else { if (!Executing_Keyboard_Macro) msg_error("Not defining Macro!"); Executing_Keyboard_Macro = 0; return(1); } /* Macro_Ptr_Max = Macro_Buffer_Ptr; */ Defining_Keyboard_Macro = 0; set_macro_state(); return(1); } /*}}}*/ int execute_keyboard_macro() /*{{{*/ { int repeat = 0, *repeat_ptr; if (!check_macro_legality()) return (0); if (Defining_Keyboard_Macro) { msg_error("Can't execute a macro while defining one."); return(0); } Executing_Keyboard_Macro = 1; set_macro_state(); Macro_Buffer_Ptr = Macro_Buffer; /* save the repeat context */ repeat_ptr = Repeat_Factor; if (repeat_ptr != NULL) repeat = *repeat_ptr; JWindow->trashed = 1; Macro_Illegal_Now = 1; while ((Macro_Buffer_Ptr < Macro_Ptr_Max) && Executing_Keyboard_Macro) /* since we might enter minibuffer and stop macro before returning here */ { Repeat_Factor = NULL; /* ch = *Macro_Buffer_Ptr++; */ (void) jed_do_key(); if (SLKeyBoard_Quit || (*Error_Buffer)) break; } Macro_Illegal_Now = 0; /* restore context */ Repeat_Factor = repeat_ptr; if (repeat_ptr != NULL) *repeat_ptr = repeat; Executing_Keyboard_Macro = 0; #if JED_HAS_MENUS /* This means that the macro was stopped from a menu */ if (Jed_Menus_Active) (void) jed_exit_menu_bar (); #endif set_macro_state(); return(1); } /*}}}*/ void get_last_macro () /*{{{*/ { unsigned char *m, *s; unsigned char buf[2 * JED_KBD_MACRO_SIZE + 1]; if (Defining_Keyboard_Macro) { msg_error("Complete Macro first!"); return; } m = Macro_Buffer; if (m == Macro_Ptr_Max) { msg_error("Macro not defined."); return; } s = buf; while (m < Macro_Ptr_Max) { unsigned char ch = *m++; if ((ch < ' ') || (ch == 127)) { *s++ = '^'; if (ch == 127) ch = '?'; else ch = '@' + ch; } else if ((ch == '^') || (ch == '\\')) { *s++ = '\\'; } *s++ = (char)ch; } *s = 0; SLang_push_string ((char *)buf); } /*}}}*/ char *safe_strcpy (char *a, SLFUTURE_CONST char *b, unsigned int n) /*{{{*/ { if (n != 0) { n--; strncpy (a, b, n); a[n] = 0; } return a; } /*}}}*/ char *safe_strcat (char *a, SLFUTURE_CONST char *b, unsigned int n) /*{{{*/ { unsigned int len = strlen (a); unsigned int max; n--; if (n > len) { max = n - len; strncpy (a + len, b, max); a[n] = 0; } return a; } /*}}}*/ void jed_vmessage (int now, char *fmt, ...) { va_list ap; char buf[2048]; va_start (ap, fmt); SLvsnprintf (buf, sizeof (buf), fmt, ap); va_end (ap); if (now) flush_message (buf); else message (buf); } void jed_verror (char *fmt, ...) { va_list ap; char buf[2048]; va_start (ap, fmt); SLvsnprintf (buf, sizeof (buf), fmt, ap); va_end (ap); msg_error (buf); } /* Since the interpreter deals mainly with hashed strings, and there is * the possibility that the strings to be compared are the same, we * will exploit this fact. */ int jed_case_strncmp (char *a, char *b, unsigned int n) { register unsigned char cha, chb; char *bmax; if (a == b) return 0; bmax = b + n; while (b < bmax) { cha = UPPER_CASE(*a); chb = UPPER_CASE(*b); if (cha != chb) return (int) cha - (int) chb; if (chb == 0) return 0; a++; b++; } return 0; } int jed_case_strcmp (char *a, char *b) { register unsigned char cha, chb; if (a == b) return 0; while (1) { cha = UPPER_CASE(*a); chb = UPPER_CASE(*b); if (cha != chb) return (int) cha - (int) chb; if (chb == 0) return 0; a++; b++; } } char *jed_malloc0 (unsigned int len) { char *s = SLmalloc (len); if (s != NULL) memset ((char *) s, 0, len); return s; } Buffer *jed_get_mini_action_buffer (void) { Window_Type *w; if (IN_MINI_WINDOW == 0) return NULL; w = Mini_Info.action_window; if (w != NULL) { Buffer *b = w->buffer; if (buffer_exists (b)) return b; } return NULL; } /* Returns 0, if the keysequence is valid, otherwise returns -1. */ int jed_getkey_wchar (SLwchar_Type *wchp) { int ch; #if JED_HAS_UTF8_SUPPORT SLuchar_Type buf[SLUTF8_MAX_MBLEN+1]; unsigned int i; #endif ch = jed_getkey (); *wchp = (SLwchar_Type) ch; #if JED_HAS_UTF8_SUPPORT if ((ch < 128) || (Jed_UTF8_Mode == 0)) return 0; buf[0] = (SLuchar_Type) ch; i = 1; while (1) { unsigned int n; if (NULL != SLutf8_decode (buf, buf+i, wchp, &n)) break; if ((i == SLUTF8_MAX_MBLEN) || (ch < 128)) { ungetkey_string ((char *)buf + 1, i-1); *wchp = buf[0]; return -1; } ch = jed_getkey (); buf[i] = (SLuchar_Type) ch; i++; } #endif return 0; } void jed_ungetkey_wchar (SLwchar_Type wc) { SLuchar_Type *b, buf[JED_MAX_MULTIBYTE_SIZE]; if (NULL == (b = jed_wchar_to_multibyte (wc, buf))) return; ungetkey_string ((char *)buf, (int)(b-buf)); } #if SLANG_VERSION < 10410 int SLang_get_error (void) { return SLang_Error; } int SLang_set_error (int e) { SLang_Error = e; return 0; } #endif jed-0.99-19/src/search.h0000644002657400265740000000135011311317447013676 0ustar davisdavis/* Copyright (c) 1992, 1998, 2000, 2005, 2006 John E. Davis * This file is part of JED editor library source. * * You may distribute this file under the terms the GNU General Public * License. See the file COPYING for more information. */ extern int search(char *, int, int); extern int search_forward(char *); extern int search_backward(char *); extern int forward_search_line(char *); extern int backward_search_line(char *); extern int bol_fsearch(char *); extern int bol_bsearch(char *); extern int re_search_forward(char *); extern int re_search_backward(char *); extern int replace_match(char *, int *); extern void regexp_nth_match(int *); int insert_file_region (char *, char *, char *); int search_file(char *, char *, int *); jed-0.99-19/src/file.h0000644002657400265740000000415311311317447013354 0ustar davisdavis/* Copyright (c) 1992, 1998, 2000, 2005, 2006 John E. Davis * This file is part of JED editor library source. * * You may distribute this file under the terms the GNU General Public * License. See the file COPYING for more information. */ #ifndef _JED_FILE_H_ #define _JED_FILE_H_ #include #ifdef VMS # include #endif #include "buffer.h" #include "vfile.h" extern int Require_Final_Newline; extern int read_file(char *); extern int insert_file(char *); extern void set_file_modes(void); extern void auto_save_buffer(Buffer *); extern void auto_save_all(void); extern void auto_save(void); extern int write_region_to_fp(int); extern int write_region(char *); extern int read_file_pointer(int); extern int insert_file_pointer(VFILE *); extern int append_to_file(char *); extern int write_file_with_backup(char *); extern void visit_file(char *, char *); extern void fixup_dir(char *); extern char *dir_file_merge(char *, char *); extern int file_status(SLFUTURE_CONST char *); extern int file_changed_on_disk (Buffer *, char *); extern int file_time_cmp(char *, char *); extern char *file_type(SLFUTURE_CONST char *); extern void check_buffer(Buffer *); extern void set_file_trans(int *); extern char *jed_expand_link(char *); #ifdef REAL_UNIX_SYSTEM extern int jed_get_inode_info (char *, int *, int *); extern int Jed_Backup_By_Copying; #endif #ifndef VMS extern int jed_copy_file (char *, char *); #endif extern void jed_set_umask (int); extern void jed_set_buffer_ctime (Buffer *); extern int jed_unlock_buffer_files (void); extern int jed_unlock_buffer_file (Buffer *); extern int jed_lock_buffer_file (Buffer *); extern int jed_lock_file (char *); extern int jed_unlock_file (char *); extern int jed_dirfile_to_dir_file (char *dirfile, char **dirp, char **filep); extern char *jed_standardize_filename (SLFUTURE_CONST char *file); extern char *jed_dir_file_merge (SLFUTURE_CONST char *dir, SLFUTURE_CONST char *file); extern char *jed_get_canonical_pathname (char *); extern int jed_buffer_file_is_readonly (Buffer *); extern int jed_file_is_readonly (char *file, int respect_perms); #endif /* _JED_FILE_H_ */ jed-0.99-19/src/jed-feat.h0000644002657400265740000000554511311317447014122 0ustar davisdavis/* Copyright (c) 1992, 1998, 2000, 2005, 2006 John E. Davis * This file is part of JED editor library source. * * You may distribute this file under the terms the GNU General Public * License. See the file COPYING for more information. */ #ifndef JED_FEATURES_H #define JED_FEATURES_H /* If you want folding capibility, you MUST set JED_HAS_LINE_ATTRIBUTES to 1. * In addition, JED_HAS_LINE_ATTRIBUTES must also be set to 1 for * syntax highlighting to work properly. This adds an additional 4 * bytes per line overhead. You must also set JED_HAS_SAVE_NARROW to * 1. It is also a good idea to set JED_HAS_BUFFER_LOCAL_VARS to 1 * since that will allow fold marks to vary on a buffer-by-buffer * basis instead of a mode-by-mode basis. Summary: for folding or * syntax highlighting, set the next 3 variables to 1. */ #define JED_HAS_LINE_ATTRIBUTES 1 #define JED_HAS_BUFFER_LOCAL_VARS 1 #define JED_HAS_SAVE_NARROW 1 #define JED_HAS_DISPLAY_LINE_NUMBERS 1 /* Drop down menu support. */ #define JED_HAS_MENUS 1 /* See ../doc/filelock.txt --- requires symbolic links */ #define JED_HAS_EMACS_LOCKING 1 /* Double/Triple click support. This is currently supported by: * * X Windows * GPM Mouse Driver (Linux) * DJGPP version of jed */ #if defined(__unix__) || defined(VMS) || defined(__GO32__) || defined(MSWINDOWS) # define JED_HAS_MULTICLICK 1 #else # define JED_HAS_MULTICLICK 0 #endif /* Asynchronous subprocess support. This is only available for Unix systems. */ #if defined(REAL_UNIX_SYSTEM) || defined(__WIN32__) # define JED_HAS_SUBPROCESSES 1 #else # define JED_HAS_SUBPROCESSES 0 #endif #ifdef NeXT # undef JED_HAS_SUBPROCESSES # define JED_HAS_SUBPROCESSES 0 #endif /* Enhanced syntax highlighting support. This is a much more sophisticated * approach based on regular expressions. Experimental. */ #define JED_HAS_DFA_SYNTAX 1 /* Set JED_HAS_ABBREVS to 1 for the abbreviation feature. */ #define JED_HAS_ABBREVS 1 #define JED_HAS_COLOR_COLUMNS 1 #define JED_HAS_LINE_MARKS 1 /* The following only applies to systems that have case-insensitive file * systems. * * Are filenames case sensitive? If this is set to 1 Ma* will not match * makefile, even on systems that are not case sensitive by default. */ #define JED_FILENAME_CASE_SENSITIVE 0 /* If compiled with XJED_SET_WM_COMMAND non-zero, then Xjed * will set the WM_COMMAND property to inform the * window manager or session manager of the command line used to * start the application. Not all versions of X support this. */ #define XJED_SET_WM_COMMAND 0 #if JED_HAS_EMACS_LOCKING && !defined(HAVE_SYMLINK) # undef JED_HAS_EMACS_LOCKING # define JED_HAS_EMACS_LOCKING 0 #endif /* Set JED_HAS_IMPORT if you want the ability to import modules into jed via * the slang import statement. This assumes that slang was compiled with * such support. */ #define JED_HAS_IMPORT 1 #endif jed-0.99-19/src/text.h0000644002657400265740000000161211311317447013416 0ustar davisdavis/* Copyright (c) 1992, 1998, 2000, 2004, 2005, 2006 John E. Davis * This file is part of JED editor library source. * * You may distribute this file under the terms the GNU General Public * License. See the file COPYING for more information. */ extern int wrap_line(int); extern int forward_paragraph(void); extern void set_paragraph_separator (char *); extern int backward_paragraph(void); extern int text_format_paragraph(void); extern int narrow_paragraph(void); extern int center_line(void); extern int text_smart_quote(void); extern void define_word(char *); extern void transform_region(int *); extern void skip_word_chars(void); extern void bskip_word_chars(void); extern void skip_non_word_chars(void); extern void bskip_non_word_chars(void); extern void jed_skip_chars (char *); extern void jed_bskip_chars (char *); extern char Jed_Word_Range[256]; extern char *jed_get_word_chars (void); jed-0.99-19/src/lineattr.c0000644002657400265740000001232011311317447014245 0ustar davisdavis/* -*- mode: C; mode: fold; -*- */ /* Copyright (c) 1992, 1998, 2000, 2002, 2003, 2004, 2005, 2006 John E. Davis * This file is part of JED editor library source. * * You may distribute this file under the terms the GNU General Public * License. See the file COPYING for more information. */ #include #include "config.h" #include "jed-feat.h" #if JED_HAS_LINE_ATTRIBUTES /*{{{ Include Files */ #include #include "jdmacros.h" #include "buffer.h" #include "lineattr.h" #include "screen.h" #include "paste.h" #include "ins.h" /*}}}*/ char *Line_Read_Only_Error = "Line is read only!"; static void set_line_readonly (int *ro) /*{{{*/ { if (*ro) CLine->flags |= JED_LINE_IS_READONLY; else CLine->flags &= ~JED_LINE_IS_READONLY; } /*}}}*/ void jed_skip_hidden_lines_forward (int *flagp) /*{{{*/ { unsigned int flag; if (*flagp) flag = JED_LINE_HIDDEN; else flag = 0; while (jed_down (1)) { if ((CLine->flags & JED_LINE_HIDDEN) != flag) break; } bol (); } /*}}}*/ void jed_skip_hidden_lines_backward (int *flagp) /*{{{*/ { unsigned int flag; if (*flagp) flag = JED_LINE_HIDDEN; else flag = 0; while (jed_up(1)) { if ((CLine->flags & JED_LINE_HIDDEN) != flag) { eol (); return; } } bol (); } /*}}}*/ static void set_line_hidden (int *hide) /*{{{*/ { if (*hide) { CLine->flags |= JED_LINE_HIDDEN; } else CLine->flags &= ~JED_LINE_HIDDEN; /* register_change (0); */ Suspend_Screen_Update = 1; } /*}}}*/ static void set_region_hidden (int *hidep) /*{{{*/ { int hide = *hidep; Line *l; if (0 == narrow_to_lines ()) return; l = CBuf->beg; while (l != NULL) { if (hide) { l->flags |= JED_LINE_HIDDEN; } else l->flags &= ~JED_LINE_HIDDEN; l = l->next; } widen (); touch_screen (); } /*}}}*/ static int is_line_hidden (void) /*{{{*/ { return (0 != (CLine->flags & JED_LINE_HIDDEN)); } /*}}}*/ SLang_Intrin_Fun_Type JedLine_Intrinsics[] = /*{{{*/ { MAKE_INTRINSIC_I("set_line_readonly", set_line_readonly, VOID_TYPE), /* Prototype: Void set_line_readonly (Integer flag); * This function may be used to turn on or off the read-only state of the * current line. If the integer parameter @flag@ is non-zero, the line * will be made read-only. If the paramter is zero, the read-only state * will be turned off. * Related Functions: @getbuf_info@ */ MAKE_INTRINSIC_I("set_line_hidden", set_line_hidden, VOID_TYPE), /* Prototype: Void set_line_hidden (Integer flag); * If the parameter @flag@ is non-zero, the current line will be given * the hidden attribute. This means that it will not be displayed. If the * parameter is zero, the hidden attribute will be turned off. * Related Functions: @set_region_hidden@, @is_line_hidden@ */ MAKE_INTRINSIC_I("set_region_hidden", set_region_hidden, VOID_TYPE), /* Prototype: Void set_region_hidden (Integer flag); * This function may be used to hide the lines in a region. If @flag@ is * non-zero, all lines in the region will be hidden. If it is zero, the * lines in the region will be made visible. * Related Functions: @set_line_hidden@, @is_line_hidden@, @skip_hidden_lines_forward@ */ MAKE_INTRINSIC("is_line_hidden", is_line_hidden, INT_TYPE, 0), /* Prototype: Integer is_line_hidden (); * This function returns a non-zero value if the current line is hidden. It * will return zero if the current line is visible. * Related Functions: @set_line_hidden@ */ MAKE_INTRINSIC_I("skip_hidden_lines_backward", jed_skip_hidden_lines_backward, VOID_TYPE), /* Prototype: Void skip_hidden_lines_backward (Integer type); * This function may be used to move backward across either hidden or non-hidden * lines depending upon whether the parameter @type@ is non-zero or zero. * If @type@ is non-zero, the Point is moved backward across hidden lines * until a visible line is reached. If @type@ is zero, visible lines will * be skipped instead. If the top of the buffer is reached before the * appropriate line is reached, the Point will be left there. * * Note: The functions @up@ and @down@ are insensitive to whether or not * a line is hidden. * Related Functions: @skip_hidden_lines_forward@, @is_line_hidden@ */ MAKE_INTRINSIC_I("skip_hidden_lines_forward", jed_skip_hidden_lines_forward, VOID_TYPE), /* Prototype: Void skip_hidden_lines_forward (Integer type); * This function may be used to move forward across either hidden or non-hidden * lines depending upon whether the parameter @type@ is non-zero or zero. * If @type@ is non-zero, the Point is moved forward across hidden lines * until a visible line is reached. If @type@ is zero, visible lines will * be skipped instead. If the end of the buffer is reached before the * appropriate line is reached, the Point will be left there. * * Note: The functions @up@ and @down@ are insensitive to whether or not * a line is hidden. * Related Functions: @skip_hidden_lines_backward@, @is_line_hidden@ */ MAKE_INTRINSIC(NULL,NULL,0,0) }; /*}}}*/ #endif /* JED_HAS_LINE_ATTRIBUTES */ jed-0.99-19/src/dfasyntx.h0000644002657400265740000000027611311317447014277 0ustar davisdavis#ifndef JED_DFA_SYNTAX_H_ #define JED_DFA_SYNTAX_H_ typedef struct Highlight Highlight; extern int jed_init_dfa_syntax (void); extern void jed_dfa_free_highlight_table (Highlight *); #endif jed-0.99-19/src/buffer.c0000644002657400265740000010050511311317447013677 0ustar davisdavis/* -*- mode: C; mode: fold; -*- */ /* Copyright (c) 1992, 1998, 2000, 2002, 2003, 2004, 2005, 2006 John E. Davis * This file is part of JED editor library source. * * You may distribute this file under the terms the GNU General Public * License. See the file COPYING for more information. */ #include "config.h" #include "jed-feat.h" /*{{{ Include Files */ #include #include #if defined (__MSDOS__) || defined (__os2_16__) # include # ifndef __MINGW32__ # include # endif #endif #include #include #include "buffer.h" #include "window.h" #include "file.h" #include "ins.h" #include "misc.h" #include "paste.h" #include "sysdep.h" #include "cmds.h" #include "indent.h" #if JED_HAS_SUBPROCESSES #include "jprocess.h" #endif /*}}}*/ typedef struct /*{{{*/ { jmp_buf b; } /*}}}*/ jmp_buf_struct; extern jmp_buf_struct Jump_Buffer, *Jump_Buffer_Ptr; typedef struct Buffer_List_Type /*{{{*/ { Buffer *buf; struct Buffer_List_Type *next; } /*}}}*/ Buffer_List_Type; Buffer_List_Type *Buffer_Stack; /* a filo */ #ifndef ULONG_MAX #define MAX_LONG (0xFFFFFFFFL | (0xFFFFFFFFL << (sizeof(long) / 8))) #else #define MAX_LONG ULONG_MAX #endif Buffer *CBuf; Line *CLine; Buffer_Local_Type Buffer_Local = /*{{{*/ { 8, 0, 0, 72 }; /*}}}*/ int Number_One = 1; /* these should be const but */ int Number_Zero = 0; /* some compilers complain */ int Number_Two = 2; int Number_Ten = 10; char *Read_Only_Error = (char *) "Buffer is read only!"; unsigned int LineNum = 1; unsigned int Max_LineNum; int Point = 0; static void delete_buffer_hooks (Jed_Buffer_Hook_Type *); void jed_set_point (int point) { if (point > CLine->len) point = CLine->len; if (point < 0) point = 0; Point = point; } /* move point to top of buffer */ int bob() /*{{{*/ { CLine = CBuf->beg; Point = 0; LineNum = 1; return(1); } /*}}}*/ int eob() /* point to end of buffer */ /*{{{*/ { CLine = CBuf->end; LineNum = Max_LineNum; if (CLine == NULL) { Point = 0; return(0); } if (LINE_HAS_NEWLINE(CLine) && (CBuf != MiniBuffer)) Point = CLine->len - 1; else Point = CLine->len; return 1; } /*}}}*/ int bol(void) /*{{{*/ { Point = 0; Goal_Column = 1; return(1); } /*}}}*/ int eol (void) /*{{{*/ { if (CLine == NULL) { Point = 0; return 1; } if (LINE_HAS_NEWLINE(CLine) && (CBuf != MiniBuffer)) Point = CLine->len - 1; else Point = CLine->len; return 1; } /*}}}*/ int bobp (void) /* returns 1 if top line of buffer, 0 otherwise */ /*{{{*/ { return ((CBuf->beg == CLine) && (Point == 0)); } /*}}}*/ int eolp (void) /*{{{*/ { int len; if ((CLine == NULL) || (0 == (len = CLine->len))) return 1; if (Point < len - 1) return 0; if (CBuf == MiniBuffer) return (Point >= len); /* Point is either len or len - 1. If it is len-1, then we are at the * end of the line only if the line ends with \n. */ if (LINE_HAS_NEWLINE(CLine) || (Point == len)) return 1; Point = len - 1; return 0; } /*}}}*/ int eobp (void) /*{{{*/ { return ((CLine == CBuf->end) && eolp ()); } /*}}}*/ int bolp (void) /*{{{*/ { return (Point == 0); } /*}}}*/ /* Attempt to goback n lines, return actual number. */ unsigned int jed_up (unsigned int n) /*{{{*/ { unsigned int i = 0; if (n == 0) return 0; while (i < n) { Line *prev = CLine->prev; /* Why would prev->len be 0 ??? */ while ((prev != NULL) && (prev->len == 0)) prev = prev->prev; if (prev == NULL) break; i++; CLine = prev; } LineNum -= i; if (i) eol (); return i; } /*}}}*/ unsigned int jed_down (unsigned int n) /*{{{*/ { unsigned int i = 0; while (i < n) { Line *next = CLine->next; if (next == NULL) break; CLine = next; i++; } LineNum += i; if (i) bol (); return i; } /*}}}*/ unsigned char *jed_multibyte_chars_forward (unsigned char *p, unsigned char *pmax, unsigned int n, unsigned int *dn, int ignore_combining) { (void) ignore_combining; #if JED_HAS_UTF8_SUPPORT if (Jed_UTF8_Mode == 0) { #endif if (p + n > pmax) n = pmax - p; p += n; if (dn != NULL) *dn = n; return p; #if JED_HAS_UTF8_SUPPORT } return SLutf8_skip_chars (p, pmax, n, dn, ignore_combining); #endif } unsigned char *jed_multibyte_chars_backward (unsigned char *pmin, unsigned char *p, unsigned int n, unsigned int *dn, int ignore_combining) { (void) ignore_combining; #if JED_HAS_UTF8_SUPPORT if (Jed_UTF8_Mode == 0) { #endif if (pmin + n > p) n = p - pmin; p -= n; if (dn != NULL) *dn = n; return p; #if JED_HAS_UTF8_SUPPORT } return SLutf8_bskip_chars (pmin, p, n, dn, ignore_combining); #endif } int jed_multibyte_charcasecmp (unsigned char **ap, unsigned char *amax, unsigned char **bp, unsigned char *bmax) { SLuchar_Type *a, *b; SLwchar_Type cha, chb; a = *ap; b = *bp; if ((a >= amax) || (b >= bmax)) return 0; #if JED_HAS_UTF8_SUPPORT if (Jed_UTF8_Mode) { unsigned int na, nb; int aok, bok; aok = (NULL != SLutf8_decode (a, amax, &cha, &na)); bok = (NULL != SLutf8_decode (b, bmax, &chb, &nb)); *ap = a + na; *bp = b + nb; if (aok && bok) { cha = SLwchar_toupper (cha); chb = SLwchar_toupper (chb); } else if (aok) return 1; else if (bok) return -1; # if SLANG_VERSION < 20005 /* Earlier versions of SLutf8_decode did not set the value of the * SLwchar_Type arg to the byte-value */ cha = *a; chb = *b; # endif if (cha > chb) return 1; if (cha == chb) return 0; return -1; } #endif *ap = a+1; *bp = b+1; if ((*a == *b) || ((cha = UPPER_CASE(*a)) == (chb = UPPER_CASE(*b)))) return 0; if (cha > chb) return 1; return -1; } /* The buffer is required to be at least JED_MAX_MULTIBYTE_SIZE bytes wide. * This routine does not \0 terminate the buffer. */ unsigned char *jed_wchar_to_multibyte (SLwchar_Type c, unsigned char *buf) { #if JED_HAS_UTF8_SUPPORT if (Jed_UTF8_Mode && (c >= 0x80)) { unsigned char *b = SLutf8_encode (c, buf, JED_MAX_MULTIBYTE_SIZE); if (b == NULL) SLang_verror (SL_Unicode_Error, "Unable to convert 0x%lX to UTF-8", (unsigned long)c); return b; } #endif *buf++ = c; return buf; } int jed_what_char (SLwchar_Type *w) /*{{{*/ { #if JED_HAS_UTF8_SUPPORT SLuchar_Type *p, *pmax; if (eobp ()) { *w = 0; return -1; } p = CLine->data + Point; if (Jed_UTF8_Mode == 0) { *w = (SLwchar_Type) *p; return 0; } pmax = SLutf8_skip_char (p, CLine->data + CLine->len); if (NULL == SLutf8_decode (p, pmax, w, NULL)) { if (p < pmax) *w = (SLwchar_Type) *p; else *w = 0; return -1; } return 0; #else if (eobp ()) return -1; *w = (SLwchar_Type) *(CLine->data + Point); return 0; #endif } /*}}}*/ void jed_count_chars (void) /*{{{*/ { unsigned long n = 0, m = 0; char buf[256]; SLwchar_Type w; Line *l = CBuf->beg; while (l != NULL) { n += l->len; l = l->next; } l = CBuf->beg; while (l != CLine) { m += l->len; l = l->next; } m += Point + 1; if (eobp ()) *buf = 0; else { if (-1 == jed_what_char (&w)) sprintf (buf, "-<%0X>, ", (int) w); else { SLuchar_Type *p, *p1, *pmax; int skip_combining = 0; p = CLine->data + Point; if (*p == 0) { p = (SLuchar_Type *) "^@"; pmax = p + 2; skip_combining = 1; } else pmax = jed_multibyte_chars_forward (p, CLine->data + CLine->len, 1, NULL, 1); buf[0] = '\''; strncpy (buf + 1, (char *)p, pmax - p); p1 = (SLuchar_Type *) (buf + 1 + (pmax - p)); sprintf ((char *)p1, "'=%ld/0x%lX/%#lo", (long)w, (unsigned long)w, (unsigned long)w); /* Check for combining */ if ((skip_combining == 0) && Jed_UTF8_Mode) { unsigned int dn; unsigned int count = 1; p = SLutf8_decode (p, pmax, &w, &dn); /* skip first */ while ((p != NULL) && (p < pmax) && (count < SLSMG_MAX_CHARS_PER_CELL)) { p = SLutf8_decode (p, pmax, &w, &dn); if (p != NULL) sprintf (buf + strlen(buf), " + 0x%lX", (long)w); count++; } } } } sprintf (buf + strlen (buf), ", point %lu of %lu", m, n); SLang_push_string(buf); } /*}}}*/ unsigned char *jed_eol_position (Line *l) { unsigned char *p = l->data + l->len; if (LINE_HAS_NEWLINE(l)) p--; return p; } void jed_position_point (unsigned char *p) { if (p < CLine->data + CLine->len) { Point = p - CLine->data; if (Point < 0) Point = 0; return; } eol (); } /* The algorithm: go to Point = len - 1. Then forward a line counted as 1 */ unsigned int jed_right (unsigned int n) /*{{{*/ { unsigned int total = 0; while (1) { int len = CLine->len; unsigned char *p = CLine->data + Point; unsigned char *pmax = CLine->data + len; int has_newline = LINE_HAS_NEWLINE(CLine); unsigned int dn; if (has_newline) pmax--; p = jed_multibyte_chars_forward (p, pmax, n, &dn, 1); Point = p - CLine->data; n -= dn; total += dn; if (n == 0) return total; /* skip over the newline */ if (has_newline) { Point++; total++; n--; } if (0 == jed_down (1)) { if (has_newline && (CBuf != MiniBuffer)) { Point--; total--; } return total; } } } /*}}}*/ unsigned int jed_right_bytes (unsigned int n) { #if JED_HAS_UTF8_SUPPORT int mode = Jed_UTF8_Mode; Jed_UTF8_Mode = 0; #endif n = jed_right (n); #if JED_HAS_UTF8_SUPPORT Jed_UTF8_Mode = mode; #endif return n; } /*}}}*/ unsigned int jed_left (unsigned int n) /*{{{*/ { unsigned int total = 0; while (1) { unsigned char *pmin = CLine->data; unsigned char *p = pmin + Point; unsigned int dn; p = jed_multibyte_chars_backward (pmin, p, n, &dn, 1); total += dn; n -= dn; Point = p - pmin; if (n == 0) return total; if (0 == jed_up (1)) return total; if (LINE_HAS_NEWLINE(CLine)) { n--; total++; } } } /*}}}*/ /* assuming 8 bit bytes */ #define BUNCH_SIZE 8 * sizeof(long) static unsigned char NewLine_Buffer[1] = /*{{{*/ { '\n' }; /*}}}*/ typedef struct Bunch_Lines_Type /*{{{*/ { struct Bunch_Lines_Type *next; unsigned long flags; /* describes which are free */ Line lines[BUNCH_SIZE]; } /*}}}*/ Bunch_Lines_Type; static unsigned int Next_Free_Offset = BUNCH_SIZE; static unsigned int Last_Free_Offset; static Bunch_Lines_Type *Last_Free_Group; static Bunch_Lines_Type *Bunch_Lines; static unsigned int Number_Freed; /* amount of Lines available */ static Line *create_line_from_bunch(void) /*{{{*/ { register Bunch_Lines_Type *b, *bsave; Line *l; unsigned long flags; int count; if (Last_Free_Group != NULL) { l = &Last_Free_Group->lines[Last_Free_Offset]; flags = ((unsigned long) 1L << Last_Free_Offset); if ((Last_Free_Group->flags & flags) == 0) { exit_error("create group: internal error 1", 1); } Last_Free_Group->flags &= ~flags; Last_Free_Group = NULL; Number_Freed--; return (l); } if (Next_Free_Offset < BUNCH_SIZE) { flags = ((unsigned long) 1L << Next_Free_Offset); if ((Bunch_Lines->flags & flags) == 0) { exit_error("free group: internal error 2", 1); } Bunch_Lines->flags &= ~flags; Number_Freed--; return(&Bunch_Lines->lines[Next_Free_Offset++]); } /* search list */ b = Bunch_Lines; if (b != NULL) { b = b->next; } if ((b != NULL) && Number_Freed) { bsave = b; do { if (b->flags) { flags = b->flags; count = 0; while ((flags & 1) == 0) { flags = flags >> 1; count++; } l = &b->lines[count]; flags = (unsigned long) 1 << count; if ((b->flags & flags) == 0) { exit_error("free group: internal error 2", 1); } b->flags &= ~flags; Number_Freed--; return (l); } b = b->next; } while (b != bsave); } /* failed so now malloc new bunch */ if (NULL == (b = (Bunch_Lines_Type *) SLmalloc (sizeof(Bunch_Lines_Type)))) return NULL; if (Bunch_Lines == NULL) { Bunch_Lines = b; b->next = b; } else { b->next = Bunch_Lines->next; Bunch_Lines->next = b; Bunch_Lines = b; } b->flags = MAX_LONG; Next_Free_Offset = 1; b->flags &= ~(unsigned long) 1; Number_Freed += BUNCH_SIZE - 1; return(&b->lines[0]); } /*}}}*/ static void destroy_bunch_line(Line *l) /*{{{*/ { #ifdef _MSC_VER Line *ll; #else register Line *ll; #endif register Bunch_Lines_Type *b, *bsave, *last, *next; static Bunch_Lines_Type *slast; if (slast != NULL) last = slast; else last = Bunch_Lines; b = bsave = last; do { ll = b->lines; if ( #if defined(SIXTEEN_BIT_SYSTEM) /* stupid DOS and its memory segmentation forces me to consider segment then offset */ (FP_SEG(ll) == FP_SEG(l)) && #endif ((ll <= l) && (l < ll + BUNCH_SIZE))) { Last_Free_Offset = (unsigned int) (l - ll); if (b->flags & (1L << Last_Free_Offset)) { exit_error("free group: internal error 2", 1); } b->flags |= (unsigned long) 1L << Last_Free_Offset; /* if this whole structure is free, free it */ if (b->flags == MAX_LONG) { if (last == b) { while ((next = last->next) != b) last = next; } last->next = b->next; if (b == Bunch_Lines) { if (last == b) { last = NULL; /* last = last->next; if (last == b) last = NULL; */ } Bunch_Lines = last; Next_Free_Offset = BUNCH_SIZE; } SLfree ((char *)b); if (last == b) last = NULL; b = NULL; Number_Freed -= BUNCH_SIZE - 1; slast = last; } else { Number_Freed++; } Last_Free_Group = b; if (Bunch_Lines == NULL) goto L1; return; } last = b; b = b->next; } while (b != bsave); L1: exit_error("destroy_bunch_line: internal error 1", 1); } /*}}}*/ Line *make_line1(unsigned int size) /*{{{*/ { Line *new_line; unsigned char *data = NULL; unsigned int chunk; /* 4 byte chunks */ #if defined(SIXTEEN_BIT_SYSTEM) chunk = (size + 3) & 0xFFFCU; #else chunk = ((size + 3)) & 0xFFFFFFFCU; #endif new_line = (Line *) create_line_from_bunch(); if (new_line != NULL) { if (size == 1) { data = NewLine_Buffer; #ifdef KEEP_SPACE_INFO chunk = 1; #endif } else data = (unsigned char *) SLmalloc (chunk); /* was chunk + 1 */ } if ((new_line == NULL) || (data == NULL)) { *Error_Buffer = 0; /* this is critical */ jed_verror ("Malloc Error in make_line: requested size: %d.", size); longjmp(Jump_Buffer_Ptr->b, 1); /* exit_error(buff); */ } new_line->data = data; new_line->len = 0; #ifdef KEEP_SPACE_INFO new_line->space = chunk; #endif #if JED_HAS_LINE_ATTRIBUTES new_line->flags = 0; #endif return(new_line); } /*}}}*/ /* adds a new link to list of lines at current point */ unsigned char *make_line(unsigned int size) /*{{{*/ { Line *new_line; new_line = make_line1(size); /* if CLine is Null, then we are at the top of a NEW buffer. Make this explicit. */ if (CLine == NULL) { new_line -> prev = NULL; new_line -> next = NULL; CBuf -> beg = CBuf ->end = new_line; } else if (CLine == CBuf->end) /* at end of buffer */ { CBuf->end = new_line; new_line->next = NULL; new_line->prev = CLine; CLine->next = new_line; } else { new_line -> next = CLine -> next; if (CLine->next != NULL) CLine->next->prev = new_line; CLine->next = new_line; new_line->prev = CLine; } if (CLine == NULL) { Max_LineNum = LineNum = 1; } else { Max_LineNum++; LineNum++; } CLine = new_line; return(CLine->data); } /*}}}*/ void free_line(Line *line) /*{{{*/ { register unsigned char *dat = line->data; if (dat != NewLine_Buffer) SLfree ((char *)dat); destroy_bunch_line(line); } /*}}}*/ /* deletes the line we are on and returns the prev one. It does not * delete the top line of the buffer. Furthermore, it does not * update any marks. */ int delete_line() /*{{{*/ { Line *n, *p, *tthis; p = CLine -> prev; if (p == NULL) return(1); n = CLine -> next; tthis = CLine; if (n == NULL) { CBuf->end = p; p->next = NULL; } else { p->next = n; n->prev = p; } free_line(tthis); CLine = p; LineNum--; Max_LineNum--; return(0); } /*}}}*/ unsigned char *remake_line(unsigned int size) /*{{{*/ { unsigned char *d = CLine->data; unsigned int mask; #if defined(SIXTEEN_BIT_SYSTEM) mask = 0xFFFCu; #else mask = 0xFFFFFFFCu; #endif size = (unsigned) (size + 3) & mask; /* 4 byte chunks */ if (d == NewLine_Buffer) { if (NULL != (d = (unsigned char *) SLmalloc (size))) *d = '\n'; } else { #if 1 /* NOTE: This was #if 0. Why??? */ #ifndef KEEP_SPACE_INFO if ((((CLine->len + 3) & mask) == size) && (size + 8 < (unsigned) CLine->len))/* realloc if the new size is less than the old */ return d; #endif #endif d = (unsigned char *) SLrealloc ((char *) d, size); } if (d == NULL) { *Error_Buffer = 0; /* critical error */ jed_verror ("remake_line: realloc error!, size = %d", size); longjmp(Jump_Buffer_Ptr->b, 1); /* exit_error(buf); */ } #ifdef KEEP_SPACE_INFO CLine->space = size; #endif CLine->data = d; return(d); } /*}}}*/ void uniquely_name_buffer (Buffer *b, SLFUTURE_CONST char *trry) /*{{{*/ { Buffer *bnext; int version = 0, n; char *neew; char *name; n = strlen(trry); neew = SLmalloc (n + 12); if (neew == NULL) exit_error ("Out of memory", 0); strcpy (neew, trry); while (1) { bnext = b->next; while (bnext != b) { if ((bnext->name != NULL) && (0 == strcmp(neew, bnext->name))) break; bnext = bnext->next; } if (bnext == b) { name = SLang_create_slstring (neew); if (name == NULL) exit_error ("Out of memory", 0); SLang_free_slstring (b->name); b->name = name; break; } version++; sprintf (neew + n, "<%d>", version); } SLfree (neew); } /*}}}*/ /* make a buffer and insert it in the list */ Buffer *make_buffer (char *name, char *dir, char *file) /*{{{*/ { Buffer *newB; newB = (Buffer *) jed_malloc0 (sizeof(Buffer)); if (newB == NULL) exit_error("Out of memory", 0); newB->keymap = Global_Map; jed_set_buffer_ctime (newB); newB->local_vars.tab = Jed_Tab_Default; newB->local_vars.case_search = Jed_Case_Search_Default; newB->local_vars.wrap_column = Jed_Wrap_Default; if (CBuf == NULL) { newB->next = newB; newB->prev = newB; } else { newB->next = CBuf; newB->prev = CBuf->prev; CBuf->prev->next = newB; CBuf->prev = newB; } #ifdef IBMPC_SYSTEM newB->flags |= ADD_CR_ON_WRITE_FLAG; #endif newB->syntax_table = Default_Syntax_Table; buffer_filename (newB, dir, file); if ((name != NULL) || (newB->name == NULL)) { if (name == NULL) name = "*scratch*"; uniquely_name_buffer (newB, name); } return (newB); } /*}}}*/ /* if there is a window attached to this buffer, then there are problems * if we get to update() without attaching another one to it. So * beware! Always make sure CBuf is set too! kill_buffer command * takes care of this */ void delete_buffer(Buffer *buf) /*{{{*/ { Line *l,*n; Jed_Mark_Array_Type *m, *m1; if (1 != buffer_exists (buf)) return; jed_widen_whole_buffer (buf); jed_unlock_buffer_file (buf); if (buf -> beg != NULL) for (l = buf -> beg; l != NULL; l = n) { n = l -> next; free_line(l); /* SLfree( l->data); SLfree( l); */ } m = buf->mark_array; while (m != NULL) { m1 = m->next; SLfree ((char *)m); m = m1; } m = buf->spot_array; while (m != NULL) { m1 = m->next; SLfree ((char *)m); m = m1; } if (buf->user_marks != NULL) free_user_marks (buf); if (buf->undo != NULL) delete_undo_ring (buf); #if JED_HAS_BUFFER_LOCAL_VARS jed_delete_blocal_vars (buf->blocal_table); #endif #if JED_HAS_SAVE_NARROW while (buf->save_narrow != NULL) jed_free_saved_narrow (buf); #endif #if JED_HAS_COLOR_COLUMNS SLfree ((char *)buf->column_colors); #endif buf->prev->next = buf->next; buf->next->prev = buf->prev; #if JED_HAS_MENUS jed_delete_menu_bar (buf->menubar); #endif #if JED_HAS_SUBPROCESSES if (buf->subprocess) jed_kill_process (buf->subprocess - 1); #endif SLang_free_slstring (buf->dir); SLang_free_slstring (buf->file); SLfree (buf->canonical_dirfile); SLfree (buf->dirfile); SLang_free_slstring (buf->name); SLang_free_slstring (buf->mode_string); delete_buffer_hooks (buf->buffer_hooks); SLfree ((char *)buf); } /*}}}*/ void goto_line (int *np) /*{{{*/ { unsigned int n; unsigned int half1 = LineNum / 2; unsigned int half2 = (Max_LineNum + LineNum) / 2; if (*np <= 1) n = 0; else n = (unsigned int) *np; if (n < LineNum) { if (n > half1) jed_up (LineNum - n); else { bob(); if (n > 0) jed_down (n-1); } } else if (n < half2) jed_down (n - LineNum); else { eob(); if (n < Max_LineNum) jed_up (Max_LineNum - n); } bol (); } /*}}}*/ Line *dup_line(Line *l) /*{{{*/ { Line *neew; int n; unsigned char *p, *q; #ifdef KEEP_SPACE_INFO n = l->space; #else n = l->len; #endif neew = (Line *) SLmalloc (sizeof(Line)); if ((neew == NULL) || (NULL == (neew->data = (unsigned char *) SLmalloc (n)))) { exit_error("Out of memory", 0); } neew->next = l->next; neew->prev = l->prev; neew->len = n; #ifdef KEEP_SPACE_INFO neew->space = l->space; #endif p = neew->data; q = l->data; while (n--) *p++ = *q++; return(neew); } /*}}}*/ Buffer *find_buffer(char *name) /*{{{*/ { Buffer *b; b = CBuf; do { if (!strcmp(b->name, name)) return(b); b = b->next; } while(b != CBuf); #if !JED_FILE_PRESERVE_CASE b = CBuf; do { if (!jed_case_strcmp (b->name, name)) return(b); b = b->next; } while(b != CBuf); #endif return(NULL); } /*}}}*/ int buffer_exists(Buffer *b) /*{{{*/ { Buffer *c = CBuf; if (b == NULL) return 0; do { if (b == c) return 1; c = c->next; } while (c != CBuf); return 0; } /*}}}*/ int switch_to_buffer(Buffer *buf) /*{{{*/ { /* save this buffer position */ CBuf->line = CLine; CBuf->point = Point; CBuf->linenum = LineNum; CBuf->max_linenum = Max_LineNum; /* local variables */ SLMEMCPY ((char *) &CBuf->local_vars, (char *) &Buffer_Local, sizeof (Buffer_Local_Type)); if (buf == CBuf) return(0); #if 0 buf->prev->next = buf->next; buf->next->prev = buf->prev; buf->next = CBuf; buf->prev = CBuf->prev; CBuf->prev->next = buf; CBuf->prev = buf; #endif /* now restore new buffer */ CBuf = buf; CLine = CBuf->line; Point = CBuf->point; /* Buffer local variables */ SLMEMCPY ((char *) &Buffer_Local, (char *) &CBuf->local_vars, sizeof (Buffer_Local_Type)); LineNum = CBuf->linenum; Max_LineNum = CBuf->max_linenum; if (CLine == NULL) { make_line(25); Point = 0; } CBuf->line = CLine; CBuf->point = Point; jed_set_umask (CBuf->umask); return(1); } /*}}}*/ #ifdef REAL_UNIX_SYSTEM static Buffer *find_file_buffer_via_inode (char *file) { int device, inode; Buffer *b; if (-1 == jed_get_inode_info (file, &device, &inode)) return NULL; if ((device == -1) || (inode == -1)) return NULL; b = CBuf; do { if ((inode == b->inode) && (device == b->device)) return b; b = b->next; } while (b != CBuf); return NULL; } #endif Buffer *find_file_buffer(char *file) /*{{{*/ { Buffer *b; file = jed_get_canonical_pathname (file); if (file == NULL) return NULL; b = CBuf; do { if ((b->canonical_dirfile != NULL) # if JED_FILE_PRESERVE_CASE && (0 == strcmp(b->canonical_dirfile, file)) # else && (0 == jed_case_strcmp (b->canonical_dirfile, file)) # endif ) { SLfree (file); return b; } b = b->next; } while (b != CBuf); # ifdef REAL_UNIX_SYSTEM if (NULL != (b = find_file_buffer_via_inode (file))) { if (0 != strcmp (file, b->canonical_dirfile)) jed_vmessage (0, "%s and %s are the same", file, b->canonical_dirfile); SLfree (file); return b; } # endif SLfree (file); return NULL; } /*}}}*/ /* take a dir and a filename, expand them then put in buffer structure */ void buffer_filename(Buffer *b, SLFUTURE_CONST char *dir, SLFUTURE_CONST char *file) /*{{{*/ { unsigned int dirlen; char *dirfile; char *canonical_dirfile; if (dir == NULL) dir = jed_get_cwd (); if (file == NULL) { file = extract_file (dir); dirlen = (unsigned int) (file - dir); } else dirlen = strlen (dir); dirfile = jed_dir_file_merge (dir, file); if (dirfile != NULL) canonical_dirfile = jed_get_canonical_pathname (dirfile); else canonical_dirfile = NULL; SLfree (b->dirfile); SLfree (b->canonical_dirfile); SLang_free_slstring (b->file); SLang_free_slstring (b->dir); if ((NULL == (b->dirfile = dirfile)) || (NULL == (b->canonical_dirfile = canonical_dirfile)) || (NULL == (b->file = SLang_create_slstring (file))) || (NULL == (b->dir = SLang_create_nslstring (dir, dirlen)))) { exit_error ("Out of memory", 0); } #ifdef REAL_UNIX_SYSTEM jed_get_inode_info (b->canonical_dirfile, &b->device, &b->inode); #endif if (*file) { uniquely_name_buffer (b, file); jed_set_buffer_ctime (b); } } /*}}}*/ /* This kills all undo information! */ int erase_buffer (void) /*{{{*/ { Line *beg, *tthis; if (-1 == jed_prepare_for_modification (0)) return -1; /* CLine = CBuf->end; */ beg = CBuf->beg; bob(); CLine = CLine->next; LineNum++; Suspend_Screen_Update = 1; while (CLine != NULL) { tthis = CLine; beg->next = tthis->next; tthis->prev = beg; jed_update_marks(LDELETE, 1); CLine = tthis->next; Max_LineNum--; free_line(tthis); } CLine = CBuf->beg; LineNum = 1; Point = 0; jed_update_marks(CDELETE, CLine->len); CLine->len = 0; /* CLine->next = NULL; */ if (CBuf->undo != NULL) delete_undo_ring(CBuf); CBuf->undo = NULL; CBuf->end = CLine; touch_screen_for_buffer(CBuf); return(1); } /*}}}*/ void mark_buffer_modified (Buffer *b, int modif, int with_lock) /*{{{*/ { if (modif) { if (b->flags & BUFFER_MODIFIED) return; #if 0 b->m_time = sys_time(); #endif b->flags |= BUFFER_MODIFIED; if (with_lock) (void) jed_lock_buffer_file (b); return; } b->flags &= ~BUFFER_MODIFIED; if (with_lock) jed_unlock_buffer_file (b); } /*}}}*/ void jed_set_buffer_flags (Buffer *b, unsigned int flags) { unsigned int modif; #if 1 if (((flags & FILE_MODIFIED) == 0) && (b->flags & FILE_MODIFIED)) jed_set_buffer_ctime (b); #endif modif = flags & BUFFER_MODIFIED; b->flags &= BUFFER_MODIFIED; b->flags |= flags & ~BUFFER_MODIFIED; mark_buffer_modified (b, (int) modif, 1); #if 0 if ((b->flags & BUFFER_MODIFIED) != (flags & BUFFER_MODIFIED)) mark_buffer_modified (b, flags & BUFFER_MODIFIED, 1); b->flags = flags; #endif } void check_line() /*{{{*/ { if ((CLine->len == 1) && (*CLine->data == '\n') && (CLine->data != NewLine_Buffer)) { SLfree ((char *)CLine->data); CLine->data = NewLine_Buffer; #ifdef KEEP_SPACE_INFO CLine->space = 1; #endif } } /*}}}*/ static SLang_Name_Type **find_buffer_hook (Jed_Buffer_Hook_Type *b, char *s) { if (b == NULL) return NULL; if (0 == strcmp("par_sep", s)) return &b->par_sep; if (0 == strcmp("format_paragraph_hook", s)) return &b->format_paragraph_hook; if (0 == strcmp("mark_paragraph_hook", s)) return &b->mark_paragraph_hook; if (0 == strcmp("forward_paragraph_hook", s)) return &b->forward_paragraph_hook; if (0 == strcmp("backward_paragraph_hook", s)) return &b->backward_paragraph_hook; if (0 == strcmp("indent_hook", s)) return &b->indent_hook; if (0 == strcmp("wrap_hook", s)) return &b->wrap_hook; if (0 == strcmp("wrapok_hook", s)) return &b->wrapok_hook; if (0 == strcmp("newline_indent_hook", s)) return &b->newline_indent_hook; if (0 == strcmp("bob_eob_error_hook", s)) return &b->bob_eob_error_hook; #ifdef HAS_MOUSE if (0 == strcmp("mouse_down", s)) return &b->mouse_down_hook; if (0 == strcmp("mouse_up", s)) return &b->mouse_up_hook; if (0 == strcmp("mouse_drag", s)) return &b->mouse_drag_hook; # if JED_HAS_MULTICLICK if (0 == strcmp("mouse_2click", s)) return &b->mouse_2click_hook; if (0 == strcmp("mouse_3click", s)) return &b->mouse_3click_hook; # endif #endif if (0 == strcmp("update_hook", s)) return &b->update_hook; if (0 == strcmp("color_region_hook", s)) return &b->color_region_hook; return NULL; } int jed_unset_buffer_hook (Buffer *buffer, char *name) { Jed_Buffer_Hook_Type *b; if ((buffer == NULL) || (NULL == (b = buffer->buffer_hooks))) return -1; if ((name != NULL) && (*name != 0)) { SLang_Name_Type **nt = find_buffer_hook (b, name); if (nt == NULL) return -1; *nt = NULL; return 0; } memset ((char *)b, 0, sizeof (Jed_Buffer_Hook_Type)); return 0; } int jed_set_buffer_hook (Buffer *buffer, char *name, SLang_Name_Type *nt) { SLang_Name_Type **ntp; Jed_Buffer_Hook_Type *b; if (buffer == NULL) return -1; b = buffer->buffer_hooks; if (b == NULL) { b = (Jed_Buffer_Hook_Type *)SLmalloc (sizeof (Jed_Buffer_Hook_Type)); if (b == NULL) return -1; memset ((char *) b, 0, sizeof (Jed_Buffer_Hook_Type)); buffer->buffer_hooks = b; } ntp = find_buffer_hook (b, name); if (ntp == NULL) return -1; SLang_free_function (*ntp); *ntp = nt; return 0; } SLang_Name_Type *jed_get_buffer_hook (Buffer *buffer, char *name) { SLang_Name_Type **ntp; Jed_Buffer_Hook_Type *b; if (buffer == NULL) return NULL; b = buffer->buffer_hooks; if ((b == NULL) || (NULL == (ntp = find_buffer_hook (b, name))) || (*ntp == NULL)) return NULL; return SLang_copy_function (*ntp); } static void delete_buffer_hooks (Jed_Buffer_Hook_Type *h) { if (h == NULL) return; if (h->mark_paragraph_hook != NULL) SLang_free_function (h->mark_paragraph_hook); if (h->format_paragraph_hook != NULL) SLang_free_function (h->format_paragraph_hook); if (h->forward_paragraph_hook != NULL) SLang_free_function (h->forward_paragraph_hook); if (h->backward_paragraph_hook != NULL) SLang_free_function (h->backward_paragraph_hook); if (h->par_sep != NULL) SLang_free_function (h->par_sep); if (h->indent_hook != NULL) SLang_free_function (h->indent_hook); if (h->newline_indent_hook != NULL) SLang_free_function (h->newline_indent_hook); if (h->wrap_hook != NULL) SLang_free_function (h->wrap_hook); if (h->wrapok_hook != NULL) SLang_free_function (h->wrapok_hook); if (h->bob_eob_error_hook != NULL) SLang_free_function (h->bob_eob_error_hook); #ifdef HAS_MOUSE if (h->mouse_down_hook != NULL) SLang_free_function (h->mouse_down_hook); if (h->mouse_up_hook != NULL) SLang_free_function (h->mouse_up_hook); if (h->mouse_drag_hook != NULL) SLang_free_function (h->mouse_drag_hook); # if JED_HAS_MULTICLICK if (h->mouse_2click_hook != NULL) SLang_free_function (h->mouse_2click_hook); if (h->mouse_3click_hook != NULL) SLang_free_function (h->mouse_3click_hook); # endif #endif if (h->update_hook != NULL) SLang_free_function (h->update_hook); if (h->color_region_hook != NULL) SLang_free_function (h->color_region_hook); SLfree ((char *) h); } jed-0.99-19/src/xkeys.c0000644002657400265740000010560511311317447013577 0ustar davisdavis/* Copyright (c) 1992, 1998, 2000, 2002, 2003, 2004, 2005, 2006 John E. Davis * This file is part of JED editor library source. * * You may distribute this file under the terms the GNU General Public * License. See the file COPYING for more information. */ /* xkeys.c */ /* The first character is the length of the string */ #define MAX_KEYSYM_STRING_LEN 8 typedef char KeySym_Mapping_Type[MAX_KEYSYM_STRING_LEN + 1]; static KeySym_Mapping_Type KeySym_Map_FF[256] = { "\004\033[3~", /* 0xFF00 Remove */ "", /* 0xFF01 */ "", /* 0xFF02 */ "", /* 0xFF03 */ "", /* 0xFF04 */ "", /* 0xFF05 */ "", /* 0xFF06 */ "", /* 0xFF07 */ "\001\177", /* 0xFF08 XK_BackSpace */ "\001\t", /* 0xFF09 XK_Tab */ "\001\n", /* 0xFF0A XK_Linefeed */ "", /* 0xFF0B XK_Clear */ "", /* 0xFF0C */ "\001\r", /* 0xFF0D XK_Return */ "", /* 0xFF0E */ "", /* 0xFF0F */ "", /* 0xFF10 */ "", /* 0xFF11 */ "", /* 0xFF12 */ "", /* 0xFF13 XK_Pause */ "", /* 0xFF14 XK_Scroll_Lock */ "", /* 0xFF15 */ "", /* 0xFF16 */ "", /* 0xFF17 */ "", /* 0xFF18 */ "", /* 0xFF19 */ "", /* 0xFF1A */ "\001\033", /* 0xFF1B XK_Escape */ "", /* 0xFF1C */ "", /* 0xFF1D */ "", /* 0xFF1E */ "", /* 0xFF1F */ "", /* 0xFF20 XK_Multi_key */ "", /* 0xFF21 XK_Kanji */ "", /* 0xFF22 XK_Muhenkan */ "", /* 0xFF23 XK_Henkan_Mode XK_Henkan */ "", /* 0xFF24 XK_Romaji */ "", /* 0xFF25 XK_Hiragana */ "", /* 0xFF26 XK_Katakana */ "", /* 0xFF27 XK_Hiragana_Katakana */ "", /* 0xFF28 XK_Zenkaku */ "", /* 0xFF29 XK_Hankaku */ "", /* 0xFF2A XK_Zenkaku_Hankaku */ "", /* 0xFF2B XK_Touroku */ "", /* 0xFF2C XK_Massyo */ "", /* 0xFF2D XK_Kana_Lock */ "", /* 0xFF2E XK_Kana_Shift */ "", /* 0xFF2F XK_Eisu_Shift */ "", /* 0xFF30 XK_Eisu_toggle */ "", /* 0xFF31 */ "", /* 0xFF32 */ "", /* 0xFF33 */ "", /* 0xFF34 */ "", /* 0xFF35 */ "", /* 0xFF36 */ "", /* 0xFF37 */ "", /* 0xFF38 */ "", /* 0xFF39 */ "", /* 0xFF3A */ "", /* 0xFF3B */ "", /* 0xFF3C */ "", /* 0xFF3D */ "", /* 0xFF3E */ "", /* 0xFF3F */ "", /* 0xFF40 */ "", /* 0xFF41 */ "", /* 0xFF42 */ "", /* 0xFF43 */ "", /* 0xFF44 */ "", /* 0xFF45 */ "", /* 0xFF46 */ "", /* 0xFF47 */ "", /* 0xFF48 */ "", /* 0xFF49 */ "", /* 0xFF4A */ "", /* 0xFF4B */ "", /* 0xFF4C */ "", /* 0xFF4D */ "", /* 0xFF4E */ "", /* 0xFF4F */ "\004\033[1~", /* 0xFF50 XK_Home */ "\003\033[D", /* 0xFF51 XK_Left */ "\003\033[A", /* 0xFF52 XK_Up */ "\003\033[C", /* 0xFF53 XK_Right */ "\003\033[B", /* 0xFF54 XK_Down */ "\004\033[5~", /* 0xFF55 XK_Prior */ "\004\033[6~", /* 0xFF56 XK_Next */ "\004\033[4~", /* 0xFF57 XK_End */ "\001\001", /* 0xFF58 XK_Begin */ "", /* 0xFF59 */ "", /* 0xFF5A */ "", /* 0xFF5B */ "", /* 0xFF5C */ "", /* 0xFF5D */ "", /* 0xFF5E */ "", /* 0xFF5F */ "\004\033[4~", /* 0xFF60 XK_Select */ "", /* 0xFF61 XK_Print */ "", /* 0xFF62 XK_Execute */ "\004\033[2~", /* 0xFF63 XK_Insert */ "", /* 0xFF64 */ "\001\037", /* 0xFF65 XK_Undo ^_ */ "", /* 0xFF66 XK_Redo */ "\005\033[29~", /* 0xFF67 XK_Menu Do */ "\004\033[1~", /* 0xFF68 XK_Find */ "\001\007", /* 0xFF69 XK_Cancel */ "\005\033[28~", /* 0xFF6A XK_Help */ "", /* 0xFF6B XK_Break */ "", /* 0xFF6C */ "", /* 0xFF6D */ "", /* 0xFF6E */ "", /* 0xFF6F */ "", /* 0xFF70 */ "", /* 0xFF71 */ "", /* 0xFF72 */ "", /* 0xFF73 */ "", /* 0xFF74 */ "", /* 0xFF75 */ "", /* 0xFF76 */ "", /* 0xFF77 */ "", /* 0xFF78 */ "", /* 0xFF79 */ "", /* 0xFF7A */ "", /* 0xFF7B */ "", /* 0xFF7C */ "", /* 0xFF7D */ "", /* 0xFF7E */ "", /* 0xFF7F XK_Num_Lock */ "", /* 0xFF80 XK_KP_Space */ "", /* 0xFF81 */ "", /* 0xFF82 */ "", /* 0xFF83 */ "", /* 0xFF84 */ "", /* 0xFF85 */ "", /* 0xFF86 */ "", /* 0xFF87 */ "", /* 0xFF88 */ "", /* 0xFF89 XK_KP_Tab */ "", /* 0xFF8A */ "", /* 0xFF8B */ "", /* 0xFF8C */ "\003\033OM", /* 0xFF8D XK_KP_Enter */ "", /* 0xFF8E */ "", /* 0xFF8F */ "", /* 0xFF90 */ "\003\033OP", /* 0xFF91 XK_KP_F1 PF1 */ "\003\033OQ", /* 0xFF92 XK_KP_F2 PF2 */ "\003\033OR", /* 0xFF93 XK_KP_F3 PF3 */ "\003\033OS", /* 0xFF94 XK_KP_F4 PF4 */ "\003\033Ow", /* 0xFF95 XK_KP_Home */ "\003\033Ot", /* 0xFF96 XK_KP_Left */ "\003\033Ox", /* 0xFF97 XK_KP_Up */ "\003\033Ov", /* 0xFF98 XK_KP_Right */ "\003\033Or", /* 0xFF99 XK_KP_Down */ "\003\033Oy", /* 0xFF9A XK_KP_Prior */ "\003\033Os", /* 0xFF9B XK_KP_Next */ "\003\033Oq", /* 0xFF9C XK_KP_End */ "\003\033Ou", /* 0xFF9D XK_KP_Begin */ "\003\033Op", /* 0xFF9E XK_KP_Insert */ "\003\033On", /* 0xFF9F XK_KP_Delete */ "", /* 0xFFA0 */ "", /* 0xFFA1 */ "", /* 0xFFA2 */ "", /* 0xFFA3 */ "", /* 0xFFA4 */ "", /* 0xFFA5 */ "", /* 0xFFA6 */ "", /* 0xFFA7 */ "", /* 0xFFA8 */ "", /* 0xFFA9 */ "\001*", /* 0xFFAA XK_KP_Multiply */ "\001+", /* 0xFFAB XK_KP_Add */ "\003\033Ol", /* 0xFFAC XK_KP_Separator KP , */ "\003\033Om", /* 0xFFAD XK_KP_Subtract KP - */ "\003\033On", /* 0xFFAE XK_KP_Decimal KP . */ "\001/", /* 0xFFAF XK_KP_Divide */ "\003\033Op", /* 0xFFB0 XK_KP_0 */ "\003\033Oq", /* 0xFFB1 XK_KP_1 */ "\003\033Or", /* 0xFFB2 XK_KP_2 */ "\003\033Os", /* 0xFFB3 XK_KP_3 */ "\003\033Ot", /* 0xFFB4 XK_KP_4 */ "\003\033Ou", /* 0xFFB5 XK_KP_5 */ "\003\033Ov", /* 0xFFB6 XK_KP_6 */ "\003\033Ow", /* 0xFFB7 XK_KP_7 */ "\003\033Ox", /* 0xFFB8 XK_KP_8 */ "\003\033Oy", /* 0xFFB9 XK_KP_9 */ "", /* 0xFFBA */ "", /* 0xFFBB */ "", /* 0xFFBC */ "\001=", /* 0xFFBD XK_KP_Equal */ "\005\033[11~", /* 0xFFBE XK_F1 */ /* xterm convention */ "\005\033[12~", /* 0xFFBF XK_F2 */ /* xterm convention */ "\005\033[13~", /* 0xFFC0 XK_F3 */ /* xterm convention */ "\005\033[14~", /* 0xFFC1 XK_F4 */ /* xterm convention */ "\005\033[15~", /* 0xFFC2 XK_F5 */ /* xterm convention */ "\005\033[17~", /* 0xFFC3 XK_F6 */ "\005\033[18~", /* 0xFFC4 XK_F7 */ "\005\033[19~", /* 0xFFC5 XK_F8 */ "\005\033[20~", /* 0xFFC6 XK_F9 */ "\005\033[21~", /* 0xFFC7 XK_F10 */ "\005\033[23~", /* 0xFFC8 XK_F11 XK_L1 */ "\005\033[24~", /* 0xFFC9 XK_F12 XK_L2 */ "\005\033[25~", /* 0xFFCA XK_F13 XK_L3 */ "\005\033[26~", /* 0xFFCB XK_F14 XK_L4 */ "\005\033[28~", /* 0xFFCC XK_F15 XK_L5 */ "\005\033[29~", /* 0xFFCD XK_F16 XK_L6 */ "\005\033[31~", /* 0xFFCE XK_F17 XK_L7 */ "\005\033[32~", /* 0xFFCF XK_F18 XK_L8 */ "\005\033[33~", /* 0xFFD0 XK_F19 XK_L9 */ "\005\033[34~", /* 0xFFD1 XK_F20 XK_L10 */ "\005\033[35~", /* 0xFFD2 XK_F21 XK_R1 */ "\005\033[36~", /* 0xFFD3 XK_F22 XK_R2 */ "\005\033[37~", /* 0xFFD4 XK_F23 XK_R3 */ "\005\033[38~", /* 0xFFD5 XK_F24 XK_R4 */ "\005\033[39~", /* 0xFFD6 XK_F25 XK_R5 */ "\005\033[40~", /* 0xFFD7 XK_F26 XK_R6 */ "\005\033[41~", /* 0xFFD8 XK_F27 XK_R7 */ "\005\033[42~", /* 0xFFD9 XK_F28 XK_R8 */ "\005\033[43~", /* 0xFFDA XK_F29 XK_R9 */ "\005\033[44~", /* 0xFFDB XK_F30 XK_R10 */ "\005\033[45~", /* 0xFFDC XK_F31 XK_R11 */ "\005\033[46~", /* 0xFFDD XK_F32 XK_R12 */ "\005\033[47~", /* 0xFFDE XK_R13 XK_F33 */ "\005\033[48~", /* 0xFFDF XK_F34 XK_R14 */ "\005\033[49~", /* 0xFFE0 XK_F35 XK_R15 */ "", /* 0xFFE1 XK_Shift_L XK_Shift_L */ "", /* 0xFFE2 XK_Shift_R */ "", /* 0xFFE3 XK_Control_L */ "", /* 0xFFE4 XK_Control_R */ "", /* 0xFFE5 XK_Caps_Lock */ "", /* 0xFFE6 XK_Shift_Lock */ "", /* 0xFFE7 XK_Meta_L */ "", /* 0xFFE8 XK_Meta_R */ "", /* 0xFFE9 XK_Alt_L */ "", /* 0xFFEA XK_Alt_R */ "", /* 0xFFEB XK_Super_L */ "", /* 0xFFEC XK_Super_R */ "", /* 0xFFED XK_Hyper_L */ "", /* 0xFFEE XK_Hyper_R */ "", /* 0xFFEF */ "", /* 0xFFF0 */ "", /* 0xFFF1 */ "", /* 0xFFF2 */ "", /* 0xFFF3 */ "", /* 0xFFF4 */ "", /* 0xFFF5 */ "", /* 0xFFF6 */ "", /* 0xFFF7 */ "", /* 0xFFF8 */ "", /* 0xFFF9 */ "", /* 0xFFFA */ "", /* 0xFFFB */ "", /* 0xFFFC */ "", /* 0xFFFD */ "", /* 0xFFFE */ "\001\177" /* 0xFFFF XK_Delete */ }; static KeySym_Mapping_Type Shift_KeySym_Map_FF[256] = { "\004\033[3$", /* 0xFF00 Remove */ "", /* 0xFF01 */ "", /* 0xFF02 */ "", /* 0xFF03 */ "", /* 0xFF04 */ "", /* 0xFF05 */ "", /* 0xFF06 */ "", /* 0xFF07 */ "\001\177", /* 0xFF08 XK_BackSpace */ "\003\033[Z", /* 0xFF09 XK_Tab */ "\001\n", /* 0xFF0A XK_Linefeed */ "", /* 0xFF0B XK_Clear */ "", /* 0xFF0C */ "\001\r", /* 0xFF0D XK_Return */ "", /* 0xFF0E */ "", /* 0xFF0F */ "", /* 0xFF10 */ "", /* 0xFF11 */ "", /* 0xFF12 */ "", /* 0xFF13 XK_Pause */ "", /* 0xFF14 XK_Scroll_Lock */ "", /* 0xFF15 */ "", /* 0xFF16 */ "", /* 0xFF17 */ "", /* 0xFF18 */ "", /* 0xFF19 */ "", /* 0xFF1A */ "\001\033", /* 0xFF1B XK_Escape */ "", /* 0xFF1C */ "", /* 0xFF1D */ "", /* 0xFF1E */ "", /* 0xFF1F */ "", /* 0xFF20 XK_Multi_key */ "", /* 0xFF21 XK_Kanji */ "", /* 0xFF22 XK_Muhenkan */ "", /* 0xFF23 XK_Henkan_Mode XK_Henkan */ "", /* 0xFF24 XK_Romaji */ "", /* 0xFF25 XK_Hiragana */ "", /* 0xFF26 XK_Katakana */ "", /* 0xFF27 XK_Hiragana_Katakana */ "", /* 0xFF28 XK_Zenkaku */ "", /* 0xFF29 XK_Hankaku */ "", /* 0xFF2A XK_Zenkaku_Hankaku */ "", /* 0xFF2B XK_Touroku */ "", /* 0xFF2C XK_Massyo */ "", /* 0xFF2D XK_Kana_Lock */ "", /* 0xFF2E XK_Kana_Shift */ "", /* 0xFF2F XK_Eisu_Shift */ "", /* 0xFF30 XK_Eisu_toggle */ "", /* 0xFF31 */ "", /* 0xFF32 */ "", /* 0xFF33 */ "", /* 0xFF34 */ "", /* 0xFF35 */ "", /* 0xFF36 */ "", /* 0xFF37 */ "", /* 0xFF38 */ "", /* 0xFF39 */ "", /* 0xFF3A */ "", /* 0xFF3B */ "", /* 0xFF3C */ "", /* 0xFF3D */ "", /* 0xFF3E */ "", /* 0xFF3F */ "", /* 0xFF40 */ "", /* 0xFF41 */ "", /* 0xFF42 */ "", /* 0xFF43 */ "", /* 0xFF44 */ "", /* 0xFF45 */ "", /* 0xFF46 */ "", /* 0xFF47 */ "", /* 0xFF48 */ "", /* 0xFF49 */ "", /* 0xFF4A */ "", /* 0xFF4B */ "", /* 0xFF4C */ "", /* 0xFF4D */ "", /* 0xFF4E */ "", /* 0xFF4F */ "\004\033[1$", /* 0xFF50 XK_Home */ "\003\033[d", /* 0xFF51 XK_Left */ "\003\033[a", /* 0xFF52 XK_Up */ "\003\033[c", /* 0xFF53 XK_Right */ "\003\033[b", /* 0xFF54 XK_Down */ "\004\033[5$", /* 0xFF55 XK_Prior */ "\004\033[6$", /* 0xFF56 XK_Next */ "\004\033[4$", /* 0xFF57 XK_End */ "\001\001", /* 0xFF58 XK_Begin */ "", /* 0xFF59 */ "", /* 0xFF5A */ "", /* 0xFF5B */ "", /* 0xFF5C */ "", /* 0xFF5D */ "", /* 0xFF5E */ "", /* 0xFF5F */ "\004\033[4$", /* 0xFF60 XK_Select */ "", /* 0xFF61 XK_Print */ "", /* 0xFF62 XK_Execute */ "\004\033[2$", /* 0xFF63 XK_Insert */ "", /* 0xFF64 */ "\001\037", /* 0xFF65 XK_Undo ^_ */ "", /* 0xFF66 XK_Redo */ "\005\033[29$", /* 0xFF67 XK_Menu Do */ "\004\033[1$", /* 0xFF68 XK_Find */ "\001\007", /* 0xFF69 XK_Cancel */ "\005\033[28$", /* 0xFF6A XK_Help */ "", /* 0xFF6B XK_Break */ "", /* 0xFF6C */ "", /* 0xFF6D */ "", /* 0xFF6E */ "", /* 0xFF6F */ "", /* 0xFF70 */ "", /* 0xFF71 */ "", /* 0xFF72 */ "", /* 0xFF73 */ "", /* 0xFF74 */ "", /* 0xFF75 */ "", /* 0xFF76 */ "", /* 0xFF77 */ "", /* 0xFF78 */ "", /* 0xFF79 */ "", /* 0xFF7A */ "", /* 0xFF7B */ "", /* 0xFF7C */ "", /* 0xFF7D */ "", /* 0xFF7E */ "", /* 0xFF7F XK_Num_Lock */ "", /* 0xFF80 XK_KP_Space */ "", /* 0xFF81 */ "", /* 0xFF82 */ "", /* 0xFF83 */ "", /* 0xFF84 */ "", /* 0xFF85 */ "", /* 0xFF86 */ "", /* 0xFF87 */ "", /* 0xFF88 */ "", /* 0xFF89 XK_KP_Tab */ "", /* 0xFF8A */ "", /* 0xFF8B */ "", /* 0xFF8C */ "\003\033OM", /* 0xFF8D XK_KP_Enter */ "", /* 0xFF8E */ "", /* 0xFF8F */ "", /* 0xFF90 */ "\003\033OP", /* 0xFF91 XK_KP_F1 PF1 */ "\003\033OQ", /* 0xFF92 XK_KP_F2 PF2 */ "\003\033OR", /* 0xFF93 XK_KP_F3 PF3 */ "\003\033OS", /* 0xFF94 XK_KP_F4 PF4 */ "\003\033Ow", /* 0xFF95 XK_KP_Home */ "\003\033Ot", /* 0xFF96 XK_KP_Left */ "\003\033Ox", /* 0xFF97 XK_KP_Up */ "\003\033Ov", /* 0xFF98 XK_KP_Right */ "\003\033Or", /* 0xFF99 XK_KP_Down */ "\003\033Oy", /* 0xFF9A XK_KP_Prior */ "\003\033Os", /* 0xFF9B XK_KP_Next */ "\003\033Oq", /* 0xFF9C XK_KP_End */ "\003\033Ou", /* 0xFF9D XK_KP_Begin */ "\003\033Op", /* 0xFF9E XK_KP_Insert */ "\003\033On", /* 0xFF9F XK_KP_Delete */ "", /* 0xFFA0 */ "", /* 0xFFA1 */ "", /* 0xFFA2 */ "", /* 0xFFA3 */ "", /* 0xFFA4 */ "", /* 0xFFA5 */ "", /* 0xFFA6 */ "", /* 0xFFA7 */ "", /* 0xFFA8 */ "", /* 0xFFA9 */ "", /* 0xFFAA XK_KP_Multiply */ "", /* 0xFFAB XK_KP_Add */ "\003\033Ol", /* 0xFFAC XK_KP_Separator KP , */ "\003\033Om", /* 0xFFAD XK_KP_Subtract KP - */ "\003\033On", /* 0xFFAE XK_KP_Decimal KP . */ "", /* 0xFFAF XK_KP_Divide */ "\003\033Op", /* 0xFFB0 XK_KP_0 */ "\003\033Oq", /* 0xFFB1 XK_KP_1 */ "\003\033Or", /* 0xFFB2 XK_KP_2 */ "\003\033Os", /* 0xFFB3 XK_KP_3 */ "\003\033Ot", /* 0xFFB4 XK_KP_4 */ "\003\033Ou", /* 0xFFB5 XK_KP_5 */ "\003\033Ov", /* 0xFFB6 XK_KP_6 */ "\003\033Ow", /* 0xFFB7 XK_KP_7 */ "\003\033Ox", /* 0xFFB8 XK_KP_8 */ "\003\033Oy", /* 0xFFB9 XK_KP_9 */ "", /* 0xFFBA */ "", /* 0xFFBB */ "", /* 0xFFBC */ "", /* 0xFFBD XK_KP_Equal */ "\005\033[11$", /* 0xFFBE XK_F1 */ "\005\033[12$", /* 0xFFBF XK_F2 */ "\005\033[13$", /* 0xFFC0 XK_F3 */ "\005\033[14$", /* 0xFFC1 XK_F4 */ "\005\033[15$", /* 0xFFC2 XK_F5 */ "\005\033[17$", /* 0xFFC3 XK_F6 */ "\005\033[18$", /* 0xFFC4 XK_F7 */ "\005\033[19$", /* 0xFFC5 XK_F8 */ "\005\033[20$", /* 0xFFC6 XK_F9 */ "\005\033[21$", /* 0xFFC7 XK_F10 */ "\005\033[23$", /* 0xFFC8 XK_F11 XK_L1 */ "\005\033[24$", /* 0xFFC9 XK_F12 XK_L2 */ "\005\033[25$", /* 0xFFCA XK_F13 XK_L3 */ "\005\033[26$", /* 0xFFCB XK_F14 XK_L4 */ "\005\033[28$", /* 0xFFCC XK_F15 XK_L5 */ "\005\033[29$", /* 0xFFCD XK_F16 XK_L6 */ "\005\033[31$", /* 0xFFCE XK_F17 XK_L7 */ "\005\033[32$", /* 0xFFCF XK_F18 XK_L8 */ "\005\033[33$", /* 0xFFD0 XK_F19 XK_L9 */ "\005\033[34$", /* 0xFFD1 XK_F20 XK_L10 */ "\005\033[35$", /* 0xFFD2 XK_F21 XK_R1 */ "\005\033[36$", /* 0xFFD3 XK_F22 XK_R2 */ "\005\033[37$", /* 0xFFD4 XK_F23 XK_R3 */ "\005\033[38$", /* 0xFFD5 XK_F24 XK_R4 */ "\005\033[39$", /* 0xFFD6 XK_F25 XK_R5 */ "\005\033[40$", /* 0xFFD7 XK_F26 XK_R6 */ "\005\033[41$", /* 0xFFD8 XK_F27 XK_R7 */ "\005\033[42$", /* 0xFFD9 XK_F28 XK_R8 */ "\005\033[43$", /* 0xFFDA XK_F29 XK_R9 */ "\005\033[44$", /* 0xFFDB XK_F30 XK_R10 */ "\005\033[45$", /* 0xFFDC XK_F31 XK_R11 */ "\005\033[46$", /* 0xFFDD XK_F32 XK_R12 */ "\005\033[47$", /* 0xFFDE XK_R13 XK_F33 */ "\005\033[48$", /* 0xFFDF XK_F34 XK_R14 */ "\005\033[49$", /* 0xFFE0 XK_F35 XK_R15 */ "", /* 0xFFE1 XK_Shift_L XK_Shift_L */ "", /* 0xFFE2 XK_Shift_R */ "", /* 0xFFE3 XK_Control_L */ "", /* 0xFFE4 XK_Control_R */ "", /* 0xFFE5 XK_Caps_Lock */ "", /* 0xFFE6 XK_Shift_Lock */ "", /* 0xFFE7 XK_Meta_L */ "", /* 0xFFE8 XK_Meta_R */ "", /* 0xFFE9 XK_Alt_L */ "", /* 0xFFEA XK_Alt_R */ "", /* 0xFFEB XK_Super_L */ "", /* 0xFFEC XK_Super_R */ "", /* 0xFFED XK_Hyper_L */ "", /* 0xFFEE XK_Hyper_R */ "", /* 0xFFEF */ "", /* 0xFFF0 */ "", /* 0xFFF1 */ "", /* 0xFFF2 */ "", /* 0xFFF3 */ "", /* 0xFFF4 */ "", /* 0xFFF5 */ "", /* 0xFFF6 */ "", /* 0xFFF7 */ "", /* 0xFFF8 */ "", /* 0xFFF9 */ "", /* 0xFFFA */ "", /* 0xFFFB */ "", /* 0xFFFC */ "", /* 0xFFFD */ "", /* 0xFFFE */ "\001\177" /* 0xFFFF XK_Delete */ }; static KeySym_Mapping_Type Control_KeySym_Map_FF[256] = { "\004\033[3^", /* 0xFF00 Remove */ "", /* 0xFF01 */ "", /* 0xFF02 */ "", /* 0xFF03 */ "", /* 0xFF04 */ "", /* 0xFF05 */ "", /* 0xFF06 */ "", /* 0xFF07 */ "\001\177", /* 0xFF08 XK_BackSpace */ "\001\t", /* 0xFF09 XK_Tab */ "\001\n", /* 0xFF0A XK_Linefeed */ "", /* 0xFF0B XK_Clear */ "", /* 0xFF0C */ "\001\r", /* 0xFF0D XK_Return */ "", /* 0xFF0E */ "", /* 0xFF0F */ "", /* 0xFF10 */ "", /* 0xFF11 */ "", /* 0xFF12 */ "", /* 0xFF13 XK_Pause */ "", /* 0xFF14 XK_Scroll_Lock */ "", /* 0xFF15 */ "", /* 0xFF16 */ "", /* 0xFF17 */ "", /* 0xFF18 */ "", /* 0xFF19 */ "", /* 0xFF1A */ "\001\033", /* 0xFF1B XK_Escape */ "", /* 0xFF1C */ "", /* 0xFF1D */ "", /* 0xFF1E */ "", /* 0xFF1F */ "", /* 0xFF20 XK_Multi_key */ "", /* 0xFF21 XK_Kanji */ "", /* 0xFF22 XK_Muhenkan */ "", /* 0xFF23 XK_Henkan_Mode XK_Henkan */ "", /* 0xFF24 XK_Romaji */ "", /* 0xFF25 XK_Hiragana */ "", /* 0xFF26 XK_Katakana */ "", /* 0xFF27 XK_Hiragana_Katakana */ "", /* 0xFF28 XK_Zenkaku */ "", /* 0xFF29 XK_Hankaku */ "", /* 0xFF2A XK_Zenkaku_Hankaku */ "", /* 0xFF2B XK_Touroku */ "", /* 0xFF2C XK_Massyo */ "", /* 0xFF2D XK_Kana_Lock */ "", /* 0xFF2E XK_Kana_Shift */ "", /* 0xFF2F XK_Eisu_Shift */ "", /* 0xFF30 XK_Eisu_toggle */ "", /* 0xFF31 */ "", /* 0xFF32 */ "", /* 0xFF33 */ "", /* 0xFF34 */ "", /* 0xFF35 */ "", /* 0xFF36 */ "", /* 0xFF37 */ "", /* 0xFF38 */ "", /* 0xFF39 */ "", /* 0xFF3A */ "", /* 0xFF3B */ "", /* 0xFF3C */ "", /* 0xFF3D */ "", /* 0xFF3E */ "", /* 0xFF3F */ "", /* 0xFF40 */ "", /* 0xFF41 */ "", /* 0xFF42 */ "", /* 0xFF43 */ "", /* 0xFF44 */ "", /* 0xFF45 */ "", /* 0xFF46 */ "", /* 0xFF47 */ "", /* 0xFF48 */ "", /* 0xFF49 */ "", /* 0xFF4A */ "", /* 0xFF4B */ "", /* 0xFF4C */ "", /* 0xFF4D */ "", /* 0xFF4E */ "", /* 0xFF4F */ "\004\033[1^", /* 0xFF50 XK_Home */ "\003\033[\004", /* 0xFF51 XK_Left */ "\003\033[\001", /* 0xFF52 XK_Up */ "\003\033[\003", /* 0xFF53 XK_Right */ "\003\033[\002", /* 0xFF54 XK_Down */ "\004\033[5^", /* 0xFF55 XK_Prior */ "\004\033[6^", /* 0xFF56 XK_Next */ "\004\033[4^", /* 0xFF57 XK_End */ "\001\001", /* 0xFF58 XK_Begin */ "", /* 0xFF59 */ "", /* 0xFF5A */ "", /* 0xFF5B */ "", /* 0xFF5C */ "", /* 0xFF5D */ "", /* 0xFF5E */ "", /* 0xFF5F */ "\004\033[4^", /* 0xFF60 XK_Select */ "", /* 0xFF61 XK_Print */ "", /* 0xFF62 XK_Execute */ "\004\033[2^", /* 0xFF63 XK_Insert */ "", /* 0xFF64 */ "\001\037", /* 0xFF65 XK_Undo ^_ */ "", /* 0xFF66 XK_Redo */ "\005\033[29^", /* 0xFF67 XK_Menu Do */ "\004\033[1^", /* 0xFF68 XK_Find */ "\001\007", /* 0xFF69 XK_Cancel */ "\005\033[28^", /* 0xFF6A XK_Help */ "", /* 0xFF6B XK_Break */ "", /* 0xFF6C */ "", /* 0xFF6D */ "", /* 0xFF6E */ "", /* 0xFF6F */ "", /* 0xFF70 */ "", /* 0xFF71 */ "", /* 0xFF72 */ "", /* 0xFF73 */ "", /* 0xFF74 */ "", /* 0xFF75 */ "", /* 0xFF76 */ "", /* 0xFF77 */ "", /* 0xFF78 */ "", /* 0xFF79 */ "", /* 0xFF7A */ "", /* 0xFF7B */ "", /* 0xFF7C */ "", /* 0xFF7D */ "", /* 0xFF7E */ "", /* 0xFF7F XK_Num_Lock */ "", /* 0xFF80 XK_KP_Space */ "", /* 0xFF81 */ "", /* 0xFF82 */ "", /* 0xFF83 */ "", /* 0xFF84 */ "", /* 0xFF85 */ "", /* 0xFF86 */ "", /* 0xFF87 */ "", /* 0xFF88 */ "", /* 0xFF89 XK_KP_Tab */ "", /* 0xFF8A */ "", /* 0xFF8B */ "", /* 0xFF8C */ "\003\033OM", /* 0xFF8D XK_KP_Enter */ "", /* 0xFF8E */ "", /* 0xFF8F */ "", /* 0xFF90 */ "\003\033OP", /* 0xFF91 XK_KP_F1 PF1 */ "\003\033OQ", /* 0xFF92 XK_KP_F2 PF2 */ "\003\033OR", /* 0xFF93 XK_KP_F3 PF3 */ "\003\033OS", /* 0xFF94 XK_KP_F4 PF4 */ "\003\033Ow", /* 0xFF95 XK_KP_Home */ "\003\033Ot", /* 0xFF96 XK_KP_Left */ "\003\033Ox", /* 0xFF97 XK_KP_Up */ "\003\033Ov", /* 0xFF98 XK_KP_Right */ "\003\033Or", /* 0xFF99 XK_KP_Down */ "\003\033Oy", /* 0xFF9A XK_KP_Prior */ "\003\033Os", /* 0xFF9B XK_KP_Next */ "\003\033Oq", /* 0xFF9C XK_KP_End */ "\003\033Ou", /* 0xFF9D XK_KP_Begin */ "\003\033Op", /* 0xFF9E XK_KP_Insert */ "\003\033On", /* 0xFF9F XK_KP_Delete */ "", /* 0xFFA0 */ "", /* 0xFFA1 */ "", /* 0xFFA2 */ "", /* 0xFFA3 */ "", /* 0xFFA4 */ "", /* 0xFFA5 */ "", /* 0xFFA6 */ "", /* 0xFFA7 */ "", /* 0xFFA8 */ "", /* 0xFFA9 */ "", /* 0xFFAA XK_KP_Multiply */ "", /* 0xFFAB XK_KP_Add */ "\003\033Ol", /* 0xFFAC XK_KP_Separator KP , */ "\003\033Om", /* 0xFFAD XK_KP_Subtract KP - */ "\003\033On", /* 0xFFAE XK_KP_Decimal KP . */ "", /* 0xFFAF XK_KP_Divide */ "\003\033Op", /* 0xFFB0 XK_KP_0 */ "\003\033Oq", /* 0xFFB1 XK_KP_1 */ "\003\033Or", /* 0xFFB2 XK_KP_2 */ "\003\033Os", /* 0xFFB3 XK_KP_3 */ "\003\033Ot", /* 0xFFB4 XK_KP_4 */ "\003\033Ou", /* 0xFFB5 XK_KP_5 */ "\003\033Ov", /* 0xFFB6 XK_KP_6 */ "\003\033Ow", /* 0xFFB7 XK_KP_7 */ "\003\033Ox", /* 0xFFB8 XK_KP_8 */ "\003\033Oy", /* 0xFFB9 XK_KP_9 */ "", /* 0xFFBA */ "", /* 0xFFBB */ "", /* 0xFFBC */ "", /* 0xFFBD XK_KP_Equal */ "\005\033[11^", /* 0xFFBE XK_F1 */ "\005\033[12^", /* 0xFFBF XK_F2 */ "\005\033[13^", /* 0xFFC0 XK_F3 */ "\005\033[14^", /* 0xFFC1 XK_F4 */ "\005\033[15^", /* 0xFFC2 XK_F5 */ "\005\033[17^", /* 0xFFC3 XK_F6 */ "\005\033[18^", /* 0xFFC4 XK_F7 */ "\005\033[19^", /* 0xFFC5 XK_F8 */ "\005\033[20^", /* 0xFFC6 XK_F9 */ "\005\033[21^", /* 0xFFC7 XK_F10 */ "\005\033[23^", /* 0xFFC8 XK_F11 XK_L1 */ "\005\033[24^", /* 0xFFC9 XK_F12 XK_L2 */ "\005\033[25^", /* 0xFFCA XK_F13 XK_L3 */ "\005\033[26^", /* 0xFFCB XK_F14 XK_L4 */ "\005\033[28^", /* 0xFFCC XK_F15 XK_L5 */ "\005\033[29^", /* 0xFFCD XK_F16 XK_L6 */ "\005\033[31^", /* 0xFFCE XK_F17 XK_L7 */ "\005\033[32^", /* 0xFFCF XK_F18 XK_L8 */ "\005\033[33^", /* 0xFFD0 XK_F19 XK_L9 */ "\005\033[34^", /* 0xFFD1 XK_F20 XK_L10 */ "\005\033[35^", /* 0xFFD2 XK_F21 XK_R1 */ "\005\033[36^", /* 0xFFD3 XK_F22 XK_R2 */ "\005\033[37^", /* 0xFFD4 XK_F23 XK_R3 */ "\005\033[38^", /* 0xFFD5 XK_F24 XK_R4 */ "\005\033[39^", /* 0xFFD6 XK_F25 XK_R5 */ "\005\033[40^", /* 0xFFD7 XK_F26 XK_R6 */ "\005\033[41^", /* 0xFFD8 XK_F27 XK_R7 */ "\005\033[42^", /* 0xFFD9 XK_F28 XK_R8 */ "\005\033[43^", /* 0xFFDA XK_F29 XK_R9 */ "\005\033[44^", /* 0xFFDB XK_F30 XK_R10 */ "\005\033[45^", /* 0xFFDC XK_F31 XK_R11 */ "\005\033[46^", /* 0xFFDD XK_F32 XK_R12 */ "\005\033[47^", /* 0xFFDE XK_R13 XK_F33 */ "\005\033[48^", /* 0xFFDF XK_F34 XK_R14 */ "\005\033[49^", /* 0xFFE0 XK_F35 XK_R15 */ "", /* 0xFFE1 XK_Shift_L XK_Shift_L */ "", /* 0xFFE2 XK_Shift_R */ "", /* 0xFFE3 XK_Control_L */ "", /* 0xFFE4 XK_Control_R */ "", /* 0xFFE5 XK_Caps_Lock */ "", /* 0xFFE6 XK_Shift_Lock */ "", /* 0xFFE7 XK_Meta_L */ "", /* 0xFFE8 XK_Meta_R */ "", /* 0xFFE9 XK_Alt_L */ "", /* 0xFFEA XK_Alt_R */ "", /* 0xFFEB XK_Super_L */ "", /* 0xFFEC XK_Super_R */ "", /* 0xFFED XK_Hyper_L */ "", /* 0xFFEE XK_Hyper_R */ "", /* 0xFFEF */ "", /* 0xFFF0 */ "", /* 0xFFF1 */ "", /* 0xFFF2 */ "", /* 0xFFF3 */ "", /* 0xFFF4 */ "", /* 0xFFF5 */ "", /* 0xFFF6 */ "", /* 0xFFF7 */ "", /* 0xFFF8 */ "", /* 0xFFF9 */ "", /* 0xFFFA */ "", /* 0xFFFB */ "", /* 0xFFFC */ "", /* 0xFFFD */ "", /* 0xFFFE */ "\001\177" /* 0xFFFF XK_Delete */ }; static KeySym_Mapping_Type Control_Shift_KeySym_Map_FF[256] = { "\004\033[3^", /* 0xFF00 Remove */ "", /* 0xFF01 */ "", /* 0xFF02 */ "", /* 0xFF03 */ "", /* 0xFF04 */ "", /* 0xFF05 */ "", /* 0xFF06 */ "", /* 0xFF07 */ "\001\177", /* 0xFF08 XK_BackSpace */ "\001\t", /* 0xFF09 XK_Tab */ "\001\n", /* 0xFF0A XK_Linefeed */ "", /* 0xFF0B XK_Clear */ "", /* 0xFF0C */ "\001\r", /* 0xFF0D XK_Return */ "", /* 0xFF0E */ "", /* 0xFF0F */ "", /* 0xFF10 */ "", /* 0xFF11 */ "", /* 0xFF12 */ "", /* 0xFF13 XK_Pause */ "", /* 0xFF14 XK_Scroll_Lock */ "", /* 0xFF15 */ "", /* 0xFF16 */ "", /* 0xFF17 */ "", /* 0xFF18 */ "", /* 0xFF19 */ "", /* 0xFF1A */ "\001\033", /* 0xFF1B XK_Escape */ "", /* 0xFF1C */ "", /* 0xFF1D */ "", /* 0xFF1E */ "", /* 0xFF1F */ "", /* 0xFF20 XK_Multi_key */ "", /* 0xFF21 XK_Kanji */ "", /* 0xFF22 XK_Muhenkan */ "", /* 0xFF23 XK_Henkan_Mode XK_Henkan */ "", /* 0xFF24 XK_Romaji */ "", /* 0xFF25 XK_Hiragana */ "", /* 0xFF26 XK_Katakana */ "", /* 0xFF27 XK_Hiragana_Katakana */ "", /* 0xFF28 XK_Zenkaku */ "", /* 0xFF29 XK_Hankaku */ "", /* 0xFF2A XK_Zenkaku_Hankaku */ "", /* 0xFF2B XK_Touroku */ "", /* 0xFF2C XK_Massyo */ "", /* 0xFF2D XK_Kana_Lock */ "", /* 0xFF2E XK_Kana_Shift */ "", /* 0xFF2F XK_Eisu_Shift */ "", /* 0xFF30 XK_Eisu_toggle */ "", /* 0xFF31 */ "", /* 0xFF32 */ "", /* 0xFF33 */ "", /* 0xFF34 */ "", /* 0xFF35 */ "", /* 0xFF36 */ "", /* 0xFF37 */ "", /* 0xFF38 */ "", /* 0xFF39 */ "", /* 0xFF3A */ "", /* 0xFF3B */ "", /* 0xFF3C */ "", /* 0xFF3D */ "", /* 0xFF3E */ "", /* 0xFF3F */ "", /* 0xFF40 */ "", /* 0xFF41 */ "", /* 0xFF42 */ "", /* 0xFF43 */ "", /* 0xFF44 */ "", /* 0xFF45 */ "", /* 0xFF46 */ "", /* 0xFF47 */ "", /* 0xFF48 */ "", /* 0xFF49 */ "", /* 0xFF4A */ "", /* 0xFF4B */ "", /* 0xFF4C */ "", /* 0xFF4D */ "", /* 0xFF4E */ "", /* 0xFF4F */ "\004\033[1^", /* 0xFF50 XK_Home */ "\003\033[\004", /* 0xFF51 XK_Left */ "\003\033[\001", /* 0xFF52 XK_Up */ "\003\033[\003", /* 0xFF53 XK_Right */ "\003\033[\002", /* 0xFF54 XK_Down */ "\004\033[5^", /* 0xFF55 XK_Prior */ "\004\033[6^", /* 0xFF56 XK_Next */ "\004\033[4^", /* 0xFF57 XK_End */ "\001\001", /* 0xFF58 XK_Begin */ "", /* 0xFF59 */ "", /* 0xFF5A */ "", /* 0xFF5B */ "", /* 0xFF5C */ "", /* 0xFF5D */ "", /* 0xFF5E */ "", /* 0xFF5F */ "\004\033[4^", /* 0xFF60 XK_Select */ "", /* 0xFF61 XK_Print */ "", /* 0xFF62 XK_Execute */ "\004\033[2^", /* 0xFF63 XK_Insert */ "", /* 0xFF64 */ "\001\037", /* 0xFF65 XK_Undo ^_ */ "", /* 0xFF66 XK_Redo */ "\005\033[29^", /* 0xFF67 XK_Menu Do */ "\004\033[1^", /* 0xFF68 XK_Find */ "\001\007", /* 0xFF69 XK_Cancel */ "\005\033[28^", /* 0xFF6A XK_Help */ "", /* 0xFF6B XK_Break */ "", /* 0xFF6C */ "", /* 0xFF6D */ "", /* 0xFF6E */ "", /* 0xFF6F */ "", /* 0xFF70 */ "", /* 0xFF71 */ "", /* 0xFF72 */ "", /* 0xFF73 */ "", /* 0xFF74 */ "", /* 0xFF75 */ "", /* 0xFF76 */ "", /* 0xFF77 */ "", /* 0xFF78 */ "", /* 0xFF79 */ "", /* 0xFF7A */ "", /* 0xFF7B */ "", /* 0xFF7C */ "", /* 0xFF7D */ "", /* 0xFF7E */ "", /* 0xFF7F XK_Num_Lock */ "", /* 0xFF80 XK_KP_Space */ "", /* 0xFF81 */ "", /* 0xFF82 */ "", /* 0xFF83 */ "", /* 0xFF84 */ "", /* 0xFF85 */ "", /* 0xFF86 */ "", /* 0xFF87 */ "", /* 0xFF88 */ "", /* 0xFF89 XK_KP_Tab */ "", /* 0xFF8A */ "", /* 0xFF8B */ "", /* 0xFF8C */ "\003\033OM", /* 0xFF8D XK_KP_Enter */ "", /* 0xFF8E */ "", /* 0xFF8F */ "", /* 0xFF90 */ "\003\033OP", /* 0xFF91 XK_KP_F1 PF1 */ "\003\033OQ", /* 0xFF92 XK_KP_F2 PF2 */ "\003\033OR", /* 0xFF93 XK_KP_F3 PF3 */ "\003\033OS", /* 0xFF94 XK_KP_F4 PF4 */ "", /* 0xFF95 */ "", /* 0xFF96 */ "", /* 0xFF97 */ "", /* 0xFF98 */ "", /* 0xFF99 */ "", /* 0xFF9A */ "", /* 0xFF9B */ "", /* 0xFF9C */ "", /* 0xFF9D */ "", /* 0xFF9E */ "", /* 0xFF9F */ "", /* 0xFFA0 */ "", /* 0xFFA1 */ "", /* 0xFFA2 */ "", /* 0xFFA3 */ "", /* 0xFFA4 */ "", /* 0xFFA5 */ "", /* 0xFFA6 */ "", /* 0xFFA7 */ "", /* 0xFFA8 */ "", /* 0xFFA9 */ "", /* 0xFFAA XK_KP_Multiply */ "", /* 0xFFAB XK_KP_Add */ "\003\033Ol", /* 0xFFAC XK_KP_Separator KP , */ "\003\033Om", /* 0xFFAD XK_KP_Subtract KP - */ "\003\033On", /* 0xFFAE XK_KP_Decimal KP . */ "", /* 0xFFAF XK_KP_Divide */ "\003\033Op", /* 0xFFB0 XK_KP_0 */ "\003\033Oq", /* 0xFFB1 XK_KP_1 */ "\003\033Or", /* 0xFFB2 XK_KP_2 */ "\003\033Os", /* 0xFFB3 XK_KP_3 */ "\003\033Ot", /* 0xFFB4 XK_KP_4 */ "\003\033Ou", /* 0xFFB5 XK_KP_5 */ "\003\033Ov", /* 0xFFB6 XK_KP_6 */ "\003\033Ow", /* 0xFFB7 XK_KP_7 */ "\003\033Ox", /* 0xFFB8 XK_KP_8 */ "\003\033Oy", /* 0xFFB9 XK_KP_9 */ "", /* 0xFFBA */ "", /* 0xFFBB */ "", /* 0xFFBC */ "", /* 0xFFBD XK_KP_Equal */ "\005\033[11^", /* 0xFFBE XK_F1 */ "\005\033[12^", /* 0xFFBF XK_F2 */ "\005\033[13^", /* 0xFFC0 XK_F3 */ "\005\033[14^", /* 0xFFC1 XK_F4 */ "\005\033[15^", /* 0xFFC2 XK_F5 */ "\005\033[17^", /* 0xFFC3 XK_F6 */ "\005\033[18^", /* 0xFFC4 XK_F7 */ "\005\033[19^", /* 0xFFC5 XK_F8 */ "\005\033[20^", /* 0xFFC6 XK_F9 */ "\005\033[21^", /* 0xFFC7 XK_F10 */ "\005\033[23^", /* 0xFFC8 XK_F11 XK_L1 */ "\005\033[24^", /* 0xFFC9 XK_F12 XK_L2 */ "\005\033[25^", /* 0xFFCA XK_F13 XK_L3 */ "\005\033[26^", /* 0xFFCB XK_F14 XK_L4 */ "\005\033[28^", /* 0xFFCC XK_F15 XK_L5 */ "\005\033[29^", /* 0xFFCD XK_F16 XK_L6 */ "\005\033[31^", /* 0xFFCE XK_F17 XK_L7 */ "\005\033[32^", /* 0xFFCF XK_F18 XK_L8 */ "\005\033[33^", /* 0xFFD0 XK_F19 XK_L9 */ "\005\033[34^", /* 0xFFD1 XK_F20 XK_L10 */ "\005\033[35^", /* 0xFFD2 XK_F21 XK_R1 */ "\005\033[36^", /* 0xFFD3 XK_F22 XK_R2 */ "\005\033[37^", /* 0xFFD4 XK_F23 XK_R3 */ "\005\033[38^", /* 0xFFD5 XK_F24 XK_R4 */ "\005\033[39^", /* 0xFFD6 XK_F25 XK_R5 */ "\005\033[40^", /* 0xFFD7 XK_F26 XK_R6 */ "\005\033[41^", /* 0xFFD8 XK_F27 XK_R7 */ "\005\033[42^", /* 0xFFD9 XK_F28 XK_R8 */ "\005\033[43^", /* 0xFFDA XK_F29 XK_R9 */ "\005\033[44^", /* 0xFFDB XK_F30 XK_R10 */ "\005\033[45^", /* 0xFFDC XK_F31 XK_R11 */ "\005\033[46^", /* 0xFFDD XK_F32 XK_R12 */ "\005\033[47^", /* 0xFFDE XK_R13 XK_F33 */ "\005\033[48^", /* 0xFFDF XK_F34 XK_R14 */ "\005\033[49^", /* 0xFFE0 XK_F35 XK_R15 */ "", /* 0xFFE1 XK_Shift_L XK_Shift_L */ "", /* 0xFFE2 XK_Shift_R */ "", /* 0xFFE3 XK_Control_L */ "", /* 0xFFE4 XK_Control_R */ "", /* 0xFFE5 XK_Caps_Lock */ "", /* 0xFFE6 XK_Shift_Lock */ "", /* 0xFFE7 XK_Meta_L */ "", /* 0xFFE8 XK_Meta_R */ "", /* 0xFFE9 XK_Alt_L */ "", /* 0xFFEA XK_Alt_R */ "", /* 0xFFEB XK_Super_L */ "", /* 0xFFEC XK_Super_R */ "", /* 0xFFED XK_Hyper_L */ "", /* 0xFFEE XK_Hyper_R */ "", /* 0xFFEF */ "", /* 0xFFF0 */ "", /* 0xFFF1 */ "", /* 0xFFF2 */ "", /* 0xFFF3 */ "", /* 0xFFF4 */ "", /* 0xFFF5 */ "", /* 0xFFF6 */ "", /* 0xFFF7 */ "", /* 0xFFF8 */ "", /* 0xFFF9 */ "", /* 0xFFFA */ "", /* 0xFFFB */ "", /* 0xFFFC */ "", /* 0xFFFD */ "", /* 0xFFFE */ "\001\177" /* 0xFFFF XK_Delete */ }; static KeySym_Mapping_Type *KeySym_Maps[256]; static KeySym_Mapping_Type *Shift_KeySym_Maps[256]; static KeySym_Mapping_Type *Control_KeySym_Maps[256]; static KeySym_Mapping_Type *Control_Shift_KeySym_Maps[256]; static int init_xkeys (void) { KeySym_Maps[0xFF] = KeySym_Map_FF; Shift_KeySym_Maps[0xFF] = Shift_KeySym_Map_FF; Control_Shift_KeySym_Maps[0xFF] = Control_Shift_KeySym_Map_FF; Control_KeySym_Maps[0xFF] = Control_KeySym_Map_FF; return 0; } static void x_set_keysym (int *np, int *shift, char *str) /*{{{*/ { unsigned int keysym = (unsigned int) *np; KeySym_Mapping_Type **maps, *map; unsigned int len; unsigned int i; str = SLang_process_keystring (str); if (str == NULL) return; len = (unsigned int) (unsigned char)str[0]; if (len > MAX_KEYSYM_STRING_LEN) return; switch (*shift) { case '$': maps = Shift_KeySym_Maps; break; case '^': maps = Control_KeySym_Maps; break; case '%': maps = Control_Shift_KeySym_Maps; break; default: maps = KeySym_Maps; break; } i = (keysym >> 8)&0xFF; if (NULL == (map = maps[i])) { map = (KeySym_Mapping_Type *)SLcalloc (256, sizeof (KeySym_Mapping_Type)); if (map == NULL) return; maps[i] = map; } map += keysym&0xFF; memcpy ((char *)map, str, len); /* was: SLMEMCPY (map[n], str, MAX_KEYSYM_STRING_LEN); */ *(char *)map -= 1; } /*}}}*/ static unsigned char *map_keysym_to_keyseq (unsigned int keysym, unsigned long mask) { KeySym_Mapping_Type **maps; KeySym_Mapping_Type *map; unsigned char *keyseq; switch (mask) { default: maps = KeySym_Maps; break; case ShiftMask: maps = Shift_KeySym_Maps; break; case ControlMask: maps = Control_KeySym_Maps; break; case ShiftMask|ControlMask: maps = Control_Shift_KeySym_Maps; break; } map = maps [(keysym >> 8) & 0xFF]; if (map == NULL) return NULL; keyseq = (unsigned char *) map[keysym & 0xFF]; if (*keyseq == 0) return NULL; return keyseq; } jed-0.99-19/src/sig.h0000644002657400265740000000124311311317447013214 0ustar davisdavis/* Copyright (c) 1992, 1998, 2000, 2005, 2006 John E. Davis * This file is part of JED editor library source. * * You may distribute this file under the terms the GNU General Public * License. See the file COPYING for more information. */ #ifndef _JED_SIG_H_ #define _JED_SIG_H_ #ifndef __MSDOS_16BIT__ extern void init_signals (void); extern void jed_reset_signals (void); #endif extern int Stdin_Is_TTY; #ifdef SIGTSTP # ifdef __unix__ extern void sig_sys_spawn_cmd(int); extern int Signal_Sys_Spawn_Flag; /* used if something else sends stop */ # endif extern int Jed_Handle_SIGTSTP; #endif extern int jed_handle_interrupt (void); #endif /* _JED_SIG_H_ */ jed-0.99-19/src/abbrev.c0000644002657400265740000001772011311317447013675 0ustar davisdavis/* -*- mode: C; mode: fold; -*- */ /* Copyright (c) 1992, 1998, 2000, 2002, 2003, 2004, 2005, 2006 John E. Davis * This file is part of JED editor library source. * * You may distribute this file under the terms the GNU General Public * License. See the file COPYING for more information. */ #include "config.h" #include "jed-feat.h" /*{{{ Include Files */ #include #include #include "buffer.h" #include "abbrev.h" #include "text.h" #include "ledit.h" #include "ins.h" #include "cmds.h" #include "misc.h" /*}}}*/ #if JED_HAS_ABBREVS /*{{{ Static Variables */ typedef struct { char *abbrev; char *string; unsigned int abbrev_len; unsigned int flags; #define ABBREV_LEAVE_POINT 1 } Abbrev_Type; typedef struct Abbrev_Table_Type /*{{{*/ { unsigned int len; /* length of table */ unsigned int max_len; /* number allocated */ Abbrev_Type *abbrevs; char word_chars[256]; /* word delimiters */ char *name; /* name of table */ struct Abbrev_Table_Type *next; } /*}}}*/ Abbrev_Table_Type; static Abbrev_Table_Type *Global_Abbrev_Table; static Abbrev_Table_Type *Abbrev_Tables; /*}}}*/ /* FIXME: Not multibyte safe */ int jed_expand_abbrev (SLwchar_Type ch) /*{{{*/ { Abbrev_Table_Type *tbl; unsigned int len; unsigned char *p; Abbrev_Type *a, *amax; char ch1; tbl = CBuf->abbrev_table; if (tbl == NULL) { tbl = Global_Abbrev_Table; if (tbl == NULL) return 0; } if (tbl->word_chars[(unsigned char) ch]) return 0; /* not a delimiter */ p = CLine->data + (Point - 1); while ((p >= CLine->data) && (tbl->word_chars[*p])) { p--; } p++; len = (unsigned int) ((CLine->data + Point) - p); if (len == 0) return 0; ch1 = *p; a = tbl->abbrevs; amax = a + tbl->len; while (a < amax) { char *str; if ((a->abbrev_len != len) || ((char) ch1 != a->abbrev[0]) || (0 != strncmp ((char *) p, a->abbrev, len))) { a++; continue; } Point -= len; (void) jed_del_nbytes (len); str = a->string; len = strlen (str); if ((CBuf->flags & OVERWRITE_MODE) && (-1 == jed_del_nbytes (len))) /* this does not delete across lines */ return -1; if (-1 == jed_insert_nbytes ((unsigned char *) str, len)) return -1; if ((0 == (a->flags & ABBREV_LEAVE_POINT)) && (-1 == _jed_ins_byte (ch))) return -1; return 1; } return 0; } /*}}}*/ static Abbrev_Table_Type *find_table (char *name, int err) /*{{{*/ { Abbrev_Table_Type *tbl; if (0 == strcmp (name, "Global")) { if (Global_Abbrev_Table != NULL) return Global_Abbrev_Table; /* Fall through for error */ } tbl = Abbrev_Tables; while (tbl != NULL) { if (0 == strcmp (tbl->name, name)) return tbl; tbl = tbl->next; } if (err) jed_verror ("Abbrev Table %s does not exist", name); return NULL; } /*}}}*/ void create_abbrev_table (char *name, char *word_chars) /*{{{*/ { Abbrev_Table_Type *tbl; tbl = find_table (name, 0); if (tbl == NULL) { tbl = (Abbrev_Table_Type *) jed_malloc0 (sizeof (Abbrev_Table_Type)); if (tbl == NULL) return; if (NULL == (tbl->name = SLang_create_slstring (name))) { SLfree ((char *) tbl); return; } if (0 == strcmp (name, "Global")) Global_Abbrev_Table = tbl; else { tbl->next = Abbrev_Tables; Abbrev_Tables = tbl; } } if (*word_chars == 0) word_chars = Jed_Word_Range; SLmake_lut ((unsigned char *) tbl->word_chars, (unsigned char *) word_chars, 0); } /*}}}*/ static void free_abbrev_table (Abbrev_Table_Type *t) { Abbrev_Type *a, *amax; a = t->abbrevs; amax = a + t->len; while (a < amax) { SLang_free_slstring (a->abbrev); SLang_free_slstring (a->string); a++; } SLfree ((char *) t->abbrevs); SLang_free_slstring (t->name); SLfree ((char *) t); } void delete_abbrev_table (char *name) /*{{{*/ { Abbrev_Table_Type *tbl; Buffer *b; tbl = find_table (name, 1); if (tbl == NULL) return; if (tbl == Global_Abbrev_Table) Global_Abbrev_Table = NULL; else { Abbrev_Table_Type *prev = Abbrev_Tables; if (prev != tbl) { while (prev->next != tbl) tbl = tbl->next; prev->next = tbl->next; } else Abbrev_Tables = tbl->next; } b = CBuf; do { if (b->abbrev_table == tbl) b->abbrev_table = NULL; b = b->next; } while (b != CBuf); free_abbrev_table (tbl); } /*}}}*/ void define_abbrev (char *table, char *abbrev, char *expans) /*{{{*/ { Abbrev_Table_Type *tbl; Abbrev_Type *a, *amax; unsigned int n; unsigned int abbrev_len, expans_len; unsigned int flags; tbl = find_table (table, 1); if (tbl == NULL) return; n = tbl->len; a = tbl->abbrevs; if (n >= tbl->max_len) { unsigned int max_len = tbl->max_len + 32; /* SLrealloc handles NULL via malloc */ if (NULL == (a = (Abbrev_Type *) SLrealloc ((char *) a, max_len * sizeof (Abbrev_Type)))) return; tbl->abbrevs = a; tbl->max_len = max_len; } /* Before actually creating an abbrev, make sure we can do it without * failure. */ flags = 0; if (NULL == (abbrev = SLang_create_slstring (abbrev))) return; abbrev_len = strlen (abbrev); expans_len = strlen (expans); if ((expans_len > 0) && (expans[expans_len-1] == 8)) /* ^H */ { expans_len--; flags |= ABBREV_LEAVE_POINT; } if (NULL == (expans = SLang_create_nslstring (expans, expans_len))) { SLang_free_slstring (abbrev); return; } amax = a + n; while (a < amax) { if (a->abbrev == abbrev) /* SLstring comparison */ { SLang_free_slstring (a->abbrev); SLang_free_slstring (a->string); break; } a++; } if (a == amax) tbl->len++; a->string = expans; a->abbrev = abbrev; a->flags = flags; a->abbrev_len = abbrev_len; } /*}}}*/ void use_abbrev_table (char *name) /*{{{*/ { Abbrev_Table_Type *tbl; if (NULL != (tbl = find_table (name, 1))) CBuf->abbrev_table = tbl; } /*}}}*/ int abbrev_table_p (char *name) /*{{{*/ { return (NULL != find_table (name, 0)); } /*}}}*/ static void push_word (Abbrev_Table_Type *tbl) /*{{{*/ { char buf[256], *b, *w; int i, in_range; b = buf; w = tbl->word_chars; if (w[(unsigned char) '-'] != 0) *b++ = '-'; in_range = 0; for (i = 33; i < 256; i++) { if ((i != '-') && (0 != w[i])) { if (i == '\\') *b++ = (char) i; *b = (char) i; if (in_range == 0) { *(b + 1) = '-'; b += 2; *b = 0; in_range = 1; } } else { if (in_range) { if (*b == 0) b--; else b++; in_range = 0; } } } *b = 0; SLang_push_string (buf); } /*}}}*/ void what_abbrev_table (void) /*{{{*/ { Abbrev_Table_Type *tbl; tbl = CBuf->abbrev_table; if (tbl == NULL) { tbl = Global_Abbrev_Table; if (tbl == NULL) { (void) SLang_push_string (""); (void) SLang_push_string (""); return; } } (void) SLang_push_string (tbl->name); push_word (tbl); } /*}}}*/ void dump_abbrev_table (char *name) /*{{{*/ { Abbrev_Table_Type *tbl; Abbrev_Type *a, *amax; if (NULL == (tbl = find_table (name, 1))) return; a = tbl->abbrevs; amax = a + tbl->len; while (a < amax) { if ((-1 == jed_insert_string (a->abbrev)) || (-1 == jed_insert_byte ('\t')) || (-1 == jed_insert_string (a->string)) || ((a->flags & ABBREV_LEAVE_POINT) && (-1 == jed_insert_byte (8))) || (-1 == jed_insert_newline ())) return; a++; } push_word (tbl); } /*}}}*/ int list_abbrev_tables (void) /*{{{*/ { Abbrev_Table_Type *tbl; int n = 0; if (Global_Abbrev_Table != NULL) { (void) SLang_push_string (Global_Abbrev_Table->name); n++; } tbl = Abbrev_Tables; while (tbl != NULL) { (void) SLang_push_string (tbl->name); tbl = tbl->next; n++; } return n; } /*}}}*/ #endif /* JED_HAS_ABBREVS */ jed-0.99-19/src/ins.c0000644002657400265740000003125111311317447013220 0ustar davisdavis/* -*- mode: C; mode: fold; -*- */ /* Copyright (c) 1992, 1998, 2000, 2002, 2003, 2004, 2005, 2006 John E. Davis * This file is part of JED editor library source. * * You may distribute this file under the terms the GNU General Public * License. See the file COPYING for more information. */ #include "config.h" #include "jed-feat.h" /*{{{ Include Files */ #include #include #include "buffer.h" #include "ins.h" #include "line.h" #include "screen.h" #include "window.h" #include "misc.h" #include "paste.h" #include "ledit.h" #include "undo.h" #include "file.h" /*}}}*/ int Suspend_Screen_Update = 0; int No_Screen_Update; static void cinsert_update_marks (Mark *m, unsigned int linenum, int n) { (void) linenum; while (m != NULL) { if ((m->line == CLine) && (m->point > Point)) m->point += n; m = m->next; } } static void cdelete_update_marks (Mark *m, unsigned int linenum, int n) { (void) linenum; while(m != NULL) { if ((m->line == CLine) && (m->point > Point)) { int tmp; /* BCC generates wrong code here with optimization. So use a * silly tmp variable as a way around the bug. */ tmp = m->point; tmp -= n; if (tmp < Point) tmp = Point; m->point = tmp; /* BAD CODE: m->point -= n; if (m->point < Point) m->point = Point; */ } m = m->next; } } static void ldelete_update_marks (Mark *m, unsigned int linenum, int n) { (void) n; while (m != NULL) { if (CLine == m->line) { if (CLine->prev != NULL) { m->line = CLine->prev; } else m->line = CBuf->beg; m->point = 0; } if (linenum <= m->n) m->n -= 1; m = m->next; } } static void nldelete_update_marks (Mark *m, unsigned int linenum, int n) { /* deletion performed at end of a line (CLine->prev) */ (void) n; while (m != NULL) { if (m->line == CLine) { m->line = CLine->prev; m->point += Point; } if (linenum <= m->n) m->n -= 1; m = m->next; } } static void nlinsert_update_marks (Mark *m, unsigned int linenum, int n) { /* newline added-- affects only marks onward from insertion point */ (void) n; while (m != NULL) { /* This is a bit controversial if the mark corresponds to JWindow->beg. In this case, JWindow beg gets shifted if Point = 0. */ if ((linenum < m->n) || ((linenum == m->n) && (m->point > Point))) m->n += 1; if ((m->line == CLine) && (m->point > Point)) { m->line = CLine->next; m->point -= Point; if (m->point > m->line->len) m->point = m->line->len; } m = m->next; } } void jed_update_marks (int type, int n) /*{{{*/ { register Window_Type *w; register Buffer *b = CBuf; Mark *m; #if JED_HAS_SAVE_NARROW Jed_Save_Narrow_Type *save_narrow; #endif void (*update_marks_fun) (Mark *, unsigned int, int); unsigned int line_num; if (!n) return; switch (type) { case CINSERT: update_marks_fun = cinsert_update_marks; break; case CDELETE: update_marks_fun = cdelete_update_marks; break; case LDELETE: update_marks_fun = ldelete_update_marks; break; case NLINSERT: update_marks_fun = nlinsert_update_marks; break; case NLDELETE: update_marks_fun = nldelete_update_marks; break; default: update_marks_fun = NULL; /* crash. I want to know about this */ } Cursor_Motion = 0; if (b->flags & UNDO_ENABLED) { if (b->undo == NULL) create_undo_ring(); Undo_Buf_Unch_Flag = !(b->flags & BUFFER_MODIFIED); } mark_buffer_modified (b, 1, 0); line_num = LineNum + b->nup; #if JED_HAS_LINE_ATTRIBUTES if ((b->min_unparsed_line_num == 0) || (b->min_unparsed_line_num > line_num)) b->min_unparsed_line_num = line_num; if ((b->max_unparsed_line_num == 0) || (b->max_unparsed_line_num < line_num)) b->max_unparsed_line_num = line_num; #endif if ((m = b->spots) != NULL) (*update_marks_fun)(m, line_num, n); if ((m = b->marks) != NULL) (*update_marks_fun)(m, line_num, n); if ((m = b->user_marks) != NULL) (*update_marks_fun)(m, line_num, n); #if JED_HAS_SAVE_NARROW save_narrow = b->save_narrow; while (save_narrow != NULL) { (*update_marks_fun) (save_narrow->beg, line_num, n); (*update_marks_fun) (save_narrow->end, line_num, n); save_narrow = save_narrow->next; } #endif w = JWindow; do { if (w->buffer == b) { (*update_marks_fun) (&w->mark, line_num, n); (*update_marks_fun) (&w->beg, line_num, n); } w = w->next; } while (w != JWindow); if (!Suspend_Screen_Update) register_change(type); } /*}}}*/ int jed_prepare_for_modification (int check_line_readonly) { if (CBuf->flags & READ_ONLY) { jed_verror ("Buffer %s is read-only", CBuf->name); return -1; } #if JED_HAS_LINE_ATTRIBUTES if (check_line_readonly && (CLine->flags & JED_LINE_IS_READONLY)) { jed_verror ("This line is read-only"); return -1; } #endif if (CBuf->flags & BUFFER_MODIFIED) return 0; if (0 == CBuf->file[0]) return 0; /* not attached to a file */ /* if ((SLang_get_error () == 0) */ if (0 == (CBuf->flags & BUFFER_NON_LOCKING)) { if (0 == (CBuf->flags & FILE_MODIFIED)) check_buffer (CBuf); if (CBuf->flags & FILE_MODIFIED) { if (1 != jed_get_y_n ("File changed on disk. Do you really want to edit this buffer")) return -1; } #if 0 /* If the buffer has had the read_only flag unset, then assume the user * knows what he/she is doing. */ if (1 == jed_buffer_file_is_readonly (CBuf)) { if (1 != jed_get_y_n ("Disk file is read-only. Do you really want to edit this buffer")) { CBuf->flags |= READ_ONLY; return -1; } } #endif if ((-1 == jed_lock_buffer_file (CBuf)) && SLang_get_error ()) return -1; } #if 0 if (SLang_get_error ()) return -1; #endif return 0; } /* This function does not handle newlines, that is, it does not split the * line if one is inserted. */ int _jed_ins_byte (unsigned char c) /*{{{*/ { register unsigned char *p, *p1, *p2; if (-1 == jed_prepare_for_modification (0)) return -1; #ifdef KEEP_SPACE_INFO if (CLine->space <= CLine->len + 1) remake_line(CLine->space + 15); #else remake_line (CLine->len + 1); #endif p = CLine->data + Point; if (Point < CLine->len) { p1 = CLine->data + (CLine->len - 1); p2 = p1 + 1; while(p1 >= p) { *p2 = *p1; p2 = p1; p1--; /* *(p1 + 1) = *p1; p1--; */ } } *p = c; CLine->len += 1; jed_update_marks(CINSERT,1); if ((c != '\n') || (CBuf == MiniBuffer)) record_insertion(1); Point++; return 0; } /*}}}*/ int jed_del_newline(void) /*{{{*/ { if (-1 == jed_prepare_for_modification (1)) return -1; #if JED_HAS_LINE_ATTRIBUTES if ((CLine->next != NULL) && (CLine->len > 1) && (CLine->next->flags & JED_LINE_IS_READONLY)) { msg_error (Line_Read_Only_Error); return -1; } #endif if (!eol() || eobp()) return -1; CLine->len -= 1; jed_update_marks(CDELETE,1); record_deletion((unsigned char *) "\n", 1); splice_line(); return 0; } /*}}}*/ /* del *np chars up until newline. Return actual number deleted. */ int jed_del_nbytes (int n) /*{{{*/ { register int nn; register unsigned char *p, *pmax; if ((n == 0) || !CLine->len) return 0; nn = CLine->len - 1; p = CLine->data + nn; if ((*p == '\n') && (CBuf != MiniBuffer)) nn = nn - Point; else nn = nn - Point + 1; p = CLine->data + Point; nn = nn > n ? n : nn; if (!nn) return (0); if (-1 == jed_prepare_for_modification (1)) return -1; jed_update_marks(CDELETE, nn); record_deletion(p, nn); CLine->len -= nn; pmax = CLine->data + CLine->len; while (p < pmax) { *p = *(p + nn); p++; } return nn; } /*}}}*/ /* delete n characters, crossing nl if necessary */ int jed_generic_del_nbytes (int n) /*{{{*/ { /* while ((n > 0) && (SLang_get_error () == 0)) */ while (n > 0) { int dn; if (eobp()) { msg_error("End of Buffer."); return -1; } dn = jed_del_nbytes (n); if (dn == -1) return -1; n -= dn; if (n && (-1 == jed_del_newline())) return -1; n--; } return 0; } /*}}}*/ int jed_del_through_eol (void) { return jed_generic_del_nbytes (CLine->len - Point); } int jed_insert_newline (void) { #if JED_HAS_LINE_ATTRIBUTES unsigned int flags = CLine->flags; #endif if (-1 == jed_prepare_for_modification (Point != 0)) return -1; split_line(); #if JED_HAS_LINE_ATTRIBUTES if (Point == 0) CLine->flags = 0; #endif if (-1 == _jed_ins_byte ('\n')) return -1; (void) jed_down (1); #if JED_HAS_LINE_ATTRIBUTES CLine->flags = flags; #endif return 0; } /* MULTIBYTE OK */ int jed_del_wchar (void) { unsigned char *p, *pmax; if (eolp ()) return jed_del_through_eol (); p = CLine->data + Point; pmax = jed_multibyte_chars_forward (p, CLine->data + CLine->len, 1, NULL, 1); return jed_generic_del_nbytes (pmax - p); } int jed_quick_insert(register unsigned char *s, int n) /*{{{*/ { register unsigned char *p, *p1; int nl = 0; if (n == 0) return 0; if (-1 == jed_prepare_for_modification (0)) return -1; #if JED_HAS_LINE_ATTRIBUTES if ((CLine->flags & JED_LINE_IS_READONLY) && ((Point != 0) || (s[n-1] != '\n'))) { jed_verror (Line_Read_Only_Error); return -1; } #endif if ((*(s + (n - 1)) == '\n') && (CBuf != MiniBuffer)) { n--; nl = 1; if (-1 == jed_insert_newline ()) return -1; (void) jed_up(1); } #ifdef KEEP_SPACE_INFO if (CLine->space <= CLine->len + n + 1) remake_line(CLine->space + n + 8); #else if (n) remake_line (CLine->len + n); #endif if (n) { /* shove n chars over to make space */ p = CLine->data + Point; if (Point < CLine->len) /* could be equal for last line of buffer */ { p1 = CLine->data + CLine->len - 1; while(p1 >= p) { *(p1 + n) = *p1; p1--; } } CLine->len += n; SLMEMCPY((char *) p, (char *) s, n); jed_update_marks(CINSERT, n); record_insertion(n); Point += n; } if (nl) jed_down (1); return 0; } /*}}}*/ int jed_insert_nbytes (unsigned char *ss, int n) /*{{{*/ { register unsigned char nl, *pmax; register unsigned char *p, *p1, *s = ss; int n1; if (CBuf == MiniBuffer) nl = 0; else nl = '\n'; p1 = s; while (1) { p = p1; /* count the number until a new line is reached */ pmax = p1 + n; while((p1 < pmax) && (*p1 != nl)) p1++; n1 = (int) (p1 - p); if (p1 != pmax) n1++; if (-1 == jed_quick_insert(p, n1)) return -1; if (p1++ == pmax) return 0; n -= n1; } } /*}}}*/ /* Multibyte-safe */ int jed_insert_wchar_n_times (SLwchar_Type c, unsigned int n) /*{{{*/ { unsigned char wchar_buf [JED_MAX_MULTIBYTE_SIZE]; unsigned char buf[20*JED_MAX_MULTIBYTE_SIZE]; unsigned char *pmax; unsigned int len; if (n == 0) return 0; if (NULL == (pmax = jed_wchar_to_multibyte (c, wchar_buf))) return -1; len = pmax - wchar_buf; pmax = buf + (sizeof (buf) - len); while (n) { unsigned char *p = buf; while ((p < pmax) && n) { memcpy (p, wchar_buf, len); n--; p += len; } if (-1 == jed_insert_nbytes (buf, p - buf)) return -1; } return 0; } /*}}}*/ void insert_buffer(Buffer *b) /*{{{*/ { Buffer *cb; if ((cb = CBuf) == b) return; switch_to_buffer(b); push_spot(); bob(); jed_push_mark(); eob(); copy_region_to_buffer(cb); pop_spot(); switch_to_buffer(cb); touch_window(); } /*}}}*/ /* Multibyte safe */ int _jed_replace_wchar (SLwchar_Type ch) /*{{{*/ { unsigned char buf[JED_MAX_MULTIBYTE_SIZE]; unsigned char *b, *bmax; unsigned char *p, *pmax; if (ch == '\n') return -1; b = buf; bmax = jed_wchar_to_multibyte (ch, buf); if (bmax == NULL) return -1; p = CLine->data + Point; pmax = CLine->data + CLine->len; while ((p < pmax) && (b < bmax) && (*b == *p)) { b++; p++; } if (b == bmax) return 0; if (-1 == jed_insert_nbytes (buf, bmax - buf)) return -1; if (-1 == jed_del_wchar ()) return -1; (void) jed_left(1); return 0; } /*}}}*/ int jed_insert_string (SLFUTURE_CONST char *s) { return jed_insert_nbytes ((unsigned char *) s, strlen (s)); } int jed_insert_byte (unsigned char ch) { return jed_insert_nbytes (&ch, 1); } int jed_insert_wchar (SLwchar_Type ch) { unsigned char buf[JED_MAX_MULTIBYTE_SIZE]; unsigned char *b; if (NULL == (b = jed_wchar_to_multibyte (ch, buf))) return -1; return jed_insert_nbytes (buf, b-buf); } jed-0.99-19/src/vmsmail.h0000644002657400265740000005533611311317447014116 0ustar davisdavis/* Copyright (c) 1992, 1998, 2000, 2005, 2006 John E. Davis * This file is part of JED editor library source. * * You may distribute this file under the terms the GNU General Public * License. See the file COPYING for more information. */ typedef struct Mail_Type { unsigned short buflen; unsigned short code; long addr; long ret, junk; } Mail_Type; /* Created by SDL V3.1-7 */ /* Source: 8-AUG-1988 10:36:21 */ #ifndef $MAILDEF_H #define $MAILDEF_H /*** MODULE $MAILDEF ***/ /* */ /* Definitions needed for callable mail. */ /* */ /* */ /* NOTE: New item codes must be appended to the end of */ /* each category so users will not have to relink. */ /* We allow 1024 entries in eatch category. */ /* */ /* */ /* Send input codes */ /* */ #define MAIL$_SEND_SPARE_0 1 #define MAIL$_SEND_FOREIGN 2 /* Send foreign format message */ #define MAIL$_SEND_CC_LINE 3 /* CC text specification */ #define MAIL$_SEND_DEFAULT_NAME 4 /* Default file name for send */ #define MAIL$_SEND_DEFAULT_TRANSPORT 5 /* Default transport used for addressees */ #define MAIL$_SEND_ERROR_ENTRY 6 /* Entry point for send error routine */ #define MAIL$_SEND_FILENAME 7 /* Specification of file name to send */ #define MAIL$_SEND_FROM_LINE 8 /* From text specification */ #define MAIL$_SEND_NO_DEFAULT_TRANSPORT 9 /* Don't use any default transport on send */ #define MAIL$_SEND_PERS_NAME 10 /* Personal name text for message */ #define MAIL$_SEND_RECORD 11 /* Record to be sent */ #define MAIL$_SEND_RESULTSPEC 12 /* Resultant filespec bodypart */ #define MAIL$_SEND_SERVER 13 /* Operate in server mode (signal success) */ #define MAIL$_SEND_SUBJECT 14 /* Subject text specification */ #define MAIL$_SEND_SUCCESS_ENTRY 15 /* Entry point for send success routine */ #define MAIL$_SEND_TO_LINE 16 /* To line text specification */ #define MAIL$_SEND_UFLAGS 17 /* User flags (for header) to send */ #define MAIL$_SEND_USER_DATA 18 /* User specified context for action routines */ #define MAIL$_SEND_USERNAME 19 /* Username to add to the "To" list */ #define MAIL$_SEND_USERNAME_TYPE 20 /* Username type - TO or CC */ #define MAIL$_SEND_FID 21 /* FID of file to send */ #define MAIL$_SEND_NO_PERS_NAME 22 /* Send message without personal name */ #define MAIL$_SEND_IN_SPARE3 23 #define MAIL$_SEND_IN_SPARE4 24 #define MAIL$_SEND_IN_SPARE5 25 /* */ /* Send output codes */ /* */ #define MAIL$_SEND_COPY_REPLY 26 /* Copy self reply set in profile */ #define MAIL$_SEND_COPY_SEND 27 /* Copy self send set in profile */ #define MAIL$_SEND_USER 28 /* Username of caller */ #define MAIL$_SEND_COPY_FORWARD 29 /* Copy self forward set in profile */ #define MAIL$_SEND_OUT_SPARE2 30 #define MAIL$_SEND_OUT_SPARE3 31 #define MAIL$_SEND_OUT_SPARE4 32 #define MAIL$_SEND_OUT_SPARE5 33 #define MAIL$K_SEND_MIN_ITEM 1 #define MAIL$K_SEND_MAX_ITEM 33 #define MAIL$K_SEND_ITEMS 33 /* */ /* file input codes */ /* */ #define MAIL$_MAILFILE_SPARE_0 1025 #define MAIL$_MAILFILE_DEFAULT_NAME 1026 /* Default filespec to open */ #define MAIL$_MAILFILE_FOLDER_ROUTINE 1027 /* Entry point of routine to process foldernames */ #define MAIL$_MAILFILE_FULL_CLOSE 1028 /* Do a PURGE, CONVERT/RECLAIM if necessary on close */ #define MAIL$_MAILFILE_NAME 1029 /* File spec to open */ #define MAIL$_MAILFILE_RECLAIM 1030 /* Do RECLAIM on PURGE command */ #define MAIL$_MAILFILE_USER_DATA 1031 /* User specified context for action routines */ #define MAIL$_MAILFILE_WASTEBASKET_NAME 1032 /* New wastebasket name for file */ #define MAIL$_MAILFILE_IN_SPARE1 1033 #define MAIL$_MAILFILE_IN_SPARE2 1034 #define MAIL$_MAILFILE_IN_SPARE3 1035 #define MAIL$_MAILFILE_IN_SPARE4 1036 #define MAIL$_MAILFILE_IN_SPARE5 1037 #define MAIL$_MAILFILE_IN_SPARE6 1038 #define MAIL$_MAILFILE_IN_SPARE7 1039 #define MAIL$_MAILFILE_IN_SPARE8 1040 #define MAIL$_MAILFILE_IN_SPARE9 1041 #define MAIL$_MAILFILE_IN_SPARE10 1042 #define MAIL$_MAILFILE_IN_SPARE11 1043 #define MAIL$_MAILFILE_IN_SPARE12 1044 #define MAIL$_MAILFILE_IN_SPARE13 1045 #define MAIL$_MAILFILE_IN_SPARE14 1046 #define MAIL$_MAILFILE_IN_SPARE15 1047 #define MAIL$_MAILFILE_IN_SPARE16 1048 #define MAIL$_MAILFILE_IN_SPARE17 1049 #define MAIL$_MAILFILE_IN_SPARE18 1050 #define MAIL$_MAILFILE_IN_SPARE19 1051 #define MAIL$_MAILFILE_IN_SPARE20 1052 /* */ /* file output codes */ /* */ #define MAIL$_MAILFILE_DATA_RECLAIM 1053 /* Number of data buckets reclaimed */ #define MAIL$_MAILFILE_DATA_SCAN 1054 /* Number of data buckets scanned */ #define MAIL$_MAILFILE_DELETED_BYTES 1055 /* Number of free bytes in mail file */ #define MAIL$_MAILFILE_INDEX_RECLAIM 1056 /* Number of index buckets reclaimed */ #define MAIL$_MAILFILE_MAIL_DIRECTORY 1057 /* Mail sub-directory specification */ #define MAIL$_MAILFILE_MESSAGES_DELETED 1058 /* Number of messages deleted */ #define MAIL$_MAILFILE_RESULTSPEC 1059 /* Resultant file spec */ #define MAIL$_MAILFILE_TOTAL_RECLAIM 1060 /* Total buckets reclaimed */ #define MAIL$_MAILFILE_WASTEBASKET 1061 /* Wastebasket name */ #define MAIL$_MAILFILE_INDEXED 1062 /* ISAM file */ #define MAIL$_MAILFILE_OUT_SPARE2 1063 #define MAIL$_MAILFILE_OUT_SPARE3 1064 #define MAIL$_MAILFILE_OUT_SPARE4 1065 #define MAIL$_MAILFILE_OUT_SPARE5 1066 #define MAIL$_MAILFILE_OUT_SPARE6 1067 #define MAIL$_MAILFILE_OUT_SPARE7 1068 #define MAIL$_MAILFILE_OUT_SPARE8 1069 #define MAIL$_MAILFILE_OUT_SPARE9 1070 #define MAIL$_MAILFILE_OUT_SPARE10 1071 #define MAIL$_MAILFILE_OUT_SPARE11 1072 #define MAIL$_MAILFILE_OUT_SPARE12 1073 #define MAIL$_MAILFILE_OUT_SPARE13 1074 #define MAIL$_MAILFILE_OUT_SPARE14 1075 #define MAIL$_MAILFILE_OUT_SPARE15 1076 #define MAIL$_MAILFILE_OUT_SPARE16 1077 #define MAIL$_MAILFILE_OUT_SPARE17 1078 #define MAIL$_MAILFILE_OUT_SPARE18 1079 #define MAIL$_MAILFILE_OUT_SPARE19 1080 #define MAIL$_MAILFILE_OUT_SPARE20 1081 #define MAIL$K_MAILFILE_MIN_ITEM 1025 #define MAIL$K_MAILFILE_MAX_ITEM 1081 #define MAIL$K_MAILFILE_ITEMS 57 /* */ /* message input codes */ /* */ #define MAIL$_MESSAGE_SPARE_0 2048 #define MAIL$_MESSAGE_BACK 2049 /* Get previous message */ #define MAIL$_MESSAGE_BEFORE 2050 /* Select messages BEFORE date */ #define MAIL$_MESSAGE_CC_SUBSTRING 2051 /* Select messages containing CC substring */ #define MAIL$_MESSAGE_CONTINUE 2052 /* Read next record */ #define MAIL$_MESSAGE_FILE_ACTION 2053 /* File create action routine */ #define MAIL$_MESSAGE_FOLDER_ACTION 2054 /* Folder create action routine */ #define MAIL$_MESSAGE_DEFAULT_NAME 2055 /* Default file name */ #define MAIL$_MESSAGE_DELETE 2056 /* Delete message */ #define MAIL$_MESSAGE_ERASE 2057 /* Erase message */ #define MAIL$_MESSAGE_FILE_CTX 2058 /* File level context */ #define MAIL$_MESSAGE_FILENAME 2059 /* File name specification */ #define MAIL$_MESSAGE_FLAGS 2060 /* Header flags specification */ #define MAIL$_MESSAGE_FOLDER 2061 /* Folder name specification */ #define MAIL$_MESSAGE_FROM_SUBSTRING 2062 /* Select messages containing FROM substring */ #define MAIL$_MESSAGE_ID 2063 /* ID of message */ #define MAIL$_MESSAGE_NEXT 2064 /* Retrive NEXT message */ #define MAIL$_MESSAGE_SINCE 2065 /* Select messages SINCE date */ #define MAIL$_MESSAGE_SUBJ_SUBSTRING 2066 /* Select messages containing SUBJ substring */ #define MAIL$_MESSAGE_TO_SUBSTRING 2067 /* Select messages containing TO substring */ #define MAIL$_MESSAGE_UFLAGS 2068 /* User flags specification */ #define MAIL$_MESSAGE_AUTO_NEWMAIL 2069 /* Move newmail to MAIL auto */ #define MAIL$_MESSAGE_USER_DATA 2070 /* User context for action routines */ #define MAIL$_MESSAGE_FLAGS_MBZ 2071 /* Select messages with these flags set at zero */ #define MAIL$_MESSAGE_MIN_CLASS 2072 /* Min access class for message */ #define MAIL$_MESSAGE_MAX_CLASS 2073 /* Max access class for message */ #define MAIL$_MESSAGE_IN_SPARE1 2074 #define MAIL$_MESSAGE_IN_SPARE2 2075 #define MAIL$_MESSAGE_IN_SPARE3 2076 #define MAIL$_MESSAGE_IN_SPARE4 2077 #define MAIL$_MESSAGE_IN_SPARE5 2078 #define MAIL$_MESSAGE_IN_SPARE6 2079 #define MAIL$_MESSAGE_IN_SPARE7 2080 #define MAIL$_MESSAGE_IN_SPARE8 2081 #define MAIL$_MESSAGE_IN_SPARE9 2082 #define MAIL$_MESSAGE_IN_SPARE10 2083 #define MAIL$_MESSAGE_IN_SPARE11 2084 #define MAIL$_MESSAGE_IN_SPARE12 2085 #define MAIL$_MESSAGE_IN_SPARE13 2086 #define MAIL$_MESSAGE_IN_SPARE14 2087 #define MAIL$_MESSAGE_IN_SPARE15 2088 #define MAIL$_MESSAGE_IN_SPARE16 2089 #define MAIL$_MESSAGE_IN_SPARE17 2090 #define MAIL$_MESSAGE_IN_SPARE18 2091 #define MAIL$_MESSAGE_IN_SPARE19 2092 #define MAIL$_MESSAGE_IN_SPARE20 2093 /* */ /* message output codes */ /* */ #define MAIL$_MESSAGE_CC 2094 /* CC text of message */ #define MAIL$_MESSAGE_CURRENT_ID 2095 /* ID of current message */ #define MAIL$_MESSAGE_DATE 2096 /* Date of current message */ #define MAIL$_MESSAGE_EXTID 2097 /* Filespec of external message */ #define MAIL$_MESSAGE_FILE_CREATED 2098 /* Mailfile created... */ #define MAIL$_MESSAGE_FOLDER_CREATED 2099 /* Folder created... */ #define MAIL$_MESSAGE_FROM 2100 /* From text of message */ #define MAIL$_MESSAGE_RECORD 2101 /* Record from message */ #define MAIL$_MESSAGE_RECORD_TYPE 2102 /* Type of record, header or text */ #define MAIL$_MESSAGE_REPLY_PATH 2103 /* Reply path of sender */ #define MAIL$_MESSAGE_RESULTSPEC 2104 /* Resultant file spec */ #define MAIL$_MESSAGE_RETURN_FLAGS 2105 /* Message header system flags */ #define MAIL$_MESSAGE_RETURN_UFLAGS 2106 /* Message header user flags */ #define MAIL$_MESSAGE_SELECTED 2107 /* Number of messages selected */ #define MAIL$_MESSAGE_SENDER 2108 /* Sender name */ #define MAIL$_MESSAGE_SIZE 2109 /* Size of the current message */ #define MAIL$_MESSAGE_SUBJECT 2110 /* Subject text of the message */ #define MAIL$_MESSAGE_TO 2111 /* To text of the message */ #define MAIL$_MESSAGE_BUFFER 2112 /* Buffer address */ #define MAIL$_MESSAGE_RETURN_CLASS 2113 /* Class of current message */ #define MAIL$_MESSAGE_BINARY_DATE 2114 /* Binary date/time quadword */ #define MAIL$_MESSAGE_SPARE4 2115 #define MAIL$_MESSAGE_SPARE5 2116 #define MAIL$_MESSAGE_SPARE6 2117 #define MAIL$_MESSAGE_SPARE7 2118 #define MAIL$_MESSAGE_SPARE8 2119 #define MAIL$_MESSAGE_SPARE9 2120 #define MAIL$_MESSAGE_SPARE10 2121 #define MAIL$_MESSAGE_SPARE11 2122 #define MAIL$_MESSAGE_SPARE12 2123 #define MAIL$_MESSAGE_SPARE13 2124 #define MAIL$_MESSAGE_SPARE14 2125 #define MAIL$_MESSAGE_SPARE15 2126 #define MAIL$_MESSAGE_SPARE16 2127 #define MAIL$_MESSAGE_SPARE17 2128 #define MAIL$_MESSAGE_SPARE18 2129 #define MAIL$_MESSAGE_SPARE19 2130 /* */ /* Constants returned */ /* */ #define MAIL$_MESSAGE_NULL 2131 /* Null bodypart */ #define MAIL$_MESSAGE_HEADER 2132 /* Header record returned */ #define MAIL$_MESSAGE_TEXT 2133 /* Text record returned */ #define MAIL$_MESSAGE_SPARE20 2134 #define MAIL$K_MESSAGE_MIN_ITEM 2048 #define MAIL$K_MESSAGE_MAX_ITEM 2134 #define MAIL$K_MESSAGE_ITEMS 87 /* */ /* user input codes */ /* */ #define MAIL$_USER_SPARE_0 3072 #define MAIL$_USER_FIRST 3073 /* Retrive first user record */ #define MAIL$_USER_NEXT 3074 /* Retrive next user record */ #define MAIL$_USER_USERNAME 3075 /* Retrive record for username */ #define MAIL$_USER_SET_AUTO_PURGE 3076 /* Set auto-purge */ #define MAIL$_USER_SET_NO_AUTO_PURGE 3077 /* Clear auto-purge */ #define MAIL$_USER_SET_SUB_DIRECTORY 3078 /* Set sub-dir field */ #define MAIL$_USER_SET_NO_SUB_DIRECTORY 3079 /* Clear sub-dir field */ #define MAIL$_USER_SET_FORWARDING 3080 /* Set forwarding address */ #define MAIL$_USER_SET_NO_FORWARDING 3081 /* Clear forwarding address */ #define MAIL$_USER_SET_PERSONAL_NAME 3082 /* Set personal name */ #define MAIL$_USER_SET_NO_PERSONAL_NAME 3083 /* Clear personal name */ #define MAIL$_USER_SET_COPY_SEND 3084 /* Set copy-send */ #define MAIL$_USER_SET_NO_COPY_SEND 3085 /* Clear copy send */ #define MAIL$_USER_SET_COPY_REPLY 3086 /* Set copy reply */ #define MAIL$_USER_SET_NO_COPY_REPLY 3087 /* Clear copy reply */ #define MAIL$_USER_SET_NEW_MESSAGES 3088 /* Set new message count */ #define MAIL$_USER_CREATE_IF 3089 /* Create record if does not exist */ #define MAIL$_USER_SET_MAILPLUS 3090 /* Set M+ */ #define MAIL$_USER_SET_NO_MAILPLUS 3091 /* Clear M+ */ #define MAIL$_USER_SET_TRANSPORT 3092 /* Set transport field */ #define MAIL$_USER_SET_NO_TRANSPORT 3093 /* Clear transport field */ #define MAIL$_USER_SET_EDITOR 3094 /* Set editor field */ #define MAIL$_USER_SET_NO_EDITOR 3095 /* Clear editor field */ #define MAIL$_USER_SET_QUEUE 3096 /* Set queue field */ #define MAIL$_USER_SET_NO_QUEUE 3097 /* Clear queue field */ #define MAIL$_USER_SET_USER1 3098 /* Set user1 field */ #define MAIL$_USER_SET_NO_USER1 3099 /* Clear user1 field */ #define MAIL$_USER_SET_USER2 3100 /* Set user2 field */ #define MAIL$_USER_SET_NO_USER2 3101 /* Clear user2 field */ #define MAIL$_USER_SET_USER3 3102 /* Set user3 field */ #define MAIL$_USER_SET_NO_USER3 3103 /* Clear user3 field */ #define MAIL$_USER_SET_FORM 3104 /* Set form field */ #define MAIL$_USER_SET_NO_FORM 3105 /* Clear form field */ #define MAIL$_USER_SET_COPY_FORWARD 3106 /* Set copy self forward */ #define MAIL$_USER_SET_NO_COPY_FORWARD 3107 /* Clear copy self forward */ #define MAIL$_USER_SET_CC_PROMPT 3108 /* Set CC prompting */ #define MAIL$_USER_SET_NO_CC_PROMPT 3109 /* Clear CC prompting */ #define MAIL$_USER_SET_SPARE3 3110 #define MAIL$_USER_SET_NO_SPARE3 3111 #define MAIL$_USER_IN_SPARE1 3112 #define MAIL$_USER_IN_SPARE2 3113 #define MAIL$_USER_IN_SPARE3 3114 #define MAIL$_USER_IN_SPARE4 3115 #define MAIL$_USER_IN_SPARE5 3116 #define MAIL$_USER_IN_SPARE6 3117 #define MAIL$_USER_IN_SPARE7 3118 #define MAIL$_USER_IN_SPARE8 3119 #define MAIL$_USER_IN_SPARE9 3120 #define MAIL$_USER_IN_SPARE10 3121 #define MAIL$_USER_IN_SPARE11 3122 #define MAIL$_USER_IN_SPARE12 3123 #define MAIL$_USER_IN_SPARE13 3124 #define MAIL$_USER_IN_SPARE14 3125 #define MAIL$_USER_IN_SPARE15 3126 #define MAIL$_USER_IN_SPARE16 3127 #define MAIL$_USER_IN_SPARE17 3128 #define MAIL$_USER_IN_SPARE18 3129 #define MAIL$_USER_IN_SPARE19 3130 #define MAIL$_USER_IN_SPARE20 3131 /* */ /* Output item parameters */ /* */ #define MAIL$_USER_MAILPLUS 3132 /* M+ field */ #define MAIL$_USER_TRANSPORT 3133 /* Transport field */ #define MAIL$_USER_EDITOR 3134 /* Editor field */ #define MAIL$_USER_QUEUE 3135 /* Queue field */ #define MAIL$_USER_USER1 3136 /* User1 field */ #define MAIL$_USER_USER2 3137 /* User2 field */ #define MAIL$_USER_USER3 3138 /* User3 field */ #define MAIL$_USER_FORM 3139 /* Form field */ #define MAIL$_USER_COPY_FORWARD 3140 /* Copy forward flag */ #define MAIL$_USER_SPARE3 3141 #define MAIL$_USER_RETURN_USERNAME 3142 /* Username of current record */ #define MAIL$_USER_AUTO_PURGE 3143 /* Auto purge flag */ #define MAIL$_USER_SUB_DIRECTORY 3144 /* Sub-dir spec */ #define MAIL$_USER_FULL_DIRECTORY 3145 /* Full directory spec */ #define MAIL$_USER_NEW_MESSAGES 3146 /* New message count */ #define MAIL$_USER_FORWARDING 3147 /* Forwarding field */ #define MAIL$_USER_PERSONAL_NAME 3148 /* Personal name field */ #define MAIL$_USER_COPY_SEND 3149 /* Copy send flag */ #define MAIL$_USER_COPY_REPLY 3150 /* Copy reply flag */ #define MAIL$_USER_CAPTIVE 3151 /* User is captive */ #define MAIL$_USER_CC_PROMPT 3152 /* CC prompting flag */ #define MAIL$_USER_OUT_SPARE2 3153 #define MAIL$_USER_OUT_SPARE3 3154 #define MAIL$_USER_OUT_SPARE4 3155 #define MAIL$_USER_OUT_SPARE5 3156 #define MAIL$_USER_OUT_SPARE6 3157 #define MAIL$_USER_OUT_SPARE7 3158 #define MAIL$_USER_OUT_SPARE8 3159 #define MAIL$_USER_OUT_SPARE9 3160 #define MAIL$_USER_OUT_SPARE10 3161 #define MAIL$_USER_OUT_SPARE11 3162 #define MAIL$_USER_OUT_SPARE12 3163 #define MAIL$_USER_OUT_SPARE13 3164 #define MAIL$_USER_OUT_SPARE14 3165 #define MAIL$_USER_OUT_SPARE15 3166 #define MAIL$_USER_OUT_SPARE16 3167 #define MAIL$_USER_OUT_SPARE17 3168 #define MAIL$_USER_OUT_SPARE18 3169 #define MAIL$_USER_OUT_SPARE19 3170 #define MAIL$_USER_OUT_SPARE20 3171 #define MAIL$K_USER_MIN_ITEM 3072 #define MAIL$K_USER_MAX_ITEM 3171 #define MAIL$K_USER_ITEMS 100 /* */ /* Special items */ /* */ #define MAIL$_NOOP 4097 /* Do nothing - used for testing */ #define MAIL$_NOSIGNAL 4098 /* Don't signal errors */ #define MAIL$_NOPROBE 4099 /* Don't probe the item list buffers */ #define MAIL$_TLD_INPUT 4100 /* This item is a tld to be used as input */ #define MAIL$_TLD_OUTPUT 4101 /* This item describes a buffer to fill */ /* */ /* Username types for mail$send_add_address */ /* */ #define MAIL$_TO 1 /* Address part of the TO line */ #define MAIL$_CC 2 /* Address part of the CC line */ #define MAIL$_SPARE1 3 #define MAIL$_SPARE2 4 /* */ /* Define the flag values for mail system flags */ /* */ #define MAIL$M_NEWMSG 0x00000001 #define MAIL$M_REPLIED 0x00000002 #define MAIL$M_DEL 0x00000004 #define MAIL$M_EXTMSG 0x00000008 #define MAIL$M_EXTFNF 0x00000010 #define MAIL$M_SYSMSG 0x00000020 #define MAIL$M_EXTNSTD 0x00000040 #define MAIL$M_MARKED 0x00000080 #define MAIL$M_RECMODE 0x00000100 struct flagsdef { union { unsigned short int mail$w_flags; /*Flags word */ struct { unsigned mail$v_newmsg : 1; /*This is a new message */ unsigned mail$v_replied : 1; /*This message has been replied to */ unsigned mail$v_del : 1; /*This message is deleted */ unsigned mail$v_extmsg : 1; /*Message text in external file */ unsigned mail$v_extfnf : 1; /*External message file not found */ unsigned mail$v_sysmsg : 1; /*Message text in system file */ unsigned mail$v_extnstd : 1; /*External file is not var-seq file */ unsigned mail$v_marked : 1; /*This message has been marked */ unsigned mail$v_recmode : 1; /*This message should be read in record mode */ unsigned mail$v_fill_2 : 7; } mail$r_fill_1; } mail$r_fill_0; } ; #endif jed-0.99-19/src/modules.unx0000644002657400265740000000126011311317447014464 0ustar davisdavisbuffer abbrev.h cmds blocal.h misc buffer.h file cmds.h main display.h ins file.h sig hooks.h sysdep indent.h screen ins.h paste jdmacros.h ledit jed-feat.h line jprocess.h search keymap.h text ledit.h keymap line.h replace lineattr.h window menu.h undo misc.h vfile paste.h intrin replace.h syntax screen.h abbrev search.h indent sig.h jprocess sysdep.h lineattr text.h blocal undo.h mouse userinfo.h menu version.h userinfo vfile.h lock vmsmail.h version vterm.h hooks window.h colors jed-0.99-19/src/win32.c0000644002657400265740000003060411311317447013372 0ustar davisdavis/* Copyright (c) 1992, 1998, 2000, 2002, 2003, 2004, 2005, 2006 John E. Davis * This file is part of JED editor library source. * * You may distribute this file under the terms the GNU General Public * License. See the file COPYING for more information. */ #include "config.h" #include "jed-feat.h" #include #include #include #include "jdmacros.h" #include #include #include #ifdef _MSC_VER # include #endif #if defined(__BORLANDC__) # include # define _fdopen fdopen #endif #ifdef HAVE_UNISTD_H # include #endif #include #include #include #include #include #include "jedlimit.h" #include "display.h" #include "sysdep.h" #include "screen.h" #include "keymap.h" #include "hooks.h" #include "ins.h" #include "ledit.h" #include "misc.h" #include "cmds.h" #include "sig.h" #include "window.h" #include "win32.h" #if JED_HAS_SUBPROCESSES # include "jprocess.h" #endif #if SLANG_VERSION < 20000 # define SLw32_Hstdin _SLw32_Hstdin extern HANDLE _SLw32_Hstdin; #endif static int x_insert_cutbuffer(void); static void x_region_2_cutbuffer(void); static void x_warp_pointer(void); static int msw_system(char *, int *, int *); static SLang_Intrin_Fun_Type Jed_WinCommon_Table[] = { MAKE_INTRINSIC("x_warp_pointer", x_warp_pointer, VOID_TYPE, 0), MAKE_INTRINSIC("x_insert_cutbuffer", x_insert_cutbuffer, INT_TYPE, 0), /* Prototype: Integer x_insert_cut_buffer (); * Inserts cutbuffer into the current buffer and returns the number * of characters inserted. */ MAKE_INTRINSIC("x_copy_region_to_cutbuffer", x_region_2_cutbuffer, VOID_TYPE, 0), /*Prototype: Void x_copy_region_to_cutbuffer();*/ MAKE_INTRINSIC(NULL, NULL, 0,0) }; static int init_intrinsics (void) { if (-1 == SLadd_intrinsic_function ("msw_system", (FVOID_STAR) msw_system, SLANG_INT_TYPE, 3, SLANG_STRING_TYPE, SLANG_INT_TYPE, SLANG_INT_TYPE)) return -1; if ((-1 == SLadd_intrin_fun_table (Jed_WinCommon_Table, "MSWINDOWS")) || (-1 == SLdefine_for_ifdef ("MOUSE"))) return -1; return 0; } int Jed_W32_Is_GUI; int init_tty(void) { if (-1 == jed_add_init_slang_hook (init_intrinsics)) return -1; if (X_Init_Term_Hook != NULL) return (*X_Init_Term_Hook) (); Jed_W32_Is_GUI = 0; if (-1 == SLang_init_tty (7, 1, 0)) return -1; Input_Events[0] = SLw32_Hstdin; return 0; } void reset_tty (void) { if (Batch) return; if (X_Init_Term_Hook != NULL) { if (X_Reset_Term_Hook != NULL) (*X_Reset_Term_Hook) (); return; } SLang_reset_tty(); } int sys_System(char *command_line) { return shell_command(command_line); } void sys_pause (int ms) { Sleep(ms); } void init_signals() { } /* Delete the file NAME. returns 0 on failure, 1 on sucess * Under OS/2 and DOS, unlink()[UNIX] and remove()[ANSI] are equivalent. */ int sys_delete_file(char *name) { return(1 + remove(name)); } static WIN32_FIND_DATA findata; static HANDLE hsearch = INVALID_HANDLE_VALUE; static char Found_Dir[JED_MAX_PATH_LEN]; static char Found_File[JED_MAX_PATH_LEN]; static int Found_FLen; static void fixup_name(char *file) { int dir; char name[JED_MAX_PATH_LEN]; strcpy (file, Found_Dir); strcpy (name, findata.cFileName); dir = (findata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY); strcat(file, name); if (dir) strcat(file, "\\"); } int sys_findfirst (char *thefile) { char *f, the_path[JED_MAX_PATH_LEN], *file, *f1; char *pat; file = jed_standardize_filename_static(thefile); f1 = f = extract_file(file); strcpy (Found_Dir, file); strcpy (Found_File, file); Found_FLen = strlen(Found_File); Found_Dir[(int) (f - file)] = 0; strcpy(the_path, file); while (*f1 && (*f1 != '*')) f1++; if (! *f1) { while (*f && (*f != '.')) f++; strcat(the_path, "*"); } pat = the_path; if (hsearch != INVALID_HANDLE_VALUE) FindClose (hsearch); if ((INVALID_HANDLE_VALUE != (hsearch = FindFirstFile (pat, &findata)))) { fixup_name(file); /* The windows file system is case-insensitive, so if one * searches for makefi*, the OS will return Makefile.in * between the others, so check for wrong values and reject * them */ if (Jed_Filename_Case_Sensitive && (0 != strncmp (file, Found_File, Found_FLen)) && !sys_findnext (file)) return 0; strcpy (thefile, file); return(1); } else return 0; } int sys_findnext(char *file) { while (FindNextFile (hsearch, &findata)) { fixup_name(file); if (Jed_Filename_Case_Sensitive && (0 != strncmp (file, Found_File, Found_FLen))) continue; return 1; } FindClose (hsearch); hsearch = INVALID_HANDLE_VALUE; return 0; } /* returns 0 if file does not exist, 1 if it is not a dir, 2 if it is */ int sys_chmod (SLFUTURE_CONST char *file, int what, mode_t *mode, uid_t *uid, gid_t *gid) { #ifdef _MSC_VER struct _stat st; #else struct stat st; #endif char filebuf[JED_MAX_PATH_LEN+1]; unsigned int len; if (what) { #ifdef _MSC_VER _chmod(file, *mode); #else (void) chmod(file, *mode); #endif return 0; } /* strip the trailing backslash if necessary */ len = strlen (file); if ((len > 1) && (file[len-1] == SLASH_CHAR) && (file[len-2] != ':')) { if (len + 1 > sizeof(filebuf)) { jed_verror ("Path too long: %s", file); return -1; } strcpy (filebuf, file); file = filebuf; len--; file[len] = 0; } if ( #ifdef _MSC_VER _stat(file, &st) < 0 #else stat(file, &st) < 0 #endif ) { if ((file[0] == SLASH_CHAR) && (file[1] == SLASH_CHAR)) { int at = GetFileAttributes(file); if (at >= 0) { if (at & FILE_ATTRIBUTE_DIRECTORY) return 2; else return 1; } } return 0; } *mode = st.st_mode & 0777; if (st.st_mode & S_IFDIR) return 2; return 1; } static void x_warp_pointer (void) { } static void x_region_2_cutbuffer (void) { int i, x, nbytes; char *dat, *buf; HGLOBAL hBuf; dat = make_buffer_substring(&nbytes); if (dat == NULL) return; /* space for LF -> CR/LF translation(s) */ for (i = x = 0; i < nbytes; i++) if (dat[i] == '\n') x++; hBuf = GlobalAlloc(GHND, x + nbytes + 1); /* space for trailing nul */ buf = (char *) GlobalLock(hBuf); for (i = x = 0; i < nbytes; i++) { if (dat[i] == '\n') buf[x++] = '\r'; /* LF -> CR/LF */ buf[x++] = dat[i]; } /* since GlobalAlloc() is like calloc(), trailing nul is 'automatic' */ /* tranfer data to clipboard */ OpenClipboard(NULL); /* This_Window.w); */ EmptyClipboard(); GlobalUnlock(hBuf); SetClipboardData(CF_TEXT, hBuf); CloseClipboard(); SLfree (dat); /* discard string */ } static int x_insert_cutbuffer (void) { int nbytes = 0; char *dat; int i, x; HGLOBAL hBuf; char *buf; CHECK_READ_ONLY; OpenClipboard(NULL); hBuf = GetClipboardData(CF_TEXT); CloseClipboard(); if (hBuf) { buf = (char *)GlobalLock(hBuf); for(i = x = 0; buf[i] != 0; i++) if (buf[i] != '\r') x++; nbytes = x; dat = SLmalloc (x + 1); if (dat != NULL) { for(i = x = 0; buf[i] != 0; i++) if (buf[i] != '\r') dat[x++] = buf[i]; dat[x] = 0; jed_insert_nbytes((unsigned char *) dat, nbytes); SLfree (dat); } GlobalUnlock(hBuf); } return nbytes; } static int msw_system(char *command_line, int *nCmdShow, int *wait) { UINT retcode; HCURSOR hcur, hcur_old; STARTUPINFO si; PROCESS_INFORMATION pi; memset ((char *) &si, 0, sizeof (STARTUPINFO)); si.wShowWindow = *nCmdShow; si.dwFlags = STARTF_USESHOWWINDOW; si.cb = sizeof(si); retcode = CreateProcess (NULL, command_line, NULL, NULL, 0, NORMAL_PRIORITY_CLASS, NULL, NULL, &si, &pi); if (!retcode) { msg_error ("Unable to create process"); return 1; } if (!*wait) return 0; hcur = LoadCursor(NULL, IDC_WAIT); hcur_old = SetCursor(hcur); WaitForSingleObject(pi.hProcess, INFINITE); SetCursor(hcur_old); return 0; } /* popen, pclose function for Win32 -- it seems that standard ones work * only for console applications. */ # define MAX_POPEN 10 typedef struct { FILE *fp; HANDLE hprocess; } Popen_Type; static int Popen_Ptr = 0; static Popen_Type Popen_Buf[MAX_POPEN]; static char *get_helper_app (void) { char *s; if (1 == SLang_execute_function ("_win32_get_helper_app_name")) { if (-1 == SLang_pop_slstring (&s)) return NULL; return s; } msg_error ("call to _win32_get_helper_app_name failed"); return NULL; } char *w32_build_command (char **argv, unsigned int num) { unsigned int len; unsigned int i; char *helper; char *cmd; helper = get_helper_app (); if (NULL == helper) return NULL; len = strlen (helper); if (len) len++; for (i = 0; i < num; i++) len += 1 + strlen (argv[i]); cmd = SLmalloc (len + 1); if (cmd == NULL) { SLang_free_slstring (helper); return NULL; } len = strlen (helper); if (len) { strcpy (cmd, helper); cmd[len] = ' '; len++; } for (i = 0; i < num; i++) { strcpy (cmd + len, argv[i]); len += strlen(argv[i]); cmd[len] = ' '; len++; } cmd[len] = 0; SLang_free_slstring (helper); return cmd; } FILE *w32_popen(char *cmd, char *mode) { int fd; HANDLE rd, wr, er, h, p; STARTUPINFO si; PROCESS_INFORMATION pi; FILE *fp; if (Popen_Ptr == MAX_POPEN) { msg_error("too many popens"); return NULL; } if (((*mode != 'r') && (*mode != 'w')) || (*(mode + 1) != 0)) { errno = EINVAL; return(NULL); } if (*mode == 'w') { msg_error ("popen mode `w' not implemented"); return NULL; } p = GetCurrentProcess (); if (FALSE == CreatePipe(&rd, &wr, NULL, 0)) /* NOT inherited */ return NULL; if (FALSE == DuplicateHandle (p, wr, p, &h, 0, TRUE, DUPLICATE_SAME_ACCESS)) { CloseHandle (rd); CloseHandle (wr); } CloseHandle (wr); wr = h; /* Get stderr handle from stdout */ if (FALSE == DuplicateHandle (p, wr, p, &er, 0, TRUE, DUPLICATE_SAME_ACCESS)) { CloseHandle (rd); CloseHandle (wr); return NULL; } if (NULL == (cmd = w32_build_command (&cmd, 1))) { CloseHandle (rd); CloseHandle (wr); return NULL; } memset ((char *) &si, 0, sizeof (STARTUPINFO)); si.cb = sizeof(STARTUPINFO); si.lpReserved = NULL; si.lpReserved2 = NULL; si.cbReserved2 = 0; si.lpDesktop = NULL; si.lpTitle = NULL; si.dwFlags = STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW; /* si.wShowWindow = SW_MINIMIZE; */ si.wShowWindow = SW_HIDE; si.hStdInput = GetStdHandle (STD_INPUT_HANDLE); si.hStdOutput = wr; si.hStdError = er; if (!CreateProcess(NULL, cmd, NULL, NULL, TRUE, CREATE_NEW_CONSOLE, NULL, NULL, &si, &pi)) { jed_verror ("popen failed (cmd=%s)", cmd); SLfree (cmd); CloseHandle (rd); CloseHandle (wr); CloseHandle (er); return NULL; } CloseHandle (wr); CloseHandle (er); SLfree (cmd); fd = _open_osfhandle((long) rd, O_RDONLY|O_TEXT); if ((fd < 0) || (NULL == (fp = _fdopen(fd, mode)))) { CloseHandle(pi.hProcess); CloseHandle(pi.hThread); if (fd < 0) CloseHandle (rd); else _close (fd); return NULL; } CloseHandle (pi.hThread); CloseHandle (pi.hProcess); Popen_Buf[Popen_Ptr].hprocess = pi.hProcess; Popen_Buf[Popen_Ptr].fp = fp; Popen_Ptr++; return fp; } int w32_pclose(FILE *fp) { int i; i = Popen_Ptr - 1; while (i >= 0) { if (Popen_Buf[i].fp == fp) { DWORD d = 0; /* send EOF */ (void) fputs ("\x1a", fp); (void) fflush (fp); #ifndef __BORLANDC__ if (fclose(fp) == EOF) return -1; #else /* [JMS] Something odd with Borland C possibly, as the fclose attempt seems */ /* [JMS] to fail every time, resulting in a 'too many popens' error as */ /* [JMS] the failure causes the function to abort without removing the */ /* [JMS] entry from the table. */ if (fclose(fp) == EOF) d = -1; #endif #if 0 if (WaitForSingleObject(Popen_Buf[i].hprocess, 1000) == WAIT_TIMEOUT) { d = TerminateProcess(Popen_Buf[i].hprocess, -1); } GetExitCodeProcess(Popen_Buf[i].hprocess, &d); #endif i++; while (i < Popen_Ptr) { Popen_Buf[i - 1] = Popen_Buf[i]; i++; } Popen_Ptr--; return d; } i--; } return -1; } jed-0.99-19/src/dfasyntx.c0000644002657400265740000010337111311317447014272 0ustar davisdavis/* Copyright (c) Simon Tatham * * This file is part of JED editor library source. * * It was written by Simon Tatham for use in the JED editor. * * You may distribute this file under the terms the GNU General Public * License. See the file COPYING for more information. */ /* * DFA-based syntax highlighting for Jed. */ /* This file is included by syntax.c */ #include "dfasyntx.h" #include "version.h" #define USE_DFA_CACHE 1 /* * The minimum number of "unsigned char"s we need to store at least * UCHAR_MAX+1 bits. */ #define SET_SIZE ((UCHAR_MAX+CHAR_BIT) / CHAR_BIT) #define EQUIV_TABLE_SIZE (UCHAR_MAX+1) typedef struct NFA NFA; typedef struct Accept Accept; typedef struct DFA DFA; /* * Set of characters. Note that this will not be the only kind of * set manipulated by the macros below - while constructing the DFA * table we will need to deal with sets of NFA states as well. */ typedef unsigned char Set[SET_SIZE]; /* * Macros for set manipulation. Beware - these macros are unsafe * with respect to side effects! */ #define empty_set(s,size) memset ((s), (unsigned char) 0, size) #define fill_set(s,size) memset ((s), (unsigned char) ~0, size) #define add_to_set(s,c) ((s)[(c)/CHAR_BIT] |= 1 << (c)%CHAR_BIT) #define take_from_set(s,c) ((s)[(c)/CHAR_BIT] &= ~(1 << (c)%CHAR_BIT)) #define is_in_set(s,c) ((s)[(c)/CHAR_BIT] & (1 << (c)%CHAR_BIT)) struct NFA { NFA *next; int from, to; int is_empty; Set set; }; struct Accept { Accept *next; int state; int is_quick, is_end; int colour, is_preproc, is_keyword; }; struct DFA { DFA *next; int number; unsigned char *nfa_set; /* the corresp. set of NFA states */ Accept *accept, *accept_end; DFA *where_to[UCHAR_MAX+1]; }; /* * This structure contains all the information for syntax * highlighting a given language. We have an NFA, generated by * parsing regular expressions, stored as a list of transitions. We * also partition the set of "unsigned char" values into * equivalence classes, accomplished by storing, in equiv[c], the * lowest value in the same equivalence class as c. "accept" is a * list of accepting states in the NFA, together with their colours * and properties, and "dfa" is the actual DFA table. * * DFA tables can take some time to generate - over a second on my * 486 for C mode - and so instead of generating them every time * Jed needs them, I support a caching option. */ struct Highlight { int nfa_states, dfa_states; NFA *nfa; unsigned char equiv[EQUIV_TABLE_SIZE]; Accept *accept; DFA *dfa; char *filename; }; /* * Local prototypes. */ static int parse_regexp (Highlight *, char **, int *, int *, int *, int *, int *); static int parse_reg1 (Highlight *, char **, int *, int *, int *); static int parse_reg2 (Highlight *, char **, int *, int *, int *); static int parse_reg3 (Highlight *, char **, int *, int *, int *); static int parse_reg4 (Highlight *, char **, int *, int *, int *); static void add_nfa_trans (Highlight *, int , int , Set); static int get_lexeme (char **, int *); static void eat_lexeme (char **, int *); static void compute_closure (Highlight *, unsigned char *); /* * Parser error codes. */ #define ERR_EOT_EXPECTED 1 #define ERR_RPAREN_EXPECTED 2 #define ERR_EMPTY_SET 3 #define ERR_METACHAR_INVALID 4 static Highlight *init_highlight (void) { Highlight *result; result = (Highlight *) SLmalloc (sizeof (Highlight)); if (result != NULL) { memset ((char *) result, 0, sizeof (Highlight)); result->nfa_states = 2; /* 0 and 1 are "special" */ } return result; } #define FLAG_QUICK 1 #define FLAG_KEYWORD 2 #define FLAG_PREPROC 4 static void add_rule (Highlight *h, char *rule, int length, int flags, int colour) { int start = 0, end = 0; int is_begin, is_end; Accept *acc; int old_states; NFA *old_nfa; int err; old_states = h->nfa_states; old_nfa = h->nfa; err = parse_regexp (h, &rule, &length, &start, &end, &is_begin, &is_end); if (!err) { /* * We have a partial NFA gained from parsing the rule. Add * an empty-string transition from the correct initial * state (0 normally, 1 for a rule that must start at the * beginning of a line), and flag the final state as * accepting. */ add_nfa_trans (h, is_begin ? 1 : 0, start, NULL); acc = (Accept *) SLmalloc (sizeof(Accept)); if (acc == NULL) goto error; /* grotty, I know, but... */ acc->next = h->accept; h->accept = acc; acc->state = end; acc->is_quick = ((flags & FLAG_QUICK) ? 1 : 0); acc->is_preproc = ((flags & FLAG_PREPROC) ? 1 : 0); acc->is_keyword = ((flags & FLAG_KEYWORD) ? 1 : 0); acc->colour = colour; acc->is_end = is_end; } else { /* * An error occurred while doing the parse. We must remove * all the NFA states and transitions that the partial * parse may have added. */ NFA *n; error: /* we may get here from above! */ h->nfa_states = old_states; for (n=h->nfa; n && n!=old_nfa ;) { NFA *temp = n; n = n->next; SLfree ((char *)temp); } h->nfa = n; } } /* * Call this to parse a regular expression. * The grammar is: * regexp : [^] reg1 [$] * reg1 : reg2 [| reg2 [| reg2...]] * reg2 : reg3 [reg3 [reg3...]] * reg3 : reg4 [*, +, ?] * reg4 : char * | char-set * | . * | ( reg1 ) * * Lexemes are: all chars (0 to 255), caret, dollar, vbar, star, * plus, query, lbracket, rbracket, dash, dot, lparen and rparen. */ #define LEX_CARET (UCHAR_MAX+1+(unsigned char)'^') #define LEX_DOLLAR (UCHAR_MAX+1+(unsigned char)'$') #define LEX_VBAR (UCHAR_MAX+1+(unsigned char)'|') #define LEX_STAR (UCHAR_MAX+1+(unsigned char)'*') #define LEX_PLUS (UCHAR_MAX+1+(unsigned char)'+') #define LEX_QUERY (UCHAR_MAX+1+(unsigned char)'?') #define LEX_LBRACKET (UCHAR_MAX+1+(unsigned char)'[') #define LEX_RBRACKET (UCHAR_MAX+1+(unsigned char)']') #define LEX_DASH (UCHAR_MAX+1+(unsigned char)'-') #define LEX_DOT (UCHAR_MAX+1+(unsigned char)'.') #define LEX_LPAREN (UCHAR_MAX+1+(unsigned char)'(') #define LEX_RPAREN (UCHAR_MAX+1+(unsigned char)')') #define LEX_ENDOFTEXT (2*UCHAR_MAX+2) #define is_normal_char(lex) ((lex)<=UCHAR_MAX) static int parse_regexp (Highlight *h, char **text, int *length, int *start, int *end, int *is_begin, int *is_end) { int err; if (get_lexeme(text, length) == LEX_CARET) { *is_begin = 1; eat_lexeme (text, length); } else *is_begin = 0; if ( (err = parse_reg1 (h, text, length, start, end)) != 0) return err; if (get_lexeme(text, length) == LEX_DOLLAR) { *is_end = 1; eat_lexeme (text, length); } else *is_end = 0; if (get_lexeme(text, length) != LEX_ENDOFTEXT) return ERR_EOT_EXPECTED; return 0; } static int parse_reg1 (Highlight *h, char **text, int *length, int *start, int *end) { int err; if ( (err = parse_reg2 (h, text, length, start, end)) != 0) return err; while (get_lexeme(text, length) == LEX_VBAR) { eat_lexeme (text, length); if ( (err = parse_reg2 (h, text, length, start, end)) != 0) return err; } return 0; } static int parse_reg2 (Highlight *h, char **text, int *length, int *start, int *end) { int en = 0; int lex, err; if ( (err = parse_reg3 (h, text, length, start, &en)) != 0) return err; while ((lex=get_lexeme(text, length)) == LEX_LPAREN || lex == LEX_LBRACKET || lex == LEX_DASH || lex == LEX_DOT || is_normal_char(lex)) { int st = en; en = 0; if ( (err = parse_reg3 (h, text, length, &st, &en)) != 0) return err; } if (*end) add_nfa_trans (h, en, *end, NULL); else *end = en; return 0; } static int parse_reg3 (Highlight *h, char **text, int *length, int *start, int *end) { int lex, err; int st = 0, en = 0; if ( (err = parse_reg4 (h, text, length, &st, &en)) != 0) return err; lex = get_lexeme (text, length); switch (lex) { case LEX_STAR: eat_lexeme (text, length); add_nfa_trans (h, st, en, NULL); add_nfa_trans (h, en, st, NULL); break; case LEX_PLUS: eat_lexeme (text, length); add_nfa_trans (h, en, st, NULL); break; case LEX_QUERY: eat_lexeme (text, length); add_nfa_trans (h, st, en, NULL); break; } if (!*end) *end = h->nfa_states++; add_nfa_trans (h, en, *end, NULL); if (!*start) *start = h->nfa_states++; add_nfa_trans (h, *start, st, NULL); return 0; } static int parse_reg4 (Highlight *h, char **text, int *length, int *start, int *end) { int lex, err; Set set; lex = get_lexeme (text, length); if (lex == LEX_LPAREN) { eat_lexeme (text, length); if ( (err = parse_reg1(h, text, length, start, end)) != 0) return err; if (get_lexeme (text, length) != LEX_RPAREN) return ERR_RPAREN_EXPECTED; eat_lexeme (text, length); return 0; } /* * OK, all other possibilities now involve a character set. So * create one. */ empty_set ((char *)set, SET_SIZE); if (lex == LEX_LBRACKET) { int complement = 0; eat_lexeme (text, length); if (get_lexeme (text, length) == LEX_CARET) { eat_lexeme (text, length); complement = 1; fill_set ((char *)set, SET_SIZE); } if (get_lexeme (text, length) == LEX_RBRACKET) return ERR_EMPTY_SET; /* empty set?! */ while ( (lex = get_lexeme (text, length)) != LEX_RBRACKET) { int one_end, other_end; int bottom, top; if (!is_normal_char(lex)) return ERR_METACHAR_INVALID; one_end = lex; eat_lexeme (text, length); if ( (lex = get_lexeme (text, length)) == LEX_DASH) { eat_lexeme (text, length); lex = get_lexeme (text, length); if (!is_normal_char(lex)) return ERR_METACHAR_INVALID; other_end = lex; } else other_end = one_end; if (other_end < one_end) bottom = other_end, top = one_end; else bottom = one_end, top = other_end; while (bottom <= top) { if (complement) take_from_set (set, bottom); else add_to_set (set, bottom); bottom++; } } eat_lexeme (text, length); } else if (is_normal_char (lex) || lex == LEX_DASH) { eat_lexeme (text, length); if (lex == LEX_DASH) lex = (unsigned char) '-'; add_to_set (set, lex); } else if (lex == LEX_DOT) { eat_lexeme (text, length); fill_set ((char *)set, SET_SIZE); } else return ERR_METACHAR_INVALID; /* * We've got a character set: devise an NFA transition on it. */ if (!*start) *start = h->nfa_states++; if (!*end) *end = h->nfa_states++; add_nfa_trans (h, *start, *end, set); return 0; } /* * Add an NFA transition. */ static void add_nfa_trans (Highlight *h, int from, int to, Set set) { NFA *trans; int i; unsigned char other[UCHAR_MAX+1], in[UCHAR_MAX+1]; trans = (NFA *) SLmalloc(sizeof(*trans)); if (trans) { trans->next = h->nfa; h->nfa = trans; if (set) { memcpy ((char *) trans->set, (char *)set, sizeof(Set)); trans->is_empty = 0; } else trans->is_empty = 1; trans->from = from; trans->to = to; } /* * Adjust the equivalence classes: no equivalence class should * contain members both inside and outside the given set. */ if (set != NULL) { for (i=0; iequiv[i]; if (j == i) { other[i] = i; /* no "other" class defined yet */ in[i] = is_in_set (set, i); } else if ( (!is_in_set (set, i)) ^ (!in[j]) ) { if (other[j] == j) other[j] = i; h->equiv[i] = other[j]; } } } } /* * Parse the next lexeme out of the expression. */ static int get_lexeme (char **text, int *length) { char *t; if (!*length) return LEX_ENDOFTEXT; t = *text; switch (*t) { case '^': return LEX_CARET; case '$': return LEX_DOLLAR; case '|': return LEX_VBAR; case '*': return LEX_STAR; case '+': return LEX_PLUS; case '?': return LEX_QUERY; case '[': return LEX_LBRACKET; case ']': return LEX_RBRACKET; case '-': return LEX_DASH; case '.': return LEX_DOT; case '(': return LEX_LPAREN; case ')': return LEX_RPAREN; case '\\': if (*length == 1) return '\\'; t++; /* drop */ default: return (int) ((unsigned char) *t); } } /* * Advance the text pointer past the lexeme given. */ static void eat_lexeme (char **text, int *length) { if (!*length) return; if (**text == '\\' && *length > 1) (*text) += 2, (*length) -= 2; else (*text) += 1, (*length) -= 1; } static void make_dfa (Highlight *h) { int setsize; DFA *tail, *next, *search; unsigned char *destination; /* a working set */ int c, dest_empty; NFA *n; Accept *a; /* * First calculate the size of array we will need to store a * set of NFA states. Allocate our temporary set variables. */ setsize = (h->nfa_states + CHAR_BIT - 1) / CHAR_BIT; destination = (unsigned char *)SLmalloc(setsize); if (!destination) return; /* * Now define our first DFA state. This is the epsilon-closure * of NFA state zero, and is the normal start state for the DFA. */ h->dfa_states = 0; h->dfa = tail = (DFA *) SLmalloc(sizeof(DFA)); if (tail == NULL) goto error; memset ((char *) tail, 0, sizeof (DFA)); if (NULL == (tail->nfa_set = (unsigned char *)SLmalloc(setsize))) goto error; /* tail->next = NULL; memset has done this */ tail->number = h->dfa_states++; empty_set ((char *) tail->nfa_set, setsize); add_to_set (tail->nfa_set, 0); compute_closure (h, tail->nfa_set); /* * Our second DFA state is the epsilon-closure of NFA states * zero and one, and is the start state for the DFA when we are * at the beginning of a line. */ if (NULL == (tail->next = (DFA *) SLmalloc(sizeof(DFA)))) goto error; tail = tail->next; memset ((char *) tail, 0, sizeof (DFA)); if (NULL == (tail->nfa_set = (unsigned char *) SLmalloc(setsize))) goto error; /* tail->next = NULL; */ tail->number = h->dfa_states++; empty_set ((char *) tail->nfa_set, setsize); add_to_set (tail->nfa_set, 0); add_to_set (tail->nfa_set, 1); compute_closure (h, tail->nfa_set); /* * Next, work along the DFA processing each state in turn. */ for (next = h->dfa; next; next=next->next) { /* * We have a state from which we wish to compute all the * transitions. Of course we need only consider transitions * on a representative member of each equivalence class. */ for (c = 0; c < EQUIV_TABLE_SIZE; c++) { if (h->equiv[c] == c) { empty_set ((char *)destination, setsize); dest_empty = 1; for (n = h->nfa; n; n = n->next) { if (is_in_set (next->nfa_set, n->from) && !n->is_empty && is_in_set (n->set, c)) { add_to_set (destination, n->to); dest_empty = 0; } } compute_closure (h, destination); if (dest_empty) search = NULL; else { for (search = h->dfa; search; search = search->next) if (!memcmp((char *) search->nfa_set, (char *) destination, setsize)) break; if (!search) { if (NULL == (search = tail->next = (DFA *) SLmalloc(sizeof(DFA)))) goto error; tail = tail->next; if (NULL == (tail->nfa_set = (unsigned char *)SLmalloc(setsize))) goto error; tail->next = NULL; tail->number = h->dfa_states++; memcpy ((char *) tail->nfa_set, (char *)destination, setsize); } } next->where_to[c] = search; } else next->where_to[c] = next->where_to[h->equiv[c]]; } /* * Having done the transitions for the state, let us also * check its acceptance properties: we need to know if it * contains any accepting NFA-states, and whether they are * constrained to be accepting only at the beginning or end * of the line. */ next->accept = next->accept_end = NULL; for (a = h->accept; a; a = a->next) { if (is_in_set (next->nfa_set, a->state)) { next->accept_end = a; if (!a->is_end) next->accept = a; } } } /* * Free the temporary variables. */ SLfree ((char *)destination); return; /* * Get here if a malloc returned null; clean up the mess. */ error: for (tail = h->dfa; tail; tail=tail->next) { if (tail->nfa_set) SLfree ((char *)tail->nfa_set); next = tail->next; SLfree ((char *)tail); tail = next; } h->dfa = NULL; } /* * Compute the epsilon-closure of a set of NFA states: that is, * expand the set to its smallest superset with the property that * an epsilon NFA transition cannot move from a member of the set * to a non-member. */ static void compute_closure (Highlight *h, unsigned char *set) { NFA *n; int changed; do { changed = 0; for (n=h->nfa; n; n=n->next) { if (n->is_empty && is_in_set (set, n->from) && !is_in_set (set, n->to)) { changed = 1; add_to_set (set, n->to); } } } while (changed); } #if USE_DFA_CACHE /* * I'm going to do this quite a bit in the next routine, so let's * make life easier for myself. */ #define get(buf) do { \ if (!fgets((buf),sizeof((buf)),fp)) goto error; \ (buf)[strcspn((buf), "\n")] = '\0'; \ } while (0) /* * Cache routine: try to load a DFA out of the cache. */ /* FIXME!!! This routine allocates arrays of Accept, DFA, etc structures * and turns them into linked lists. However, elsewhere each node in the * list is allocated. So, the free_highlight_table routine cannot be used * with a DFA read from the cache. Perhaps the best and easiest fix would * be to add a "free" method to the Highlight structure. * * There is currently no way of knowing if the set of regular expressions * matches those implicit in the cache. It would be nice to write out the * list of regular expressions used and compare those with the desired * expressions, or to compute and compare MD5 checksums. */ static int load_dfa (Highlight *h, char *name) { FILE *fp; char buffer[2048], buf2[2048]; unsigned char equiv[EQUIV_TABLE_SIZE]; int i, j; Accept *accept = NULL; int accepts; DFA *dfa = NULL; int dfa_states; if (h->filename == NULL) return 0; /* don't have caching enabled */ fp = fopen (h->filename, "r"); if (fp == NULL) return 0; /* can't open the file */ /* * Check the first line: "DFA cache: %s". */ get(buffer); (void) SLsnprintf (buf2, sizeof (buf2), "DFA cache: %s", name); if (strcmp(buffer, buf2)) goto error; /* not the right syntax table */ get(buffer); (void) SLsnprintf (buf2, sizeof (buf2), "Version: %s", JED_VERSION_STR); if (strcmp(buffer, buf2)) goto error; /* Not built with this executable */ /* * Check the next line: "equiv". */ get(buffer); if (strcmp(buffer, "equiv")) goto error; /* * Read in the equivalence classes. */ i = 0; while (i < EQUIV_TABLE_SIZE) { char *p, *q, *r; unsigned int e; get(buffer); p = q = buffer; while (*p && i < EQUIV_TABLE_SIZE) { q = p + strcspn(p, " "); r = q + strspn(q, " "); *q = '\0'; sscanf(p, "%x", &e); equiv[i++] = e; p = r; } } /* * Read in the accepting states. */ get(buffer); if (!sscanf(buffer, "accept %d", &accepts)) goto error; accept = (Accept *) SLmalloc(sizeof(Accept) * accepts); if (!accept) goto error; for (i=0; i= 0) dfa[i].where_to[j] = dfa+astate; else dfa[i].where_to[j] = NULL; p = r; } else dfa[i].where_to[j] = dfa[i].where_to[equiv[j]]; } } /* * If we've got here, we're actually done. So free the previous * list of Accept structures, set up the Highlight structure, * and leave. */ { Accept *a, *b; a = h->accept; while (a) { b = a; a = a->next; SLfree ((char *)b); } } h->dfa_states = dfa_states; h->dfa = dfa; h->accept = accept; memcpy ((char *) h->equiv, (char *) equiv, sizeof(equiv)); fclose (fp); return 1; /* * We only get here on error. */ error: SLfree ((char *)dfa); SLfree ((char *)accept); if (fp != NULL) fclose(fp); return 0; } #undef get #endif /* USE_DFA_CACHE */ /* * Cache routine: try to save a DFA into the cache, if we have * access rights. (We might be a non-root user and the cache might * be in /usr/lib/jed/lib, in which case we can't save cache files * ourselves but shouldn't actually moan about it.) * * The DFA cache format is as follows: the first line contains "DFA * cache: %s" where %s is the name of the syntax table. The next * line contains "equiv". Next the equivalence classes are stored: * 256 hex bytes, on 16 lines of 16, separated by spaces, denoting * for each character code in turn the lowest character code * equivalent to that character. Thus if all characters are * equivalent, 256 zeros will be stored, and if all characters are * distinct in behaviour, the numbers 0 through 255 will be stored * in order. * * The next line contains "accept %d", where %d is the number of * Accept structures. The Accept structures are stored next: each * line contains one structure. The line contains six integers, * separated by spaces: the members @state@, @is_quick@, @is_end@, * @colour@, @is_preproc@ and @is_keyword@ of the structure. * * The next line contains "dfa %d", where %d is the number of DFA * states. Thereafter the actual DFA states are given. Each line * contains one state: it begins with the number of the state, the * @state@ member of the Accept structure in its @accept@ field, * the same for its @accept_end@ field, then a colon, then the * numbers of each transition on a representative character, * separated by spaces. (A representative character is defined as * one which has the lowest character code in its equivalence * class.) */ #if USE_DFA_CACHE static void save_dfa (Highlight *h, char *name) { FILE *fp; int i; DFA *d; Accept *a; if (!h->filename) return; /* don't have caching enabled */ fp = fopen (h->filename, "w"); if (!fp) return; /* didn't have access, or something */ /* FIXME!!! Check the return values from the fprintf functions. Upon * failure, remove the file. */ fprintf(fp, "DFA cache: %s\nVersion: %s\nequiv\n", name, JED_VERSION_STR); /* write the equivalence classes */ for (i=0; iequiv[i], ((i+1) % 16 ? ' ' : '\n')); } /* write the accepting states */ for (i=0, a=h->accept; a; a=a->next, i++); fprintf(fp, "accept %d\n", i); for (a=h->accept; a; a=a->next) fprintf(fp, "%d %d %d %d %d %d\n", a->state, a->is_quick, a->is_end, a->colour, a->is_preproc, a->is_keyword); /* write the DFA itself */ fprintf(fp, "dfa %d\n", h->dfa_states); for (d = h->dfa; d; d = d->next) { fprintf(fp, "%d %d %d:", d->number, d->accept ? d->accept->state : -1, d->accept_end ? d->accept_end->state : -1); for (i=0; iequiv[i] == i) fprintf(fp, " %d", d->where_to[i] ? d->where_to[i]->number : -1); fprintf(fp, "\n"); } fclose (fp); } #endif /* USE_DFA_CACHE */ #ifdef TEST_MODE # include static void dump_it (Highlight *h) { NFA *n; DFA *df; Accept *a; int c, d; printf("Equivalence classes:\n"); for (c=1; cequiv[c] == c) { printf(" equivalent to "); if (isprint(c)) putchar (c); else printf("\\x%02X", c); printf(": "); for (d=c; dequiv[d] == c) { if (isprint(d)) putchar (d); else printf("\\x%02X", d); } } printf("\n"); } } printf(" equivalent to \\x00: everything else\n"); printf("NFA states: %d\n", h->nfa_states); for (n=h->nfa; n; n=n->next) { printf(" transition %3d -> %3d on ", n->from, n->to); if (n->is_empty) printf("epsilon"); else for (c=0; cequiv[c] == c) if (is_in_set (n->set, c)) { if (isprint(c)) putchar (c); else printf("\\x%02X", c); } printf("\n"); } for (a=h->accept; a; a=a->next) printf("Accepting state: %3d%s\n", a->state, (a->is_end ? " (end)" : "")); printf("DFA states:\n"); for (df=h->dfa; df; df=df->next) { printf(" %d is [", df->number); for (c=0; cnfa_states; c++) if (is_in_set (df->nfa_set, c)) printf(" %d", c); printf(" ]"); for (c=0; cequiv[c] == c) { printf(", to %d on ", df->where_to[c] ? df->where_to[c]->number : -1); if (isprint(c)) putchar (c); else printf("\\x%02X", c); } printf("\n"); printf(" accepting: %d, e=%d\n", df->accept ? df->accept->state : -1, df->accept_end ? df->accept_end->state : -1); } } #endif /* TEST_MODE */ static int dfa_try_keyword (register unsigned char *q, int n, register char *t, int case_sense) { unsigned char *p; int m, result; if (!t) return 0; while (*t) { p = q; m = n; result = 0; while (m--) { unsigned char star_p = *p++; unsigned char star_t = *t++; if (!case_sense) star_p = (unsigned char) LOWER_CASE (star_p); result = star_p - star_t; if (result) break; } t += m; if (result < 0) return 0; else if (result == 0) return 1; } return 0; } static void dfa_syntax_highlight (register unsigned char *p, register unsigned char *pmax, Syntax_Table_Type *st) { Highlight *h = st->hilite; DFA *d; unsigned char *q; unsigned char *last_acc_pos; Accept *accept, *last_accept; int preproc = -1, colour, i; int case_sense; if (st == NULL) return; case_sense = !(st->flags & SYNTAX_NOT_CASE_SENSITIVE); d = h->dfa->next; /* the first time, start at state 1 */ while (p < pmax) { q = p; last_accept = NULL; last_acc_pos = NULL; while (q < pmax) { d = d->where_to[*q++]; /* accept = (!d ? NULL : q==pmax ? d->accept_end : d->accept); */ accept = ((d==NULL) ? NULL : (q==pmax) ? d->accept_end : d->accept); if (accept != NULL) { /* * We have hit an accepting state: record it. */ last_accept = accept; last_acc_pos = q; if (last_accept->is_quick) break; } if (d == NULL) { if (last_accept == NULL) { if ((*p & 0x80) && Jed_UTF8_Mode) q = SLutf8_skip_chars (p, pmax, 1, NULL, 1); else q = p + 1; } break; /* error state */ } } if (last_accept) { colour = last_accept->colour; if (last_accept->is_keyword) { int n = last_acc_pos - p; if (n>=1 && n<=MAX_KEYWORD_LEN) for (i=0; ikeywords[i][n-1], case_sense)) { colour = JKEY_COLOR+i; break; } } if (preproc != -1 && !last_accept->is_preproc && colour != JCOM_COLOR) colour = preproc; p = write_using_color(p, last_acc_pos, colour); if (last_accept->is_preproc) preproc = last_accept->colour; } else { if (preproc != -1) p = write_using_color (p, q, preproc); else p = write_using_color (p, q, JNORMAL_COLOR); } d = h->dfa; } } void jed_dfa_free_highlight_table (Highlight *h) { (void) h; /* Until the reading of the cache gets fixed, do nothing except leak,...*/ #if 0 NFA *nfa; Accept *accept; if (h == NULL) return; nfa = h->nfa; while (nfa != NULL) { NFA *next = nfa->next; SLfree ((char *) nfa); nfa = next; } accept = h->accept; while (accept != NULL) { Accept *next = accept->next; SLfree ((char *) accept); accept = next; } dfa = h->dfa; while (dfa != NULL) { DFA *next = dfa->next; SLfree ((char *) dfa->nfa_set); SLfree ((char *) dfa); dfa = next; } SLfree (h->filename); SLfree ((char *) h); #endif } static Highlight *find_highlight_table (char *name, int init) { Syntax_Table_Type *table; table = jed_find_syntax_table (name, 1); if (table == NULL) return NULL; if ((table->hilite == NULL) && init) table->hilite = init_highlight (); return table->hilite; } static void define_highlight_rule (char *rule, char *colour, char *name) { Highlight *hilite; int flags = 0; int i; if (NULL == (hilite = find_highlight_table (name, 1))) return; if (hilite->dfa) return; /* don't need to */ while (*colour == 'K' || *colour == 'P' || *colour == 'Q') { switch (*colour) { case 'K': flags |= FLAG_KEYWORD; break; case 'Q': flags |= FLAG_QUICK; break; case 'P': flags |= FLAG_PREPROC; break; } colour++; } if ( (i = jed_get_color_obj (colour)) != -1) add_rule (hilite, rule, strlen(rule), flags, i); } /* FIXME: * If a cache table already exists, any additional rules will get ignored * making the dfa_build_highlight_table_hook useless. The init_dfa_callback * hook looks more or less like: * * dfa_enable_highlight_cache ("cache.dfa", "syntax-table"); * dfa_define_highlight_rule ("pattern", "color-obj", "syntax-table"); * . * . * dfa_define_highlight_rule ("pattern", "color-obj", "syntax-table"); * dfa_build_highlight_table ("tag"); * * The problem is that if "cache.dfa" already exists, it will be loaded and * used. */ static void build_highlight_table (char *name) { Highlight *hilite; if (-1 == SLang_run_hooks ("dfa_build_highlight_table_hook", 1, name)) return; if (NULL == (hilite = find_highlight_table (name, 0))) return; if (NULL == hilite->dfa) { jed_vmessage (1, "Creating DFA syntax table for %s...", name); make_dfa (hilite); #if USE_DFA_CACHE if (hilite->filename) save_dfa (hilite, name); #endif message (""); } } static void enable_highlight_cache (char *file, char *name) { #if USE_DFA_CACHE Highlight *hilite; if (NULL == (hilite = find_highlight_table (name, 1))) return; if (hilite->filename != NULL) SLfree (hilite->filename); /* Ok to fail */ hilite->filename = SLmake_string (file); if (!hilite->dfa) load_dfa (hilite, name); #else (void) file; (void) name; #endif } static void set_init_callback (char *name) { SLang_Name_Type *f; Syntax_Table_Type *t; if (NULL == (f = SLang_pop_function ())) return; if (NULL == (t = jed_find_syntax_table (name, 1))) { #if SLANG_VERSION > 10400 SLang_free_function (f); #endif return; } #if SLANG_VERSION > 10400 if (t->init_dfa_callback != NULL) SLang_free_function (t->init_dfa_callback); #endif t->init_dfa_callback = f; } static void use_dfa_syntax (int *x) { Syntax_Table_Type *t = CBuf->syntax_table; if (t == NULL) t = Default_Syntax_Table; if (*x == 0) { t->use_dfa_syntax = 0; return; } if (t->hilite == NULL) { if ((t->init_dfa_callback == NULL) || (-1 == SLang_start_arg_list ()) || (-1 == SLang_push_string (t->name)) || (-1 == SLang_end_arg_list ()) || (1 != SLexecute_function (t->init_dfa_callback)) || (NULL == t->hilite) || (NULL == t->hilite->dfa)) { t->use_dfa_syntax = 0; return; } } t->use_dfa_syntax = 1; } static SLang_Intrin_Fun_Type DFA_Intrinsics [] = { MAKE_INTRINSIC_SSS("dfa_define_highlight_rule", define_highlight_rule, VOID_TYPE), MAKE_INTRINSIC_S("dfa_build_highlight_table", build_highlight_table, VOID_TYPE), MAKE_INTRINSIC_SS("_dfa_enable_highlight_cache", enable_highlight_cache, VOID_TYPE), MAKE_INTRINSIC_I("use_dfa_syntax", use_dfa_syntax, VOID_TYPE), MAKE_INTRINSIC_S("dfa_set_init_callback", set_init_callback, VOID_TYPE), MAKE_INTRINSIC_0(NULL, NULL, 0) }; int jed_init_dfa_syntax (void) { return SLadd_intrin_fun_table (DFA_Intrinsics, "HAS_DFA_SYNTAX"); } jed-0.99-19/src/hooks.c0000644002657400265740000001737011311317447013560 0ustar davisdavis/* Copyright (c) 1992, 2000, 2002, 2003, 2004, 2005, 2006 John E. Davis * This file is part of JED editor library source. * * You may distribute this file under the terms the GNU General Public * License. See the file COPYING for more information. */ #include "config.h" #include "jed-feat.h" /*{{{ #include files */ #include #ifdef HAVE_STDLIB_H # include #endif #include #include #include "hooks.h" #include "misc.h" typedef struct Hook_Type { SLang_Name_Type *nt; /* The locking and is_valid flags are necessary to prevent the list from * becoming corrupt if the hook is removed by the hook */ unsigned int num_locks; int is_valid; /* non-zero if not deleted */ struct Hook_Type *next; struct Hook_Type *prev; } Hook_Type; typedef struct Hook_List_Type { char *hooks_name; /* slstring */ Hook_Type *hooks; struct Hook_List_Type *next; } Hook_List_Type; static Hook_List_Type *Hook_List; static Hook_Type *hook_already_exists (Hook_List_Type *h, SLang_Name_Type *nt) { Hook_Type *next; next = h->hooks; while (next != NULL) { if (next->nt == nt) break; next = next->next; } return next; } static void free_hook (Hook_List_Type *l, Hook_Type *h) { Hook_Type *n, *p; if (h == NULL) return; if (h->num_locks) return; p = h->prev; n = h->next; if (p != NULL) p->next = n; else l->hooks = n; if (n != NULL) n->prev = p; SLfree ((char *) h); } static void release_hook (Hook_List_Type *l, Hook_Type *h) { if (h->num_locks >= 1) h->num_locks--; if (h->is_valid == 0) free_hook (l, h); } static void lock_hook (Hook_Type *h) { h->num_locks++; } static Hook_List_Type *new_hook_list (char *name) { Hook_List_Type *h; h = (Hook_List_Type *) jed_malloc0 (sizeof (Hook_List_Type)); if (h == NULL) return NULL; if (NULL == (h->hooks_name = SLang_create_slstring (name))) { SLfree ((char *) h); return NULL; } h->next = Hook_List; Hook_List = h; return h; } static Hook_List_Type *find_hook_list (char *name) { Hook_List_Type *l; char ch; l = Hook_List; ch = name[0]; while (l != NULL) { if ((ch == l->hooks_name[0]) && (0 == strcmp (l->hooks_name, name))) break; l = l->next; } return l; } static int insert_hook_1 (char *hook, SLang_Name_Type *nt, int append) { Hook_List_Type *l; Hook_Type *h, *p; if (NULL == (l = find_hook_list (hook))) { if (NULL == (l = new_hook_list (hook))) return -1; } h = hook_already_exists (l, nt); if (h != NULL) { h->is_valid = 1; return 0; } if (NULL == (h = (Hook_Type *) jed_malloc0 (sizeof (Hook_Type)))) return -1; h->nt = nt; h->is_valid = 1; p = l->hooks; if (append && (p != NULL)) { while (p->next != NULL) p = p->next; p->next = h; h->prev = p; } else { h->next = p; l->hooks = h; if (p != NULL) p->prev = h; } return 0; } static int pop_hooks_info (char **s, SLang_Name_Type **nt) { if (NULL == (*nt = SLang_pop_function ())) return -1; if (-1 == SLang_pop_slstring (s)) return -1; return 0; } static int insert_hook (int append) { SLang_Name_Type *nt; char *name; int status; if (-1 == pop_hooks_info (&name, &nt)) return -1; status = insert_hook_1 (name, nt, append); SLang_free_slstring (name); return status; } static void add_hook_cmd (void) { (void) insert_hook (0); } static void append_hook_cmd (void) { (void) insert_hook (1); } static void remove_hook_cmd (void) { char *name; SLang_Name_Type *nt; Hook_Type *h; Hook_List_Type *l; if (-1 == pop_hooks_info (&name, &nt)) return; if ((NULL == (l = find_hook_list (name))) || (NULL == (h = hook_already_exists (l, nt)))) { SLang_free_slstring (name); return; } h->is_valid = 0; free_hook (l, h); SLang_free_slstring (name); } static int execute_fun_with_args (SLang_Name_Type *nt, unsigned int argc, char **argv) { unsigned int i; (void) SLang_start_arg_list (); for (i = 0; i < argc; i++) (void) SLang_push_string (argv[i]); (void) SLang_end_arg_list (); return SLexecute_function (nt); } int jed_hook_exists (char *name) { Hook_List_Type *l; return ((NULL != (l = find_hook_list (name))) && (l->hooks != NULL)); } static int jed_run_hooks (char *name, int method, unsigned int argc, char **argv) { Hook_List_Type *l; Hook_Type *h; if (NULL == (l = find_hook_list (name))) h = NULL; else h = l->hooks; while (h != NULL) { int status; Hook_Type *next; if (0 == h->is_valid) { h = h->next; continue; } lock_hook (h); status = execute_fun_with_args (h->nt, argc, argv); next = h->next; release_hook (l, h); h = next; if (status == -1) return -1; if (method == JED_HOOKS_RUN_ALL) continue; if (-1 == SLang_pop_integer (&status)) return -1; if (method == JED_HOOKS_RUN_UNTIL_0) { if (status == 0) return 0; continue; } /* else method = JED_HOOKS_RUN_UNTIL_NON_0 */ if (status) return 1; } if (method == JED_HOOKS_RUN_UNTIL_0) return 1; return 0; } static char **build_arg_list (unsigned int n, va_list ap) { char **s; unsigned int i; s = (char **)SLmalloc ((n+1) * sizeof (char *)); if (s == NULL) return NULL; for (i = 0; i < n; i++) s[i] = va_arg(ap, char *); s[n] = NULL; return s; } int jed_va_run_hooks (char *name, int method, unsigned int nargs, ...) { va_list ap; char **arglist; int status; va_start (ap, nargs); if (NULL == (arglist = build_arg_list (nargs, ap))) { va_end (ap); return -1; } va_end (ap); status = jed_run_hooks (name, method, nargs, arglist); SLfree ((char *) arglist); return status; } static void run_hooks_cmd (void) { unsigned int n; SLang_Array_Type *at; int method; char *hook; n = (unsigned int) SLang_Num_Function_Args; at = NULL; hook = NULL; switch (n) { case 3: if (-1 == SLang_pop_array_of_type (&at, SLANG_STRING_TYPE)) return; /* drop */ case 2: if (-1 == SLang_pop_integer (&method)) goto the_return; if (-1 == SLang_pop_slstring (&hook)) goto the_return; break; default: SLang_verror (SL_USAGE_ERROR, "usage: expecting 2 or 3 arguments"); return; } switch (method) { case JED_HOOKS_RUN_ALL: case JED_HOOKS_RUN_UNTIL_0: case JED_HOOKS_RUN_UNTIL_NON_0: break; default: SLang_verror (SL_INVALID_PARM, "run method %d is not supported", method); goto the_return; } if (at == NULL) (void) jed_run_hooks (hook, method, 0, NULL); else (void) jed_run_hooks (hook, method, at->num_elements, (char **) at->data); the_return: SLang_free_slstring (hook); SLang_free_array (at); } static SLang_Intrin_Fun_Type Hooks_Intrinsics [] = { MAKE_INTRINSIC_0("add_to_hook", add_hook_cmd, SLANG_VOID_TYPE), MAKE_INTRINSIC_0("append_to_hook", append_hook_cmd, SLANG_VOID_TYPE), MAKE_INTRINSIC_0("remove_from_hook", remove_hook_cmd, SLANG_VOID_TYPE), MAKE_INTRINSIC_0("_jed_run_hooks", run_hooks_cmd, SLANG_VOID_TYPE), MAKE_INTRINSIC_0(NULL, NULL, 0) }; static SLang_IConstant_Type Hook_IConstants [] = { MAKE_ICONSTANT("JED_HOOKS_RUN_ALL", JED_HOOKS_RUN_ALL), MAKE_ICONSTANT("JED_HOOKS_RUN_UNTIL_NON_0", JED_HOOKS_RUN_UNTIL_NON_0), MAKE_ICONSTANT("JED_HOOKS_RUN_UNTIL_0", JED_HOOKS_RUN_UNTIL_0), SLANG_END_ICONST_TABLE }; int jed_init_user_hooks (void) { if ((-1 == SLadd_intrin_fun_table (Hooks_Intrinsics, NULL)) || (-1 == SLadd_iconstant_table (Hook_IConstants, NULL))) return -1; return 0; } jed-0.99-19/src/sysdep.h0000644002657400265740000000614511311317447013747 0ustar davisdavis/* Copyright (c) 1992, 1998, 2000, 2005, 2006 John E. Davis * This file is part of JED editor library source. * * You may distribute this file under the terms the GNU General Public * License. See the file COPYING for more information. */ #ifndef __DAVIS_SYSDEP_H__ #define __DAVIS_SYSDEP_H__ #include extern int Ignore_User_Abort; extern char *_Jed_Backspace_Key; #ifdef __MSDOS_16BIT__ #define MAX_INPUT_BUFFER_LEN 40 #else #define MAX_INPUT_BUFFER_LEN 1024 #endif extern int Input_Buffer_Len; extern unsigned char Input_Buffer[MAX_INPUT_BUFFER_LEN]; extern unsigned char sys_getkey(void); extern int sys_input_pending(int *, int); extern int init_tty(void); extern void reset_tty(void); extern void sys_suspend(void); extern int my_getkey(void); extern int input_pending(int *); extern void flush_input(void); extern void ungetkey_string(char *, int); extern void buffer_keystring (char *, int); extern void ungetkey(int *); extern void sys_resume(void); extern int sys_delete_file(char *); extern int sys_chmod(SLFUTURE_CONST char *, int, mode_t *, uid_t *, gid_t *); extern unsigned long sys_file_mod_time(char *); /* expand the file in a canonical way and return a pointer to a static area which should be regarded volatile */ extern char *jed_standardize_filename_static (char *); extern char *jed_expand_filename (char *); /* return pointer to place filename starts in path */ extern char *extract_file(SLFUTURE_CONST char *); /* Like extract_file, except ignores the trailing slash */ char *jed_extract_file_or_dir (char *); extern int sys_findfirst(char *); extern int sys_findnext(char *); extern unsigned long sys_time(void); extern int Meta_Char; extern int DEC_8Bit_Hack; extern void map_character(int *, int *); extern int make_random_number(int *, int *); extern int ch_dir(char *); extern void deslash(char *); extern char *slash2slash (char *); #if defined(__MSDOS_16BIT__) || defined(__os2__) || defined(__WIN32__) extern int NumLock_Is_Gold; #endif #ifdef __os2__ extern int IsHPFSFileSystem(char *); #endif #if defined(__GO32__) || (defined(__WATCOMC__) && !defined(__QNX__)) extern void i386_check_kbd(void); extern int i386_access (char *, int); #endif #ifdef IBMPC_SYSTEM # define SCREEN_HEIGHT 25 extern int PC_Alt_Char; extern char *msdos_pinhead_fix_dir(char *); extern int sys_System (char *); # ifdef MSWINDOWS extern int PC_Fn_Char; # endif extern int Jed_Filename_Case_Sensitive; #else # define SCREEN_HEIGHT 24 #endif #ifdef sequent # define strchr index extern char *my_strstr(); #endif #ifdef __unix__ extern void enable_flow_control(int *); #endif #ifdef VMS void vms_cancel_exithandler(void); extern int vms_send_mail(char *, char *); extern int vms_get_help (char *, char *); #endif #ifdef __WIN32__ extern int jed_win32_rename (char *, char *); #endif #ifdef VMS #endif extern char *jed_get_cwd(void); extern void jed_pause (int *); extern void sys_pause (int); extern void jed_sleep (unsigned int n); extern char Jed_Root_Dir [JED_MAX_PATH_LEN]; extern void (*Jed_Sig_Exit_Fun) (void); extern int jed_set_default_key_wait_time (const int *tsecs); #endif /* __DAVIS_SYSDEP_H__ */ jed-0.99-19/src/TODO0000644002657400265740000000012511311317447012747 0ustar davisdavis1. Allow abbreviation table to dynamically grow with words of arbitrary length. jed-0.99-19/src/jdmacros.h0000644002657400265740000000227611311317447014243 0ustar davisdavis/* Copyright (c) 1992, 1998, 2000, 2005, 2006 John E. Davis * This file is part of JED editor library source. * * You may distribute this file under the terms the GNU General Public * License. See the file COPYING for more information. */ #ifndef _JD_MACROS_H_ #define _JD_MACROS_H_ /* This file defines some macros that I use with programs that link to * the slang library. */ #ifdef HAVE_MALLOC_H # if !defined(__FreeBSD__) # include # endif #endif #ifdef HAVE_MEMORY_H # include #endif #ifndef SLMEMSET # ifdef HAVE_MEMSET # define SLMEMSET memset # else # define SLMEMSET SLmemset # endif #endif #ifndef SLMEMCHR # ifdef HAVE_MEMCHR # define SLMEMCHR memchr # else # define SLMEMCHR SLmemchr # endif #endif #ifndef SLMEMCPY # ifdef HAVE_MEMCPY # define SLMEMCPY memcpy # else # define SLMEMCPY SLmemcpy # endif #endif /* Note: HAVE_MEMCMP requires an unsigned memory comparison!!! */ #ifndef SLMEMCMP # ifdef HAVE_MEMCMP # define SLMEMCMP memcmp # else # define SLMEMCMP SLmemcmp # endif #endif #if defined(__QNX__) && defined(__WATCOMC__) # include #endif #ifndef SLFUTURE_CONST # define SLFUTURE_CONST #endif #endif /* _JD_MACROS_H_ */ jed-0.99-19/src/window.c0000644002657400265740000002537511311317447013750 0ustar davisdavis/* -*- mode: C; mode: fold; -*- */ /* Copyright (c) 1992, 1998, 2000, 2002-2009 John E. Davis * This file is part of JED editor library source. * * You may distribute this file under the terms the GNU General Public * License. See the file COPYING for more information. */ #include "config.h" #include "jed-feat.h" /*{{{ Include Files */ #include #include #include "buffer.h" #include "window.h" #include "screen.h" #include "misc.h" #include "ledit.h" #include "sysdep.h" #include "display.h" #include "paste.h" /*}}}*/ Window_Type *JMiniWindow; Window_Type *JWindow; int Top_Window_SY = 1; static Window_Type *alloc_window(int sy, int sx, int rows, int col, int width) { Window_Type *w; if (NULL == (w = (Window_Type *) jed_malloc0 (sizeof(Window_Type)))) { exit_error("create_window: malloc error.", 0); } if (sy < 0) sy = 0; if (sx < 0) sx = 0; w->sx = sx; w->sy = sy; if (rows < 1) rows = 1; w->rows = rows; if (width < 1) width = 1; w->width = width; w->hscroll_column = col; return w; } static Window_Type *new_window (int sy, int sx, int rows, int col, int width) { Window_Type *w = alloc_window (sy, sx, rows, col, width); if (w == NULL) return w; if ((jed_new_window_cb != NULL) && (-1 == (*jed_new_window_cb)(w))) exit_error ("The new_window callback function failed", 0); return w; } Window_Type *jed_create_minibuffer_window (void) { Window_Type *w; w = alloc_window (Jed_Num_Screen_Rows-1, 0, 1, 1, Jed_Num_Screen_Cols); if (w == NULL) return NULL; w->flags |= MINIBUFFER_WINDOW; if ((jed_create_mini_window_cb != NULL) && (*jed_create_mini_window_cb)(w)) exit_error ("Unable to create a mini-buffer window", 0); return w; } static void free_window (Window_Type *w) { if (w == NULL) return; if (Mini_Info.action_window == w) Mini_Info.action_window = NULL; if (jed_free_window_cb != NULL) (*jed_free_window_cb)(w); SLfree ((char *) w); } void window_buffer(Buffer *b) /*{{{*/ { if (JWindow == NULL) { JWindow = new_window (Top_Window_SY, 0, Jed_Num_Screen_Rows - 2 - Top_Window_SY, 1, Jed_Num_Screen_Cols); JWindow->next = JWindow; } touch_window(); jed_init_mark_for_buffer (&JWindow->beg, b, 0); jed_init_mark_for_buffer (&JWindow->mark, b, 0); JWindow->hscroll_column = 1; JWindow->buffer = b; JWindow->trashed = 1; } /*}}}*/ #if JED_HAS_SUBPROCESSES void move_window_marks (int all) /*{{{*/ { Window_Type *w = JWindow; if (w == NULL) return; do { if (w->buffer == CBuf) { jed_init_mark (&w->mark, 0); if (all == 0) break; } w = w->next; } while (w != JWindow); } /*}}}*/ #endif int other_window (void) /*{{{*/ { switch_to_buffer(JWindow->buffer); jed_init_mark (&JWindow->mark,0); if (JWindow->next == JWindow) return 1; if (jed_leave_window_cb != NULL) (void) (*jed_leave_window_cb)(JWindow); JWindow = JWindow->next; switch_to_buffer(JWindow->buffer); if (JWindow->mark.line != NULL) (void) jed_goto_mark (&JWindow->mark); if (jed_enter_window_cb != NULL) (void) (*jed_enter_window_cb)(JWindow); return 1; } /*}}}*/ int split_window (void) /*{{{*/ { int n, sy, width, row; Window_Type *w, *neew; /* Line *l, cline; */ if (JWindow->rows < 5) { msg_error("Window too small."); return(0); } switch_to_buffer(JWindow->buffer); n = JWindow->rows / 2; sy = JWindow->sy + n + 1; width = JWindow->width; n = JWindow->rows - n - 1; JWindow->rows = JWindow->rows / 2; jed_init_mark (&JWindow->beg, 0); w = JWindow->next; JWindow->next = neew = new_window (sy, JWindow->sx, n, JWindow->hscroll_column, width); neew->next = w; neew->buffer = CBuf; jed_init_mark (&neew->mark, 0); jed_copy_mark (&neew->beg, &JWindow->beg); if (jed_split_window_cb != NULL) { (void) (*jed_split_window_cb)(JWindow, neew); } n = JWindow->sy; other_window(); touch_window(); if (-1 != (row = jed_find_line_on_screen (CLine, n))) { /* The screen row below (not above) the current window containing * the current line was found. Switch to that buffer to avoid * the cursor jumping. This is not necessary but it has a more * appealing visual effect. */ row += 1; w = JWindow; do { if ((JWindow->buffer == CBuf) && (JWindow->sy < row) && (JWindow->sy + JWindow->rows >= row)) break; other_window(); } while (w != JWindow); } return 1; } /*}}}*/ int one_window (void) /*{{{*/ { Window_Type *w, *next, *mini; Buffer *b; mini = NULL; if (IN_MINI_WINDOW) return 0; w = JWindow->next; b = JWindow->buffer; while (w != JWindow) { next = w->next; if (w != JMiniWindow) { if (w->buffer != b) touch_window_hard (w, 0); free_window (w); } else mini = w; w = next; } if (mini == NULL) mini = JWindow; JWindow->next = mini; mini->next = JWindow; JWindow->sy = Top_Window_SY; JWindow->sx = 0; JWindow->width = Jed_Num_Screen_Cols; JWindow->rows = Jed_Num_Screen_Rows - 2 - Top_Window_SY; touch_window(); return(1); } /*}}}*/ int enlarge_window (void) /*{{{*/ { Window_Type *w, *w1; int min = 2; if (IN_MINI_WINDOW) return 0; if (JWindow == JWindow->next) return(0); w = JWindow->next; while(w->rows <= min) w = w->next; if (w == JWindow) return(0); if (w->sy < JWindow->sy) { w->rows -= 1; JWindow->rows += 1; do { w = w->next; w->sy -= 1; } while (w != JWindow); } else { JWindow->rows += 1; w1 = JWindow; while(w1 != w) { w1 = w1->next; w1->sy += 1; } w->rows -= 1; } w = JWindow; do { touch_window(); JWindow = JWindow->next; } while (w != JWindow); if ((jed_window_geom_change_cb != NULL) && (-1 == (*jed_window_geom_change_cb) ())) exit_error ("window_geom_change callback failed", 0); return 1; } /*}}}*/ static void adjust_windows (int height) /*{{{*/ { Window_Type *w = JWindow; int rows; do { if (w->rows + w->sy + 2 == Jed_Num_Screen_Rows) { /* bottom window */ rows = height - 2 - w->sy; if (rows > 1) { w->rows = rows; return; } while (JWindow->sy != Top_Window_SY) other_window(); one_window(); JWindow->rows = height - 2 - Top_Window_SY; if (JWindow->rows < 1) JWindow->rows = 1; return; } w = w->next; } while (w != JWindow); /* not reached! */ } /*}}}*/ void jed_update_window_sizes (int height, int width) /*{{{*/ { Window_Type *w; if (JWindow == NULL) return; if (height < 5) height = 5; if (width < 5) width = 5; if (height != Jed_Num_Screen_Rows) adjust_windows(height); w = JWindow; do { JWindow->trashed = 1; JWindow->width = width; JWindow = JWindow->next; } while (w != JWindow); if (JMiniWindow != NULL) { JMiniWindow->sy = height-1; JMiniWindow->width = width; } if ((jed_window_geom_change_cb != NULL) && (-1 == (*jed_window_geom_change_cb) ())) exit_error ("window_geom_change callback failed", 0); } /*}}}*/ int buffer_visible(Buffer *b) /*{{{*/ { Window_Type *w = JWindow; int n; if ((b == NULL) || (w == NULL)) return 0; n = 0; do { if (w->buffer == b) n++; w = w->next; } while (w != JWindow); return n; } /*}}}*/ int delete_window (void) /*{{{*/ { Window_Type *tthis, *prev, *next; int nr1; tthis = JWindow; next = tthis->next; if ((MiniBuffer_Active && ((tthis == JMiniWindow) || (tthis == next->next))) || (tthis == next)) return(0); nr1 = tthis->sy + tthis->rows + 2; if (nr1 != Jed_Num_Screen_Rows) { /* Not the bottom window. Move to the window below this one */ while (JWindow->sy + 1 != nr1) other_window(); JWindow->sy = tthis->sy; } else { /* The bottom window. Move to the window above this one. */ while (JWindow->sy + JWindow->rows + 1 != tthis->sy) other_window(); } JWindow->rows += tthis->rows + 1; touch_window(); prev = next; while(prev->next != tthis) prev = prev->next; prev->next = next; free_window (tthis); return(1); } /*}}}*/ void touch_screen_for_buffer(Buffer *b) /*{{{*/ { Window_Type *w; w = JWindow; do { if (w->buffer == b) { touch_window_hard (w, 0); } w = w->next; } while(w != JWindow); } /*}}}*/ int is_line_visible (int lnum) /*{{{*/ { int n = JWindow->rows; Line *l, *beg = JWindow->beg.line; push_spot (); goto_line (&lnum); l = CLine; pop_spot (); #if JED_HAS_LINE_ATTRIBUTES if (l->flags & JED_LINE_HIDDEN) return 0; #endif while (n && (beg != NULL)) { if (l == beg) return 1; #if JED_HAS_LINE_ATTRIBUTES if (0 == (beg->flags & JED_LINE_HIDDEN)) #endif n--; beg = beg->next; } return 0; } /*}}}*/ int jed_num_windows (void) { Window_Type *w = JWindow; int n = 0; do { n++; w = w->next; } while (w != JWindow); return n; } void jed_set_scroll_column (int sc) { if (sc < 1) sc = 1; JWindow->hscroll_column = sc; touch_window(); } void jed_scroll_right (int dn) { jed_set_scroll_column (JWindow->hscroll_column - dn); } void jed_scroll_left (int dn) { jed_set_scroll_column (JWindow->hscroll_column + dn); } int jed_get_scroll_column (void) { return JWindow->hscroll_column; } static void set_scroll_column_intrin (int *sc) { jed_set_scroll_column (*sc); } static int window_info_intrin(int *what) { register int n = 0; switch (*what) { case 'x': n = JWindow->sx; break; case 'y': n = JWindow->sy; break; case 'r': n = JWindow->rows; break; case 'c': n = JWindow->hscroll_column; break; case 't': n = JWindow->sy + 1; break; case 'w': n = JWindow->width; break; default: SLang_set_error (SL_INVALID_PARM); } return (n); } static SLang_Intrin_Fun_Type Window_Intrinsics [] = { MAKE_INTRINSIC_0("enlargewin", enlarge_window, SLANG_VOID_TYPE), MAKE_INTRINSIC_0("splitwindow", split_window, SLANG_VOID_TYPE), MAKE_INTRINSIC_0("window_line", window_line, INT_TYPE), MAKE_INTRINSIC_0("nwindows", jed_num_windows, SLANG_INT_TYPE), MAKE_INTRINSIC_0("otherwindow", other_window, SLANG_VOID_TYPE), MAKE_INTRINSIC_0("onewindow", one_window, SLANG_VOID_TYPE), MAKE_INTRINSIC_I("window_info", window_info_intrin, SLANG_INT_TYPE), MAKE_INTRINSIC_I("set_scroll_column", set_scroll_column_intrin, SLANG_VOID_TYPE), MAKE_INTRINSIC_0("get_scroll_column", jed_get_scroll_column, SLANG_INT_TYPE), SLANG_END_INTRIN_FUN_TABLE }; int jed_init_window_intrinsics (void) { if (-1 == SLadd_intrin_fun_table (Window_Intrinsics, NULL)) return -1; return 0; } jed-0.99-19/src/keymap.h0000644002657400265740000000571511311317447013730 0ustar davisdavis/* Copyright (c) 1992, 1998, 2000, 2004, 2005, 2006 John E. Davis * This file is part of JED editor library source. * * You may distribute this file under the terms the GNU General Public * License. See the file COPYING for more information. */ #ifndef _JED_KEYMAP_H_ #define _JED_KEYMAP_H_ /*Jed Keymap routines. * * The main problem here is how to associate a sequence of characters to a * given function in as fast a way as possible. In addition, I require that * the procedure be memory efficient as well as allowing the user the * flexability to redefine the keys and add new keymaps. * * To do this, I define a key map to be an array of keys. There may be many * keymaps (global, local, etc...). A key structure is defined. */ #ifdef HAS_MOUSE typedef struct { int x, y; /* row column of mouse event */ #define JMOUSE_UP 1 #define JMOUSE_DOWN 2 #define JMOUSE_DRAG 3 #define JMOUSE_DOUBLE_CLICK 4 #define JMOUSE_TRIPLE_CLICK 5 #define JMOUSE_IGNORE_EVENT 6 /* generated by button up on multiclick. */ unsigned char type; /* Note: The specific values for JMOUSE_BUTTON_? are exploited by the * mouse mapping code in mouse.c */ #define JMOUSE_BUTTON_1 0x01 #define JMOUSE_BUTTON_2 0x02 #define JMOUSE_BUTTON_3 0x04 #define JMOUSE_BUTTON_4 0x08 #define JMOUSE_BUTTON_5 0x10 #define JMOUSE_BUTTON_6 0x20 #define JMOUSE_SHIFT 0x40 #define JMOUSE_CTRL 0x80 unsigned char button; /* button that triggered event */ unsigned char state; /* button info BEFORE event */ } JMouse_Type; extern int jed_mouse_cmd (void); extern void jed_set_default_mouse_hook (char *, char *); extern void jed_set_current_mouse_window (void); extern int jed_mouse_add_event (JMouse_Type *); extern void jed_flush_mouse_queue (void); extern void jed_mouse_get_event_info (void); extern void jed_map_mouse_buttons (int *, int *); #endif extern SLKeyMap_List_Type *Global_Map; extern SLKeyMap_List_Type *Jed_Current_Keymap; extern void init_keymaps(void); extern int digit_arg(void); extern void do_jed(void); extern void jed(void); extern int jed_do_key (void); extern int kbd_quit(void); extern FVOID_STAR Last_Key_Function; extern FVOID_STAR Jed_This_Key_Function; extern int *Repeat_Factor; extern void jed_call_cmd (char *); extern void jed_set_abort_char(int *); extern int next_function_list(char *); extern int open_function_list(char *); extern char *Read_This_Character; /* alternate keyboard buffer */ extern int add_to_completion(char *); extern int is_internal(char *); extern void create_keymap (char *); extern char Key_Buffer[SLANG_MAX_KEYMAP_KEY_SEQ + 1]; extern char Jed_Key_Buffer[SLANG_MAX_KEYMAP_KEY_SEQ + 1]; extern char *Key_Bufferp; extern int jed_beep (void); extern void set_current_kbd_command (char *); extern char Current_Kbd_Command_String[32]; extern char Last_Kbd_Command_String[32]; extern unsigned char Jed_Abort_Char; extern int Jed_Max_Hits; extern int jed_init_keymap_intrinsics (void); #endif jed-0.99-19/src/mkfiles/0000755002657400265740000000000011311317447013713 5ustar davisdavisjed-0.99-19/src/mkfiles/mkmake.exe0000644002657400265740000002721211311317447015667 0ustar davisdavisMZŠ$ ÿÿÜ€>ûPjr^£OÈ· ‰oE2 K Ï C æ µ ƒ ^ = u V F  ‚ 4 â ž î  âŒÞŒÚŒXºŒ.‰‘´0Í!‹.‹,ŽÚ£}Œ{‰w‰.‘èU¡wŽÀ3À‹Ø‹ø¹ÿüò®ãCC&8uö€Í€÷Ù‰u¹ÓãƒÃƒãð‰yŒÒ+꿌ŽÇ&‹>úÿs¿&‰>ú±ÓïG;ïséù‹ßÚ‰‰‰¡{+ØŽÀ´JWÍ!_ÓçúŽÒ‹çû¸ŒŽÀ&‰>ú3À.Ž‘¿Ì¹ô+Ïüóªƒ>tvG€>}r@w€>~r7¸X»Í!r*´g‹tÍ!r ´H»Í!r@£‘HŽÀ´IÍ!r ¸X»Í!sén´Í‰‰ƒ Àt ¸@ŽÀ»p&Æ3í.Ž‘¾º¿Ìèµÿ6sÿ6qÿ6oÿ6mÿ6kš$PèÃ.Ž‘VW¾Ì¿ÌèÊ_^ËË‹ì´LŠFÍ!¹º/é¸5Í!‰[Œ]¸5Í!‰_Œa¸5Í!‰cŒe¸5Í!‰gŒi¸%ŒÊŽÚºtÍ!ø%Å[Í!¸%Å_Í!¸%ÅcÍ!¸%ÅgÍ!˸‹×‹Þ;ßt&€?ÿt&ŠO2í;Ès‹Á‹ÓƒÃëã;×t‹Ú&€?&Æÿt&ÿ_ëÄ&ÿWë½Ã´‹×‹Þ;ßt&€?ÿt &8gr&Šg‹ÓƒÃëå;×t‹Ú&€?&Æÿt&ÿ_ëÇ&ÿWëÀô@»Í!ùº=.Ž‘èêÿ¸Pè˜ÀU‹ìƒ>Ö u¸ë‹Ö±Óã‹F‹V‰‡r‰—pÿÖ3À]ËËU‹ìV‹v öu"ëÿÖ‹Ö±ÓãÿŸpƒ>ÖuéèkþÿØèËþèpþƒ~u öuÿÜÿàÿvèWþY^]ÂU‹ì3ÀPPÿvèœÿ]ËU‹ì¸P3ÀPÿvèŠÿ]Ë3ÀP¸P3ÀPè{ÿ˸PP3ÀPèoÿË[S€ùs‹ØÓàÓâöÙ€ÁÓë ÓË€é’3ÀÓâË É} ÷Ó÷уÃÑë/ÃsŠé±ÒåõŠèÓèЊÅ%Ë É} ÷Ó÷уÃÑëÑ+ÃsêŠù±Òç2Û+ÓŠèÓèЊÅ%ËU‹ìV‹v ö|ƒþX~¾W‰6žŠ„ ˜‹ðë ÷Þƒþ0éÇžÿÿ‰6¸ÿÿ^]ÂU‹ìV‹vVè¼ÿ‹Æ^]ÂU‹ì¸D‹^Í!’%€]ËU‹ìƒì"VWÄ~ ‹^ƒû$w\€ûrW‹F‹N É}€~t &Æ-G÷Ù÷؃ÙvÞã‘+Ò÷ó‘÷ó6ˆFã ëð+Ò÷ó6ˆF ÀuôNÞ÷ÙÎüN6Š, s:ëFªâî°ª‹V ‹F _^‹å]ÂU‹ì3ÀPÿvÿvÿv¸ P°P°aPèbÿ]ÂU‹ì‹^Ñã§vÿý´BŠF ‹^‹N ‹VÍ!rëPèÜþ™]ËQŠè±ÓèЊŊãÓëYËŠÜ%ƒã;Ñu;ÃÃU‹ì‹^Ñã÷‡vt¸Pë´?‹^‹N ÅVÍ!rëPè‹þ]˹;ts8‹ÙÑãLJv‹Áº÷ê‹ØÆ‡èÿ‹Áº÷êäP‹Áº÷ê‹ØX‰‡öA;trÈ è˜Pè‰þY Àu&æÿý¸P÷æt¸ë3ÀP3À3ÒPR¸äPèÒƒÄ  ü˜PèMþY Àu&úÿý¸P÷út¸ë3ÀP3À3ÒPR¸øPè–ƒÄ ÊÆèŠÂÔ†àè†à'@'ªÃU‹ìì–VWÇFîÇFìPÇFêëJW¹ÿÿ2Àò®÷ÑI_Ã6ˆGþNìu3SQR†jÿ+ø†jÿPWÿv ÿv ÿV ÀuÇFêÇFìP~î¾jÿZY[Ãü¾jÿ‰~ü‹~üÄv&¬ Àt<%t6ˆGþNìíè§ÿëèéå‰vð&¬<%tæ‰~ü3ɉNòÇFþ ˆNõÇFøÿÿÇFöÿÿë&¬2ä‹Ð‹Ø€ë €û`sŠŸƒûvéÑã.ÿ§² 醀ýwøƒNþëÏ€ýwíƒNþëÄ€ýwâ€~õ+tˆVõë´ƒfþßëƒNþ µ릀ýwM÷Fþu)ƒNþµë’é;‹~6‹ƒF€ýs Ày÷؃Nþ‰Føµénÿ€ýu׉FöþÅéaÿ€ýsʵÿFöéTÿ’,0˜€ýwµ‡Fø À|ÑÑà‹ÐÑàÑàÂFøé2ÿ€ýu›‡Fö ÀtµÑà‹ÐÑàÑàÂFöéÿƒNþéeÿNþƒfþïéYÿ·ë · ë ·³éÚÆFõˆVû3ÒˆVú‹~6‹ë· ÆFúˆVû‹~6‹™GG‰v÷Fþt6‹GG‰~~» Àu Òuƒ~öu 6Æ‹ÇëƒNþRPWŠÇ˜PŠFúPSèðû‹Vö Ò}éôéÿˆVû‰v~º‹^6ÿ7CC‰^÷Fþ t6‹CC‰^èŽý°:ªZè…ý6ÆÆFúƒfþûNº+ù‡Ï‹Vö;Ñ‹Ñ顉vˆVû‹~6‹ƒF~»2ä6‰¹éĉvˆVû‹~÷Fþ u 6‹=ƒF ÿë 6Ä=ƒFŒÀ Çu¿üèFý;Növ‹Nö釉vˆVû‹~‹Nö É}¹WQ^»SR¸#FþP‹Fþ©t ¸ƒF ëƒF¸Pè6~»÷Fþt‹Vø Ò~èæü&€=-uI+Ñ~‰Vò&€=-t ŠFõ ÀtO&ˆƒ~ò~ ‹Nö É}ÿNòè´ü‹÷‹~ü‹^ø¸#Fþ=uŠfû€üou ƒ~òÇFòë€üxt€üXuƒNþ@KKƒnò}ÇFòNò÷Fþu ë° èmüK;Ùö÷Fþ@t °0è\üŠFûèVü‹Vò Ò~'+Ê+Ú&Š<-t< t<+u&¬è7üIK‡Êã°0è,üâù‡Êã+Ù&¬6ˆGþNìèüâð Û~ ‹Ë° è üâùéMü‰v‹~÷Fþ u 6‹=ƒFë6Ä=ƒF¸P*FìFî&‰÷FþtGG&Çéü‹vðŽF‹~ü°%èºû&¬ Àu÷€~ìP}è´ûƒ~êt¸ÿÿë‹Fî_^‹å] øCq~¼ÃÈ,ñÏÓ×Qþ¡ÁB ~ ~ ~ $ºdëºi¹´@»Í!¹'ºn´@Í!éy÷.; t7ŽÚŽƒ>t.Œ ë8ŒØ.; t¡.£ 3ÀPè¢.Ž ë#.‹ .Ç .Ç .Ç .Ž R3ÀPè=ƒÄÃŽÚŽÇŒ.; t.&ƒ>u&¡[&ŒÁÐŽÂ&ƒ>u&‰ë &‰ëèQŒÀ&ŽØƒ>tá&ŒÀŒÛŽÃ&£ŒÛ;tŽŽŒ&Œ.Œ ŽÛÃ.Ç Ã.¡ Àt!ŒÓœúŽÐ6Ž6ŒŒŽÓ&ŒŒÃ.Œ ŒŒÃU‹ìVW.Œ ‹V Òt.; uè±þëèÿ.Ž _^]ËP.Ž 3ÀPPèqƒÄ%tº+Ð3À.Ž PRèXƒÄXP3ۊܱÓëÓà.Ž SPè?ƒÄ[=ÿÿt.‰ .‰ ŽÚ‰‰¸Ã3À™ÃP3ۊܱÓëÓà.Ž SPèƒÄ[=ÿÿt8%u.‹ .‰ ŽÚ‰‰¸ÃSR÷Ø3ÛSPèуÄZ[=ÿÿtBëÍ3À™Ã‹Ú)ŽÚ£‰‹ÚŽÛ‰¸ÃU‹ì3Ò‹Fë U‹ì‹V‹F‹È ÊVW.Œ t^ƒÒrA÷Âðÿu;±ÓèÓâ â.‹ Òt .‹ Òt‹ÚŽÚ9s‹;Óuðè&ÿëè½þëèvÿë3À™ëwôè#þ‹‰¸.Ž _^]ËS.‹6 V.‹6 VèrÿƒÄ Òu[ÃŽÂS‹üJ¿‹÷¹ó¥ Òt7ŒÀ@ŽÀŒØ@ŽØ3ÿ‹÷‹Êùv¹ÑáÑáÑáó¥êvŒÀŽÀŒØŽØëÓ.Ž èûýƒÄZ¸Ã.; tE‹ûøŽÇ‹ñ+ð&‰6&‰PŽÃ&£‹ÓÑŽÂ&ƒ>t&‰>ë&‰>‹óè°ýƒÄ‹Ö¸ÃSŽÃ&£ØS3ÀPèÿƒÄZ¸ÃU‹ì3ÒëU‹ì‹V ‹F ‹^VW.Œ .‰ .£ Ût:‹È Êt?ƒÒr@÷Âðÿu:±ÓèÓâ âŽÃ&‹;Èrw‹Ó¸ë!èBÿëèÁþëRPè<þƒÄë SPèýƒÄ3À™.Ž _^]ËU‹ìV‹vF+6{ƒÆ?±Óî;6–u‹F‹V£‰‹¸ëF±Óæ‹‘‹Æ{;Âv‹ò+6{Vÿ6{è"YY‹Ðƒúÿu ‹Æ±Ó裖븡{£‘Ç3À^]ÂU‹ì‹‰‹‡‹V‹Fè@õr ‹‘‹‹V‹Fè-õw ÿvÿvèXÿ Àu¸ÿÿë3À]ÃU‹ìƒì¡3Ò±è]ó‹ƒÒFVƒú|=ÿÿvºÿÿ¸ÿÿëV‹¡‹‹N‹^èMó‰Vþ‰Fü‹‰‹‡èÃôrÕ‹‘‹‹Vþ‹Füè°ôw¡‹‹‰Fú‰VøÿvþÿvüèÎþ Àt¨‹Vú‹Fø‹å]Ãÿ&²ž ¢.Œw‰6¤‰>¦üŽ{¾€2ä&¬@ŒÅ‡Ö“‹6uFF¹€>}rŽw‹þ±2Àò®ãr€ñP‹ÁÃ@%þÿ‹ü+ør`‹çQIó¤2ÀªŽÝ‡ò‡Ù‹Ã‹ÐCèw rF< tèwõ< t< t< uä2Àëà ÀtBª ÀuC†à2Àùã¬I,"t"<\u€<"u¬I öÃéAñYÊ.Žw‰˜CÛÛ‹ô‹ì+ërâ‹å‰.šŒœã‰vŒVƒÅ6¬ Ààútí3À‰F‰F.Žw‹6¤‹>¦ÿ6¢ÿ6 ¡˜£k¡œ£o¡š£mÿ&žU‹ì´J‹^ŽFÍ!r¸ÿÿëSPèòX]ËVWŽw3ÿÿ6yè{û[‹Ø£¨‰ªŽÚ Âué“ð3À¹ÿÿ&€=t‰?ŒGƒÃò®&8uñ‰‰G_^¡ª£s¡¨£qÃStack overflow! $ŒÛŒÈŽØº´ Í!ŽÛéïðU‹ìƒì‹F;tr¸Pë[‹^Ñã÷‡vt¸ëL¸D‹^Í!r>ö€u5¸B3É‹ÑÍ!r.RP¸B3É‹ÑÍ!‰Fü‰VþZYr¸BÍ!r;Vþr w;Fürë·3ÀëPè)ñ‹å]ËU‹ìV‹F FuèXé´Ä^&‹G;Ft¸ÿÿé¤Ä^&ƒ?|Q&÷Gu&‹G‹VƒÂ;Fté&9W uyÄ^&Ç&‹G‹VƒÂ;Fub&9W u\&‹G &‹W&‰G&‰W ëJëHÄ^&‹G&@‹ð&)7P&‹G &‹W&‰G&‰W PR&ŠG˜Pè ƒÄ;ÆtÄ^&÷Gu&ƒOéXÿ3À^]ËU‹ìƒìVW‹~ 3É‹F‹V‰Fþ‰Vüë Ä^ü&ˆÿFüƒù t4O~1Ä^ &ÿ|&‹G&‹w &ÿG ŽÀ&Š´ë ÿvÿv èˆYY‹È=ÿÿu¾ƒùÿu‹Fþ‹Vü;Fu ;Vu3Ò3ÀëÄ^ü&ÆÄ^ &÷Gt3Ò3Àë‹V‹F_^‹å]ËU‹ìƒìVW3ÿ‹6tŒ^þÇFüäëÄ^ü&÷Gt ÿvþSèkþYYGƒFü‹ÆN ÀuÞ‹Ç_^‹å]ËU‹ì¸ÅPÿvÿvÿv ÿv FPè©ñ]ËU‹ìV‹F Fu3Àë7ÿvÿvèS YY‹ð ÀtéÿvÿvVÿv ÿv è Àt Ä^Þ&ŠGÿ´ë¸ÿÿ^]ËU‹ìƒìVÄ^&ƒ?} &‹O&A‹ñëÄ^&‹™3Â+‹ȋðÄ^&÷G@uCÄ^&‹G&‹W ‰Fþ‰Vü&ƒ?}%ë ÿNüÄ^ü&€? uF‹ÁI ÀuìëÄ^üÿFü&€? uF‹ÁI Àuì‹Æ^‹å]ÂU‹ìV‹vÿvÿvè[ýYY Àt¸ÿÿë`ƒþuÄ^&ƒ?~ÿvSèLÿ™)F V Ä^&g_þ&Ç&‹G &‹W&‰G&‰W Vÿv ÿv &ŠG˜Pè'ïƒÄƒúÿu =ÿÿu¸ÿÿë3À^]ËU‹ìƒì¸P3À3ÒPRÄ^&ŠG˜PèòîƒÄ‰Vþ‰Füƒúÿu=ÿÿué¢Ä^&ƒ?|é†&ŠG˜Ñà‹Ø÷‡vtc¸P3À3ÒPR‹^&ŠG˜Pè§îƒÄ‰Vú‰Føƒúÿu=ÿÿt`3ÀPÿvþÿvüÄ^&ŠG˜Pè}îƒÄƒúÿu =ÿÿuºÿÿ¸ÿÿë4‹Fú‹Vø‰Fþ‰VüÿvÿvèAþ™FüVþëÿvÿvè/þ™)FüVþ‹Vþ‹Fü‹å]ËU‹ìƒìV¾Œ^þÇFüäëÄ^ü&‹G%=u ÿvþSèáûYYƒFü‹ÆN ÀuÛ^‹å]ÃU‹ìÄ^&÷Gtè±ÿÄ^&ÿw&‹G &‹W&‰G&‰W PR&ŠG˜P豃ÄÄ^&‰ À~ &ƒgß3Àë)Ä^&ƒ?u&‹G%þ &‰Gë Ä^&Ç&ƒO¸ÿÿ]ÂU‹ìÄ^&ÿÿvSèYY]ËXPU‹ìV‹F Fu¸ÿÿéÙÄ^&ƒ?~Ä^&ÿ&‹G&‹w &ÿG ŽÀ&Šé´Ä^&ƒ?|o&÷Gug&÷Gt_Ä^&O€&ƒtÿvSè ÿ Àt²ë¡ë®Ä^&÷Gtè·þ¸P¸ðPÄ^&ŠG˜PèÄƒÄ Àu3Ä^&ŠG˜Pè!úY=t Ä^&ƒOéTÿÄ^&‹G%þ &‰Gé@ÿ€>ð u Ä^&÷G@tÄ^&ƒgß ð´^]˸äPè ÿYYËU‹ìƒìVWÄ~ŒÀ Çt °&Š%¹ÿÿüò®÷ÑItÄ>¨ŒFþŒÃ ߉~üu 3Ò3Àë3ƒFüÄ~ü&Ä=ŒÃ ßtê&Š Àtã:àuå‹Ù&€9=uÝÅvó¦‡ËuÒG‹ÇŒÂ_^‹å]ËU‹ìVWŒÚÄ~Åv ‹NÑéüó¥s¤ŽÚ‹V‹F_^]ËU‹ìÄ^&ÿÿv SŠF˜PèƒÄ]ËU‹ìVŠF¢òÄ^&ƒ?ÿ}T&ÿ&‹G&‹w &ÿG ŠòŽÀ&ˆŽF &÷GuéT€>ò t €>ò téCÿv ÿvè@ùYY Àué/¸ÿÿé.é&Ä^&÷Gu&÷Gu Ä^&ƒOëÚÄ^&O&ƒto&ƒ?tÿv SèòøYY ÀuµÄ^&‹G÷Ø&‰&‹G&‹w &ÿG ŠòŽÀ&ˆŽF &÷Guéµ€>ò t €>ò té¤ÿv ÿvè¡øYY Àuéé^ÿéŠÄ^&ŠG˜Ñà‹Ø÷‡vt¸P3À3ÒPR‹^&ŠG˜Pè‰êƒÄ€>ò u'Ä^&÷G@u¸P¸¬P&ŠG˜PèKƒÄ=u¸P¸òPÄ^&ŠG˜Pè,ƒÄ=tÄ^&÷Guéíþ ò´^]ËU‹ì¸øPÿvè\þƒÄ]ËU‹ìƒìVW‹~‰~þÄ^&÷Gt.ë"ÿvÿvÄ^ ÿF &Š˜Pè'þƒÄ=ÿÿu3À龋ÇO Àu×é±Ä^&÷G@ué(&ƒuéË&9si&ƒ?tÿvSèx÷YY Àu¾Ä^&ŠG˜Ñà‹Ø÷‡vt¸P3À3ÒPR‹^&ŠG˜PèiéƒÄWÿv ÿv Ä^&ŠG˜Pè<ƒÄ;Çué0émÿé*Ä^&‹Ç|&&ƒ?u ¸ÿÿ&+G&‰ëÿvÿvè÷öYY Àté:ÿWÿv ÿv Ä^&ÿw&ÿw èýƒÄ Ä^&‹Ç&‰& éÎÄ^&ŠG˜Ñà‹Ø÷‡vt¸P3À3ÒPR‹^&ŠG˜Pè¹èƒÄWÿv ÿv Ä^&ŠG˜P范Ä;Çué€é½þë{Ä^&ƒtRëGÄ^&ÿ} &‹G&‹w &ÿG Ä^ ÿF &ŠŽÀ&ˆŠÂ´ëÿvÿvÄ^ ÿF &ŠPèvüƒÄ=ÿÿuéhþ‹ÇO Àu²ëWÿv ÿv Ä^&ŠG˜P軃Ä;Çté@þ‹Fþ_^‹å] U‹ìƒìVW‹F;tr ¸Pèöæé°‹F @=r ‹^Ñã÷‡vt3Àé•ÿv ÿv ÿvÿvèèƒÄ‰Fþ@=r ‹^Ñã÷‡v@u‹Fþëf‹NþÄv‹þ‹Þü&¬<t0< tªâóëâïS¸PFýPÿvèÂçƒÄ[üŠFýª;ûuë’ë"S¸P÷ÙÀPQÿvèSçƒÄ‹^Ñãv[+û—_^‹å]ËU‹ìVW‹~‹vÄ^&‹G;Fu ƒÿþÿv¸ÿÿéñƒ>°u~øuǰëƒ>®u ~äuÇ®Ä^&ƒ?t¸P3À3ÒPRÿvSè=÷ƒÄ Ä^&÷Gt&ÿw &ÿwèîYYÄ^&ƒgó&ÇG‹F‹VƒÂ&‰G &‰W&‰G&‰W ƒÿt` öv\ÇÚÇØû ‹F F u!VèÝîY‰V ‰F Âué?ÿÄ^&ƒOëé2ÿÄ^‹F ‹V &‰G&‰W &‰G &‰W&‰wƒÿu&ƒO3À_^]ËU‹ìVWŒÚü3À‹ØÄ~ ‹÷2À¹ÿÿò®÷Ñ‹þÅvó¦ŠDÿ&Š]ÿ+ÃŽÚ_^]ËU‹ìWÄ~3À;Fu;Çt ü¹ÿÿò®‘÷ÐH_]ËU‹ìVWŒÚüÄ~ ‹÷‹F‹Èã‹Ø2Àò®+Ù‹Ë‹þÅvó¦ŠDÿ&Š]ÿ2äŠü+ÃŽÚ_^]ËU‹ìVWüÄ~ ‹÷2À‹^‹Ëò®+ٌǎßÄ~‡Ëó¤‹Ëóª‹V‹F_^]ËU‹ììŽVW‹~;>tr ¸PèOäé/‹F @=s3Àé!‹ßÑã÷‡vt¸P3À3ÒPRWè åƒÄ‹ßÑã÷‡v@uÿv ÿv ÿvWèíƒÄéá‹ßÑã§vÿý‹F ‹V‰Fö‰Vô‹F ‰FúëuÿNúÄ^ôÿFô&ŠˆFù< u Ä^ü&Æ ÿFüÄ^üŠFù&ˆÿFü†rÿ‹Vü3Û+ÐƒÛ Û|Duú€r<†rÿ‹vü3Ò+ðƒÚVPWèoƒÄ‹Ð;Ætƒúÿu¸ÿÿëQ‹F +FúëE†rÿŒVþ‰Füƒ~útéxÿ†rÿ‹vü3Ò+ðƒÚ‹Æ Àv$V†rÿPWè ƒÄ‹Ð;Ætƒúÿt±‹F Â+Æë‹F _^‹å]ËU‹ì‹^Ñã÷‡vt¸Pë!´@‹^‹N ÅVÍ!rP‹^ÑãvXëPèÝâ]ËU‹ìƒìV¾Œ^þÇFüäëÄ^ü&÷Gt ÿvþSèŽñYYNƒFü öuá^‹å]ËU‹ì¸”P¸ Pš\ƒÄ¸PšY]ËU‹ìì V3ÀPš!Y ÀtèÆÿFöPš YYÆFü!ÆFý#ÆFþ¾ë‹Æ±ÓàÄ^Ø&ÿw&ÿ7šO YYF;v|áë*FöP†öûPš  ƒÄ Àt¸øP†öûPšxƒÄ¸äP¸ÿP†öûPš~ƒÄ Âu»FöPš: YY3Àë^‹å]ËU‹ì9&úwš(Ä^&Ç&ÇG&ÇG&ÆG%&ÆG#&ÆG3À]ËU‹ì9&úwš(]ËU‹ì9&úwš(‹F FtÄ^&€?t¸¶PÿvSš¶ƒÄ Àu¸éÉ‹F F u~ëxÄ^&Š˜=*t =?u;ÿFÿF ëcÿFÄ^&€?uëÉÿv ÿv ÿvÿvè…ÿƒÄ Àu²ÿF Ä^ &€?uÝë,Ä^&€?\uÿFÄ^&€?uÿNÄ^ÿF&ŠÄ^ ÿF &:t3ÀëCÄ^&€?t Ä^ &€?téoÿÄ^ &€?u#Ä^&€?t¸¸PÿvSš¶ƒÄ Àu¸ë3À]ËU‹ìƒì9&úwš(3ҋ±ÓàÌŒ^ü‰FúÄ^ú&€?uOÿvÿvšæYY‰Fþ=vÇFþÄ^úŠFþ&ˆÿFúÿvþÿvÿvÿvüÿvúš=ƒÄ Ä^ú^þ&ƸëBƒú |“3À‹å]ËU‹ìƒìVW9&úwš(‹F‹V‰Fú‰Vø3öé‹Fú‹Vø‰F‰VëÿFÄ^&Š Òt€ú t €ú ¸ë3À ÀuÞ€ú ~W:V tRWÿvþÿvüÿvÿvšƒÄ Àu~Ä^&€? ~&Š:F uª¸ëUÿFÄ^&Š€ú ~ :V t¸ë3À Àuâë…Fƒþ }-‹Æ±ÓàÌŒ^þ‰FüÄ^üÿFü&Š˜‹ø Àt¸ë3À ÀtéAÿ3À_^‹å]ËU‹ìƒì9&úwš(‹FH‹V ‹^ ؉Vþ‰^üëÄ^&ŠÄ^ &ˆÿFÿF ‹F ;Füs Ä^&€? wÝÄ^&€? v3Ò3Àë!Ä^ &ÆëÿFÄ^&€? tô&€? tî‹V‹F‹å]ËU‹ìƒì$9&úwš(Ä^&€? é®&Š:F u飸 PFÜPÿvÿvèIÿƒÄ ‰V‰F Âué€FÜPšlYY‰Vþ‰Fü ÂtjÄ^&€?t&€? t&Š:F u¸ëP¸ PFÜPÿvÿvèôþƒÄ ‰V‰F Ft-ÿvþÿvüFÜPèaüƒÄ ÀuÄÄ^&€?t&€? t&Š:F u²3À‹å]ËU‹ìƒìVW9&úwš(‹F Ft‹F F u¸é‚Ä^ &ŠGÄ^&:tGÄ^ &‹G&;tébÄ^&€? uÄ^ &ŠG´%éLÄ^ &ŠGÄ^&:uµÄ^ &ŠG´%é.ë¤Ä^ &‹7&‹&‹G‰FþÿFÄ^&€?!uÄ^ &€#uéÿFÄ^&€? tô&€? tî&€?a};÷u¸ë3ÀéܸP¸ºPÿvÿvšƒÄ Àu;÷uO‰~þN;vþ|é–‰vþéÄ^&€?eu:&€lu3‹Ç@;Æu!9vþtƒFÄ^&€?su &€eu‹þé[Në ;÷téQOéMÄ^&€?itéÓþ&€ftéÉþ;÷tFé/FƒFÄ^&€?nu ÇFüÿFëÇFü¸P¸ÀPÿvÿvšƒÄ Àu)Ä^ &ŠGP‹FÿvPèüƒÄ;FüuéŸ3À‰Fü龸P¸ÄPÿvÿvšƒÄ Àu‹Fü÷ØÀ@‰Füé•Ä^&€?$u Ä^ &ŠGP‹F@ÿvPè&ýƒÄ;FüuªëG릸P¸ÊPÿvÿvšƒÄ Àu3¡l nt*Ä^ &ŠGP‹FÿvPÿlƒÄ;Fütéaÿ¸é]ÿéXÿ¸P¸ÑPÿvÿvšƒÄ Àté¢ýƒ~üt ‹þ‰~þëé’ý ÿ}é‹ýÄ^ &‰7&‰‹Fþ&‰G3À_^‹å]ËBorland C++ - Copyright 1991 Borland Intl.Divide error Abnormal program termination ôUsage: mkmake [DEF1 [DEF2 ...]] **endifdeffalseexiststrueÂÂÂ ä ø C B4```  ),(((((),(((),#,*((((**#(#%((null)       print scanf : floating point formats not linked â ç ç ç My¾jed-0.99-19/src/mkfiles/README0000644002657400265740000000216611311317447014600 0ustar davisdavisThe *only* makefile here that I will continue to support is makefile.all. It is used in conjunction with the DOS executable `mkmake.exe' to produce other makefiles. To produce makefiles for, e.g., an MSDOS executable compiled with BCC, use the command mkmake MSDOS BCC < makefile.all > makefile Similarly, other makefiles may be produced as mkmake MSDOS DJGPP < makefile.all > makefile mkmake WIN32 MINGW32 < makefile.all > makefile mkmake OS2 EMX < makefile.all > makefile mkmake WIN16 BCC NO_FOLD < makefile.all > makefile (Note: NO_FOLD is to compile without folding support.) If you want to submit a makefile to me, please make additions to makefile.all. Notes: 1. I have only tested makefiles for BCC, DJGPP, and MINGW32 development environments. It is conceivable that makefile.all may need modifed for other systems. 2. I think that the MINGW32 and CYGWIN32 spawnvp function is broken. For that reason, I recommend that you use the BCC compiled mswshell.exe executable in jed/bin. Better yet, find out how to achieve the same effect without using spawnvp. jed-0.99-19/src/mkfiles/makefile.all0000644002657400265740000005036211311317447016170 0ustar davisdavis!ifndef MSDOS WIN16 WIN32 OS2 # -*- mode: sh; mode: fold -*- # This file has been folded. #{{{ MACRO descriptions This is a master makefile that from which DOS/Windows/OS2 makefiles may be derived. A makefile for a particular system may be derived by passing this through the standalone DOS executable 'mkmake' which should be present in this directory. For example, to produce a makefile suitable for OS2 using the EMX compiler use: mkmake OS2 EMX < makefile.all > Makefile Similarly, mkmake MSDOS BCC < makefile.all > Makefile will produce a makefile for MSDOS and the Borland C compiler. Currently supported environments include: MSDOS WIN16 WIN32 OS2 Currently supported compilers include: MSDOS - BCC, DJGPP, DJGPP_V1 WIN16 - BCC WIN32 - BCC, VC, CYGWIN32, MINGW32 OS2 - EMX, ICC Features include (also edit features.h!) NO_FOLD (The default is to get folding support) More will be added in the future. If are linking against a dll version of slang, add a 'DLL' parameter to mkmake: mkmake WIN32 VC DLL < makefile.all > Makefile (right now this is known to work only with Visual Studio). Each section must define the following macros: CC : The C compiler CFLAGS : Compiler flags P : Path separator used by make/compiler O : Object file extension SRCDIR : SRC location (.) OBJDIR : Directory where objects are placed COMPILE_CMD : Command used to produce object from .c file LINK_CMD : Command used to produce executable LIBDEPS : Other dependencies library depends upon TARGET : Primary target name SLANGLIB : Location of slang library SLANGINC : Location of slang.h TARGET_DEPS : Misc stuff to build COMPILE_DEPS : Dependencies associated with COMPILE_CMD COPY : Copy command Other macros include: RSPFILE : Name of response file RSP_PREFIX : Prefix for response file line (See its usage) RSP_POSTFIX : Postfix for response file line (See its usage) DEF_FILE : *.def file Special notes: The P macro could be problematic when its value is a backslash (\). Some make programs may require it to be doubled, i.e., \\. Whatever its value is, it should expand to something that does not include whitespace. Usually this requires that it be followed by a '#' character; however, this may result in the '#' character being quoted, or, escaped if the value of P is a backslash. #}}} !else #rest of file # Note: # This makefile was automatically generated from the master makefile.all. TOOL_PREFIX = !ifdef MSDOS ! ifdef DJGPP DJGPP_V1 #{{{ CC = gcc CFLAGS = -O2 -fno-strength-reduce -Wall -DJED P = /# path sep O = o # Object extension SRCDIR = .# Location of sources OBJDIR = djgobjs# Location of objects TARGET = $(OBJDIR)/jed.exe RSPFILE = $(OBJDIR)/link.rsp RSP_PREFIX = RSP_POSTFIX = SLANGINC = ../../slang/src SLANGLIB = $(SLANGINC)/$(OBJDIR) COMPILE_CMD = $(CC) -c $(CFLAGS) -I$(SLANGINC) -o # ! ifndef DJGPP_V1 LINK_CMD = $(CC) -s -L$(SLANGLIB) -o $(TARGET) @$(RSPFILE) -lslang -lm ! else GO32 = G:/djgpp/bin/go32.exe ! endif COMPILE_DEPS = TARGET_DEPS = COPY = cp #}}} ! elifdef BCC #{{{ CC = bcc CFLAGS = -G- -H -N -O1 -w -ml -Dmsdos -DJED P = \\ O = obj SRCDIR = . OBJDIR = bccobjs TARGET = $(OBJDIR)\jed.exe RSPFILE = $(OBJDR)\bcc.rsp RSP_PREFIX = RSP_POSTFIX = SLANGINC = ..\..\slang\src SLANGLIB = $(SLANGINC)\$(OBJDIR) COMPILE_CMD = $(CC) -c $(CFLAGS) -I$(SLANGINC) -o# <-- no tailing space LINK_CMD = $(CC) -ml -L$(SLANGLIB) -e$(TARGET) /P=4096 @$(RSPFILE) slang.lib COMPILE_DEPS = TARGET_DEPS = COPY = copy #}}} ! endif !endif !ifdef WIN16 ! ifdef BCC #{{{ CC = bcc CFLAGS = -G- -H -N -w -ml -DJED -Dmsdos -D__WIN16__ -W #CFLAGS = -N -v -H -w -ml -Dmsdos -DMSWINDOWS -DJED -WS OBJDIR = mswobjs# Location of objects TARGET = $(OBJDIR)\wjed.exe BCCLIB = C:\BCC31\LIB O = obj # Object extension P = \\ SRCDIR = .# Location of sources SLANGINC = ..\..\slang\src SLANGLIB = $(SLANGINC)\$(OBJDIR) RSPFILE = $(OBJDIR)\mswin.rsp RSP_PREFIX = RSP_POSTFIX = + COMPILE_CMD = $(CC) -c $(CFLAGS) -I$(SLANGINC) -o# LINK_CMD = tlink /Twe/m/v/c/P/i/s $(BCCLIB)\c0wl @$(RSPFILE) MSWSHELL_EXE = ..\bin\mswshell.exe DEF_FILE = $(OBJDIR)\wjed.def TARGET_DEPS = $(MSWSHELL_EXE) $(DEF_FILE) COMPILE_DEPS = COPY = copy #}}} ! endif !endif !ifdef WIN32 ! ifdef BCC #{{{ CC = bcc32 #CFLAGS = -G- -H -N -w -D__WIN32__ -W -DJED CFLAGS = -G- -H -N -w -W -w-sig -w-stu -DJED # Location of objects OBJDIR = bw32objs TARGET = $(OBJDIR)\wjed32.exe BCCLIB = C:\BC5\LIB # Object extension O = obj P = \\ # Comment to prevent continuation marker confusion with Borland Make SRCDIR = . RSPFILE = $(OBJDIR)\link.rsp RSPFILE2 = $(OBJDIR)\link2.rsp RSP_PREFIX = RSP_POSTFIX = + COMPILE_CMD = $(CC) -c $(CFLAGS) -I$(SLANGINC) -o LINK_CMD = tlink32 /Tpe /ap /c /x $(BCCLIB)\c0x32 $(JED_OBJS) @$(RSPFILE), $(OBJDIR)$(P)jed.exe, @$(RSPFILE2) WLINK_CMD = tlink32 /Tpe /aa /c /x $(BCCLIB)\c0w32 $(WJED_OBJS) @$(RSPFILE), $(OBJDIR)$(P)wjed.exe, @$(RSPFILE2) DEF_FILE = TARGET_DEPS = $(RSPFILE2) COMPILE_DEPS = COPY = copy #}}} ! elifdef VC #{{{ # Makefile for slang as Win32 GUI using nmake under Visual C. CC = cl CFLAGS = /nologo /W3 /YX /O2 /D "JED" /D "NDEBUG" /D $(CPU) /D "__WIN32__" /I "." /I $(SLANGINC) /ML P = \\ O = obj # Object extension SRCDIR = .# Location of sources OBJDIR = mw32objs# Location of objects RSPFILE = $(OBJDIR)\link.rsp RSP_PREFIX = RSP_POSTFIX = COMPILE_RSP = $(OBJDIR)\comp.rsp COMPILE_CMD = $(CC) /c $(CFLAGS) @$(COMPILE_RSP) /Fo # /Fo specifies object file name TARGET_DEPS = COMPILE_DEPS = $(COMPILE_RSP) COPY = copy LINK_CMD = link -out:$(OBJDIR)$(P)jed.exe /SUBSYSTEM:console $(JED_OBJS) @$(RSPFILE) WLINK_CMD = link -out:$(OBJDIR)$(P)wjed.exe /SUBSYSTEM:windows $(WJED_OBJS) @$(RSPFILE) # This needs changing for Windows NT on non-Intel processors CPU = _X86_ #}}} ! elifdef CYGWIN32 MINGW32 #{{{ CC = $(TOOL_PREFIX)gcc P = / ! ifdef CYGWIN32 CFLAGS += -DWIN32 -W -Wall -O2 -fno-strength-reduce -DJED -mno-cygwin WLINK_CMD = $(CC) -Wl,--subsystem,windows -mno-cygwin -s -L$(SLANGLIB) \ -o $(OBJDIR)$(P)wjed.exe $(WJED_OBJS) $(OBJS) -lslang -luser32 -lmingw32 -lgdi32 ! else ! ifdef DLL DLL_FLAGS = -DSLANG_DLL=1 ! endif CFLAGS += -DWIN32 -W -Wall -O2 -fno-strength-reduce -DJED $(DLL_FLAGS) WLINK_CMD = $(CC) -Wl,--subsystem,windows -s -L$(SLANGLIB) \ -o $(OBJDIR)$(P)wjed.exe $(WJED_OBJS) $(OBJS) -lslang -luser32 -lgdi32 ! endif LINK_CMD = $(CC) -s -L$(SLANGLIB) -o $(OBJDIR)$(P)jed.exe $(JED_OBJS) $(OBJS) -lslang -luser32 OBJDIR = gw32objs# Location of objects O = o # Object extension SRCDIR = .# Location of sources RSPFILE = RSP_PREFIX = RSP_POSTFIX = COMPILE_CMD = $(CC) -c $(CFLAGS) -I$(SLANGINC) -o # COMPILE_DEPS = COPY = cp #}}} ! endif JED_OBJS = $(OBJDIR)$(P)w32cons.$(O) $(OBJDIR)$(P)display.$(O) WJED_OBJS = $(OBJDIR)$(P)wterm.$(O) TARGET = $(OBJDIR)$(P)jed.exe WTARGET = $(OBJDIR)$(P)wjed.exe SLANGINC = ..$(P)..$(P)slang$(P)src SLANGLIB = ..$(P)..$(P)slang$(P)src$(P)$(OBJDIR) !endif !ifdef OS2 ! ifdef EMX #{{{ CC = gcc -Zmtd CFLAGS = -DOS2 -D__os2__ -DJED P = / O = o # Object extension SRCDIR = .# Location of sources OBJDIR = emxobjs# Location of objects SLANGINC = ../../slang/src SLANGLIB = ../../slang/src/$(OBJDIR) TARGET = $(OBJDIR)/os2jed.exe COMPILE_CMD = $(CC) -c $(CFLAGS) -I$(SLANGINC) -o # DEF_FILE = $(OBJDIR)/os2jed.def LINK_CMD = $(CC) -o $(TARGET) $(OBJS) -L$(SLANGLIB) $(DEF_FILE) -lslang -lvideo TARGET_DEPS = $(DEF_FILE) COMPILE_DEPS = COPY = cp #}}} ! elifdef WCC #{{{ CC = wcc386 CFLAGS = -DOS2 -D__os2__ -DJED -bm -bt=os2 # P = \# O = obj # Object extension SRCDIR = .# Location of sources OBJDIR = wccobjs# Location of objects SLANGINC = ..\..\slang\src SLANGLIB = ..\..\slang\src\$(OBJDIR)\slang.lib TARGET = $(OBJDIR)\os2jed.exe COMPILE_CMD = $(CC) $(CFLAGS) -I=$(SLANGINC) -fo=# DEF_FILE = LINK_CMD = wcl386 -fe=$(TARGET) $(OBJS) $(SLANGLIB) -k150000 # -lvideo TARGET_DEPS = COMPILE_DEPS = COPY = copy #}}} ! elifdef ICC #{{{ CC = icc CFLAGS = -Q+ -W3 -DOS2 -D__os2__ -Gm+ -Wcnd- -DJED P = \# O = obj SRCDIR = . OBJDIR = iccobjs SLANGINC = ..\..\slang\src SLANGLIB = ..\..\slang\src\$(OBJDIR)\slang.lib TARGET = $(OBJDIR)\os2jed.exe COMPILE_CMD = $(CC) -c $(CFLAGS) -I$(SLANGINC) -Fo# <-- no trailing space DEF_FILE = LINK_CMD = $(CC) -Fe$(TARGET) $(OBJS) $(SLANGLIB) TARGET_DEPS = COMPILE_DEPS = COPY = copy #}}} ! endif !endif #------------------------------------------------------------------------------- # End of compiler specific section CONFIG_H = config.h SYSDEP_O_DEPS = $(SRCDIR)$(P)sysdep.c \ $(SRCDIR)$(P)dos_os2.c \ $(SRCDIR)$(P)pcscan.c \ $(SRCDIR)$(P)ibmpc.c \ $(SRCDIR)$(P)os2.c \ $(SRCDIR)$(P)win32.c \ $(SRCDIR)$(P)win16.c \ $(SRCDIR)$(P)i386.c # #{{{ OBJS = OBJS = $(OBJDIR)$(P)buffer.$(O) \ $(OBJDIR)$(P)cmds.$(O) \ $(OBJDIR)$(P)misc.$(O) \ $(OBJDIR)$(P)file.$(O) \ $(OBJDIR)$(P)main.$(O) \ $(OBJDIR)$(P)menu.$(O) \ $(OBJDIR)$(P)jedwin.$(O) \ !ifndef WIN16 WIN32 $(OBJDIR)$(P)display.$(O) \ !endif $(OBJDIR)$(P)ins.$(O) \ $(OBJDIR)$(P)sysdep.$(O) \ $(OBJDIR)$(P)screen.$(O) \ $(OBJDIR)$(P)colors.$(O) \ $(OBJDIR)$(P)paste.$(O) \ $(OBJDIR)$(P)ledit.$(O) \ $(OBJDIR)$(P)userinfo.$(O) \ $(OBJDIR)$(P)version.$(O) \ $(OBJDIR)$(P)hooks.$(O) \ $(OBJDIR)$(P)lock.$(O) \ $(OBJDIR)$(P)line.$(O) \ $(OBJDIR)$(P)vterm.$(O) \ $(OBJDIR)$(P)keymap.$(O) \ $(OBJDIR)$(P)replace.$(O) \ $(OBJDIR)$(P)window.$(O) \ $(OBJDIR)$(P)search.$(O) \ $(OBJDIR)$(P)text.$(O) \ $(OBJDIR)$(P)undo.$(O) \ $(OBJDIR)$(P)vfile.$(O) \ $(OBJDIR)$(P)intrin.$(O) \ $(OBJDIR)$(P)syntax.$(O) \ $(OBJDIR)$(P)abbrev.$(O) \ $(OBJDIR)$(P)mouse.$(O) \ !ifndef NO_FOLD $(OBJDIR)$(P)blocal.$(O) \ $(OBJDIR)$(P)lineattr.$(O) \ !endif ! ifdef WIN32 $(OBJDIR)$(P)w32proc.$(O) \ ! endif ! ifdef OS2 $(OBJDIR)$(P)jprocess.$(O) \ ! endif ! ifdef WIN16 $(OBJDIR)$(P)wterm.$(O) \ ! endif $(OBJDIR)$(P)indent.$(O) #}}} ! ifdef WIN32 jed: $(TARGET) @echo jed created in $(OBJDIR) wjed: $(WTARGET) @echo wjed created in $(OBJDIR) $(TARGET): $(OBJDIR) $(CONFIG_H) $(RSPFILE) $(OBJS) $(JED_OBJS) $(TARGET_DEPS) $(LINK_CMD) $(WTARGET): $(OBJDIR) $(CONFIG_H) $(RSPFILE) $(OBJS) $(WJED_OBJS) $(TARGET_DEPS) $(WLINK_CMD) ! ifdef VC $(COMPILE_RSP) : echo $(CFLAGS) > $(COMPILE_RSP) !ifdef DLL echo /DSLANG_DLL=1 >> $(COMPILE_RSP) !endif ! elifdef BCC $(RSPFILE2) : makefile @echo $(OBJDIR)$(P)wjed32.map > $(RSPFILE2) @echo $(SLANGLIB)$(P)wslang+ >> $(RSPFILE2) @echo $(BCCLIB)$(P)import32+ >> $(RSPFILE2) @echo $(BCCLIB)$(P)cw32 >> $(RSPFILE2) ! ifdef WIN16 EMX @echo $(DEF_FILE) >> $(RSPFILE2) ! endif ! endif ! else $(TARGET): $(OBJDIR) $(CONFIG_H) $(RSPFILE) $(OBJS) $(TARGET_DEPS) ! ifndef DJGPP_V1 $(LINK_CMD) ! else $(CC) -s @$(RSPFILE) -L$(SLANGLIB) -lslang -lpc -o $(OBJDIR)/jed386.386 strip $(OBJDIR)/jed386.386 coff2exe -s $(GO32) $(OBJDIR)/jed386.386 ! endif ! endif # WIN32 ! ifndef EMX CYGWIN32 MINGW32 ICC #{{{ $(RSPFILE) $(RSPFILE) : makefile echo Creating response file $(RSPFILE) ! ifdef VC @echo /NOLOGO user32.lib gdi32.lib > $(RSPFILE) @echo winspool.lib comdlg32.lib advapi32.lib shell32.lib >> $(RSPFILE) @echo $(RSP_PREFIX)$(OBJDIR)$(P)indent.$(O) $(RSP_POSTFIX) >> $(RSPFILE) ! else @echo $(RSP_PREFIX)$(OBJDIR)$(P)indent.$(O) $(RSP_POSTFIX) > $(RSPFILE) ! endif ! ifndef NO_FOLD @echo $(RSP_PREFIX)$(OBJDIR)$(P)blocal.$(O) $(RSP_POSTFIX) >> $(RSPFILE) @echo $(RSP_PREFIX)$(OBJDIR)$(P)lineattr.$(O) $(RSP_POSTFIX) >> $(RSPFILE) ! endif @echo $(RSP_PREFIX)$(OBJDIR)$(P)mouse.$(O) $(RSP_POSTFIX) >> $(RSPFILE) @echo $(RSP_PREFIX)$(OBJDIR)$(P)abbrev.$(O) $(RSP_POSTFIX) >> $(RSPFILE) @echo $(RSP_PREFIX)$(OBJDIR)$(P)syntax.$(O) $(RSP_POSTFIX) >> $(RSPFILE) @echo $(RSP_PREFIX)$(OBJDIR)$(P)intrin.$(O) $(RSP_POSTFIX) >> $(RSPFILE) @echo $(RSP_PREFIX)$(OBJDIR)$(P)vfile.$(O) $(RSP_POSTFIX) >> $(RSPFILE) @echo $(RSP_PREFIX)$(OBJDIR)$(P)undo.$(O) $(RSP_POSTFIX) >> $(RSPFILE) @echo $(RSP_PREFIX)$(OBJDIR)$(P)text.$(O) $(RSP_POSTFIX) >> $(RSPFILE) @echo $(RSP_PREFIX)$(OBJDIR)$(P)search.$(O) $(RSP_POSTFIX) >> $(RSPFILE) @echo $(RSP_PREFIX)$(OBJDIR)$(P)window.$(O) $(RSP_POSTFIX) >> $(RSPFILE) @echo $(RSP_PREFIX)$(OBJDIR)$(P)replace.$(O) $(RSP_POSTFIX) >> $(RSPFILE) @echo $(RSP_PREFIX)$(OBJDIR)$(P)keymap.$(O) $(RSP_POSTFIX) >> $(RSPFILE) @echo $(RSP_PREFIX)$(OBJDIR)$(P)vterm.$(O) $(RSP_POSTFIX) >> $(RSPFILE) @echo $(RSP_PREFIX)$(OBJDIR)$(P)line.$(O) $(RSP_POSTFIX) >> $(RSPFILE) @echo $(RSP_PREFIX)$(OBJDIR)$(P)ledit.$(O) $(RSP_POSTFIX) >> $(RSPFILE) @echo $(RSP_PREFIX)$(OBJDIR)$(P)userinfo.$(O) $(RSP_POSTFIX) >> $(RSPFILE) @echo $(RSP_PREFIX)$(OBJDIR)$(P)version.$(O) $(RSP_POSTFIX) >> $(RSPFILE) @echo $(RSP_PREFIX)$(OBJDIR)$(P)hooks.$(O) $(RSP_POSTFIX) >> $(RSPFILE) @echo $(RSP_PREFIX)$(OBJDIR)$(P)lock.$(O) $(RSP_POSTFIX) >> $(RSPFILE) @echo $(RSP_PREFIX)$(OBJDIR)$(P)paste.$(O) $(RSP_POSTFIX) >> $(RSPFILE) @echo $(RSP_PREFIX)$(OBJDIR)$(P)screen.$(O) $(RSP_POSTFIX) >> $(RSPFILE) @echo $(RSP_PREFIX)$(OBJDIR)$(P)colors.$(O) $(RSP_POSTFIX) >> $(RSPFILE) @echo $(RSP_PREFIX)$(OBJDIR)$(P)sysdep.$(O) $(RSP_POSTFIX) >> $(RSPFILE) @echo $(RSP_PREFIX)$(OBJDIR)$(P)ins.$(O) $(RSP_POSTFIX) >> $(RSPFILE) @echo $(RSP_PREFIX)$(OBJDIR)$(P)main.$(O) $(RSP_POSTFIX) >> $(RSPFILE) @echo $(RSP_PREFIX)$(OBJDIR)$(P)file.$(O) $(RSP_POSTFIX) >> $(RSPFILE) @echo $(RSP_PREFIX)$(OBJDIR)$(P)misc.$(O) $(RSP_POSTFIX) >> $(RSPFILE) @echo $(RSP_PREFIX)$(OBJDIR)$(P)menu.$(O) $(RSP_POSTFIX) >> $(RSPFILE) @echo $(RSP_PREFIX)$(OBJDIR)$(P)jedwin.$(O) $(RSP_POSTFIX) >> $(RSPFILE) ! ifndef WIN16 WIN32 @echo $(RSP_PREFIX)$(OBJDIR)$(P)display.$(O) $(RSP_POSTFIX) >> $(RSPFILE) ! endif ! ifdef WIN32 @echo $(RSP_PREFIX)$(OBJDIR)$(P)w32proc.$(O) $(RSP_POSTFIX) >> $(RSPFILE) ! endif ! ifdef WIN16 @echo $(RSP_PREFIX)$(OBJDIR)$(P)wterm.$(O) $(RSP_POSTFIX) >> $(RSPFILE) ! endif @echo $(RSP_PREFIX)$(OBJDIR)$(P)cmds.$(O) $(RSP_POSTFIX) >> $(RSPFILE) @echo $(RSP_PREFIX)$(OBJDIR)$(P)buffer.$(O) >> $(RSPFILE) ! ifdef WIN16 @echo $(TARGET) >> $(RSPFILE) @echo wjed.map >> $(RSPFILE) @echo $(SLANGLIB)\wslang+ >> $(RSPFILE) @echo $(BCCLIB)\import+ >> $(RSPFILE) @echo $(BCCLIB)\mathwl+ >> $(RSPFILE) @echo $(BCCLIB)\cwl >> $(RSPFILE) @echo $(DEF_FILE) >> $(RSPFILE) !endif !ifdef WIN32 !ifdef VC @echo $(SLANGLIB)\WSLANG32.LIB >> $(RSPFILE) !endif !endif #}}} !endif #NOT EMX $(OBJDIR) : -mkdir $(OBJDIR) $(CONFIG_H): jedconf.h $(COPY) jedconf.h $(CONFIG_H) touch $(CONFIG_H) !ifdef WIN16 $(MSWSHELL_EXE): mswshell.c bcc -ml -I. -e$(MSWSHELL_EXE) mswshell.c ! endif ! ifdef WIN16 EMX #{{{ $(DEF_FILE) $(DEF_FILE) : @echo creating $(DEF_FILE) ! ifdef WIN16 @echo NAME WJED > $(DEF_FILE) @echo EXETYPE WINDOWS >> $(DEF_FILE) @echo CODE PRELOAD MOVEABLE DISCARDABLE >> $(DEF_FILE) @echo DATA PRELOAD MOVEABLE >> $(DEF_FILE) @echo HEAPSIZE 100 >> $(DEF_FILE) @echo STACKSIZE 16384 >> $(DEF_FILE) ! endif ! ifdef EMX @echo NAME JED WINDOWCOMPAT > $(DEF_FILE) @echo DESCRIPTION 'JED for OS/2' >> $(DEF_FILE) @echo STACKSIZE 150000 >> $(DEF_FILE) ! endif #}}} !endif $(OBJDIR)$(P)indent.$(O) : $(SRCDIR)$(P)indent.c $(CONFIG_H) $(COMPILE_DEPS) $(COMPILE_CMD)$(OBJDIR)$(P)indent.$(O) $(SRCDIR)$(P)indent.c $(OBJDIR)$(P)mouse.$(O) : $(SRCDIR)$(P)mouse.c $(CONFIG_H) $(COMPILE_DEPS) $(COMPILE_CMD)$(OBJDIR)$(P)mouse.$(O) $(SRCDIR)$(P)mouse.c $(OBJDIR)$(P)abbrev.$(O) : $(SRCDIR)$(P)abbrev.c $(CONFIG_H) $(COMPILE_DEPS) $(COMPILE_CMD)$(OBJDIR)$(P)abbrev.$(O) $(SRCDIR)$(P)abbrev.c $(OBJDIR)$(P)syntax.$(O) : $(SRCDIR)$(P)syntax.c $(CONFIG_H) $(COMPILE_DEPS) $(COMPILE_CMD)$(OBJDIR)$(P)syntax.$(O) $(SRCDIR)$(P)syntax.c $(OBJDIR)$(P)intrin.$(O) : $(SRCDIR)$(P)intrin.c $(CONFIG_H) $(COMPILE_DEPS) $(COMPILE_CMD)$(OBJDIR)$(P)intrin.$(O) $(SRCDIR)$(P)intrin.c $(OBJDIR)$(P)vfile.$(O) : $(SRCDIR)$(P)vfile.c $(CONFIG_H) $(COMPILE_DEPS) $(COMPILE_CMD)$(OBJDIR)$(P)vfile.$(O) $(SRCDIR)$(P)vfile.c $(OBJDIR)$(P)undo.$(O) : $(SRCDIR)$(P)undo.c $(CONFIG_H) $(COMPILE_DEPS) $(COMPILE_CMD)$(OBJDIR)$(P)undo.$(O) $(SRCDIR)$(P)undo.c $(OBJDIR)$(P)text.$(O) : $(SRCDIR)$(P)text.c $(CONFIG_H) $(COMPILE_DEPS) $(COMPILE_CMD)$(OBJDIR)$(P)text.$(O) $(SRCDIR)$(P)text.c $(OBJDIR)$(P)search.$(O) : $(SRCDIR)$(P)search.c $(CONFIG_H) $(COMPILE_DEPS) $(COMPILE_CMD)$(OBJDIR)$(P)search.$(O) $(SRCDIR)$(P)search.c $(OBJDIR)$(P)window.$(O) : $(SRCDIR)$(P)window.c $(CONFIG_H) $(COMPILE_DEPS) $(COMPILE_CMD)$(OBJDIR)$(P)window.$(O) $(SRCDIR)$(P)window.c $(OBJDIR)$(P)replace.$(O) : $(SRCDIR)$(P)replace.c $(CONFIG_H) $(COMPILE_DEPS) $(COMPILE_CMD)$(OBJDIR)$(P)replace.$(O) $(SRCDIR)$(P)replace.c $(OBJDIR)$(P)keymap.$(O) : $(SRCDIR)$(P)keymap.c $(CONFIG_H) $(COMPILE_DEPS) $(COMPILE_CMD)$(OBJDIR)$(P)keymap.$(O) $(SRCDIR)$(P)keymap.c $(OBJDIR)$(P)vterm.$(O) : $(SRCDIR)$(P)vterm.c $(CONFIG_H) $(COMPILE_DEPS) $(COMPILE_CMD)$(OBJDIR)$(P)vterm.$(O) $(SRCDIR)$(P)vterm.c $(OBJDIR)$(P)line.$(O) : $(SRCDIR)$(P)line.c $(CONFIG_H) $(COMPILE_DEPS) $(COMPILE_CMD)$(OBJDIR)$(P)line.$(O) $(SRCDIR)$(P)line.c $(OBJDIR)$(P)ledit.$(O) : $(SRCDIR)$(P)ledit.c $(CONFIG_H) $(COMPILE_DEPS) $(COMPILE_CMD)$(OBJDIR)$(P)ledit.$(O) $(SRCDIR)$(P)ledit.c $(OBJDIR)$(P)userinfo.$(O) : $(SRCDIR)$(P)userinfo.c $(CONFIG_H) $(COMPILE_DEPS) $(COMPILE_CMD)$(OBJDIR)$(P)userinfo.$(O) $(SRCDIR)$(P)userinfo.c $(OBJDIR)$(P)version.$(O) : $(SRCDIR)$(P)version.c $(CONFIG_H) $(COMPILE_DEPS) $(COMPILE_CMD)$(OBJDIR)$(P)version.$(O) $(SRCDIR)$(P)version.c $(OBJDIR)$(P)hooks.$(O) : $(SRCDIR)$(P)hooks.c $(CONFIG_H) $(COMPILE_DEPS) $(COMPILE_CMD)$(OBJDIR)$(P)hooks.$(O) $(SRCDIR)$(P)hooks.c $(OBJDIR)$(P)lock.$(O) : $(SRCDIR)$(P)lock.c $(CONFIG_H) $(COMPILE_DEPS) $(COMPILE_CMD)$(OBJDIR)$(P)lock.$(O) $(SRCDIR)$(P)lock.c $(OBJDIR)$(P)paste.$(O) : $(SRCDIR)$(P)paste.c $(CONFIG_H) $(COMPILE_DEPS) $(COMPILE_CMD)$(OBJDIR)$(P)paste.$(O) $(SRCDIR)$(P)paste.c $(OBJDIR)$(P)screen.$(O) : $(SRCDIR)$(P)screen.c $(CONFIG_H) $(COMPILE_DEPS) $(COMPILE_CMD)$(OBJDIR)$(P)screen.$(O) $(SRCDIR)$(P)screen.c $(OBJDIR)$(P)colors.$(O) : $(SRCDIR)$(P)colors.c $(CONFIG_H) $(COMPILE_DEPS) $(COMPILE_CMD)$(OBJDIR)$(P)colors.$(O) $(SRCDIR)$(P)colors.c $(OBJDIR)$(P)sysdep.$(O) : $(SYSDEP_O_DEPS) $(CONFIG_H) $(COMPILE_DEPS) $(COMPILE_CMD)$(OBJDIR)$(P)sysdep.$(O) $(SRCDIR)$(P)sysdep.c $(OBJDIR)$(P)ins.$(O) : $(SRCDIR)$(P)ins.c $(CONFIG_H) $(COMPILE_DEPS) $(COMPILE_CMD)$(OBJDIR)$(P)ins.$(O) $(SRCDIR)$(P)ins.c $(OBJDIR)$(P)main.$(O) : $(SRCDIR)$(P)main.c $(CONFIG_H) $(COMPILE_DEPS) $(COMPILE_CMD)$(OBJDIR)$(P)main.$(O) $(SRCDIR)$(P)main.c $(OBJDIR)$(P)file.$(O) : $(SRCDIR)$(P)file.c $(CONFIG_H) $(COMPILE_DEPS) $(COMPILE_CMD)$(OBJDIR)$(P)file.$(O) $(SRCDIR)$(P)file.c $(OBJDIR)$(P)misc.$(O) : $(SRCDIR)$(P)misc.c $(CONFIG_H) $(COMPILE_DEPS) $(COMPILE_CMD)$(OBJDIR)$(P)misc.$(O) $(SRCDIR)$(P)misc.c $(OBJDIR)$(P)cmds.$(O) : $(SRCDIR)$(P)cmds.c $(CONFIG_H) $(COMPILE_DEPS) $(COMPILE_CMD)$(OBJDIR)$(P)cmds.$(O) $(SRCDIR)$(P)cmds.c $(OBJDIR)$(P)buffer.$(O) : $(SRCDIR)$(P)buffer.c $(CONFIG_H) $(COMPILE_DEPS) $(COMPILE_CMD)$(OBJDIR)$(P)buffer.$(O) $(SRCDIR)$(P)buffer.c # !ifndef NO_FOLD $(OBJDIR)$(P)lineattr.$(O) : $(SRCDIR)$(P)lineattr.c $(CONFIG_H) $(COMPILE_DEPS) $(COMPILE_CMD)$(OBJDIR)$(P)lineattr.$(O) $(SRCDIR)$(P)lineattr.c $(OBJDIR)$(P)blocal.$(O) : $(SRCDIR)$(P)blocal.c $(CONFIG_H) $(COMPILE_DEPS) $(COMPILE_CMD)$(OBJDIR)$(P)blocal.$(O) $(SRCDIR)$(P)blocal.c !endif !ifndef WIN16 $(OBJDIR)$(P)display.$(O) : $(SRCDIR)$(P)display.c $(CONFIG_H) $(COMPILE_DEPS) $(COMPILE_CMD)$(OBJDIR)$(P)display.$(O) $(SRCDIR)$(P)display.c !endif $(OBJDIR)$(P)menu.$(O) : $(SRCDIR)$(P)menu.c $(CONFIG_H) $(COMPILE_DEPS) $(COMPILE_CMD)$(OBJDIR)$(P)menu.$(O) $(SRCDIR)$(P)menu.c $(OBJDIR)$(P)jedwin.$(O) : $(SRCDIR)$(P)jedwin.c $(CONFIG_H) $(COMPILE_DEPS) $(COMPILE_CMD)$(OBJDIR)$(P)jedwin.$(O) $(SRCDIR)$(P)jedwin.c ! ifdef WIN32 $(OBJDIR)$(P)w32cons.$(O) : $(SRCDIR)$(P)w32cons.c $(CONFIG_H) $(COMPILE_DEPS) $(COMPILE_CMD)$(OBJDIR)$(P)w32cons.$(O) $(SRCDIR)$(P)w32cons.c $(OBJDIR)$(P)w32proc.$(O) : $(SRCDIR)$(P)w32proc.c $(CONFIG_H) $(COMPILE_DEPS) $(COMPILE_CMD)$(OBJDIR)$(P)w32proc.$(O) $(SRCDIR)$(P)w32proc.c ! endif ! ifdef OS2 $(OBJDIR)$(P)jprocess.$(O) : $(SRCDIR)$(P)jprocess.c $(CONFIG_H) $(COMPILE_DEPS) $(COMPILE_CMD)$(OBJDIR)$(P)jprocess.$(O) $(SRCDIR)$(P)jprocess.c ! endif ! ifdef WIN16 WIN32 $(OBJDIR)$(P)wterm.$(O) : $(SRCDIR)$(P)wterm.c $(CONFIG_H) $(COMPILE_DEPS) $(COMPILE_CMD)$(OBJDIR)$(P)wterm.$(O) $(SRCDIR)$(P)wterm.c ! endif ! ifdef WIN16 WIN32 $(SRCDIR)$(P)sysdep.c : $(SRCDIR)$(P)win16.c $(SRCDIR)$(P)win32.c touch $(SRCDIR)$(P)sysdep.c !endif !endif #NOT HELP jed-0.99-19/src/mkfiles/mkmake.c0000644002657400265740000000130011311317447015316 0ustar davisdavis#include #include #include static void usage (void) { fprintf (stderr, "Usage: mkmake [DEF1 [DEF2 ...]]\n"); exit (1); } int main (int argc, char **argv) { char buf[1024]; int i; SLPreprocess_Type pt; if (isatty (0)) usage (); SLprep_open_prep (&pt); pt.preprocess_char = '!'; pt.comment_char = '#'; pt.flags = SLPREP_BLANK_LINES_OK | SLPREP_COMMENT_LINES_OK; for (i = 1; i < argc; i++) SLdefine_for_ifdef (argv[i]); while (NULL != fgets (buf, sizeof (buf) - 1, stdin)) { if (SLprep_line_ok (buf, &pt)) { fputs (buf, stdout); } } SLprep_close_prep (&pt); return 0; } jed-0.99-19/src/w32proc.c0000644002657400265740000004031111311317447013723 0ustar davisdavis/* Copyright (c) 1992, 1998, 2000, 2002, 2003, 2004, 2005, 2006 John E. Davis * This file is part of JED editor library source. * * You may distribute this file under the terms the GNU General Public * License. See the file COPYING for more information. */ #include "config.h" #include "jed-feat.h" #ifdef JED_HAS_SUBPROCESSES # include # include # include "jdmacros.h" # include # include "jprocess.h" # include "buffer.h" # include "ins.h" # include "ledit.h" # include "misc.h" # include "paste.h" # include "win32.h" int Num_Subprocesses; static CRITICAL_SECTION Critical_Section; static int Is_GUI; /* Note: The console version of jed uses Input_Events[0] for the * handle to the keyboard. So, we start numbering at 1. This is ugly. */ HANDLE Input_Events[MAX_PROCESSES + 1]; static int Subprocess_Id[MAX_PROCESSES + 1]; /* maps input events to id */ volatile int Child_Status_Changed_Flag;/* if this is non-zero, editor * should call the appropriate * function below to call slang * handlers. */ typedef struct { int flags; /* This is zero if the process is gone * and the status is nolonger avail */ # define PROCESS_RUNNING 1 # define PROCESS_STOPPED 2 # define PROCESS_ALIVE 3 # define PROCESS_EXITED 4 # define PROCESS_SIGNALLED 8 int return_status; /* This value depends on the flags */ int status_changed; /* non-zero if status changed. */ HANDLE rd, wd; /* read/write handles */ HANDLE hprocess; /* real process handle */ HANDLE hthread; int output_type; # define PROCESS_USE_BUFFER 1 # define PROCESS_USE_SLANG 2 # define PROCESS_SAVE_POINT 4 # define PROCESS_AT_POINT 8 int process_flags; # define USE_CURRENT_BUFFER 0x1 /* use the current buffer instead of * the one associated with the process */ Buffer *buffer; /* buffer associated with process */ SLang_Name_Type *slang_fun; /* function to pass output to */ SLang_MMT_Type *umark; /* marks point of last output */ SLang_Name_Type *status_change_fun; /* call this if process status changes * The function should be declared like * define fun (pid, flags); * The flags parameter corresponds to * the flags field in this struct and * the pid is NOT the pid of this struct */ HANDLE input_event; int quietly_kill_on_exit; # define PROCESS_BUFSIZE 513 unsigned char input_buf [PROCESS_BUFSIZE]; int input_bufsize; } Process_Type; static Process_Type Processes[MAX_PROCESSES]; static Process_Type *get_process (int fd) { Process_Type *p; if ((fd >= 0) && (fd < MAX_PROCESSES) && (p = &Processes[fd], p->flags != 0)) return p; msg_error ("process does not exist."); return NULL; } static void call_slang_status_change_hook (Process_Type *p) { Buffer *cbuf = CBuf; if ((p->status_change_fun == NULL) || (p->buffer == NULL)) return; cbuf->locked++; if (0 == (p->process_flags & USE_CURRENT_BUFFER)) switch_to_buffer (p->buffer); SLang_push_integer ((int) (p - Processes)); SLang_push_integer (p->flags); SLang_push_integer (p->return_status); SLexecute_function (p->status_change_fun); touch_screen (); if ((0 == (p->process_flags & USE_CURRENT_BUFFER)) && (CBuf != cbuf)) switch_to_buffer (cbuf); cbuf->locked--; } #if 0 static void close_rd_and_wd(Process_Type *p) { char eof = '\x1a'; /* ^Z */ DWORD d; if (p->wd != INVALID_HANDLE_VALUE) { WriteFile(p->wd, &eof, 1, &d, NULL); CloseHandle(p->wd); p->wd = INVALID_HANDLE_VALUE; } if (p->rd != INVALID_HANDLE_VALUE) { CloseHandle(p->rd); p->rd = INVALID_HANDLE_VALUE; } } #endif /* This routine is called to clean up after the process has exited. * After getting the exit status, we call a slang hook and if the * process is dead, adjust the process arrays to delete the process. */ static void get_process_status (Process_Type *p) { int i; /* Call slang to let it know what happened. Do it first before we * really shut it down to give the hook a chance to query the state of * it before it returns. */ call_slang_status_change_hook (p); if (p->flags & PROCESS_ALIVE) return; /* Process is dead. So perform clean up. */ CloseHandle(p->input_event); p->input_event = INVALID_HANDLE_VALUE; if (p->buffer != NULL) p->buffer->subprocess = 0; if (p->umark != NULL) SLang_free_mmt (p->umark); /* Adjust the array of input events. Note that first handle * is used for read descriptor for console jed */ i = 1; while (i <= Num_Subprocesses) { if (Input_Events[i] == p->input_event) break; i++; } Num_Subprocesses--; while (i <= Num_Subprocesses) { Input_Events[i] = Input_Events[i + 1]; Subprocess_Id[i] = Subprocess_Id[i + 1]; i++; } #if SLANG_VERSION > 10400 SLang_free_function (p->slang_fun); SLang_free_function (p->status_change_fun); #endif memset((char *) p, 0, sizeof(Process_Type)); } int jed_close_process (int *fd) { Process_Type *p; if (NULL == (p = get_process (*fd))) return -1; EnterCriticalSection(&Critical_Section); TerminateProcess(p->hprocess, 0); if (p->buffer != NULL) p->buffer->subprocess = 0; LeaveCriticalSection(&Critical_Section); return 0; } void jed_kill_process (int fd) { /* This function is called when the buffer is going to be destroyed */ Processes[fd].buffer = NULL; jed_close_process (&fd); } void jed_get_child_status (void) { Process_Type *p, *pmax; p = Processes; pmax = p + MAX_PROCESSES; while (p < pmax) { if (p->flags && p->status_changed) { EnterCriticalSection(&Critical_Section); Child_Status_Changed_Flag--; LeaveCriticalSection(&Critical_Section); p->status_changed--; get_process_status (p); } p++; } } static DWORD thread_func (DWORD fd) { char buf[PROCESS_BUFSIZE]; DWORD n; int i; Process_Type *p = get_process(fd); if (p == NULL) return 0; while (1) { EnterCriticalSection(&Critical_Section); i = PROCESS_BUFSIZE - p->input_bufsize - 1; LeaveCriticalSection(&Critical_Section); /* Check if there is free space in process buffer */ if (i > 0) { if (!ReadFile(p->rd, buf, i, &n, NULL)) { EnterCriticalSection(&Critical_Section); /* read handle is closed, so mark process as terminated */ CloseHandle (p->rd); p->rd = INVALID_HANDLE_VALUE; CloseHandle (p->wd); p->wd = INVALID_HANDLE_VALUE; p->flags = PROCESS_EXITED; p->status_changed++; SetEvent(p->input_event); LeaveCriticalSection (&Critical_Section); return 0; } if (n == 0) continue; EnterCriticalSection(&Critical_Section); buf[n] = 0; memcpy(p->input_buf + p->input_bufsize, buf, n + 1); p->input_bufsize += n; SetEvent(p->input_event); LeaveCriticalSection(&Critical_Section); } } } void read_process_input(int input_event_number) { Buffer *b = CBuf, *pbuf; int otype, n, status; Process_Type *p; char buf[PROCESS_BUFSIZE]; /* Should never happen */ if (NULL == (p = get_process (Subprocess_Id[input_event_number]))) return; EnterCriticalSection(&Critical_Section); ResetEvent(p->input_event); n = p->input_bufsize; memcpy(buf, p->input_buf, n + 1); p->input_bufsize = 0; *p->input_buf = 0; status = p->status_changed; LeaveCriticalSection(&Critical_Section); if (n > 0) { otype = p->output_type; pbuf = p->buffer; if (pbuf != NULL) { if (0 == (p->process_flags & USE_CURRENT_BUFFER)) switch_to_buffer (pbuf); pbuf->locked++; } if (otype & PROCESS_SAVE_POINT) push_spot (); if (otype & PROCESS_USE_BUFFER) { if (0 == (otype & PROCESS_AT_POINT)) eob (); jed_insert_nbytes ((unsigned char *)buf, n); jed_move_user_object_mark (p->umark); } else if (otype == PROCESS_USE_SLANG) { SLang_push_integer ((int) (p - Processes)); SLang_push_string (buf); SLexecute_function (p->slang_fun); /* function to pass output to */ } if (otype & PROCESS_SAVE_POINT) pop_spot (); else if (otype & PROCESS_USE_BUFFER) move_window_marks (0); if (p->buffer != NULL) { if ((b != CBuf) && (0 == (p->process_flags & USE_CURRENT_BUFFER))) switch_to_buffer (b); pbuf->locked--; } } if (status) { p->status_changed--; get_process_status (p); } touch_screen (); } static int make_handle_inheritable (HANDLE p, HANDLE *h) { HANDLE x; if (FALSE == DuplicateHandle (p, *h, p, &x, 0, TRUE, DUPLICATE_SAME_ACCESS)) return -1; CloseHandle (*h); *h = x; return 0; } static int open_process (char *cmd) { int pd; Process_Type *p; HANDLE pid; SLang_MMT_Type *mmt; STARTUPINFO si; PROCESS_INFORMATION pi; DWORD id_thread; HANDLE h_stdin, h_stdout, h_stderr; /* For subprocess */ HANDLE x_stdin, x_stdout; /* Our copies */ pd = 0; while ((pd < MAX_PROCESSES) && Processes[pd].flags) pd++; if (pd == MAX_PROCESSES) return -1; p = &Processes[pd]; SLMEMSET ((char *) p, 0, sizeof (Process_Type)); /* Create stdin/out/err handles */ pid = GetCurrentProcess (); if (FALSE == CreatePipe(&h_stdin, &x_stdin, NULL, 0)) return -1; if (FALSE == CreatePipe(&x_stdout, &h_stdout, NULL, 0)) { CloseHandle(h_stdin); CloseHandle(x_stdin); return -1; } if ((-1 == make_handle_inheritable (pid, &h_stdin)) || (-1 == make_handle_inheritable (pid, &h_stdout)) || (FALSE == DuplicateHandle (pid, h_stdout, pid, &h_stderr, 0, TRUE, DUPLICATE_SAME_ACCESS))) { CloseHandle (h_stdin); CloseHandle (h_stdout); CloseHandle (x_stdin); CloseHandle (x_stdout); return -1; } if (NULL == (mmt = jed_make_user_object_mark ())) { CloseHandle (h_stderr); CloseHandle (h_stdin); CloseHandle (h_stdout); CloseHandle (x_stdin); CloseHandle (x_stdout); return -1; } si.cb = sizeof(STARTUPINFO); si.lpReserved = NULL; si.lpReserved2 = NULL; si.cbReserved2 = 0; si.lpDesktop = NULL; si.lpTitle = NULL; si.dwFlags = STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW; /* This is necessary to work around a windows 95 bug where HIDE has no * effect. */ if (Is_GUI) si.wShowWindow = SW_MINIMIZE; else si.wShowWindow = SW_HIDE; si.hStdInput = h_stdin; si.hStdOutput = h_stdout; si.hStdError = h_stderr; if (FALSE == CreateProcess(NULL, cmd, NULL, NULL, TRUE, CREATE_NEW_PROCESS_GROUP | CREATE_NEW_CONSOLE, NULL, NULL, &si, &pi)) { jed_verror ("open_process: exec of %s failed.", cmd); CloseHandle (h_stderr); CloseHandle (h_stdin); CloseHandle (h_stdout); CloseHandle (x_stdin); CloseHandle (x_stdout); SLang_free_mmt(mmt); return -1; } CloseHandle(h_stdin); CloseHandle(h_stdout); CloseHandle(h_stderr); p->flags = PROCESS_RUNNING; p->rd = x_stdout; p->wd = x_stdin; p->hprocess = pi.hProcess; Num_Subprocesses += 1; CBuf->subprocess = pd + 1; /* Processing options */ p->buffer = CBuf; p->output_type = PROCESS_USE_BUFFER; p->umark = mmt; p->input_bufsize = 0; SLang_inc_mmt (mmt); /* tell slang we are keeping a copy */ /* If we wait on this event, it will block until set */ if (NULL == (p->input_event = CreateEvent(NULL, TRUE, FALSE, NULL))) { } /* Note that Input_Events[0] is used by the console version. So, make * sure that we start at 1. */ Input_Events[Num_Subprocesses] = p->input_event; Subprocess_Id[Num_Subprocesses] = pd; p->hthread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)thread_func, (LPVOID) pd, 0, &id_thread); return pd; } int jed_send_process (int *fd, char *str) { DWORD d; Process_Type *p = get_process (*fd); if ((p == NULL) || (p->wd == INVALID_HANDLE_VALUE)) return -1; WriteFile(p->wd, str, strlen(str), &d, NULL); return 0; } void jed_send_process_eof (int *fd) { Process_Type *p = get_process (*fd); if (p == NULL) return; if (p->wd != INVALID_HANDLE_VALUE) { CloseHandle(p->wd); p->wd = INVALID_HANDLE_VALUE; } } /* If s is NULL, then f != NULL, or visa-versa */ static int set_process (Process_Type *p, char *what, char *s, SLang_Name_Type *f) /*{{{*/ { if (!strcmp (what, "output")) { if (s != NULL) { if (0 == strcmp (s, ".")) { p->output_type = PROCESS_AT_POINT | PROCESS_USE_BUFFER; return 0; } if (0 == strcmp (s, "@")) { p->output_type = PROCESS_SAVE_POINT | PROCESS_USE_BUFFER; return 0; } if (*s == 0) { p->output_type = PROCESS_USE_BUFFER; return 0; } if (NULL == (f = SLang_get_function (s))) return -1; } p->output_type = PROCESS_USE_SLANG; p->slang_fun = f; return 0; } else if (!strcmp (what, "signal")) { if ((s != NULL) && (NULL == (f = SLang_get_function (s)))) return -1; p->status_change_fun = f; return 0; } jed_verror ("set_process: %s not supported", what); return -1; } /*}}}*/ void jed_set_process (void) { int pd; char *what, *s; Process_Type *p; SLang_Name_Type *f; f = NULL; what = NULL; s = NULL; if (SLang_peek_at_stack () == SLANG_REF_TYPE) { if (NULL == (f = SLang_pop_function ())) return; } else if (-1 == SLang_pop_slstring (&s)) return; if ((0 == SLang_pop_slstring (&what)) && (0 == SLang_pop_integer (&pd)) && (NULL != (p = get_process (pd))) && (0 == set_process (p, what, s, f))) f = NULL; SLang_free_slstring (what); SLang_free_slstring (s); #if SLANG_VERSION > 10400 SLang_free_function (f); #endif } void jed_set_process_flags (int *fd, int *oflags) { Process_Type *p; if (NULL == (p = get_process (*fd))) return; p->process_flags = *oflags; } int jed_get_process_flags (int *fd) { Process_Type *p; if (NULL == (p = get_process (*fd))) return -1; return p->process_flags; } void jed_get_process_mark (int *fd) { Process_Type *p; if (NULL == (p = get_process (*fd))) return; SLang_push_mmt (p->umark); } int jed_open_process (int *np) { int fd = -1; char *argv[501]; unsigned int num, i; char *cmd; if (CBuf->subprocess) { msg_error ("There is already a process attached to this buffer."); return -1; } num = (unsigned int) *np; if (num > 500) { msg_error ("open process: too many arguments"); return -1; } memset ((char *) argv, 0, sizeof (argv)); num += 1; /* allow for argv[0] */ i = num; while (i--) { if (SLang_pop_slstring (&argv[i])) goto free_return; } if (NULL == (cmd = w32_build_command (argv, num))) goto free_return; if ((fd = open_process(cmd)) < 0) msg_error ("Unable to open process."); SLfree (cmd); /* drop */ free_return: for (i = 0; i < num; i++) { SLang_free_slstring (argv[i]); /* NULL ok */ i++; } return fd; } int jed_signal_process (int *fd, int *sig) { (void) fd; (void) sig; return -1; } int jed_signal_fg_process (int *fd, int *sig) { return jed_signal_process (fd, sig); } void jed_query_process_at_exit (int *pid, int *query) { Process_Type *p; if (NULL == (p = get_process (*pid))) return; p->quietly_kill_on_exit = (*query == 0); } int jed_processes_ok_to_exit (void) { Process_Type *p, *pmax; int num; char buf[64]; if (Num_Subprocesses == 0) return 1; num = 0; p = Processes; pmax = p + MAX_PROCESSES; while (p < pmax) { if ((p->flags & PROCESS_ALIVE) && (0 == p->quietly_kill_on_exit)) num++; p++; } if (num == 0) return 1; sprintf (buf, "%d Subprocesses exist. Exit anyway", num); return jed_get_y_n (buf); } #if defined (__WIN32__) /* defined (__BORLANDC__) || defined (_MSC_VER) */ # undef popen # undef pclose # define popen w32_popen # define pclose w32_pclose #endif FILE *jed_popen (char *cmd, char *type) /*{{{*/ { return popen(cmd, type); } /*}}}*/ int jed_pclose (FILE *fp) { return pclose (fp); } int w32_init_subprocess_support (int is_gui) { Is_GUI = is_gui; InitializeCriticalSection(&Critical_Section); return 0; } #endif jed-0.99-19/src/getmail.c0000644002657400265740000001205711311317447014054 0ustar davisdavis/*-------------------------------*- C -*--------------------------------*/ /* Copyright (c) 1992, 1998, 2000, 2002, 2003, 2004, 2005, 2006 John E. Davis * This file is part of JED editor library source. * * You may distribute this file under the terms the GNU General Public * License. See the file COPYING for more information. */ /* File: getmail.c * * Usage: getmail * * typical usage: * getmail /usr/spool/mail/$USER $HOME/Mail/#NewMail# * * ----------------------------------------------------------------------- * Moving mail from a maildir. Written in C to avoid a race condition. * * Two methods of file locking. * * 1) Write a lock file into the mail spool directory * file = "/usr/mail/spool/username" * lock = "/usr/mail/spool/username.lock" * * * Requires sgid (possible security hole) or a world-writeable * spool directory (minor security hole - but not serious) * * 2) use fcntl () call. * * * Should always work provided the fcntl call supports file locking. * This code was inspired by the Pine mailer implementation of flock. * * Depending on your system, you may need to define or comment out * the following line: \*----------------------------------------------------------------------*/ /* #define USE_LOCK_FILE */ /* mail spool is writeable */ /*----------------------------------------------------------------------*/ #include "config.h" #include "jed-feat.h" #include #ifdef HAVE_STDLIB_H # include #endif #ifdef HAVE_UNISTD_H # include #endif #include #include #include #include #include #ifdef HAVE_SYS_FCNTL_H # include #endif #ifndef F_WRLCK # define USE_LOCK_FILE #endif #ifndef JED_MAX_PATH_LEN # define JED_MAX_PATH_LEN 1024 #endif static char *Program_Name; static void usage (void) { fprintf (stderr, "%s: usage: %s infile outfile\n", Program_Name, Program_Name); exit (-1); } #ifdef USE_LOCK_FILE static char Lock_File [JED_MAX_PATH_LEN]; #endif static void unlock_mail_file (void) { #ifdef USE_LOCK_FILE unlink (Lock_File); #endif } static void exit_error (char *msg, int l) { fprintf (stderr, "%s: %s\n", Program_Name, msg); if (l) unlock_mail_file (); exit (-1); } static int my_close (int fd) { while (-1 == close(fd)) { #ifdef EINTR if (errno == EINTR) { errno = 0; sleep (1); continue; } #endif return -1; } return 0; } #ifdef USE_LOCK_FILE static int lock_mail_file (char *file, int attempts) { struct stat s; char buf[80]; int fd; sprintf (Lock_File, "%s.lock", file); while (attempts-- > 0) { if (stat (Lock_File, &s) < 0) { if (errno != ENOENT) exit_error ("stat failed.", 0); fd = open (Lock_File, O_EXCL | O_CREAT, 0666); if (fd >= 0) { sprintf (buf, "%d", getpid()); write (fd, buf, strlen(buf)); if (0 == my_close (fd)) return (0); exit_error ("Unable to lock file. File system full.", 1); } perror (NULL); fprintf (stderr, "Attempt %d: can\'t lock <%s>", attempts, Lock_File); } else if (time((time_t *) NULL) - s.st_ctime > 60) { unlock_mail_file (); } sleep (1); } return (-1); } #endif #ifndef USE_LOCK_FILE /* This chunk was inspired by the way the pine mailer implemented flock. */ static void our_flock (int fd) { struct flock f; f.l_type = F_WRLCK; f.l_pid = 0; /* not used for setting locks*/ /* set up rest of structure to lock whole file */ f.l_whence = 0; /* from beginning of file */ f.l_start = f.l_len = 0; /* entire file */ /* we are going to block */ if (fcntl (fd, F_SETLKW, (int) &f) == -1) { exit_error ("Unable to lock file.", 0); } } #endif static void mv_mail (char *from, char *to) { char buf[8192]; int fdfrom, fdto; int n; int flags; #ifdef USE_LOCK_FILE flags = O_RDONLY; #else flags = O_RDWR; #endif if ((fdfrom = open (from, flags, 0666)) < 0) exit_error ("Unable to open input file.", 1); #ifndef USE_LOCK_FILE our_flock (fdfrom); #endif if ((fdto = open (to, O_WRONLY | O_CREAT | O_TRUNC, 0600)) < 0) exit_error ("Unable to create output file.", 1); while ((n = read (fdfrom, buf, sizeof(buf))) > 0) { if (n != write (fdto, buf, n)) { exit_error ("write failed.", 1); } } if (-1 == my_close (fdto)) exit_error ("File system full. write failed.", 1); my_close (fdfrom); #ifndef TEST_DONT_UNLINK if ( unlink (from) ) { if ((fdfrom = open (from, O_WRONLY | O_CREAT | O_TRUNC, 0600)) >= 0) close (fdfrom); } #endif unlock_mail_file (); } int main (int argc, char **argv) { char *in = argv[1]; char *out = argv[2]; Program_Name = argv [0]; if (argc != 3) usage (); #ifdef USE_LOCK_FILE if (lock_mail_file (in, 60)) exit_error ("Unable to lock file.", 0); #endif mv_mail (in, out); return (0); } /* /////////////////////// end of file (c source) ///////////////////// */ jed-0.99-19/src/dos_os2.c0000644002657400265740000002061311311317447013777 0ustar davisdavis/* Copyright (c) 1992, 1998, 2000, 2002, 2003, 2004, 2005, 2006 John E. Davis * This file is part of JED editor library source. * * You may distribute this file under the terms the GNU General Public * License. See the file COPYING for more information. */ /* /////////////////////////////////////////////////////////////////// // File: dos_os2.c // // Descript: routines that are common to dos & os/2 and `fairly' // compiler independent // included by i386.c, ibmpc.c, os2.c // // Public: // sys_delete_file(); // sys_suspend(); // sys_System(); // // Private: discover_shell(); // parse_command_line(); // // Public: NumLock_Is_Gold, PC_Alt_Char // // Private: --- // // Revisions: // - --- -- --- --- /////////////////////////////////////////////////////////////////// */ #ifndef __DOS_OS2_CODE_INCLUDED #define __DOS_OS2_CODE_INCLUDED #include "config.h" #include "jed-feat.h" #ifdef __GO32__ # include # include # include # include #endif #ifdef __os2__ #include #include #include #include #endif #ifdef __MSDOS__ #include #include #include #endif #ifdef UNIXSLASH const char SlashChar[2] = "/"; #else const char SlashChar[2] = "\\"; #endif int NumLock_Is_Gold = 0; /* map numlock key to F1 */ int PC_Alt_Char = 27; /* Delete the file NAME. returns 0 on failure, 1 on sucess * Under OS/2 and DOS, unlink()[UNIX] and remove()[ANSI] are equivalent. */ int sys_delete_file(char *name) { return(1 + remove(name)); } /* find shell (once only) */ static char *shell = NULL, *shell_switch = NULL; static void discover_shell(void) { if ( shell != NULL ) return; #ifdef SH_SHELL /* maybe some day ... */ shell_switch = "-c"; if ( (shell = getenv("SHELL")) != NULL ) return; #endif shell_switch = "/c"; if ( (shell = getenv("COMSPEC")) != NULL ) return; #ifdef __os2__ shell = "cmd.exe"; /* absolute last resort! */ #else shell = "command.com"; /* absolute last resort! */ #endif } /* /////////////////////////////////////////////////////////////////// // Function: static int parse_command_line( int *argc, char ***argv, // char **fname, // char *command_line ); // Descript: parse command_line // // Returns: the handles to redirect // // Caveat: requires spaces to separate each argument // ie., args>filename will NOT work ///////////////////////////////////////////////////////////////////// */ #define DIRECT_SPAWN 0x1000 /* some arbitrary number */ static int parse_command_line( int *argc, char ***argv, char **fname, char *command_line ) { int count, handles = 0; char *pt; discover_shell(); /* find which shell to use */ while ( (*command_line != '\0') && (*command_line == ' ')) command_line++; /* start on 1st non-space */ if ( *command_line == '!' ) { handles = DIRECT_SPAWN; command_line++; /* advance past '!' */ while ((*command_line != '\0') && (*command_line == ' ')) command_line++; /* start on next non-space */ } pt = command_line; count = 0; while ( *pt != '\0' ) { count++; /* this is an argument */ while ((*pt != '\0') && (*pt != ' ')) { if ( *pt == '|' ) /* cannot spawn directly */ handles = 0; /* need shell for pipes */ pt++; /* advance until a space */ } while ( *pt == ' ' ) pt++; /* advance until a non-space */ } *argv = (char **) SLmalloc ( (count+3) * sizeof(char *) ); if ( *argv == NULL ) return 0; /* malloc error */ *argc = 0; if ( !(handles & DIRECT_SPAWN) ) { (*argv)[ *argc ] = shell; (*argc)++; if ( count > 0 ) { (*argv)[ *argc ] = shell_switch; (*argc)++; } count += (*argc); } pt = command_line; while ((*argc < count) && (*pt != '\0')) { (*argv)[ *argc ] = pt; (*argc)++; while ( *pt != '\0' && *pt != ' ' ) pt++; /* advance until a space */ if ( *pt != '\0' ) *(pt++) = '\0'; /* parse argument here */ while ( *pt == ' ') pt++; /* advance until a non-space */ } (*argv) [ *argc ] = (char *) NULL; /* NULL terminated list */ /* now examine the arguments for '>' redirect */ for ( count = 0; count < *argc; count++ ) { for ( pt = (*argv)[count]; *pt && *pt != '>'; pt++ ) /* find '>' char */; if ( *pt == '>' ) { if ( pt == (*argv)[count] ) { handles |= 0x01; } else { switch ( *(--pt) ) { case '1': handles |= 0x01; break; case '2': handles |= 0x02; break; case '&': handles |= 0x03; break; } } (*argv)[count] = NULL; /* remove from the list */ count++; /* file name follows '>' */ if ( (*argv)[count] != NULL ) *fname = (*argv)[count]; } } if ((*fname == NULL) || (**fname == '\0' )) handles = 0x00; /* don't redirect if there is no name */ return handles; } /* /////////////////////////////////////////////////////////////////// // Function: int sys_System(char *command_line); // // Descript: shell wrapper that understands some common redirection syntax // command args > filename ; stdout // command args 1> filename ; stdout // command args 2> filename ; stderr // command args &> filename ; stdout+stderr // command args > filename 2>&1 ; stdout+stderr // // additionally, if command is prefixed by a '!', then the command is // spawned directly without invoking the shell // // Returns: returns error codes as per spawn*() // // Caveat: requires spaces to separate each argument // ie., command args>filename will NOT work ///////////////////////////////////////////////////////////////////// */ static int execute_the_command (char **, int, char *); int sys_System(char *command_line1) { int ret = -1, handles, argc = 0; char *fname = NULL, **argv = NULL, *command_line; if (NULL == (command_line = SLmake_string (command_line1))) return -1; handles = parse_command_line( &argc, &argv, &fname, command_line ); /* Note: The argc that is passed bacl has nothing to do with the * actual number of arguments in argv if there are redirections involved. * However, if it is non-zero then argv was malloced. */ if (argc) { ret = execute_the_command (argv, handles, fname); SLfree((char *)argv); } SLfree (command_line); return ret; } void sys_suspend(void) { sys_System( "" ); } static int execute_the_command (char **argv, int handles, char *file) { int ret = 0; int fd1 = -1, fd2 = -1; int fd_err = -1, fd_out = -1; if (handles & 1) { /* save stdout file handle */ fd1 = dup (fileno (stdout)); if (fd1 == -1) { msg_error ("Unable to dup stdout"); return -1; } fd_out = open (file, O_CREAT | O_TRUNC | O_TEXT | O_WRONLY | O_APPEND, S_IREAD | S_IWRITE); if ((fd_out == -1) || (-1 == dup2 (fd_out, fileno (stdout)))) { msg_error ("Unable to redirect stdout!"); ret = -1; } } if (handles & 0x2) /* stderr */ { /* save stderr file handle */ fd2 = dup (fileno (stderr)); if (fd2 == -1) { msg_error ("Unable to dup stderr"); return -1; } if (fd_out == -1) { fd_err = open (file, O_CREAT | O_TRUNC | O_TEXT | O_RDWR | O_APPEND, S_IREAD | S_IWRITE); } else fd_err = fd_out; if ((fd_err == -1) || (-1 == dup2 (fd_err, fileno (stderr)))) { msg_error ("Unable to redirect stderr!"); ret = -1; } } if (fd_out != -1) close (fd_out); if ((fd_err != -1) && (fd_err != fd_out)) close (fd_err); if (ret == 0) { ret = spawnvp(P_WAIT, argv[0], (void *) argv); if (-1 == ret ) { switch(errno) { case ENOENT: if (handles & DIRECT_SPAWN ) msg_error("Command not found."); else msg_error("Shell not found."); break; case ENOMEM: msg_error("Insufficient Memory."); break; default: msg_error("Unknown Error."); } } } if (fd1 != -1) { if (-1 == dup2 (fd1, fileno (stdout))) { msg_error ("Unable to reattach stdout"); } close (fd1); } if (fd2 != -1) { if (-1 == dup2 (fd2, fileno (stderr))) { msg_error ("Unable to reattach stderr"); } close (fd2); } return ret; } #endif /* whole file */ jed-0.99-19/src/VMSMAKE.COM0000644002657400265740000001423111311317447013725 0ustar davisdavis$!------------------------make.com for Jed-------------------------------------- $! Modified VMSMAKE for JED - Andy Harper, Kings College London $! Martin Zinser (zinser@decus.decus.de) $! AH - Use logicals to define SLANG location, if defined [16-MAY-1996] $! AH - A few bug fixes! [16-MAY-1996] $! MPJZ - Extensive re-write to check $! Platform, Compiler and MMS/MMK [02-MAR-1998] $! $ ver = f$verify(0) $! $ Make = "" $! $! Check for MMK/MMS $! $ If F$Search ("Sys$System:MMS.EXE") .nes. "" Then Make = "MMS" $ If F$Type (MMK) .eqs. "STRING" Then Make = "MMK" $! $! Look for the compiler used $! $ its_decc = (f$search("SYS$SYSTEM:DECC$COMPILER.EXE") .nes. "") $ its_vaxc = .not. its_decc .and. (f$search("SYS$SYSTEM:VAXC.EXE") .nes. "") $ its_gnuc = .not.(its_decc .or. its_vaxc) .and. (f$trnlnm("gnu_cc").nes."") $! $! Exit if no compiler available $! $ if (.not. (its_decc .or. its_vaxc .or. its_gnuc)) $ then $ write sys$output "C compiler required to build Jed" $ exit $ endif $! $! Override if requested from the commandline $! $ if (p1 .eqs. "DECC") $ then $ its_decc = .true. $ its_gnuc = .false. $ its_vaxc = .false. $ endif $ if (p1 .eqs. "VAXC") $ then $ its_decc = .false. $ its_gnuc = .false. $ its_vaxc = .true. $ endif $ if (p1 .eqs. "GCC") $ then $ its_decc = .false. $ its_gnuc = .true. $ its_vaxc = .false. $ endif $ defs = "" $! $! If you do not want floating point, comment out next line $ defs = "FLOAT_TYPE," $! $! S-Lang Include directory (where slang.olb is located) $ slanglib = "[-.-.slang.src]" $ SLANGOBJ = SLANGLIB + "SLANG.OLB" ! AH 16-MAY-1996 $ $! $! If logical names defining the location of the slang libraries and header $! files exist, use them in preference to the above definition of SLANGLIB $! - SLANG_ROOT:[SRC] = location of header files (slang.h) $! - SLANG_LIBRARY = (if defined) location of SLANG.OLB $! (if not defined) SLANG_ROOT:[SRC]SLANG.OLB used $ $ if f$trnlnm("SLANG_ROOT") .nes. "" ! AH 16-MAY-1996 $ then ! AH 16-MAY-1996 $ SLANGLIB := "SLANG_ROOT:[SRC]" ! AH 16-MAY-1996 $ if f$trnlnm("SLANG_LIBRARY") .nes. "" ! AH 16-MAY-1996 $ then ! AH 16-MAY-1996 $ SLANGOBJ = "SLANG_LIBRARY" ! AH 16-MAY-1996 $ else ! AH 16-MAY-1996 $ SLANGOBJ = SLANGLIB + "SLANG.OLB" ! AH 16-MAY-1996 $ endif ! AH 16-MAY-1996 $ endif ! AH 16-MAY-1996 $! $! Build the option files $! $ open/write optf jed.opt $ open/write xoptf xjed.opt $ write optf "Identification=""Jed B0.99-8""" $ write xoptf "Identification=""XJed B0.99-8""" $ write optf "''slangobj'/lib" $ write xoptf "''slangobj'/lib" $! $ ccopt = "/define=(''defs'JED)/include=(''slanglib')" $ if its_decc $ then $ C_C = "CC" $ if f$getsyi("HW_MODEL").ge.1024 $ then $ ccopt = "/float=ieee/name=(as_is,short)/prefix=all" + "''ccopt'" $ else $ ccopt = "/DECC/prefix=all" + "''ccopt'" $ endif $ if its_vaxc $ then $ C_C = "CC" $ endif $ if its_gnuc $ then $ C_C = "GCC" $ ccopt = "/nocase_hack/warnings" + "''ccopt'" $ write optf "gnu_cc:[000000]gcclib/lib" $ write xoptf "gnu_cc:[000000]gcclib/lib" $ endif $! $!Close the option files $! $! Note: to include decw$dwtlibshr and vaxcrtl shouldn't be necessary $! $ write xoptf "sys$share:decw$xlibshr/share" $ close optf $ close xoptf $ if (p1 .eqs. "INSTALL") then goto install $ bfiles = "abbrev," - + "buffer," - + "cmds," - + "file," - + "indent," - + "ins," - + "intrin," - + "keymap," - + "ledit," - + "line," - + "lineattr," - + "main," - + "misc," - + "paste," - + "replace" $! $ bfiles = bfiles - + ",screen," - + "search," - + "sig," - + "syntax," - + "sysdep," - + "text," - + "undo," - + "vfile," - + "vmshelp," - + "vmsmail," - + "vterm," - + "blocal," - + "mouse," - + "menu," - + "jedwin," - + "window" $ bfiles = bfiles - + ",colors" - + ",lock" - + ",hooks" - + ",version" - + ",userinfo" - + "" $! $ jfiles = bfiles + ",display" $ xfiles = bfiles + ",xterm" $! $ copy jedconf.h config.h $ purge config.h $! $ if (p2 .eqs. "XJED") then goto make_xjed_label $! $ call simple_make 'jfiles $ write sys$output "Linking jed" $ link/exec=jed.exe 'jfiles',jed.opt/opt $! $ make_xjed_label: $ call simple_make 'xfiles $ write sys$output "Linking Xjed" $ link/exec=xjed.exe 'xfiles,xjed.opt/opt $! $ if (ver .eq. 1) then set verify $ exit $! $! $! Installation $! $ Install: $ write sys$output "Sorry, no installation implemented yet." $!----------------------------------------------------------------------- $! Note: The installation requires the following director structure: $! JED_ROOT:[lib] $! JED_ROOT:[lib.tm] $! JED_ROOT:[lib.colors] $! JED_ROOT:[info] $! JED_ROOT:[doc] $! JED_ROOT:[bin] $! See Makefile.in for what should be copied to these directories. $!----------------------------------------------------------------------- $! destdef = f$trnlnm("JED_ROOT") $! again: $! def = "" $! if (destdef .nes. "") then def = "(default ''destdef')" $! write sys$output "Installation Directory" $! inquire dest "''def'" $! if (dest .eqs. "") then dest = destdef $! if (dest .eqs. "") then goto again $! if (f$parse(dest) .nes. "") then goto do_copy $! write sys$output "Directory does not exist. Creating it." $! create/dir/prot=(w:re) 'dest' $! do_copy: $! copy/log/prot=(w:re) *.sl, *.hlp, *.rc, *.info, jed.*in, jed.exe, *.com - ! 'dest' $! $! simple make $! $ simple_make: Subroutine !Subroutine to build from file-list $! $! P1 = List of files to compile $! $ files = p1 $ count = 0 $ next_file: $ f = f$element(count, ",", files) $ count = count + 1 $ if (f .eqs. ",") then goto exit_sub $ objf = f$search("''f'.obj") $ if (objf .eqs. "") then goto compile_it $ tobj = f$file_attr(objf, "RDT") $ tc = f$file_attr("''f'.c", "RDT") $ if (f .eqs. "sysdep") $ then $ if ( f$cvtime(tobj) .lts. f$cvtime(f$file_attr("vms.c","RDT"))) - then goto compile_it $ endif $ if (f$cvtime(tc) .lts. f$cvtime(tobj)) then goto next_file $ compile_it: $ write sys$output "''C_C' ''ccopt' ''f'.c" $ 'C_C''ccopt' 'f'.c $ goto next_file $ exit_sub: $ENDSUBROUTINE jed-0.99-19/src/paste.c0000644002657400265740000007227111311317447013552 0ustar davisdavis/* -*- mode: C; mode: fold; -*- */ /* Copyright (c) 1992, 1998, 2000, 2002, 2003, 2004, 2005, 2006 John E. Davis * This file is part of JED editor library source. * * You may distribute this file under the terms the GNU General Public * License. See the file COPYING for more information. */ #include "config.h" #include "jed-feat.h" /*{{{ Include Files */ #include #include #include "buffer.h" #include "ins.h" #include "line.h" #include "paste.h" #include "screen.h" #include "misc.h" #include "cmds.h" /*}}}*/ /* SLang user object be larger than 128 */ #define JED_MARK_TYPE 128 Buffer *Paste_Buffer; static Buffer *Rectangle_Buffer; /* This is used by the narrow command so that multiple windows are * handled properly. The assumption is that we are dealing with a canonical * region */ static void touch_windows(void) /*{{{*/ { Window_Type *w; Line *l; unsigned int n; w = JWindow; JWindow = JWindow->next; while (JWindow != w) { if (CBuf == JWindow->buffer) { /* The mark is set with line at top of buffer */ l = CBuf->marks->line; n = CBuf->marks->n; while ((l != NULL) && (l != JWindow->mark.line)) l = l->next, n++; if (l == NULL) jed_init_mark (&JWindow->mark, 0); touch_window(); } JWindow = JWindow->next; } jed_pop_mark(0); } /*}}}*/ #if 0 static int line_in_buffer(Line *line) /*{{{*/ { Line *l; l = CBuf->beg; while (l != NULL) if (l == line) return(1); else l = l->next; return(0); } /*}}}*/ #endif /*{{{ Spot/Mark Functions */ void jed_copy_mark (Mark *dest, Mark *src) { *dest = *src; dest->next = NULL; } void jed_init_mark (Mark *m, unsigned int flags) /*{{{*/ { m->line = CLine; m->point = Point; m->n = LineNum + CBuf->nup; m->flags = flags; /* m->next = NULL; */ } /*}}}*/ void jed_init_mark_for_buffer (Mark *m, Buffer *b, unsigned int flags) /*{{{*/ { m->line = b->line; m->point = b->point; m->n = b->linenum + b->nup; m->flags = flags; /* m->next = NULL; */ } /*}}}*/ #if 0 int jed_init_mark_for_line (Mark *m, Line *l, unsigned int flags) /*{{{*/ { Line *ll; unsigned int n; n = 1; ll = CBuf->beg; while ((ll != NULL) && (ll != l)) { ll = ll->next; n++; } if (ll == NULL) return -1; m->line = l; m->point = 0; m->n = n + CBuf->nup; m->flags = flags; /* m->next = NULL; */ return 0; } /*}}}*/ #endif #if JED_HAS_SAVE_NARROW static Mark *create_mark (unsigned int flags) /*{{{*/ { Mark *m; if (NULL == (m = (Mark *) jed_malloc0 (sizeof(Mark)))) exit_error("create-mark: malloc error", 0); jed_init_mark (m, flags); return m; } /*}}}*/ #endif /* with prefix argument, pop marks */ int set_mark_cmd (void) /*{{{*/ { Mark *m; if (Repeat_Factor != NULL) { while (CBuf->marks != NULL) jed_pop_mark(0); Repeat_Factor = NULL; return(1); } if (CBuf->marks == NULL) { jed_push_mark (); } m = CBuf->marks; jed_init_mark (m, m->flags); if ((m->flags & VISIBLE_MARK) == 0) { m->flags |= VISIBLE_MARK; CBuf->vis_marks++; } /* if (m != CBuf->marks) m->next = CBuf->marks; CBuf->marks = m; */ if (Last_Key_Function == (FVOID_STAR) set_mark_cmd) message("Mark Set."); return(1); } /*}}}*/ static Mark *allocate_mark (Jed_Mark_Array_Type **ap, Mark **mp, unsigned int flags) /*{{{*/ { Jed_Mark_Array_Type *a, *b; Mark *m; a = *ap; if ((a == NULL) || (a->num_marks == JED_MAX_MARK_ARRAY_SIZE)) { if (NULL == (b = (Jed_Mark_Array_Type *) jed_malloc0 (sizeof(Jed_Mark_Array_Type)))) { exit_error("allocate_mark: malloc error", 0); } b->next = a; a = b; *ap = a; } m = &a->marks[a->num_marks]; jed_init_mark (m, flags); a->num_marks += 1; m->next = *mp; *mp = m; return m; } /*}}}*/ static void deallocate_mark (Jed_Mark_Array_Type **ap, Mark **mp) /*{{{*/ { Jed_Mark_Array_Type *a; Mark *m; m = *mp; *mp = m->next; a = *ap; a->num_marks -= 1; if (a->num_marks == 0) { *ap = a->next; SLfree ((char *)a); } } /*}}}*/ int push_spot() /*{{{*/ { (void) allocate_mark (&CBuf->spot_array, &CBuf->spots, 0); return 1; } /*}}}*/ int jed_push_mark() /*{{{*/ { (void) allocate_mark (&CBuf->mark_array, &CBuf->marks, 0); return 1; } /*}}}*/ int jed_goto_mark(Mark *m) /*{{{*/ { Line *l; int ret = -1; l = m->line; LineNum = m->n; if (LineNum <= CBuf->nup) bob(); else if (LineNum > CBuf->nup + Max_LineNum) eob(); else { CLine = l; Point = m->point; LineNum -= CBuf->nup; ret = 0; } return ret; } /*}}}*/ int jed_pop_mark (int go) /*{{{*/ { Mark *m; m = CBuf->marks; if (m == NULL) return(0); if (go) jed_goto_mark(m); if (m->flags & VISIBLE_MARK_MASK) { CBuf->vis_marks--; /* touch screen since region may be highlighted */ if (CBuf->vis_marks == 0) touch_screen(); } deallocate_mark (&CBuf->mark_array, &CBuf->marks); return 1; } /*}}}*/ int mark_spot() /*{{{*/ { push_spot(); message("Spot Marked."); return(1); } /*}}}*/ static int pop_spot_go (int go) /*{{{*/ { Mark *m; m = CBuf->spots; if (m == NULL) return(0); if (go) jed_goto_mark (m); deallocate_mark (&CBuf->spot_array, &CBuf->spots); return 1; } /*}}}*/ int pop_spot () /*{{{*/ { return pop_spot_go (1); } /*}}}*/ int exchange_point_mark(void) /*{{{*/ { Line *save_line; int save_point; unsigned int save_n; Mark *m; if ((m = CBuf->marks) == NULL) return(0); save_point = Point; save_line = CLine; save_n = LineNum + CBuf->nup; jed_goto_mark (m); m->point = save_point; m->line = save_line; m->n = save_n; return(1); } /*}}}*/ /*}}}*/ /*{{{ Narrow/Widen/Region Functions */ /*returns 0 if the mark is not set and gives error. Exchanges point and mark * to produce valid region. A valid region is one with mark * earlier in the buffer than point. Always call this if using a region * which reqires point > mark. Also, push spot first then pop at end. */ int check_region(int *push) /*{{{*/ { register Line *beg, *tthis = CLine; int pbeg; if (CBuf->marks == NULL) { msg_error("No region defined"); return(0); } if (*push) push_spot(); beg = CBuf->marks->line; pbeg = CBuf->marks->point; if (beg == CLine) { if (pbeg <= Point) return(1); } else { while((beg != NULL) && (beg != tthis)) beg = beg->next; if (beg == tthis) return(1); } exchange_point_mark(); return(1); } /*}}}*/ static int widen_buffer_lines (Buffer *b) /*{{{*/ { Narrow_Type *n; Buffer *save = CBuf; if (NULL == (n = b->narrow)) return(0); /* make sure buffer ends in final newline */ switch_to_buffer(b); push_spot(); eob(); if ((n->end != NULL) && (0 == LINE_HAS_NEWLINE (CLine))) { /* This is a hack to avoid messing with the lock file. Yuk. */ unsigned int flags = CBuf->flags; CBuf->flags &= ~(READ_ONLY); CBuf->flags |= BUFFER_NON_LOCKING; (void) _jed_ins_byte ('\n'); CBuf->flags = flags; /* jed_set_buffer_flags (CBuf, flags); */ } pop_spot(); if (n->end != NULL) n->end->prev = b->end; if (n->beg != NULL) n->beg->next = b->beg; b->end->next = n->end; b->beg->prev = n->beg; b->beg = n->beg1; if (n->end != NULL) b->end = n->end1; Max_LineNum += n->ndown + n->nup; LineNum += n->nup; /* adjust absolute offsets */ b->nup -= n->nup; b->ndown -= n->ndown; b->narrow = n->next; /* mark_undo_boundary (b); */ SLfree ((char *)n); switch_to_buffer(save); return(1); } /*}}}*/ int widen_buffer (Buffer *b) /*{{{*/ { unsigned int flags; #if JED_HAS_LINE_ATTRIBUTES unsigned int line_flags; #endif Buffer *save; if (b->narrow == NULL) return 0; if (b->narrow->is_region == 0) return widen_buffer_lines (b); flags = b->flags; b->flags &= ~(READ_ONLY); /* A hack to avoid locking file */ b->flags |= BUFFER_NON_LOCKING; save = CBuf; if (b != CBuf) switch_to_buffer (b); push_spot (); bob (); push_spot (); eob (); widen_buffer_lines (CBuf); #if JED_HAS_LINE_ATTRIBUTES line_flags = CLine->flags; CLine->flags &= ~JED_LINE_IS_READONLY; #endif (void) jed_del_wchar (); #if JED_HAS_LINE_ATTRIBUTES CLine->flags = line_flags; #endif pop_spot (); (void) jed_up (1); #if JED_HAS_LINE_ATTRIBUTES line_flags = CLine->flags; CLine->flags &= ~JED_LINE_IS_READONLY; #endif (void) jed_del_wchar (); #if JED_HAS_LINE_ATTRIBUTES CLine->flags = line_flags; #endif /* mark_undo_boundary (b); */ pop_spot (); if (save != CBuf) switch_to_buffer (save); b->flags = flags; return 1; } /*}}}*/ int narrow_to_region (void) /*{{{*/ { int pnt; Line *line; unsigned int flags; #if JED_HAS_LINE_ATTRIBUTES unsigned int line_flags; #endif if (0 == check_region (&Number_One))/* spot pushed */ return 0; /* unmark_undo_boundary (CBuf); */ flags = CBuf->flags; CBuf->flags &= ~(READ_ONLY); /* A hack to avoid locking file */ CBuf->flags |= BUFFER_NON_LOCKING; push_spot (); line = CLine; pnt = Point; jed_pop_mark (1); /* Special case if region is empty */ if ((CLine == line) && (pnt == Point)) { pop_spot (); pop_spot (); #if JED_HAS_LINE_ATTRIBUTES line_flags = CLine->flags; CLine->flags &= ~JED_LINE_IS_READONLY; #endif (void) jed_insert_newline (); #if JED_HAS_LINE_ATTRIBUTES if (CLine->prev != NULL) CLine->prev->flags = line_flags; #endif jed_push_mark (); (void) jed_insert_newline (); #if JED_HAS_LINE_ATTRIBUTES CLine->flags = line_flags; #endif (void) jed_up (1); #if JED_HAS_LINE_ATTRIBUTES CLine->flags = line_flags; #endif if (narrow_to_lines ()) CBuf->narrow->is_region = 1; } else { #if JED_HAS_LINE_ATTRIBUTES line_flags = CLine->flags; CLine->flags &= ~JED_LINE_IS_READONLY; #endif jed_insert_newline (); #if JED_HAS_LINE_ATTRIBUTES CLine->flags = line_flags; if (CLine->prev != NULL) CLine->prev->flags = line_flags; #endif jed_push_mark (); pop_spot (); #if JED_HAS_LINE_ATTRIBUTES line_flags = CLine->flags; CLine->flags &= ~JED_LINE_IS_READONLY; #endif jed_insert_newline (); #if JED_HAS_LINE_ATTRIBUTES CLine->flags = line_flags; #endif jed_up (1); #if JED_HAS_LINE_ATTRIBUTES CLine->flags = line_flags; #endif if (narrow_to_lines ()) CBuf->narrow->is_region = 1; pop_spot (); } /* mark_undo_boundary (CBuf); */ CBuf->flags = flags; return 1; } /*}}}*/ int widen (void) /*{{{*/ { if (CBuf->narrow == NULL) return 0; if (CBuf->narrow->is_region == 0) return widen_buffer_lines (CBuf); return widen_buffer (CBuf); } /*}}}*/ int widen_region (void) /*{{{*/ { return widen (); } /*}}}*/ /* not really a region of points but a region of lines. */ int narrow_to_lines () /*{{{*/ { Line *beg; Narrow_Type *nt; if (NULL == (nt = (Narrow_Type *) jed_malloc0 (sizeof(Narrow_Type)))) return 0; if (!check_region(&Number_One)) return(0); /* spot pushed */ /* unmark_undo_boundary (CBuf); */ push_spot(); jed_pop_mark(1); jed_push_mark(); /* popped and used in touch_windows! */ beg = CLine; nt->nup = LineNum - 1; pop_spot(); /* eor now */ nt->ndown = Max_LineNum - LineNum; Max_LineNum = LineNum = LineNum - nt->nup; CBuf->nup += nt->nup; CBuf->ndown += nt->ndown; nt->next = CBuf->narrow; CBuf->narrow = nt; nt->beg = beg->prev; nt->end = CLine->next; nt->beg1 = CBuf->beg; nt->end1 = CBuf->end; nt->is_region = 0; CBuf->beg = beg; CBuf->end = CLine; beg->prev = NULL; CLine->next = NULL; if (CLine->len && (CLine->data[CLine->len - 1] == '\n')) { /* I do not think that this will affect undo. */ CLine->len--; } pop_spot(); touch_windows(); return(1); } /*}}}*/ /*}}}*/ /*{{{ Pastebuffer, Delete Region functions */ int yank() /*{{{*/ { CHECK_READ_ONLY if (Paste_Buffer == NULL) return(0); insert_buffer(Paste_Buffer); return(1); } /*}}}*/ int copy_region_to_buffer(Buffer *b) /*{{{*/ { int first_point, last_point, n; Line *first, *last; Buffer *save_buf; if (b->flags & READ_ONLY) { msg_error(Read_Only_Error); return (0); } if (!check_region(&Number_One)) return(0); /* spot pushed */ last = CLine; last_point = Point; jed_pop_mark(1); if (b == CBuf) { msg_error("A buffer cannot be inserted upon itself."); pop_spot(); return(0); } first = CLine; first_point = Point; save_buf = CBuf; switch_to_buffer(b); /* go through standard routines for undo comapatability */ Suspend_Screen_Update = 1; if (first == last) { n = last_point - first_point; if (save_buf == MiniBuffer) { (void) jed_insert_nbytes (first->data + first_point, n); } else (void) jed_quick_insert (first->data + first_point, n); } else { n = first->len - first_point; if (-1 == jed_quick_insert(first->data + first_point, n)) goto the_return; while (first = first->next, first != last) { if (-1 == jed_quick_insert (first->data, first->len)) goto the_return; } (void) jed_quick_insert(first->data, last_point); } the_return: switch_to_buffer(save_buf); pop_spot(); return(1); } /*}}}*/ int copy_to_pastebuffer() /*{{{*/ { /* delete paste buffer */ if (Paste_Buffer != NULL) delete_buffer(Paste_Buffer); Paste_Buffer = make_buffer (" ", NULL, NULL); copy_region_to_buffer(Paste_Buffer); return(0); } /*}}}*/ static int jed_check_readonly_region (void) { int beg_point, end_point; Line *beg, *end; if (CBuf->flags & READ_ONLY) { msg_error(Read_Only_Error); return -1; } if (!check_region(&Number_Zero)) return -1; end = CLine; end_point = Point; (void) exchange_point_mark (); beg = CLine; beg_point = Point; (void) exchange_point_mark (); while (1) { if (beg->flags & JED_LINE_IS_READONLY) { if ((beg == end) && (end_point == 0) && (beg_point == 0)) return 0; msg_error (Line_Read_Only_Error); return -1; } if (beg == end) break; beg = beg->next; } return 0; } int delete_region (void) /*{{{*/ { int beg_point, end_point; Line *beg, *end; if (0 != jed_check_readonly_region ()) return -1; /* make this go through standard ins/del routines to ensure undo */ end = CLine; end_point = Point; push_spot(); jed_pop_mark(1); beg = CLine; beg_point = Point; pop_spot(); if (end != beg) { bol (); if (-1 == jed_del_nbytes (end_point)) return -1; /* go back because we do not want to mess with Line structures changing on us --- shouldn't happen anyway */ while (jed_up (1) && (CLine != beg)) { bol (); if (-1 == jed_del_through_eol ()) return -1; } end_point = CLine->len; /* include \n */ } jed_set_point (beg_point); (void) jed_generic_del_nbytes (end_point - Point); return 1; } /*}}}*/ int kill_region() /*{{{*/ { if (-1 == jed_check_readonly_region ()) return -1; /* need two marks for this one */ push_spot(); if (!jed_pop_mark(1)) { check_region(&Number_Zero); pop_spot(); return(0); } jed_push_mark(); jed_push_mark(); pop_spot(); copy_to_pastebuffer(); delete_region(); return(1); } /*}}}*/ /*}}}*/ /*{{{ Rectangle Functions */ static char *Rect_Error = "Rectangle has 0 width."; int insert_rectangle() /*{{{*/ { int c1; Line *rline; CHECK_READ_ONLY if (0 == buffer_exists (Rectangle_Buffer)) { Rectangle_Buffer = NULL; return 0; } Suspend_Screen_Update = 1; c1 = calculate_column(); rline = Rectangle_Buffer->beg; if (rline != NULL) while (1) { goto_column(&c1); if (-1 == jed_quick_insert (rline->data, rline->len)) return -1; rline = rline->next; if (rline == NULL) break; if (0 == jed_down (1)) { eol(); jed_insert_newline(); } } return(1); } /*}}}*/ int open_rectangle() /*{{{*/ { int c1, n, c2, tmpm; Line *save_line; CHECK_READ_ONLY if (!check_region(&Number_One)) return(0); /* push_spot(); performed */ c1 = calculate_column(); save_line = CLine; tmpm = 1; jed_pop_mark(1); c2 = calculate_column(); n = c2 - c1; if (n < 0) { n = -n; c1 = c2; } Suspend_Screen_Update = 1; while(1) { goto_column(&c1); if (-1 == jed_insert_wchar_n_times(' ', n)) break; if (CLine == save_line) break; (void) jed_down (1); } pop_spot(); return(1); } /*}}}*/ /* MB Safe */ static int copy_or_kill_rectangle (int kill) /*{{{*/ { Line *save_line, *line, *beg; int c1, c2, dc, tmp; if (!check_region(&Number_One)) return(0); /* spot pushed */ /* delete Rectangle buffer */ if (Rectangle_Buffer != NULL) delete_buffer(Rectangle_Buffer); Rectangle_Buffer = make_buffer (" ", NULL, NULL); c2 = calculate_column(); save_line = CLine; jed_pop_mark(1); c1 = calculate_column(); if (c1 == c2) { msg_error(Rect_Error); pop_spot(); return(0); } if (c1 > c2) { tmp = c1; c1 = c2; c2 = tmp; goto_column(&c1); } dc = c2 - c1; /* go through the region copying rectanglar blocks to Rectanglebuffer */ line = beg = NULL; while (1) { int col2, col1; unsigned int len, len1; unsigned int nspaces; unsigned int nbytes; unsigned char *p1, *p2; col1 = goto_column1 (&c1); p1 = CLine->data + Point; if (col1 == c1) { col2 = goto_column1(&c2); p2 = CLine->data + Point; } else { col2 = col1; p2 = p1; } nspaces = (unsigned int) (dc - (col2 - col1)); nbytes = (unsigned int) (p2 - p1); len1 = len = nbytes + nspaces; /* Need to allocate at least 2 bytes, since a single byte is a * signature of a line with a single character whose value is a * newline character. See make_line1 for details. */ if (len <= 1) len1++; if (beg == NULL) { beg = line = make_line1 (len1); beg->prev = NULL; } else { line->next = make_line1 (len1); line->next->prev = line; line = line->next; } line->len = len; memcpy ((char *) line->data, (char *) p1, nbytes); memset ((char *) line->data + nbytes, ' ', nspaces); if (kill && (nbytes != 0)) { jed_position_point (p1); if (-1 == jed_del_nbytes (nbytes)) break; } if (CLine == save_line) break; (void) jed_down(1); } line->next = NULL; Rectangle_Buffer->line = Rectangle_Buffer->beg = beg; Rectangle_Buffer->end = line; Rectangle_Buffer->point = 0; pop_spot(); return(0); } /*}}}*/ int copy_rectangle (void) { return copy_or_kill_rectangle (0); } int kill_rectangle (void) { return copy_or_kill_rectangle (1); } int blank_rectangle (void) /*{{{*/ { int c1, c2; Line *save_line; int ncols; CHECK_READ_ONLY if (!check_region(&Number_One)) return(0); /* push_spot(); performed */ c1 = calculate_column(); save_line = CLine; jed_pop_mark(1); c2 = calculate_column(); if (c1 > c2) { int tmp = c1; c1 = c2; c2 = tmp; } ncols = c2 - c1; Suspend_Screen_Update = 1; while(1) { int pnt; goto_column (&c2); pnt = Point; goto_column (&c1); if (-1 == jed_del_nbytes (pnt - Point)) break; if (-1 == jed_insert_wchar_n_times( ' ', ncols)) break; if (CLine == save_line) break; (void) jed_down (1); } pop_spot(); return(1); } /*}}}*/ /*}}}*/ /*{{{ User Mark Functions */ typedef struct /*{{{*/ { Mark m; /* MUST be the first */ Buffer *b; } /*}}}*/ User_Mark_Type; static void free_user_mark (SLtype type, VOID_STAR um_alias) /*{{{*/ { Mark *m, *m1; Buffer *b; User_Mark_Type *um; (void) type; um = (User_Mark_Type *) um_alias; m1 = &um->m; /* The mark is only valid if the buffer that it was created for still * exists. */ if ((m1->flags & MARK_INVALID) == 0) { /* Unlink the mark from the chain. */ b = um->b; m = b->user_marks; #if JED_HAS_LINE_MARKS if (m1->flags & JED_LINE_MARK) touch_screen (); #endif if (m == m1) b->user_marks = m1->next; else { while (m->next != m1) m = m->next; m->next = m1->next; } } SLfree ((char *)um); } /*}}}*/ void free_user_marks (Buffer *b) /*{{{*/ { Mark *m = b->user_marks; while (m != NULL) { m->flags |= MARK_INVALID; m = m->next; } } /*}}}*/ static int mark_valid (Mark *m) /*{{{*/ { if (m->flags & MARK_INVALID) { msg_error ("Mark is invalid."); return 0; } return 1; } /*}}}*/ static SLang_MMT_Type *pop_valid_user_mark (User_Mark_Type **ump) { SLang_MMT_Type *mmt; User_Mark_Type *um; *ump = NULL; if (NULL == (mmt = SLang_pop_mmt (JED_MARK_TYPE))) return NULL; um = (User_Mark_Type *) SLang_object_from_mmt (mmt); if (0 == mark_valid (&um->m)) { SLang_free_mmt (mmt); return NULL; } *ump = um; return mmt; } int jed_move_user_object_mark (SLang_MMT_Type *mmt) /*{{{*/ { User_Mark_Type *um; Mark *m; um = (User_Mark_Type *) SLang_object_from_mmt (mmt); m = &um->m; if (!mark_valid (m)) return 0; if (CBuf != um->b) { msg_error ("Mark not in buffer."); return 0; } m->line = CLine; m->point = Point; m->n = LineNum + CBuf->nup; return 1; } /*}}}*/ void move_user_mark (void) /*{{{*/ { SLang_MMT_Type *mmt; if (NULL == (mmt = SLang_pop_mmt (JED_MARK_TYPE))) return; (void) jed_move_user_object_mark (mmt); SLang_free_mmt (mmt); } /*}}}*/ static int x_user_mark_fun (int (*xfun)(Mark *)) /*{{{*/ { SLang_MMT_Type *mmt; User_Mark_Type *um; int ret = -1; if (NULL == (mmt = pop_valid_user_mark (&um))) return -1; if (CBuf != um->b) msg_error ("Mark not in buffer."); else ret = (*xfun) (&um->m); SLang_free_mmt (mmt); return ret; } /*}}}*/ /* It is up to calling routine to ensure that mark is in buffer. */ static int is_mark_in_narrow (Mark *m) { return ((m->n > CBuf->nup) && (m->n <= CBuf->nup + Max_LineNum)); } int jed_is_user_mark_in_narrow (void) { return x_user_mark_fun (is_mark_in_narrow); } void goto_user_mark (void) { (void) x_user_mark_fun (jed_goto_mark); } SLang_MMT_Type *jed_make_user_object_mark (void) /*{{{*/ { User_Mark_Type *um; SLang_MMT_Type *mmt; Mark *m; if (NULL == (um = (User_Mark_Type *) jed_malloc0 (sizeof(User_Mark_Type)))) return NULL; if (NULL == (mmt = SLang_create_mmt (JED_MARK_TYPE, (VOID_STAR) um))) { SLfree ((char *) um); return NULL; } m = &um->m; jed_init_mark (m, 0); m->next = CBuf->user_marks; CBuf->user_marks = m; um->b = CBuf; return mmt; } /*}}}*/ void create_user_mark (void) /*{{{*/ { SLang_MMT_Type *mmt; if (NULL != (mmt = jed_make_user_object_mark ())) { if (-1 == SLang_push_mmt (mmt)) SLang_free_mmt (mmt); } } /*}}}*/ char *user_mark_buffer (void) /*{{{*/ { SLang_MMT_Type *mmt; User_Mark_Type *um; char *s; if (NULL == (mmt = pop_valid_user_mark (&um))) return ""; s = um->b->name; SLang_free_mmt (mmt); return s; } /*}}}*/ static int user_mark_bin_op_result (int op, SLtype a, SLtype b, SLtype *c) { (void) a; (void) b; switch (op) { default: return 0; case SLANG_GT: case SLANG_GE: case SLANG_LT: case SLANG_LE: case SLANG_EQ: case SLANG_NE: *c = SLANG_INT_TYPE; break; } return 1; } static int user_mark_bin_op (int op, SLtype a_type, VOID_STAR ap, unsigned int na, SLtype b_type, VOID_STAR bp, unsigned int nb, VOID_STAR cp) { int *ic; unsigned int n, n_max; unsigned int da, db; SLang_MMT_Type **a, **b; (void) a_type; (void) b_type; if (na == 1) da = 0; else da = 1; if (nb == 1) db = 0; else db = 1; if (na > nb) n_max = na; else n_max = nb; a = (SLang_MMT_Type **) ap; b = (SLang_MMT_Type **) bp; ic = (int *) cp; for (n = 0; n < n_max; n++) { User_Mark_Type *ua, *ub; Buffer *ba, *bb; int pa, pb; unsigned int la, lb; ub = NULL; ba = bb = NULL; pa = pb = 0; la = lb = 0; if ((*a != NULL) && (NULL != (ua = (User_Mark_Type *) SLang_object_from_mmt (*a)))) { la = ua->m.n; pa = ua->m.point; ba = ua->b; } if ((*b != NULL) && (NULL != (ub = (User_Mark_Type *) SLang_object_from_mmt (*b)))) { lb = ub->m.n; pb = ub->m.point; bb = ub->b; } if ((ba == NULL) || (bb == NULL)) { ic[n] = 0; a += da; b += db; continue; } switch (op) { case SLANG_GT: ic[n] = ((la > lb) || ((la == lb) && (pa > pb))); break; case SLANG_GE: ic[n] = ((la > lb) || ((la == lb) && (pa >= pb))); break; case SLANG_LT: ic[n] = ((la < lb) || ((la == lb) && (pa < pb))); break; case SLANG_LE: ic[n] = ((la < lb) || ((la == lb) && (pa <= pb))); break; case SLANG_EQ: ic[n] = ((ba == bb) && (la == lb) && (pa == pb)); break; case SLANG_NE: ic[n] = ((ba != bb) || (la != lb) || (pa != pb)); break; default: return 0; } a += da; b += db; } return 1; } /*}}}*/ #if JED_HAS_LINE_MARKS void jed_create_line_mark (int *color) /*{{{*/ { SLang_MMT_Type *mmt; User_Mark_Type *um; if (NULL == (mmt = jed_make_user_object_mark ())) return; um = (User_Mark_Type *) SLang_object_from_mmt (mmt); um->m.flags |= JED_LINE_MARK | (*color & MARK_COLOR_MASK); if (-1 == SLang_push_mmt (mmt)) SLang_free_mmt (mmt); } /*}}}*/ #endif #ifndef SLFUTURE_CONST # define SLFUTURE_CONST #endif static int user_mark_sget (SLtype type, SLFUTURE_CONST char *name) { SLang_MMT_Type *mmt; User_Mark_Type *um; int status; Buffer *buf; (void) type; if (NULL == (mmt = pop_valid_user_mark (&um))) return -1; buf = um->b; status = -1; if (0 == strcmp (name, "buffer_name")) status = SLang_push_string (buf->name); else SLang_verror (SL_NOT_IMPLEMENTED, "Mark_Type.%s is invalid", name); SLang_free_mmt (mmt); return status; } int register_jed_classes (void) /*{{{*/ { SLang_Class_Type *cl; cl = SLclass_allocate_class ("Mark_Type"); if (cl == NULL) return -1; (void) SLclass_set_destroy_function (cl, free_user_mark); (void) SLclass_set_sget_function (cl, user_mark_sget); if (-1 == SLclass_register_class (cl, JED_MARK_TYPE, sizeof (User_Mark_Type), SLANG_CLASS_TYPE_MMT)) return -1; if (-1 == SLclass_add_binary_op (JED_MARK_TYPE, JED_MARK_TYPE, user_mark_bin_op, user_mark_bin_op_result)) return -1; return 0; } /*}}}*/ void jed_widen_whole_buffer (Buffer *b) /*{{{*/ { while (b->narrow != NULL) widen_buffer (b); } /*}}}*/ #if JED_HAS_SAVE_NARROW static void restore_saved_narrow (void) /*{{{*/ { Mark *beg, *end; Jed_Save_Narrow_Type *save_narrow; if (NULL == (save_narrow = CBuf->save_narrow)) return; push_spot (); /* remove current restriction */ jed_widen_whole_buffer (CBuf); beg = save_narrow->beg; end = save_narrow->end; while (beg != NULL) { jed_goto_mark (beg); jed_push_mark (); jed_goto_mark (end); if (end->flags & NARROW_REGION_MARK) narrow_to_region (); else narrow_to_lines (); beg = beg->next; end = end->next; } pop_spot (); } /*}}}*/ static void free_mark_chain (Mark *m) /*{{{*/ { Mark *next; while (m != NULL) { next = m->next; SLfree ((char *)m); m = next; } } /*}}}*/ void jed_free_saved_narrow (Buffer *b) /*{{{*/ { Jed_Save_Narrow_Type *save_narrow; save_narrow = b->save_narrow; if (save_narrow == NULL) return; b->save_narrow = save_narrow->next; free_mark_chain (save_narrow->beg); free_mark_chain (save_narrow->end); SLfree ((char *)save_narrow); } /*}}}*/ void jed_push_narrow (void) /*{{{*/ { Jed_Save_Narrow_Type *save_narrow; if (NULL == (save_narrow = (Jed_Save_Narrow_Type *) jed_malloc0 (sizeof (Jed_Save_Narrow_Type)))) { exit_error ("push_narrow: malloc error.", 0); } save_narrow->beg = save_narrow->end = NULL; save_narrow->next = CBuf->save_narrow; CBuf->save_narrow = save_narrow; push_spot (); while (CBuf->narrow != NULL) { Mark *m; bob (); m = create_mark (0); m->next = save_narrow->beg; save_narrow->beg = m; eob (); m = create_mark (CBuf->narrow->is_region ? NARROW_REGION_MARK : 0); m->next = save_narrow->end; save_narrow->end = m; widen_buffer (CBuf); } restore_saved_narrow (); pop_spot (); } /*}}}*/ void jed_pop_narrow (void) /*{{{*/ { restore_saved_narrow (); jed_free_saved_narrow (CBuf); } /*}}}*/ #endif int jed_count_narrows (void) /*{{{*/ { int n = 0; Narrow_Type *nt = CBuf->narrow; while (nt != NULL) { n++; nt = nt->next; } return n; } /*}}}*/ unsigned int jed_count_lines_in_region (void) { Mark *m; unsigned int n0, n1; m = CBuf->marks; if (m == NULL) return 0; n0 = m->n - CBuf->nup; n1 = LineNum; if (n0 > n1) return 1 + (n0 - n1); return 1 + (n1 - n0); } jed-0.99-19/src/hooks.h0000644002657400265740000000242211311317447013555 0ustar davisdavis/* Copyright (c) 1992, 1998, 2000, 2005, 2006 John E. Davis * This file is part of JED editor library source. * * You may distribute this file under the terms the GNU General Public * License. See the file COPYING for more information. */ extern int (*X_Read_Hook) (void); extern int (*X_Input_Pending_Hook) (void); extern void (*X_Suspend_Hook)(void); extern int (*X_Argc_Argv_Hook)(int, char **); #if 0 extern int (*X_Init_SLang_Hook)(void); #endif extern int jed_add_init_slang_hook (int (*)(void)); extern int (*X_Init_Term_Hook) (void); extern void (*X_Reset_Term_Hook) (void); extern void (*X_Update_Open_Hook)(void); /* hooks called when starting */ extern void (*X_Update_Close_Hook)(void); /* and finishing update */ extern void (*X_Define_Keys_Hook) (SLKeyMap_List_Type *); extern int (*X_Set_Abort_Char_Hook) (unsigned char); #ifdef HAS_MOUSE extern int (*X_Open_Mouse_Hook)(void); extern void (*X_Close_Mouse_Hook)(void); extern int (*JMouse_Event_Hook)(void); extern void (*JMouse_Hide_Mouse_Hook)(int); #endif #define JED_HOOKS_RUN_ALL 1 #define JED_HOOKS_RUN_UNTIL_0 2 #define JED_HOOKS_RUN_UNTIL_NON_0 3 extern int jed_init_user_hooks (void); extern int jed_va_run_hooks (char *name, int method, unsigned int nargs, ...); extern int jed_hook_exists (char *); jed-0.99-19/src/gtkjed.h0000644002657400265740000000211211311317447013676 0ustar davisdavis#ifndef _GTK_JED_H_ #define _GTK_JED_H_ #include /* extern void jedGtkUpdateEdSize( int, int ); */ extern void jGtkCheckEdSize( int, int ); extern void jGtkWidenEd( int, int, int ); extern void jgtk_updMiniWinWidgetWinXRef( int ); extern void jgtk_updEdWidgetWinXRef( Window_Type *, int, int ); extern void jgtk_updOWEdWin( Window_Type *, int, int, int, int ); extern void jgtk_delEdWin( Window_Type *, Window_Type *, int, int, int, int, int ); extern void jgtk_splitEdWin( Window_Type *, Window_Type *, int, int, int, int, int ); extern void jgtk_createTopEdWin( Window_Type *, int, int, int, int, int ); extern int jgtk_createEditorMiniWin( Window_Type * ); extern void updateScrollbar( Window_Type * ); extern void jGtkSetWinSizes(void); extern void jGtkSetWinSizes(void); extern void jgtk_initToolbarArray(void); extern void jgtk_initMenubarStruct(void); extern int jgtk_createKeyEvents (char *); extern void jGtkSetFocus(void); extern void jGtkAttachMenubar( GtkWidget *mb ); extern void jGtkAddToolbar(GtkWidget *tb, int where); #endif jed-0.99-19/src/mouse.c0000644002657400265740000002773711311317447013575 0ustar davisdavis/* -*- mode: C; mode: fold; -*- */ /* Copyright (c) 1992, 1998, 2000, 2002, 2003, 2004, 2005, 2006 John E. Davis * This file is part of JED editor library source. * * You may distribute this file under the terms the GNU General Public * License. See the file COPYING for more information. */ #include "config.h" #include "jed-feat.h" /*{{{ Include Files */ #include #include #include #ifdef HAS_MOUSE #include "jdmacros.h" #include "buffer.h" #include "sysdep.h" #include "keymap.h" #include "misc.h" #include "paste.h" #include "screen.h" #include "ledit.h" #include "ins.h" #include "display.h" #include "hooks.h" /*}}}*/ int (*JMouse_Event_Hook)(void); void (*JMouse_Hide_Mouse_Hook) (int); /*{{{ Static Global Variables */ static SLang_Name_Type *Jed_Default_Mouse_Down_Hook; static SLang_Name_Type *Jed_Mouse_Status_Down_Hook; static SLang_Name_Type *Jed_Default_Mouse_Up_Hook; static SLang_Name_Type *Jed_Mouse_Status_Up_Hook; static SLang_Name_Type *Jed_Default_Mouse_Drag_Hook; static SLang_Name_Type *Jed_Mouse_Status_Drag_Hook; #if JED_HAS_MULTICLICK static SLang_Name_Type *Jed_Mouse_Status_2Click_Hook; static SLang_Name_Type *Jed_Mouse_Status_3Click_Hook; static SLang_Name_Type *Jed_Default_Mouse_2Click_Hook; static SLang_Name_Type *Jed_Default_Mouse_3Click_Hook; #endif static Window_Type *Use_This_Window; static Window_Type *Save_Window; static unsigned int Down_Mask; #ifdef IBMPC_SYSTEM # define JED_MOUSE_MAX_QUEUE_SIZE 8 #else # define JED_MOUSE_MAX_QUEUE_SIZE 64 #endif static JMouse_Type Mouse_Queue [JED_MOUSE_MAX_QUEUE_SIZE]; static JMouse_Type Current_Event; static int Mouse_Queue_Hint; static unsigned char Mouse_Button_Map [6] = { JMOUSE_BUTTON_1, JMOUSE_BUTTON_2, JMOUSE_BUTTON_3, JMOUSE_BUTTON_4, JMOUSE_BUTTON_5, JMOUSE_BUTTON_6 }; /*}}}*/ #ifndef USE_GPM_MOUSE # if defined(__MSDOS__) # if !defined(MSWINDOWS) # include "pcmouse.c" # endif # else # ifdef __os2__ # include "os2mouse.c" # else int (*X_Open_Mouse_Hook)(void); void (*X_Close_Mouse_Hook)(void); # endif /* os2 */ # endif /* ibmpc */ #endif /* NOT USE_GPM_MOUSE */ #if JED_HAS_MENUS static int Hack_Hack = 1; static Window_Type *Non_Existent_Menu_Window = (Window_Type *)&Hack_Hack; #endif #define BUFFER_STATUS_LINE 1 #define MENU_BAR_STATUS 2 /* returns button number from map */ static unsigned char m2b (int m) { switch (m) { default: case 0x01: return 0; case 0x02: return 1; case 0x04: return 2; case 0x08: return 3; case 0x10: return 4; case 0x20: return 5; } } /* *ap and *bp must have one of values in set (1, 2, 4, 8, 16, 32, 64). */ void jed_map_mouse_buttons (int *ap, int *bp) /*{{{*/ { unsigned char a, b; a = m2b (*ap); b = m2b (*bp); if ((a > 5) || (b > 5)) return; Mouse_Button_Map [a] = b << 1; } /*}}}*/ int jed_mouse_add_event (JMouse_Type *ev) /*{{{*/ { int save = Mouse_Queue_Hint; /* Search the queue looking for an empty slot. */ while (Mouse_Queue_Hint < JED_MOUSE_MAX_QUEUE_SIZE) { if (Mouse_Queue[Mouse_Queue_Hint].type == 0) { Mouse_Queue [Mouse_Queue_Hint] = *ev; return Mouse_Queue_Hint; } Mouse_Queue_Hint++; } Mouse_Queue_Hint = save; while (Mouse_Queue_Hint > 0) { Mouse_Queue_Hint--; if (Mouse_Queue[Mouse_Queue_Hint].type == 0) { Mouse_Queue [Mouse_Queue_Hint] = *ev; return Mouse_Queue_Hint; } } if (Input_Buffer_Len == 0) { jed_flush_mouse_queue (); Mouse_Queue [0] = *ev; return 0; } return -1; } /*}}}*/ static JMouse_Type *get_mouse_event (unsigned int *type) /*{{{*/ { int queue_pos; JMouse_Type *jm; /* Keyboard input should be ready. If it is not, get out. */ if (0 == input_pending (&Number_Zero)) return NULL; queue_pos = jed_getkey (); if ((queue_pos >= JED_MOUSE_MAX_QUEUE_SIZE) || (queue_pos < 0)) return NULL; jm = Mouse_Queue + queue_pos; /* 1, 2, 4, 8,..., 32 --> Mouse_Button_Map of 0, 1, 2, ... 5 */ jm->button = Mouse_Button_Map [m2b(jm->button)]; *type = jm->type; jm->type = 0; Mouse_Queue_Hint = queue_pos; return jm; } /*}}}*/ void jed_mouse_get_event_info (void) /*{{{*/ { SLang_push_integer (Current_Event.x); SLang_push_integer (Current_Event.y); SLang_push_integer (Current_Event.state); } /*}}}*/ void jed_flush_mouse_queue (void) /*{{{*/ { unsigned int i; for (i = 0; i < JED_MOUSE_MAX_QUEUE_SIZE; i++) Mouse_Queue[i].type = 0; Mouse_Queue_Hint = 0; } /*}}}*/ static int window_exists (Window_Type *win) /*{{{*/ { Window_Type *w; w = JWindow; do { if (w == win) return 1; w = w->next; } while (w != JWindow); return 0; } /*}}}*/ static int switch_to_event_window (int x, int y, int *linep, int *colp, int *status) /*{{{*/ { Window_Type *w; int delta_y; static int last_status; *status = 0; if (Use_This_Window != NULL) { #if JED_HAS_MENUS if (Use_This_Window == Non_Existent_Menu_Window) { *status = last_status = MENU_BAR_STATUS; *colp = x; *linep = y; return 0; } #endif if (0 == window_exists (Use_This_Window)) { last_status = 0; return -1; } *status = last_status; } else { #if JED_HAS_MENUS if (Jed_Menus_Active || ((y == 1) && (Top_Window_SY != 0))) { Use_This_Window = Non_Existent_Menu_Window; *colp = x; *linep = y; *status = last_status = MENU_BAR_STATUS; return 0; } #endif w = JWindow; do { int sy, bot; sy = w->sy; bot = sy + w->rows + 1; if ((y >= sy) && (y < bot)) { Use_This_Window = w; break; } if (y == bot) { Use_This_Window = w; *status = BUFFER_STATUS_LINE; break; } w = w->next; } while (w != JWindow); } if (Use_This_Window == NULL) { last_status = 0; return -1; } while (JWindow != Use_This_Window) other_window (); last_status = *status; if (last_status) { *colp = x; return 0; } /* What line does y correspond ??? */ delta_y = y - (Use_This_Window->sy + window_line ()); y = LineNum; #if JED_HAS_LINE_ATTRIBUTES if (delta_y == 0) { Line *l = CLine; while ((l != NULL) && (l->flags & JED_LINE_HIDDEN)) { y--; l = l->prev; } } else if (delta_y > 0) { Line *l = CLine; while (delta_y && (l != NULL)) { if (0 == (l->flags & JED_LINE_HIDDEN)) delta_y--; l = l->next; y++; } while ((l != NULL) && (l->flags & JED_LINE_HIDDEN)) { l = l->next; y++; } } else if (delta_y < 0) { Line *l = CLine; while (delta_y && (l != NULL)) { if (0 == (l->flags & JED_LINE_HIDDEN)) delta_y++; l = l->prev; y--; } while ((l != NULL) && (l->flags & JED_LINE_HIDDEN)) { l = l->prev; y--; } } #endif *linep = y + delta_y; *colp = JWindow->hscroll_column + x - 1; return 0; } /*}}}*/ static int do_function (SLang_Name_Type *fun, int line, int col, int button, int shift) /*{{{*/ { int ret; if ((-1 == SLang_start_arg_list ()) || (-1 == SLang_push_integer (line)) || (-1 == SLang_push_integer (col)) || (-1 == SLang_push_integer (button)) || (-1 == SLang_push_integer (shift)) || (-1 == SLang_end_arg_list ())) return 1; if ((-1 == SLexecute_function (fun)) || (-1 == SLang_pop_integer (&ret))) ret = 1; return ret; } /*}}}*/ static void switch_to_window (Window_Type *w) /*{{{*/ { if (window_exists (w)) { while (JWindow != w) other_window (); } } /*}}}*/ static int do_mouse_cmd (JMouse_Type *jmouse, unsigned int type) /*{{{*/ { int button, shift; int linenum = -1, column, is_status; int ret; SLang_Name_Type *fun, *default_fun; Jed_Buffer_Hook_Type *h = CBuf->buffer_hooks; button = jmouse->button; /* Consistency check */ if (type == JMOUSE_DOWN) { if (Down_Mask & button) { Down_Mask = 0; return 0; } Save_Window = JWindow; } else if ((0 == (Down_Mask & button)) && (type != JMOUSE_DOUBLE_CLICK) && (type != JMOUSE_TRIPLE_CLICK)) { Down_Mask = 0; return 0; } if (Down_Mask == 0) Use_This_Window = NULL; if (-1 == switch_to_event_window (jmouse->x, jmouse->y, &linenum, &column, &is_status)) { Down_Mask = 0; Use_This_Window = NULL; return 0; } default_fun = NULL; fun = NULL; switch (type) { case JMOUSE_DRAG: if (is_status) fun = Jed_Mouse_Status_Drag_Hook; else { if (h != NULL) fun = h->mouse_drag_hook; default_fun = Jed_Default_Mouse_Drag_Hook; } break; #if JED_HAS_MULTICLICK case JMOUSE_DOUBLE_CLICK: if (is_status) fun = Jed_Mouse_Status_2Click_Hook; else { if (h != NULL) fun = h->mouse_2click_hook; default_fun = Jed_Default_Mouse_2Click_Hook; } break; case JMOUSE_TRIPLE_CLICK: if (is_status) fun = Jed_Mouse_Status_3Click_Hook; else { if (h != NULL) fun = h->mouse_3click_hook; default_fun = Jed_Default_Mouse_3Click_Hook; } break; #endif case JMOUSE_DOWN: Down_Mask |= button; if (is_status) fun = Jed_Mouse_Status_Down_Hook; else { if (h != NULL) fun = h->mouse_down_hook; default_fun = Jed_Default_Mouse_Down_Hook; } break; case JMOUSE_UP: Down_Mask &= ~button; if (is_status) fun = Jed_Mouse_Status_Up_Hook; else { if (h != NULL) fun = h->mouse_up_hook; default_fun = Jed_Default_Mouse_Up_Hook; } break; default: flush_input (); fun = NULL; } if (jmouse->state & JMOUSE_SHIFT) shift = 1; else if (jmouse->state & JMOUSE_CTRL) shift = 2; else shift = 0; #if JED_HAS_MENUS if (is_status == MENU_BAR_STATUS) return jed_menu_handle_mouse (type, column, linenum, button, shift); #endif ret = -1; if (fun != NULL) { ret = do_function (fun, linenum, column, button, shift); } if ((ret == -1) && (default_fun != NULL)) { ret = do_function (default_fun, linenum, column, button, shift); } if ((type == JMOUSE_UP) && (Down_Mask == 0) && (ret <= 0)) { switch_to_window (Save_Window); Save_Window = NULL; } return ret; } /*}}}*/ int jed_mouse_cmd (void) /*{{{*/ { unsigned int type; JMouse_Type *jmouse; if ((NULL == (jmouse = get_mouse_event (&type))) || (type == JMOUSE_IGNORE_EVENT)) return 0; Current_Event = *jmouse; #if JED_HAS_MULTICLICK if ((-1 == do_mouse_cmd (jmouse, type)) && ((type == JMOUSE_DOUBLE_CLICK) || (type == JMOUSE_TRIPLE_CLICK))) { /* Event multiclick event not handled so simulated click. */ (void) do_mouse_cmd (&Current_Event, JMOUSE_DOWN); (void) do_mouse_cmd (&Current_Event, JMOUSE_UP); } #else (void) do_mouse_cmd (jmouse, type); #endif return 1; } /*}}}*/ void jed_set_current_mouse_window (void) /*{{{*/ { switch_to_window (Save_Window); } /*}}}*/ void jed_set_default_mouse_hook (char *hook_name, char *function) /*{{{*/ { SLang_Name_Type *f; f = SLang_get_function (function); if (!strcmp ("mouse_drag", hook_name)) Jed_Default_Mouse_Drag_Hook = f; else if (!strcmp ("mouse_up", hook_name)) Jed_Default_Mouse_Up_Hook = f; else if (!strcmp ("mouse_down", hook_name)) Jed_Default_Mouse_Down_Hook = f; else if (!strcmp ("mouse_status_up", hook_name)) Jed_Mouse_Status_Up_Hook = f; else if (!strcmp ("mouse_status_down", hook_name)) Jed_Mouse_Status_Down_Hook = f; else if (!strcmp ("mouse_status_drag", hook_name)) Jed_Mouse_Status_Drag_Hook = f; else if (!strcmp ("mouse_status_drag", hook_name)) Jed_Mouse_Status_Drag_Hook = f; #if JED_HAS_MULTICLICK else if (!strcmp ("mouse_2click", hook_name)) Jed_Default_Mouse_2Click_Hook = f; else if (!strcmp ("mouse_3click", hook_name)) Jed_Default_Mouse_3Click_Hook = f; #endif } /*}}}*/ #endif /* HAS_MOUSE */ jed-0.99-19/src/sig.c0000644002657400265740000001107611311317447013214 0ustar davisdavis/* -*- mode: C; mode: fold; -*- */ /* Copyright (c) 1992, 1998, 2000, 2002, 2003, 2004, 2005, 2006 John E. Davis * This file is part of JED editor library source. * * You may distribute this file under the terms the GNU General Public * License. See the file COPYING for more information. */ /*{{{ Include Files */ #include "config.h" #include "jed-feat.h" #include #if defined(__unix__) || defined(VMS) #include #include #include "jdmacros.h" #ifdef HAVE_STDLIB_H # include #endif #ifdef HAVE_UNISTD_H # include #endif #include #if !defined(VMS) || (__VMS_VER >= 70000000) # include #endif #include "sig.h" #include "file.h" #include "sysdep.h" #include "misc.h" #include "screen.h" #include "cmds.h" #include "hooks.h" /*}}}*/ #ifdef SIGTSTP int Jed_Handle_SIGTSTP = 1; #endif #if !defined(VMS) || (__VMS_VER >= 70000000) static void sigwinch_handler (int sig) /*{{{*/ { sig = errno; Jed_Resize_Pending = 1; # ifdef SIGWINCH SLsignal_intr (SIGWINCH, sigwinch_handler); # endif errno = sig; } /*}}}*/ #endif static volatile int Signal_In_Progress = 0; #if !defined(VMS) || (__VMS_VER >= 70000000) /* Handle SIGHUP-like signals differently. The reason is that we might get * such a signal when messing with a linked list pointer, etc. We do not want * to exit at that point because the exit routines may need that pointer * intact. So, set a hook that should be called by the editor at a * convenient moment. */ static int Sig_Hup_Sig; static void hup_exit_jed (void) { char buf[64]; Jed_Sig_Exit_Fun = NULL; auto_save_all (); sprintf (buf, "Killed by signal %d.", Sig_Hup_Sig); exit_error (buf, 0); exit (1); } static void sig_hup_exit_jed (int sig) { if (Sig_Hup_Sig == 0) { Sig_Hup_Sig = sig; Jed_Sig_Exit_Fun = hup_exit_jed; } } static void sig_exit_jed(int sig) /*{{{*/ { char buf[48]; if (Signal_In_Progress) return; Signal_In_Progress = 1; SLsig_block_signals (); auto_save_all (); sprintf (buf, "Killed by signal %d.", sig); exit_error (buf, (sig == SIGSEGV) || (sig == SIGBUS)); exit (1); } /*}}}*/ /* a control-G puts us here */ static void my_interrupt(int sig) /*{{{*/ { sig = errno; SLKeyBoard_Quit = 1; if (Ignore_User_Abort == 0) SLang_set_error (SL_USER_BREAK); SLsignal_intr (SIGINT, my_interrupt); errno = sig; } /*}}}*/ # if defined( SIGTSTP ) || (defined( VMS) && ( __VMS_VER >= 70000000)) int Signal_Sys_Spawn_Flag = 0; /* This should only be called from outside disturbance */ void sig_sys_spawn_cmd(int sig) /*{{{*/ { sig = errno; Signal_Sys_Spawn_Flag = 1; SLsignal_intr (SIGTSTP, sig_sys_spawn_cmd); errno = sig; } /*}}}*/ # endif #endif /* NOT VMS */ #define CATCH_SIGTTIN 0 #if CATCH_SIGTTIN #ifdef SIGTTIN static void background_read (int sig) /*{{{*/ { sig = errno; if (Stdin_Is_TTY == 0) { if (Signal_In_Progress) return; Signal_In_Progress = 1; SLsig_block_signals (); exit_error ("Attempt to read from background-- exiting.", 0); exit (1); } sig_sys_spawn_cmd (0); errno = sig; } /*}}}*/ #endif #endif static void (*Old_Sigint_Handler)(int); static void (*Old_Sigtstp_Handler)(int); void jed_reset_signals (void) { SLsignal (SIGINT, Old_Sigint_Handler); #ifdef SIGTSTP SLsignal (SIGTSTP, Old_Sigtstp_Handler); #endif /* return 0; */ } void init_signals (void) /*{{{*/ { #if !defined(VMS) || (__VMS_VER >= 70000000) #ifdef SIGWINCH (void) SLsignal_intr(SIGWINCH, sigwinch_handler); #endif Old_Sigint_Handler = SLsignal_intr (SIGINT, my_interrupt); SLsignal (SIGHUP, sig_hup_exit_jed); SLsignal (SIGQUIT, sig_hup_exit_jed); SLsignal (SIGTERM, sig_hup_exit_jed); SLsignal (SIGILL, sig_exit_jed); #if 0 && defined(SIGTRAP) SLsignal (SIGTRAP, sig_exit_jed); #endif #if 0 SLsignal (SIGIOT, sig_exit_jed); /* used by abort */ #endif #ifdef SIGPIPE SLsignal_intr (SIGPIPE, SIG_IGN); #endif /* SIGNAL (SIGFPE, sig_exit_jed); */ #ifdef SIGBUS SLsignal (SIGBUS, sig_exit_jed); #endif #if 0 SLsignal (SIGSEGV, sig_exit_jed); #endif #ifdef SIGSYS SLsignal (SIGSYS, sig_exit_jed); #endif #ifdef SIGTSTP if (Jed_Handle_SIGTSTP) { Old_Sigtstp_Handler = SLsignal_intr (SIGTSTP, sig_sys_spawn_cmd); if (SIG_DFL != Old_Sigtstp_Handler) Jed_Suspension_Not_Allowed = 1; } #endif #if CATCH_SIGTTIN # ifdef SIGTTOU SLsignal_intr (SIGTTOU, background_read); # endif # ifdef SIGTTIN SLsignal_intr (SIGTTIN, background_read); # endif #endif #endif /* VMS */ } /*}}}*/ #endif /* __unix__ || VMS */ jed-0.99-19/src/gtkmenu.c0000644002657400265740000037726011311317447014116 0ustar davisdavis/* Drop-down menus (GTK) */ /* * This file is part of JED editor library source. * * You may always distribute this file under the terms the GNU General Public * License. See the file COPYING for more information. */ #define _BUILD_GTK_JED #include "config.h" #include "jed-feat.h" #include #if JED_HAS_MENUS # include # include # include # include # include "jdmacros.h" # include # include "buffer.h" # include "screen.h" # include "misc.h" # include "sysdep.h" # include "cmds.h" # include "menu.h" # include "colors.h" #include "gtkjed.h" # define GTK_HAS_TOOLTIPS 0 # if 0 static GHashTable *menuArray; /************************************************************************* * * Datastructure to manage GtkMenus and Toolbars * * For Menus: * * Settings for the Menubar: * parent = NULL * menuItem = menubar * subMenu = NULL * path = menu path * * Settings for the submenu: * parent = parent of type GtkJedMenuType * * menuItem = current menu item (item in current menu) * subMenu = the newly created submenu * path = menu path * * Settings for the menu item: * parent = parent of type GtkJedMenuType * * menuItem = current menu item (item in current menu) * subMenu = NULL * path = menu path * ************************************************************************/ typedef struct GtkJedMenuTypeStruct { struct GtkJedMenuTypeStruct *parent; GtkWidget *menuItem; GtkWidget *subMenu; char *path; } GtkJedMenuType; # endif /* static int toolbarInputSelected = 0; */ /* static int tbActive = 0; */ extern void gtkCreateTBCmd( char * ); extern void gtkSetBufferMenuBarCmd( char * ); extern void gtkInsertPopupMenuCmd( char *, char * ); extern void gtkAppendTBCmd( char *, char * ); extern void gtkInsertSeparatorCmd( char * ); extern void gtkAppendSeparatorCmd( char * ); extern void gtkMenuItemNew( char *, char *, int ); extern void gtkMenuDeleteItemCmd( char * ); extern void gtkMenuDeleteItemsCmd( char * ); extern void gtkSetObjectAvailableCmd( char * ); typedef struct _Menu_Node_Type { char *name; int type; # define MENU_NODE_FUN_SLANG 1 /* typedef struct {} Menu_SLang_Fun_Type; */ # define MENU_NODE_FUN_C 2 /* typedef struct {} Menu_C_Fun_Type; */ # define MENU_NODE_POPUP 3 /* typedef struct _Menu_Popup_Type {} Menu_Popup_Type; */ # define MENU_NODE_SEPARATOR 4 /* typedef struct _Menu_Node_Type {} Menu_Node_Type; */ # define MENU_NODE_MENUBAR 5 /* struct _Menu_Bar_Type {}; */ # define MENU_NODE_KEYSTRING 6 /* typedef struct {} Menu_Keystring_Fun_Type; */ # define MENU_NODE_TYPEDKEYS 7 /* typedef struct {} Menu_Keystring_Fun_Type; */ unsigned int flags; # define MENU_ACTIVE 1 # define MENU_SELECTION 2 # define MENU_ITEM_UNAVAILABLE 4 # define MENU_POPUP_PREPARED 8 # define JGTK_MENU_POPUP_PREPARED 16 GtkWidget *menuItem; GtkWidget *subMenu; } Menu_Node_Type; typedef struct _Menu_Popup_Type { char *name; int type; /* =MENU_NODE_POPUP 3 */ unsigned int flags; GtkWidget *menuItem; GtkWidget *subMenu; /* Private data */ /* These 5 must match Menu_Bar_Type */ Menu_Node_Type **subnodes; unsigned int num_subnodes; unsigned int max_subnodes; struct _Menu_Popup_Type *parent; unsigned int active_node; SLang_Name_Type *select_popup_callback; SLang_Name_Type *tweak_popup_callback; int column; /* meaningful when active */ int row; int max_row; int max_col; unsigned int min_width; int visible_node_offset; } Menu_Popup_Type; struct _Menu_Bar_Type { char *name; int type; /* =MENU_NODE_MENUBAR 5 */ unsigned int flags; GtkWidget *menuItem; /* gtk_menu_bar */ GtkWidget *subMenu; /* NULL */ /* Private data */ /* These 5 must match Menu_Popup_Type */ Menu_Node_Type **subnodes; unsigned int num_subnodes; unsigned int max_subnodes; struct _Menu_Popup_Type *parent; unsigned int active_node; SLang_Name_Type *init_callback; SLang_Name_Type *select_callback; /* Void select_callback (name) */ int *item_columns; /* locations of items on menu bar */ unsigned int num_refs; # define DEFAULT_MENU_PREFIX "F10 key ==> " char *prefix_string; struct _Menu_Bar_Type *next; }; typedef struct { char *name; int type; /* =MENU_NODE_FUN_SLANG 1 */ unsigned int flags; GtkWidget *menuItem; GtkWidget *subMenu; SLang_Name_Type *slang_fun; SLang_Any_Type *client_data; } Menu_SLang_Fun_Type; typedef struct { char *name; int type; /* =MENU_NODE_FUN_C 2 */ unsigned int flags; GtkWidget *menuItem; GtkWidget *subMenu; int (*c_fun)(void); } Menu_C_Fun_Type; typedef struct { char *name; int type; /* =MENU_NODE_KEYSTRING 6, =Menu_NODE_TYPEDKEYS 7 */ unsigned int flags; GtkWidget *menuItem; GtkWidget *subMenu; char *keystring; } Menu_Keystring_Fun_Type; /*******************************************************************************/ /***** creating Toolbars *******************************************************/ /*******************************************************************************/ extern void gtkCreateToolbarCmd( Menu_Bar_Type * ); extern void gtkAddBufferToolbarCmd( char * ); static void gtkToolbarStockItemNew( Menu_Popup_Type *, Menu_Node_Type *, char *, int ); static void gtkToolbarItemNew( Menu_Popup_Type *, Menu_Node_Type *, char *, int ); static void gtkToolbarAppendSeparatorCmd( Menu_Popup_Type *, Menu_Node_Type * ); static void gtkToolbarInsertSeparatorCmd( Menu_Popup_Type *, Menu_Node_Type *, int ); extern int createKeyEvents( char * ); static void jGtkInsertBufferToolbarCmd( char *, int * ); static int jGtkSelectTB(void); static int jGtkExecTB(void); static gboolean menuBarActivateCurrentCB( GtkWidget *, GdkEvent *, gpointer * ); int Jed_Menus_Active; static Menu_Bar_Type *Global_Menu_Bar; static Menu_Bar_Type *Menu_Bar_Root; static Menu_Bar_Type *Active_Menu_Bar; static Menu_Popup_Type *Active_Popup; static void free_menu_node (Menu_Node_Type *); static int select_menu_cmd (void); extern void execTBCmd( char * ); static int tbExecSlangFlag = 0; static Menu_Node_Type *actTBCmdNode; static int tbInputSelected = 0; static Menu_Popup_Type *activeTopSubmenu = NULL; static void jGtkCreateMenuBarCmd( Menu_Bar_Type * ); static void jGtkInsertPopupMenuCmd( Menu_Popup_Type *, int ); static void jGtkSimpleInsertPopupMenuCmd( Menu_Popup_Type *, int ); static void jGtkMenuItemNew( Menu_Popup_Type *, Menu_Node_Type *, int ); static void jGtkMenuKeystringItemNew( Menu_Popup_Type *, Menu_Node_Type *, int ); static void jGtkInsertSeparatorCmd( Menu_Popup_Type *, Menu_Node_Type *, int ); /* static void jGtkAppendSeparatorCmd( Menu_Node_Type * ); */ void toolbarCallback( GtkWidget *, gpointer ); # define TB_SEL_KEY_SEQ "\033[TB" # define TB_EXE_KEY_SEQ "\033[TX" static char tbExeKeySeq[] = "\x1B[TX"; /* = TB_EXE_KEY_SEQ */ static int tbExeKeyInx = 0; /************************************ * free_menu_popup_subnodes * * debug print: "Menu: %x\n", m * ************************************/ static void free_menu_popup_subnodes (Menu_Popup_Type *m) { Menu_Node_Type **l, **lmax; l = m->subnodes; lmax = l + m->num_subnodes; while (l < lmax) { free_menu_node (*l); l++; } SLfree ((char *) m->subnodes); m->subnodes = NULL; m->num_subnodes = 0; m->max_subnodes = 0; } /************************************ * free_menu_popup_private_data * * debug print: "Menu: %x\n", m * ************************************/ static void free_menu_popup_private_data (Menu_Popup_Type *m) { free_menu_popup_subnodes (m); # if SLANG_VERSION > 10400 SLang_free_function (m->select_popup_callback); SLang_free_function (m->tweak_popup_callback); m->select_popup_callback = NULL; m->tweak_popup_callback = NULL; # endif } /************************************ * free_menu_bar_private_data * * debug print: "Menu: %x\n", m * ************************************/ static void free_menu_bar_private_data (Menu_Bar_Type *m) { Menu_Node_Type **l, **lmax; if (m == Active_Menu_Bar) Active_Menu_Bar = NULL; if (m == Global_Menu_Bar) Global_Menu_Bar = NULL; if (m == Menu_Bar_Root) Menu_Bar_Root = m->next; else { Menu_Bar_Type *prev; prev = Menu_Bar_Root; while (prev->next != m) prev = prev->next; prev->next = m->next; } l = m->subnodes; lmax = l + m->num_subnodes; while (l < lmax) { free_menu_node (*l); l++; } SLfree ((char *) m->subnodes); SLfree ((char *) m->item_columns); SLang_free_slstring (m->prefix_string); # if SLANG_VERSION > 10400 SLang_free_function (m->init_callback); SLang_free_function (m->select_callback); # endif } /************************************ * free_keystring_private_data * * debug print: "Menu Key String Function: %x\n", m * ************************************/ static void free_keystring_private_data (Menu_Keystring_Fun_Type *m) { SLang_free_slstring (m->keystring); } /************************************ * free_slangfun_private_data * * debug print: "Menu: %x\n", m * ************************************/ static void free_slangfun_private_data (Menu_SLang_Fun_Type *m) { if (m->client_data != NULL) SLang_free_anytype (m->client_data); # if SLANG_VERSION > 10400 SLang_free_function (m->slang_fun); # endif } /************************************ * free_menu_node * * debug print: "Menu: %x, Name: |%s|\n", m, m->name * ************************************/ static void free_menu_node (Menu_Node_Type *m) { Menu_Bar_Type *b; if (m == NULL) return; switch (m->type) { case MENU_NODE_SEPARATOR: case MENU_NODE_FUN_C: break; case MENU_NODE_FUN_SLANG: free_slangfun_private_data ((Menu_SLang_Fun_Type *) m); break; case MENU_NODE_KEYSTRING: free_keystring_private_data ((Menu_Keystring_Fun_Type *) m); break; case MENU_NODE_MENUBAR: b = (Menu_Bar_Type *)m; if (b->num_refs > 1) { b->num_refs -= 1; return; } free_menu_bar_private_data ((Menu_Bar_Type *) m); break; case MENU_NODE_POPUP: free_menu_popup_private_data ((Menu_Popup_Type *) m); break; } /* Dbp1( "m->menuItem: %x\n", m->menuItem ); */ if ( m->menuItem ) gtk_widget_destroy( m->menuItem ); /* Dbp1( "m->subMenu: %x\n", m->subMenu ); */ if ( m->subMenu ) gtk_widget_destroy( m->subMenu ); SLang_free_slstring (m->name); SLfree ((char *) m); } /************************************ * create_menu_node * * debug print: "Name: %s, Node type: %d, Size of node: %d\n", name, node_type, sizeof_node * ************************************/ static Menu_Node_Type *create_menu_node (char *name, int node_type, unsigned int sizeof_node) { Menu_Node_Type *m; m = (Menu_Node_Type *) jed_malloc0 (sizeof_node); if (m == NULL) return NULL; m->type = node_type; m->menuItem = NULL; m->subMenu = NULL; /* m->flags = 0; */ if (NULL == (m->name = SLang_create_slstring (name))) { SLfree ((char *)m); return NULL; } return m; } /************************************ * create_menu_popup * * debug print: "Name: %s, Num items: %d\n", name, num_items * ************************************/ static Menu_Popup_Type * create_menu_popup (char *name, unsigned int num_items) { Menu_Popup_Type *m; m = (Menu_Popup_Type *) create_menu_node (name, MENU_NODE_POPUP, sizeof (Menu_Popup_Type)); if (m == NULL) return NULL; if (num_items == 0) num_items = 5; if (NULL == (m->subnodes = (Menu_Node_Type **)SLmalloc (num_items * sizeof (Menu_Node_Type *)))) { free_menu_node ((Menu_Node_Type *) m); return NULL; } m->max_subnodes = num_items; return m; } /************************************ * create_menu_bar * * debug print: "Name: %s, Num items: %d\n", name, num_items * ************************************/ static Menu_Bar_Type * create_menu_bar( char *name, unsigned int num_items ) { Menu_Bar_Type *m; char *prefix; m = ( Menu_Bar_Type * ) create_menu_node( name, MENU_NODE_MENUBAR, sizeof( Menu_Bar_Type ) ); if ( m == NULL ) return NULL; if ( num_items == 0 ) num_items = 5; if ((NULL == (m->subnodes = (Menu_Node_Type **)SLmalloc (num_items * sizeof (Menu_Node_Type *)))) || (NULL == (m->item_columns = (int *)jed_malloc0 (num_items * sizeof (int))))) { free_menu_node ((Menu_Node_Type *) m); return NULL; } m->max_subnodes = num_items; if (Menu_Bar_Root != NULL) m->next = Menu_Bar_Root; Menu_Bar_Root = m; m->num_refs = 1; prefix = DEFAULT_MENU_PREFIX; if ((Global_Menu_Bar != NULL) && (Global_Menu_Bar->prefix_string != NULL)) prefix = Global_Menu_Bar->prefix_string; prefix = SLang_create_slstring (prefix); if (prefix == NULL) { jed_delete_menu_bar (m); return NULL; } m->prefix_string = prefix; return m; } /************************************ * jed_delete_menu_bar * * debug print: "Menu Bar Type: %x\n", m * ************************************/ void jed_delete_menu_bar (Menu_Bar_Type *m) { if ( m == NULL ) return; free_menu_node ((Menu_Node_Type *)m); } /************************************ * menu_name_eqs * * debug print: "A: |%s|, B: |%s|, bMax: |%s|\n", a, b, bmax * ************************************/ static int menu_name_eqs( char *a, char *b, char *bmax ) { while (*a) { if ( ( b == bmax ) || ( *a != *b ) ) return 0; a++; b++; } return( b == bmax ); } /************************************ * menu_find_menu_bar * * debug print: "Name: |%s|, do error: %d\n", name, do_error * ************************************/ static Menu_Bar_Type *menu_find_menu_bar (char *name, int do_error) { Menu_Bar_Type *b; char *name_max; name_max = strchr (name, '.'); if (name_max == NULL) name_max = name + strlen (name); b = Menu_Bar_Root; while (b != NULL) { if (menu_name_eqs (b->name, name, name_max)) return b; b = b->next; } if (do_error) SLang_verror (SL_INTRINSIC_ERROR, "Unable to a find menu bar called %s", name); return NULL; } /************************************ * find_subnode * * debug print: "Menu popup type: %x, Name: |%s|\n", m, name * ************************************/ static Menu_Node_Type *find_subnode (Menu_Popup_Type *m, char *name) { Menu_Node_Type **l, **lmax; if (m == NULL) return NULL; l = m->subnodes; lmax = l + m->num_subnodes; while (l < lmax) { if (0 == strcmp (name, (*l)->name)) return *l; l++; } return NULL; } /************************************ * check_subnode_space * * debug print: "Menu: %x, Dn: %d\n", m, dn * ************************************/ static int check_subnode_space (Menu_Popup_Type *m, unsigned int dn) { Menu_Node_Type **subnodes; unsigned int num; if (m->num_subnodes + dn <= m->max_subnodes) return 0; num = m->max_subnodes + dn; subnodes = (Menu_Node_Type **)SLrealloc ((char *)m->subnodes, num * sizeof (Menu_Node_Type *)); if (subnodes == NULL) return -1; m->subnodes = subnodes; if (m->type == MENU_NODE_MENUBAR) { Menu_Bar_Type *b = (Menu_Bar_Type *)m; int *item_columns; unsigned int i; item_columns = (int *)SLrealloc ((char *)b->item_columns, num * sizeof(int)); if (item_columns == NULL) return -1; for (i = m->max_subnodes; i < num; i++) item_columns [i] = 0; b->item_columns = item_columns; } m->max_subnodes = num; return 0; } /************************************ * insert_node_to_popup * This function assumes that there is enough space to insert one item * * * debug print: "Menu popup type: %x, menu node type: %x, where: %d\n", p, m, where * ************************************/ static void insert_node_to_popup( Menu_Popup_Type *p, Menu_Node_Type *m, unsigned int where ) { unsigned int len; unsigned int n; n = p->num_subnodes; if (where > n) where = n; while (n > where) { p->subnodes[n] = p->subnodes[n-1]; n--; } p->subnodes[where] = m; p->num_subnodes += 1; /* p could be a menu-bar */ if (p->type != MENU_NODE_POPUP) return; len = strlen( m->name ); if ( len > p->min_width ) p->min_width = len; } /************************************ * insert_popup_menu * * debug print: "Menu popup type: %x, Name: |%s|, where: %d\n", m, name, where * ************************************/ static Menu_Popup_Type *insert_popup_menu (Menu_Popup_Type *m, char *name, int where) { Menu_Popup_Type *p; if (NULL != (p = (Menu_Popup_Type *)find_subnode (m, name))) return p; if (-1 == check_subnode_space (m, 1)) return NULL; p = create_menu_popup (name, 5); if (p == NULL) return NULL; p->parent = m; insert_node_to_popup (m, (Menu_Node_Type *)p, where); return p; } /************************************ * append_popup_menu * * debug print: "Menu: %x, Name: |%s|\n", m, name * ************************************/ static Menu_Popup_Type *append_popup_menu (Menu_Popup_Type *m, char *name) { return insert_popup_menu (m, name, m->num_subnodes); } /************************************ * insert_separator * * debug print: "Menu: %x, where: %d\n", m, where * ************************************/ static Menu_Node_Type *insert_separator (Menu_Popup_Type *m, int where) { Menu_Node_Type *l; if (-1 == check_subnode_space (m, 1)) return NULL; l = create_menu_node ("", MENU_NODE_SEPARATOR, sizeof (Menu_Node_Type)); if (l == NULL) return NULL; insert_node_to_popup (m, l, where); return l; } /************************************ * append_separator * * debug print: "Menu: %x\n", m * ************************************/ static Menu_Node_Type *append_separator (Menu_Popup_Type *m) { return insert_separator (m, m->num_subnodes); } /************************************ * insert_slang_fun_item * * debug print: "Menu: %x, Name: |%s|, Nt: %x, Cd: %x, Where: %d\n", m, name, nt, cd, where * ************************************/ static Menu_SLang_Fun_Type * insert_slang_fun_item( Menu_Popup_Type *m, char *name, SLang_Name_Type *nt, SLang_Any_Type *cd, int where) { Menu_SLang_Fun_Type *l; if (NULL != (l = (Menu_SLang_Fun_Type *)find_subnode (m, name))) { if (l->type != MENU_NODE_FUN_SLANG) return NULL; free_slangfun_private_data (l); l->slang_fun = nt; l->client_data = cd; return l; } if (-1 == check_subnode_space (m, 1)) return NULL; l = (Menu_SLang_Fun_Type *) create_menu_node (name, MENU_NODE_FUN_SLANG, sizeof (Menu_SLang_Fun_Type)); if (l == NULL) return NULL; l->slang_fun = nt; l->client_data = cd; insert_node_to_popup (m, (Menu_Node_Type *)l, where); return l; } /************************************ * append_slang_fun_item * * debug print: "Menu: %x, Name: |%s|, Nt: %x, Cd: %x\n", m, name, nt, cd * ************************************/ static Menu_SLang_Fun_Type *append_slang_fun_item (Menu_Popup_Type *m, char *name, SLang_Name_Type *nt, SLang_Any_Type *cd) { return insert_slang_fun_item (m, name, nt, cd, m->num_subnodes); } /************************************ * insert_keystring_item * * debug print: "Menu: %x, Name: |%s|, k: |%s|, Where: %d\n", m, name, k, where * ************************************/ static Menu_Keystring_Fun_Type * insert_keystring_item( Menu_Popup_Type *m, char *name, char *k, int where ) { Menu_Keystring_Fun_Type *l; if (NULL != (l = (Menu_Keystring_Fun_Type *)find_subnode (m, name))) { if (l->type != MENU_NODE_KEYSTRING) return NULL; if (NULL == (k = SLang_create_slstring (k))) return NULL; free_keystring_private_data (l); l->keystring = k; return l; } if (-1 == check_subnode_space (m, 1)) return NULL; l = (Menu_Keystring_Fun_Type *) create_menu_node (name, MENU_NODE_KEYSTRING, sizeof (Menu_Keystring_Fun_Type)); if (l == NULL) return NULL; if (NULL == (l->keystring = SLang_create_slstring (k))) { free_menu_node ((Menu_Node_Type *) l); return NULL; } /* Dbp( "l->keystring: |%s|\n", l->keystring ); */ insert_node_to_popup (m, (Menu_Node_Type *)l, where); return l; } /************************************ * append_keystring_item * * debug print: "Menu popup type: %x, Name: |%s|, k: |%s|\n", m, name, k * ************************************/ static Menu_Keystring_Fun_Type * append_keystring_item (Menu_Popup_Type *m, char *name, char *k) { return insert_keystring_item (m, name, k, m->num_subnodes); } /************************************ * insertSpecCmdItem ********************* * Currently no use of specCmd. Maybe for future use * * debug print: "Menu: %x, Name: %s, SpecCmd: %s, KeySeq: %s, Where: %d", m, name, specCmd, keySeq, where * ************************************/ static Menu_Keystring_Fun_Type * insertSpecCmdItem( Menu_Popup_Type *m, char *name, char *specCmd, char *keySeq, int where ) { Menu_Keystring_Fun_Type *l; char *buf; char *k; /* printf( "File: %s, Line: %d: insertSpecCmdItem\n", __FILE__, __LINE__ ); */ if (NULL != (l = (Menu_Keystring_Fun_Type *)find_subnode (m, name))) { /* printf( "File: %s, Line: %d: insertSpecCmdItem\n", __FILE__, __LINE__ ); */ if (l->type != MENU_NODE_TYPEDKEYS) return NULL; /* printf( "File: %s, Line: %d: insertSpecCmdItem\n", __FILE__, __LINE__ ); */ l->keystring = SLang_create_slstring( keySeq ); # if 0 Dbp( "buf: |%s|\n", buf ); /* printf( "File: %s, Line: %d: insertSpecCmdItem: Length: %d\n", __FILE__, __LINE__, *buf ); */ if ( NULL == ( k = SLmalloc( sizeof( ( *buf ) + 1 ) ) ) ) return NULL; strncpy( k, buf, *buf ); k[*buf] = '\0'; /* if (NULL == (k = SLang_create_slstring (k))) */ /* Return NULL; */ /* free_keystring_private_data (l); */ /* */ # endif l->keystring = k; return l; } /* printf( "File: %s, Line: %d: insertSpecCmdItem\n", __FILE__, __LINE__ ); */ if (-1 == check_subnode_space (m, 1)) return NULL; /* printf( "File: %s, Line: %d: insertSpecCmdItem\n", __FILE__, __LINE__ ); */ l = (Menu_Keystring_Fun_Type *) create_menu_node (name, MENU_NODE_TYPEDKEYS, sizeof (Menu_Keystring_Fun_Type)); /* printf( "File: %s, Line: %d: insertSpecCmdItem\n", __FILE__, __LINE__ ); */ if (l == NULL) return NULL; /* printf( "File: %s, Line: %d: insertSpecCmdItem\n", __FILE__, __LINE__ ); */ buf = SLang_process_keystring( keySeq ); /* printf( "File: %s, Line: %d: insertSpecCmdItem: Length: %d 1: |%x| 2: |%c|\n", __FILE__, __LINE__, *buf, *buf, buf[1] ); */ /* if (NULL == (l->keystring = SLang_create_slstring (k))) */ if ( NULL == ( k = SLmalloc( sizeof( ( *buf ) + 1 ) ) ) ) { free_menu_node ((Menu_Node_Type *) l); return NULL; } strncpy( k, buf, *buf ); k[(unsigned char)*buf] = '\0'; /* printf( "File: %s, Line: %d: insertSpecCmdItem: Node: %x, String: %x, 1: |%x| 2: |%x| 3: |%x|\n", */ /* __FILE__, __LINE__, l, k, *k, k[1], k[2] ); */ l->keystring = k; insert_node_to_popup (m, (Menu_Node_Type *)l, where); return l; /* Return( NULL ); */ } /************************************ * get_selected_menu_item * * debug print: "Menu: %x\n", p * ************************************/ static Menu_Node_Type *get_selected_menu_item (Menu_Popup_Type *p) { Menu_Node_Type *m; if (p == NULL) return NULL; /* Db; */ if (p->num_subnodes <= p->active_node) { /* Db; */ p->active_node = 0; return NULL; } /* Db; */ m = p->subnodes[p->active_node]; if (m->flags & MENU_ITEM_UNAVAILABLE) { /* Db; */ p->active_node = 0; return NULL; } /* Make sure this is selected. */ m->flags |= MENU_SELECTION; /* Db; */ return m; } /************************************ * unselect_active_node * * debug print: "Menu: %x\n", b * ************************************/ static int unselect_active_node (Menu_Popup_Type *b) { Menu_Node_Type *m; if (NULL == (m = get_selected_menu_item (b))) return -1; m->flags &= ~(MENU_SELECTION|MENU_ACTIVE); return 0; } /************************************ * select_next_active_node * * debug print: "Menu: %x, active: %d, flags: %d\n", b, active_node, flags * ************************************/ static int select_next_active_node (Menu_Popup_Type *b, unsigned int active_node, unsigned int flags) { int wrapped; unsigned int num_subnodes; if (b == NULL) return -1; num_subnodes = b->num_subnodes; if (num_subnodes == 0) { b->active_node = 0; return -1; } unselect_active_node (b); wrapped = 0; while (1) { Menu_Node_Type *node; active_node++; if (active_node >= num_subnodes) { active_node = 0; if (wrapped) return -1; wrapped = 1; } node = b->subnodes[active_node]; if ((node->type != MENU_NODE_SEPARATOR) && (0 == (node->flags & MENU_ITEM_UNAVAILABLE))) { node->flags |= MENU_SELECTION|flags; break; } } b->active_node = active_node; return 0; } /************************************ * select_prev_active_node * * debug print: "Menu %x, Active Node: %d, flags %d\n", b, active_node, flags * ************************************/ static int select_prev_active_node (Menu_Popup_Type *b, unsigned int active_node, unsigned int flags) { int wrapped; unsigned int num_subnodes; if (b == NULL) return -1; num_subnodes = b->num_subnodes; if (num_subnodes == 0) { b->active_node = 0; return -1; } unselect_active_node (b); wrapped = 0; while (1) { Menu_Node_Type *node; if (active_node == 0) { active_node = num_subnodes; if (wrapped) return -1; wrapped = 1; } active_node--; node = b->subnodes[active_node]; if ((node->type != MENU_NODE_SEPARATOR) && (0 == (node->flags & MENU_ITEM_UNAVAILABLE))) { node->flags |= MENU_SELECTION|flags; break; } } b->active_node = active_node; return 0; } /************************************ * set_node_selection * * debug print: "Menu %x, Menu-node: %x\n", p, m * ************************************/ static int set_node_selection (Menu_Popup_Type *p, Menu_Node_Type *m) { unsigned int i, imax; Menu_Node_Type **subnodes; if ((p == NULL) || (m == NULL) || (m->type == MENU_NODE_SEPARATOR) || (m->flags & MENU_ITEM_UNAVAILABLE)) return -1; subnodes = p->subnodes; imax = p->num_subnodes; for (i = 0; i < imax; i++) { if (subnodes[i] == m) { unselect_active_node (p); p->active_node = i; m->flags |= MENU_SELECTION; return 0; } } return -1; } /************************************ * get_active_node_flags * * debug print: "Menu: %x\n", p * ************************************/ static unsigned int get_active_node_flags (Menu_Popup_Type *p) { Menu_Node_Type *m; m = get_selected_menu_item (p); if (m == NULL) return 0; return m->flags; } /************************************ * menu_delete_node * * debug print: "Menu: %x, Menu node: %x\n", p, m * ************************************/ static int menu_delete_node (Menu_Popup_Type *p, Menu_Node_Type *m) { unsigned int i, imax; if ((p == NULL) || (m == NULL)) return -1; imax = p->num_subnodes; for (i = 0; i < imax; i++) { if (p->subnodes[i] != m) continue; if (i == p->active_node) p->active_node = 0; while (++i < imax) p->subnodes[i-1] = p->subnodes[i]; p->num_subnodes -= 1; (void) unselect_active_node (p); free_menu_node (m); return 0; } return -1; } /************************************ * menu_delete_nodes * * debug print: "Menu: %x\n", p * ************************************/ static int menu_delete_nodes (Menu_Popup_Type *p) { unsigned int i, imax; if (p == NULL) return -1; imax = p->num_subnodes; for (i = 0; i < imax; i++) free_menu_node (p->subnodes[i]); p->num_subnodes = 0; p->active_node = 0; return 0; } /************************************ * copy_menu * * debug print: "Menu dest: %x, Menu node src: %x\n", dest, src * ************************************/ static int copy_menu (Menu_Popup_Type *dest, Menu_Node_Type *src) { Menu_Node_Type **l, **lmax; Menu_Popup_Type *p; Menu_Node_Type *m; SLang_Any_Type *any; Menu_SLang_Fun_Type *sl; if (src == (Menu_Node_Type *)dest) { SLang_verror (SL_INTRINSIC_ERROR, "Unable to copy a menu onto itself"); return -1; } switch (src->type) { case MENU_NODE_POPUP: p = (Menu_Popup_Type *) src; l = p->subnodes; lmax = l + p->num_subnodes; p = append_popup_menu (dest, src->name); if (p == NULL) return -1; while (l < lmax) { if (-1 == copy_menu (p, *l)) { menu_delete_node (dest, (Menu_Node_Type *)p); return -1; } l++; } m = (Menu_Node_Type *)p; break; case MENU_NODE_SEPARATOR: m = append_separator (dest); break; case MENU_NODE_FUN_SLANG: sl = (Menu_SLang_Fun_Type *) src; /* Need a s-lang fun for this !!! */ if ((-1 == SLang_push_anytype (sl->client_data)) || (-1 == SLang_pop_anytype (&any))) return -1; m = (Menu_Node_Type *) append_slang_fun_item (dest, sl->name, sl->slang_fun, any); if (m == NULL) SLang_free_anytype (any); break; case MENU_NODE_KEYSTRING: m = (Menu_Node_Type *) append_keystring_item (dest, src->name, ((Menu_Keystring_Fun_Type *)src)->keystring); break; case MENU_NODE_MENUBAR: SLang_verror (SL_INTRINSIC_ERROR, "Unable to copy a menu-bar"); return -1; case MENU_NODE_FUN_C: default: SLang_verror (SL_APPLICATION_ERROR, "Menu Type %d not supported", src->type); return -1; } if (m == NULL) return -1; m->flags = src->flags; return 0; } /************************************ * gtkCopyMenu * * debug print: "Menu dest: %x: |%s|, Menu node src: %x: |%s|\n", dest, dest->name, src, src->name * ************************************/ static int gtkCopyMenu( Menu_Popup_Type *dest, Menu_Node_Type *src ) { int numItems; Menu_Node_Type **l, **lmax; Menu_Popup_Type *p; Menu_Node_Type *m; SLang_Any_Type *any; Menu_SLang_Fun_Type *sl; if (src == (Menu_Node_Type *)dest) { SLang_verror (SL_INTRINSIC_ERROR, "Unable to copy a menu onto itself"); return -1; } switch (src->type) { case MENU_NODE_POPUP: /* Db; */ p = (Menu_Popup_Type *) src; l = p->subnodes; lmax = l + p->num_subnodes; numItems = dest->num_subnodes; p = append_popup_menu (dest, src->name); if (p == NULL) return -1; jGtkInsertPopupMenuCmd( p, numItems ); while (l < lmax) { /* if (-1 == copy_menu (p, *l)) */ if (-1 == gtkCopyMenu (p, *l)) { menu_delete_node (dest, (Menu_Node_Type *)p); return -1; } l++; } m = (Menu_Node_Type *)p; break; case MENU_NODE_SEPARATOR: /* Db; */ m = append_separator (dest); if ( m ) jGtkInsertSeparatorCmd( dest, m, dest->num_subnodes - 1 ); break; case MENU_NODE_FUN_SLANG: /* Db; */ sl = (Menu_SLang_Fun_Type *) src; /* Need a s-lang fun for this !!! */ if ((-1 == SLang_push_anytype (sl->client_data)) || (-1 == SLang_pop_anytype (&any))) return -1; m = (Menu_Node_Type *) append_slang_fun_item (dest, sl->name, sl->slang_fun, any); /* jGtkMenuItemNew( dest, m, dest->num_subnodes - 1 ); */ if (m == NULL) SLang_free_anytype (any); else jGtkMenuItemNew( dest, m, dest->num_subnodes - 1 ); break; case MENU_NODE_KEYSTRING: /* Db; */ m = (Menu_Node_Type *) append_keystring_item (dest, src->name, ((Menu_Keystring_Fun_Type *)src)->keystring); if ( m ) jGtkMenuKeystringItemNew( dest, m, dest->num_subnodes - 1 ); break; case MENU_NODE_TYPEDKEYS: /* Db; */ SLang_verror (SL_INTRINSIC_ERROR, "Copy of Typed keys should not occur! Internal error."); return -1; case MENU_NODE_MENUBAR: /* Db; */ SLang_verror (SL_INTRINSIC_ERROR, "Unable to copy a menu-bar"); return -1; case MENU_NODE_FUN_C: default: /* Db; */ SLang_verror (SL_APPLICATION_ERROR, "Menu Type %d not supported", src->type); return -1; } if (m == NULL) return -1; m->flags = src->flags; return 0; } /* * SLsmg MenuBar interface */ /************************************ * simulate_hline * * debug print: "Line: %d\n", n * ************************************/ static void simulate_hline (unsigned int n) { while (n--) SLsmg_write_string ("-"); } /************************************ * simulate_box * * debug print: "r: %d, c: %d, dr: %d, dc: %d\n", r, c, dr, dc * ************************************/ static void simulate_box (int r, int c, unsigned int dr, unsigned int dc) { int rr, rmax; if ((dr < 1) || (dc < 2)) return; dr--; dc--; /* Dbp2( "--- r: %d c: %d ---------------------------\n", r, c ); */ SLsmg_gotorc (r, c); SLsmg_write_string ("+"); simulate_hline (dc-1); SLsmg_write_string ("+"); /* Dbp2( "--- r: %d c: %d ---------------------------\n", r + dr, c ); */ SLsmg_gotorc (r + dr, c); SLsmg_write_string ("+"); simulate_hline (dc-1); SLsmg_write_string ("+"); rmax = r + dr; for (rr = r + 1; rr < rmax; rr++) { /* Dbp2( "--- r: %d c: %d ---------------------------\n", rr, c ); */ SLsmg_gotorc (rr, c); SLsmg_write_string ("|"); /* Dbp2( "--- r: %d c: %d ---------------------------\n", rr, c + dc ); */ SLsmg_gotorc (rr, c + dc); SLsmg_write_string ("|"); } } /* I would prefer to use real up/down arrows but I cannot depend upon their * portability. */ /************************************ * draw_up_arrow * * debug print: "r: %d, c: %d\n", r, c * ************************************/ static void draw_up_arrow (int r, int c) { /* Dbp2( "--- r: %d c: %d ---------------------------\n", r, c ); */ SLsmg_gotorc (r, c); SLsmg_write_string ("(-)"); } /************************************ * draw_down_arrow * * debug print: "r: %d, c: %d\n", r, c * ************************************/ static void draw_down_arrow (int r, int c) { /* Dbp2( "--- r: %d c: %d ---------------------------\n", r, c ); */ SLsmg_gotorc (r, c); SLsmg_write_string ("(+)"); } /************************************ * draw_name * * debug print: "Name %s, color0: %d, color1: %d, field_width: %d\n", name, color0, color1, field_width * ************************************/ static void draw_name (char *name, int color0, int color1, unsigned int field_width) { char *s; unsigned int n; s = name; while (*s && (*s != '&')) s++; n = (unsigned int) (s - name); if (n) { SLsmg_set_color (color0); SLsmg_write_nchars (name, n); } if (*s != 0) { unsigned int dn; s++; SLsmg_set_color (color1); SLsmg_write_nchars (s, 1); n++; SLsmg_set_color (color0); if (*s != 0) { s++; dn = strlen (s); SLsmg_write_nchars (s, dn); n += dn; } } if (n < field_width) SLsmg_write_nstring ("", field_width - n); } /************************************ * draw_menu_bar * * debug print: "Menu bar: %x\n", b * ************************************/ static int draw_menu_bar (Menu_Bar_Type *b) { Menu_Node_Type **m; unsigned int i, imax; int active; /* Dbp2( "--- r: %d c: %d ---------------------------\n", 0, 0 ); */ SLsmg_gotorc (0, 0); SLsmg_set_color (JMENU_COLOR); SLsmg_write_string (b->prefix_string); m = b->subnodes; imax = b->num_subnodes; active = -1; for (i = 0; i < imax; i++) { Menu_Popup_Type *p; char *name; p = (Menu_Popup_Type *) m[i]; if (p->flags & MENU_ITEM_UNAVAILABLE) continue; b->item_columns[i] = SLsmg_get_column (); if (p->type == MENU_NODE_SEPARATOR) name = " "; else name = p->name; if (p->flags & MENU_SELECTION) { if (p->type == MENU_NODE_POPUP) active = i; draw_name (name, JMENU_SELECTION_COLOR, JMENU_SELECTED_CHAR_COLOR, 0); } else draw_name (name, JMENU_COLOR, JMENU_CHAR_COLOR, 0); SLsmg_set_color (JMENU_COLOR); SLsmg_write_string (" "); } SLsmg_set_color (JMENU_COLOR); SLsmg_erase_eol (); return active; } /************************************ * draw_keystring * * debug print: "Menu keystring fun type: %x, color0: %d, color1: %d, field_widht: %d\n", k, color0, color1, field_width * ************************************/ static int draw_keystring (Menu_Keystring_Fun_Type *k, int color0, int color1, unsigned int field_width) { int i; SLang_Key_Type *key, *key_root; FVOID_STAR fp; unsigned char type; char buf[3]; unsigned int best_len; char *best_keystring; SLang_Key_Type *best_key; char *name; draw_name (k->name, color0, color1, field_width); name = k->keystring; /* Now try to draw the binding */ if (NULL == (fp = (FVOID_STAR) SLang_find_key_function(name, CBuf->keymap))) type = SLKEY_F_INTERPRET; else type = SLKEY_F_INTRINSIC; best_keystring = NULL; best_len = 0xFFFF; best_key = NULL; key_root = CBuf->keymap->keymap; for (i = 0; i < 256; i++, key_root++) { # ifdef IBMPC_SYSTEM if ((i == 0) || (i == 0xE0)) continue; # endif key = key_root->next; if ((key == NULL) && (type == key_root->type)) { if (type == SLKEY_F_INTERPRET) { if (strcmp (name, key_root->f.s)) continue; } else if ((type != SLKEY_F_INTRINSIC) || (fp != key_root->f.f)) continue; buf[0] = i; buf[1] = 0; # ifndef IBMPC_SYSTEM if (i == 0) { buf[0] = '^'; buf[1] = '@'; buf[2] = 0; } # endif best_keystring = buf; break; } while (key != NULL) { char *s; SLang_Key_Type *this_key = key; key = key->next; if (this_key->type != type) continue; if (type == SLKEY_F_INTERPRET) { if (strcmp (name, this_key->f.s)) continue; } else if ((type != SLKEY_F_INTRINSIC) || (fp != this_key->f.f)) continue; s = SLang_make_keystring (this_key->str); if (s == NULL) continue; if (strlen (s) < best_len) { best_key = this_key; best_len = strlen (s); } } } if (best_keystring == NULL) { if (best_key == NULL) return 0; best_keystring = SLang_make_keystring (best_key->str); if (best_keystring == NULL) return 0; } best_len = strlen (best_keystring); if (best_len > 4) return 0; SLsmg_forward (-4); SLsmg_set_color (color0); SLsmg_write_nchars (best_keystring, best_len); return 0; } /************************************ * draw_popup_menu * * debug print: "Menu: %x, r: %d, c: %d\n", p, r, c * ************************************/ static int draw_popup_menu (Menu_Popup_Type *p, int r, int c) { int active_row, active_col; unsigned int dr, dc; Menu_Node_Type **l, **lmax; Menu_Popup_Type *p_active; Active_Popup = p; if (r == 0) r = 1; dr = p->num_subnodes + 2; dc = p->min_width + 5 + 4; /* allow room for keystring */ if (c + (int)dc >= Jed_Num_Screen_Cols) { if ((int)dc > Jed_Num_Screen_Cols) c = 0; else c = Jed_Num_Screen_Cols - (int)dc; } if (r + (int)dr >= Jed_Num_Screen_Rows) { if ((int)dr >= Jed_Num_Screen_Rows) { r = 1; dr = Jed_Num_Screen_Rows - 1; } else r = Jed_Num_Screen_Rows - (int)dr; } SLsmg_set_color_in_region (JMENU_SHADOW_COLOR, r + 1, c + 1, dr, dc); SLsmg_set_color (JMENU_POPUP_COLOR); /* SLsmg_fill_region (r, c, dr, dc, ' '); */ if (Jed_Simulate_Graphic_Chars) simulate_box (r, c, dr, dc); else SLsmg_draw_box (r, c, dr, dc); p->row = r; p->column = c; p->max_row = r + dr; p->max_col = c + dc; /* Make sure a selection is present */ (void) get_selected_menu_item (p); l = p->subnodes; lmax = l + p->num_subnodes; if (p->num_subnodes + 2 > dr) { unsigned int page; unsigned int nr = dr - 2; unsigned int col; col = c + dc - 4; page = p->active_node / nr; if (page) { l += page * nr; draw_up_arrow (r, col); } if (lmax > l + nr) { lmax = l + nr; draw_down_arrow (r + dr - 1, col); } else l = lmax - nr; } p->visible_node_offset = (int) (l - p->subnodes); c++; r++; p_active = NULL; active_row = r; active_col = c; dc -= 3; while (l < lmax) { Menu_Node_Type *m; int color0, color1; m = *l; /* Dbp2( "--- r: %d c: %d ---------------------------\n", r, c ); */ SLsmg_gotorc (r, c); color0 = JMENU_POPUP_COLOR; color1 = JMENU_CHAR_COLOR; if (m->flags & MENU_SELECTION) { active_row = r; active_col = c + dc; color0 = JMENU_SELECTION_COLOR; color1 = JMENU_SELECTED_CHAR_COLOR; } if ((m->flags & MENU_ACTIVE) && (m->type == MENU_NODE_POPUP)) { p_active = (Menu_Popup_Type *)m; p_active->row = active_row; p_active->column = active_col - dc/2; } SLsmg_set_color (color0); switch (m->type) { case MENU_NODE_SEPARATOR: SLsmg_write_nchars (" ", 1); if (Jed_Simulate_Graphic_Chars) simulate_hline (dc - 1); else SLsmg_draw_hline (dc-1); SLsmg_write_nchars (" ", 1); break; case MENU_NODE_POPUP: SLsmg_write_nchars (" ", 1); draw_name (m->name, color0, color1, dc); /* Dbp2( "--- r: %d c: %d ---------------------------\n", r, c + ( dc - 2 ) ); */ SLsmg_gotorc (r, c + (dc - 2)); SLsmg_write_nchars (">>>", 3); break; case MENU_NODE_KEYSTRING: SLsmg_write_nchars (" ", 1); draw_keystring ((Menu_Keystring_Fun_Type *)m, color0, color1, dc); break; default: SLsmg_write_nchars (" ", 1); draw_name (m->name, color0, color1, dc); break; } l++; r++; } if (p_active != NULL) return draw_popup_menu (p_active, p_active->row, p_active->column); /* Dbp2( "--- r: %d c: %d ---------------------------\n", active_row, active_col ); */ SLsmg_gotorc (active_row, active_col); return 0; } /************************************ * get_active_menubar * * debug print: "(void)\n" * ************************************/ static Menu_Bar_Type *get_active_menubar (void) { Menu_Bar_Type *b; /* Active_Popup = NULL; */ b = Active_Menu_Bar; if (b == NULL) { Buffer *buf = CBuf; if (IN_MINI_WINDOW) { if (NULL == (buf = jed_get_mini_action_buffer ())) return NULL; } if (NULL == (b = buf->menubar)) b = Global_Menu_Bar; if (b == NULL) return NULL; } /* Active_Popup = (Menu_Popup_Type *) b; */ return b; } /************************************ * jed_redraw_menus * * debug print: "(void)\n" * ************************************/ int jed_redraw_menus (void) { Menu_Popup_Type *p; Menu_Bar_Type *b; int active; return 0; # if 0 if (NULL == (b = CBuf->menubar)) b = Global_Menu_Bar; # else b = get_active_menubar (); # endif Active_Popup = (Menu_Popup_Type *) b; if (b == NULL) { /* Dbp2( "--- r: %d c: %d ---------------------------\n", 0, 0 ); */ SLsmg_gotorc (0, 0); SLsmg_set_color (0); SLsmg_erase_eol (); return 0; } active = draw_menu_bar (b); if (active == -1) return 0; touch_screen (); p = (Menu_Popup_Type *)b->subnodes[active]; if (0 == (p->flags & MENU_ACTIVE)) { /* Dbp2( "--- r: %d c: %d ---------------------------\n", 0, b->item_columns[active] ); */ SLsmg_gotorc (0, b->item_columns[active]); return 1; } draw_popup_menu (p, 0, b->item_columns[active]); return 1; } /* Keyboard Interface */ /************************************ * find_active_popup * * debug print: "(void)\n" * ************************************/ static int find_active_popup (void) { Menu_Popup_Type *p; if (Active_Menu_Bar == NULL) return -1; p = (Menu_Popup_Type *) Active_Menu_Bar; while (1) { Active_Popup = p; p = (Menu_Popup_Type *) get_selected_menu_item (p); if ((p == NULL) || (p->type != MENU_NODE_POPUP)) return 0; if (0 == (p->flags & MENU_ACTIVE)) return 0; if (0 == (p->flags & MENU_POPUP_PREPARED)) return select_menu_cmd (); } } /************************************ * next_menubar_cmd * * debug print: "(void)\n" * ************************************/ static int next_menubar_cmd (void) { unsigned int flags; Menu_Popup_Type *p; if (NULL == (p = (Menu_Popup_Type *) Active_Menu_Bar)) return -1; flags = get_active_node_flags (p) & MENU_ACTIVE; /* (void) unselect_active_node ((Menu_Popup_Type *)Active_Menu_Bar); */ (void) select_next_active_node (p, p->active_node, flags); (void) find_active_popup (); return 1; } /************************************ * prev_menubar_cmd * * debug print: "(void)\n" * ************************************/ static int prev_menubar_cmd (void) { unsigned int flags; Menu_Popup_Type *p; if (NULL == (p = (Menu_Popup_Type *) Active_Menu_Bar)) return -1; flags = get_active_node_flags (p) & MENU_ACTIVE; /* (void) unselect_active_node ((Menu_Popup_Type *)Active_Menu_Bar); */ (void) select_prev_active_node (p, p->active_node, flags); (void) find_active_popup (); return 1; } /************************************ * jed_exit_menu_bar * * debug print: "(void)\n" * ************************************/ int jed_exit_menu_bar (void) { while (Active_Popup != NULL) { unselect_active_node (Active_Popup); Active_Popup->active_node = 0; Active_Popup->flags &= ~MENU_POPUP_PREPARED; Active_Popup = Active_Popup->parent; } Active_Menu_Bar = NULL; /* Db; */ /* Dbp1( "################################################################\n", 1 ); */ Jed_Menus_Active = 0; return 1; } /************************************ * down_menu_cmd * * debug print: "(void)\n" * ************************************/ static int down_menu_cmd (void) { if (Active_Popup == NULL) return -1; /* unselect_active_node (Active_Popup); */ select_next_active_node (Active_Popup, Active_Popup->active_node, 0); return 1; } /************************************ * up_menu_cmd * * debug print: "(void)\n" * ************************************/ static int up_menu_cmd (void) { if (Active_Popup == NULL) return -1; /* unselect_active_node (Active_Popup); */ select_prev_active_node (Active_Popup, Active_Popup->active_node, 0); return 1; } /************************************ * pgup_menu_cmd * * debug print: "(void)\n" * ************************************/ static int pgup_menu_cmd (void) { if (Active_Popup == NULL) return -1; select_next_active_node (Active_Popup, Active_Popup->num_subnodes, 0); return 1; } /************************************ * pgdn_menu_cmd * * debug print: "(void)\n" * ************************************/ static int pgdn_menu_cmd (void) { if (Active_Popup == NULL) return -1; select_prev_active_node (Active_Popup, 0, 0); return 1; } /************************************ * execute_keystring * * debug print: "Key string: %s\n", s * ************************************/ static int execute_keystring (char *s) { int (*f)(void); /* printf( "File: %s, Line: %d: exec keystring keymap: %x\n", __FILE__, __LINE__, CBuf->keymap ); */ if (NULL != (f = (int (*)(void)) (SLang_find_key_function(s, CBuf->keymap)))) { /* printf( "File: %s, Line: %d: exec keystring function: %x\n", __FILE__, __LINE__, f ); */ return (*f) (); } /* Dbp( "Function: |%s|\n", s ); */ if ( ( *s == '.' ) || !SLang_execute_function( s ) ) SLang_load_string(s); /* printf( "File: %s, Line: %d exec keystring load string\n", __FILE__, __LINE__ ); */ return 1; } /************************************ * get_full_popup_name * * debug print: "Menu: %x\n", p * ************************************/ static char *get_full_popup_name (Menu_Popup_Type *p) { Menu_Popup_Type *parent; unsigned int len; char *name; char *s; len = strlen (p->name); parent = p->parent; while (parent != NULL) { len += 1 + strlen (parent->name); parent = parent->parent; } name = SLmalloc (len + 1); if (name == NULL) return NULL; s = (name + len) - strlen (p->name); strcpy (s, p->name); parent = p->parent; while (parent != NULL) { s--; *s = '.'; len = strlen (parent->name); s -= len; strncpy (s, parent->name, len); parent = parent->parent; } return name; } /************************************ * run_popup_callback * * debug print: "Menu: %x, Name: %x\n", p, cb * ************************************/ static int run_popup_callback (Menu_Popup_Type *p, SLang_Name_Type *cb) { char *name; if (NULL == (name = get_full_popup_name (p))) return -1; if (-1 == SLang_push_string (name)) { SLfree (name); return -1; } SLfree (name); if (0 != SLexecute_function (cb)) return -1; return 0; } /************************************ * prepare_popup * * debug print: "Menu: %x\n", p * ************************************/ static int prepare_popup (Menu_Popup_Type *p) { SLang_Name_Type *cb; if (NULL != (cb = p->select_popup_callback)) { free_menu_popup_subnodes (p); if (-1 == run_popup_callback (p, cb)) return -1; } if (NULL != (cb = p->tweak_popup_callback)) { if (-1 == run_popup_callback (p, cb)) return -1; } p->flags |= MENU_POPUP_PREPARED; return 0; } /************************************ * jGtkPreparePopup * * debug print: "p: %x, cb: %x\n", p, cb * ************************************/ static int jGtkPreparePopup( Menu_Popup_Type *p, SLang_Name_Type *cb ) { /* SLang_Name_Type *cb; */ if ( cb ) { free_menu_popup_subnodes( p ); if ( -1 == run_popup_callback( p, cb ) ) return -1; } if (NULL != (cb = p->tweak_popup_callback)) { if (-1 == run_popup_callback (p, cb)) return -1; } p->flags |= MENU_POPUP_PREPARED; return 0; } /************************************ * execMenuTbCmd * * debug print: "Menu: %x\n", m * ************************************/ static int execMenuTbCmd( Menu_Node_Type *m ) { Menu_Popup_Type *p; Menu_Popup_Type *mp = ( Menu_Popup_Type * ) m; Menu_C_Fun_Type *c; SLang_Name_Type *nt; char *str; if ( activeTopSubmenu ) { if ( m->type != MENU_NODE_POPUP ) { /* Dbp1( "Deselecting: %x\n", activeTopSubmenu->parent->subMenu ); */ gtk_menu_shell_deselect( ( GtkMenuShell * ) activeTopSubmenu->parent->subMenu ); activeTopSubmenu = NULL; } } /* printf( "File: %s, Line: %d\n", __FILE__, __LINE__ ); */ if (m == NULL) return -1; switch (m->type) { case MENU_NODE_POPUP: # if 0 m->flags |= MENU_ACTIVE; p = (Menu_Popup_Type *) m; # else /* Do it this way to avoid DEC C ansi-aliasing warning. */ p = (Menu_Popup_Type *) m; /* p->flags |= MENU_ACTIVE; */ # endif if (-1 == prepare_popup (p)) return -1; Active_Popup = p; /* select_next_active_node (p, p->num_subnodes, 0); */ /* Dbp1( "Activate: %x\n", m ); */ /****/ gtk_menu_shell_select_item( ( GtkMenuShell * ) mp->parent->subMenu, p->menuItem ); if ( !activeTopSubmenu ) activeTopSubmenu = mp; /*****/ /******* gtk_menu_shell_select_first( ( GtkMenuShell * ) mp->parent->subMenu, 1 ); *******/ # if 0 gtk_menu_popup( ( GtkMenu * ) mp->subMenu, NULL, NULL, /* mp->parent->subMenu, */ /* mp->parent->menuItem, */ NULL, NULL, 0, gtk_get_current_event_time() ); # endif /************* gtk_menu_shell_activate_item( ( GtkMenuShell * ) mp->parent->subMenu, p->menuItem, 1 ); *********/ return 1; case MENU_NODE_FUN_SLANG: /* Dbp( "MENU_NODE_FUN_SLANG: %d\n", 1 ); */ nt = ((Menu_SLang_Fun_Type *) m)->slang_fun; /* jed_exit_menu_bar (); */ if (nt == NULL) return -1; if ((-1 == SLang_start_arg_list ()) || (-1 == SLang_push_anytype (((Menu_SLang_Fun_Type*)m)->client_data)) || (-1 == SLang_end_arg_list ())) return -1; /* Dbp( "SLexecute_functions: |%x|\n", nt ); */ return SLexecute_function (nt); case MENU_NODE_KEYSTRING: /* printf( "File: %s, Line: %d\n", __FILE__, __LINE__ ); */ str = ((Menu_Keystring_Fun_Type *) m)->keystring; /* printf( "File: %s, Line: %d: String to execute: %s\n", __FILE__, __LINE__, str ); */ /* Grab a copy while it is still available */ if (NULL == SLang_create_slstring (str)) return -1; /* jed_exit_menu_bar (); */ /* Dbp( "execute_keystring: |%s|\n", str ); */ (void) execute_keystring (str); SLang_free_slstring (str); break; case MENU_NODE_FUN_C: /* Dbp( "MENU_NODE_FUN_C: %d\n", 1 ); */ c = (Menu_C_Fun_Type *) m; /* jed_exit_menu_bar (); */ if (c->c_fun != NULL) return -1; return c->c_fun (); case MENU_NODE_TYPEDKEYS: /* Dbp2( "m: %x keystring: %x\n", m, (( Menu_Keystring_Fun_Type * ) m)->keystring ); */ str = (( Menu_Keystring_Fun_Type * ) m)->keystring; return( jgtk_createKeyEvents( str ) ); } return 0; } static int execMenuTbCmdNode( Menu_Node_Type *m ) { /* Menu_Popup_Type *p; */ Menu_C_Fun_Type *c; SLang_Name_Type *nt; char *str; /* Dbp1( "m->name: |%s|\n", m->name ); */ /* printf( "File: %s, Line: %d\n", __FILE__, __LINE__ ); */ if (m == NULL) return -1; switch (m->type) { case MENU_NODE_POPUP: /* Dbp1( "Popup node type should not occur here: %x\n", m ); */ return( -1 ); # if 0 # if 0 m->flags |= MENU_ACTIVE; p = (Menu_Popup_Type *) m; # else /* Do it this way to avoid DEC C ansi-aliasing warning. */ p = (Menu_Popup_Type *) m; p->flags |= MENU_ACTIVE; # endif if (-1 == prepare_popup (p)) return -1; Active_Popup = p; select_next_active_node (p, p->num_subnodes, 0); return 1; # endif case MENU_NODE_FUN_SLANG: /* Dbp( "MENU_NODE_FUN_SLANG: %d\n", 1 ); */ nt = ((Menu_SLang_Fun_Type *) m)->slang_fun; /* jed_exit_menu_bar (); */ if (nt == NULL) return -1; if ((-1 == SLang_start_arg_list ()) || (-1 == SLang_push_anytype (((Menu_SLang_Fun_Type*)m)->client_data)) || (-1 == SLang_end_arg_list ())) return -1; /* Dbp( "SLexecute_functions: |%x|\n", nt ); */ return SLexecute_function (nt); case MENU_NODE_KEYSTRING: /* printf( "File: %s, Line: %d\n", __FILE__, __LINE__ ); */ str = ((Menu_Keystring_Fun_Type *) m)->keystring; /* printf( "File: %s, Line: %d: String to execute: %s\n", __FILE__, __LINE__, str ); */ /* Grab a copy while it is still available */ if (NULL == SLang_create_slstring (str)) return -1; /* jed_exit_menu_bar (); */ /* Dbp( "execute_keystring: |%s|\n", str ); */ (void) execute_keystring (str); SLang_free_slstring (str); break; case MENU_NODE_FUN_C: /* Dbp( "MENU_NODE_FUN_C: %d\n", 1 ); */ c = (Menu_C_Fun_Type *) m; /* jed_exit_menu_bar (); */ if (c->c_fun != NULL) return -1; return c->c_fun (); case MENU_NODE_TYPEDKEYS: /* Dbp2( "m: %x keystring: %x\n", m, (( Menu_Keystring_Fun_Type * ) m)->keystring ); */ str = (( Menu_Keystring_Fun_Type * ) m)->keystring; return( jgtk_createKeyEvents( str ) ); } return 0; } /************************************ * select_menu_cmd * * debug print: "(void)\n" * ************************************/ static int select_menu_cmd (void) { return( execMenuTbCmd( get_selected_menu_item( Active_Popup ) ) ); } /************************************ * back_menu_cmd * * debug print: "(void)\n" * ************************************/ static int back_menu_cmd (void) { if ((Active_Popup == NULL) || (Active_Popup == (Menu_Popup_Type *)Active_Menu_Bar) || (Active_Popup->parent == (Menu_Popup_Type *) Active_Menu_Bar)) return jed_exit_menu_bar (); Active_Popup->flags &= ~(MENU_ACTIVE|MENU_POPUP_PREPARED); Active_Popup = Active_Popup->parent; return 1; } /************************************ * find_subnode_via_char * * debug print: "Menu: %x, ch: %c\n", p, ch * ************************************/ static Menu_Node_Type *find_subnode_via_char (Menu_Popup_Type *p, char ch) { Menu_Node_Type **l, **lmax; unsigned int two; if (p == NULL) return NULL; two = 2; while (two) { l = p->subnodes; lmax = l + p->num_subnodes; while (l < lmax) { Menu_Node_Type *m; char *s; m = *l++; if (m->type == MENU_NODE_SEPARATOR) continue; if (m->flags & MENU_ITEM_UNAVAILABLE) continue; s = strchr (m->name, '&'); if (s == NULL) continue; if (s[1] == ch) return m; } ch = (char) CHANGE_CASE(ch); two--; } return NULL; } /************************************ * select_via_char_cmd * * debug print: "(void)\n" * ************************************/ static int select_via_char_cmd (void) { Menu_Node_Type *m; m = find_subnode_via_char (Active_Popup, (char) SLang_Last_Key_Char); if (m == NULL) return -1; set_node_selection (Active_Popup, m); return select_menu_cmd (); } static SLKeyMap_List_Type *Menu_Keymap; static SLKeymap_Function_Type Menu_Keymap_Functions [] = { {"next_menubar_menu", next_menubar_cmd}, {"prev_menubar_menu", prev_menubar_cmd}, {"exit_menubar", jed_exit_menu_bar}, {"next_menu_item", down_menu_cmd}, {"prev_menu_item", up_menu_cmd}, {"top_menu_item", pgup_menu_cmd}, {"bot_menu_item", pgdn_menu_cmd}, {"select_menu_item", select_menu_cmd}, {"back_menu", back_menu_cmd}, {NULL, NULL} }; # ifndef IBMPC_SYSTEM # ifdef HAS_MOUSE static int xterm_mouse_cmd (void); # endif # endif /************************************ * init_menu_keymap * * debug print: "(void)\n" * ************************************/ static int init_menu_keymap (void) { int ch; char simple[3]; if (NULL == (Menu_Keymap = SLang_create_keymap ("menu", NULL))) return -1; Menu_Keymap->functions = Menu_Keymap_Functions; simple[1] = 0; for (ch = 0; ch < 256; ch++) { simple[0] = (char) ch; SLkm_define_key (simple, (FVOID_STAR) select_via_char_cmd, Menu_Keymap); } simple [0] = 27; simple [2] = 0; for (ch = 'a'; ch <= 'z'; ch++) { simple [1] = (char) ch; SLkm_define_key (simple, (FVOID_STAR) select_via_char_cmd, Menu_Keymap); } SLkm_define_key (" ", (FVOID_STAR) back_menu_cmd, Menu_Keymap); SLkm_define_key ("^?", (FVOID_STAR) back_menu_cmd, Menu_Keymap); SLkm_define_key ("^H", (FVOID_STAR) back_menu_cmd, Menu_Keymap); SLkm_define_key ("^G", (FVOID_STAR) jed_exit_menu_bar, Menu_Keymap); SLkm_define_key ("^Z", (FVOID_STAR) sys_spawn_cmd, Menu_Keymap); SLkm_define_key ("^M", (FVOID_STAR) select_menu_cmd, Menu_Keymap); # ifndef IBMPC_SYSTEM SLkm_define_key ("\033[A", (FVOID_STAR) up_menu_cmd, Menu_Keymap); SLkm_define_key ("\033OA", (FVOID_STAR) up_menu_cmd, Menu_Keymap); SLkm_define_key ("\033[B", (FVOID_STAR) down_menu_cmd, Menu_Keymap); SLkm_define_key ("\033OB", (FVOID_STAR) down_menu_cmd, Menu_Keymap); SLkm_define_key ("\033[C", (FVOID_STAR) next_menubar_cmd, Menu_Keymap); SLkm_define_key ("\033OC", (FVOID_STAR) next_menubar_cmd, Menu_Keymap); SLkm_define_key ("\033[D", (FVOID_STAR) prev_menubar_cmd, Menu_Keymap); SLkm_define_key ("\033OD", (FVOID_STAR) prev_menubar_cmd, Menu_Keymap); SLkm_define_key ("\033[5~", (FVOID_STAR) pgup_menu_cmd, Menu_Keymap); SLkm_define_key ("\033[6~", (FVOID_STAR) pgdn_menu_cmd, Menu_Keymap); # ifdef __unix__ SLkm_define_key ("^(ku)", (FVOID_STAR) up_menu_cmd, Menu_Keymap); SLkm_define_key ("^(kd)", (FVOID_STAR) down_menu_cmd, Menu_Keymap); SLkm_define_key ("^(kr)", (FVOID_STAR) next_menubar_cmd, Menu_Keymap); SLkm_define_key ("^(kl)", (FVOID_STAR) prev_menubar_cmd, Menu_Keymap); SLkm_define_key ("^(kP)", (FVOID_STAR) pgup_menu_cmd, Menu_Keymap); SLkm_define_key ("^(kN)", (FVOID_STAR) pgdn_menu_cmd, Menu_Keymap); # endif # ifdef HAS_MOUSE SLkm_define_key ("\033[M", (FVOID_STAR) xterm_mouse_cmd, Menu_Keymap); # endif # else /* IBMPC_SYSTEM */ # include "doskeys.h" SLkm_define_key (PC_UP, (FVOID_STAR) up_menu_cmd, Menu_Keymap); SLkm_define_key (PC_UP1, (FVOID_STAR) up_menu_cmd, Menu_Keymap); SLkm_define_key (PC_DN, (FVOID_STAR) down_menu_cmd, Menu_Keymap); SLkm_define_key (PC_DN1, (FVOID_STAR) down_menu_cmd, Menu_Keymap); SLkm_define_key (PC_RT, (FVOID_STAR) next_menubar_cmd, Menu_Keymap); SLkm_define_key (PC_RT1, (FVOID_STAR) next_menubar_cmd, Menu_Keymap); SLkm_define_key (PC_LT, (FVOID_STAR) prev_menubar_cmd, Menu_Keymap); SLkm_define_key (PC_LT1, (FVOID_STAR) prev_menubar_cmd, Menu_Keymap); SLkm_define_key (PC_PGUP, (FVOID_STAR) pgup_menu_cmd, Menu_Keymap); SLkm_define_key (PC_PGUP1, (FVOID_STAR) pgup_menu_cmd, Menu_Keymap); SLkm_define_key (PC_PGDN, (FVOID_STAR) pgdn_menu_cmd, Menu_Keymap); SLkm_define_key (PC_PGDN1, (FVOID_STAR) pgdn_menu_cmd, Menu_Keymap); # endif # ifdef HAS_MOUSE SLkm_define_key ("\033^@", (FVOID_STAR) jed_mouse_cmd, Menu_Keymap); # endif /* Toolbar callback key */ /* SLkm_define_key( TB_CMD_KEY_SEQ, (FVOID_STAR) jed_select_menu_bar, Global_Map ); */ SLkm_define_key( TB_SEL_KEY_SEQ, (FVOID_STAR) jGtkExecTB, Global_Map ); /* SLkm_define_key( TB_EXE_KEY_SEQ, (FVOID_STAR) jGtkExecTB, Menu_Keymap ); */ return 0; } /* key_interpret */ static int jGtkExecTB() { activeTopSubmenu = NULL; if ( actTBCmdNode ) { /* execTBCmd( actTBCmd->path ); */ execMenuTbCmdNode( actTBCmdNode ); actTBCmdNode = NULL; /* jed_redraw_screen( 1 ); */ /* update((Line *) NULL, 1, 0, 1); // File: screen.c */ SLang_restart( 1 ); touch_screen(); } /* Dbp1( "actTBCmdNode: %x\n", actTBCmdNode ); */ return( 0 ); } static int jGtkFeedTBKeySeq(void) { /* Dbp2( "Key: %d: |%c|\n", tbExeKeySeq[tbExeKeyInx], tbExeKeySeq[tbExeKeyInx] ); */ return( tbExeKeySeq[tbExeKeyInx++] ); } /************************************ * jed_menu_do_key * * debug print: "(void)\n" * ************************************/ SLang_Key_Type * jed_menu_do_key (void) { int ch; if ( tbInputSelected ) { /* Dbp1( "ActTBCmdNode: |%x|\n", actTBCmdNode ); */ /* tbExecSlangFlag = 1; */ tbInputSelected = 0; /* tbActive = 0; */ /* Db; */ /* Dbp1( "################################################################\n", 1 ); */ Jed_Menus_Active = 0; tbExeKeyInx = 0; /* Return SLang_do_key( Menu_Keymap, jed_getkey ); */ return SLang_do_key( Menu_Keymap, jGtkFeedTBKeySeq ); } else { if ( Executing_Keyboard_Macro || ( Read_This_Character != NULL ) ) return SLang_do_key( Menu_Keymap, jed_getkey ); ch = my_getkey(); if ( SLKeyBoard_Quit || SLang_get_error () ) { jed_exit_menu_bar(); return NULL; } if ( ch == 27 ) /* ESC */ { int tsecs = 2; if ( 0 == input_pending( &tsecs ) ) ch = 127; } ungetkey (&ch); return SLang_do_key( Menu_Keymap, jed_getkey ); } } /************************************ * exec_menubar_callback * * debug print: "Menu bar: %x, Name types: %x\n", b, ntp * ************************************/ static int exec_menubar_callback (Menu_Bar_Type *b, SLang_Name_Type **ntp) { SLang_Name_Type *nt; nt = *ntp; if (nt == NULL) return 0; if (SLang_get_error ()) return -1; if (-1 == SLang_push_string (b->name)) return -1; if (-1 == SLexecute_function (nt)) { if (Active_Menu_Bar == b) /* disable callback */ { # if SLANG_VERSION > 10400 SLang_free_function (nt); # endif *ntp = NULL; } return -1; } return 0; } /************************************ * jed_notify_menu_buffer_changed * * debug print: "(void)\n" * ************************************/ void jed_notify_menu_buffer_changed (void) { Menu_Bar_Type *b; int err; if (NULL == (b = get_active_menubar ())) return; err = SLang_get_error (); SLang_set_error (0); (void) exec_menubar_callback (b, &b->init_callback); if (SLang_get_error () == 0) SLang_set_error (err); } static int jGtkSelectTB(void) { /* if ( IN_MINI_WINDOW ) Return( -1 ); */ tbInputSelected = 1; Jed_Menus_Active = 1; return 0; } /************************************ * jed_select_menu_bar * * debug print: "(void)\n" * ************************************/ int jed_select_menu_bar (void) { Menu_Popup_Type *p; Menu_Node_Type **l, **lmax; /* Db; */ if (IN_MINI_WINDOW) { /* For now do not allow access to menus from the minibuffer * since the minibuffer is not recursive */ return -1; } # if 0 if ( tbActive ) { Dbp( "Toolbar activated %d\n", 1 ); tbInputSelected = 1; } else # endif { /* Dbp( "Menus activate %d\n", 1 ); */ if (NULL == (Active_Menu_Bar = get_active_menubar ())) return -1; p = (Menu_Popup_Type *) Active_Menu_Bar; Active_Popup = p; l = p->subnodes; lmax = l + p->num_subnodes; /* Reset each sub-node to its default value. This is necessary * to ensure that keyboard macros will work when one switches from * one node to another via next/prev_menubar_cmd functions. */ while (l < lmax) { Menu_Popup_Type *pp = (Menu_Popup_Type *) *l++; if (pp->type == MENU_NODE_POPUP) { (void) unselect_active_node (pp); pp->active_node = 0; } } p->active_node = 0; if ( -1 == exec_menubar_callback( Active_Menu_Bar, &Active_Menu_Bar->select_callback ) ) { jed_exit_menu_bar (); return -1; } /* Db; */ /* Dbp1( "######################################################\n", 1 ); */ /* ( void ) get_selected_menu_item (p); */ /* Dbp1( "######################################################\n", 1 ); */ } touch_screen (); /* Db; */ /* Dbp1( "################################################################\n", 1 ); */ /* Jed_Menus_Active = 1; */ return 0; } /* Interpreter interface */ /************************************ * find_menu_node1 * * debug print: "Menu: %x, Name: %s, stop at last popup: %d\n", m, name, stop_at_last_popup * ************************************/ static Menu_Node_Type *find_menu_node1 (Menu_Popup_Type *m, char *name, int stop_at_last_popup) { char *name_end; Menu_Node_Type **l, **lmax; name_end = strchr (name, '.'); if (name_end == NULL) name_end = name + strlen (name); l = m->subnodes; lmax = l + m->num_subnodes; while (l < lmax) { Menu_Popup_Type *p; p = (Menu_Popup_Type *) *l++; if (0 == menu_name_eqs (p->name, name, name_end)) continue; if (*name_end == 0) { if (stop_at_last_popup && ((p->type != MENU_NODE_POPUP) || (p->type != MENU_NODE_MENUBAR))) return (Menu_Node_Type *)m; return (Menu_Node_Type *)p; } if (p->type == MENU_NODE_POPUP) return find_menu_node1 (p, name_end + 1, stop_at_last_popup); return NULL; } return NULL; } /************************************ * find_menu_node * * debug print: "Name: %s, stop at last popup: %d\n", name, stop_at_last_popup * ************************************/ static Menu_Node_Type *find_menu_node (char *name, int stop_at_last_popup) { char *s; Menu_Node_Type *m; m = (Menu_Node_Type *) menu_find_menu_bar (name, 1); if (m == NULL) return m; s = strchr (name, '.'); if (s == NULL) return m; m = find_menu_node1 ((Menu_Popup_Type *)m, s + 1, stop_at_last_popup); if (m == NULL) SLang_verror (SL_INTRINSIC_ERROR, "Unable to find menu node %s", name); return m; } /************************************ * find_menu_popup * * debug print: "Name: %s\n", name * ************************************/ static Menu_Popup_Type *find_menu_popup (char *name) { Menu_Popup_Type *m; m = (Menu_Popup_Type *) find_menu_node (name, 0); if (m == NULL) return m; if ((m->type != MENU_NODE_POPUP) && (m->type != MENU_NODE_MENUBAR)) { SLang_verror (SL_INVALID_PARM, "%s is not a menu node", name); return NULL; } return m; } /* If name is NULL or non-existent, then insert at end */ /************************************ * find_where_to_insert * * debug print: "Menu: %x, Name: %s\n", p, name * ************************************/ static unsigned int find_where_to_insert (Menu_Popup_Type *p, char *name) { unsigned int i, num; num = p->num_subnodes; if (name != NULL) for (i = 0; i < num; i++) { if (0 == strcmp (name, p->subnodes[i]->name)) return i; } return num; } /************************************ * create_menu_bar_cmd * * debug print: "Name: %s\n", name * ************************************/ static void create_menu_bar_cmd( char *name ) { /* gtkCreateMenuBarCmd( name ); */ if ( 0 == strcmp( "Global", name ) ) { Menu_Bar_Type *g = create_menu_bar( name, 5 ); if ( g != NULL ) { jed_delete_menu_bar( Global_Menu_Bar ); jGtkCreateMenuBarCmd( g ); /* Global_Menu_Bar = g; */ if ( !Active_Menu_Bar ) { gtkSetBufferMenuBarCmd( name ); } } Global_Menu_Bar = g; return; } if ( NULL != menu_find_menu_bar( name, 0 ) ) return; jGtkCreateMenuBarCmd( create_menu_bar( name, 5 ) ); } /************************************ * set_buffer_menu_bar_cmd * * debug print: "Name: %s\n", name * ************************************/ static void set_buffer_menu_bar_cmd (char *name) { Menu_Bar_Type *b; gtkSetBufferMenuBarCmd( name ); b = menu_find_menu_bar (name, 1); if (b == NULL) return; if ( b != CBuf->menubar ) { jed_delete_menu_bar (CBuf->menubar); CBuf->menubar = b; b->num_refs += 1; } } /************************************ * pop_where_to_insert * * debug print: "Menu: %x, where: %d\n", p, where * ************************************/ static int pop_where_to_insert (Menu_Popup_Type *p, unsigned int *where) { if (SLang_peek_at_stack () == SLANG_STRING_TYPE) { char *s; if (-1 == SLang_pop_slstring (&s)) return -1; *where = find_where_to_insert (p, s); SLang_free_slstring (s); return 0; } if (-1 == SLang_pop_uinteger (where)) return -1; return 0; } /************************************ * insert_popup_menu_cmd * * debug print: "Dest: |%s|, Menu: |%s|\n", dest, menu * ************************************/ static void insert_popup_menu_cmd (char *dest, char *menu) { Menu_Popup_Type *m; unsigned int where; m = find_menu_popup (dest); if (m == NULL) return; if (-1 == pop_where_to_insert (m, &where)) return; jGtkInsertPopupMenuCmd( insert_popup_menu( m, menu, where ), where ); } /************************************ * append_popup_menu_cmd * * debug print: "Dest %s, Menu: %s\n", dest, menu * ************************************/ static void append_popup_menu_cmd (char *dest, char *menu) { Menu_Popup_Type *m; /* gtkAppendPopupMenuCmd( dest, menu ); */ m = find_menu_popup (dest); if (m == NULL) return; jGtkInsertPopupMenuCmd( insert_popup_menu (m, menu, m->num_subnodes), m->num_subnodes ); } /************************************ * insert_separator_cmd * * debug print: "Name: %s\n", name * ************************************/ static void insert_separator_cmd (char *name) { Menu_Popup_Type *m; unsigned int where; /* gtkInsertSeparatorCmd( name ); */ m = find_menu_popup (name); if (m == NULL) return; if (-1 == pop_where_to_insert (m, &where)) return; jGtkInsertSeparatorCmd( m, insert_separator( m, where ), where ); } /************************************ * append_separator_cmd * * debug print: "Name: %s\n", name * ************************************/ static void append_separator_cmd (char *name) { Menu_Popup_Type *m; /* gtkAppendSeparatorCmd( name ); */ m = find_menu_popup (name); if (m != NULL) jGtkInsertSeparatorCmd( m, insert_separator( m, m->num_subnodes ), m->num_subnodes - 1 ); } /************************************ * insert_menu_item_cmd_internal * * debug print: "Is fun: %d, do append: %d\n", is_fun, do_append * ************************************/ static void insert_menu_item_cmd_internal( int is_fun, int do_append ) { Menu_Popup_Type *m; Menu_Node_Type *newItem; SLang_Name_Type *nt = NULL; SLang_Any_Type *client_data = NULL; char *str = NULL; char *menu = NULL; char *name = NULL; unsigned int where; /* printf( "File: %s, Line: %d\n", __FILE__, __LINE__ ); */ if ( is_fun ) { if ( -1 == SLang_pop_anytype( &client_data ) ) return; if ( NULL == ( nt = SLang_pop_function() ) ) goto free_and_return; } else if ( -1 == SLang_pop_slstring( &str ) ) return; if ( -1 == SLang_pop_slstring( &name ) ) goto free_and_return; if ( -1 == SLang_pop_slstring( &menu ) ) goto free_and_return; if ( NULL == ( m = find_menu_popup( menu ) ) ) goto free_and_return; if ( do_append ) where = m->num_subnodes; else if ( -1 == pop_where_to_insert( m, &where ) ) goto free_and_return; /* Creates crash because second argument sometimes NULL!!! */ /* Dbp( "Menu: |%s|, Name: |%s|\n", ( menu, name ) ); */ /* gtkMenuItemNew( menu, name, do_append ); */ if ( nt != NULL ) { newItem = ( Menu_Node_Type * ) insert_slang_fun_item( m, name, nt, client_data, where ); if ( NULL != newItem ) { jGtkMenuItemNew( m, newItem, where ); client_data = NULL; nt = NULL; } } else jGtkMenuKeystringItemNew( m, ( Menu_Node_Type * ) insert_keystring_item( m, name, str, where ), where ); /* drop */ free_and_return: if ( client_data != NULL ) SLang_free_anytype( client_data ); SLang_free_slstring( str ); SLang_free_slstring( menu ); SLang_free_slstring( name ); # if SLANG_VERSION > 10400 SLang_free_function( nt ); # endif } /************************************ * insert_menu_item_cmd * * debug print: "(void)\n" * ************************************/ static void insert_menu_item_cmd (void) { /* printf( "File: %s, Line: %d\n", __FILE__, __LINE__ ); */ insert_menu_item_cmd_internal( ( SLang_Num_Function_Args == 5 ), 0 ); } /************************************ * append_menu_item_cmd * * debug print: "(void)\n" * ************************************/ static void append_menu_item_cmd (void) { /* printf( "File: %s, Line: %d\n", __FILE__, __LINE__ ); */ insert_menu_item_cmd_internal( ( SLang_Num_Function_Args == 4 ), 1 ); } /************************************ * menu_delete_item_cmd * * debug print: "Menu: %s\n", menu * ************************************/ static void menu_delete_item_cmd( char *menu ) { Menu_Popup_Type *parent; Menu_Node_Type *child; /* gtkMenuDeleteItemCmd( menu ); */ parent = (Menu_Popup_Type *)find_menu_node (menu, 1); child = find_menu_node (menu, 0); if ((parent == NULL) || (child == NULL)) { SLang_verror (SL_INVALID_PARM, "Menu %s does not exist", menu); return; } menu_delete_node (parent, child); } /************************************ * menu_delete_items_cmd * * debug print: "Menu: %s\n", menu * ************************************/ static void menu_delete_items_cmd (char *menu) { Menu_Popup_Type *p; /* gtkMenuDeleteItemsCmd( menu ); */ if (NULL == (p = find_menu_popup (menu))) return; menu_delete_nodes (p); } static int getChildPos( Menu_Popup_Type *parent, Menu_Node_Type *child ) { unsigned int i; for ( i = 0; i < parent->num_subnodes; ++i ) { if ( parent->subnodes[i] == child ) return( (int) i ); } return( -1 ); } static void setObjectAvailable( Menu_Node_Type *parent, Menu_Node_Type *item ) { int n; if ( parent == item ) return; /* someone trying to make the menubar unavailable */ if ( !item->menuItem ) return; /* if ( !parent->subMenu ) Return; */ if ( !gtk_widget_get_parent( item->menuItem ) ) { n = getChildPos( ( Menu_Popup_Type * ) parent, item ); if ( n >= 0 ) { gtk_menu_shell_insert( GTK_MENU_SHELL( parent->subMenu ), item->menuItem, n ); g_object_unref( item->menuItem ); } } } static void setObjectUnavailable( Menu_Node_Type *parent, Menu_Node_Type *item ) { GtkWidget *pW; if ( parent == item ) return; if ( !item->menuItem ) return; pW = gtk_widget_get_parent( item->menuItem ); if ( !pW ) return; g_object_ref( item->menuItem ); gtk_container_remove( GTK_CONTAINER( pW ), item->menuItem ); } /************************************ * set_object_available_cmd * * debug print: "Name: %s, Flag: %d\n", name, flag * ************************************/ static void set_object_available_cmd (char *name, int *flag) { Menu_Node_Type *m; gtkSetObjectAvailableCmd( name ); if (NULL == (m = find_menu_node (name, 0))) return; if ( *flag ) { m->flags &= ~MENU_ITEM_UNAVAILABLE; setObjectAvailable( find_menu_node( name, 1 ), m ); } else { m->flags |= MENU_ITEM_UNAVAILABLE; setObjectUnavailable( find_menu_node( name, 1 ), m ); } } /************************************ * pop_popup_callback * * debug print: "Menus: %x, type: %d, Names: %x\n", pp, type, ntp * ************************************/ static int pop_popup_callback (Menu_Popup_Type **pp, int type, SLang_Name_Type **ntp) { SLang_Name_Type *nt; char *popup; Menu_Popup_Type *p; if (SLang_peek_at_stack () == SLANG_NULL_TYPE) { (void) SLang_pop_null (); nt = NULL; } else if (NULL == (nt = SLang_pop_function ())) return -1; if (-1 == SLang_pop_slstring (&popup)) { # if SLANG_VERSION > 10400 SLang_free_function (nt); # endif return -1; } p = find_menu_popup (popup); if (p == NULL) { # if SLANG_VERSION > 10400 SLang_free_function (nt); # endif SLang_free_slstring (popup); return -1; } if (type && (p->type != type)) { SLang_verror (SL_INVALID_PARM, "%s does not specify the proper menu type", popup); # if SLANG_VERSION > 10400 SLang_free_function (nt); # endif SLang_free_slstring (popup); return -1; } SLang_free_slstring (popup); *ntp = nt; *pp = p; return 0; } /************************************ * pop_menubar_callback * * debug print: "Menu bar: %x, Name type: %x\n", bp, nt * ************************************/ static int pop_menubar_callback (Menu_Bar_Type **bp, SLang_Name_Type **nt) { return pop_popup_callback ((Menu_Popup_Type **)bp, MENU_NODE_MENUBAR, nt); } /************************************ * set_select_menubar_callback * * debug print: "(void)\n" * ************************************/ static void set_select_menubar_callback (void) { Menu_Bar_Type *b; SLang_Name_Type *nt; if (-1 == pop_menubar_callback (&b, &nt)) return; b->select_callback = nt; } /************************************ * set_init_menubar_callback * * debug print: "(void)\n" * ************************************/ static void set_init_menubar_callback (void) { Menu_Bar_Type *b; SLang_Name_Type *nt; if (-1 == pop_menubar_callback (&b, &nt)) return; b->init_callback = nt; } /************************************ * set_select_popup_callback * * debug print: "(void)\n" * ************************************/ static void set_select_popup_callback (void) { Menu_Popup_Type *p; SLang_Name_Type *nt; if (-1 == pop_popup_callback (&p, MENU_NODE_POPUP, &nt)) return; p->select_popup_callback = nt; } /************************************ * set_tweak_popup_callback * * debug print: "(void)\n" * ************************************/ static void set_tweak_popup_callback (void) { Menu_Popup_Type *p; SLang_Name_Type *nt; if (-1 == pop_popup_callback (&p, MENU_NODE_POPUP, &nt)) return; p->tweak_popup_callback = nt; } /************************************ * copy_menu_cmd * * debug print: "Dest: %s, Src: %s\n", destname, srcname * ************************************/ static void copy_menu_cmd (char *destname, char *srcname) { Menu_Popup_Type *dest; Menu_Node_Type *src; dest = find_menu_popup (destname); if (dest == NULL) return; src = find_menu_node (srcname, 0); if (src == NULL) return; /* (void) copy_menu (dest, src); */ gtkCopyMenu( dest, src ); } /************************************ * set_menu_bar_prefix_string * * debug print: "Menubar: |%s|, s: |%s|\n", menubar, s * ************************************/ static void set_menu_bar_prefix_string (char *menubar, char *s) { Menu_Bar_Type *b; if (NULL == (b = menu_find_menu_bar (menubar, 1))) return; s = SLang_create_slstring (s); if (s == NULL) return; SLang_free_slstring (b->prefix_string); b->prefix_string = s; } /************************************ * execTBCmd * * debug print: "Menu: %s\n", menu * ************************************/ void execTBCmd( char *menu ) { char *menuMax; char *popup; Menu_Popup_Type *activePopup; char *savMenu = SLmalloc( strlen( menu ) + 1 ); Menu_Bar_Type *savBar = NULL; Menu_Bar_Type *b = Menu_Bar_Root; if (savMenu == NULL) return; strcpy( savMenu, menu ); /* Dbp1( "menu: %s\n", menu ); */ menuMax = strchr( menu, '.' ); if ( menuMax == NULL ) menuMax = menu + strlen( menu ); while ( b != NULL ) { /* Dbp1( "menuBarName: %s\n", b->name ); */ if ( menu_name_eqs( b->name, menu, menuMax ) ) { savBar = b; b = NULL; } else b = b->next; } /* (void) jed_exit_menu_bar (); */ /* if (-1 == jed_select_menu_bar ()) */ /* Return; */ if ( !savBar ) { /* printf( "Cannot find menuBar: %s\n", menu ); */ return; } activePopup = ( Menu_Popup_Type * ) savBar; if (NULL == (menu = SLmake_string (menu))) return; /* for now ignore the menubar name and use default */ popup = strchr (menu, '.'); if (popup != NULL) popup++; while ((popup != NULL) && (activePopup != NULL)) { Menu_Node_Type *m; char *next_popup; /* Dbp1( "next_popup: %s\n", next_popup ); */ next_popup = strchr (popup, '.'); /* Dbp1( "next_popup: %s\n", next_popup ); */ if (next_popup != NULL) *next_popup++ = 0; /* Dbp1( "next_popup: %s\n", next_popup ); */ /* Dbp1( "popup: %s\n", popup ); */ /* Dbp1( "Active_Popup-name: %s\n", activePopup->name ); */ if ( NULL == ( m = find_subnode( activePopup, popup ) ) ) { SLang_verror( SL_INVALID_PARM, "Unable to find a popup menu called %s", menu ); break; } /* set_node_selection( activePopup, m ); */ if ( -1 == execMenuTbCmd( m ) ) break; popup = next_popup; } SLfree( menu ); } static Menu_Node_Type * getMenuNodeByPath( char *menu ) { char *menuMax; char *popup; Menu_Popup_Type *activePopup; Menu_Popup_Type *p; /* char *savMenu = SLmalloc( strlen( menu ) + 1 ); */ Menu_Bar_Type *savBar = NULL; Menu_Bar_Type *b = Menu_Bar_Root; /* strcpy( savMenu, menu ); */ /* Dbp1( "menu: %s\n", menu ); */ menuMax = strchr( menu, '.' ); if ( menuMax == NULL ) menuMax = menu + strlen( menu ); while ( b != NULL ) { /* Dbp1( "menuBarName: %s\n", b->name ); */ if ( menu_name_eqs( b->name, menu, menuMax ) ) { savBar = b; b = NULL; } else b = b->next; } /* (void) jed_exit_menu_bar (); */ /* if (-1 == jed_select_menu_bar ()) */ /* Return; */ if ( !savBar ) { /* printf( "Cannot find menuBar: %s\n", menu ); */ /* SLfree( savMenu ); */ return( NULL ); } activePopup = ( Menu_Popup_Type * ) savBar; if (NULL == (menu = SLmake_string (menu))) return( NULL ); /* for now ignore the menubar name and use default */ popup = strchr (menu, '.'); if (popup != NULL) popup++; while ((popup != NULL) && (activePopup != NULL)) { Menu_Node_Type *m; char *next_popup; /* Dbp1( "next_popup: %s\n", next_popup ); */ next_popup = strchr (popup, '.'); /* Dbp1( "next_popup: %s\n", next_popup ); */ if (next_popup != NULL) *next_popup++ = 0; /* Dbp1( "next_popup: %s\n", next_popup ); */ /* Dbp1( "popup: %s\n", popup ); */ /* Dbp1( "Active_Popup-name: %s\n", activePopup->name ); */ if ( NULL == ( m = find_subnode( activePopup, popup ) ) ) { SLang_verror( SL_INVALID_PARM, "Unable to find a popup menu called %s", menu ); break; } /* set_node_selection( activePopup, m ); */ /* if ( -1 == execMenuTbCmd( m ) ) */ /* break; */ if ( m->type == MENU_NODE_POPUP ) { p = ( Menu_Popup_Type * ) m; if ( -1 == prepare_popup( p ) ) { break; } Active_Popup = p; select_next_active_node( p, p->num_subnodes, 0 ); } else { return( m ); } popup = next_popup; } SLfree( menu ); /* SLfree( savMenu ); */ return( NULL ); } /************************************ * popup_menu_cmd * * debug print: "Menu: |%s|\n", menu * ************************************/ static void popup_menu_cmd (char *menu) { char *popup; /* printf( "File: %s, Line: %d: menu: %s\n", __FILE__, __LINE__, menu ); */ (void) jed_exit_menu_bar (); if (-1 == jed_select_menu_bar ()) return; if (NULL == (menu = SLmake_string (menu))) return; /* for now ignore the menubar name and use default */ popup = strchr (menu, '.'); if (popup != NULL) popup++; while ((popup != NULL) && (Active_Popup != NULL)) { Menu_Node_Type *m; char *next_popup; /* printf( "File: %s, Line: %d: next_popup: %s\n", __FILE__, __LINE__, next_popup ); */ next_popup = strchr (popup, '.'); /* printf( "File: %s, Line: %d: next_popup: %s\n", __FILE__, __LINE__, next_popup ); */ if (next_popup != NULL) *next_popup++ = 0; /* printf( "File: %s, Line: %d: next_popup: %s\n", __FILE__, __LINE__, next_popup ); */ /* printf( "File: %s, Line: %d: popup: %s\n", __FILE__, __LINE__, popup ); */ /* printf( "File: %s, Line: %d: Active_Popup-name: %s\n", __FILE__, __LINE__, Active_Popup->name ); */ if (NULL == (m = find_subnode (Active_Popup, popup))) { SLang_verror (SL_INVALID_PARM, "Unable to find a popup menu called %s", menu); break; } set_node_selection (Active_Popup, m); if (-1 == select_menu_cmd ()) break; popup = next_popup; } SLfree (menu); } /************************************ * insertToolbarItemCmdInternal * * debug print: "Is fun, %d, do append: %d, isStopck: %d\n", is_fun, do_append, isStock * ************************************/ static void insertToolbarItemCmdInternal( int is_fun, int do_append, int isStock ) { Menu_Popup_Type *m; Menu_Node_Type *nn; /* new node */ SLang_Name_Type *nt = NULL; SLang_Any_Type *client_data = NULL; char *keySeq = NULL; char *specCmd = NULL; char *str = NULL; char *menu = NULL; char *name = NULL; char *iconName = NULL; unsigned int where; /* printf( "File: %s, Line: %d\n", __FILE__, __LINE__ ); */ if ( is_fun == 2 ) { if ( SLang_Num_Function_Args == 5 ) { if ( -1 == SLang_pop_slstring( &keySeq ) ) { return; } if ( -1 == SLang_pop_slstring( &specCmd ) ) goto free_and_return; /* printf( "FILE: %s, Line: %d: keySeq: %s, specCmd: %s\n", __FILE__, __LINE__, keySeq, specCmd ); */ } else if ( -1 == SLang_pop_slstring( &specCmd ) ) { /* printf( "FILE: %s, Line: %d: specCmd: %s\n", __FILE__, __LINE__, specCmd ); */ return; } } else { if ( is_fun ) { if ( -1 == SLang_pop_anytype( &client_data ) ) return; if ( NULL == ( nt = SLang_pop_function() ) ) goto free_and_return; } else if ( -1 == SLang_pop_slstring( &str ) ) return; } if ( -1 == SLang_pop_slstring( &iconName ) ) goto free_and_return; if ( -1 == SLang_pop_slstring( &name ) ) goto free_and_return; if ( -1 == SLang_pop_slstring( &menu ) ) goto free_and_return; /* printf( "FILE: %s, Line: %d: menu: %s\n", __FILE__, __LINE__, menu ); */ /* printf( "FILE: %s, Line: %d: name: %s\n", __FILE__, __LINE__, name ); */ /* printf( "FILE: %s, Line: %d: iconName: %s\n", __FILE__, __LINE__, iconName ); */ if ( NULL == ( m = find_menu_popup( menu ) ) ) goto free_and_return; /* Dbp1( "m: %x\n", m ); */ if ( do_append ) where = m->num_subnodes; else if ( -1 == pop_where_to_insert( m, &where ) ) goto free_and_return; if ( where > m->num_subnodes || do_append ) { where = -1; } if ( is_fun == 2 ) { nn = ( Menu_Node_Type * ) insertSpecCmdItem( m, name, specCmd, keySeq, where ); } else { if ( nt != NULL ) { if ( NULL != ( nn = ( Menu_Node_Type * ) insert_slang_fun_item( m, name, nt, client_data, where ) ) ) { client_data = NULL; nt = NULL; } } else nn = ( Menu_Node_Type * ) insert_keystring_item( m, name, str, where ); /* drop */ } if ( isStock ) { gtkToolbarStockItemNew( m, nn, iconName, where ); } else { gtkToolbarItemNew( m, nn, iconName, where ); } free_and_return: if ( client_data != NULL ) SLang_free_anytype( client_data ); SLang_free_slstring( keySeq ); SLang_free_slstring( specCmd ); SLang_free_slstring( str ); SLang_free_slstring( menu ); SLang_free_slstring( name ); SLang_free_slstring( iconName ); # if SLANG_VERSION > 10400 SLang_free_function( nt ); # endif } static void toolbarExtension(void) { /* Do nothing. Only to allow to check, whether toolbars can be used!!! */ } /************************************ * createToolbarCmd * * debug print: "Name: %s\n", name * ************************************/ static void createToolbarCmd( char *name ) { /* printf( "File: %s, Line: %d: Function(%s): create_tool_bar_cmd\n", __FILE__, __LINE__, name ); */ /* gtkCreateToolbarCmd( name ); */ gtkCreateToolbarCmd( create_menu_bar( name, 10 ) ); /* ( void ) create_menu_bar( name, 10 ); */ } /************************************ * addBufferToolbarCmd * * debug print: "Name: %s\n", name * ************************************/ static void addBufferToolbarCmd( char *name ) { /* printf( "File: %s, Line: %d: Funktion(%s): add_buffer_tool_bar_cmd\n", __FILE__, __LINE__, name ); */ gtkAddBufferToolbarCmd( name ); } /************************************ * insertToolbarItemCmd * * debug print: "(void)\n" * ************************************/ static void insertToolbarItemCmd( void ) { /* printf( "File: %s, Line: %d: append_tool_bar_item_cmd\n", __FILE__, __LINE__ ); */ insertToolbarItemCmdInternal( ( SLang_Num_Function_Args == 6 ), 0, 0 ); } /************************************ * insertToolbarStockItemCmd * * debug print: "(void)\n" * ************************************/ static void insertToolbarStockItemCmd( void ) { /* printf( "File: %s, Line: %d: append_tool_bar_item_cmd\n", __FILE__, __LINE__ ); */ insertToolbarItemCmdInternal( ( SLang_Num_Function_Args == 6 ), 0, 1 ); } /************************************ * insertToolbarSpecialCmd * * debug print: "(void)\n" * ************************************/ static void insertToolbarSpecialCmd( void ) { /* printf( "File: %s, Line: %d: Funktion: append_tool_bar_special_cmd\n", __FILE__, __LINE__ ); */ insertToolbarItemCmdInternal( 2, 0, 0 ); } /************************************ * insertToolbarStockSpecialCmd * * debug print: "(void)\n" * ************************************/ static void insertToolbarStockSpecialCmd( void ) { /* printf( "File: %s, Line: %d: Funktion: append_tool_bar_stock_special_cmd\n", __FILE__, __LINE__ ); */ insertToolbarItemCmdInternal( 2, 0, 1 ); } /************************************ * appendToolbarStockItemCmd * * debug print: "(void)\n" * ************************************/ static void appendToolbarItemCmd( void ) { /* printf( "File: %s, Line: %d: append_tool_bar_item_cmd\n", __FILE__, __LINE__ ); */ insertToolbarItemCmdInternal( ( SLang_Num_Function_Args == 5 ), 1, 0 ); } /************************************ * appendToolbarStockItemCmd * * debug print: "(void)\n" * ************************************/ static void appendToolbarStockItemCmd( void ) { /* printf( "File: %s, Line: %d: Funktion(%s): append_tool_bar_stock_item_cmd\n", __FILE__, __LINE__ ); */ insertToolbarItemCmdInternal( ( SLang_Num_Function_Args == 5 ), 1, 1 ); } /************************************ * appendToolbarSpecialCmd * * debug print: "(void)\n" * ************************************/ static void appendToolbarSpecialCmd( void ) { /* printf( "File: %s, Line: %d: Funktion: append_tool_bar_special_cmd\n", __FILE__, __LINE__ ); */ insertToolbarItemCmdInternal( 2, 1, 0 ); } /************************************ * appendToolbarStockSpecialCmd * * debug print: "(void)\n" * ************************************/ static void appendToolbarStockSpecialCmd( void ) { /* printf( "File: %s, Line: %d: Funktion: append_tool_bar_stock_special_cmd\n", __FILE__, __LINE__ ); */ insertToolbarItemCmdInternal( 2, 1, 1 ); } /************************************ * appendToolbarSeparatorItemCmd * * debug print: "Name: %s\n", name * ************************************/ static void appendToolbarSeparatorItemCmd( char *name ) { Menu_Popup_Type *m; /* gtkToolbarAppendSeparatorCmd( name ); */ m = find_menu_popup (name); if (m != NULL) gtkToolbarAppendSeparatorCmd( m, insert_separator( m, m->num_subnodes ) ); } /************************************ * insertToolbarSeparatorItemCmd * * debug print: "Name: %s\n", name * ************************************/ static void insertToolbarSeparatorItemCmd( char *name ) { unsigned int where; Menu_Popup_Type *m; /* gtkToolbarAppendSeparatorCmd( name ); */ m = find_menu_popup (name); if ( m == NULL ) return; if (-1 == pop_where_to_insert( m, &where )) return; if ( where > m->num_subnodes ) where = m->num_subnodes; gtkToolbarInsertSeparatorCmd( m, insert_separator( m, where ), where ); } /************************************ * toolbarGetNumItemsCmd * * debug print: "Menu: %s\n", menu * ************************************/ static int toolbarGetNumItemsCmd( char *menu ) { Menu_Popup_Type *p; /* gtkMenuDeleteItemsCmd( menu ); */ if (NULL == (p = find_menu_popup (menu))) return( - 1 ); if ( p->type != MENU_NODE_POPUP && p->type != MENU_NODE_MENUBAR ) { return( -1 ); } return( p->num_subnodes ); } static SLang_Intrin_Fun_Type Menu_Table[] = { /****************************************************************************************************/ /***** Menu functions *************************************************************************/ /****************************************************************************************************/ MAKE_INTRINSIC_S( "menu_create_menu_bar", create_menu_bar_cmd, VOID_TYPE ), MAKE_INTRINSIC_SS( "menu_append_popup", append_popup_menu_cmd, VOID_TYPE ), MAKE_INTRINSIC_SS( "menu_insert_popup", insert_popup_menu_cmd, VOID_TYPE ), MAKE_INTRINSIC_S( "menu_use_menu_bar", set_buffer_menu_bar_cmd, VOID_TYPE ), MAKE_INTRINSIC_S( "menu_append_separator", append_separator_cmd, VOID_TYPE ), MAKE_INTRINSIC_S( "menu_insert_separator", insert_separator_cmd, VOID_TYPE ), MAKE_INTRINSIC_0( "menu_append_item", append_menu_item_cmd, VOID_TYPE ), MAKE_INTRINSIC_0( "menu_insert_item", insert_menu_item_cmd, VOID_TYPE ), MAKE_INTRINSIC_S( "menu_delete_item", menu_delete_item_cmd, VOID_TYPE ), MAKE_INTRINSIC_S( "menu_delete_items", menu_delete_items_cmd, VOID_TYPE ), MAKE_INTRINSIC_SI( "menu_set_object_available", set_object_available_cmd, VOID_TYPE ), MAKE_INTRINSIC_0( "menu_set_select_menubar_callback", set_select_menubar_callback, VOID_TYPE ), MAKE_INTRINSIC_0( "menu_set_init_menubar_callback", set_init_menubar_callback, VOID_TYPE ), MAKE_INTRINSIC_0( "menu_set_select_popup_callback", set_select_popup_callback, VOID_TYPE ), MAKE_INTRINSIC_0( "menu_set_tweak_popup_callback", set_tweak_popup_callback, VOID_TYPE ), MAKE_INTRINSIC_SS( "menu_copy_menu", copy_menu_cmd, VOID_TYPE ), MAKE_INTRINSIC_SS( "menu_set_menu_bar_prefix", set_menu_bar_prefix_string, VOID_TYPE ), MAKE_INTRINSIC_S( "menu_select_menu", popup_menu_cmd, VOID_TYPE ), /****************************************************************************************************/ /***** Toolbar functions *************************************************************************/ /****************************************************************************************************/ MAKE_INTRINSIC_0( "toolbar_extension", toolbarExtension, VOID_TYPE ), /* MAKE_INTRINSIC_S( "toolbar_create_toolbar", createToolbarCmd, VOID_TYPE ), */ MAKE_INTRINSIC_S( "toolbar_create", createToolbarCmd, VOID_TYPE ), /* MAKE_INTRINSIC_S( "toolbar_add_toolbar", addBufferToolbarCmd, VOID_TYPE ), */ /* MAKE_INTRINSIC_S( "toolbar_append_toolbar", addBufferToolbarCmd, VOID_TYPE ), */ MAKE_INTRINSIC_S( "toolbar_append", addBufferToolbarCmd, VOID_TYPE ), /* MAKE_INTRINSIC_SI( "toolbar_insert_toolbar", jGtkInsertBufferToolbarCmd, VOID_TYPE ), */ MAKE_INTRINSIC_SI( "toolbar_insert", jGtkInsertBufferToolbarCmd, VOID_TYPE ), /* MAKE_INTRINSIC_SI( "toolbar_detach", ???, VOID_TYPE ), */ MAKE_INTRINSIC_0( "toolbar_append_item", appendToolbarItemCmd, VOID_TYPE ), MAKE_INTRINSIC_0( "toolbar_append_stock_item", appendToolbarStockItemCmd, VOID_TYPE ), MAKE_INTRINSIC_S( "toolbar_append_separator", appendToolbarSeparatorItemCmd, VOID_TYPE ), MAKE_INTRINSIC_0( "toolbar_append_stock_spec", appendToolbarStockSpecialCmd, VOID_TYPE ), MAKE_INTRINSIC_0( "toolbar_append_spec", appendToolbarSpecialCmd, VOID_TYPE ), MAKE_INTRINSIC_0( "toolbar_insert_item", insertToolbarItemCmd, VOID_TYPE ), MAKE_INTRINSIC_0( "toolbar_insert_stock_item", insertToolbarStockItemCmd, VOID_TYPE ), MAKE_INTRINSIC_S( "toolbar_insert_separator", insertToolbarSeparatorItemCmd, VOID_TYPE ), MAKE_INTRINSIC_0( "toolbar_insert_stock_spec", insertToolbarStockSpecialCmd, VOID_TYPE ), MAKE_INTRINSIC_0( "toolbar_insert_spec", insertToolbarSpecialCmd, VOID_TYPE ), MAKE_INTRINSIC_S( "toolbar_delete_items", menu_delete_items_cmd, VOID_TYPE ), MAKE_INTRINSIC_S( "toolbar_delete_item", menu_delete_item_cmd, VOID_TYPE ), MAKE_INTRINSIC_S( "toolbar_get_num_items", toolbarGetNumItemsCmd, INT_TYPE ), MAKE_INTRINSIC( NULL, NULL, 0, 0 ) }; /************************************ * jGtkDestroyWidget * * debug print: "w: %x, data: %x, *data: %x\n", w, data, *data * ************************************/ static void jGtkDestroyWidget( GtkWidget *w, gpointer data ) { GtkWidget **wp = ( GtkWidget ** ) data; *wp = NULL; } /************************************ * jed_init_menus * * debug print: "(void)\n" * ************************************/ int jed_init_menus (void) { if (-1 == init_menu_keymap ()) return -1; if (-1 == SLadd_intrin_fun_table (Menu_Table, NULL)) return -1; # if 0 if (-1 == make_global_menubar ()) return -1; # endif return 0; } /******************************************************************** ******************************************************************** ***** Menu functions ******************************************************************* *******************************************************************/ /* extern void popup_menu_cmd( char * ); */ void jgtk_initMenubarStruct(void) { if ( Global_Menu_Bar ) { set_buffer_menu_bar_cmd( "Global" ); } } # if 0 static int checkMenuPathExists( char *dest, char *name ) { char *newPath = SLmalloc( strlen( dest ) + 1 + strlen( name ) + 1 ); char *savPath = newPath; if (newPath == NULL) return -1; strcpy( newPath, dest ); newPath += strlen( dest ); *newPath = '.'; newPath += 1; strcpy( newPath, name ); if ( g_hash_table_lookup( menuArray, savPath ) ) { SLfree( savPath ); return( 1 ); } else { SLfree( savPath ); return( 0 ); } } char * addNewMenuPath( char *dest, char *name, GtkJedMenuType *menu ) { char *newPath = SLmalloc( strlen( dest ) + 1 + strlen( name ) + 1 ); char *savPath = newPath; if (newPath == NULL) return NULL; strcpy( newPath, dest ); newPath += strlen( dest ); *newPath = '.'; newPath += 1; strcpy( newPath, name ); g_hash_table_insert( menuArray, savPath, menu ); return( savPath ); } # endif static int isMnemonic( char *name ) { while ( *name ) { if ( *name == '&' ) { return( True ); } ++name; } return( False ); } static char * createMenuNameMnemonic( char *name ) { char *savName; char *gtkName = SLmalloc( strlen( name ) + 1 ); int notEnd; if (gtkName == NULL) return NULL; strcpy( gtkName, name ); savName = gtkName; notEnd = 1; while( *savName && notEnd ) { if ( *savName == '&' ) { *savName = '_'; notEnd = 0; } ++savName; } return( gtkName ); } gboolean menuBarActivateCurrentCB( GtkWidget *w, GdkEvent *ev, gpointer *data ) { /* printf( "Current Menubar activated!!!!!!!!!!!!!\n" ); */ /* Db; */ /* Return( FALSE ); */ jed_select_menu_bar(); Jed_Menus_Active = 0; return( FALSE ); } /************************************ * jGtkGetKeystring * * debug print: "Menu keystring fun type: %x, color0: %d, color1: %d, field_widht: %d\n", k, color0, color1, field_width * ************************************/ static int jGtkGetKeystring( Menu_Keystring_Fun_Type *k, char *retBuf ) { int i; SLang_Key_Type *key, *key_root; FVOID_STAR fp; unsigned char type; char buf[3]; unsigned int best_len; char *best_keystring; SLang_Key_Type *best_key; char *name; /* draw_name (k->name, color0, color1, field_width); */ name = k->keystring; /* Now try to draw the binding */ if (NULL == (fp = (FVOID_STAR) SLang_find_key_function(name, CBuf->keymap))) type = SLKEY_F_INTERPRET; else type = SLKEY_F_INTRINSIC; best_keystring = NULL; best_len = 0xFFFF; best_key = NULL; key_root = CBuf->keymap->keymap; for (i = 0; i < 256; i++, key_root++) { # ifdef IBMPC_SYSTEM if ((i == 0) || (i == 0xE0)) continue; # endif key = key_root->next; if ((key == NULL) && (type == key_root->type)) { if (type == SLKEY_F_INTERPRET) { if (strcmp (name, key_root->f.s)) continue; } else if ((type != SLKEY_F_INTRINSIC) || (fp != key_root->f.f)) continue; buf[0] = i; buf[1] = 0; # ifndef IBMPC_SYSTEM if (i == 0) { buf[0] = '^'; buf[1] = '@'; buf[2] = 0; } # endif best_keystring = buf; break; } while (key != NULL) { char *s; SLang_Key_Type *this_key = key; key = key->next; if (this_key->type != type) continue; if (type == SLKEY_F_INTERPRET) { if (strcmp (name, this_key->f.s)) continue; } else if ((type != SLKEY_F_INTRINSIC) || (fp != this_key->f.f)) continue; s = SLang_make_keystring (this_key->str); if (s == NULL) continue; if (strlen (s) < best_len) { best_key = this_key; best_len = strlen (s); } } } /* Dbp2( "Best keystring: %x, Best key: %x\n", best_keystring, best_key ); */ if ( best_keystring && *best_keystring > 0 && *best_keystring < 32 ) { best_keystring[2] = '\0'; best_keystring[1] = *best_keystring + 64; best_keystring[0] = '^'; } if ((best_keystring != NULL) && ((*best_keystring & 0x80) || ((unsigned char)*best_keystring < 32))) best_keystring = NULL; if (best_keystring == NULL) { /* Db; */ if (best_key == NULL) return 0; /* Db; */ best_keystring = SLang_make_keystring (best_key->str); if (best_keystring == NULL) return 0; } best_len = strlen (best_keystring); if (best_len > 4) return 0; /* Db; */ strcpy( retBuf, best_keystring ); return( best_len ); /********** SLsmg_forward (-4); SLsmg_set_color (color0); SLsmg_write_nchars (best_keystring, best_len); Return 0; *****/ } static void jGktDrawKeyStringAccelKey( Menu_Keystring_Fun_Type *km ) { char keyBuf[5]; char keyBufExt[50] = " "; GList *cl; /* Dbp2( "Drawing: %x, |%s|\n", *n, ( *n )->name ); */ /* km = ( Menu_Keystring_Fun_Type * ) *n; */ if ( jGtkGetKeystring( km, keyBuf ) ) { *keyBufExt = ' '; /* Dbp1( "AccelKey: |%s|\n", keyBuf ); */ if ( !strncmp( keyBuf, "^[", 2 ) ) { strcpy( keyBufExt + 5, "ESC " ); /* Dbp1( "AccelKeyExt: |%s|\n", keyBufExt ); */ strcpy( keyBufExt + 9, keyBuf + 2 ); /* Dbp1( "AccelKeyExt: |%s|\n", keyBufExt ); */ } else { strcpy( keyBufExt + 5, keyBuf ); } } else { *keyBuf = '\0'; *keyBufExt = '\0'; } /* Dbp1( "AccelKey: |%s|\n", keyBuf ); */ /* Dbp1( "AccelKeyExt: |%s|\n", keyBufExt ); */ /* */ cl = gtk_container_get_children( ( GtkContainer * ) gtk_container_get_children( ( GtkContainer * ) km->menuItem )->data ); if ( cl && cl->next && GTK_IS_LABEL( ( GtkWidget * ) cl->next->data ) ) { gtk_label_set_text( ( GtkLabel * ) cl->next->data, keyBufExt ); } } static void jGtkDrawAccelKey( Menu_Popup_Type *p ) { unsigned int i = p->num_subnodes; Menu_Node_Type **n = p->subnodes; for ( i = 0; i < p->num_subnodes; ++i ) { if ( ( *n )->type == MENU_NODE_KEYSTRING ) { jGktDrawKeyStringAccelKey( ( Menu_Keystring_Fun_Type * ) *n ); } ++n; } } static gboolean jGtkPopupMenuActivateCB( GtkMenuItem *w, gpointer data ) { Menu_Popup_Type *m = ( Menu_Popup_Type * ) data; /* Dbp2( "Popup %x: |%s| activated\n", m, m->name ); */ if ( ! ( m->flags & JGTK_MENU_POPUP_PREPARED ) ) { jGtkDrawAccelKey( m ); /* Dbp2( "Prepare popup %x: |%s|\n", m, m->name ); */ /* m->flags |= JGTK_MENU_POPUP_PREPARED; */ jGtkPreparePopup( m, m->select_popup_callback ); } return( FALSE ); } static gboolean jGtkPrepareCB( GtkMenuItem *w, gpointer data ) { Menu_Popup_Type *m = ( Menu_Popup_Type * ) data; /* Dbp2( "Popup %x: |%s| prepared\n", m, m->name ); */ /* jGtkPreparePopup( m, m->select_popup_callback ); */ return( FALSE ); } static void jGtkResetPopupGtkPrepared( Menu_Popup_Type *m ) { Menu_Node_Type **l, **lmax; m->flags &= ~JGTK_MENU_POPUP_PREPARED; l = m->subnodes; lmax = l + m->num_subnodes; while ( l < lmax ) { if ( ( *l )->type == 3 ) /* *l->type == 5 should not occur */ jGtkResetPopupGtkPrepared( ( Menu_Popup_Type * ) *l ); ++l; } } static gboolean jGtkDeactivateCB( GtkMenuItem *w, gpointer data ) { Menu_Popup_Type *m = ( Menu_Popup_Type * ) data; /* Dbp2( "Menu shell %x: |%s| deactivated\n", m, m->name ); */ jGtkResetPopupGtkPrepared( m ); /* jGtkPreparePopup( m, m->select_popup_callback ); */ return( FALSE ); } static gboolean jGtkActivateCurrentCB( GtkMenuItem *w, gboolean force, gpointer data ) { Menu_Popup_Type *m = ( Menu_Popup_Type * ) data; /* Dbp2( "Menu shell %x: |%s| activate-current\n", m, m->name ); */ /* jGtkPreparePopup( m, m->select_popup_callback ); */ return( FALSE ); } static void menuCallback( Menu_Node_Type *menu ) { execMenuTbCmd( menu ); jGtkSetFocus(); Jed_Menus_Active = 0; update((Line *) NULL, 0, 0, 1); /* File: screen.c */ jGtkSetFocus(); } # if 0 int gtkCreateTBCmd( char *name ) { char *newKey = SLmalloc( strlen( name ) + 1 ); if (newKey == NULL) return -1; /* GtkJedMenuType *newMenu = ( GtkJedMenuType * ) SLmalloc( sizeof( GtkJedMenuType ) ); */ /* printf( "File: %s, Line: %d, gtkCreateMenuBarCmd: |%s|\n", __FILE__, __LINE__, name ); */ strcpy( newKey, name ); /* printf( "File: %s, Line: %d, gtkCreateMenuBarCmd: |%s|\n", __FILE__, __LINE__, newKey ); */ newMenu->parent = NULL; newMenu->subMenu = NULL; newMenu->menuItem = gtk_menu_bar_new(); g_signal_connect( G_OBJECT( newMenu->menuItem ), "button-release-event", G_CALLBACK( menuBarActivateCurrentCB ), newMenu->menuItem ); /******* g_signal_connect( G_OBJECT( newMenu->menuItem ), "button-press-event", G_CALLBACK( menuBarActivateCurrentCB ), newMenu->menuItem ); ***********/ /* printf( "File: %s, Line: %d, Name: %s, menu: %x\n", __FILE__, __LINE__, newKey, newMenu ); */ g_hash_table_insert( menuArray, newKey, newMenu ); return 0; } # endif static void jGtkCreateMenuBarCmd( Menu_Bar_Type *m ) { /* char *newKey = SLmalloc( strlen( name ) + 1 ); */ /* GtkJedMenuType *newMenu = ( GtkJedMenuType * ) SLmalloc( sizeof( GtkJedMenuType ) ); */ /* printf( "File: %s, Line: %d, gtkCreateMenuBarCmd: |%s|\n", __FILE__, __LINE__, name ); */ /* strcpy( newKey, name ); */ /* printf( "File: %s, Line: %d, gtkCreateMenuBarCmd: |%s|\n", __FILE__, __LINE__, newKey ); */ /* newMenu->parent = NULL; */ /* newMenu->subMenu = NULL; */ /* newMenu->menuItem = gtk_menu_bar_new(); */ m->subMenu = gtk_menu_bar_new(); g_signal_connect( G_OBJECT( m->subMenu ), "button-release-event", G_CALLBACK( menuBarActivateCurrentCB ), NULL ); g_signal_connect( G_OBJECT( m->subMenu ), "destroy", G_CALLBACK( jGtkDestroyWidget ), &( m->subMenu ) ); g_signal_connect( G_OBJECT( m->subMenu ), "deactivate", G_CALLBACK( jGtkDeactivateCB ), m ); g_signal_connect( G_OBJECT( m->subMenu ), "activate-current", G_CALLBACK( jGtkActivateCurrentCB ), m ); } void gtkSetBufferMenuBarCmd( char *name ) { Menu_Bar_Type *menu = menu_find_menu_bar( name, True ); /* Db; */ /* Dbp2( ">>>: ----------->Menu: |%s|%x|<<<\n", name, menu ); */ if ( menu ) jGtkAttachMenubar( menu->subMenu ); # if 0 if ( menu && menu->menuItem != JGtkWin->appWMenuBar ) { /* Dbp1( "Menu: %x\n", menu ); */ gtk_box_pack_start( GTK_BOX( JGtkWin->appWGrid ), menu->menuItem, False, False, 0 ); gtk_box_reorder_child( GTK_BOX( JGtkWin->appWGrid ), menu->menuItem, 1 ); if ( JGtkWin->appWMenuBar ) gtk_container_remove( GTK_CONTAINER( JGtkWin->appWGrid ), JGtkWin->appWMenuBar ); JGtkWin->appWMenuBar = menu->menuItem; gtk_widget_show_all( menu->menuItem ); } # endif } # if 0 static void jGtkSimpleAppendTBCmd( char *dest, char *menuName ) { char *gtkName = createMenuNameMnemonic( menuName ); /* GtkJedMenuType *menu = g_hash_table_lookup( menuArray, dest ); */ /* GtkJedMenuType *newMenu = ( GtkJedMenuType * ) SLmalloc( sizeof( GtkJedMenuType ) ); */ /* newMenu->parent = menu; */ /* newMenu->menuItem = gtk_menu_item_new_with_mnemonic( gtkName ); */ SLfree( gtkName ); newMenu->subMenu = gtk_menu_new(); g_signal_connect( G_OBJECT( newMenu->menuItem ), "destroy", G_CALLBACK( jGtkDestroyWidget ), &( newMenu->menuItem ) ); g_signal_connect( G_OBJECT( newMenu->subMenu ), "destroy", G_CALLBACK( jGtkDestroyWidget ), &( newMenu->subMenu ) ); gtk_widget_show_all( newMenu->menuItem ); gtk_widget_show_all( newMenu->subMenu ); gtk_menu_item_set_submenu( GTK_MENU_ITEM( newMenu->menuItem ), newMenu->subMenu ); /* printf( "gtkSimpleAppendPopupMenuCmd (File: %s, Line: %d): dest: |%s| name: |%s|\n", __FILE__, __LINE__, dest, menuName ); */ if ( menu->parent ) { gtk_menu_shell_append( GTK_MENU_SHELL( menu->subMenu ), newMenu->menuItem ); } else { gtk_menu_bar_append( GTK_MENU_BAR( menu->menuItem ), newMenu->menuItem ); } addNewMenuPath( dest, menuName, newMenu ); } # endif static void jGtkSimpleInsertPopupMenuCmd( Menu_Popup_Type *m, int n ) { char *gtkName = createMenuNameMnemonic( m->name ); m->menuItem = gtk_menu_item_new_with_mnemonic( gtkName ); SLfree( gtkName ); m->subMenu = gtk_menu_new(); gtk_menu_item_set_submenu( GTK_MENU_ITEM( m->menuItem ), m->subMenu ); g_signal_connect( G_OBJECT( m->menuItem ), "destroy", G_CALLBACK( jGtkDestroyWidget ), &( m->menuItem ) ); g_signal_connect( G_OBJECT( m->subMenu ), "destroy", G_CALLBACK( jGtkDestroyWidget ), &( m->subMenu ) ); g_signal_connect( G_OBJECT( m->menuItem ), "activate", G_CALLBACK( jGtkPopupMenuActivateCB ), ( gpointer ) m ); /* Dbp2( "Name: |%x|%s|\n", m, m->name ); */ gtk_widget_show_all( m->menuItem ); gtk_widget_show_all( m->subMenu ); /* printf( "gtkSimpleAppendPopupMenuCmd (File: %s, Line: %d): dest: |%s| name: |%s|\n", __FILE__, __LINE__, dest, menuName ); */ /* if ( m->parent->parent ) */ /* { */ gtk_menu_shell_insert( GTK_MENU_SHELL( m->parent->subMenu ), m->menuItem, n ); /* } */ /* else */ /* { */ /* gtk_menu_shell_insert( GTK_MENU_SHELL( m->parent->menuItem ), m->menuItem, n ); */ /* } */ } # if 0 void checkAndCreateMenuPath( char *path ) { /* char *savPath = path; */ char *savPathBeg = path; char *savPathEnd = path; while ( *savPathEnd ) { if ( *savPathEnd == '.' ) { /* the char-sequence .. has occured */ if ( savPathBeg == savPathEnd ) { savPathBeg++; savPathEnd++; } else { *savPathEnd = '\0'; /* temporary End of String; */ if ( g_hash_table_lookup( menuArray, path ) ) { /* Path exists */ *savPathEnd = '.'; ++savPathEnd; savPathBeg = savPathEnd; } else { /* Path does not exist */ if ( savPathBeg == path ) { /* First part does not exist ==> new Menu Bar */ gtkCreateTBCmd( path ); *savPathEnd = '.'; ++savPathEnd; savPathBeg = savPathEnd; } else { /* a new submenu needs to be created */ char savChar; --savPathBeg; savChar = *savPathBeg; *savPathBeg = '\0'; savPathBeg++; jGtkSimpleAppendTBCmd( path, savPathBeg ); --savPathBeg; *savPathBeg = savChar; *savPathEnd = '.'; ++savPathEnd; savPathBeg = savPathEnd; } } } } else { ++savPathEnd; } } if ( savPathBeg != savPathEnd ) { if ( !g_hash_table_lookup( menuArray, path ) ) { /* Path does not exist */ if ( savPathBeg == path ) { /* First part does not exist ==> new Menu Bar */ gtkCreateTBCmd( path ); } else { /* a new submenu needs to be created */ char savChar; --savPathBeg; savChar = *savPathBeg; *savPathBeg = '\0'; savPathBeg++; gtkAppendTBCmd( path, savPathBeg ); --savPathBeg; *savPathBeg = savChar; } } } } void gtkAppendTBCmd( char *dest, char *menu ) { /* printf( "gtkAppendPopupMenuCmd (File: %s, Line: %d): dest: |%s| menu: |%s|\n", __FILE__, __LINE__, dest, menu ); */ if ( !checkMenuPathExists( dest, menu ) ) { checkAndCreateMenuPath( dest ); jGtkSimpleAppendTBCmd( dest, menu ); } } # endif static void jGtkInsertPopupMenuCmd( Menu_Popup_Type *m, int n ) { /* printf( "gtkAppendPopupMenuCmd (File: %s, Line: %d): dest: |%s| menu: |%s|\n", __FILE__, __LINE__, dest, menu ); */ if ( m && !m->menuItem && !m->subMenu && m->parent && ( m->parent->type == 5 || m->parent->type == 3 ) ) { jGtkSimpleInsertPopupMenuCmd( m, n ); } /* m->flags &= ~JGTK_MENU_POPUP_PREPARED; */ /* m->flags = 0; */ } static void jGtkInsertSeparatorCmd( Menu_Popup_Type *m, Menu_Node_Type *sep, int n ) { if ( m && m->subMenu && sep ) { sep->menuItem = gtk_separator_menu_item_new(); g_signal_connect( G_OBJECT( sep->menuItem ), "destroy", G_CALLBACK( jGtkDestroyWidget ), &( sep->menuItem ) ); gtk_menu_shell_insert( GTK_MENU_SHELL( m->subMenu ), sep->menuItem, n + 1 ); gtk_widget_show_all( sep->menuItem ); } } static void jGtkMenuItemNew( Menu_Popup_Type *menu, Menu_Node_Type *newNode, int n ) { if ( menu && menu->subMenu && newNode ) { char *gtkName = createMenuNameMnemonic( newNode->name ); if ( isMnemonic( newNode->name ) ) { newNode->menuItem = gtk_menu_item_new_with_mnemonic( gtkName ); } else { newNode->menuItem = gtk_menu_item_new_with_label( gtkName ); } g_signal_connect( G_OBJECT( newNode->menuItem ), "destroy", G_CALLBACK( jGtkDestroyWidget ), &( newNode->menuItem ) ); SLfree( gtkName ); gtk_menu_shell_insert( GTK_MENU_SHELL( menu->subMenu ), newNode->menuItem, n ); gtk_widget_show_all( newNode->menuItem ); /******** g_signal_connect_swapped( G_OBJECT( newNode->menuItem ), "activate", G_CALLBACK( menuCallback ), ( gpointer ) newNode ); **********/ g_signal_connect( G_OBJECT( newNode->menuItem ), "activate", G_CALLBACK( toolbarCallback ), ( gpointer ) newNode ); } } static void jGtkMenuKeystringItemNew( Menu_Popup_Type *menu, Menu_Node_Type *newNode, int n ) { GtkWidget *l; GtkWidget *lb; if ( menu && menu->subMenu && newNode ) { char *gtkName = createMenuNameMnemonic( newNode->name ); newNode->menuItem = gtk_menu_item_new(); lb = gtk_hbox_new( 0, 0 ); gtk_container_add( ( GtkContainer * ) newNode->menuItem, lb ); l = gtk_label_new( " " ); gtk_box_pack_start( ( GtkBox * ) lb, l, True, True, 0 ); if ( isMnemonic( newNode->name ) ) { gtk_label_set_markup_with_mnemonic( ( GtkLabel * ) l, gtkName ); /* newNode->menuItem = gtk_menu_item_new_with_mnemonic( gtkName ); */ } else { gtk_label_set_markup( ( GtkLabel * ) l, gtkName ); /* newNode->menuItem = gtk_menu_item_new_with_label( gtkName ); */ } gtk_misc_set_alignment( ( GtkMisc * ) l, 0, 0 ); /* gtk_label_set_justify( ( GtkLabel * ) l, GTK_JUSTIFY_LEFT ); */ l = gtk_label_new( " " ); gtk_box_pack_start( ( GtkBox * ) lb, l, False, False, 0 ); g_signal_connect( G_OBJECT( newNode->menuItem ), "destroy", G_CALLBACK( jGtkDestroyWidget ), &( newNode->menuItem ) ); SLfree( gtkName ); gtk_menu_shell_insert( GTK_MENU_SHELL( menu->subMenu ), newNode->menuItem, n ); gtk_widget_show_all( newNode->menuItem ); /******** g_signal_connect_swapped( G_OBJECT( newNode->menuItem ), "activate", G_CALLBACK( menuCallback ), ( gpointer ) newNode ); **********/ g_signal_connect( G_OBJECT( newNode->menuItem ), "activate", G_CALLBACK( toolbarCallback ), ( gpointer ) newNode ); jGktDrawKeyStringAccelKey( ( Menu_Keystring_Fun_Type * ) newNode ); } } # if 0 void gtkMenuDeleteItemCmd( char *menu ) { } void gtkMenuDeleteItemsCmd( char *menu ) { } # endif void gtkSetObjectAvailableCmd( char *name ) { } /******************************************************************** ******************************************************************** ***** Toolbar functions ******************************************************************* *******************************************************************/ void jgtk_initToolbarArray(void) { /* menuArray = g_hash_table_new( g_str_hash, g_str_equal ); */ } extern int execTBKeyFeedCmd( char * ); extern int split_window( void ); void toolbarCallback( GtkWidget *w, gpointer data ) { Menu_Node_Type *menu = ( Menu_Node_Type * ) data; /* Dbp1( "Toolbar clicked\n", 1 ); */ /* Dbp1( "Menu Item: %x selected!\n", menu ); */ /* Dbp1( "Path: |%s| selected!\n", menu->name ); */ if ( actTBCmdNode ) { Menu_Keystring_Fun_Type *tmp = ( Menu_Keystring_Fun_Type * ) menu; /* Dbp1( "ActTBCmdNode: %x\n", actTBCmdNode ); */ if ( tmp && tmp->type == MENU_NODE_TYPEDKEYS ) { /* Dbp6( "keyStr[0]: %d, |%c|, keyStr[1]: %d, |%c|, keyStr[2]: %d, |%c|\n", tmp->keystring[0], tmp->keystring[0], tmp->keystring[1], tmp->keystring[1], tmp->keystring[2], tmp->keystring[2] ); */ jgtk_createKeyEvents( tmp->keystring ); } else { jgtk_createKeyEvents( SLang_process_keystring( "^M" ) ); } } else { actTBCmdNode = ( Menu_Node_Type * ) data; /* Dbp1( "ActTBCmdNode: %x\n", actTBCmdNode ); */ if ( actTBCmdNode ) { /* Dbp1( "ActTBCmdNode: %x\n", actTBCmdNode ); */ if ( actTBCmdNode->type == MENU_NODE_TYPEDKEYS ) { jgtk_createKeyEvents( ( ( Menu_Keystring_Fun_Type * ) actTBCmdNode )->keystring ); actTBCmdNode = NULL; } else if ( !IN_MINI_WINDOW ) { /* Dbp1( "IN_MINI_WINDOW: %d\n", IN_MINI_WINDOW ); */ jgtk_createKeyEvents( SLang_process_keystring( TB_SEL_KEY_SEQ ) ); } else { actTBCmdNode = NULL; } /* Dbp1( "Dummy: %d\n", 1 ); */ } /* tbActive = 1; */ } } void gtkCreateToolbarCmd( Menu_Bar_Type *mb ) { /* char *newKey = SLmalloc( strlen( mb->name ) + 1 ); */ GtkToolbar *tb = ( GtkToolbar * ) gtk_toolbar_new(); mb->subMenu = ( GtkWidget * ) tb; mb->menuItem = gtk_handle_box_new(); g_signal_connect( G_OBJECT( mb->subMenu ), "destroy", G_CALLBACK( jGtkDestroyWidget ), ( gpointer ) &( mb->subMenu ) ); g_signal_connect( G_OBJECT( mb->menuItem ), "destroy", G_CALLBACK( jGtkDestroyWidget ), ( gpointer ) &( mb->menuItem ) ); gtk_toolbar_set_tooltips( tb, TRUE ); gtk_toolbar_set_style( tb, GTK_TOOLBAR_ICONS ); /* strcpy( newKey, mb->name ); */ gtk_container_add( GTK_CONTAINER( mb->menuItem ), ( GtkWidget * ) tb ); gtk_widget_show_all( ( GtkWidget * ) tb ); } /************************************ * jGtkInsertBufferToolbarCmd * * debug print: "Name: |%s|, where: %x, *where: %d\n", name, where, *where * ************************************/ static void jGtkInsertBufferToolbarCmd( char *name, int *where ) /*{{{*/ { Menu_Bar_Type *menu = menu_find_menu_bar( name, 1 ); /* Dbp1( "Menu: %x\n", menu ); */ jGtkAddToolbar( menu->menuItem, *where ); } void gtkAddBufferToolbarCmd( char *name ) /*{{{*/ { Menu_Bar_Type *menu = menu_find_menu_bar( name, 1 ); jGtkAddToolbar( menu->menuItem, -1 ); } /*}}}*/ #if GTK_HAS_TOOLTIPS static gboolean jGtkQueryTooltipCB( GtkWidget *w, gint x, gint y, gboolean kbM, GtkTooltip *tooltip, gpointer ud ) { gtk_tooltip_set_text( tooltip, ( const gchar * ) ud ); return( TRUE ); } #endif static void gtkToolbarStockItemNew( Menu_Popup_Type *parent, Menu_Node_Type *nn, char *iconName, int where ) { #if GTK_HAS_TOOLTIPS char *ttName; #endif GtkWidget *stockW = ( GtkWidget * ) gtk_tool_button_new_from_stock( iconName ); nn->subMenu = NULL; nn->menuItem = stockW; #if GTK_HAS_TOOLTIPS ttName = SLmalloc( strlen( nn->name ) + 1 ); if (ttName != NULL) { g_object_set( G_OBJECT( stockW ), "has-tooltip", TRUE, NULL ); strcpy( ttName, nn->name ); g_signal_connect( G_OBJECT( stockW ), "query-tooltip", G_CALLBACK( jGtkQueryTooltipCB ), ttName ); } #endif g_object_set( G_OBJECT( stockW ), "has-tooltip", TRUE, NULL ); gtk_toolbar_insert( ( GtkToolbar * ) parent->subMenu, ( GtkToolItem * ) stockW, where ); gtk_widget_show_all( stockW ); g_signal_connect( G_OBJECT( stockW ), "clicked", G_CALLBACK( toolbarCallback ), ( gpointer ) nn ); g_signal_connect( G_OBJECT( stockW ), "destroy", G_CALLBACK( jGtkDestroyWidget ), ( gpointer ) &( nn->menuItem ) ); } static void gtkToolbarItemNew( Menu_Popup_Type *parent, Menu_Node_Type *nn, char *iconName, int where ) { gint iconW, iconH; GdkPixbuf *iconImagePixbuf; GtkWidget *stockW; gtk_icon_size_lookup( gtk_toolbar_get_icon_size( ( GtkToolbar * ) parent->subMenu ), &iconW, &iconH ); iconImagePixbuf = gdk_pixbuf_new_from_file_at_size( iconName, iconW, iconH, NULL ); stockW = ( GtkWidget * ) gtk_tool_button_new( gtk_image_new_from_pixbuf( iconImagePixbuf ), nn->name ); nn->subMenu = NULL; nn->menuItem = stockW; #if GTK_HAS_TOOLTIPS gtk_tool_item_set_tooltip_text( GTK_TOOL_ITEM( stockW ), nn->name ); #endif gtk_toolbar_insert( ( GtkToolbar * ) parent->subMenu, ( GtkToolItem * ) stockW, where ); gtk_widget_show_all( stockW ); g_signal_connect( G_OBJECT( stockW ), "clicked", G_CALLBACK( toolbarCallback ), ( gpointer ) nn ); g_signal_connect( G_OBJECT( stockW ), "destroy", G_CALLBACK( jGtkDestroyWidget ), ( gpointer ) &( nn->menuItem ) ); } static void gtkToolbarAppendSeparatorCmd( Menu_Popup_Type *p, Menu_Node_Type *menu ) { char *name; Menu_Bar_Type *parent = ( Menu_Bar_Type * ) p; GtkWidget *sepW = ( GtkWidget * ) gtk_separator_tool_item_new(); menu->subMenu = NULL; menu->menuItem = sepW; gtk_toolbar_insert( ( GtkToolbar * ) parent->subMenu, ( GtkToolItem * ) sepW, -1 ); gtk_widget_show_all( sepW ); g_signal_connect( G_OBJECT( sepW ), "destroy", G_CALLBACK( jGtkDestroyWidget ), ( gpointer ) &( menu->menuItem ) ); } static void gtkToolbarInsertSeparatorCmd( Menu_Popup_Type *p, Menu_Node_Type *menu, int where ) { char *name; Menu_Bar_Type *parent = ( Menu_Bar_Type * ) p; GtkWidget *sepW = ( GtkWidget * ) gtk_separator_tool_item_new(); menu->subMenu = NULL; menu->menuItem = sepW; gtk_toolbar_insert( ( GtkToolbar * ) parent->subMenu, ( GtkToolItem * ) sepW, where ); gtk_widget_show_all( sepW ); g_signal_connect( G_OBJECT( sepW ), "destroy", G_CALLBACK( jGtkDestroyWidget ), ( gpointer ) &( menu->menuItem ) ); } # ifdef HAS_MOUSE /************************************ * select_menu_via_rc * * debug print: " Type: %d, r: %d, c: %d\n", type, r, c * ************************************/ static int select_menu_via_rc (int type, int r, int c) { Menu_Popup_Type *p; p = Active_Popup; while (p != (Menu_Popup_Type *)Active_Menu_Bar) { if ((r >= p->row) && (r < p->max_row) && (c >= p->column) && (c < p->max_col)) break; p = p->parent; } if ((p == NULL) || (p->type == MENU_NODE_MENUBAR)) { unsigned int i; int *item_columns; if (Active_Popup == NULL) return -1; if (r != 0) { if (type != JMOUSE_DRAG) return -1; if (Active_Popup->type != MENU_NODE_MENUBAR) return 0; } unselect_active_node ((Menu_Popup_Type *) Active_Menu_Bar); i = Active_Menu_Bar->num_subnodes; item_columns = Active_Menu_Bar->item_columns; while (i > 0) { i--; if ((i != 0) && (item_columns[i] > c)) continue; p = (Menu_Popup_Type *)Active_Menu_Bar->subnodes[i]; if (p->type == MENU_NODE_SEPARATOR) continue; if (p->flags & MENU_ITEM_UNAVAILABLE) continue; if (-1 == set_node_selection ((Menu_Popup_Type *) Active_Menu_Bar, (Menu_Node_Type *) p)) return -1; if (-1 == find_active_popup ()) return -1; if (p->type == MENU_NODE_POPUP) return select_menu_cmd (); } return -1; } if (p == Active_Popup) { r -= (p->row + 1); r += p->visible_node_offset; if ((r >= (int)p->num_subnodes) || (r < 0)) return 0; if (-1 == set_node_selection (p, p->subnodes[r])) return 0; if ((type != JMOUSE_DRAG) || ((p->subnodes[r]->type == MENU_NODE_POPUP) && (c + 1 >= p->max_col))) select_menu_cmd (); return 0; } while (Active_Popup != p) back_menu_cmd (); return 0; } /************************************ * jed_menu_handle_mouse * * debug print: "Type: %d, x: %d, y: %d, button %d, shift: %d\n", type, x, y, button, shift * ************************************/ int jed_menu_handle_mouse (unsigned int type, int x, int y, int button, int shift) { (void) shift; (void) button; if ((type != JMOUSE_UP) && (type != JMOUSE_DRAG)) return -1; /* Dbp1( "################################################################\n", 1 ); */ if ((Jed_Menus_Active == 0) && (-1 == jed_select_menu_bar ())) return -1; if (-1 == select_menu_via_rc (type, y-1, x-1)) { if (type != JMOUSE_DRAG) jed_exit_menu_bar (); } return 0; } # ifndef IBMPC_SYSTEM /************************************ * xterm_mouse_cmd * * debug print: "(void)\n" * ************************************/ static int xterm_mouse_cmd (void) { int x, y, b; b = my_getkey (); printf( "File: %s, Line: %d, ch: %d\n", __FILE__, __LINE__, b ); x = (unsigned char) my_getkey () - 32; y = (unsigned char) my_getkey () - 32; /* We need to trigger on the button release event */ b -= 32; if ((b & 3) != 3) return -1; return jed_menu_handle_mouse (JMOUSE_UP, x, y, 0, 0); } # endif /* !IBMPC_SYSTEM */ # endif /* HAS_MOUSE */ #endif /* JED_HAS_MENUS */ jed-0.99-19/src/os2mouse.c0000644002657400265740000001665611311317447014217 0ustar davisdavis/* Copyright (c) 1992, 1998, 2000, 2002, 2003, 2004, 2005, 2006 John E. Davis * This file is part of JED editor library source. * * You may distribute this file under the terms the GNU General Public * License. See the file COPYING for more information. */ #ifdef HAS_MOUSE #define INCL_ERRORS #define INCL_SUB #define INCL_DOSPROCESS #define INCL_DOSSEMAPHORES #include "config.h" #include "jed-feat.h" #include #include static void show_mouse (int show); static int Mouse_X, Mouse_Y; #if __os2_16__ typedef USHORT APIRET; #define DosSetPriority DosSetPrty #endif #define THREADSTACKSIZE 32768 static TID Os2_Mouse_ThreadID = (TID) 0; static int Mouse_Hidden = 1; static int Last_Mouse_Hidden = 1; static HMOU Mouse_Handle = -1; #define MOUSE_BN1 (MOUSE_MOTION_WITH_BN1_DOWN | MOUSE_BN1_DOWN) #define MOUSE_BN2 (MOUSE_MOTION_WITH_BN2_DOWN | MOUSE_BN2_DOWN) #define MOUSE_BN3 (MOUSE_MOTION_WITH_BN3_DOWN | MOUSE_BN3_DOWN) #define MOUSE_NOMOVE (MOUSE_BN1_DOWN | MOUSE_BN2_DOWN | MOUSE_BN3_DOWN) #define MOUSE_DRAGGED (MOUSE_MOTION_WITH_BN1_DOWN | MOUSE_MOTION_WITH_BN2_DOWN | MOUSE_MOTION_WITH_BN3_DOWN) #define MOUSE_MOVED (MOUSE_MOTION | MOUSE_DRAGGED) #define MouseNoMove(event) (MOUSE_NOMOVE & event.fs) #define MouseMoved(event) (MOUSE_MOVED & event.fs) #define MouseDragged(event) (MOUSE_DRAGGED & event.fs) #define MouseButtonPressed(event,button) (event.fs & button) #define MouseButtons(event) (event.fs & (MOUSE_BN1 | MOUSE_BN2 | MOUSE_BN3)) static int buttonDown [3] = {0, 0, 0}; static int buttonMask [3]; USHORT noButtons; static void os2_add_event (int x, int y, int type, int but) { char buf[4]; int b, s, id; JMouse_Type jm; Mouse_X = jm.x = x; Mouse_Y = jm.y = y; b = but & 0xF; s = but >> 4; if (b == 1) jm.button = JMOUSE_BUTTON_1; /* left */ else if (b == 2) jm.button = JMOUSE_BUTTON_3; /* right */ else jm.button = JMOUSE_BUTTON_2; /* middle */ if (s & 0x8) /* alt key--- use as middle */ { jm.button = JMOUSE_BUTTON_2; } if (s & 0x3) jm.state = JMOUSE_SHIFT; else if (s & 0x4) jm.state = JMOUSE_CTRL; else jm.state = 0; jm.type = type; if (-1 == (id = jed_mouse_add_event (&jm))) return; buf[0] = 27; buf[1] = 0; buf[2] = (char) id; ungetkey_string (buf, 3); } static void os2_mouse_handler (void *Args) { MOUEVENTINFO event_info; APIRET Error; USHORT wait_flag; int press, i; short x, y; KBDINFO kbd_info; (void) Args; wait_flag = MOU_NOWAIT; DosSetPriority( PRTYS_THREAD, PRTYC_NOCHANGE, PRTYD_MINIMUM, 0 ) ; while (Mouse_Handle) { Error = MouReadEventQue (&event_info, &wait_flag, Mouse_Handle); if ((Error != NO_ERROR) || !event_info.time) { DosSleep (5); continue; } x = event_info.col + 1; y = event_info.row + 1; if (MouseMoved (event_info) && ((x != Mouse_X) || (y != Mouse_Y))) { /* mouse moved so show it. */ show_mouse (1); } for(i = 0; i < noButtons; i++) { if(MouseButtonPressed (event_info, buttonMask[i])) { if (!buttonDown [i]) { /* I don't think that we can find shift key status in OS/2, since we * are reading the keyboard in another thread */ kbd_info.cb = sizeof (kbd_info); KbdGetStatus (&kbd_info, 0); press = (i + 1) | ((kbd_info.fsState & 0xF) << 4); os2_add_event (x, y, JMOUSE_DOWN, press); buttonDown [i] = 1; continue; } else { /* button already down */ if (MouseDragged (event_info)) { if ((x == Mouse_X) && (y == Mouse_Y)) continue; os2_add_event (x, y, JMOUSE_DRAG, i + 1); continue; } } } else { if (buttonDown [i]) { os2_add_event (x, y, JMOUSE_UP, i + 1); buttonDown [i] = 0; continue; } } } } Mouse_Handle = -1; _endthread (); } static int os2_get_mouse_event (void) { return 0; } /* Mouse routines for OS/2 */ static void show_mouse (int show) { NOPTRRECT PtrRect; if (show) { if (Mouse_Hidden == 0) return; MouDrawPtr (Mouse_Handle); } else { if (Mouse_Hidden) return; PtrRect.row = 0; PtrRect.col = 0; PtrRect.cRow = Jed_Num_Screen_Rows - 1; PtrRect.cCol = Jed_Num_Screen_Cols - 1; MouRemovePtr (&PtrRect, Mouse_Handle); } Mouse_Hidden = !show; } static void os2_close_mouse () { MouClose (Mouse_Handle); Mouse_Handle = 0; #if defined(__os2_16__) while (!Mouse_Handle) DosSleep(0); #else DosWaitThread (&Os2_Mouse_ThreadID, DCWW_WAIT); #endif Os2_Mouse_ThreadID = 0; } static void move_mouse (int x, int y) { PTRLOC ptr_loc; ptr_loc.row = y - 1; ptr_loc.col = x - 1; MouSetPtrPos (&ptr_loc, Mouse_Handle); } static void os2_update_open_hook (void) { Last_Mouse_Hidden = Mouse_Hidden; if (Mouse_Hidden == 0) show_mouse (0); } static int Warp_Pending; static void os2_update_close_hook (void) { if (Last_Mouse_Hidden == 0) show_mouse (1); if (Warp_Pending) move_mouse (Screen_Col - 1, Screen_Row - 1); Warp_Pending = 0; } static void warp_pointer (void) { Warp_Pending = 1; } static char *CutBuffer; static int CutBuffer_Len; static int insert_cutbuffer (void) { CHECK_READ_ONLY if (CutBuffer == NULL) return 0; if (CutBuffer_Len) jed_insert_nbytes ((unsigned char *) CutBuffer, CutBuffer_Len); return CutBuffer_Len; } static void region_to_cutbuffer (void) { int nbytes; if (CutBuffer != NULL) { SLfree (CutBuffer); } CutBuffer = make_buffer_substring(&nbytes); CutBuffer_Len = nbytes; } static SLang_Intrin_Fun_Type os2_mouse_table[] = { MAKE_INTRINSIC("x_warp_pointer", warp_pointer, VOID_TYPE, 0), MAKE_INTRINSIC("x_insert_cutbuffer", insert_cutbuffer, INT_TYPE, 0), /* Prototype: Integer x_insert_cut_buffer (); * Inserts cutbuffer into the current buffer and returns the number * of characters inserted. */ MAKE_INTRINSIC("x_copy_region_to_cutbuffer", region_to_cutbuffer, VOID_TYPE, 0), /* Prototype: Void x_copy_region_to_cutbuffer(); */ SLANG_END_TABLE }; void (*X_Close_Mouse_Hook)(void); static int os2_open_mouse () { static int not_first_time = 0; USHORT Error; X_Close_Mouse_Hook = NULL; JMouse_Event_Hook = NULL; JMouse_Hide_Mouse_Hook = NULL; X_Update_Open_Hook = NULL; X_Update_Close_Hook = NULL; /* Now open the device */ Error = MouOpen (NULL, &Mouse_Handle); if (Error) return -1; Mouse_X = Jed_Num_Screen_Cols / 2 + 1; Mouse_Y = Jed_Num_Screen_Rows / 2 + 1; MouDrawPtr (Mouse_Handle); MouGetNumButtons (&noButtons, Mouse_Handle); if (noButtons == 3) buttonMask [2] = MOUSE_BN3; buttonMask [0] = MOUSE_BN1; buttonMask [1] = MOUSE_BN2; MouFlushQue(Mouse_Handle); /* flush mouse queue */ move_mouse (Mouse_X, Mouse_Y); if (not_first_time == 0) { if (-1 == SLadd_intrin_fun_table (os2_mouse_table, "MOUSE")) return -1; not_first_time = 1; } #if defined __BORLANDC__ Os2_Mouse_ThreadID = _beginthread (os2_mouse_handler, THREADSTACKSIZE, NULL); #else Os2_Mouse_ThreadID = _beginthread (os2_mouse_handler, NULL, THREADSTACKSIZE, NULL); #endif JMouse_Hide_Mouse_Hook = show_mouse; X_Close_Mouse_Hook = os2_close_mouse; /* I am not sure if I should set this */ JMouse_Event_Hook = os2_get_mouse_event; X_Update_Open_Hook = os2_update_open_hook; X_Update_Close_Hook = os2_update_close_hook; return 1; } int (*X_Open_Mouse_Hook)(void) = os2_open_mouse; #endif jed-0.99-19/src/Makefile.in0000644002657400265740000004253211311317447014334 0ustar davisdavis# -*- sh -*- # C compiler and C flags CC = @CC@ CFLAGS = @CFLAGS@ @CPPFLAGS@ @X_CFLAGS@ @SLANG_DLL_CFLAGS@ LDFLAGS = @LDFLAGS@ @DYNAMIC_LINK_FLAGS@ #--------------------------------------------------------------------------- # Installation information. All jed library files will be placed under # $JED_ROOT. /usr/local/jed is a good choice. For a private installation, # use, e.g., $(HOME)/src/jed #--------------------------------------------------------------------------- prefix = @prefix@ exec_prefix = @exec_prefix@ datarootdir = @datarootdir@ #JED_ROOT = $(HOME)/src/jed# <--- make sure # is at end of file!! #JED_ROOT = $(prefix)/jed# <--- make sure # is at end of file!! JED_ROOT = @JED_ROOT@# <--- make sure # is at end of file!! BIN_DIR = @bindir@ MAN_DIR = @mandir@/man1 INFO_DIR = @infodir@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ MKINSDIR = ../autoconf/mkinsdir.sh JED_LIB_FILES = ../lib/*.sl ../lib/*.dat ../lib/*.hlp ../lib/jed.rc JED_DOC_FILES = ../doc/README JED_DOC_TXT_FILES = ../doc/txt/*.txt JED_DOC_HLP_FILES = ../doc/hlp/*.hlp JED_DOC_MAN_FILES = ../doc/manual/jed.tex JED_MAN_FILES = ../doc/manual/rgrep.1 ../doc/manual/jed.1 JED_COLOR_FILES = ../lib/colors/*.sl ../lib/colors/README XJED_COLOR_FILES = ../lib/colors/Xjed/*.sl JED_INFO_FILES = # ../info/* #--------------------------------------------------------------------------- # DESTDIR is designed to facilitate making packages. Normally it is empty #--------------------------------------------------------------------------- DESTDIR = DEST_BIN_DIR = $(DESTDIR)$(BIN_DIR) DEST_MAN_DIR = $(DESTDIR)$(MAN_DIR) DEST_INFO_DIR = $(DESTDIR)$(INFO_DIR) DEST_JED_ROOT = $(DESTDIR)$(JED_ROOT) #--------------------------------------------------------------------------- # Location of jed source code #--------------------------------------------------------------------------- # Location of jed source code (absolute path) SRCDIR = @SRCDIR@ # Location of compiled object code (absolute path) OBJDIR = @OBJDIR@ #--------------------------------------------------------------------------- # Special features (See also features.h) #--------------------------------------------------------------------------- # 1. Linux GPM Mouse support MOUSEDEFINES = @MOUSEDEFINES@ MOUSELIB = @MOUSELIB@ MOUSE_O_FILE = @MOUSE_O_FILE@ MOUSE_OBJ_FILE = @MOUSE_OBJ_FILE@ # 2. XFree86 XRENDERFONT (Anti-aliased font) support for XJED #XRENDERFONTLIBS = -lXft -lXrender -lfreetype -lXext XRENDERFONTLIBS = @XRENDERFONTLIBS@ #--------------------------------------------------------------------------- # S-Lang library location #--------------------------------------------------------------------------- # -L + Location of libslang.a SLANG_LIB = @SLANG_LIB@ RPATH = @RPATH@ # -I + Location of slang.h SLANG_INC = @SLANG_INC@ #--------------------------------------------------------------------------- # X and Miscellaneous libraries #--------------------------------------------------------------------------- # Some systems need -ltermcap (NeXT) TERMCAP_LIB = @TERMCAP@ # X library location XLIBDIR = @X_LIBS@ # X Include directory XINCLUDE = @X_CFLAGS@ # Extra libraries needed by X and Network support on some systems X_XTRA_LIBS = @X_EXTRA_LIBS@ # Libraries to support dynamic linking DL_LIB = @DYNAMIC_LINK_LIB@ # Anything else??? OTHERLIBS = @LIBS@ -lm #--------------------------------------------------------------------------- # There should be no need to modify anything below here. #--------------------------------------------------------------------------- MIN_SLANG_VERSION = 20100 MAX_SLANG_VERSION = XLIB = $(X_XTRA_LIBS) $(XLIBDIR) -lX11 $(TERMCAP_LIB) $(OTHERLIBS) $(DL_LIB) MISCLIBS = $(MOUSELIB) $(TERMCAP_LIB) $(X_XTRA_LIBS) $(OTHERLIBS) $(DL_LIB) ALL_CFLAGS = $(CFLAGS) -Dunix -DJED $(MOUSEDEFINES) $(SLANG_INC) CONFIG_H = config.h COMPILE_CMD = $(CC) -c $(ALL_CFLAGS) COMMON_OFILES = buffer.o cmds.o misc.o file.o ins.o sig.o sysdep.o \ screen.o paste.o ledit.o line.o search.o text.o keymap.o replace.o \ window.o undo.o vfile.o intrin.o syntax.o abbrev.o indent.o \ jprocess.o lineattr.o blocal.o mouse.o userinfo.o lock.o \ version.o hooks.o colors.o main.o COMMON_OBJS = $(OBJDIR)/buffer.o $(OBJDIR)/cmds.o $(OBJDIR)/misc.o \ $(OBJDIR)/file.o $(OBJDIR)/ins.o $(OBJDIR)/sig.o $(OBJDIR)/sysdep.o \ $(OBJDIR)/screen.o $(OBJDIR)/paste.o $(OBJDIR)/ledit.o $(OBJDIR)/line.o \ $(OBJDIR)/search.o $(OBJDIR)/text.o $(OBJDIR)/keymap.o $(OBJDIR)/replace.o \ $(OBJDIR)/window.o $(OBJDIR)/undo.o $(OBJDIR)/vfile.o $(OBJDIR)/intrin.o \ $(OBJDIR)/syntax.o $(OBJDIR)/abbrev.o $(OBJDIR)/indent.o \ $(OBJDIR)/jprocess.o $(OBJDIR)/lineattr.o $(OBJDIR)/blocal.o \ $(OBJDIR)/mouse.o $(OBJDIR)/menu.o $(OBJDIR)/userinfo.o $(OBJDIR)/lock.o \ $(OBJDIR)/version.o $(OBJDIR)/hooks.o $(OBJDIR)/colors.o \ $(OBJDIR)/main.o main_C_FLAGS = -DJED_ROOT='"$(JED_ROOT)"' main_O_DEP = Makefile jprocess_O_DEP = $(SRCDIR)/pty.c version_O_DEP = $(SRCDIR)/version.h DOT_O_DEPS = $(SRCDIR)/buffer.h $(SRCDIR)/jed-feat.h $(CONFIG_H) COMMON_LIBS = $(LDFLAGS) $(RPATH) $(SLANG_LIB) -lslang $(MISCLIBS) JED_OFILES = jedwin.o display.o menu.o $(MOUSE_O_FILE) JED_OBJS = $(OBJDIR)/jedwin.o $(OBJDIR)/display.o $(OBJDIR)/menu.o $(MOUSE_OBJ_FILE) XJED_OFILES = jedwin.o xterm.o vterm.o menu.o XJED_OBJS = $(OBJDIR)/jedwin.o $(OBJDIR)/xterm.o $(OBJDIR)/vterm.o $(OBJDIR)/menu.o xterm_C_FLAGS = $(XINCLUDE) XJED_LIBS = $(XLIB) $(XRENDERFONTLIBS) GTKJED_OFILES = vterm.o gtkmenu.o gtkwin.o gtkterm.o GTKJED_OBJS = $(OBJDIR)/vterm.o $(OBJDIR)/gtkmenu.o $(OBJDIR)/gtkwin.o $(OBJDIR)/gtkterm.o GTKJED_LIBS = @GTK_LIBS@ $(XRENDERFONTLIBS) GTKJED_CFLAGS = @GTK_CFLAGS@ BUILD_GTKJED = @BUILD_GTKJED@ UPDATE_VERSION_SCRIPT = $(HOME)/bin/update_changes_version TAG_FILES = $(CFILES) $(HFILES) TAGS_FILE_NAME = tags CTAGS_PGM = ctags #--------------------------------------------------------------------------- all: jed jed: $(OBJDIR) $(CONFIG_H) slangversion $(OBJDIR)/jed @echo jed created in $(OBJDIR) $(OBJDIR)/jed: $(COMMON_OBJS) $(JED_OBJS) cd $(OBJDIR); $(CC) $(COMMON_OFILES) $(JED_OFILES) -o jed $(COMMON_LIBS) $(JED_LIBS) slangversion: $(OBJDIR)/chkslang if $(OBJDIR)/chkslang jed $(MIN_SLANG_VERSION) $(MAX_SLANG_VERSION);\ then exit 0; else $(RM) $(OBJDIR)/chkslang; exit 1; fi $(OBJDIR)/chkslang: config.h Makefile chkslang.c $(DOT_O_DEPS) $(chkslang_O_DEP) $(CC) $(ALL_CFLAGS) $(LDFLAGS) $(SRCDIR)/chkslang.c -o $(OBJDIR)/chkslang $(COMMON_LIBS) $(OBJDIR): -mkdir $(OBJDIR) $(CONFIG_H) : $(SRCDIR)/sysconf.h /bin/cp $(SRCDIR)/sysconf.h $(CONFIG_H) touch $(CONFIG_H) $(SRCDIR)/sysdep.c: $(SRCDIR)/unix.c touch $(SRCDIR)/sysdep.c $(SRCDIR)/xterm.c: $(SRCDIR)/xkeys.c touch $(SRCDIR)/xterm.c $(SRCDIR)/syntax.c: $(SRCDIR)/dfasyntx.c touch $(SRCDIR)/syntax.c $(SRCDIR)/version.h: $(SRCDIR)/../changes.txt if [ -x $(UPDATE_VERSION_SCRIPT) ]; then \ $(UPDATE_VERSION_SCRIPT) $(SRCDIR)/../changes.txt $(SRCDIR)/version.h; \ fi # xjed : $(OBJDIR) $(CONFIG_H) slangversion $(OBJDIR)/xjed @echo xjed created in $(OBJDIR) $(OBJDIR)/xjed : $(COMMON_OBJS) $(XJED_OBJS) cd $(OBJDIR); \ $(CC) $(COMMON_OFILES) $(XJED_OFILES) -o xjed $(COMMON_LIBS) $(XJED_LIBS) # gtkversion: @if test "z$(BUILD_GTKJED)" != "zyes"; \ then \ echo ""; \ echo " ----------------------------------------------"; \ echo " | 'gtkjed' requires GTK+-2.0. |"; \ echo " ----------------------------------------------"; \ echo ""; \ exit 1; \ fi gtkjed : gtkversion $(OBJDIR) $(CONFIG_H) slangversion $(OBJDIR)/gtkjed @echo gtkjed created in $(OBJDIR) $(OBJDIR)/gtkjed : $(COMMON_OBJS) $(GTKJED_OBJS) cd $(OBJDIR); \ $(CC) $(COMMON_OFILES) $(GTKJED_OFILES) -o gtkjed $(COMMON_LIBS) $(GTKJED_LIBS) # rgrep: $(OBJDIR)/rgrep @echo rgrep created in $(OBJDIR) $(OBJDIR)/rgrep: $(OBJDIR)/vfile.o $(OBJDIR)/rgrep.o cd $(OBJDIR); $(CC) vfile.o rgrep.o -o rgrep $(LDFLAGS) $(RPATH) $(SLANG_LIB) -lslang $(TERMCAP_LIB) # getmail: $(OBJDIR)/getmail @echo getmail created in $(OBJDIR) $(OBJDIR)/getmail: $(OBJDIR)/getmail.o cd $(OBJDIR); $(CC) getmail.o -o getmail $(LDFLAGS) #--------------------------------------------------------------------------- $(TAGS_FILE_NAME): $(TAG_FILES) $(CTAGS_PGM) $(TAG_FILES) #--------------------------------------------------------------------------- clean: /bin/rm -f $(OBJDIR)/* *~ \#* distclean: clean /bin/rm -rf $(OBJDIR) Makefile sysconf.h config.h test/*.log install_data_directories: $(MKINSDIR) $(DEST_MAN_DIR) $(MKINSDIR) $(DEST_JED_ROOT) $(MKINSDIR) $(DEST_JED_ROOT)/doc $(MKINSDIR) $(DEST_JED_ROOT)/doc/txt $(MKINSDIR) $(DEST_JED_ROOT)/doc/hlp $(MKINSDIR) $(DEST_JED_ROOT)/doc/manual $(MKINSDIR) $(DEST_JED_ROOT)/lib $(MKINSDIR) $(DEST_JED_ROOT)/lib/colors $(MKINSDIR) $(DEST_JED_ROOT)/lib/colors/Xjed # $(MKINSDIR) $(DEST_INFO_DIR) install_bin_directories: $(MKINSDIR) $(DEST_BIN_DIR) # install_bin: install_bin_directories $(INSTALL) $(OBJDIR)/jed $(DEST_BIN_DIR)/ -cd $(DEST_BIN_DIR); ln -s jed jed-script -$(INSTALL) $(OBJDIR)/xjed $(DEST_BIN_DIR)/ if test -r $(OBJDIR)/getmail; \ then \ $(MKINSDIR) $(DEST_JED_ROOT)/bin; \ $(INSTALL) $(OBJDIR)/getmail $(DEST_JED_ROOT)/bin/; \ fi install_data: install_data_directories @for i in $(JED_LIB_FILES); \ do \ echo $(INSTALL_DATA) $$i $(DEST_JED_ROOT)/lib/; \ $(INSTALL_DATA) $$i $(DEST_JED_ROOT)/lib/; \ if [ "$$?" != "0" ]; then \ exit 1; \ fi; \ done @for i in $(JED_COLOR_FILES); \ do \ echo $(INSTALL_DATA) $$i $(DEST_JED_ROOT)/lib/colors/; \ $(INSTALL_DATA) $$i $(DEST_JED_ROOT)/lib/colors/; \ if [ "$$?" != "0" ]; then \ exit 1; \ fi; \ done @for i in $(XJED_COLOR_FILES); \ do \ echo $(INSTALL_DATA) $$i $(DEST_JED_ROOT)/lib/colors/Xjed/; \ $(INSTALL_DATA) $$i $(DEST_JED_ROOT)/lib/colors/Xjed/; \ if [ "$$?" != "0" ]; then \ exit 1; \ fi; \ done @for i in $(JED_MAN_FILES); \ do \ $(INSTALL_DATA) $$i $(DEST_MAN_DIR)/; \ echo $(INSTALL_DATA) $$i $(DEST_MAN_DIR)/; \ done @for i in $(JED_DOC_FILES); \ do \ $(INSTALL_DATA) $$i $(DEST_JED_ROOT)/doc/; \ echo $(INSTALL_DATA) $$i $(DEST_JED_ROOT)/doc/; \ done @for i in $(JED_DOC_TXT_FILES); \ do \ $(INSTALL_DATA) $$i $(DEST_JED_ROOT)/doc/txt; \ echo $(INSTALL_DATA) $$i $(DEST_JED_ROOT)/doc/txt; \ done @for i in $(JED_DOC_HLP_FILES); \ do \ $(INSTALL_DATA) $$i $(DEST_JED_ROOT)/doc/hlp; \ echo $(INSTALL_DATA) $$i $(DEST_JED_ROOT)/doc/hlp; \ done @for i in $(JED_DOC_MAN_FILES); \ do \ $(INSTALL_DATA) $$i $(DEST_JED_ROOT)/doc/manual; \ echo $(INSTALL_DATA) $$i $(DEST_JED_ROOT)/doc/manual; \ done # @for i in $(JED_INFO_FILES); \ # do \ # $(INSTALL_DATA) $$i $(DEST_INFO_DIR); \ # echo $(INSTALL_DATA) $$i $(DEST_INFO_DIR); \ # done install: all install_data install_bin # runtests: $(OBJDIR)/jed ./test/runtests.sh $(OBJDIR)/jed # The symlinks target is for my own private use. It simply creates the object # directory as a symbolic link to a local disk instead of an NFS mounted one. symlinks: -/bin/rm -f $(ARCH)objs mkdir -p $(HOME)/sys/$(ARCH)/objs/jed/src ln -s $(HOME)/sys/$(ARCH)/objs/jed/src $(ARCH)objs .PHONY: all install_bin install_data install_bin_directories install_data_directories #--------------------------------------------------------------------------- # Common object rules #--------------------------------------------------------------------------- $(OBJDIR)/buffer.o : $(SRCDIR)/buffer.c $(DOT_O_DEPS) $(buffer_O_DEP) cd $(OBJDIR); $(COMPILE_CMD) $(buffer_C_FLAGS) $(SRCDIR)/buffer.c $(OBJDIR)/cmds.o : $(SRCDIR)/cmds.c $(DOT_O_DEPS) $(cmds_O_DEP) cd $(OBJDIR); $(COMPILE_CMD) $(cmds_C_FLAGS) $(SRCDIR)/cmds.c $(OBJDIR)/misc.o : $(SRCDIR)/misc.c $(DOT_O_DEPS) $(misc_O_DEP) cd $(OBJDIR); $(COMPILE_CMD) $(misc_C_FLAGS) $(SRCDIR)/misc.c $(OBJDIR)/file.o : $(SRCDIR)/file.c $(DOT_O_DEPS) $(file_O_DEP) cd $(OBJDIR); $(COMPILE_CMD) $(file_C_FLAGS) $(SRCDIR)/file.c $(OBJDIR)/main.o : $(SRCDIR)/main.c $(DOT_O_DEPS) $(main_O_DEP) cd $(OBJDIR); $(COMPILE_CMD) $(main_C_FLAGS) $(SRCDIR)/main.c $(OBJDIR)/ins.o : $(SRCDIR)/ins.c $(DOT_O_DEPS) $(ins_O_DEP) cd $(OBJDIR); $(COMPILE_CMD) $(ins_C_FLAGS) $(SRCDIR)/ins.c $(OBJDIR)/sig.o : $(SRCDIR)/sig.c $(DOT_O_DEPS) $(sig_O_DEP) cd $(OBJDIR); $(COMPILE_CMD) $(sig_C_FLAGS) $(SRCDIR)/sig.c $(OBJDIR)/sysdep.o : $(SRCDIR)/sysdep.c $(DOT_O_DEPS) $(sysdep_O_DEP) cd $(OBJDIR); $(COMPILE_CMD) $(sysdep_C_FLAGS) $(SRCDIR)/sysdep.c $(OBJDIR)/screen.o : $(SRCDIR)/screen.c $(DOT_O_DEPS) $(screen_O_DEP) cd $(OBJDIR); $(COMPILE_CMD) $(screen_C_FLAGS) $(SRCDIR)/screen.c $(OBJDIR)/paste.o : $(SRCDIR)/paste.c $(DOT_O_DEPS) $(paste_O_DEP) cd $(OBJDIR); $(COMPILE_CMD) $(paste_C_FLAGS) $(SRCDIR)/paste.c $(OBJDIR)/ledit.o : $(SRCDIR)/ledit.c $(DOT_O_DEPS) $(ledit_O_DEP) cd $(OBJDIR); $(COMPILE_CMD) $(ledit_C_FLAGS) $(SRCDIR)/ledit.c $(OBJDIR)/line.o : $(SRCDIR)/line.c $(DOT_O_DEPS) $(line_O_DEP) cd $(OBJDIR); $(COMPILE_CMD) $(line_C_FLAGS) $(SRCDIR)/line.c $(OBJDIR)/search.o : $(SRCDIR)/search.c $(DOT_O_DEPS) $(search_O_DEP) cd $(OBJDIR); $(COMPILE_CMD) $(search_C_FLAGS) $(SRCDIR)/search.c $(OBJDIR)/text.o : $(SRCDIR)/text.c $(DOT_O_DEPS) $(text_O_DEP) cd $(OBJDIR); $(COMPILE_CMD) $(text_C_FLAGS) $(SRCDIR)/text.c $(OBJDIR)/keymap.o : $(SRCDIR)/keymap.c $(DOT_O_DEPS) $(keymap_O_DEP) cd $(OBJDIR); $(COMPILE_CMD) $(keymap_C_FLAGS) $(SRCDIR)/keymap.c $(OBJDIR)/replace.o : $(SRCDIR)/replace.c $(DOT_O_DEPS) $(replace_O_DEP) cd $(OBJDIR); $(COMPILE_CMD) $(replace_C_FLAGS) $(SRCDIR)/replace.c $(OBJDIR)/window.o : $(SRCDIR)/window.c $(DOT_O_DEPS) $(window_O_DEP) cd $(OBJDIR); $(COMPILE_CMD) $(window_C_FLAGS) $(SRCDIR)/window.c $(OBJDIR)/undo.o : $(SRCDIR)/undo.c $(DOT_O_DEPS) $(undo_O_DEP) cd $(OBJDIR); $(COMPILE_CMD) $(undo_C_FLAGS) $(SRCDIR)/undo.c $(OBJDIR)/vfile.o : $(SRCDIR)/vfile.c $(DOT_O_DEPS) $(vfile_O_DEP) cd $(OBJDIR); $(COMPILE_CMD) $(vfile_C_FLAGS) $(SRCDIR)/vfile.c $(OBJDIR)/intrin.o : $(SRCDIR)/intrin.c $(DOT_O_DEPS) $(intrin_O_DEP) cd $(OBJDIR); $(COMPILE_CMD) $(intrin_C_FLAGS) $(SRCDIR)/intrin.c $(OBJDIR)/syntax.o : $(SRCDIR)/syntax.c $(DOT_O_DEPS) $(syntax_O_DEP) cd $(OBJDIR); $(COMPILE_CMD) $(syntax_C_FLAGS) $(SRCDIR)/syntax.c $(OBJDIR)/abbrev.o : $(SRCDIR)/abbrev.c $(DOT_O_DEPS) $(abbrev_O_DEP) cd $(OBJDIR); $(COMPILE_CMD) $(abbrev_C_FLAGS) $(SRCDIR)/abbrev.c $(OBJDIR)/indent.o : $(SRCDIR)/indent.c $(DOT_O_DEPS) $(indent_O_DEP) cd $(OBJDIR); $(COMPILE_CMD) $(indent_C_FLAGS) $(SRCDIR)/indent.c $(OBJDIR)/jprocess.o : $(SRCDIR)/jprocess.c $(DOT_O_DEPS) $(jprocess_O_DEP) cd $(OBJDIR); $(COMPILE_CMD) $(jprocess_C_FLAGS) $(SRCDIR)/jprocess.c $(OBJDIR)/lineattr.o : $(SRCDIR)/lineattr.c $(DOT_O_DEPS) $(lineattr_O_DEP) cd $(OBJDIR); $(COMPILE_CMD) $(lineattr_C_FLAGS) $(SRCDIR)/lineattr.c $(OBJDIR)/blocal.o : $(SRCDIR)/blocal.c $(DOT_O_DEPS) $(blocal_O_DEP) cd $(OBJDIR); $(COMPILE_CMD) $(blocal_C_FLAGS) $(SRCDIR)/blocal.c $(OBJDIR)/mouse.o : $(SRCDIR)/mouse.c $(DOT_O_DEPS) $(mouse_O_DEP) cd $(OBJDIR); $(COMPILE_CMD) $(mouse_C_FLAGS) $(SRCDIR)/mouse.c $(OBJDIR)/menu.o : $(SRCDIR)/menu.c $(DOT_O_DEPS) $(menu_O_DEP) cd $(OBJDIR); $(COMPILE_CMD) $(menu_C_FLAGS) $(SRCDIR)/menu.c $(OBJDIR)/userinfo.o : $(SRCDIR)/userinfo.c $(DOT_O_DEPS) $(userinfo_O_DEP) cd $(OBJDIR); $(COMPILE_CMD) $(userinfo_C_FLAGS) $(SRCDIR)/userinfo.c $(OBJDIR)/lock.o : $(SRCDIR)/lock.c $(DOT_O_DEPS) $(lock_O_DEP) cd $(OBJDIR); $(COMPILE_CMD) $(lock_C_FLAGS) $(SRCDIR)/lock.c $(OBJDIR)/version.o : $(SRCDIR)/version.c $(DOT_O_DEPS) $(version_O_DEP) cd $(OBJDIR); $(COMPILE_CMD) $(version_C_FLAGS) $(SRCDIR)/version.c $(OBJDIR)/hooks.o : $(SRCDIR)/hooks.c $(DOT_O_DEPS) $(hooks_O_DEP) cd $(OBJDIR); $(COMPILE_CMD) $(hooks_C_FLAGS) $(SRCDIR)/hooks.c $(OBJDIR)/colors.o : $(SRCDIR)/colors.c $(DOT_O_DEPS) $(colors_O_DEP) cd $(OBJDIR); $(COMPILE_CMD) $(colors_C_FLAGS) $(SRCDIR)/colors.c $(OBJDIR)/display.o : $(SRCDIR)/display.c $(DOT_O_DEPS) $(display_O_DEP) cd $(OBJDIR); $(COMPILE_CMD) $(display_C_FLAGS) $(SRCDIR)/display.c $(OBJDIR)/jedwin.o : $(SRCDIR)/jedwin.c $(DOT_O_DEPS) $(jedwin_O_DEP) cd $(OBJDIR); $(COMPILE_CMD) $(jedwin_C_FLAGS) $(SRCDIR)/jedwin.c $(OBJDIR)/gpmmouse.o : $(SRCDIR)/gpmmouse.c $(DOT_O_DEPS) $(gpmmouse_O_DEP) cd $(OBJDIR); $(COMPILE_CMD) $(gpmmouse_C_FLAGS) $(SRCDIR)/gpmmouse.c $(OBJDIR)/vterm.o : $(SRCDIR)/vterm.c $(DOT_O_DEPS) $(vterm_O_DEP) cd $(OBJDIR); $(COMPILE_CMD) $(vterm_C_FLAGS) $(SRCDIR)/vterm.c $(OBJDIR)/xterm.o : $(SRCDIR)/xterm.c $(DOT_O_DEPS) $(xterm_O_DEP) cd $(OBJDIR); $(COMPILE_CMD) $(xterm_C_FLAGS) $(SRCDIR)/xterm.c #--------------------------------------------------------------------------- # GTK-jed rules #--------------------------------------------------------------------------- $(OBJDIR)/gtkmenu.o : $(SRCDIR)/gtkmenu.c $(DOT_O_DEPS) $(gtkmenu_O_DEP) cd $(OBJDIR); $(COMPILE_CMD) $(GTKJED_CFLAGS) $(gtkmenu_C_FLAGS) $(SRCDIR)/gtkmenu.c $(OBJDIR)/gtkwin.o : $(SRCDIR)/gtkwin.c $(DOT_O_DEPS) $(gtkwin_O_DEP) cd $(OBJDIR); $(COMPILE_CMD) $(GTKJED_CFLAGS) $(gtkwin_C_FLAGS) $(SRCDIR)/gtkwin.c $(OBJDIR)/gtkterm.o : $(SRCDIR)/gtkterm.c $(DOT_O_DEPS) $(gtkterm_O_DEP) cd $(OBJDIR); $(COMPILE_CMD) $(GTKJED_CFLAGS) $(gtkterm_C_FLAGS) $(SRCDIR)/gtkterm.c #--------------------------------------------------------------------------- # MISC rules #--------------------------------------------------------------------------- $(OBJDIR)/rgrep.o : $(SRCDIR)/rgrep.c $(DOT_O_DEPS) $(rgrep_O_DEP) cd $(OBJDIR); $(COMPILE_CMD) $(rgrep_C_FLAGS) $(SRCDIR)/rgrep.c $(OBJDIR)/getmail.o : $(SRCDIR)/getmail.c $(DOT_O_DEPS) $(getmail_O_DEP) cd $(OBJDIR); $(COMPILE_CMD) $(getmail_C_FLAGS) $(SRCDIR)/getmail.c jed-0.99-19/src/xterm.c0000644002657400265740000024714211311317447013576 0ustar davisdavis/* -*- mode: C; mode: fold; -*- */ /* Copyright (c) 1992, 1998, 2000, 2002, 2003, 2004, 2005, 2006 John E. Davis * This file is part of JED editor library source. * * You may distribute this file under the terms the GNU General Public * License. See the file COPYING for more information. */ #include "config.h" #include "jed-feat.h" #define USE_NEW_META_CODE 1 #define HAS_IBM_NUMLOCK_CODE 0 #define SKIP_LOCALE_CODE 0 #ifndef HAVE_SETLOCALE # define X_LOCALE 1 #endif #define XJED_USE_COMPOUND_TEXT 0 /*{{{ Include Files */ #ifndef VMS # include # include /* #include */ # include # include # include # include #ifndef XJED_HAS_XRENDERFONT # define XJED_HAS_XRENDERFONT 0 #endif # if XJED_HAS_XRENDERFONT # include # endif # if !SKIP_LOCALE_CODE # if XtSpecificationRelease >= 6 # define XJED_USE_R6IM # include # endif # endif #else # include # include /* #include */ # include # include # include #endif #include #include #include #include #include #include "jdmacros.h" /* #include "xterm.h"*/ #include "buffer.h" #include "display.h" #include "sysdep.h" #include "screen.h" #include "keymap.h" #include "hooks.h" #include "ins.h" #include "ledit.h" #include "misc.h" #include "cmds.h" #include "sig.h" #include "file.h" #include "vterm.h" #include "colors.h" /* Fixes some X headers... */ #ifndef Button6Mask # define Button6Mask (Button5Mask<<1) #endif /*}}}*/ /* X_HAVE_UTF8_STRING is defined in X11.h */ #if (SLANG_VERSION >= 20000) && defined(X_HAVE_UTF8_STRING) # define USE_XUTF8_CODE 1 #else # define USE_XUTF8_CODE 0 #endif /*{{{ Static Global Variables */ static int JX_Screen_Cols; static int JX_Screen_Rows; static int JX_Term_Cannot_Scroll = 0; static int JX_Term_Cannot_Insert = 0; static int JX_Use_Ansi_Colors = 1; static int JX_Ignore_Beep = 3; static int JX_Blink_Mode = 1; static int JX_MultiClick_Time = 500; /* milliseconds */ static int JX_MetaMask = Mod1Mask; #ifdef XJED_USE_R6IM static char *R6IM_Input_Method = NULL; static XIMStyle R6IM_Input_Style = 0; static char *R6IM_Preedit_Type = "Root"; static XIC R6IM_Xic; static void i18init(void); static XPoint R6IM_Spot; static XVaNestedList R6IM_Preedit_Attr; static void move_input_position (void); static void set_geometry (XEvent *, XIMStyle, char *); #endif static char *The_Xserver_Vendor; /* static int Current_Color; */ static int X_Alt_Char = 27; static KeySym X_Last_Keysym; static int X_Warp_Pending = 0; typedef struct /*{{{*/ { GC gc; unsigned long fg, bg; char *fg_name; char *bg_name; int dirty; } /*}}}*/ GC_Info_Type; typedef struct /*{{{*/ { Window w; Atom wm_del_win; /* delete window protocol */ int height, width; int border; /* inside border */ int o_border; /* outside border */ Colormap color_map; /* font information */ XFontStruct *font; char *font_name; int font_height, font_width, font_base; int is_dual_font; /* if both single and double width */ #if XJED_HAS_XRENDERFONT XftFont *xftfont; XftDraw *xftdraw; double face_size; #endif /* GC info */ GC_Info_Type *text_gc; GC_Info_Type *current_gc; int vis_curs_row, vis_curs_col; /* position of VISIBLE cursor */ /* flags */ int cursor_showing; /* true if widow has cursor showing */ int focus; /* true if window has focus */ int window_mapped; /* true if window is mapped */ /* Window tty parameters */ int insert_mode; /* true if inserting */ int scroll_r1, scroll_r2; /* scrolling region */ int cursor_row, cursor_col; /* row column of cursor (0, 0) origin */ int visible; /* from visibilitynotify */ Cursor mouse; } /*}}}*/ JXWindow_Type; static JXWindow_Type XWin_Buf; static JXWindow_Type *XWin; static Display *This_XDisplay; static Window This_XWindow; static int This_XScreen; static int Performing_Update; static int Check_Buffers_Pending; static int No_XEvents; /* if true, do nothing */ typedef struct /*{{{*/ { char *name; char *name1; int type; char *value; char **dflt; } /*}}}*/ XWindow_Arg_Type; #define XJED_CLASS "XTerm" static char *This_App_Name = "xjed"; static char *This_App_Title = "XJed"; /* #define Default_Geometry "80x24+0-0" */ #define Default_Geometry "80x24" static char *This_Geometry = NULL; static char *This_Font_Name = "fixed"; #if XJED_HAS_XRENDERFONT static char *This_Face_Size = " "; #endif static char *This_Border_Width_Name = "0"; static char *This_Internal_Border_Name = "0"; static char *This_MFG = "green"; static char *This_MBG = "white"; static char *Iconic = NULL; static Atom Xjed_Prop; static Atom Compound_Text_Atom; static Atom UTF8_String_Atom; static Atom Text_Atom; static Atom Targets_Atom; static XEvent Current_Event; static char *Selection_Send_Data = NULL; static int receive_selection (XEvent *); static int send_selection (XEvent *); static GC_Info_Type Default_GC_Info[JMAX_COLORS] = /*{{{*/ { {NULL, 0, 0, "black", "white",0}, /* NORMAL */ {NULL, 0, 0, "green", "red",0}, /* CURSOR */ {NULL, 0, 0, "default", "skyblue",0}, /* STATUS */ {NULL, 0, 0, "default", "magenta",0}, /* REGION */ {NULL, 0, 0, "default", "skyblue",0}, /* MENU */ {NULL, 0, 0, "default", "default",0}, /* operator */ {NULL, 0, 0, "green", "default",0}, /* numbers */ {NULL, 0, 0, "blue", "default",0}, /* strings */ {NULL, 0, 0, "default", "gray",0}, /* comments */ {NULL, 0, 0, "default", "default",0}, /* delimeters */ {NULL, 0, 0, "magenta", "default",0}, /* preprocess */ {NULL, 0, 0, "blue", "default",0}, /* message */ {NULL, 0, 0, "red", "default",0}, /* error */ {NULL, 0, 0, "magenta", "default",0}, /* dollar */ {NULL, 0, 0, "red", "default",0}, /* keyword */ {NULL, 0, 0, "green", "default",0}, /* keyword1 */ {NULL, 0, 0, "red", "default",0}, /* keyword2 */ {NULL, 0, 0, "green", "default",0} /* ... fold mark */ }; /*}}}*/ /* cheat a little, use VOID_TYPE for boolean arguments */ static XWindow_Arg_Type X_Arg_List[] = /*{{{*/ { /* These MUST be in this order!!! */ #define XARG_DISPLAY 0 {"Display", "d", STRING_TYPE, NULL, NULL}, #define XARG_NAME 1 {"Name", NULL, STRING_TYPE, NULL, &This_App_Name}, #define XARG_GEOMETRY 2 {"Geometry", NULL, STRING_TYPE, NULL, &This_Geometry}, #define XARG_START 2 /* Note: it's good to look for * `font', `background', `foreground' * instead of * `Font', `background', `foreground' * so that XTerm names can be used * (resource vs. class names) * * also, change order of names a little? */ {"font", "fn", STRING_TYPE, NULL, &This_Font_Name}, {"fgMouse", "mfg", STRING_TYPE, NULL, &This_MFG}, {"bgMouse", "mbg", STRING_TYPE, NULL, &This_MBG}, {"background", "bg", STRING_TYPE, NULL, &Default_GC_Info[JNORMAL_COLOR].bg_name}, {"foreground", "fg", STRING_TYPE, NULL, &Default_GC_Info[JNORMAL_COLOR].fg_name}, {"fgStatus", "sfg", STRING_TYPE, NULL, &Default_GC_Info[JSTATUS_COLOR].fg_name}, {"bgStatus", "sbg", STRING_TYPE, NULL, &Default_GC_Info[JSTATUS_COLOR].bg_name}, {"fgRegion", "rfg", STRING_TYPE, NULL, &Default_GC_Info[JREGION_COLOR].fg_name}, {"bgRegion", "rbg", STRING_TYPE, NULL, &Default_GC_Info[JREGION_COLOR].bg_name}, {"fgCursor", "cfg", STRING_TYPE, NULL, &Default_GC_Info[JCURSOR_COLOR].fg_name}, {"bgCursor", "cbg", STRING_TYPE, NULL, &Default_GC_Info[JCURSOR_COLOR].bg_name}, {"fgCursorOvr", "cofg", STRING_TYPE, NULL, &Default_GC_Info[JCURSOROVR_COLOR].fg_name}, {"bgCursorOvr", "cobg", STRING_TYPE, NULL, &Default_GC_Info[JCURSOROVR_COLOR].bg_name}, {"fgMenu", "fgm", STRING_TYPE, NULL, &Default_GC_Info[JMENU_COLOR].fg_name}, {"bgMenu", "bgm", STRING_TYPE, NULL, &Default_GC_Info[JMENU_COLOR].bg_name}, {"fgOperator", "fgop", STRING_TYPE, NULL, &Default_GC_Info[JOP_COLOR].fg_name}, {"bgOperator", "bgop", STRING_TYPE, NULL, &Default_GC_Info[JOP_COLOR].bg_name}, {"fgNumber", "fgnm", STRING_TYPE, NULL, &Default_GC_Info[JNUM_COLOR].fg_name}, {"bgNumber", "bgnm", STRING_TYPE, NULL, &Default_GC_Info[JNUM_COLOR].bg_name}, {"fgString", "fgst", STRING_TYPE, NULL, &Default_GC_Info[JSTR_COLOR].fg_name}, {"bgString", "bgst", STRING_TYPE, NULL, &Default_GC_Info[JSTR_COLOR].bg_name}, {"fgComments", "fgco", STRING_TYPE, NULL, &Default_GC_Info[JCOM_COLOR].fg_name}, {"bgComments", "bgco", STRING_TYPE, NULL, &Default_GC_Info[JCOM_COLOR].bg_name}, {"fgKeyword", "fgkw", STRING_TYPE, NULL, &Default_GC_Info[JKEY_COLOR].fg_name}, {"bgKeyword", "bgkw", STRING_TYPE, NULL, &Default_GC_Info[JKEY_COLOR].bg_name}, {"fgKeyword1", "fgkw1",STRING_TYPE, NULL, &Default_GC_Info[JKEY_COLOR + 1].fg_name}, {"bgKeyword1", "bgkw1",STRING_TYPE, NULL, &Default_GC_Info[JKEY_COLOR + 1].bg_name}, {"fgKeyword2", "fgkw2",STRING_TYPE, NULL, &Default_GC_Info[JKEY_COLOR + 2].fg_name}, {"bgKeyword2", "bgkw2",STRING_TYPE, NULL, &Default_GC_Info[JKEY_COLOR + 2].bg_name}, {"fgDelimiter", "fgde", STRING_TYPE, NULL, &Default_GC_Info[JDELIM_COLOR].fg_name}, {"bgDelimiter", "bgde", STRING_TYPE, NULL, &Default_GC_Info[JDELIM_COLOR].bg_name}, {"fgPreprocess", "fgpr", STRING_TYPE, NULL, &Default_GC_Info[JPREPROC_COLOR].fg_name}, {"bgPreprocess", "bgpr", STRING_TYPE, NULL, &Default_GC_Info[JPREPROC_COLOR].bg_name}, {"bgMessage", "bgms", STRING_TYPE, NULL, &Default_GC_Info[JMESSAGE_COLOR].bg_name}, {"fgMessage", "fgms", STRING_TYPE, NULL, &Default_GC_Info[JMESSAGE_COLOR].fg_name}, {"bgError", "bger", STRING_TYPE, NULL, &Default_GC_Info[JERROR_COLOR].bg_name}, {"fgError", "fger", STRING_TYPE, NULL, &Default_GC_Info[JERROR_COLOR].fg_name}, {"fgDots", "fgdt", STRING_TYPE, NULL, &Default_GC_Info[JDOTS_COLOR].bg_name}, {"bgDots", "bgdt", STRING_TYPE, NULL, &Default_GC_Info[JDOTS_COLOR].bg_name}, {"BorderWidth", "bw", STRING_TYPE, NULL, &This_Border_Width_Name}, {"title", NULL, STRING_TYPE, NULL, &This_App_Title}, {"BorderColor", "bd", STRING_TYPE, NULL, NULL}, {"Iconic", "ic", VOID_TYPE, NULL, &Iconic}, {"xrm", NULL, STRING_TYPE, NULL, NULL}, {"internalBorder", "ib", STRING_TYPE, NULL, &This_Internal_Border_Name}, #ifdef XJED_USE_R6IM {"inputMethod", "im", STRING_TYPE, NULL, &R6IM_Input_Method}, {"inputStyle", "is", STRING_TYPE, NULL, &R6IM_Preedit_Type}, #endif #if XJED_HAS_XRENDERFONT {"facesize", "fs", STRING_TYPE, NULL, &This_Face_Size}, #endif {NULL, NULL, 0, NULL, NULL} }; /*}}}*/ /*}}}*/ #if XJED_HAS_XRENDERFONT static XftColor *Pixel2XftColor (Pixel pixel) { # define CACHE_SIZE 40 static struct { XftColor color; unsigned long use; } cache[CACHE_SIZE]; static unsigned long use; unsigned int i; unsigned long oldest, oldestuse; XColor color; oldestuse = (unsigned long) -1L; oldest = 0; for (i = 0; i < CACHE_SIZE; i++) { if (cache[i].use) { if (cache[i].color.pixel == pixel) { cache[i].use = ++use; return &cache[i].color; } } if (cache[i].use < oldestuse) { oldestuse = cache[i].use; oldest = i; } } i = oldest; color.pixel = pixel; XQueryColor (This_XDisplay, XWin->color_map, &color); cache[i].color.color.red = color.red; cache[i].color.color.green = color.green; cache[i].color.color.blue = color.blue; cache[i].color.color.alpha = 0xffff; cache[i].color.pixel = pixel; cache[i].use = ++use; return &cache[i].color; } #endif #if SLANG_VERSION >= 20000 /* conversion tools */ /* wchars to XChar2b for X drawing */ static XChar2b *wchars_to_XChar2b(SLwchar_Type *w, unsigned int nchars) { unsigned int i; XChar2b *x = (XChar2b *)SLmalloc(nchars*sizeof(XChar2b)); if (x == NULL) return NULL; for (i = 0; i < nchars; i++) { SLwchar_Type w_i = w[i]; if (w_i > 0xFFFF) w_i = '?'; x[i].byte2 = (unsigned char)(w_i & 0xFF); x[i].byte1 = (unsigned char)((w_i >> 8 )& 0xFF); } return x; } static SLwchar_Type *bytes_to_wchars (unsigned char *s, unsigned int nchars) { unsigned int i; SLwchar_Type *w = (SLwchar_Type *)SLmalloc(nchars*sizeof(SLwchar_Type)); if (w == NULL) return NULL; for (i = 0; i < nchars; i++) w[i] = s[i]; return w; } static SLwchar_Type *utf8nt_to_wchars(unsigned char *s, unsigned int len, unsigned int *ncharsp) { SLwchar_Type *w; unsigned int i, nchars; unsigned char *smax; nchars = SLutf8_strlen(s, 0); if (NULL == (w = (SLwchar_Type *)SLmalloc(nchars*sizeof(SLwchar_Type)))) { *ncharsp = 0; return NULL; } smax = s + len; for (i = 0; i < nchars; i++) { unsigned int n; if (SLutf8_decode(s, smax, &w[i], &n) == NULL) w[i] = '?'; s += n; } *ncharsp = nchars; return w; } # define SLSMGCHAR_EQUAL(o, n) \ (((o)->nchars == (n)->nchars) \ && ((o)->color == (n)->color) \ && (0 == memcmp((o)->wchars, (n)->wchars, (n)->nchars * sizeof(SLwchar_Type)))) # define SLSMGCHAR_SET_CHAR(sc, _char) \ do { (sc).nchars = 1; (sc).wchars[0] = (_char); } while (0) # define SLSMGCHAR_SET_COLOR(sc, _color) \ (sc).color = (_color) # define SLSMG_COUNT_CHARS(sc) ((sc).nchars) #else /* SLang1 versions */ # define SLSMGCHAR_EQUAL(o, n) ((o) == (n)) # ifdef SLSMG_HLINE_CHAR_UNICODE /* Grrr.... hack for the slang1-utf8 version hacked by RedHat and SuSE... */ # define SLSMGCHAR_SET_CHAR(sc, _char) (sc) = ((sc) & 0xFF000000) + (_char) # define SLSMGCHAR_SET_COLOR(sc, _color) (sc) = ((sc) & 0xFF) + ((_color)<<24) # else # define SLSMGCHAR_SET_CHAR(sc, _char) (sc) = ((sc) & 0xFF00) + (_char) # define SLSMGCHAR_SET_COLOR(sc, _color) (sc) = ((sc) & 0xFF) + ((_color)<<8) # endif # define SLSMG_COUNT_CHARS(sc) (1) /* These exist in SLang 2 include, but not on SLang 1. Define here to allow * using the same code */ # define SLSMG_COLOR_MASK 0xFF # define SLwchar_Type char #endif /* SLANG_VERSION >= 20000 */ /* This function does the low-level drawing. * It can draw the new text, but setting 'overimpose' to 1 it draws the string * over the existing text (used for unicode combining characters). * It can use Xft (if configured), or plain X functions. */ static int xdraw (GC_Info_Type *gc, int row, int col, SLwchar_Type *w, int nchars, int overimpose) { int b = XWin->border; int x = col * XWin->font_width; int y = row * XWin->font_height; #if XJED_HAS_XRENDERFONT if ((XWin->face_size > 0) && (XWin->xftdraw != NULL)) { /* if (!XWin->xftdraw) */ /* XWin->xftdraw = XftDrawCreate(This_XDisplay, This_XWindow, DefaultVisual(This_XDisplay, This_XScreen), XWin->color_map); */ if (overimpose == 0) XftDrawRect (XWin->xftdraw, Pixel2XftColor(gc->bg), x + b, y, nchars * XWin->font_width, XWin->font_height); # if SLANG_VERSION >= 20000 XftDrawString32 (XWin->xftdraw, Pixel2XftColor(gc->fg), XWin->xftfont, x + b, y + b + XWin->font_base, w, nchars); # else XftDrawString8 (XWin->xftdraw, Pixel2XftColor(gc->fg), XWin->xftfont, x + b, y + b + XWin->font_base, (unsigned char *)w, nchars); # endif return 0; } #endif /* XJED_HAS_XRENDERFONT */ #if SLANG_VERSION >= 20000 { XChar2b *d = wchars_to_XChar2b (w, nchars); if (d == NULL) return -1; if (overimpose) XDrawString16(This_XDisplay, This_XWindow, gc->gc, x + b, y + b + XWin->font_base, d, nchars); else XDrawImageString16(This_XDisplay, This_XWindow, gc->gc, x + b, y + b + XWin->font_base, d, nchars); SLfree((char *)d); return 0; } #else /* Standard X, SLang 1 */ { if (overimpose) XDrawString(This_XDisplay, This_XWindow, gc->gc, x + b, y + b + XWin->font_base, w, nchars); else XDrawImageString(This_XDisplay, This_XWindow, gc->gc, x + b, y + b + XWin->font_base, w, nchars); return 0; } #endif } /* Get 'n' characters from SLSMG screen, at position ('row', 'col'). */ static unsigned int smg_read_at(int row, int col, SLsmg_Char_Type *s, unsigned int n) { int saverow, savecol; unsigned int rc; saverow = SLsmg_get_row (); savecol = SLsmg_get_column (); SLsmg_gotorc(row, col); rc = SLsmg_read_raw (s, n); SLsmg_gotorc (saverow, savecol); return rc; } /* Write to screen a single SLsmg_Char, handling combining characters * (X doesn't seem to handle these...) to position (row, col). * This function doesn't touch the cursor position. */ static void JX_write_smgchar (int row, int col, SLsmg_Char_Type *s) { int color = SLSMG_EXTRACT_COLOR(*s) & SLSMG_COLOR_MASK; if ((color >= JMAX_COLORS) || (color < 0)) color = 0; #if SLANG_VERSION >= 20000 if (s->nchars > 0) (void) xdraw (XWin->text_gc + color, row, col, s->wchars, 1, 0); if (Jed_UTF8_Mode) { unsigned int i; for (i = 1; i < s->nchars; i++) (void) xdraw(XWin->text_gc+color, row, col, &s->wchars[i], 1, 1); } #else { SLwchar_Type ch = SLSMG_EXTRACT_CHAR(*s); (void) xdraw(XWin->text_gc+color, row, col, &ch, 1, 0); } #endif } /* Write to screen a row of SLsmg_Chars, handling combining characters * (X doesn't seem to handle these...) to position (row, col). * This function doesn't touch the cursor position. */ static void JX_write_smgchars(int row, int col, SLsmg_Char_Type *s, SLsmg_Char_Type *smax) { SLwchar_Type *b, *bend, buf[512]; int oldcolor, color; SLsmg_Char_Type *s0; int is_dual_font; b = buf; bend = buf + 510; oldcolor = (SLSMG_EXTRACT_COLOR(*s) & SLSMG_COLOR_MASK); if ((oldcolor < 0) || (oldcolor >= JMAX_COLORS)) oldcolor = 0; is_dual_font = XWin->is_dual_font; s0 = s; while (s < smax) { color = (SLSMG_EXTRACT_COLOR(*s) & SLSMG_COLOR_MASK); if ((color < 0) || (color >= JMAX_COLORS)) color = 0; if (oldcolor != color /* Color changed. */ || (b >= bend) /* Space finished */ || SLSMG_COUNT_CHARS(*s) > 1) /* a combining character */ { (void) xdraw(XWin->text_gc+oldcolor, row, col, buf, b-buf, 0); col += (int)(s-s0); s0 = s; b = buf; oldcolor = color; } #if SLANG_VERSION >= 20000 if (s->nchars > 1) { /* this cell has combining characters */ JX_write_smgchar(row, col, s); col++; s0 = s + 1; } else if (s->nchars == 0) { /* SLsmg thinks this is a double width character, but the font has no such characters */ if (is_dual_font == 0) *b++ = ' '; } else #endif *b++ = SLSMG_EXTRACT_CHAR(*s); s++; } if (b != buf) (void) xdraw(XWin->text_gc+color, row, col, buf, b-buf, 0); } static void hide_cursor (void) /*{{{*/ { SLsmg_Char_Type sc; if (No_XEvents || (XWin->cursor_showing == 0)) return; XWin->cursor_showing = 0; if (0 == smg_read_at (XWin->vis_curs_row, XWin->vis_curs_col, &sc, 1)) { SLSMGCHAR_SET_CHAR(sc, ' '); SLSMGCHAR_SET_COLOR(sc, JNORMAL_COLOR); } JX_write_smgchar(XWin->vis_curs_row, XWin->vis_curs_col, &sc); } /*}}}*/ static void copy_rect(int x1, int y1, int x2, int y2, int x3, int y3) /*{{{*/ { int w, h; if (No_XEvents || (XWin->window_mapped == 0)) return; w = (x2 - x1) * XWin->font_width; h = (y2 - y1) * XWin->font_height; if ((w <= 0) || (h <= 0)) return; x3 = XWin->border + x3 * XWin->font_width; x1 = XWin->border + x1 * XWin->font_width; y3 = XWin->border + y3 * XWin->font_height; y1 = XWin->border + y1 * XWin->font_height; hide_cursor (); XCopyArea (This_XDisplay, This_XWindow, This_XWindow, XWin->current_gc->gc, x1, y1, w, h, x3, y3); } /*}}}*/ static void blank_rect (int x1, int y1, int x2, int y2) /*{{{*/ { int w, h; if (No_XEvents || (XWin->window_mapped == 0)) return; w = (x2 - x1) * XWin->font_width; h = (y2 - y1) * XWin->font_height; if ((w <= 0) || (h <= 0)) return; x1 = XWin->border + x1 * XWin->font_width; y1 = XWin->border + y1 * XWin->font_height; hide_cursor (); XClearArea (This_XDisplay, This_XWindow, x1, y1, w, h, 0); } /*}}}*/ static void JX_set_scroll_region(int r1, int r2) /*{{{*/ { XWin->scroll_r1 = r1; XWin->scroll_r2 = r2; /* vterm_set_scroll_region (r1, r2); */ } /*}}}*/ static void JX_reset_scroll_region (void) /*{{{*/ { JX_set_scroll_region (0, JX_Screen_Rows - 1); } /*}}}*/ static void show_cursor (void) /*{{{*/ { SLsmg_Char_Type sc; int row, col, b; int color; GC_Info_Type *gc_info; GC gc; XGCValues gcv; if (No_XEvents) return; if (XWin->cursor_showing) hide_cursor (); XWin->cursor_showing = 1; row = XWin->vis_curs_row = XWin->cursor_row; col = XWin->vis_curs_col = XWin->cursor_col; b = XWin->border; if ((CBuf != NULL) && (CBuf->flags & OVERWRITE_MODE)) color = JCURSOROVR_COLOR; else color = JCURSOR_COLOR; gc_info = &XWin->text_gc[color]; gc = gc_info->gc; if (XWin->focus) { /* restore the modified GC */ if (gc_info->dirty) { gc_info->dirty = 0; gcv.foreground = gc_info->fg; gcv.background = gc_info->bg; XChangeGC(This_XDisplay, gc, GCForeground | GCBackground, &gcv); } if (smg_read_at(row, col, &sc, 1) == 0) SLSMGCHAR_SET_CHAR(sc, ' '); SLSMGCHAR_SET_COLOR(sc, color); JX_write_smgchar(row, col, &sc); } else { gc_info->dirty = 1; gcv.foreground = gc_info->bg; gcv.background = gc_info->fg; XChangeGC(This_XDisplay, gc, GCForeground | GCBackground, &gcv); XDrawRectangle(This_XDisplay, This_XWindow, gc, col * XWin->font_width + b, row * XWin->font_height + b, XWin->font_width - 1, XWin->font_height - 1); } XFlush(This_XDisplay); } /*}}}*/ static void toggle_cursor (int on) /*{{{*/ { if (on) { if (XWin->focus) return; XWin->focus = 1; } else { if (XWin->focus == 0) return; XWin->focus = 0; } show_cursor (); } /*}}}*/ /* This routine assumes that cursor is in the correct location. The * cursor is placed at the end of the string. Even if we are unable to * write the string, make sure that the cursor is moved as if we did * the write. The main reason for this is that our X cursor must track * the vterm cursor so that the display gets updated properly. * Otherwise, smart_puts will call forward_cursor and then write to the * virtual display, and get that wrong because forward_cursor assumes * that the XWin cursor is correct. */ static void JX_write_string (char *s) /*{{{*/ { unsigned int nchars; SLwchar_Type *w; unsigned int nbytes = strlen(s); #if SLANG_VERSION >= 20000 if (Jed_UTF8_Mode) w = utf8nt_to_wchars((unsigned char *)s, nbytes, &nchars); else { w = bytes_to_wchars((unsigned char *)s, nbytes); nchars = nbytes; } if (w == NULL) goto write_done; #else nchars = nbytes; w = s; #endif if ((No_XEvents == 0) && XWin->window_mapped) { hide_cursor (); (void) xdraw(XWin->current_gc, XWin->cursor_row, XWin->cursor_col, w, nchars, 0); } #if SLANG_VERSION >= 20000 SLfree((char *)w); write_done: #endif XWin->cursor_col += nchars; if (XWin->cursor_col >= JX_Screen_Cols) XWin->cursor_col = JX_Screen_Cols - 1; if (!Performing_Update) show_cursor (); } static void JX_goto_rc(int r, int c) /*{{{*/ { if (XWin == NULL) return; if (XWin->cursor_showing) hide_cursor (); if (r >= JX_Screen_Rows) r = JX_Screen_Rows - 1; if (c >= JX_Screen_Cols) c = JX_Screen_Cols - 1; XWin->cursor_row = r + XWin->scroll_r1; XWin->cursor_col = c; /* vterm_goto_rc (r, c); */ if (Performing_Update) return; show_cursor (); } /*}}}*/ /* Must respect scrolling region */ static void JX_delete_nlines(int n) /*{{{*/ { int r1, r2; /* vterm_delete_nlines (n); */ if (No_XEvents || (XWin->window_mapped == 0)) return; r1 = XWin->cursor_row; r2 = XWin->scroll_r2; if (r1 <= r2 - n) copy_rect(0, r1 + n, JX_Screen_Cols, r2 + 1, 0, r1); r2++; blank_rect(0, r2 - n, JX_Screen_Cols, r2); } /*}}}*/ static void JX_reverse_index(int n) /*{{{*/ { int r1, r2; /* vterm_reverse_index (n); */ if (No_XEvents || (XWin->window_mapped == 0)) return; r1 = XWin->scroll_r1; r2 = XWin->scroll_r2; if (r2 >= r1 + n) copy_rect(0, r1, JX_Screen_Cols, r2 - n + 1, 0, r1 + n); blank_rect(0, r1, JX_Screen_Cols, r1 + n); } /*}}}*/ static void JX_beep(void) /*{{{*/ { GC gc; XGCValues gcv; if (No_XEvents) return; flush_input(); if (JX_Ignore_Beep & 0x1) XBell (This_XDisplay, 50); /* visible bell */ if (JX_Ignore_Beep & 0x2) { gc = XCreateGC(This_XDisplay, This_XWindow, 0, &gcv); XSetState(This_XDisplay, gc, WhitePixel (This_XDisplay, This_XScreen), BlackPixel(This_XDisplay, This_XScreen), GXinvert, AllPlanes); XFillRectangle (This_XDisplay, This_XWindow, gc, 0, 0, XWin->font_width * JX_Screen_Cols, XWin->font_height * JX_Screen_Rows); XFlush (This_XDisplay); /* I attempted to put a pause in here but it was too slow. */ XFillRectangle (This_XDisplay, This_XWindow, gc, 0, 0, XWin->font_width * JX_Screen_Cols, XWin->font_height * JX_Screen_Rows); XFreeGC(This_XDisplay, gc); } XFlush (This_XDisplay); } /*}}}*/ static void JX_del_eol(void) /*{{{*/ { /* vterm_del_eol (); */ if (No_XEvents || (XWin->window_mapped == 0)) return; blank_rect(XWin->cursor_col, XWin->cursor_row, JX_Screen_Cols, XWin->cursor_row + 1); } /*}}}*/ static void JX_reverse_video(int color) /*{{{*/ { if ((color < 0) || (color >= JMAX_COLORS)) return; if (XWin == NULL) return; /* Current_Color = color; */ XWin->current_gc = XWin->text_gc + color; /* vterm_reverse_video (color); */ } /*}}}*/ static void JX_normal_video(void) /*{{{*/ { JX_reverse_video (JNORMAL_COLOR); } /*}}}*/ static void JX_smart_puts(SLsmg_Char_Type *neww, SLsmg_Char_Type *oldd, int len, int row) { int col; /* Skip equal chars at the beginning */ col = 0; while ((col < len) && SLSMGCHAR_EQUAL(&neww[col], &oldd[col])) col++; if (col < len) { hide_cursor(); JX_write_smgchars(row, col, neww+col, neww+len); JX_goto_rc (row, len); } } /*}}}*/ static void cover_exposed_area (int x, int y, int width, int height, int count) /*{{{*/ { SLsmg_Char_Type *s; int row, max_col, max_row, col; int width_chars, len; Performing_Update++; /* VTerm_Suspend_Update++; */ hide_cursor (); col = (x - XWin->border) / XWin->font_width; row = (y - XWin->border) / XWin->font_height; width_chars = 2 + width / XWin->font_width; max_col = col + width_chars; max_row = 2 + row + height / XWin->font_height; if (max_col > JX_Screen_Cols) max_col = JX_Screen_Cols; if (max_row > JX_Screen_Rows) max_row = JX_Screen_Rows; if (NULL != (s = (SLsmg_Char_Type *)SLmalloc(width_chars*sizeof(SLsmg_Char_Type)))) { while (row < max_row) { len = smg_read_at(row, col, s, width_chars); JX_write_smgchars(row, col, s, s + len); row++; } SLfree ((char *)s); } Performing_Update--; if (count == 0) show_cursor (); } /*}}}*/ #include "xkeys.c" /* Return 1 if event is listed in the switch or zero otherwise. The switch * events are considered harmless--- that is, processing them does not really * interfere with internal JED state (redisplay, etc...). More bluntly, * harmless means that the events can be processesed while checking for * pending input. */ static int Debug_Xjed = 0; static int x_handle_harmless_events (XEvent *report) /*{{{*/ { switch (report->type) { case EnterNotify: toggle_cursor(report->xcrossing.focus); break; case LeaveNotify: /* toggle_cursor(0); */ break; case UnmapNotify: XWin->window_mapped = 0; break; case MapNotify: XWin->window_mapped = 1; break; case FocusIn: toggle_cursor(1); #ifdef XJED_USE_R6IM if (NULL != R6IM_Xic) XSetICFocus (R6IM_Xic); #endif Check_Buffers_Pending = 1; break; case FocusOut: toggle_cursor(0); #ifdef XJED_USE_R6IM if (NULL != R6IM_Xic) XUnsetICFocus (R6IM_Xic); #endif break; case VisibilityNotify: XWin->visible = report->xvisibility.state; break; case GraphicsExpose: cover_exposed_area (report->xgraphicsexpose.x, report->xgraphicsexpose.y, report->xgraphicsexpose.width, report->xgraphicsexpose.height, report->xgraphicsexpose.count); break; case ConfigureNotify: if ((report->xconfigure.height == XWin->height) && (report->xconfigure.width == XWin->width)) break; XWin->width = report->xconfigure.width; XWin->height = report->xconfigure.height; jed_init_display (); jed_redraw_screen (1); break; case Expose: cover_exposed_area (report->xexpose.x, report->xexpose.y, report->xexpose.width, report->xexpose.height, report->xexpose.count); break; case ReparentNotify: case NoExpose: break; case KeyPress: /* Just look for Modifier key presses */ #ifdef XJED_USE_R6IM if (R6IM_Xic && (R6IM_Input_Style & XIMPreeditPosition)) move_input_position (); #endif return IsModifierKey (XLookupKeysym (&report->xkey, 0)); case SelectionNotify: (void) receive_selection (report); if (Performing_Update == 0) update_cmd (&Number_One); break; default: if (Debug_Xjed) fprintf(stderr, "harmless: %d\n", report->type); return 0; } return 1; } /*}}}*/ static void fill_jmouse (JMouse_Type *jmouse, /*{{{*/ unsigned char type, int x, int y, unsigned long t, unsigned int button, unsigned int state) { unsigned char s; #if JED_HAS_MULTICLICK static unsigned long last_press_time; static unsigned int clicks; static unsigned int last_button; if (type == JMOUSE_DOWN) { if ((last_button == button) && (last_press_time + JX_MultiClick_Time > t)) { clicks++; if (clicks == 2) type = JMOUSE_DOUBLE_CLICK; else type = JMOUSE_TRIPLE_CLICK; } else { clicks = 1; last_button = button; } last_press_time = t; } else if ((clicks > 1) && (last_button == button)) { /* Last was a multi-click. Ignore this event. */ type = JMOUSE_IGNORE_EVENT; } #endif jmouse->type = type; jmouse->x = 1 + (x - XWin->border) / XWin->font_width; if (y < XWin->border) jmouse->y = 0; else jmouse->y = 1 + (y - XWin->border) / XWin->font_height; if (button == Button1) jmouse->button = JMOUSE_BUTTON_1; else if (button == Button2) jmouse->button = JMOUSE_BUTTON_2; else if (button == Button3) jmouse->button = JMOUSE_BUTTON_3; else if (button == Button4) jmouse->button = JMOUSE_BUTTON_4; else if (button == Button5) jmouse->button = JMOUSE_BUTTON_5; else jmouse->button = JMOUSE_BUTTON_6; s = 0; if (state & Button1Mask) s |= JMOUSE_BUTTON_1; if (state & Button2Mask) s |= JMOUSE_BUTTON_2; if (state & Button3Mask) s |= JMOUSE_BUTTON_3; if (state & Button4Mask) s |= JMOUSE_BUTTON_4; if (state & Button5Mask) s |= JMOUSE_BUTTON_5; if (state & Button6Mask) s |= JMOUSE_BUTTON_5; if (state & ShiftMask) s |= JMOUSE_SHIFT; if (state & ControlMask) s |= JMOUSE_CTRL; jmouse->state = s; } /*}}}*/ #define MOUSE_DRAG_THRESHOLD 3 /* if force is true, wait for an event. If force is false, only * process events that exist. This will return either when there * are no more events or a key/mouse event is processed returning * 1 in the process */ static int X_process_events (int force, char *buf, unsigned int buflen, int *n_chars) /*{{{*/ { XEvent report; JMouse_Type jmouse; int ch1; int block_expose = 0; char *bufp; KeySym ks = 0; int esc = 27; Window root, child; int posx, posy, rootx, rooty; unsigned int keys_buttons; int last_x, last_y; static int last_event, last_motion_down_button; static unsigned int motion_state; #if MOUSE_DRAG_THRESHOLD static int button_press_x, button_press_y; #endif int width, height; while (force || XPending(This_XDisplay)) { XNextEvent(This_XDisplay, &report); Current_Event = report; switch (report.type) { case ClientMessage: if ((report.xclient.format == 32) && ((Atom) report.xclient.data.l[0] == XWin->wm_del_win)) jed_exit_jed (1); break; case MotionNotify: /* Make sure we get the last event of this type */ while (XCheckMaskEvent (This_XDisplay, ButtonMotionMask, &report)) ; if (!XQueryPointer(This_XDisplay, report.xmotion.window, &root, &child, &rootx, &rooty, &posx, &posy, &keys_buttons)) break; /* This will ensure that modifier keys are not pressed while we are in motion. */ if ((last_event == MotionNotify) && (motion_state != keys_buttons)) break; motion_state = keys_buttons; memset ((char *) &jmouse, 0, sizeof (jmouse)); last_x = jmouse.x; last_y = jmouse.y; fill_jmouse (&jmouse, JMOUSE_DRAG, posx, posy, report.xmotion.time, last_motion_down_button, keys_buttons); #if MOUSE_DRAG_THRESHOLD if ((abs(button_press_x - posx) <= MOUSE_DRAG_THRESHOLD) && (abs(button_press_y - posy) <= MOUSE_DRAG_THRESHOLD)) break; #endif if ((last_x == jmouse.x) && (last_y == jmouse.y)) break; if (-1 == (ch1 = jed_mouse_add_event (&jmouse))) break; /* queue full */ /* return ESC ^@ */ *buf++ = esc; *buf++ = 0; *buf++ = ch1; *n_chars = 3; last_event = MotionNotify; return 1; case Expose: if (block_expose == 0) cover_exposed_area (report.xexpose.x, report.xexpose.y, report.xexpose.width, report.xexpose.height, report.xexpose.count); else { if (report.xexpose.count == 0) { jed_redraw_screen (1); block_expose = 0; } } break; case ConfigureNotify: width = report.xconfigure.width; height = report.xconfigure.height; if ((width != XWin->width) || (height != XWin->height)) { XWin->width = width; XWin->height = height; jed_init_display (); jed_redraw_screen (0); block_expose = -1; } #ifdef XJED_USE_R6IM if (R6IM_Input_Style & XIMPreeditArea) { set_geometry (&report, XIMPreeditArea, XNPreeditAttributes); set_geometry (&report, XIMStatusArea, XNStatusAttributes); } #endif break; case ButtonPress: /* Prohibit dragging more than one button at a time. */ if (last_event == MotionNotify) break; /* drop */ case ButtonRelease: if ((last_event == MotionNotify) && (report.xbutton.button != (unsigned int) last_motion_down_button)) break; #if MOUSE_DRAG_THRESHOLD if (report.type == ButtonPress) { button_press_x = report.xbutton.x; button_press_y = report.xbutton.y; } else { button_press_x = 0; button_press_y = 0; } #endif last_event = 0; fill_jmouse (&jmouse, ((report.type == ButtonRelease) ? JMOUSE_UP : JMOUSE_DOWN), report.xbutton.x, report.xbutton.y, report.xbutton.time, report.xbutton.button, report.xbutton.state); if (-1 == (ch1 = jed_mouse_add_event (&jmouse))) break; /* queue full */ if ((report.type == ButtonPress) && (0 == (report.xbutton.state & (Button1Mask|Button2Mask|Button3Mask |Button4Mask|Button5Mask|Button6Mask)))) last_motion_down_button = report.xbutton.button; /* ESC ^@ is a mouse prefix */ *buf++ = esc; *buf++ = 0; *buf++ = ch1; *n_chars = 3; return 1; #if HAS_IBM_NUMLOCK_CODE case KeyRelease: if ((report.xkey.keycode != 98) # if 0 || (0 != strcmp (The_Xserver_Vendor, "International Business Machines")) # endif ) { (void) x_handle_harmless_events (&report); break; } /* Drop */ #endif case KeyPress: bufp = buf; #ifndef XJED_USE_R6IM *n_chars = XLookupString(&report.xkey, buf, buflen, &ks, NULL); #else if (!XFilterEvent (&report, report.xkey.window)) { Status status_return; if (R6IM_Xic != NULL) { #if USE_XUTF8_CODE if (Jed_UTF8_Mode) *n_chars = Xutf8LookupString (R6IM_Xic, &report.xkey, buf, buflen, &ks, &status_return); else #endif *n_chars = XmbLookupString (R6IM_Xic, &report.xkey, buf, buflen, &ks, &status_return); } else *n_chars = XLookupString(&report.xkey, buf, buflen, &ks, NULL); } else *n_chars = 0; #endif ks = ks & 0xFFFF; X_Last_Keysym = ks; #if USE_NEW_META_CODE if ((*n_chars == 0) && (ks > 0x00FF) && (ks < 0x0FFF)) { *n_chars = 1; buf[0] = ks & 0x00FF ; } #endif bufp = (char *)map_keysym_to_keyseq (ks, report.xkey.state & (ShiftMask|ControlMask)); if (bufp != NULL) { *n_chars = (unsigned char) *bufp++; #if USE_NEW_META_CODE if (report.xkey.state & JX_MetaMask) { buf[0] = X_Alt_Char; SLMEMCPY (buf + 1, bufp, *n_chars); *n_chars += 1; } else #endif SLMEMCPY(buf, bufp, *n_chars); } else if (*n_chars == 1) { if (bufp == NULL) bufp = buf; if (report.xkey.state & JX_MetaMask) { ch1 = *bufp; #if 0 /* Only do this on alphabetic characters. This * is because, e.g., german keyboards use 'Alt-{' * to generate the '{' character */ if (isalnum (ch1) && (ch1 < 0x80)) { #endif if (X_Alt_Char <= 0) *buf |= 0x80; else { *bufp++ = (unsigned char) X_Alt_Char; *bufp = (unsigned char) ch1; *n_chars = 2; } #if 0 } #endif } else if (report.xkey.state & ControlMask) { if (*buf == ' ') *buf = 0; else if (*buf == '-') *buf = 0x1F; } } if (*n_chars == 0) break; return 1; case SelectionNotify: (void) receive_selection (&report); break; case SelectionClear: SLfree (Selection_Send_Data); /* NULL ok */ Selection_Send_Data = NULL; break; case SelectionRequest: (void) send_selection (&report); break; default: (void) x_handle_harmless_events (&report); } } return 0; } /*}}}*/ static int X_read_key (void) /*{{{*/ { int nread; char buf[64]; (void) X_process_events (1, buf, sizeof (buf), &nread); if (nread > 1) ungetkey_string(buf + 1, nread - 1); return (int) *buf; } /*}}}*/ static int X_input_pending (void) /*{{{*/ { XEvent ev; int n; if (No_XEvents) return 0; #if 1 /* XCheckMaskEvent searches the queue and removes the specified event. */ if (0 != XCheckMaskEvent(This_XDisplay, KeyPressMask, &ev)) { /* XPutBackEvent pushes the event to the head of the event queue-- no return value */ XPutBackEvent(This_XDisplay, &ev); return 1; } #endif n = XPending (This_XDisplay); while (n > 0) { XPeekEvent(This_XDisplay, &ev); if (0 == x_handle_harmless_events (&ev)) return 1; XNextEvent(This_XDisplay, &ev); n--; } return 0; } /*}}}*/ static void JX_get_display_size (int *rows, int *cols) /*{{{*/ { JX_Screen_Cols = (XWin->width - XWin->border) / XWin->font_width; JX_Screen_Rows = (XWin->height - XWin->border) / XWin->font_height; *cols = JX_Screen_Cols; *rows = JX_Screen_Rows; } /*}}}*/ static void JX_set_term_vtxxx (int *n) /*{{{*/ { (void) n; } /*}}}*/ static void JX_narrow_width (void) /*{{{*/ { } /*}}}*/ static void JX_wide_width (void) /*{{{*/ { } /*}}}*/ static void JX_enable_cursor_keys(void) /*{{{*/ { } /*}}}*/ static void JX_cls(void) /*{{{*/ { /* vterm_cls (); */ if (No_XEvents) return; if (XWin->window_mapped == 0) return; XClearWindow(This_XDisplay, This_XWindow); } /*}}}*/ /* This routine is called from S-Lang inner interpreter. It serves as a poor mans version of an interrupt 9 handler */ static void xjed_check_kbd(void) /*{{{*/ { char buf[64]; int n; register char *b, *bmax; if (Batch || No_XEvents) return; while (XPending(This_XDisplay)) { if (X_process_events (0, buf, sizeof (buf), &n) == 0) continue; b = buf; bmax = b + n; while (b < bmax) { if (*b == (char) Jed_Abort_Char) { if (Ignore_User_Abort == 0) SLang_set_error (USER_BREAK); if (b != buf) buffer_keystring (buf, (int) (b - buf)); SLKeyBoard_Quit = 1; break; } b++; } if (!SLKeyBoard_Quit) buffer_keystring (buf, n); } } /*}}}*/ static void xjed_suspend (void) /*{{{*/ { if (No_XEvents) return; if (XWin->focus) { /* XIconifyWindow (This_XDisplay, XWin->w, This_XScreen); */ if (XWin->visible == VisibilityUnobscured) XLowerWindow (This_XDisplay, This_XWindow); else XRaiseWindow (This_XDisplay, This_XWindow); } else { /* The window doesn't have focus which means that this was most * likely called by pressing Ctrl-Z from another window. */ fprintf (stderr, "jed stopping\n"); #ifdef SIGSTOP kill (0, SIGSTOP); #endif /* sys_suspend (); */ } } /*}}}*/ static void x_toggle_visibility (void) /*{{{*/ { int hide_win = (XWin->visible == VisibilityUnobscured); if ((SLang_Num_Function_Args == 1) && (-1 == SLang_pop_integer (&hide_win))) return; if (hide_win) /* XIconifyWindow (This_XDisplay, XWin->w, This_XScreen); */ XLowerWindow (This_XDisplay, This_XWindow); else XRaiseWindow (This_XDisplay, This_XWindow); } /*}}}*/ static int get_font_width (XFontStruct *f, int *wp, int *is_dualp) { int w0, w1; *is_dualp = 0; if (f->min_bounds.width == f->max_bounds.width) { *wp = f->max_bounds.width; return 0; } /* Simple heristic */ w0 = XTextWidth (f, "M", 1); w1 = XTextWidth (f, "l", 1); if (w0 != w1) (void) fprintf (stderr, "This font does not appear to be single-width. Expect rendering problems.\n"); #if SLANG_VERSION >= 20000 if (Jed_UTF8_Mode && (f->min_bounds.width * 2 == f->max_bounds.width)) { *wp = f->min_bounds.width; *is_dualp = 1; return 0; } #endif *wp = f->max_bounds.width; return 0; } static int load_font (char *font) /*{{{*/ { static XFontStruct *xfont; #if XJED_HAS_XRENDERFONT if (XWin->face_size > 0) { /* the user wants xrender */ XWin->xftfont = XftFontOpen(This_XDisplay, This_XScreen, XFT_FAMILY, XftTypeString, font, XFT_SIZE, XftTypeDouble, XWin->face_size, XFT_SPACING, XftTypeInteger, XFT_MONO, NULL); if (XWin->xftfont == NULL) return -1; XWin->font_name = font; XWin->font_height = XWin->xftfont->ascent + XWin->xftfont->descent; XWin->font_width = XWin->xftfont->max_advance_width; XWin->font_base = XWin->xftfont->ascent; return 0; } #endif xfont = XLoadQueryFont(This_XDisplay, font); if (xfont == NULL) return -1; XWin->font = xfont; XWin->font_name = font; XWin->font_height = xfont->ascent + xfont->descent; XWin->font_base = xfont->ascent; (void) get_font_width (xfont, &XWin->font_width, &XWin->is_dual_font); if (XWin->font_width <= 0) { fprintf (stderr, "Font width for %s is <= 0\n", font); return -1; } return 0; } /*}}}*/ static void get_xdefaults (void) /*{{{*/ { XWindow_Arg_Type *xargs = X_Arg_List + XARG_START; /* skip display, name, etc */ while (xargs->name != NULL) { if (xargs->dflt == NULL) { xargs++; continue; } if ((xargs->type != VOID_TYPE) && (xargs->value == NULL)) { static char *class_names[] = { "UXjed", "UXJed", "uxjed", NULL }; char *p, *cn; char **cnp; /* Note that strings returned by XGetDefault are owned by * Xlib and should not be modified or freed by the client. * However, the solaris folks apparantly are not aware of this * and the following two function calls produce memory leaks. * Sigh. */ p = NULL; #if SLANG_VERSION >= 20000 if (Jed_UTF8_Mode) { cnp = class_names; while (NULL != (cn = *cnp++)) { p = XGetDefault (This_XDisplay, cn, xargs->name); if (p != NULL) break; } } #endif if (p == NULL) { cnp = class_names; while (NULL != (cn = *cnp++)) { cn++; /* Skip leading U */ p = XGetDefault (This_XDisplay, cn, xargs->name); if (p != NULL) break; } } if (p == NULL) { #if SLANG_VERSION >= 20000 if (Jed_UTF8_Mode) p = XGetDefault (This_XDisplay, "UXTerm", xargs->name); #endif if (p == NULL) p = XGetDefault (This_XDisplay, "XTerm", xargs->name); } if (p != NULL) xargs->value = p; } if (xargs->value != NULL) *xargs->dflt = xargs->value; xargs++; } } /*}}}*/ static void set_window_name (char *s) /*{{{*/ { if (Batch) return; XStoreName (This_XDisplay, XWin->w, s); } /*}}}*/ static void set_icon_name (char *s) /*{{{*/ { if (Batch) return; XSetIconName(This_XDisplay, XWin->w, s); } /*}}}*/ #if 0 static void set_wm_hints (JXWindow_Type *w, int xpos, int ypos, unsigned long orflags) /*{{{*/ { XSizeHints h; XWMHints h1; XClassHint ch; ch.res_name = "xjed"; ch.res_class = "XJed"; h.width_inc = w->font_width; h.height_inc = w->font_height; h.min_width = 5 * w->font_width + w->border; h.min_height = 5 * w->font_height + w->border; h.base_height = 0; h.base_width = 0; h.x = xpos; h.y = ypos; h.height = w->height; h.width = w->width; h.flags = PMinSize | PResizeInc | PBaseSize; h.flags |= orflags; XSetWMNormalHints(This_XDisplay, w->w, &h); /* This bit allows me to track the focus. It is not at all clear from the documentation. */ h1.input = 1; h1.flags = InputHint; XSetWMHints(This_XDisplay, w->w, &h1); # if 0 XSetClassHint(This_XDisplay, w->w, &ch); # endif } /*}}}*/ #endif static int alloc_color(char* color_name, XColor* color_info) { XColor exact_info; if (XAllocNamedColor(This_XDisplay, XWin->color_map, color_name, color_info, &exact_info)) return color_info->pixel; if (0 == strncmp (color_name, "bright", 6)) color_name += 6; if (XAllocNamedColor(This_XDisplay, XWin->color_map, color_name, color_info, &exact_info)) return color_info->pixel; fprintf(stderr, "Can't allocate color %s\n", color_name); return -1; } /* This parses the colors in the XWin structure and setting defaults to fg, bg upon failure of either one */ static void setup_ith_color (int i) /*{{{*/ { XColor xcol; int fg, bg; if (!Term_Supports_Color) return; fg = alloc_color(XWin->text_gc[i].fg_name, &xcol); bg = alloc_color(XWin->text_gc[i].bg_name, &xcol); if ((fg < 0) || (bg < 0)) return; XWin->text_gc[i].fg = fg; XWin->text_gc[i].bg = bg; } /*}}}*/ /* This is used to set the colors in the Win structure and if f is non-zero, * the previous definitions are freed. f is 0 when the colors correspond to the * default. */ static void x_set_color_free (int i, char *fgcolor, char *bgcolor, int do_free) /*{{{*/ { char *save_fg, *save_bg, *fg, *bg; if ((*fgcolor == 0) || !strcmp (fgcolor, "default")) fgcolor = XWin->text_gc[0].fg_name; if ((*bgcolor == 0) || !strcmp (bgcolor, "default")) bgcolor = XWin->text_gc[0].bg_name; if (NULL == (fg = SLmalloc(strlen(fgcolor) + 1))) return; strcpy (fg, fgcolor); if (NULL == (bg = SLmalloc (strlen(bgcolor) + 1))) { SLfree (fg); return; } strcpy (bg, bgcolor); save_fg = XWin->text_gc[i].fg_name; XWin->text_gc[i].fg_name = fg; save_bg = XWin->text_gc[i].bg_name; XWin->text_gc[i].bg_name = bg; setup_ith_color (i); if (do_free) { if (save_fg != NULL) SLfree (save_fg); if (save_bg != NULL) SLfree (save_bg); } } /*}}}*/ static int setup_and_parse_colors (void) /*{{{*/ { unsigned long fg, bg, tmp; char *fg_name, *bg_name; int i; GC_Info_Type *d; /* Check to see if this is a color display */ bg = WhitePixel (This_XDisplay, This_XScreen); fg = BlackPixel (This_XDisplay, This_XScreen); fg_name = Default_GC_Info[0].fg_name; bg_name = Default_GC_Info[0].bg_name; XWin->color_map = DefaultColormap (This_XDisplay, This_XScreen); #if 0 if (XWin->color_map == NULL) { fprintf (stderr, "Unable to get a colormap\n"); exit (1); } #endif if (DisplayCells (This_XDisplay, This_XScreen) > 2) { Term_Supports_Color = 1; } else Term_Supports_Color = 0; for (i = 0; i < JMAX_COLORS; i++) { d = Default_GC_Info + i; /* The assumption here is that ALL colors beyond JNORMAL_COLOR (0) * take reversed fg, bgs. I really ought to have flags if this is * not the case. */ d->fg = fg; d->bg = bg; if (d->fg_name == NULL) d->fg_name = fg_name; if (d->bg_name == NULL) d->bg_name = bg_name; if (i == JNORMAL_COLOR) { char *tmp_name; tmp = fg; fg = bg; bg = tmp; tmp_name = fg_name; fg_name = bg_name; bg_name = tmp_name; } x_set_color_free (i, d->fg_name, d->bg_name, 0); } return 0; } /*}}}*/ static void set_mouse_color (char *fgc, char *bgc) /*{{{*/ { XColor xfg, xbg; if (0 == Term_Supports_Color) return; if (alloc_color(fgc, &xfg) < 0) return; if (alloc_color(bgc, &xbg) < 0) return; XRecolorCursor (This_XDisplay, XWin->mouse, &xfg, &xbg); } /*}}}*/ static void create_needed_gcs (void) /*{{{*/ { int i; XGCValues xgcv; #if XJED_HAS_XRENDERFONT if (XWin->face_size == 0) #endif xgcv.font = XWin->font->fid; for (i = 0; i < JMAX_COLORS; i++) { xgcv.foreground = XWin->text_gc[i].fg; xgcv.background = XWin->text_gc[i].bg; #if XJED_HAS_XRENDERFONT if (XWin->face_size > 0) { XWin->text_gc[i].gc = XCreateGC(This_XDisplay, This_XWindow, GCForeground | GCBackground /*| GCFont*/, /* XFT */ &xgcv); } else #endif XWin->text_gc[i].gc = XCreateGC(This_XDisplay, This_XWindow, GCForeground | GCBackground | GCFont, &xgcv); } } /*}}}*/ static Window create_XWindow (JXWindow_Type *win) /*{{{*/ { int bdr, x, y, flags; unsigned int width, height; XSizeHints sizehint; XClassHint xcls; XWMHints wmhint; long key_event_type; bdr = atoi(This_Border_Width_Name); if (This_Geometry == NULL) This_Geometry = Default_Geometry; sizehint.flags = 0; flags = XParseGeometry (This_Geometry, &x, &y, &width, &height); if (flags & WidthValue) { sizehint.width = width; sizehint.flags |= USSize; } else { width = JX_Screen_Cols; } if (flags & HeightValue) { sizehint.height = height; sizehint.flags |= USSize; } else { height = JX_Screen_Rows; } win->height = height * win->font_height + 2 * win->border; win->width = width * win->font_width + 2 * win->border; sizehint.height = win->height; sizehint.width = win->width; sizehint.width_inc = win->font_width; sizehint.height_inc = win->font_height; sizehint.min_width = 5 * win->font_width + win->border; sizehint.min_height = 5 * win->font_height + win->border; sizehint.base_height = 0; sizehint.base_width = 0; if (flags & XValue) { if (flags & XNegative) { x += (DisplayWidth (This_XDisplay, This_XScreen) - sizehint.width - 2 * win->border); sizehint.win_gravity = NorthEastGravity; } sizehint.x = x; sizehint.flags |= USPosition; } else x = 0; if (flags & YValue) { if (flags & YNegative) { y += (DisplayHeight (This_XDisplay, This_XScreen) - sizehint.height - 2 * win->border); if ((flags&XValue) && (flags&XNegative)) sizehint.win_gravity = SouthEastGravity; else sizehint.win_gravity = SouthWestGravity; } sizehint.y = y; sizehint.flags |= USPosition; } else y = 0; sizehint.flags |= (PMinSize | PResizeInc | PBaseSize); /* create and display window */ win->w = XCreateSimpleWindow(This_XDisplay, RootWindow(This_XDisplay, This_XScreen), x, y, /* xpos, ypos */ win->width, /* width, height */ win->height, /* width, height */ bdr, /* border width */ win->text_gc[JNORMAL_COLOR].fg, win->text_gc[JNORMAL_COLOR].bg ); xcls.res_name = This_App_Name; xcls.res_class = XJED_CLASS; wmhint.input = True; /* track the focus */ if (Iconic != NULL) wmhint.initial_state = IconicState; else wmhint.initial_state = NormalState; wmhint.flags = InputHint | StateHint; wmhint.window_group = win->w; wmhint.flags |= WindowGroupHint; XSetWMProperties (This_XDisplay, win->w, NULL, NULL, NULL, 0, &sizehint, &wmhint, &xcls); /* Enable the delete window protocol */ win->wm_del_win = XInternAtom (This_XDisplay, "WM_DELETE_WINDOW", False); XSetWMProtocols (This_XDisplay, win->w, &win->wm_del_win, 1); #if XJED_SET_WM_COMMAND XSetCommand(This_XDisplay, win->w, _Jed_Startup_Argv, _Jed_Startup_Argc); #endif if (NULL == (The_Xserver_Vendor = XServerVendor (This_XDisplay))) The_Xserver_Vendor = ""; key_event_type = KeyPressMask; #if HAS_IBM_NUMLOCK_CODE if ((0 == strcmp (The_Xserver_Vendor, "International Business Machines")) || 0 == strcmp (The_Xserver_Vendor, "Hewlett-Packard Company")) key_event_type |= KeyReleaseMask; #endif /* select event types */ XSelectInput(This_XDisplay, win->w, (ExposureMask | key_event_type | ButtonPressMask | ButtonReleaseMask | StructureNotifyMask | PointerMotionHintMask | ButtonMotionMask | EnterWindowMask /* | LeaveWindowMask */ | FocusChangeMask | VisibilityChangeMask) ); if (XWin->mouse) XDefineCursor(This_XDisplay, win->w, XWin->mouse); return win->w; } /*}}}*/ static int x_err_handler (Display *d, XErrorEvent *ev) /*{{{*/ { char errmsg[256]; No_XEvents = 1; XGetErrorText (d, ev->error_code, errmsg, 255); exit_error (errmsg, 0); return 1; } /*}}}*/ static int x_ioerr_handler (Display *d) /*{{{*/ { No_XEvents = 1; exit_error("XWindows IO error", 0); return d == NULL; /* just use d to avoid a warning */ } /*}}}*/ static int open_Xdisplay (void) /*{{{*/ { char dname [256]; char *n; n = X_Arg_List[XARG_DISPLAY].value; if (n != NULL) { strncpy (dname, X_Arg_List[XARG_DISPLAY].value, sizeof (dname)-10); dname[sizeof(dname)-10] = 0; n = dname; while (*n && (*n != ':')) n++; if (*n == 0) strcpy(n, ":0.0"); n = dname; } XSetIOErrorHandler (x_ioerr_handler); if ( (This_XDisplay = XOpenDisplay(n)) == NULL ) return 0; XSetErrorHandler (x_err_handler); return 1; } /* returns socket descriptor */ static int init_Xdisplay (void) /*{{{*/ { #ifdef XJED_USE_R6IM setlocale(LC_ALL, ""); #endif if (X_Arg_List[XARG_NAME].value != NULL) { This_App_Name = X_Arg_List[XARG_NAME].value; } XWin = &XWin_Buf; memset ((char *)XWin, 0, sizeof (JXWindow_Type)); get_xdefaults (); XWin->border = atoi(This_Internal_Border_Name); if (XWin->border < 0) XWin->border = 0; XWin->font_name = This_Font_Name; #if XJED_HAS_XRENDERFONT /* if a parameter to -fs was supplied, we assume the user wants XFT */ if (strlen(This_Face_Size)) { if ((XWin->face_size = atof(This_Face_Size))<=0) /* we couldn't convert the value, or a negative value was specified */ XWin->face_size = 0; } else /* there was no -fs, so we don't do anything */ XWin->face_size = 0; /* make sure that XWin->xftdraw is null in any case */ XWin->xftdraw = NULL; #endif This_XScreen = DefaultScreen(This_XDisplay); if (-1 == load_font(XWin->font_name)) { (void) fprintf( stderr, "xjed: cannot load font %s, using fixed.\n", XWin->font_name); if (-1 == load_font("fixed")) { (void) fprintf( stderr, "xjed: cannot load fixed font.\n"); exit (1); } } XWin->text_gc = Default_GC_Info; if (-1 == setup_and_parse_colors ()) /* This allocs and parses colors */ exit (1); XWin->mouse = XCreateFontCursor (This_XDisplay, XC_xterm); set_mouse_color (This_MFG, This_MBG); This_XWindow = create_XWindow(XWin); set_window_name (This_App_Title); set_icon_name (This_App_Name); /* GCs and their colors */ create_needed_gcs (); /* This uses info from previous call */ XWin->current_gc = XWin->text_gc + JNORMAL_COLOR; #if XJED_HAS_XRENDERFONT /* we only XSetFont() if we're NOT using renderfont */ if (XWin->face_size != 0) { XWin->xftdraw = XftDrawCreate(This_XDisplay, This_XWindow, DefaultVisual(This_XDisplay, This_XScreen), XWin->color_map); if (NULL == XWin->xftdraw) { fprintf (stderr, "xjed: XftDrawCreate failed\n"); exit (1); } } else #endif XSetFont (This_XDisplay, XWin->current_gc->gc, XWin->font->fid); /* display window */ XMapWindow(This_XDisplay, This_XWindow); #ifdef XJED_USE_R6IM i18init (); #endif Compound_Text_Atom = XInternAtom(This_XDisplay, "COMPOUND_TEXT", False); Text_Atom = XInternAtom(This_XDisplay, "TEXT", False); UTF8_String_Atom = XInternAtom (This_XDisplay, "UTF8_STRING", False); Targets_Atom = XInternAtom (This_XDisplay, "TARGETS", False); Xjed_Prop = XInternAtom(This_XDisplay, "XJED_PROPERTY_TEXT", False); return ConnectionNumber (This_XDisplay); } /*}}}*/ static void reset_Xdisplay (void) /*{{{*/ { if (This_XDisplay != NULL) XCloseDisplay(This_XDisplay); } /*}}}*/ #define UPCSE(x) (((x) <= 'z') && ((x) >= 'a') ? (x) - 32 : (x)) static int myXstrcmp(char *a, char *b) /*{{{*/ { register char cha, chb; /* do simple comparison */ cha = *a++; chb = *b++; if ((cha != chb) && (UPCSE(cha) != UPCSE(chb))) return 0; while ((cha = *a++), (chb = *b++), (cha && chb) != 0) { if (cha != chb) return 0; } return (cha == chb); } /*}}}*/ #define STREQS(a, b) myXstrcmp(a, b) static int X_eval_command_line (int argc, char **argv) /*{{{*/ { char *arg; int i; XWindow_Arg_Type *opt; for (i = 1; i < argc; i++) { arg = argv[i]; if (*arg != '-') break; if (0 == strcmp ("--debug-xjed", arg)) { Debug_Xjed = 1; continue; } arg++; opt = X_Arg_List; while (opt->name != NULL) { if (STREQS(opt->name, arg) || ((opt->name1 != NULL) && STREQS(opt->name1, arg))) break; opt++; } if (opt->name == NULL) break; if (opt->type == VOID_TYPE) opt->value = "on"; else if (i + 1 < argc) { i++; opt->value = argv[i]; } else break; } /* Out of this loop, argv[i] is the last unprocessed argument */ return i; } /*}}}*/ #ifdef XJED_USE_R6IM static void move_input_position (void) { XPoint spot; /* XVaNestedList list; */ spot.x = XWin->border + XWin->cursor_col * XWin->font_width; spot.y = XWin->cursor_row * XWin->font_height + XWin->border + XWin->font_base; if (R6IM_Preedit_Attr != NULL) XFree (R6IM_Preedit_Attr); if (NULL != (R6IM_Preedit_Attr = XVaCreateNestedList (0, XNSpotLocation, &spot, NULL))) { if (R6IM_Xic != NULL) XSetICValues (R6IM_Xic, XNPreeditAttributes, R6IM_Preedit_Attr, NULL); } } static void set_geometry (XEvent *report, XIMStyle style, char *attr) { XVaNestedList list; static XRectangle ra, *rb; if (style == XIMPreeditArea) ra.width = report->xconfigure.width - (XWin->font_width * 8); else if (style == XIMStatusArea) ra.width = XWin->font_width * 8; /* ra.width = report->xconfigure.width; */ ra.height = XWin->font_height; list = XVaCreateNestedList (0, XNAreaNeeded, &ra, NULL); XSetICValues (R6IM_Xic, attr, list, NULL); XFree (list); rb = &ra; list = XVaCreateNestedList (0, XNAreaNeeded, rb, NULL); XGetICValues (R6IM_Xic, attr, list, NULL); XFree (list); rb->x = 0; if (style == XIMPreeditArea) { rb->x = XWin->font_width * 8; rb->y = report->xconfigure.height - rb->height; } else if (style == XIMStatusArea) { rb->x = 0; rb->y = report->xconfigure.height - rb->height; } list = XVaCreateNestedList (0, XNArea, rb, NULL); XSetICValues (R6IM_Xic, attr, list, NULL); XFree (list); /* XFree (rb); */ } /* * This is more or less stolen startight from XFree86 xterm. This should * support all European type languages. */ static void i18init (void) /*{{{*/ { int i; char *p, *s, *ns, *end, tmp[1024], buf[32]; XIM xim = NULL; XIMStyles *xim_styles = NULL; int found; setlocale(LC_ALL, ""); if (R6IM_Input_Method != NULL) { strcpy(tmp, R6IM_Input_Method); s=tmp; while (*s) { while (*s && (isspace(*s) || (*s == ','))) s++; if (*s == 0) break; end = s; while (*end && (*end != ',')) end++; ns = end; if (*end) ns++; *end-- = 0; while ((end >= s) && isspace(*end)) *end-- = 0; if (*s) { strcpy(buf, "@im="); strcat(buf, s); if (((p = XSetLocaleModifiers(buf)) != NULL) && *p && (NULL != (xim = XOpenIM(This_XDisplay, NULL, NULL, NULL)))) break; } s = ns; } } if ((xim == NULL) && ((p = XSetLocaleModifiers("")) != NULL) && *p) xim = XOpenIM(This_XDisplay, NULL, NULL, NULL); if ((xim == NULL) && ((p = XSetLocaleModifiers("@im=none")) != NULL) && *p) xim = XOpenIM(This_XDisplay, NULL, NULL, NULL); if (xim == NULL) { fprintf(stderr, "Failed to open input method"); return; } /* Believe it or not, XGetIMValues return NULL upon success */ if ((NULL != XGetIMValues(xim, XNQueryInputStyle, &xim_styles, NULL)) || (xim_styles == NULL)) { fprintf(stderr, "Input method doesn't support any style\n"); XCloseIM(xim); return; } found = 0; strcpy(tmp, R6IM_Preedit_Type); s = tmp; while (*s && !found) { while (*s && (isspace(*s) || (*s == ','))) s++; if (*s == 0) break; end = s; while (*end && (*end != ',')) end++; ns = end; if (*ns) ns++; *end-- = 0; while ((end >= s) && isspace(*end)) *end-- = 0; if (!strcmp(s, "OverTheSpot")) R6IM_Input_Style = (XIMPreeditPosition | XIMStatusArea); else if (!strcmp(s, "OffTheSpot")) R6IM_Input_Style = (XIMPreeditArea | XIMStatusArea); else if (!strcmp(s, "Root")) R6IM_Input_Style = (XIMPreeditNothing | XIMStatusNothing); /* FIXME!!! (I think) * Examples on the web show testing of bits via & instead of * the == operator. */ for (i = 0; (unsigned short)i < xim_styles->count_styles; i++) { if (R6IM_Input_Style == xim_styles->supported_styles[i]) { found = 1; break; } } s = ns; } XFree(xim_styles); if (found == 0) { /* fprintf(stderr, "input method doesn't support my preedit type\n"); */ XCloseIM(xim); return; } /* * This program only understands the Root preedit_style yet * Then misc.preedit_type should default to: * "OverTheSpot,OffTheSpot,Root" * /MaF */ #if 0 if (R6IM_Input_Style != (XIMPreeditNothing | XIMStatusNothing)) { fprintf(stderr,"This program only supports the 'Root' preedit type\n"); XCloseIM(xim); return; } #else if (R6IM_Input_Style == (XIMPreeditNothing | XIMStatusNothing))/* "Root" */ R6IM_Xic = XCreateIC(xim, XNInputStyle, R6IM_Input_Style, XNClientWindow, This_XWindow, XNFocusWindow, This_XWindow, NULL); else if (R6IM_Input_Style == (XIMPreeditPosition | XIMStatusArea))/* "OverTheSpot" */ { XFontSet fs; char **miss, *def; int n_miss; char *fontlist; R6IM_Spot.x = 0; R6IM_Spot.y = 0; /* R6IM_Spot.x = XWin->border + XWin->cursor_col * XWin->font_width; R6IM_Spot.y = XWin->cursor_row * XWin->font_height + XWin->border + XWin->font_base; */ if (NULL != (fontlist = SLmake_string (This_Font_Name))) { fs = XCreateFontSet (This_XDisplay, fontlist, &miss, &n_miss, &def); SLfree(fontlist); R6IM_Preedit_Attr = XVaCreateNestedList (0, XNFontSet, fs, XNSpotLocation, &R6IM_Spot, NULL); R6IM_Xic = XCreateIC(xim, XNInputStyle, R6IM_Input_Style, XNClientWindow, This_XWindow, XNPreeditAttributes, R6IM_Preedit_Attr, XNStatusAttributes, R6IM_Preedit_Attr, NULL); } } else if (R6IM_Input_Style == (XIMPreeditArea | XIMStatusArea))/* "OffTheSpot" */ { XFontSet fs; char **miss, *def; int n_miss; char *fontlist; if (NULL != (fontlist = SLmake_string (This_Font_Name))) { fs = XCreateFontSet (This_XDisplay, fontlist, &miss, &n_miss, &def); SLfree(fontlist); R6IM_Preedit_Attr = XVaCreateNestedList (0, XNFontSet, fs, XNSpotLocation, &R6IM_Spot, NULL); R6IM_Xic = XCreateIC(xim, XNInputStyle, R6IM_Input_Style, XNClientWindow, This_XWindow, XNPreeditAttributes, R6IM_Preedit_Attr, XNStatusAttributes, R6IM_Preedit_Attr, NULL); } } #endif if (NULL == R6IM_Xic) { fprintf(stderr,"Failed to create input context\n"); XCloseIM(xim); } } /*}}}*/ #endif static void set_border_color (char *fgc, char *bgc) /*{{{*/ { XColor xfg; unsigned int bdr = atoi(bgc); if (!Term_Supports_Color) return; if (alloc_color(fgc, &xfg) < 0) return; XSetWindowBorder (This_XDisplay, XWin->w, xfg.pixel); if (bdr < 1000) XSetWindowBorderWidth (This_XDisplay, XWin->w, bdr); } /*}}}*/ static JX_SETXXX_RETURN_TYPE JX_set_mono (int obj_unused, char *unused, SLtt_Char_Type c_unused) { (void) obj_unused; (void) unused; (void) c_unused; return JX_SETXXX_RETURN_VAL; } static JX_SETXXX_RETURN_TYPE JX_set_color (int i, char *what, char *fg, char *bg) { if (XWin == NULL) return JX_SETXXX_RETURN_VAL; if (!Term_Supports_Color) return JX_SETXXX_RETURN_VAL; #if SLANG_VERSION >= 10306 SLsmg_touch_screen (); #endif if (i == -1) { if (!strcmp("mouse", what)) { set_mouse_color (fg, bg); } else if (!strcmp("border", what)) { set_border_color (fg, bg); } return JX_SETXXX_RETURN_VAL; } x_set_color_free (i, fg, bg, 1); XSetForeground(This_XDisplay, XWin->text_gc[i].gc, XWin->text_gc[i].fg); XSetBackground(This_XDisplay, XWin->text_gc[i].gc, XWin->text_gc[i].bg); if (i == JNORMAL_COLOR) XSetWindowBackground (This_XDisplay, This_XWindow, XWin->text_gc[i].bg); return JX_SETXXX_RETURN_VAL; } /*}}}*/ static void x_warp_pointer (void) /*{{{*/ { X_Warp_Pending = 1; } /*}}}*/ static void x_region_2_cutbuffer (void) /*{{{*/ { int nbytes; char *dat; dat = make_buffer_substring(&nbytes); if (dat == NULL) return; XStoreBytes (This_XDisplay, dat, nbytes); #if 0 XChangeProperty (This_XDisplay, DefaultRootWindow (This_XDisplay), XA_CUT_BUFFER0, XA_STRING, 8, PropModeReplace, dat, nbytes); #endif SLfree (dat); } /*}}}*/ static int x_insert_cutbuffer (void) /*{{{*/ { int nbytes; char *dat; CHECK_READ_ONLY dat = XFetchBytes (This_XDisplay, &nbytes); if (nbytes && (dat != NULL)) jed_insert_nbytes ((unsigned char *) dat, nbytes); if (dat != NULL) XFree (dat); return nbytes; } /*}}}*/ static int x_insert_selection (void) { #if XJED_USE_COMPOUND_TEXT XConvertSelection (This_XDisplay, XA_PRIMARY, Compound_Text_Atom, Xjed_Prop, This_XWindow, Current_Event.xbutton.time); #else # if SLANG_VERSION >= 20000 if (Jed_UTF8_Mode) XConvertSelection (This_XDisplay, XA_PRIMARY, UTF8_String_Atom, Xjed_Prop, This_XWindow, Current_Event.xbutton.time); else # endif XConvertSelection (This_XDisplay, XA_PRIMARY, XA_STRING, Xjed_Prop, This_XWindow, Current_Event.xbutton.time); #endif return 0; } typedef struct Selection_Data_Type { unsigned int len; struct Selection_Data_Type *next; unsigned char bytes[1]; } Selection_Data_Type; static void free_selection_list (Selection_Data_Type *list) { while (list != NULL) { Selection_Data_Type *next = list->next; SLfree ((char *) list); list = next; } } static int append_to_selection_list (unsigned char *buf, unsigned int len, Selection_Data_Type **rootp, Selection_Data_Type **tailp) { Selection_Data_Type *next; if (NULL == (next = (Selection_Data_Type *)SLmalloc (sizeof(Selection_Data_Type)+len))) return -1; memcpy ((char *)next->bytes, buf, len); next->len = len; next->next = NULL; if (*rootp == NULL) *rootp = next; else *tailp = next; return 0; } static Selection_Data_Type *read_selection (Display *d, Window w, Atom property) { Atom actual_type; int actual_format; unsigned long nitem, bytes_after; unsigned char *data; unsigned long total_bytes; Selection_Data_Type *list = NULL, *tail = NULL; data = NULL; /* XGetWindowProperty is a very messed up function. I do not * recall one so poorly designed, including the win32 functions that * I have seen. */ if (Success != XGetWindowProperty (d, w, property, 0, 0, False, AnyPropertyType, &actual_type, &actual_format, &nitem, &bytes_after, &data)) return NULL; if (data != NULL) XFree (data); if ((actual_type == None) || (actual_format != 8)) return NULL; total_bytes = 0; while (bytes_after != 0) { unsigned long bytes_read; XTextProperty tp; char **mb_data; int mb_n; int status; if (Success != XGetWindowProperty (d, w, property, total_bytes/4, 1 + bytes_after/4, False, AnyPropertyType, &actual_type, &actual_format, &nitem, &bytes_after, &data)) break; /* What the ?? */ bytes_read = nitem * (actual_format/8); tp.value = data; tp.encoding = actual_type; tp.format = actual_format; tp.nitems = nitem; #if USE_XUTF8_CODE if (Jed_UTF8_Mode) status = Xutf8TextPropertyToTextList (This_XDisplay, &tp, &mb_data, &mb_n); else #endif status = XmbTextPropertyToTextList(This_XDisplay, &tp, &mb_data, &mb_n); if (status == Success) { int i; for (i=0; i < mb_n; i++) { if (-1 == append_to_selection_list ((unsigned char *)mb_data[i], strlen(mb_data[i]), &list, &tail)) { free_selection_list (list); XFreeStringList (mb_data); XFree (data); return NULL; } } XFreeStringList (mb_data); } else if (-1 == append_to_selection_list (data, bytes_read, &list, &tail)) { free_selection_list (list); XFree (data); return NULL; } total_bytes += bytes_read; XFree (data); } return list; } static int receive_selection (XEvent *ev) { Atom property; Selection_Data_Type *list; if (None == (property = ev->xselection.property)) { /* Try this */ (void) x_insert_cutbuffer (); return -1; } list = read_selection (This_XDisplay, This_XWindow, property); XDeleteProperty (This_XDisplay, This_XWindow, property); if (list == NULL) return -1; while (list != NULL) { Selection_Data_Type *next = list->next; if (-1 == jed_insert_nbytes (list->bytes, list->len)) { free_selection_list (list); return -1; } SLfree ((char *) list); list = next; } return 0; } static void x_region_2_selection (void) { int nbytes; if (Selection_Send_Data != NULL) SLfree (Selection_Send_Data); Selection_Send_Data = make_buffer_substring (&nbytes); if (Selection_Send_Data == NULL) return; XSetSelectionOwner (This_XDisplay, XA_PRIMARY, This_XWindow, Current_Event.xbutton.time); if (This_XWindow != XGetSelectionOwner (This_XDisplay, XA_PRIMARY)) return; } static int send_selection (XEvent *ev) { int len; XTextProperty tp; XSelectionEvent sev; XSelectionRequestEvent *xsr; int status; Atom target; int free_tp_value; if (NULL == Selection_Send_Data) return 0; memset ((char *)&tp, 0, sizeof (tp)); xsr = &ev->xselectionrequest; target = xsr->target; if (target == Targets_Atom) { /* The requester wants to know what targets we support. How polite. */ #define MAX_SELECTION_TARGETS 5 Atom target_atoms[MAX_SELECTION_TARGETS]; unsigned int ntargets = 0; target_atoms[ntargets++] = XA_STRING; target_atoms[ntargets++] = Text_Atom; target_atoms[ntargets++] = Compound_Text_Atom; #if USE_XUTF8_CODE target_atoms[ntargets++] = UTF8_String_Atom; #endif tp.value = (unsigned char *)target_atoms; tp.format = 8; tp.nitems = sizeof(Atom)*ntargets; free_tp_value = 0; len = 0; } else { int (*text_to_property)(Display *, char **, int, XICCEncodingStyle, XTextProperty *); XICCEncodingStyle style; #if USE_XUTF8_CODE if (Jed_UTF8_Mode) text_to_property = Xutf8TextListToTextProperty; else #endif text_to_property = XmbTextListToTextProperty; if (target == Compound_Text_Atom) style = XCompoundTextStyle; else if (target == UTF8_String_Atom) { #if USE_XUTF8_CODE style = XUTF8StringStyle; #else style = XTextStyle; #endif } else if ((target == Text_Atom) || (target == XA_STRING)) style = XTextStyle; else { char *name = XGetAtomName(This_XDisplay, target); if (name != NULL) { (void) fprintf (stderr, "Unsupported selection target: %s\n", name); XFree (name); } return -1; } status = (*text_to_property) (This_XDisplay, &Selection_Send_Data, 1, style, &tp); if ((status != Success) || (tp.value == NULL)) return -1; free_tp_value = 1; len = strlen (Selection_Send_Data); } status = XChangeProperty (This_XDisplay, xsr->requestor, xsr->property, xsr->target, tp.format, PropModeReplace, tp.value, tp.nitems); sev.type = SelectionNotify; sev.requestor = xsr->requestor; sev.selection = xsr->selection; sev.target = target; sev.time = xsr->time; sev.property = xsr->property; /* Apparantly XChangeProperty can return BadRequest, even if it succeeds. * So ignore its return value except for BadAlloc */ if (status != BadAlloc) (void) XSendEvent (This_XDisplay, xsr->requestor, False, (long)NULL, (XEvent*)&sev); if (free_tp_value) XFree (tp.value); return len; } static char *x_server_vendor (void) { return The_Xserver_Vendor; } #if SLANG_VERSION < 10404 static char *get_termcap_string (char *cap) { return ""; } #endif static void x_set_meta_keys (int *maskp) { int mask = *maskp; JX_MetaMask = 0; if (mask & (1<<0)) JX_MetaMask |= Mod1Mask; if (mask & (1<<1)) JX_MetaMask |= Mod2Mask; if (mask & (1<<2)) JX_MetaMask |= Mod3Mask; if (mask & (1<<3)) JX_MetaMask |= Mod4Mask; if (mask & (1<<4)) JX_MetaMask |= Mod5Mask; } static SLang_Intrin_Fun_Type sl_x_table[] = /*{{{*/ { MAKE_INTRINSIC_S("x_set_window_name", set_window_name, VOID_TYPE), MAKE_INTRINSIC_S("x_set_icon_name", set_icon_name, VOID_TYPE), MAKE_INTRINSIC("x_warp_pointer", x_warp_pointer, VOID_TYPE, 0), MAKE_INTRINSIC("x_insert_cutbuffer", x_insert_cutbuffer, INT_TYPE, 0), /* Prototype: Integer x_insert_cutbuffer (); * Inserts cutbuffer into the current buffer and returns the number * of characters inserted. */ MAKE_INTRINSIC("x_copy_region_to_cutbuffer", x_region_2_cutbuffer, VOID_TYPE, 0), /*Prototype: Void x_copy_region_to_cutbuffer(); */ MAKE_INTRINSIC("x_insert_selection", x_insert_selection, SLANG_INT_TYPE, 0), /* Prototype: Integer x_insert_selection (); * This function only requests selection data from the selection owner. * If Xjed received EVENT, Xjed inserts selection data into the current buffer. * And returns the number of characters inserted. */ MAKE_INTRINSIC("x_copy_region_to_selection", x_region_2_selection, VOID_TYPE, 0), /*Prototype: Void x_copy_region_to_selection(); */ MAKE_INTRINSIC_IIS("x_set_keysym", x_set_keysym, VOID_TYPE), /*Prototype: Void x_set_keysym (Integer keysym, Integer shift, String str); * * This function may be used to assocate a string 'str' with a key * 'keysym' modified by mask @shift@. Pressing the key associated with * @keysym@ will then generate the keysequence given by @str@. The * function keys are mapped to integers in the range @0xFF00@ to @0xFFFF@. * On most systems, the keys that these mappings refer to are located in * the file @/usr/include/X11/keysymdef.h@. For example, on my system, the * keysyms for the function keys @XK_F1@ to @XK_F35@ fall in the range * @0xFFBE@ to @0xFFE0@. So to make the @F1@ key correspond to the string * given by the two characters @Ctrl-X@ @Ctrl-C@, simply use: * @ x_set_keysym (0xFFBE, 0, "^X^C"); * The @shift@ argument is an integer with the following meanings: * @ 0 : unmodified key * @ '$' : shifted * @ '^' : control * Any other value for shift will default to 0 (unshifted). */ MAKE_INTRINSIC("x_server_vendor", x_server_vendor, STRING_TYPE, 0), /* Prototype: String x_server_vendor (); * This function returns the vendor name of the X server. */ MAKE_INTRINSIC_I("x_set_meta_keys", x_set_meta_keys, SLANG_VOID_TYPE), #if SLANG_VERSION < 10404 MAKE_INTRINSIC_S("get_termcap_string", get_termcap_string, STRING_TYPE), #endif MAKE_INTRINSIC_0("x_toggle_visibility", x_toggle_visibility, SLANG_VOID_TYPE), MAKE_INTRINSIC(NULL,NULL,0,0) }; /*}}}*/ static SLang_Intrin_Var_Type X_Variable_Table [] = { MAKE_VARIABLE("ALT_CHAR", &X_Alt_Char, INT_TYPE, 0), MAKE_VARIABLE("X_LAST_KEYSYM", &X_Last_Keysym, INT_TYPE, 0), MAKE_VARIABLE(NULL,NULL,0,0) }; static int X_init_slang (void) /*{{{*/ { if ((-1 == SLadd_intrin_fun_table (sl_x_table, "XWINDOWS")) || (-1 == SLadd_intrin_var_table (X_Variable_Table, NULL))) return -1; return 0; } /*}}}*/ static void X_update_open (void) /*{{{*/ { hide_cursor (); if (Check_Buffers_Pending) { check_buffers(); Check_Buffers_Pending = 0; } Performing_Update = 1; } /*}}}*/ static void X_update_close (void) /*{{{*/ { Performing_Update = 0; if (XWin->window_mapped == 0) JWindow->trashed = 1; if (JWindow->trashed) return; show_cursor (); if (X_Warp_Pending) { XWarpPointer (This_XDisplay, None, XWin->w, 0, 0, 0, 0, (XWin->vis_curs_col * XWin->font_width + XWin->border + XWin->font_width / 2), (XWin->vis_curs_row * XWin->font_height + XWin->border + XWin->font_height / 2)); X_Warp_Pending = 0; } } /*}}}*/ static void x_define_xkeys (SLKeyMap_List_Type *map) /*{{{*/ { SLkm_define_key ("\033[^D", (FVOID_STAR) jed_scroll_right_cmd, map); SLkm_define_key ("\033[d", (FVOID_STAR) jed_scroll_right_cmd, map); SLkm_define_key ("\033[^C", (FVOID_STAR) jed_scroll_left_cmd, map); SLkm_define_key ("\033[c", (FVOID_STAR) jed_scroll_left_cmd, map); SLkm_define_key ("\033[a", (FVOID_STAR) bob, map); SLkm_define_key ("\033[^A", (FVOID_STAR) bob, map); SLkm_define_key ("\033[b", (FVOID_STAR) eob, map); SLkm_define_key ("\033[^B", (FVOID_STAR) eob, map); SLkm_define_key ("\033[1~", (FVOID_STAR) bol, map); /* home */ SLkm_define_key ("\033[4~", (FVOID_STAR) eol, map); /* end */ } /*}}}*/ static int JX_reset_video (void) /*{{{*/ { JX_reset_scroll_region (); JX_goto_rc (0, 0); JX_normal_video (); /* return vterm_reset_display (); */ return 0; } /*}}}*/ static int JX_init_video (void) /*{{{*/ { JX_reset_video (); if ((JX_Screen_Rows == 0) || (JX_Screen_Cols == 0)) { JX_Screen_Cols = 80; JX_Screen_Rows = 24; } /* return vterm_init_display (JX_Screen_Rows, JX_Screen_Cols); */ return 0; } /*}}}*/ void flush_output (void) /*{{{*/ { if (This_XDisplay == NULL) fflush (stdout); else SLtt_flush_output (); } /*}}}*/ /* a hook to parse some command line args. */ int (*X_Argc_Argv_Hook)(int, char **) = X_eval_command_line; static int JX_flush_output (void) { return 0; } static int JX_Zero = 0; static void get_screen_size (int *r, int *c) { SLtt_get_screen_size (); *r = SLtt_Screen_Rows; *c = SLtt_Screen_Cols; } /* the links to functions and variables here */ void (*tt_beep)(void); void (*tt_write_string)(char *); JX_SETXXX_RETURN_TYPE (*tt_set_color)(int, char *, char *, char *); JX_SETXXX_RETURN_TYPE (*tt_set_color_esc)(int, char *); JX_SETXXX_RETURN_TYPE (*tt_set_mono) (int, char *, SLtt_Char_Type); void (*tt_wide_width)(void); void (*tt_narrow_width)(void); void (*tt_enable_cursor_keys)(void); void (*tt_set_term_vtxxx)(int *); void (*tt_get_screen_size)(int *, int *); int *tt_Ignore_Beep; int *tt_Use_Ansi_Colors; int *tt_Term_Cannot_Scroll; int *tt_Term_Cannot_Insert; int *tt_Blink_Mode; /* int *tt_Baud_Rate; */ static void set_xtt_hooks (void) { tt_beep = JX_beep; tt_write_string = JX_write_string; tt_get_screen_size = JX_get_display_size; tt_set_color = JX_set_color; tt_set_mono = JX_set_mono; tt_wide_width = JX_wide_width; tt_narrow_width = JX_narrow_width; tt_enable_cursor_keys = JX_enable_cursor_keys; tt_set_term_vtxxx = JX_set_term_vtxxx; tt_Ignore_Beep = &JX_Ignore_Beep; tt_Use_Ansi_Colors = &JX_Use_Ansi_Colors; tt_Term_Cannot_Scroll = &JX_Term_Cannot_Scroll; tt_Term_Cannot_Insert = &JX_Term_Cannot_Insert; tt_Blink_Mode = &JX_Blink_Mode; } static void JX_get_terminfo (void) /*{{{*/ { SLsmg_Term_Type tt; #ifdef REAL_UNIX_SYSTEM SLtt_Force_Keypad_Init = 1; #endif if ((Batch) || !open_Xdisplay()) { /* This function should match the corresponding function in display.c. * I should "include" it to guarantee the correspondence. */ tt_beep = SLtt_beep; tt_write_string = SLtt_write_string; tt_get_screen_size = get_screen_size; tt_set_color = SLtt_set_color; tt_set_mono = SLtt_set_mono; #if SLANG_VERSION < 20000 tt_set_color_esc = SLtt_set_color_esc; #endif tt_wide_width = SLtt_wide_width; tt_narrow_width = SLtt_narrow_width; tt_enable_cursor_keys = SLtt_enable_cursor_keys; tt_set_term_vtxxx = SLtt_set_term_vtxxx; tt_Ignore_Beep = &SLtt_Ignore_Beep; tt_Use_Ansi_Colors = &SLtt_Use_Ansi_Colors; tt_Term_Cannot_Scroll = &SLtt_Term_Cannot_Scroll; tt_Term_Cannot_Insert = &SLtt_Term_Cannot_Insert; tt_Blink_Mode = &SLtt_Blink_Mode; /* tt_Baud_Rate = &SLtt_Baud_Rate; */ if (Batch == 0) SLtt_get_terminfo (); return; } set_xtt_hooks (); if (-1 == init_xkeys ()) { } JX_Screen_Cols = 80; JX_Screen_Rows = 24; (void) jed_add_init_slang_hook (X_init_slang); /* init hooks */ X_Read_Hook = X_read_key; X_Input_Pending_Hook = X_input_pending; X_Update_Open_Hook = X_update_open; X_Update_Close_Hook = X_update_close; X_Suspend_Hook = xjed_suspend; X_Init_Term_Hook = init_Xdisplay; X_Reset_Term_Hook = reset_Xdisplay; X_Define_Keys_Hook = x_define_xkeys; SLang_Interrupt = xjed_check_kbd; /* Set this so that main will not try to read from stdin. It is quite * likely that this is started from a menu or something. */ Stdin_Is_TTY = -1; /* We do not need this since we do not have to worry about incoming * eight bit escape sequences. */ DEC_8Bit_Hack = 0; memset ((char *) &tt, 0, sizeof (SLsmg_Term_Type)); tt.tt_normal_video = JX_normal_video; tt.tt_set_scroll_region = JX_set_scroll_region; tt.tt_goto_rc = JX_goto_rc; tt.tt_reverse_index = JX_reverse_index; tt.tt_reset_scroll_region = JX_reset_scroll_region; tt.tt_delete_nlines = JX_delete_nlines; tt.tt_cls = JX_cls; tt.tt_del_eol = JX_del_eol; tt.tt_smart_puts = JX_smart_puts; tt.tt_flush_output = JX_flush_output; tt.tt_reset_video = JX_reset_video; tt.tt_init_video = JX_init_video; tt.tt_screen_rows = &JX_Screen_Rows; tt.tt_screen_cols = &JX_Screen_Cols; tt.tt_term_cannot_scroll = &JX_Term_Cannot_Scroll; tt.tt_has_alt_charset = &JX_Zero; #if SLANG_VERSION >= 20000 tt.unicode_ok = &Jed_UTF8_Mode; #endif SLsmg_set_terminal_info (&tt); Jed_Handle_SIGTSTP = 0; } /*}}}*/ void (*tt_get_terminfo)(void) = JX_get_terminfo; /* Unused but required. */ #ifdef USE_GPM_MOUSE int (*X_Open_Mouse_Hook)(void); void (*X_Close_Mouse_Hook)(void); #endif jed-0.99-19/src/pty.c0000644002657400265740000001256211311317447013247 0ustar davisdavis/* Copyright (c) 1992, 1998, 2000, 2002, 2003, 2004, 2005, 2006 John E. Davis * This file is part of JED editor library source. * * You may distribute this file under the terms the GNU General Public * License. See the file COPYING for more information. */ /* This file should only be included if REALLY_HAVE_TERMIOS_H is defined. */ #include #ifdef sun # ifndef PENDIN # include # endif #else # include #endif #include #ifdef HAVE_GRANTPT # if !defined (__linux__) && !defined(__CYGWIN__) && !defined(__FreeBSD__) && !defined(_AIX) # define USE_SYSV_PTYS # include # include # endif #endif #ifdef HAVE_PTY_H # include #endif #ifdef HAVE_SYS_PTY_H # include #endif static int pty_setup_slave_term (int slave, int raw) { struct termios slave_termios; while (-1 == tcgetattr (slave, &slave_termios)) { #ifdef EINTR if (errno == EINTR) continue; #endif return -1; } slave_termios.c_lflag = 0; if (raw == 0) slave_termios.c_lflag |= ICANON; slave_termios.c_iflag &= ~(ECHO | INLCR | ICRNL); #ifdef ONLRET slave_termios.c_oflag |= ONLRET; #endif #ifdef ONLCR slave_termios.c_oflag &= ~ONLCR; #endif slave_termios.c_cc[VEOF] = 4; slave_termios.c_cc[VMIN] = 1; slave_termios.c_cc[VTIME] = 0; /* while (-1 == tcsetattr (slave, TCSANOW, &slave_termios)) */ while (-1 == tcsetattr (slave, TCSADRAIN, &slave_termios)) { #ifdef EINTR if (errno == EINTR) continue; #endif return -1; } return 0; } #ifndef USE_SYSV_PTYS # include # include # include # ifdef HAVE_OPENPTY static int pty_open_master_pty (int *master, char *slave_tty_name) { int slave; char *s; if (-1 == openpty (master, &slave, NULL, NULL, NULL)) return -1; if (NULL == (s = ttyname (slave))) { signal_safe_close (*master); signal_safe_close (slave); return -1; } safe_strcpy (slave_tty_name, s, MAX_TTY_SLAVE_NAME); (void) pty_setup_slave_term (slave, 1); signal_safe_close (slave); (void) pty_setup_slave_term (*master, 1); return 0; } # else /* NOT HAVE_OPENPTY */ static int pty_open_master_pty (int *master, char *slave_tty_name) { char *a, *b; strcpy (slave_tty_name, "/dev/ptyab"); a = "pqrstuvwxyz"; while (*a != 0) { slave_tty_name [8] = *a++; b = "0123456789abcdef"; while (*b != 0) { int slave; slave_tty_name [9] = *b++; if (-1 == (*master = signal_safe_open (slave_tty_name, O_RDWR))) continue; /* Make sure the slave can be opened. I attempt to set up * the master terminal also even though it is not a tty and will * probably fail. */ slave_tty_name [5] = 't'; if (-1 != (slave = open (slave_tty_name, O_RDWR))) { (void) pty_setup_slave_term (slave, 1); signal_safe_close (slave); (void) pty_setup_slave_term (*master, 1); return 0; } signal_safe_close (*master); slave_tty_name [5] = 'p'; } } return -1; } # endif /* HAVE_OPENPTY */ static int pty_open_slave_pty (char *slave_name, int *slave) { int fd; struct group *g; *slave = -1; if (NULL != (g = getgrnam ("tty"))) { int gid = g->gr_gid; (void) chown (slave_name, getuid (), gid); # ifndef S_IRUSR # define S_IRUSR 0400 # endif # ifndef S_IWUSR # define S_IWUSR 0200 # endif # ifndef S_IWGRP # define S_IWGRP 0020 # endif (void) chmod (slave_name, S_IRUSR | S_IWUSR | S_IWGRP); } if (-1 == (fd = signal_safe_open (slave_name, O_RDWR))) return -1; # if defined(TIOCSCTTY) && !defined(CIBAUD) /* Stevens says use CIBAUD to avoid doing this under SunOS. * This gives us a controlling terminal. */ while ((-1 == ioctl (fd, TIOCSCTTY, NULL)) && (errno == EINTR)); # endif *slave = fd; return 0; } #else static int pty_open_master_pty (int *master, char *slave_tty_name) { int fd; char *slave_name; *master = -1; *slave_tty_name = 0; if (-1 == (fd = signal_safe_open ("/dev/ptmx", O_RDWR))) return -1; /* According to the solaris man page, this could fail if jed catches * SIGCHLD. So lets block it. */ jed_block_child_signal (1); if (-1 == grantpt (fd)) { jed_block_child_signal (0); signal_safe_close (fd); return -1; } if (-1 == unlockpt (fd)) { jed_block_child_signal (0); (void) signal_safe_close (fd); return -1; } jed_block_child_signal (0); if (NULL == (slave_name = ptsname (fd))) { (void) signal_safe_close (fd); return -1; } safe_strcpy (slave_tty_name, slave_name, MAX_TTY_SLAVE_NAME); *master = fd; return 0; } static int pty_open_slave_pty (char *slave_name, int *slave) { int fd; *slave = -1; /* The open here will make this the controlling terminal */ if (-1 == (fd = signal_safe_open (slave_name, O_RDWR))) return -1; if ((-1 == ioctl (fd, I_PUSH, "ptem")) || (-1 == ioctl (fd, I_PUSH, "ldterm"))) { signal_safe_close (fd); return -1; } /* Some systems are reported not to have ttcompat. Since it is a BSD * compatibility interface, let it silently fail if errno is EINVAL. */ if (-1 == ioctl (fd, I_PUSH, "ttcompat")) { # ifdef EINVAL if (errno != EINVAL) { signal_safe_close (fd); return -1; } # endif } *slave = fd; return 0; } #endif jed-0.99-19/src/vterm.h0000644002657400265740000000214411311317447013570 0ustar davisdavis/* Copyright (c) 1992, 1998, 2000, 2005, 2006 John E. Davis * This file is part of JED editor library source. * * You may distribute this file under the terms the GNU General Public * License. See the file COPYING for more information. */ extern int VTerm_Num_Rows, VTerm_Num_Cols; #if SLANG_VERSION < 10310 typedef unsigned short SLsmg_Char_Type; # define SLSMG_EXTRACT_CHAR(x) ((x) & 0xFF) # define SLSMG_EXTRACT_COLOR(x) (((x)>>8)&0xFF) # define SLSMG_BUILD_CHAR(ch,color) (((SLsmg_Char_Type)(unsigned char)(ch))|((color)<<8)) #endif extern SLsmg_Char_Type **VTerm_Display; extern int VTerm_Suspend_Update; extern int vterm_init_display (int, int); extern int vterm_reset_display (void); extern void vterm_set_scroll_region (int, int); extern void vterm_delete_nlines (int); extern void vterm_reverse_index (int); extern void vterm_del_eol (void); extern void vterm_goto_rc (int, int); extern void vterm_reverse_video (int); extern void vterm_cls (void); extern void vterm_write_nchars (char *, unsigned int); extern void vterm_forward_cursor (int); /* extern void vterm_write (unsigned short *, unsigned int); */ jed-0.99-19/src/intrin.c0000644002657400265740000010053311311317447013732 0ustar davisdavis/* -*- mode: C; mode: fold; -*- */ /* Copyright (c) 1992, 1998, 2000, 2002, 2003, 2004, 2005, 2006 John E. Davis * This file is part of JED editor library source. * * You may distribute this file under the terms the GNU General Public * License. See the file COPYING for more information. */ #include "config.h" #include "jed-feat.h" /*{{{ Include Files */ #include #include #include "jdmacros.h" #ifdef HAVE_STDLIB_H # include #endif #ifdef HAVE_UNISTD_H # include #endif #include #include "buffer.h" #include "keymap.h" #include "file.h" #include "ins.h" #include "ledit.h" #include "screen.h" #include "window.h" #include "display.h" #include "search.h" #include "misc.h" #include "replace.h" #include "paste.h" #include "sysdep.h" #include "cmds.h" #include "text.h" #include "abbrev.h" #include "indent.h" #include "colors.h" #if JED_HAS_LINE_ATTRIBUTES # include "lineattr.h" #endif #if JED_HAS_SUBPROCESSES # include "jprocess.h" #endif #if defined(__DECC) && defined(VMS) # include #endif #if defined(__MSDOS__) || defined(__os2__) || defined(__WIN32__) # include #endif /*}}}*/ extern char Jed_Root_Dir[JED_MAX_PATH_LEN]; static void do_buffer_keystring (char *s) /*{{{*/ { buffer_keystring (s, strlen(s)); } /*}}}*/ static void do_tt_write_string (char *s) /*{{{*/ { if (Batch) { fputs (s, stdout); } else tt_write_string (s); } /*}}}*/ #ifndef IBMPC_SYSTEM static void do_tt_set_term_vtxxx (int *i) /*{{{*/ { tt_set_term_vtxxx (i); } /*}}}*/ #endif static void autoload_n (void) /*{{{*/ { int n; char *file, *fun; if (SLang_pop_integer (&n)) return; while ((n > 0) && (0 == SLang_get_error ())) { n--; if (SLang_pop_slstring (&file)) return; if (SLang_pop_slstring (&fun)) { SLang_free_slstring (file); return; } (void) SLang_autoload (fun, file); SLang_free_slstring (file); SLang_free_slstring (fun); } } /*}}}*/ static void add_to_completion_n (void) /*{{{*/ { int n; char *fun; if (SLang_pop_integer (&n)) return; while (n > 0) { n--; if (SLang_pop_slstring (&fun)) return; if (-1 == add_to_completion (fun)) { SLang_free_slstring (fun); return; } SLang_free_slstring (fun); } } /*}}}*/ static void translate_region (void) /*{{{*/ { SLang_Array_Type *a; char **strings; int zero = 0; Mark *m; if (0 == check_region (&zero)) return; exchange_point_mark (); m = CBuf->marks; if (-1 == SLang_pop_array_of_type (&a, SLANG_STRING_TYPE)) return; if (a->num_elements != 256) { jed_verror ("translate_region: String_Type[256] required"); SLang_free_array (a); return; } strings = (char **) a->data; Suspend_Screen_Update = 1; while ((CLine != m->line) || (Point != m->point)) { char *s = strings [*(CLine->data + Point)]; if (s == NULL) { (void) jed_right (1); continue; } if (-1 == jed_insert_nbytes ((unsigned char *)s, strlen (s))) break; if (-1 == jed_generic_del_nbytes (1)) break; } /* Leave point at end of region */ jed_pop_mark (0); SLang_free_array (a); } /*}}}*/ static int write_region_cmd (char *file) /*{{{*/ { int n = write_region (file); if (n == -1) { jed_verror ("Error writing region to %s", file); } return n; } /*}}}*/ static void enable_menu_bar (int *what) /*{{{*/ { Window_Type *w; /* find the top window */ w = JWindow; while (w->sy != Top_Window_SY) w = w->next; if (*what) { if (Top_Window_SY != 0) return; if (w->rows < 3) { /* window is too small --- fix it. */ one_window (); w = JWindow; if (w->rows < 3) return; } Top_Window_SY = 1; w->sy = Top_Window_SY; w->rows -= 1; } else { if (Top_Window_SY == 0) return; Top_Window_SY = 0; w->sy = Top_Window_SY; w->rows += 1; } touch_screen (); } /*}}}*/ static int rename_file (char *f1, char *f2) /*{{{*/ { return rename (f1, f2); } /*}}}*/ static void exit_error_cmd (char *msg, int *severity) /*{{{*/ { exit_error (msg, *severity); } /*}}}*/ static void do_prefix_argument (void) /*{{{*/ { int n; if (SLang_Num_Function_Args == 1) { /* old semantics */ if (-1 == SLang_pop_integer (&n)) return; if (Repeat_Factor != NULL) n = *Repeat_Factor; } else if (Repeat_Factor == NULL) { SLang_push_null (); return; } else n = *Repeat_Factor; (void) SLang_push_integer (n); Repeat_Factor = NULL; } /*}}}*/ static void set_prefix_argument (int *n) { static int rf; rf = *n; if (*n < 0) Repeat_Factor = NULL; else Repeat_Factor = &rf; } static void bury_buffer(char *name) /*{{{*/ { Buffer *b, *cp, *bp, *bn; if ((NULL == (b = find_buffer(name))) || (b == CBuf) || (CBuf == (bn = b->next))) return; cp = CBuf->prev; bp = b->prev; CBuf->prev = b; /* my definition of bury buffer */ b->next = CBuf; b->flags |= BURIED_BUFFER; bp->next = bn; bn->prev = bp; cp->next = b; b->prev = cp; } /*}}}*/ static void set_buffer_hook (void) /*{{{*/ { SLang_Name_Type *f; char *s; if (NULL == (f = SLang_pop_function ())) return; if (-1 == SLang_pop_slstring (&s)) { SLang_free_function (f); return; } if (-1 == jed_set_buffer_hook (CBuf, s, f)) SLang_free_function (f); SLang_free_slstring (s); } /*}}}*/ static void get_buffer_hook (char *name) { SLang_Name_Type *nt = jed_get_buffer_hook (CBuf, name); (void) SLang_push_function (nt); SLang_free_function (nt); } static void unset_buffer_hook (char *h) /*{{{*/ { (void) jed_unset_buffer_hook (CBuf, h); } /*}}}*/ static Buffer *pop_buffer (int nargs) { Buffer *b; char *s; if (nargs != SLang_Num_Function_Args) return CBuf; if (-1 == SLang_pop_slstring (&s)) return NULL; if (NULL == (b = find_buffer (s))) jed_verror ("Unable to find a buffer named %s", s); SLang_free_slstring (s); return b; } static void get_buffer_info(void) /*{{{*/ { Buffer *b; if (NULL == (b = pop_buffer (1))) return; check_buffer (b); (void) SLang_push_string (b->file); (void) SLang_push_string (b->dir); (void) SLang_push_string (b->name); (void) SLang_push_integer (b->flags); } /*}}}*/ static void set_buffer_info(char *file, char *dir, char *name, int *flagsp) /*{{{*/ { char *tmp; Buffer *b; if (NULL == (b = pop_buffer (5))) return; tmp = SLmalloc (strlen (dir) + 2); if (tmp == NULL) return; strcpy (tmp, dir); dir = tmp; fixup_dir (dir); tmp = jed_standardize_filename (dir); SLfree (dir); if (tmp == NULL) return; if ((file != b->file) || (tmp != b->dir)) buffer_filename (b, tmp, file); SLfree (tmp); if (name != b->name) uniquely_name_buffer (b, name); jed_set_buffer_flags (b, (unsigned int) *flagsp); } /*}}}*/ static void intrin_load_buffer (void) { char *ns = NULL; if ((SLang_Num_Function_Args == 1) && (-1 == SLang_pop_slstring (&ns))) return; jed_load_buffer (ns); SLang_free_slstring (ns); /* NULL ok */ } static int intrin_what_mode(void) /*{{{*/ { Buffer *b; char *m; if (NULL == (b = pop_buffer (1))) return -1; if (NULL == (m = b->mode_string)) m = ""; SLang_push_string (m); return b->modes; } /*}}}*/ static void intrin_set_mode (int *flags) { char *mode; if (-1 == SLang_pop_slstring (&mode)) return; SLang_free_slstring (CBuf->mode_string); CBuf->mode_string = mode; CBuf->modes = *flags; #if JED_HAS_LINE_ATTRIBUTES CBuf->min_unparsed_line_num = 1; CBuf->max_unparsed_line_num = Max_LineNum + CBuf->nup; #endif } #ifdef REAL_UNIX_SYSTEM static char *get_termcap_string (char *cap) /*{{{*/ { char *s; if (Batch) s = NULL; else s = SLtt_tgetstr (cap); if (s == NULL) s = ""; return s; } /*}}}*/ #endif static void intrin_insert_char (unsigned long *chp) { (void) jed_insert_wchar ((SLwchar_Type) *chp); } static void intrin_insert_byte (unsigned char *chp) { (void) jed_insert_byte ((unsigned char)*chp); } static void del_intrinsic (void) { (void) jed_del_wchar (); } static int file_changed_on_disk_cmd (char *file) { return file_changed_on_disk (CBuf, file); } static int get_point_cmd (void) { return Point; } static void set_point_cmd (int *p) { jed_position_point (CLine->data + *p); } static void expand_filename_cmd (char *s) { if (NULL != (s = jed_expand_filename (s))) (void) SLang_push_malloced_string (s); } static void insert_string (void) { char *s; SLang_BString_Type *bs; unsigned int len; int ret = 0; switch (SLang_peek_at_stack ()) { case SLANG_STRING_TYPE: if (-1 == SLang_pop_slstring (&s)) return; ret = jed_insert_string (s); SLang_free_slstring (s); break; default: if (-1 == SLang_pop_bstring (&bs)) return; if (NULL != (s = (char *)SLbstring_get_pointer (bs, &len))) ret = jed_insert_nbytes ((unsigned char *)s, len); SLbstring_free (bs); } if (ret == -1) jed_verror ("insert: insertion failed"); } static int get_top_window_row (void) { return Top_Window_SY + 1; } static void exit_jed_intrin (void) { int status = 0; if ((SLang_Num_Function_Args == 1) && (-1 == SLang_pop_integer (&status))) return; (void) jed_exit_jed (status); } static void quit_jed_intrin (void) { int status = 0; if ((SLang_Num_Function_Args == 1) && (-1 == SLang_pop_integer (&status))) return; (void) jed_quit_jed (status); } static int jed_system (char *s) /*{{{*/ { if (Jed_Secure_Mode) { msg_error ("Access to shell denied."); return -1; } #ifdef IBMPC_SYSTEM return sys_System (s); #else return SLsystem (s); #endif } /*}}}*/ static int run_program (char *s) /*{{{*/ { int status; if (Jed_Secure_Mode) { msg_error ("Access to shell denied."); return -1; } status = SLang_run_hooks ("_jed_run_program_hook", 1, s); if (status == 0) return jed_spawn_fg_process ((int (*)(VOID_STAR))jed_system, (VOID_STAR) s); if (status == -1) return -1; if (-1 == SLang_pop_integer (&status)) return -1; return status; } /*}}}*/ static void expand_link_intrin (char *s) { if (NULL != (s = jed_expand_link (s))) (void) SLang_push_malloced_string (s); } static int right_intrinsic (int *np) { if (*np < 0) return 0; return jed_right (*np); } static int left_intrinsic (int *np) { if (*np < 0) return 0; return jed_left (*np); } static int up_intrinsic (int *np) { if (*np < 0) return 0; return jed_up ((unsigned int) *np); } static int down_intrinsic (int *np) { if (*np < 0) return 0; return jed_down ((unsigned int) *np); } static void pop_mark_intrin (int *go) { jed_pop_mark (*go); } static void trim_intrinsic (void) { (void) jed_trim_whitespace (); } static void skip_white_intrin (void) { (void) jed_skip_whitespace (); } static void set_line_number_mode (int *statusp) { #if JED_HAS_DISPLAY_LINE_NUMBERS int status = *statusp; if (status < 0) status = (CBuf->line_num_display_size == 0); CBuf->line_num_display_size = (status > 0); #else (void) statusp; #endif } static void what_char_intrin (void) { SLwchar_Type ch; if (-1 == jed_what_char (&ch)) (void) SLang_push_integer (-(int)ch); else (void) SLclass_push_long_obj (SLANG_ULONG_TYPE, ch); } static int intrin_strwidth (char *s) { char *smax; smax = s + strlen (s); #if SLANG_VERSION < 20000 /* This is technically not correct but slang-1 will not be supported for * much longer. */ return smax - s; #else return (int) SLsmg_strwidth ((SLuchar_Type *)s, (SLuchar_Type *)smax); #endif } #if 0 static int get_utf8_mode (void) { return CBuf->local_vars.is_utf8; } static void set_utf8_mode (int *yes_no) { CBuf->local_vars.is_utf8 = (*yes_no != 0); } #endif /* These pointers are necessary because the things they are assigned to * are character arrays. Character arrays are not valid in MAKE_VARIABLE. */ static char *Default_Status_Line_Ptr = Default_Status_Line; static char *Message_Buffer_Ptr = Message_Buffer; static char *Jed_Root_Dir_Ptr = Jed_Root_Dir; static SLang_Intrin_Fun_Type Jed_Intrinsics [] = /*{{{*/ { #if 0 MAKE_INTRINSIC_0("get_utf8_mode", get_utf8_mode, INT_TYPE), MAKE_INTRINSIC_I("set_utf8_mode", set_utf8_mode, VOID_TYPE), #endif MAKE_INTRINSIC_S("expand_symlink", expand_link_intrin, VOID_TYPE), MAKE_INTRINSIC_I("_set_point", set_point_cmd, VOID_TYPE), MAKE_INTRINSIC_0("_get_point", get_point_cmd, INT_TYPE), MAKE_INTRINSIC("_autoload", autoload_n, VOID_TYPE, 0), MAKE_INTRINSIC("push_mark", jed_push_mark,VOID_TYPE, 0), MAKE_INTRINSIC("bol", bol,VOID_TYPE, 0), MAKE_INTRINSIC_0("insert", insert_string,VOID_TYPE), MAKE_INTRINSIC_1("insert_char", intrin_insert_char, VOID_TYPE, SLANG_ULONG_TYPE), MAKE_INTRINSIC_1("insert_byte", intrin_insert_byte, VOID_TYPE, SLANG_UCHAR_TYPE), MAKE_INTRINSIC("eol", eol,VOID_TYPE, 0), MAKE_INTRINSIC_S("setbuf", set_buffer, VOID_TYPE), MAKE_INTRINSIC("_add_completion", add_to_completion_n, VOID_TYPE, 0), MAKE_INTRINSIC("del_region", delete_region, VOID_TYPE, 0), MAKE_INTRINSIC("bufsubstr", buffer_substring, VOID_TYPE, 0), MAKE_INTRINSIC_I("right", right_intrinsic, INT_TYPE), MAKE_INTRINSIC_I("left", left_intrinsic, INT_TYPE), MAKE_INTRINSIC("whatbuf", what_buffer, STRING_TYPE, 0), MAKE_INTRINSIC("getbuf_info", get_buffer_info, VOID_TYPE, 0), MAKE_INTRINSIC_S("is_internal", is_internal, INT_TYPE), MAKE_INTRINSIC_4("setbuf_info", set_buffer_info, VOID_TYPE, STRING_TYPE, STRING_TYPE, STRING_TYPE, INT_TYPE), MAKE_INTRINSIC_I("up", up_intrinsic, INT_TYPE), MAKE_INTRINSIC_I("down", down_intrinsic, INT_TYPE), MAKE_INTRINSIC_S("call", jed_call_cmd, VOID_TYPE), MAKE_INTRINSIC("eob", eob,VOID_TYPE, 0), MAKE_INTRINSIC("bob", bob,VOID_TYPE, 0), MAKE_INTRINSIC_S("looking_at", jed_looking_at, INT_TYPE), MAKE_INTRINSIC("del", del_intrinsic, VOID_TYPE, 0), MAKE_INTRINSIC("markp", markp, INT_TYPE, 0), MAKE_INTRINSIC_S("add_completion", add_to_completion, VOID_TYPE), MAKE_INTRINSIC("what_column", calculate_column,INT_TYPE, 0), MAKE_INTRINSIC("eobp", eobp,INT_TYPE, 0), MAKE_INTRINSIC_I("set_mode", intrin_set_mode, VOID_TYPE), MAKE_INTRINSIC_S("buffer_visible", jed_buffer_visible, INT_TYPE), MAKE_INTRINSIC_S("extract_filename", extract_file, STRING_TYPE), MAKE_INTRINSIC_0("trim", trim_intrinsic, VOID_TYPE), MAKE_INTRINSIC_S("pop2buf", pop_to_buffer, VOID_TYPE), MAKE_INTRINSIC_S("pop2buf_whatbuf", pop_to_buffer, STRING_TYPE), #ifndef VMS MAKE_INTRINSIC_SS("copy_file", jed_copy_file, INT_TYPE), #endif MAKE_INTRINSIC_S("copy_region", copy_region_cmd, VOID_TYPE), MAKE_INTRINSIC_S("insbuf", insert_buffer_name, VOID_TYPE), MAKE_INTRINSIC("bolp", bolp,INT_TYPE, 0), MAKE_INTRINSIC("beep", jed_beep, VOID_TYPE, 0), MAKE_INTRINSIC("pop_spot", pop_spot,VOID_TYPE, 0), MAKE_INTRINSIC("push_spot", push_spot,VOID_TYPE, 0), MAKE_INTRINSIC_S("sw2buf", switch_to_buffer_cmd, VOID_TYPE), MAKE_INTRINSIC_S("tt_send", do_tt_write_string, VOID_TYPE), MAKE_INTRINSIC("eolp", eolp,INT_TYPE, 0), MAKE_INTRINSIC_S("find_file", find_file_in_window, INT_TYPE), MAKE_INTRINSIC_SI("set_status_line", set_status_format, VOID_TYPE), MAKE_INTRINSIC_S("bury_buffer", bury_buffer, VOID_TYPE), MAKE_INTRINSIC("dupmark", dup_mark, INT_TYPE, 0), MAKE_INTRINSIC("erase_buffer", erase_buffer, VOID_TYPE, 0), #ifndef SIXTEEN_BIT_SYSTEM MAKE_INTRINSIC_I("copy_region_to_kill_array", copy_region_to_kill_array, VOID_TYPE), MAKE_INTRINSIC_I("append_region_to_kill_array", append_region_to_kill_array, VOID_TYPE), MAKE_INTRINSIC_I("prepend_region_to_kill_array", prepend_region_to_kill_array, VOID_TYPE), MAKE_INTRINSIC_I("insert_from_kill_array", insert_from_kill_array, VOID_TYPE), #endif /* SIXTEEN_BIT_SYSTEM */ MAKE_INTRINSIC_I("goto_column", goto_column, VOID_TYPE), MAKE_INTRINSIC_I("goto_column_best_try", goto_column1, INT_TYPE), MAKE_INTRINSIC_I("goto_line", goto_line,VOID_TYPE), MAKE_INTRINSIC_I("pop_mark", pop_mark_intrin, VOID_TYPE), MAKE_INTRINSIC_SSS("read_mini", mini_read, VOID_TYPE), MAKE_INTRINSIC_S("file_status", file_status, INT_TYPE), MAKE_INTRINSIC_0("skip_white", skip_white_intrin, VOID_TYPE), MAKE_INTRINSIC("bobp", bobp,INT_TYPE, 0), MAKE_INTRINSIC_S("flush", flush_message, VOID_TYPE), MAKE_INTRINSIC_I("input_pending", input_pending, INT_TYPE), MAKE_INTRINSIC_I("usleep", jed_pause, VOID_TYPE), MAKE_INTRINSIC_S("insert_file", insert_file, INT_TYPE), MAKE_INTRINSIC_0("what_char", what_char_intrin, VOID_TYPE), MAKE_INTRINSIC_I("recenter", recenter, VOID_TYPE), MAKE_INTRINSIC_S("bufferp", bufferp, INT_TYPE), MAKE_INTRINSIC_I("update", update_cmd, VOID_TYPE), MAKE_INTRINSIC_I("update_sans_update_hook", update_sans_update_hook_cmd, VOID_TYPE), MAKE_INTRINSIC("skip_word_chars", skip_word_chars, VOID_TYPE, 0), MAKE_INTRINSIC("skip_non_word_chars", skip_non_word_chars, VOID_TYPE, 0), MAKE_INTRINSIC("bskip_word_chars", bskip_word_chars, VOID_TYPE, 0), MAKE_INTRINSIC("bskip_non_word_chars", bskip_non_word_chars, VOID_TYPE, 0), MAKE_INTRINSIC_I("whitespace", insert_whitespace,VOID_TYPE), MAKE_INTRINSIC_SS("file_time_compare", file_time_cmp, INT_TYPE), /* MAKE_INTRINSIC_I("xform_region", transform_region, VOID_TYPE), */ MAKE_INTRINSIC_S("skip_chars", jed_skip_chars, VOID_TYPE), MAKE_INTRINSIC_I("set_file_translation", set_file_trans, VOID_TYPE), #if defined (__unix__) || defined(__WIN32__) || (defined (__os2__) && !defined(__WATCOMC__)) # if (!defined(__GO32__) && !defined(__WATCOMC__)) || defined(__QNX__) MAKE_INTRINSIC_S("pipe_region", pipe_region, INT_TYPE), MAKE_INTRINSIC_S("run_shell_cmd", shell_command, INT_TYPE), # endif #endif MAKE_INTRINSIC_S("append_region_to_file", append_to_file, INT_TYPE), MAKE_INTRINSIC("autosave", auto_save, VOID_TYPE, 0), MAKE_INTRINSIC("autosaveall", auto_save_all, VOID_TYPE, 0), MAKE_INTRINSIC("backward_paragraph", backward_paragraph, VOID_TYPE, 0), MAKE_INTRINSIC("blank_rect", blank_rectangle, VOID_TYPE, 0), MAKE_INTRINSIC_S("bskip_chars", jed_bskip_chars, VOID_TYPE), MAKE_INTRINSIC("buffer_list", make_buffer_list, VOID_TYPE, 0), MAKE_INTRINSIC_I("check_region", check_region, VOID_TYPE), MAKE_INTRINSIC("copy_rect", copy_rectangle, VOID_TYPE, 0), MAKE_INTRINSIC_S("define_word", define_word, VOID_TYPE), MAKE_INTRINSIC_S("delbuf", kill_buffer_cmd, VOID_TYPE), MAKE_INTRINSIC_S("delete_file", sys_delete_file, INT_TYPE), /* MAKE_INTRINSIC_S("directory", expand_wildcards, INT_TYPE), */ MAKE_INTRINSIC("evalbuffer", intrin_load_buffer, VOID_TYPE ,0), MAKE_INTRINSIC_S("expand_filename", expand_filename_cmd, SLANG_VOID_TYPE), MAKE_INTRINSIC_0("check_buffers", check_buffers, SLANG_VOID_TYPE), MAKE_INTRINSIC_S("file_changed_on_disk", file_changed_on_disk_cmd, INT_TYPE), MAKE_INTRINSIC("forward_paragraph", forward_paragraph, VOID_TYPE, 0), MAKE_INTRINSIC("indent_line", indent_line, VOID_TYPE, 0), MAKE_INTRINSIC("insert_rect", insert_rectangle, VOID_TYPE, 0), MAKE_INTRINSIC("kill_rect", kill_rectangle, VOID_TYPE, 0), MAKE_INTRINSIC_II("map_input", map_character, VOID_TYPE), MAKE_INTRINSIC("narrow_to_region", narrow_to_region, VOID_TYPE, 0), MAKE_INTRINSIC("narrow", narrow_to_lines, VOID_TYPE, 0), MAKE_INTRINSIC("open_rect", open_rectangle, VOID_TYPE, 0), MAKE_INTRINSIC("quit_jed", quit_jed_intrin, VOID_TYPE, 0), MAKE_INTRINSIC("exit_jed", exit_jed_intrin, VOID_TYPE, 0), MAKE_INTRINSIC_0("exit", exit_jed_intrin, VOID_TYPE), MAKE_INTRINSIC_S("read_file", find_file_cmd, INT_TYPE), MAKE_INTRINSIC_4("read_with_completion", read_object_with_completion, VOID_TYPE, STRING_TYPE, STRING_TYPE, STRING_TYPE, INT_TYPE), MAKE_INTRINSIC_I("set_abort_char", jed_set_abort_char, VOID_TYPE), MAKE_INTRINSIC("suspend", sys_spawn_cmd, VOID_TYPE, 0), MAKE_INTRINSIC_S("buffer_keystring", do_buffer_keystring, VOID_TYPE), #ifndef IBMPC_SYSTEM MAKE_INTRINSIC("w132", screen_w132, VOID_TYPE, 0), MAKE_INTRINSIC("w80", screen_w80, VOID_TYPE, 0), #endif MAKE_INTRINSIC("what_mode", intrin_what_mode, INT_TYPE, 0), MAKE_INTRINSIC("widen", widen, VOID_TYPE, 0), MAKE_INTRINSIC("widen_region", widen_region, VOID_TYPE, 0), MAKE_INTRINSIC_S("write_buffer", jed_save_buffer_as, INT_TYPE), MAKE_INTRINSIC_S("write_region_to_file", write_region_cmd, INT_TYPE), MAKE_INTRINSIC("count_chars", jed_count_chars, VOID_TYPE, 0), MAKE_INTRINSIC_S("get_yes_no", jed_get_yes_no, INT_TYPE), MAKE_INTRINSIC_S("get_y_or_n", jed_get_y_n, INT_TYPE), MAKE_INTRINSIC_S("get_mini_response", jed_get_mini_response, INT_TYPE), MAKE_INTRINSIC_SS("rename_file", rename_file, INT_TYPE), MAKE_INTRINSIC_S("change_default_dir", ch_dir, INT_TYPE), MAKE_INTRINSIC_0("prefix_argument", do_prefix_argument, VOID_TYPE), MAKE_INTRINSIC_I("set_prefix_argument", set_prefix_argument, SLANG_VOID_TYPE), MAKE_INTRINSIC_0("set_buffer_hook", set_buffer_hook, VOID_TYPE), MAKE_INTRINSIC_S("get_buffer_hook", get_buffer_hook, VOID_TYPE), MAKE_INTRINSIC_S("unset_buffer_hook", unset_buffer_hook, VOID_TYPE), MAKE_INTRINSIC_SSS("insert_file_region", insert_file_region, INT_TYPE), MAKE_INTRINSIC_SSI("search_file", search_file, INT_TYPE), MAKE_INTRINSIC_II("random", make_random_number, INT_TYPE), MAKE_INTRINSIC("translate_region", translate_region, VOID_TYPE, 0), MAKE_INTRINSIC_S("set_current_kbd_command", set_current_kbd_command, VOID_TYPE), MAKE_INTRINSIC("blink_match", blink_match, VOID_TYPE, 0), MAKE_INTRINSIC_S("set_expansion_hook", set_expansion_hook, VOID_TYPE), MAKE_INTRINSIC("clear_message", clear_message, VOID_TYPE, 0), MAKE_INTRINSIC("flush_input", flush_input, VOID_TYPE, 0), MAKE_INTRINSIC_0("get_word_chars", jed_get_word_chars, STRING_TYPE), MAKE_INTRINSIC_SI("core_dump", exit_error_cmd, VOID_TYPE), MAKE_INTRINSIC("get_last_macro", get_last_macro, VOID_TYPE, 0), MAKE_INTRINSIC_S("set_top_status_line", define_top_screen_line, VOID_TYPE), MAKE_INTRINSIC_I("enable_top_status_line", enable_menu_bar, VOID_TYPE), MAKE_INTRINSIC("create_user_mark", create_user_mark, VOID_TYPE, 0), MAKE_INTRINSIC("goto_user_mark", goto_user_mark, VOID_TYPE, 0), MAKE_INTRINSIC("move_user_mark", move_user_mark, VOID_TYPE, 0), MAKE_INTRINSIC("user_mark_buffer", user_mark_buffer, STRING_TYPE, 0), MAKE_INTRINSIC("is_user_mark_in_narrow", jed_is_user_mark_in_narrow, INT_TYPE, 0), #if JED_HAS_LINE_MARKS MAKE_INTRINSIC_I("create_line_mark", jed_create_line_mark, VOID_TYPE), #endif #if JED_HAS_ABBREVS MAKE_INTRINSIC("list_abbrev_tables", list_abbrev_tables, INT_TYPE, 0), MAKE_INTRINSIC_S("use_abbrev_table", use_abbrev_table, VOID_TYPE), MAKE_INTRINSIC_SS("create_abbrev_table", create_abbrev_table, VOID_TYPE), MAKE_INTRINSIC_SSS("define_abbrev", define_abbrev, VOID_TYPE), MAKE_INTRINSIC_S("abbrev_table_p", abbrev_table_p, INT_TYPE), MAKE_INTRINSIC_S("dump_abbrev_table", dump_abbrev_table, VOID_TYPE), MAKE_INTRINSIC("what_abbrev_table", what_abbrev_table, VOID_TYPE, 0), MAKE_INTRINSIC_S("delete_abbrev_table", delete_abbrev_table, VOID_TYPE), #endif /* JED_HAS_ABBREVS */ #if JED_HAS_SUBPROCESSES MAKE_INTRINSIC_I("kill_process", jed_close_process, VOID_TYPE), MAKE_INTRINSIC_IS("send_process", jed_send_process, VOID_TYPE), MAKE_INTRINSIC_I("open_process", jed_open_process, INT_TYPE), #ifdef REAL_UNIX_SYSTEM MAKE_INTRINSIC_I("open_process_pipe", jed_open_process_pipe, INT_TYPE), #endif MAKE_INTRINSIC_I("process_mark", jed_get_process_mark, VOID_TYPE), MAKE_INTRINSIC_0("set_process", jed_set_process, VOID_TYPE), MAKE_INTRINSIC_I("send_process_eof", jed_send_process_eof, VOID_TYPE), MAKE_INTRINSIC_I("get_process_input", get_process_input, VOID_TYPE), MAKE_INTRINSIC_II("signal_process", jed_signal_process, VOID_TYPE), MAKE_INTRINSIC_II("signal_fg_process", jed_signal_fg_process, VOID_TYPE), MAKE_INTRINSIC_II("process_query_at_exit", jed_query_process_at_exit, VOID_TYPE), MAKE_INTRINSIC_II("set_process_flags", jed_set_process_flags, VOID_TYPE), MAKE_INTRINSIC_I("get_process_flags", jed_get_process_flags, INT_TYPE), #endif #ifdef HAS_MOUSE MAKE_INTRINSIC("mouse_get_event_info", jed_mouse_get_event_info, VOID_TYPE, 0), MAKE_INTRINSIC("mouse_set_current_window", jed_set_current_mouse_window, VOID_TYPE, 0), MAKE_INTRINSIC_SS("mouse_set_default_hook", jed_set_default_mouse_hook, VOID_TYPE), MAKE_INTRINSIC_II("mouse_map_buttons", jed_map_mouse_buttons, VOID_TYPE), #endif /* HAS_MOUSE */ /* System specific intrinsics */ #ifndef IBMPC_SYSTEM MAKE_INTRINSIC_I("set_term_vtxxx", do_tt_set_term_vtxxx, VOID_TYPE), #endif #ifdef IBMPC_SYSTEM MAKE_INTRINSIC_S("msdos_fixup_dirspec", msdos_pinhead_fix_dir, STRING_TYPE), #endif #ifdef VMS MAKE_INTRINSIC_SS("vms_get_help", vms_get_help,VOID_TYPE), MAKE_INTRINSIC_SS("vms_send_mail", vms_send_mail, INT_TYPE), #endif #ifdef REAL_UNIX_SYSTEM MAKE_INTRINSIC_I("enable_flow_control", enable_flow_control, VOID_TYPE), /* MAKE_INTRINSIC_S("get_passwd_info", get_passwd_info, VOID_TYPE), */ MAKE_INTRINSIC_S("get_termcap_string", get_termcap_string, STRING_TYPE), #endif #ifdef __os2__ MAKE_INTRINSIC_S("IsHPFSFileSystem", IsHPFSFileSystem, INT_TYPE), #endif MAKE_INTRINSIC_0("TOP_WINDOW_ROW", get_top_window_row, INT_TYPE), MAKE_INTRINSIC_S("run_program", run_program, INT_TYPE), MAKE_INTRINSIC_I("set_line_number_mode", set_line_number_mode, INT_TYPE), MAKE_INTRINSIC_S("strwidth", intrin_strwidth, INT_TYPE), MAKE_INTRINSIC_0("set_undo_position", jed_undo_record_position, VOID_TYPE), SLANG_END_INTRIN_FUN_TABLE }; /*}}}*/ #ifndef IBMPC_SYSTEM static int Obsolete_Int_Variable; #endif static SLang_Intrin_Var_Type Jed_Variables [] = { MAKE_VARIABLE("Status_Line_String", &Default_Status_Line_Ptr, STRING_TYPE, 1), MAKE_VARIABLE("MINIBUFFER_ACTIVE", &MiniBuffer_Active, INT_TYPE, 1), MAKE_VARIABLE("USE_TABS", &Jed_Use_Tabs, INT_TYPE, 0), MAKE_VARIABLE("TAB_DEFAULT", &Jed_Tab_Default, INT_TYPE, 0), MAKE_VARIABLE("CASE_SEARCH", &Buffer_Local.case_search, INT_TYPE, 0), MAKE_VARIABLE("CASE_SEARCH_DEFAULT", &Jed_Case_Search_Default, INT_TYPE, 0), MAKE_VARIABLE("REPLACE_PRESERVE_CASE_INTERNAL", &Replace_Preserve_Case, INT_TYPE, 0), /* Prototype: Integer REPLACE_PRESERVE_CASE_INTERNAL = 0; * This variable affects the @replace@ function. If the length of the * old string is the same as the new string and this variable is * non-zero, then then the case of the old string will be preserved by * the replace function. For example, if @REPLACE_PRESERVE_CASE_INTERNAL@ * is non-zero, and @"abCdE"@ is replaced by @"tuvwx"@, then @"tuVwX"@ will * actually be used. * Note: This variable's value automatically gets reset to zero after every * keystroke. */ MAKE_VARIABLE("what_line", &LineNum,INT_TYPE, 1), MAKE_VARIABLE("BLINK", &Blink_Flag, INT_TYPE, 0), MAKE_VARIABLE("WRAP_INDENTS", &Indented_Text_Mode, INT_TYPE, 0), MAKE_VARIABLE("IGNORE_BEEP", &tt_Ignore_Beep, INTP_TYPE, 0), MAKE_VARIABLE("ADD_NEWLINE", &Require_Final_Newline, INT_TYPE, 0), MAKE_VARIABLE("DISPLAY_TIME", &Display_Time, INT_TYPE, 0), MAKE_VARIABLE("WANT_EOB", &Want_Eob, INT_TYPE, 0), MAKE_VARIABLE("WRAP", &Buffer_Local.wrap_column, INT_TYPE, 0), MAKE_VARIABLE("WRAP_DEFAULT", &Jed_Wrap_Default, INT_TYPE, 0), MAKE_VARIABLE("META_CHAR", &Meta_Char, INT_TYPE, 0), MAKE_VARIABLE("DEC_8BIT_HACK", &DEC_8Bit_Hack, INT_TYPE, 0), MAKE_VARIABLE("BATCH", &Batch, INT_TYPE, 1), MAKE_VARIABLE("TAB", &Buffer_Local.tab, INT_TYPE, 0), MAKE_VARIABLE("MAX_HITS", &Jed_Max_Hits, INT_TYPE, 0), MAKE_VARIABLE("POINT", &Point, INT_TYPE, 0), MAKE_VARIABLE("MESSAGE_BUFFER", &Message_Buffer_Ptr, STRING_TYPE, 1), MAKE_VARIABLE("IGNORE_USER_ABORT", &Ignore_User_Abort, INT_TYPE, 0), MAKE_VARIABLE("KILL_LINE_FEATURE", &Kill_Line_Feature, INT_TYPE, 0), MAKE_VARIABLE("SCREEN_HEIGHT", &Jed_Num_Screen_Rows, INT_TYPE, 1), MAKE_VARIABLE("SCREEN_WIDTH", &Jed_Num_Screen_Cols, INT_TYPE, 1), MAKE_VARIABLE("JED_ROOT", &Jed_Root_Dir_Ptr, STRING_TYPE, 1), MAKE_VARIABLE("LINENUMBERS", &User_Prefers_Line_Numbers, INT_TYPE, 0), MAKE_VARIABLE("HIGHLIGHT", &Wants_Attributes, INT_TYPE, 0), MAKE_VARIABLE("HORIZONTAL_PAN", &Wants_HScroll, INT_TYPE, 0), MAKE_VARIABLE("WANT_SYNTAX_HIGHLIGHT", &Wants_Syntax_Highlight, INT_TYPE, 0), MAKE_VARIABLE("DEFINING_MACRO", &Defining_Keyboard_Macro, INT_TYPE, 1), MAKE_VARIABLE("EXECUTING_MACRO", &Executing_Keyboard_Macro, INT_TYPE, 1), MAKE_VARIABLE("DOLLAR_CHARACTER", &Jed_Dollar, INT_TYPE, 0), MAKE_VARIABLE("Highlight_Trailing_Whitespace", &Jed_Highlight_WS, INT_TYPE, 0), MAKE_VARIABLE("Highlight_Whitespace", &Jed_Highlight_WS, INT_TYPE, 0), MAKE_VARIABLE("_jed_version", &Jed_Version_Number, INT_TYPE, 1), MAKE_VARIABLE("_jed_version_string", &Jed_Version_String, STRING_TYPE, 1), MAKE_VARIABLE("_jed_secure_mode", &Jed_Secure_Mode, INT_TYPE, 1), MAKE_VARIABLE("Simulate_Graphic_Chars", &Jed_Simulate_Graphic_Chars, INT_TYPE, 0), #ifndef IBMPC_SYSTEM MAKE_VARIABLE("OUTPUT_RATE", &Obsolete_Int_Variable, INT_TYPE, 0), MAKE_VARIABLE("USE_ANSI_COLORS", &tt_Use_Ansi_Colors, INTP_TYPE, 0), MAKE_VARIABLE("TERM_CANNOT_INSERT", &tt_Term_Cannot_Insert, INTP_TYPE, 0), MAKE_VARIABLE("TERM_CANNOT_SCROLL", &tt_Term_Cannot_Scroll, INTP_TYPE, 0), MAKE_VARIABLE("TERM_BLINK_MODE", &tt_Blink_Mode, INTP_TYPE, 0), #endif /* !IBMPC_SYSTEM */ #ifdef IBMPC_SYSTEM MAKE_VARIABLE("Case_Sensitive_Filenames", &Jed_Filename_Case_Sensitive, INT_TYPE, 0), # if defined(__MSDOS_16BIT__) || defined(__WIN32__) MAKE_VARIABLE("NUMLOCK_IS_GOLD", &NumLock_Is_Gold, INT_TYPE, 0), # endif # ifndef MSWINDOWS MAKE_VARIABLE("CHEAP_VIDEO", &SLtt_Msdos_Cheap_Video, INTP_TYPE, 0), # endif # ifdef MSWINDOWS MAKE_VARIABLE("FN_CHAR", &PC_Fn_Char, INT_TYPE, 0), # endif MAKE_VARIABLE("ALT_CHAR", &PC_Alt_Char, INT_TYPE, 0), #endif /* IBMPC_SYSTEM */ #ifdef REAL_UNIX_SYSTEM MAKE_VARIABLE("BACKUP_BY_COPYING", &Jed_Backup_By_Copying, INT_TYPE, 0), #endif #ifndef SIXTEEN_BIT_SYSTEM MAKE_VARIABLE("KILL_ARRAY_SIZE", &Kill_Array_Size, INT_TYPE, 1), #endif MAKE_VARIABLE("_Backspace_Key", &_Jed_Backspace_Key, STRING_TYPE, 1), #if JED_HAS_MENUS MAKE_VARIABLE("Menus_Active", &Jed_Menus_Active, INT_TYPE, 1), #endif MAKE_VARIABLE(NULL, NULL, 0, 0) }; int init_jed_intrinsics (void) /*{{{*/ { if ((-1 == SLadd_intrin_fun_table (Jed_Intrinsics, NULL)) || (-1 == SLadd_intrin_fun_table(Jed_Other_Intrinsics, NULL)) || (-1 == SLadd_intrin_var_table (Jed_Variables, NULL)) #if JED_HAS_LINE_ATTRIBUTES || (-1 == SLadd_intrin_fun_table(JedLine_Intrinsics, NULL)) #endif || (-1 == jed_init_color_intrinsics ()) || (-1 == jed_init_keymap_intrinsics ()) || (-1 == jed_init_window_intrinsics ()) ) return -1; /* made here for win32 dll support! */ if ((-1 == SLadd_intrinsic_variable ("DISPLAY_EIGHT_BIT", (VOID_STAR)&SLsmg_Display_Eight_Bit, INT_TYPE, 0)) || (-1 == SLadd_intrinsic_variable ("LAST_CHAR", (VOID_STAR)&SLang_Last_Key_Char, INT_TYPE, 0)) ) return -1; /* overload default slang version of system */ SLadd_intrinsic_function ("system", (FVOID_STAR) jed_system, SLANG_INT_TYPE, 1, SLANG_STRING_TYPE); #if JED_HAS_DISPLAY_TABLE SLang_add_intrinsic_array ("Display_Map", /* slang name */ SLANG_CHAR_TYPE, 0, /* not read-only */ (VOID_STAR) Output_Display_Table, /* location of the array */ 1, 256); #endif #if 0 SLang_add_intrinsic_array ("TRANSLATE_ARRAY", /* slang name */ SLANG_CHAR_TYPE, 0, /* not-readonly */ (VOID_STAR) Translate_Region_Array, /* location of the array */ 1, /* number of dimensions */ 256); /* number of elements in X direction */ #endif #ifdef __MSDOS__ /* SLang does not define this symbol if WIN32 was used. However, as * far as JED is concerned, WIN32 is MSDOS because of the file system. */ SLdefine_for_ifdef ("MSDOS"); #endif #ifdef IBMPC_SYSTEM SLdefine_for_ifdef ("IBMPC_SYSTEM"); #endif #ifdef SIXTEEN_BIT_SYSTEM SLdefine_for_ifdef("16_BIT_SYSTEM"); #endif #if JED_HAS_SUBPROCESSES SLdefine_for_ifdef("SUBPROCESSES"); #endif #if JED_HAS_LINE_ATTRIBUTES SLdefine_for_ifdef("HAS_LINE_ATTR"); #endif #if JED_HAS_BUFFER_LOCAL_VARS SLdefine_for_ifdef("HAS_BLOCAL_VAR"); #endif if (SLang_get_error ()) return -1; return 0; } /*}}}*/ jed-0.99-19/src/win32.h0000644002657400265740000000074611311317447013403 0ustar davisdavis/* Copyright (c) 2007 John E. Davis * This file is part of JED editor library source. * * You may distribute this file under the terms the GNU General Public * License. See the file COPYING for more information. */ #ifndef _JED_WIN32_H_ #define _JED_WIN32_H_ extern FILE *w32_popen(char *, char *); extern int w32_pclose(FILE *); extern char *w32_build_command (char **, unsigned int); extern int w32_init_subprocess_support (int); extern int jed_init_w32_support (void); #endif jed-0.99-19/src/version.c0000644002657400265740000000547411311317447014124 0ustar davisdavis/* Copyright (c) 1999, 2000, 2002, 2003, 2004, 2005, 2006 John E. Davis * This file is part of JED editor library source. * * You may distribute this file under the terms the GNU General Public * License. See the file COPYING for more information. */ #include "config.h" #include "jed-feat.h" #include #include #include #include "buffer.h" #include "version.h" int Jed_Version_Number = JED_VERSION; char *Jed_Version_String = JED_VERSION_STR; #ifdef USE_GPM_MOUSE # undef USE_GPM_MOUSE # define USE_GPM_MOUSE 1 #else # define USE_GPM_MOUSE 0 #endif typedef struct { char *name; int value; } Compile_Option_Type; static Compile_Option_Type Compile_Options [] = { {"LINE_ATTRIBUTES", JED_HAS_LINE_ATTRIBUTES}, {"BUFFER_LOCAL_VARS", JED_HAS_BUFFER_LOCAL_VARS}, {"SAVE_NARROW", JED_HAS_SAVE_NARROW}, {"TTY_MENUS", JED_HAS_MENUS}, {"EMACS_LOCKING", JED_HAS_EMACS_LOCKING}, {"MULTICLICK", JED_HAS_MULTICLICK}, {"SUBPROCESSES", JED_HAS_SUBPROCESSES}, {"DFA_SYNTAX", JED_HAS_DFA_SYNTAX}, {"ABBREVS", JED_HAS_ABBREVS}, {"COLOR_COLUMNS", JED_HAS_COLOR_COLUMNS}, {"LINE_MARKS", JED_HAS_LINE_MARKS}, {"GPM_MOUSE", USE_GPM_MOUSE}, {"IMPORT", JED_HAS_IMPORT}, {NULL, 0} }; static void show_features (FILE *fp) { Compile_Option_Type *opt; unsigned int len; fprintf (fp, "\njed compile-time options:\n"); opt = Compile_Options; len = 0; while (opt->name != NULL) { unsigned int dlen = strlen (opt->name) + 3; len += dlen; if (len >= 80) { fputc ('\n', fp); len = dlen; } fprintf (fp, " %c%s", (opt->value ? '+' : '-'), opt->name); opt++; } fputc ('\n', fp); } void jed_show_version (FILE *fp) { char *os; #ifdef VMS os = "VMS"; #else # ifdef __os2__ os = "OS/2"; # else # ifdef __WIN32__ os = "win32"; # else # ifdef __MSDOS__ os = "MSDOS"; # else # ifdef REAL_UNIX_SYSTEM os = "Unix"; # else os = "unknown"; # endif # endif # endif # endif #endif fprintf (fp, "jed version: %s/%s\n", Jed_Version_String, os); #if defined(__GNUC__) && defined(__GNUC_MINOR__) fprintf (fp, " Compiled with GNU C %d.%d", __GNUC__, __GNUC_MINOR__); # if defined(__DJGPP) && defined(__DJGPP_MINOR) fprintf (fp, " (DJGPP v%d.%d)", __DJGPP, __DJGPP_MINOR); # endif # ifdef __MINGW32__ # ifndef __MINGW32_PATCHLEVEL # define __MINGW32_PATCHLEVEL 0 # endif fprintf (fp, " (MINGW32 v%d.%d-%d)", __MINGW32_MAJOR_VERSION, __MINGW32_MAJOR_VERSION, __MINGW32_PATCHLEVEL ); # endif fprintf (fp, "\n"); #endif /* __GNUC__ */ fprintf (fp, "S-Lang version: %s\n", SLang_Version_String); if (SLang_Version != SLANG_VERSION) fprintf (fp, "*** Compiled against S-Lang %d but linked to %d\n", SLANG_VERSION, SLang_Version); show_features (fp); } jed-0.99-19/src/vterm.c0000644002657400265740000001506611311317447013572 0ustar davisdavis/* -*- mode: C; mode: fold; -*- */ /* Copyright (c) 1992, 1998, 2000, 2002, 2003, 2004, 2005, 2006 John E. Davis * This file is part of JED editor library source. * * You may distribute this file under the terms the GNU General Public * License. See the file COPYING for more information. */ #include "config.h" #include "jed-feat.h" #include #include #include #include "vterm.h" #include "misc.h" /* This is a virtual terminal used by the window system displays. */ #if SLANG_VERSION < 20000 typedef unsigned short SLsmg_Color_Type; #endif int VTerm_Num_Rows, VTerm_Num_Cols; SLsmg_Char_Type **VTerm_Display; int VTerm_Suspend_Update; static int Scroll_R1, Scroll_R2; static SLsmg_Color_Type Current_Color; static int Current_Row; static int Current_Col; /* Note: In my opinion, area clearing operations should use the current color. * Unfortunately, window systems clear using the default color. So, that must * be mimicked here. This means that the color argument to this function * should be 0. Sigh. */ static void blank_line (SLsmg_Char_Type *s, int len, int color) { #if SLANG_VERSION < 20000 SLsmg_Char_Type c; SLsmg_Char_Type *smax; c = (SLsmg_Char_Type) SLSMG_BUILD_CHAR(' ', color); smax = s + len; while (s < smax) *s++ = c; #else SLsmg_Char_Type *smax = s + len; memset ((char *)s, 0, len * sizeof (SLsmg_Char_Type)); while (s < smax) { s->nchars = 1; s->color = color; s->wchars[0] = ' '; s++; } #endif } int vterm_reset_display (void) { int r; if (VTerm_Suspend_Update) return 0; Current_Col = Current_Row = 0; Current_Color = 0; Scroll_R2 = Scroll_R1 = 0; if (VTerm_Display == NULL) return 0; for (r = 0; r < VTerm_Num_Rows; r++) SLfree ((char *) VTerm_Display [r]); SLfree ((char *)VTerm_Display); VTerm_Display = NULL; return 0; } int vterm_init_display (int rows, int cols) { int r; if (VTerm_Suspend_Update) return 0; vterm_reset_display (); if ((rows == 0) || (cols == 0)) { rows = 24; cols = 80; } VTerm_Num_Cols = cols; VTerm_Num_Rows = rows; VTerm_Display = (SLsmg_Char_Type **)jed_malloc0 (rows * sizeof (SLsmg_Char_Type *)); if (VTerm_Display == NULL) return -1; for (r = 0; r < rows; r++) { SLsmg_Char_Type *s; if (NULL == (s = (SLsmg_Char_Type *) SLmalloc (cols * sizeof (SLsmg_Char_Type)))) { vterm_reset_display (); return -1; } VTerm_Display[r] = s; } vterm_set_scroll_region (0, VTerm_Num_Rows - 1); vterm_reverse_video (0); vterm_goto_rc (0, 0); vterm_cls (); return 0; } void vterm_set_scroll_region (int r1, int r2) { if (VTerm_Suspend_Update) return; if (r1 >= VTerm_Num_Rows) r1 = VTerm_Num_Rows - 1; if (r1 < 0) r1 = 0; if (r2 >= VTerm_Num_Rows) r2 = VTerm_Num_Rows - 1; if (r2 < 0) r2 = 0; Scroll_R1 = r1; Scroll_R2 = r2; } void vterm_delete_nlines (int n) { if (VTerm_Suspend_Update) return; if (VTerm_Display == NULL) return; if (n > Scroll_R2 - Scroll_R1) n = 1 + Scroll_R2 - Scroll_R1; while (n > 0) { SLsmg_Char_Type *s; int r; s = VTerm_Display[Scroll_R1]; for (r = Scroll_R1; r < Scroll_R2; r++) VTerm_Display[r] = VTerm_Display[r + 1]; VTerm_Display[Scroll_R2] = s; blank_line (s, VTerm_Num_Cols, 0); n--; } } void vterm_reverse_index (int n) { if (VTerm_Suspend_Update) return; if (VTerm_Display == NULL) return; if (n > Scroll_R2 - Scroll_R1) n = 1 + Scroll_R2 - Scroll_R1; while (n > 0) { SLsmg_Char_Type *s; int r; s = VTerm_Display[Scroll_R2]; for (r = Scroll_R2; r > Scroll_R1; r--) VTerm_Display[r] = VTerm_Display[r - 1]; VTerm_Display[Scroll_R1] = s; blank_line (s, VTerm_Num_Cols, 0); n--; } } void vterm_del_eol (void) { if (VTerm_Suspend_Update) return; if (VTerm_Display == NULL) return; blank_line (VTerm_Display[Current_Row] + Current_Col, VTerm_Num_Cols - Current_Col, 0); } void vterm_goto_rc (int r, int c) { if (VTerm_Suspend_Update) return; r += Scroll_R1; if (r >= VTerm_Num_Rows) r = VTerm_Num_Rows - 1; if (r < 0) r = 0; if (c >= VTerm_Num_Cols) c = VTerm_Num_Cols - 1; if (c < 0) c = 0; Current_Col = c; Current_Row = r; } void vterm_forward_cursor (int n) { Current_Col += n; if (Current_Col >= VTerm_Num_Cols) Current_Col = VTerm_Num_Cols - 1; } void vterm_reverse_video (int c) { if (VTerm_Suspend_Update) return; Current_Color = c; } void vterm_cls (void) { int r; if (VTerm_Suspend_Update) return; if (VTerm_Display == NULL) return; for (r = 0; r < VTerm_Num_Rows; r++) blank_line (VTerm_Display[r], VTerm_Num_Cols, 0); } void vterm_write_nchars (char *s, unsigned int len) { SLsmg_Char_Type *p, *pmax; char *smax; SLsmg_Color_Type color; if (VTerm_Suspend_Update) return; if (VTerm_Display == NULL) return; p = VTerm_Display[Current_Row]; pmax = p + VTerm_Num_Cols; p += Current_Col; #if SLANG_VERSION >= 20000 if (p + len >= pmax) memset ((char *) p, 0, (pmax - p) * sizeof (SLsmg_Char_Type)); else memset ((char *) p, 0, len * sizeof (SLsmg_Char_Type)); #endif color = Current_Color; smax = s + len; while ((p < pmax) && (s < smax)) { #if SLANG_VERSION < 20000 *p = SLSMG_BUILD_CHAR(*s, color); #else p->color = color; p->nchars = 1; p->wchars[0] = (unsigned char) *s; #endif p++; s++; } vterm_forward_cursor (len); } #if SLANG_VERSION >= 20000 /* This is commented out until I can test it. It was submitted by */ #if 0 /* // return number of wide characters written */ int vterm_write_nbytes (char *s, unsigned int len) { SLsmg_Char_Type *p, *pmin, *pmax; char *smax, *s1; int ncons; SLsmg_Color_Type color; SLwchar_Type wch; if (VTerm_Suspend_Update) return 0; if (VTerm_Display == NULL) return 0; p = VTerm_Display[Current_Row]; pmax = p + VTerm_Num_Cols; p += Current_Col; pmin = p; memset ((char *) p, 0, (pmax - p) * sizeof (SLsmg_Char_Type)); color = Current_Color; smax = s + len; while ((p < pmax) && (s < smax)) { s1 = SLutf8_decode (s, smax, &wch, &ncons); if (s1 == NULL) { vterm_forward_cursor (p - pmin); vterm_write_nchars(s, smax - s); return (p - pmin) + (smax - s); } else { p->color = color; p->nchars = 1; p->wchars[0] = wch; p++; s = s1; } } vterm_forward_cursor (p - pmin); return (p - pmin); } #endif #endif jed-0.99-19/src/indent.h0000644002657400265740000000720611311317447013720 0ustar davisdavis/* Copyright (c) 1992, 1998, 2000, 2005, 2006 John E. Davis * This file is part of JED editor library source. * * You may distribute this file under the terms the GNU General Public * License. See the file COPYING for more information. */ #ifndef __JED_INDENT_H_ #define __JED_INDENT_H_ #if JED_HAS_DFA_SYNTAX # include "dfasyntx.h" #endif typedef struct Syntax_Table_Type { char *name; /* name of this table */ unsigned char sgml_start_char; /* < */ unsigned char sgml_stop_char; /* > */ #define MAX_STRING_CHARS 2 /* do not change this without making other changes to buffer flags */ unsigned char string_chars[MAX_STRING_CHARS]; /* character for string delim */ unsigned int num_string_chars; unsigned char char_char; /* char for char delim */ unsigned int flags; #define SYNTAX_NOT_CASE_SENSITIVE 0x1 #define FORTRAN_TYPE 0x2 #define C_COMMENT_TYPE 0x4 /* means if non-digit in first column, it is a comment */ #define TEX_LIKE_KEYWORDS 0x8 #define EOL_COMMENT_NEEDS_WHITESPACE 0x10 #define PREPROCESS_COLOR_WHOLE_LINE 0x20 #define PREPROCESS_IGNORE_WHITESPACE 0x40 #define SINGLE_LINE_STRINGS 0x80 /* Comments. Each mode can have at most 2 comment styles: one for * multiline comments, and one for single line comments. * A single line comments ends at the end of the line. Since some * comments must be followed by whitespace or a word delimeter, an * flag will be set for them. For example, in BASIC, 'rem' denotes * a comment but 'remote' does not. Sigh. * * Languages such as m4 are especially problematic. m4 uses 'dnl' to * start an end-of-line comment. However, it must occur as an isolated * word such that * dnlsilly is not a comment * and sillydnl is not a comment */ char *comment_start; unsigned int comment_start_len; unsigned int comment_stop_len; char *comment_stop; #define MAX_EOL_COMMENTS 2 char *eol_comment_starts[MAX_EOL_COMMENTS]; unsigned int eol_comment_lens[MAX_EOL_COMMENTS]; unsigned int num_eol_comments; unsigned char quote_char; /* used for quoting in strings */ unsigned char preprocess; /* start preprocessor lines */ unsigned short char_syntax[256]; /* syntax type for characters */ unsigned char matching_delim[256]; /* matching pairs */ #define MAX_KEYWORD_LEN 48 #define MAX_KEYWORD_TABLES 3 /* must be less than 10 for a * 1-1 correspondence with keyword colors */ char *keywords[MAX_KEYWORD_TABLES][MAX_KEYWORD_LEN]; struct Syntax_Table_Type *next; /* pointer to next table */ #if JED_HAS_DFA_SYNTAX struct Highlight *hilite; SLang_Name_Type *init_dfa_callback; #endif int use_dfa_syntax; unsigned char fortran_comment_chars[256]; } Syntax_Table_Type; #define WORD_SYNTAX 0x001 #define NUMBER_SYNTAX 0x002 #define DELIM_SYNTAX 0x004 #define SYNTAX_MASK 0xFFF8 #define QUOTE_SYNTAX 0x008 #define STRING_SYNTAX 0x010 #define OPEN_DELIM_SYNTAX 0x020 #define CLOSE_DELIM_SYNTAX 0x040 #define COMMENT_SYNTAX 0x080 #define OP_SYNTAX 0x100 #define HTML_START_SYNTAX 0x200 #define HTML_END_SYNTAX 0x400 extern Syntax_Table_Type *Default_Syntax_Table; extern void init_syntax_tables (void); extern void blink_match(void); extern int goto_match(void); extern Syntax_Table_Type *jed_find_syntax_table (char *, int); extern int jed_init_syntax (void); #if JED_HAS_LINE_ATTRIBUTES extern void jed_syntax_parse_buffer (int); #endif extern int map_color_object_to_number (char *); extern int _jed_is_eol_comment_start (Syntax_Table_Type *, Line *, unsigned char *, unsigned char *, unsigned int *); #endif /* __JED_INDENT_H_ */ jed-0.99-19/src/abbrev.h0000644002657400265740000000116311311317447013674 0ustar davisdavis/* Copyright (c) 1992, 1998, 2000, 2005, 2006 John E. Davis * This file is part of JED editor library source. * * You may distribute this file under the terms the GNU General Public * License. See the file COPYING for more information. */ extern void use_abbrev_table (char *); extern void define_abbrev (char *, char *, char *); extern void create_abbrev_table (char *, char *); extern int jed_expand_abbrev (SLwchar_Type); extern int abbrev_table_p (char *); extern void dump_abbrev_table (char *); extern void what_abbrev_table (void); extern int list_abbrev_tables (void); extern void delete_abbrev_table (char *); jed-0.99-19/src/colors.h0000644002657400265740000000355411311317447013742 0ustar davisdavis/* Copyright (c) 2007 John E. Davis * This file is part of JED editor library source. * * You may distribute this file under the terms the GNU General Public * License. See the file COPYING for more information. */ #ifndef _JED_COLORS_H_ #define _JED_COLORS_H_ /* These numbers should not be changed. They are hard-coded in the * dfa cache files. */ #define JNORMAL_COLOR 0 #define JCURSOR_COLOR 1 #define JSTATUS_COLOR 2 #define JREGION_COLOR 3 #define JMENU_COLOR 4 #define JOP_COLOR 5 #define JNUM_COLOR 6 #define JSTR_COLOR 7 #define JCOM_COLOR 8 #define JDELIM_COLOR 9 #define JPREPROC_COLOR 10 #define JMESSAGE_COLOR 11 #define JERROR_COLOR 12 #define JDOLLAR_COLOR 13 #define JDOTS_COLOR 14 #define JMENU_CHAR_COLOR 15 #define JMENU_SHADOW_COLOR 16 #define JMENU_SELECTION_COLOR 17 #define JMENU_POPUP_COLOR 18 #define JMENU_SELECTED_CHAR_COLOR 19 #define JCURSOROVR_COLOR 20 #define JLINENUM_COLOR 21 #define JTWS_COLOR 22 #define JTAB_COLOR 23 #define JURL_COLOR 24 #define JITALIC_COLOR 25 #define JUNDERLINE_COLOR 26 #define JBOLD_COLOR 27 #define JHTML_KEY_COLOR 28 #define JKEY_COLOR 29 #define JKEY1_COLOR (JKEY_COLOR+1) #define JKEY2_COLOR (JKEY_COLOR+2) #define JKEY3_COLOR (JKEY_COLOR+3) #define JKEY4_COLOR (JKEY_COLOR+4) #define JKEY5_COLOR (JKEY_COLOR+5) #define JKEY6_COLOR (JKEY_COLOR+6) #define JKEY7_COLOR (JKEY_COLOR+7) #define JKEY8_COLOR (JKEY_COLOR+8) #define JKEY9_COLOR (JKEY_COLOR+9) /* 38 */ #define FIRST_USER_COLOR 64 #if SLANG_VERSION < 20000 # define JMAX_COLORS 128 /* Do NOT increase this number */ #else # define JMAX_COLORS 256 /* Do NOT increase this number */ #endif extern int jed_init_color_intrinsics (void); extern int jed_get_color_obj (char *name); extern int jed_set_color (int, char *, char *); #endif /* _JED_COLORS_H_ */ jed-0.99-19/src/rgrep.c0000644002657400265740000006204111311317447013547 0ustar davisdavis/* Copyright (c) 1992, 1998, 2000, 2002, 2003, 2004, 2005, 2006 John E. Davis * This file is part of JED editor library source. * * You may distribute this file under the terms the GNU General Public * License. See the file COPYING for more information. */ #include "config.h" #define RGREP_MAJOR_VERSION 2 #define RGREP_MINOR_VERSION 1 #include #include #include "jdmacros.h" #include #ifdef HAVE_STDLIB_H #include #endif /* For isatty */ #ifdef HAVE_UNISTD_H # include #endif #ifdef HAVE_LIMITS_H # include #endif #ifdef PATH_MAX # define JED_MAX_PATH_LEN PATH_MAX #else # ifdef IBMPC_SYSTEM # define JED_MAX_PATH_LEN 256 # else # define JED_MAX_PATH_LEN 1024 # endif #endif #ifdef __MSDOS__ # include #endif #include "vfile.h" static int Binary_Option = 0; static int Case_Sensitive = 1; static int File_Name_Only; static int Do_Recursive = 0; static int Recursive_Match = 0; static int Highlight = 0; static int Output_Match_Only = 0; static int Count_Matches = 0; static int Line_Numbers = 0; static int Follow_Links = 0; static int Debug_Mode = 0; static char *Match_This_Extension; static int Print_Non_Matching_Lines = 0; #ifdef __unix__ static int Stdout_Is_TTY; #endif #define HON_STR "\033[1m" #define HON_STR_LEN 4 #define HOFF_STR "\033[0m" #define HOFF_STR_LEN 4 #if SLANG_VERSION < 10410 int SLang_get_error (void) { return SLang_Error; } int SLang_set_error (int e) { SLang_Error = e; return 0; } #endif extern int jed_handle_interrupt (void); int jed_handle_interrupt (void) { return 0; } static void version (void) { fprintf (stdout, "rgrep version %d.%d\n", RGREP_MAJOR_VERSION, RGREP_MINOR_VERSION); fprintf (stdout, "S-Lang version: %s\n", SLang_Version_String); if (SLang_Version != SLANG_VERSION) fprintf (stdout, "*** Compiled against S-Lang %d but linked to %d\n", SLANG_VERSION, SLang_Version); exit (0); } static void usage(void) { fputs("Usage: rgrep [options..] pattern [files ...]\n\ Options:\n\ -? additional help (use '-?' to avoid shell expansion on some systems)\n\ -c count matches\n\ -h highlight match (ANSI compatable terminal assumed)\n\ -H Output match instead of entire line containing match\n\ -i ignore case\n\ -l list filename only\n\ -n print line number of match\n\ -F follow links\n\ -r recursively scan through directory tree\n\ -N Do NOT perform a recursive search\n\ -B If file looks like a binary one, skip it.\n\ -R 'pat' like '-r' except that only those files matching 'pat' are checked\n\ Here 'pat' is a globbing expression.\n\ -v print only lines that do NOT match the specified pattern\n\ -x 'ext' checks only files with extension given by 'ext'.\n\ -D Print all directories that would be searched. This option is for\n\ debugging purposes only. No file is grepped with this option.\n\ -W'len' lines are 'len' characters long (not newline terminated).\n\ --version Print version\n\ --help Print this help\n\ \n\ 'pattern' is a valid 'ex' type of regular expression. See the man page for ex.\n\ It is best enclosed in single quotes to avoid shell expansion.\n", stderr); exit(1); } static void additional_help (void) { char buf[3]; fputs("Supported Regular Expressions:\n\ . match any character except newline\n\ \\d match any digit\n\ \\e match ESC char\n\ * matches zero or more occurences of last single char RE\n\ + matches one or more occurences of last single char RE\n\ ? matches zero or one occurence of last single char RE\n\ ^ matches beginning of line\n\ $ matches end of line\n\ [ ... ] matches any single character between brackets.\n\ For example, [-02468] matches `-' or any even digit.\n\ and [-0-9a-z] matches `-' and any digit between 0 and 9\n\ as well as letters a through z.\n\ \\< Match the beginning of a word.\n\ \\> Match the end of a word.\n\ \\{ ... \\}\n\ \\( ... \\)\n\ \\1, \\2, ..., \\9 matches match specified by nth \\( ... \\) expression.\n\ For example, '\\([ \\t][a-zA-Z]+\\)\\1[ \\t]' matches any\n\ word repeated consecutively.\n", stderr); if (isatty(fileno(stderr)) && isatty(fileno(stdin))) { fputs("\nPress RETURN for examples>", stderr); fgets(buf, 2, stdin); putc('\n', stderr); } fputs ("Examples:\n\ \n\ Look in all files with a 'c' extension in current directory and all its\n\ subdirectories looking for matches of 'int ' at the beginning of a line,\n\ printing the line containing the match with its line number: (two methods)\n\ rgrep -n -R '*.c' '^int ' .\n\ rgrep -n -x c '^int ' .\n\ \n\ Highlight all matches of repeated words in file 'paper.tex':\n\ rgrep -h '\\<\\([a-zA-Z]+\\)\\>[ \\t]+\\<\\1\\>' paper.tex\n", stderr); fputs ("\n\ Search through all files EXCEPT .o and .a file below /usr/src/linux looking\n\ for the string 'mouse' without regard to case:\n\ rgrep -i -R '*.[^ao]' mouse /usr/src/linux\n\ \n\ Search a fixed record length FITS file for the keyword EXTNAME:\n\ rgrep -W80 ^EXTNAME file.fits\n\ (Note that the regular expression '^[A-Z]+' will dump all fits headers.)\n", stderr); exit (-1); } static FILE *File_Fp; static VFILE *File_Vp; static unsigned char *Fixed_Len_Buf; static int Fixed_Len_Mode; static int Fixed_Line_Len; extern void msg_error (char *); void msg_error (char *str) { fputs(str, stderr); putc('\n', stderr); } static void exit_error(char *s) { fprintf(stderr, "rgrep: %s\n", s); exit(1); } static void parse_flags(char *f) { char ch; while ((ch = *f++) != 0) { switch (ch) { case 'i': Case_Sensitive = 0; break; case 'l': File_Name_Only = 1; break; case 'r': Do_Recursive = 1; break; case 'N': Do_Recursive = -1; break; case 'B': Binary_Option = 1; break; case 'v': Print_Non_Matching_Lines = 1; case 'H': Highlight = 1; /* does not cause highlight for this case */ Output_Match_Only = 1; break; case 'h': #ifndef IBMPC_SYSTEM Highlight = 1; #endif break; case 'c': Count_Matches = 1; break; case 'n': Line_Numbers = 1; break; case 'F': Follow_Links = 1; break; case 'D': Debug_Mode = 1; break; case '?': additional_help (); break; case 'W': Fixed_Line_Len = 0; while (((ch = *f) != 0) && (ch >= '0') && (ch <= '9')) { Fixed_Line_Len = Fixed_Line_Len * 10 + (unsigned char) ch - '0'; f++; } if (Fixed_Line_Len == 0) usage (); Fixed_Len_Buf = (unsigned char *) SLmalloc (Fixed_Line_Len); if (Fixed_Len_Buf == NULL) { exit_error ("Malloc error."); } Fixed_Len_Mode = 1; break; case '-': if (!strcmp (f, "version")) version (); /* drop */ default: usage (); } } } #if SLANG_VERSION < 20000 static SLRegexp_Type reg; static SLRegexp_Type recurse_reg; static unsigned char Recurse_Reg_Pattern_Buffer[JED_MAX_PATH_LEN]; #else static SLRegexp_Type *reg; static SLRegexp_Type *recurse_reg; static unsigned char Recurse_Reg_Pattern_Buffer[JED_MAX_PATH_LEN]; #endif static int Must_Match; static int print_file_too; static void do_fwrite (unsigned char *s, int n, int nl) { unsigned char *smax = s + n, ch = 0; #if defined(__unix__) || defined(VMS) unsigned char ch1; #endif while (s < smax) { ch = *s++; #if defined(__unix__) || defined(VMS) ch1 = ch & 0x7F; if ((ch1 < ' ') || (ch1 == 0x7F)) { if ((ch != '\n') && (ch != '\t')) { if (ch & 0x80) putc ('~', stdout); putc ('^', stdout); if (ch1 == 0x7F) ch = '?'; else ch = ch1 + '@'; } } #endif putc (ch, stdout); } if (nl && (ch != '\n')) putc ('\n', stdout); } static void output_line(unsigned char *s, unsigned int n, unsigned char *p, unsigned char *pmax) { if (Highlight == 0) { do_fwrite(s, n, 1); } else { if (Output_Match_Only == 0) { do_fwrite (s, (int) (p - s), 0); fwrite (HON_STR, 1, HON_STR_LEN, stdout); } do_fwrite (p, (int) (pmax - p), 0); if (Output_Match_Only == 0) { fwrite (HOFF_STR, 1, HOFF_STR_LEN, stdout); do_fwrite (pmax, (int) n - (int) (pmax - s), 1); } else if (*(pmax - 1) != '\n') putc ('\n', stdout); } } static unsigned char *rgrep_gets (unsigned int *n) { unsigned int nread; if (File_Vp != NULL) return (unsigned char *) vgets (File_Vp, n); nread = fread (Fixed_Len_Buf, 1, Fixed_Line_Len, File_Fp); if (nread == 0) return NULL; *n = nread; return Fixed_Len_Buf; } static int OSearch_Ok = 0; static int Search_St_Key_Length = 0; #if SLANG_VERSION < 20000 static SLsearch_Type Search_St; # define SEARCH_FORWARD(a,b) SLsearch ((a), (b), &Search_St) # define REGEXP_MATCH(r,b,n) SLang_regexp_match((unsigned char *)(b),(n), &r) #else static SLsearch_Type *Search_St; # define SEARCH_FORWARD(a,b) SLsearch_forward (Search_St, (a), (b)) # define REGEXP_MATCH(r,b,n) (NULL != SLregexp_match(r,(char *) (b),(n))) #endif static void grep(char *file) { unsigned char *buf, *p, *pmax; unsigned int n; int line = 0, n_matches = 0; if (NULL == (buf = (unsigned char *) rgrep_gets(&n))) return; if (Binary_Option) { p = buf; if (File_Vp == NULL) { if (n < 32) pmax = p + n; else pmax = p + 32; } else { unsigned int vn; p = (unsigned char *) File_Vp->buf; if (File_Vp->eof != NULL) vn = (unsigned char *) File_Vp->eof - p; else vn = (unsigned char *) File_Vp->bmax - p; if (vn < 32) pmax = p + vn; else pmax = p + 32; } while (p < pmax) { if (*p == 0) return; p++; } } do { line++; #if SLANG_VERSION < 20000 if (reg.min_length > n) { if (Print_Non_Matching_Lines) { p = buf; pmax = p + n; goto match_found; } continue; } #endif if (Must_Match) { #if SLANG_VERSION < 20000 if (Search_St.key_len > (int) n) { if (Print_Non_Matching_Lines) { p = buf; pmax = p + n; goto match_found; } continue; } #endif if (NULL == (p = SEARCH_FORWARD (buf, buf + n))) { if (Print_Non_Matching_Lines) { p = buf; pmax = p + n; goto match_found; } continue; } if (OSearch_Ok) { if (Print_Non_Matching_Lines) continue; pmax = p + Search_St_Key_Length; goto match_found; } } if (!REGEXP_MATCH (reg, buf, n)) { if (Print_Non_Matching_Lines) { p = buf; pmax = p + n; goto match_found; } continue; } if (Print_Non_Matching_Lines) continue; #if SLANG_VERSION < 20000 p = buf + reg.beg_matches[0]; pmax = p + reg.end_matches[0]; #else { unsigned int ofs, len; (void) SLregexp_nth_match (reg, 0, &ofs, &len); p = buf + ofs; pmax = p + len; } #endif match_found: n_matches++; if (Count_Matches) continue; if (File_Name_Only) { if (Print_Non_Matching_Lines) continue; puts(file); return; } if (print_file_too) { fputs(file, stdout); putc(':', stdout); } if (Line_Numbers) { fprintf(stdout, "%d:", line); } output_line(buf, n, p, pmax); #ifdef __unix__ if (Stdout_Is_TTY) fflush (stdout); #endif } while (NULL != (buf = (unsigned char *) rgrep_gets(&n))); if (Print_Non_Matching_Lines && File_Name_Only && (n_matches == line)) { puts (file); #ifdef __unix__ if (Stdout_Is_TTY) fflush (stdout); #endif } if (n_matches && Count_Matches) { if (print_file_too || File_Name_Only) { fputs(file, stdout); putc(':', stdout); } fprintf(stdout, "%d\n", n_matches); #ifdef __unix__ if (Stdout_Is_TTY) fflush (stdout); #endif } } #ifdef __MSDOS__ # include #endif #ifdef __unix__ # include # include #endif #ifdef IBMPC_USE_ASM typedef struct Dos_DTA_Type { unsigned char undoc[21]; unsigned char attr; unsigned int time; unsigned int date; unsigned char low_size[2]; unsigned char high_size[2]; char name[13]; } DOS_DTA_Type; #endif #ifdef __unix__ # if HAVE_DIRENT_H # include # define NAMLEN(dirent) strlen((dirent)->d_name) # else # define dirent direct # define NAMLEN(dirent) (dirent)->d_namlen # define NEED_D_NAMLEN # if HAVE_SYS_NDIR_H # include # endif # if HAVE_SYS_DIR_H # include # endif # if HAVE_NDIR_H # include # endif # endif #endif typedef struct { char dir[JED_MAX_PATH_LEN]; int dir_len; char *file; /* pointer to place in dir */ int isdir; #ifdef IBMPC_USE_ASM DOS_DTA_Type *dta; char pattern[16]; #endif #ifdef __unix__ DIR *dirp; #endif } Sys_Dir_Type; #ifdef IBMPC_USE_ASM void dos_set_dta (DOS_DTA_Type *dta) { asm mov ah, 0x1A asm push ds asm lds dx, dword ptr dta asm int 21h asm pop ds } int dos_is_dir (char *file) { int n = strlen (file); if (n == 0) return 0; if (file[n - 1] == '\\') return 1; asm mov ah, 0x43 asm mov al, 0 asm push ds asm lds dx, dword ptr file asm int 21h asm pop ds asm mov n, cx asm jnc L1 return 0; L1: if (n & 0x10) return 1; return 0; } #endif #ifdef __unix__ static int unix_is_dir (char *dir, int force_link) { /* AIX requires this */ #ifdef _S_IFDIR #ifndef S_IFDIR #define S_IFDIR _S_IFDIR #endif #endif struct stat buf; int mode; return 0; if (stat(dir, &buf)) return -1; if ((buf.st_mode & S_IFMT) == S_IFREG) return 0; #ifdef S_IFLNK if ((0 == Follow_Links) && (0 == force_link) && (-1 == lstat(dir, &buf))) return -1; #endif mode = buf.st_mode & S_IFMT; #ifdef S_IFLNK if (mode == S_IFLNK) { return -2; } #endif if (mode == S_IFDIR) return (1); if (mode != S_IFREG) return (-1); return(0); } #endif static Sys_Dir_Type *sys_opendir(char *dir, Sys_Dir_Type *x) { #ifdef IBMPC_USE_ASM char slash = '\\'; char *pat = "*.*"; dos_set_dta (x->dta); if ((dir[1] == ':') && (dir[2] == '\\')) { strcpy (x->dir, dir); } else { /* must have drive/dirpath/filename */ getcwd(x->dir, JED_MAX_PATH_LEN); if (*dir == slash) { strcpy (x->dir + 2, dir); } else { if (x->dir[strlen (x->dir) - 1] != slash) strcat (x->dir, "\\"); strcat(x->dir, dir); } } dir = x->dir + strlen (x->dir); /* check for a pattern already as part of the dirspec */ while (dir > x->dir) { if (*dir == '\\') break; if (*dir == '*') { while (*dir != '\\') dir--; *dir = 0; pat = dir + 1; break; } dir--; } strcpy (x->pattern, pat); #else #ifdef __unix__ char slash = '/'; DIR *dirp; if (NULL == (dirp = (DIR *) opendir(dir))) { fprintf (stderr, "rgrep: dir %s not readable.\n", dir); return NULL; } x->dirp = dirp; strcpy(x->dir, dir); #endif /* __unix__ */ #endif /* IBMPC_USE_ASM */ x->dir_len = strlen(x->dir); if (x->dir[x->dir_len - 1] != slash) { x->dir[x->dir_len++] = slash; x->dir[x->dir_len] = 0; } return (x); } static void sys_closedir(Sys_Dir_Type *x) { #ifdef IBMPC_USE_ASM (void) x; #else #ifdef __unix__ DIR *dirp; dirp = x->dirp; if (dirp != NULL) closedir(dirp); x->dirp = NULL; #endif #endif } #ifdef IBMPC_USE_ASM char *dos_dta_fixup_name (Sys_Dir_Type *x) { x->file = x->dir + x->dir_len; strcpy(x->file, x->dta->name); /* sub directory */ if (x->dta->attr & 0x10) x->isdir = 1; else x->isdir = 0; return x->file; } #endif static char *sys_dir_findnext(Sys_Dir_Type *x) { char *file; #ifdef IBMPC_USE_ASM asm mov ah, 0x4F asm int 21h asm jnc L1 return NULL; L1: file = dos_dta_fixup_name (x); #else #ifdef __unix__ # ifdef NEED_D_NAMLEN # define dirent direct # endif struct dirent *dp; DIR *d; d = x->dirp; if (NULL == (dp = readdir(d))) return(NULL); # ifdef NEED_D_NAMLEN dp->d_name[dp->d_namlen] = 0; # endif file = dp->d_name; x->file = x->dir + x->dir_len; strcpy (x->file, dp->d_name); x->isdir = unix_is_dir (x->dir, 0); #endif /* __unix__ */ #endif /* IBMPC_USE_ASM */ /* exclude '.' and '..' */ if (*file++ == '.') { if ((*file == 0) || ((*file == '.') && (*(file + 1) == 0))) x->isdir = -1; } return (x->dir); } static char *sys_dir_findfirst(Sys_Dir_Type *x) { #ifdef IBMPC_USE_ASM unsigned int attr = 0x1 | 0x10; /* read only + sub directory */ char pat[JED_MAX_PATH_LEN], *patp, *file; attr |= 0x2 | 0x4; /* hidden and system */ strcpy (pat, x->dir); strcat (pat, x->pattern); patp = pat; asm mov ah, 0x4e asm mov cx, attr asm push ds asm lds dx, dword ptr patp asm int 21h asm pop ds asm jc L1 file = dos_dta_fixup_name (x); /* exclude '.' and '..' */ if (*file++ == '.') { if ((*file == 0) || ((*file == '.') && (*(file + 1) == 0))) x->isdir = -1; } return x->dir; L1: return NULL; #else #ifdef __unix__ return (sys_dir_findnext(x)); #endif #endif } #define BUF_SIZE 4096 static void grep_file(char *file, char *filename) { char *p; if (Debug_Mode) return; if (Recursive_Match) { if (Match_This_Extension != NULL) { p = filename + strlen(filename); while ((p >= filename) && (*p != '.')) p--; if ((*p != '.') || #ifdef __MSDOS__ stricmp(Match_This_Extension, p + 1) #else strcmp(Match_This_Extension, p + 1) #endif ) return; } else if (!REGEXP_MATCH(recurse_reg, filename, strlen(filename))) return; } File_Fp = NULL; File_Vp = NULL; if (Fixed_Len_Mode) { File_Fp = fopen (file, "rb"); } else File_Vp = vopen (file, BUF_SIZE, 0); if ((File_Vp == NULL) && (File_Fp == NULL)) { fprintf(stderr, "rgrep: unable to read %s\n", file); } else { grep(file); if (File_Fp == NULL) vclose(File_Vp); else fclose (File_Fp); } } #define MAX_DEPTH 25 static void grep_dir(char *dir) { static int depth; Sys_Dir_Type x; char *file; #ifdef IBMPC_USE_ASM DOS_DTA_Type dta; x.dta = &dta; #endif if (NULL == sys_opendir(dir, &x)) return; if (depth >= MAX_DEPTH) { fprintf(stderr, "Maximum search depth exceeded.\n"); return; } depth++; if (Debug_Mode) fprintf(stderr, "%s\n", dir); for (file = sys_dir_findfirst(&x); file != NULL; file = sys_dir_findnext(&x)) { if (x.isdir == 0) grep_file(file, x.file); else if ((Do_Recursive > 0) && (x.isdir == 1)) grep_dir(file); #ifdef IBMPC_USE_ASM dos_set_dta (&dta); /* something might move it */ #endif } sys_closedir(&x); depth--; } static unsigned char *fixup_filename (unsigned char *name) { unsigned char *pat = Recurse_Reg_Pattern_Buffer; unsigned char ch; *pat++ = '^'; while ((ch = *name++) != 0) { if (ch == '*') { *pat++ = '.'; *pat++ = '*'; } else if (ch == '?') *pat++ = '.'; else if ((ch == '.') || (ch == '$')) { *pat++ = '\\'; *pat++ = ch; } else *pat++ = ch; } *pat++ = '$'; *pat = 0; return Recurse_Reg_Pattern_Buffer; } int main(int argc, char **argv) { #if SLANG_VERSION < 20000 unsigned char buf[2 * JED_MAX_PATH_LEN]; unsigned char recurse_buf[JED_MAX_PATH_LEN]; #else unsigned int flags; #endif char *pattern; #ifdef __unix__ Stdout_Is_TTY = isatty (fileno(stdout)); #endif argv++; argc--; SLang_init_case_tables (); while (argc && (**argv == '-') && *(*argv + 1)) { if (!strcmp(*argv, "-R")) { argc--; argv++; if (!argc) usage(); #if SLANG_VERSION < 20000 recurse_reg.pat = fixup_filename ((unsigned char *) *argv); recurse_reg.buf = recurse_buf; recurse_reg.buf_len = JED_MAX_PATH_LEN; # ifdef __MSDOS__ recurse_reg.case_sensitive = 0; # else recurse_reg.case_sensitive = 1; # endif if (SLang_regexp_compile (&recurse_reg)) exit_error("Error compiling pattern."); #else flags = 0; # ifdef __MSDOS__ flags |= SLREGEXP_CASELESS; # endif if (NULL == (recurse_reg = SLregexp_compile ((char *)fixup_filename((unsigned char *) *argv), flags))) exit_error ("Error compiling pattern"); #endif Do_Recursive = 1; Recursive_Match = 1; } else if (!strcmp(*argv, "-x")) { argc--; argv++; if (!argc) usage(); Recursive_Match = 1; Match_This_Extension = *argv; } else { parse_flags(*argv + 1); } argv++; argc--; } if (!argc) usage(); pattern = *argv; #if SLANG_VERSION < 20000 reg.pat = (unsigned char *) pattern; reg.buf = buf; reg.buf_len = sizeof (buf); reg.case_sensitive = Case_Sensitive; if (SLang_regexp_compile (®)) exit_error("Error compiling pattern."); #else if (NULL == (reg = SLregexp_compile (pattern, Case_Sensitive ? 0 : SLREGEXP_CASELESS))) exit_error ("Error compiling pattern"); #endif argc--; argv++; Must_Match = 1; #if SLANG_VERSION < 20000 OSearch_Ok = reg.osearch; #else (void) SLregexp_get_hints (reg, &flags); OSearch_Ok = (0 != (flags & SLREGEXP_HINT_OSEARCH)); #endif if (OSearch_Ok) { #if SLANG_VERSION < 20000 SLsearch_init (pattern, 1, Case_Sensitive, &Search_St); #else if (NULL == (Search_St = SLsearch_new ((unsigned char *)pattern, Case_Sensitive ? 0 : SLSEARCH_CASELESS))) exit_error ("SLsearch_new failed"); #endif Search_St_Key_Length = strlen (pattern); } #if SLANG_VERSION < 20000 else if (reg.must_match) { SLsearch_init ((char *) reg.must_match_str, 1, Case_Sensitive, &Search_St); Search_St_Key_Length = strlen ((char *) reg.must_match_str); } else #endif Must_Match = 0; if (argc == 0) { if (Fixed_Len_Mode) File_Fp = stdin; else File_Vp = vstream(fileno(stdin), BUF_SIZE, 0); if ((File_Fp == NULL) && (File_Vp == NULL)) { exit_error("Error vopening stdin."); } grep("stdin"); if (File_Vp != NULL) vclose(File_Vp); else fclose (File_Fp); } else { if ((Do_Recursive > 0) || (argc != 1)) print_file_too = 1; while (argc--) { #ifdef __unix__ int ret; #endif #ifdef __MSDOS__ { char *p = *argv; while (*p) { if (*p == '/') *p = '\\'; p++; } } #endif if ( #ifdef IBMPC_USE_ASM dos_is_dir (*argv) /* * && (('\\' == (*argv)[strlen(*argv) - 1]) * || (!strcmp (*argv, ".")) * || (!strcmp (*argv, ".."))) */ #else #ifdef __unix__ (1 == (ret = unix_is_dir (*argv, (strlen(*argv) && ('/' == (*argv)[strlen(*argv) - 1]))))) #endif #endif ) { print_file_too = 1; if (Do_Recursive >= 0) grep_dir (*argv); } else #ifdef __MSDOS__ { char *file = *argv; while (*file && (*file != '*')) file++; if (*file == '*') { print_file_too = 1; grep_dir (*argv); } else grep_file(*argv, *argv); } #else #ifdef __unix__ if (ret == 0) #endif grep_file(*argv, *argv); #endif argv++; } } return (0); } /* ------------------------------------------------------------ */ #ifdef VMS int vms_expand_filename(char *file,char *expanded_file) { unsigned long status; static int context = 0; static char inputname[JED_MAX_PATH_LEN] = ""; $DESCRIPTOR(file_desc,inputname); $DESCRIPTOR(default_dsc,"SYS$DISK:[]*.*;"); static struct dsc$descriptor_s result = {0, DSC$K_DTYPE_T, DSC$K_CLASS_D, NULL}; if (strcmp(inputname, file)) { if (context) { lib$find_file_end(&context); } context = 0; strcpy(inputname, file); file_desc.dsc$w_length = strlen(inputname); } if (RMS$_NORMAL == lib$find_file(&file_desc,&result,&context, &default_dsc,0,0,&Number_Zero)) { MEMCPY(expanded_file, result.dsc$a_pointer, result.dsc$w_length); expanded_file[result.dsc$w_length] = '\0'; return (1); } else { /* expanded_file[0] = '\0'; */ /* so file comes back as zero width */ return(0); } } static int context = 0; static char inputname[JED_MAX_PATH_LEN] = ""; $DESCRIPTOR(file_desc,inputname); $DESCRIPTOR(default_dsc,"SYS$DISK:[]*.*;"); int sys_findnext(char *file) { unsigned long status; static struct dsc$descriptor_s result = { 0, DSC$K_DTYPE_T, DSC$K_CLASS_D, NULL }; if (RMS$_NORMAL == lib$find_file(&file_desc,&result,&context, &default_dsc,0,0,&Number_Zero)) { MEMCPY(file, result.dsc$a_pointer, result.dsc$w_length); file[result.dsc$w_length] = 0; return (1); } else return(0); } int sys_findfirst(char *file) { char *file; strcpy(inputname, file); file_desc.dsc$w_length = strlen(inputname); if (context) lib$find_file_end(&context); context = 0; return sys_findnext(file); } #endif /* VMS */ jed-0.99-19/src/search.c0000644002657400265740000003412011311317447013672 0ustar davisdavis/* -*- mode: C; mode: fold; -*- */ /* Copyright (c) 1992, 1998, 2000, 2002, 2003, 2004, 2005, 2006 John E. Davis * This file is part of JED editor library source. * * You may distribute this file under the terms the GNU General Public * License. See the file COPYING for more information. */ #include "config.h" #include "jed-feat.h" /*{{{ Include Files */ #include #include #include "jdmacros.h" #include #include "buffer.h" #include "vfile.h" #include "search.h" #include "misc.h" #include "ins.h" #include "paste.h" #include "ledit.h" /*}}}*/ static SLRegexp_Type *Regexp; static unsigned int Regexp_Offset; static int search_internal (SLsearch_Type *st, int dir, int n, int key_len) /*{{{*/ { unsigned char *beg, *end, *p; Line *line; unsigned int num = 0; line = CLine; (void) key_len; if (dir == 1) { beg = line->data + Point; end = line->data + line->len; do { p = SLsearch_forward (st, beg, end); if (p != NULL) { CLine = line; LineNum += num; jed_position_point (p); return 1; } line = line->next; num++; if (line == NULL) return 0; beg = line->data; end = line->data + line->len; } while (--n); } else if (dir == -1) { beg = line->data; end = beg + line->len; p = beg + Point; do { p = SLsearch_backward (st, beg, p, end); if (p != NULL) { CLine = line; LineNum -= num; jed_position_point (p); return 1; } line = line->prev; num++; if (line == NULL) return(0); beg = line->data; end = line->data + line->len; p = end; } while (--n); } return(0); } /*}}}*/ static void close_search (SLsearch_Type *st) { SLsearch_delete (st); } static SLsearch_Type *open_search (char *str, int dir, int cs, int *key_lenp) { unsigned int flags = 0; (void) key_lenp; (void) dir; if (cs == 0) flags |= SLSEARCH_CASELESS; if (Jed_UTF8_Mode) flags |= SLSEARCH_UTF8; *key_lenp = strlen (str); return SLsearch_new ((SLuchar_Type *) str, flags); } int search (char *str, int dir, int n) /*{{{*/ { SLsearch_Type *st; int key_len=0; int status; int cs = Buffer_Local.case_search; if (NULL == (st = open_search (str, dir, cs, &key_len))) return 0; status = search_internal (st, dir, n, key_len); if (status == 1) { key_len = SLsearch_match_len (st); /* We want the actual number of multibyte chars */ if (Jed_UTF8_Mode) { unsigned int len; unsigned char *p, *pmax; p = CLine->data + Point; pmax = p + key_len; if (pmax >= CLine->data + CLine->len) pmax = CLine->data + CLine->len; (void) SLutf8_skip_chars (p, pmax, pmax - p, &len, 1); key_len = (int) len; } } else key_len = 0; close_search (st); return key_len; } /*}}}*/ int search_forward(char *s) /*{{{*/ { return search(s, 1, 0); } /*}}}*/ int search_backward(char *s) /*{{{*/ { return search(s, -1, 0); } /*}}}*/ int forward_search_line(char *s) /*{{{*/ { return search(s, 1, 1); } /*}}}*/ int backward_search_line(char *s) /*{{{*/ { return( search(s, -1, 1)); } /*}}}*/ int bol_fsearch (char *str) /*{{{*/ { Line *tthis; int max, cs = Buffer_Local.case_search; unsigned int num; unsigned char ch; if (Point) { tthis = CLine->next; if (tthis == NULL) return 0; num = 1; } else { tthis = CLine; num = 0; } max = strlen (str); if (max == 0) goto return_success; ch = str[0]; if (cs != 0) { while (tthis != NULL) { if ((tthis->len >= max) && (*tthis->data == ch)) { int n; unsigned char *s; s = tthis->data; n = 1; while (1) { if (n == max) goto return_success; if (s[n] != str[n]) break; n++; } } num++; tthis = tthis->next; } return 0; } /* Here we have the case-insensitive match */ while (tthis != NULL) { if (tthis->len >= max) { unsigned char *s = tthis->data; int n = 0; while (UPPER_CASE(s[n]) == UPPER_CASE(str[n])) { n++; if (n == max) goto return_success; } } num++; tthis = tthis->next; } return 0; return_success: LineNum += num; CLine = tthis; bol (); return max; } /*}}}*/ int bol_bsearch (char *str) /*{{{*/ { Line *tthis; int max, n, cs = Buffer_Local.case_search; unsigned int num; unsigned char ch; if (bolp ()) { if (NULL == (tthis = CLine->prev)) return 0; num = 1; } else { tthis = CLine; num = 0; } max = strlen (str); if (max == 0) { LineNum -= num; CLine = tthis; bol (); return 0; } ch = str[0]; if (cs == 0) ch = UPPER_CASE(ch); while (tthis != NULL) { unsigned char *s; if (tthis->len < max) { num++; tthis = tthis->prev; continue; } s = tthis->data; if ((*s != ch) && ((cs != 0) || (ch != UPPER_CASE(*s)))) { num++; tthis = tthis->prev; continue; } if (cs) { for (n = 1; n < max; n++) { if (s[n] != str[n]) break; } } else { for (n = 1; n < max; n++) { if (UPPER_CASE(s[n]) != UPPER_CASE(str[n])) break; } } if (n == max) { CLine = tthis; LineNum -= num; bol (); return max; } num++; tthis = tthis->prev; } return 0; } /*}}}*/ static int re_search_dir(unsigned char *pat, int dir) /*{{{*/ { char *match; unsigned int flags = 0; int must_match_bol; int max_point; if (Buffer_Local.case_search == 0) flags |= SLREGEXP_CASELESS; #if 0 if (Jed_UTF8_Mode) flags |= SLREGEXP_UTF8; #endif if (Regexp != NULL) SLregexp_free (Regexp); if (NULL == (Regexp = SLregexp_compile ((char *)pat, flags))) return 0; (void) SLregexp_get_hints (Regexp, &flags); must_match_bol = flags & SLREGEXP_HINT_BOL; if (must_match_bol && (dir == 1) && (Point != 0) && (0 == jed_down (1))) return 0; max_point = Point; while (1) { if (dir == 1) { match = SLregexp_match (Regexp, (char *)CLine->data + Point, CLine->len - Point); if (match != NULL) { /* adjust offsets */ Regexp_Offset = Point; } } else if (NULL != (match = SLregexp_match(Regexp, (char *)CLine->data, CLine->len))) { char *max_match = (char *)CLine->data + max_point; Regexp_Offset = 0; if (match >= max_match) { /* Match occurs to the right of where it is expected to be */ match = NULL; } else if (must_match_bol == 0) { int epos = Point - 1; /* found a match on line now find one closest to current point */ while (epos >= 0) { match = SLregexp_match(Regexp, (char *)CLine->data + epos, CLine->len - epos); if ((match == NULL) || (match >= max_match)) { epos--; continue; } Regexp_Offset = epos; break; } } } if (match != NULL) { unsigned int ofs, len; jed_position_point ((unsigned char *)match); (void) SLregexp_nth_match (Regexp, 0, &ofs, &len); return (len + 1); } if (dir > 0) { if (0 == jed_down (1)) break; } else { if (0 == jed_up(1)) break; /* For the purposes of searching, the Point lies between the end * of this one and the beginning of the next. */ max_point = CLine->len; } } return (0); } /*}}}*/ int re_search_forward(char *pat) /*{{{*/ { int n, p, len; Line *l; if (eobp ()) return 0; p = Point; n = LineNum; l = CLine; if (0 != (len = re_search_dir((unsigned char *) pat, 1))) return (len); Point = p; LineNum = n; CLine = l; return (0); } /*}}}*/ int re_search_backward(char *pat) /*{{{*/ { int n, p, len; Line *l; p = Point; n = LineNum; l = CLine; if (0 != (len = re_search_dir((unsigned char *) pat, -1))) return (len); Point = p; LineNum = n; CLine = l; return (0); } /*}}}*/ int replace_match(char *s, int *literal) /*{{{*/ { int n, nmax; char ch; unsigned int offset; unsigned int end_of_match_point; Line *match_line; unsigned int i; int beg_matches[10]; unsigned int len_matches[10]; if (Regexp == NULL) return 0; offset = Regexp_Offset; for (i = 0; i < 10; i++) { unsigned int bm, lm; if (-1 == SLregexp_nth_match (Regexp, i, &bm, &lm)) { beg_matches[i] = -1; len_matches[i] = 0; continue; } beg_matches[i] = (int) bm; len_matches[i] = lm; } end_of_match_point = beg_matches[0] + offset + len_matches[0]; if ((beg_matches[0] == -1) || (end_of_match_point > (unsigned int) CLine->len)) return 0; if (*literal) { Point = beg_matches[0] + offset; n = len_matches[0]; if (-1 == jed_generic_del_nbytes (n)) return -1; jed_insert_string(s); return (1); } /* This is painful --- \& means whole expression, \x x = 1..9 means a sub expression */ match_line = CLine; /* must work with relative numbers since ins/del may do a realloc */ if (end_of_match_point == (unsigned int) match_line->len) { (void) eol (); (void) jed_right(1); } else Point = end_of_match_point; while ((ch = *s++) != 0) { if (ch != '\\') { if (-1 == jed_insert_byte (ch)) return -1; continue; } ch = *s++; if (ch == 0) break; switch (ch) { case 'n': ch = '\n'; goto default_label; case 't': ch = '\t'; goto default_label; case 'r': ch = '\r'; goto default_label; case 'v': ch = '\v'; goto default_label; case 'b': ch = '\b'; goto default_label; case 'f': ch = '\f'; goto default_label; case 'e': ch = 27; goto default_label; case 'a': ch = 7; goto default_label; case '\\': default_label: default: if (-1 == jed_insert_byte (ch)) return -1; break; case '&': ch = 0; /* drop */ case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': nmax = ch - '0'; if ((n = beg_matches[nmax]) == -1) continue; nmax = len_matches[nmax] + beg_matches[nmax]; while (n < nmax) { /* _jed_ins_byte may reallocate CLine->data */ unsigned char byte = *(match_line->data + offset + n); if (-1 == jed_insert_byte (byte)) return -1; n++; } } } push_spot(); while (CLine != match_line) { if (1 != jed_up (1)) { SLang_verror (SL_APPLICATION_ERROR, "Internal problem in replace_match"); return -1; } } Point = beg_matches[0] + offset; n = len_matches[0]; (void) jed_generic_del_nbytes (n); pop_spot(); return (1); } /*}}}*/ /* Someday it might be necessary to deal with embedded \0 characters. */ static int push_string(char *b, int n) /*{{{*/ { char *s; int ret = -1; s = SLang_create_nslstring (b, n); if (s != NULL) { ret = SLang_push_string (s); SLang_free_slstring (s); } return ret; } /*}}}*/ void regexp_nth_match (int *np) /*{{{*/ { unsigned int ofs, len; unsigned char *p, *pmax; if (Regexp == NULL) { (void) push_string ("", 0); return; } if (-1 == SLregexp_nth_match (Regexp, (unsigned int) *np, &ofs, &len)) { (void) push_string ("", 0); return; } p = CLine->data + Regexp_Offset + ofs; pmax = p + len; if (pmax > CLine->data + CLine->len) { SLang_set_error (SL_RunTime_Error); return; } (void) push_string((char *) p, len); } /*}}}*/ int search_file (char *file, char *pat, int *np) /*{{{*/ { unsigned int n; VFILE *vp; int n_matches = 0, n_max = *np, key_len = 0; SLsearch_Type *st; unsigned char *buf; unsigned int flags; SLRegexp_Type *reg; int osearch; int must_match; flags = 0; if (Buffer_Local.case_search == 0) flags |= SLREGEXP_CASELESS; if (Jed_UTF8_Mode) flags |= SLREGEXP_UTF8; if (NULL == (reg = SLregexp_compile (pat, flags))) return 0; (void) SLregexp_get_hints (reg, &flags); osearch = flags & SLREGEXP_HINT_OSEARCH; must_match = 0; st = NULL; if (osearch) { st = open_search ((char *) pat, 1, Buffer_Local.case_search, &key_len); if (st == NULL) return 0; } if (NULL == (vp = vopen(file, 0, VFILE_TEXT))) { if (st != NULL) close_search (st); SLregexp_free (reg); return 0; } while (NULL != (buf = (unsigned char *) vgets(vp, &n))) { if (must_match) { if (NULL == SLsearch_forward (st, buf, buf + n)) continue; if (osearch) goto match_found; } if (NULL == SLregexp_match (reg, (char *)buf, n)) continue; match_found: n_matches++; if (-1 == push_string ((char *) buf, n)) break; n_max--; if (n_max == 0) break; } vclose(vp); if (st != NULL) close_search (st); SLregexp_free (reg); return n_matches; } /*}}}*/ int insert_file_region (char *file, char *rbeg, char *rend) /*{{{*/ { VFILE *vp; unsigned int n; unsigned int len = (unsigned int) strlen (rbeg); int num = 0; unsigned char *buf; if (NULL == (vp = vopen(file, 0, VFILE_TEXT))) return (-1); while (NULL != (buf = (unsigned char *) vgets(vp, &n))) { if ((len == 0) || ((n >= len) && !strncmp ((char *) buf, rbeg, len))) { Suspend_Screen_Update = 1; if (-1 == jed_quick_insert (buf, (int) n)) { vclose (vp); return -1; } num++; len = (unsigned int) strlen (rend); while (NULL != (buf = (unsigned char *) vgets(vp, &n))) { if (len && ((n >= len) && !strncmp ((char *) buf, rend, len))) break; if (-1 == jed_quick_insert(buf, (int) n)) { vclose (vp); return -1; } if (SLang_get_error ()) break; num++; } break; } } vclose (vp); return num; } /*}}}*/ jed-0.99-19/src/chkslang.c0000644002657400265740000000773511311317447014233 0ustar davisdavis/* Copyright (c) 1992, 1998, 2000, 2002, 2003, 2004, 2005, 2006, 2008 John E. Davis * This file is part of JED editor library source. * * You may distribute this file under the terms the GNU General Public * License. See the file COPYING for more information. */ /* It is too bad that this cannot be done at the preprocessor level. * Unfortunately, C is not completely portable yet. Basically the #error * directive is the problem. */ #include "config.h" #include #ifdef HAVE_STDLIB_H # include #endif #ifdef VMS # include #endif #include #include "jdmacros.h" #ifdef VMS # define SUCCESS 1 # define FAILURE 2 #else # define SUCCESS 0 # define FAILURE 1 #endif static char *make_version (unsigned int v) { static char v_string[128]; unsigned int a, b, c; a = v/10000; b = (v - a * 10000) / 100; c = v - (a * 10000) - (b * 100); sprintf (v_string, "%u.%u.%u", a, b, c); return v_string; } int main (int argc, char **argv) { unsigned int min_version, sl_version; unsigned int sug_version; int ret; if ((argc < 3) || (argc > 4)) { fprintf (stderr, "Usage: %s \n", argv[0]); return FAILURE; } #ifndef SLANG_VERSION sl_version = 0; #else sl_version = SLANG_VERSION; #ifdef REAL_UNIX_SYSTEM if (SLang_Version != SLANG_VERSION) { fprintf (stderr, "\n\n******\n"); fprintf (stderr, "\ slang.h (version=%ld) does not match the slang library version (%ld)\n\ Did you install slang as a shared library? Did you run ldconfig?\n\ Perhaps you need to set the RPATH variable in the Makefile.\n\ You have an installation problem and you will need to check the SLANG\n\ variables in the Makefile and properly set them.\n\ Also try: make clean; make\n", (long)SLANG_VERSION, (long)SLang_Version); fprintf (stderr, "******\n\n"); return FAILURE; } #endif #endif sscanf (argv[2], "%u", &min_version); if (argc == 4) sscanf (argv[3], "%u", &sug_version); else sug_version = sl_version; ret = SUCCESS; if (sl_version < min_version) { fprintf (stderr, "This version of %s requires slang version %s.\n", argv[1], make_version(min_version)); ret = FAILURE; } if (sl_version < sug_version) { fprintf (stderr, "Your slang version is %s.\n", make_version(sl_version)); fprintf (stderr, "To fully utilize this program, you should upgrade the slang library to\n"); fprintf (stderr, " version %s\n", make_version(sug_version)); fprintf (stderr, "This library is available from .\n"); } #ifdef SIZEOF_SHORT if (sizeof(short) != SIZEOF_SHORT) { fprintf (stderr, "SIZEOF_SHORT[%lu] is not equal to sizeof(short)[%lu]\n", (unsigned long) SIZEOF_SHORT, (unsigned long) sizeof(short)); ret = FAILURE; } #endif #ifdef SIZEOF_INT if (sizeof(int) != SIZEOF_INT) { fprintf (stderr, "SIZEOF_INT[%lu] is not equal to sizeof(int)[%lu]\n", (unsigned long) SIZEOF_INT, (unsigned long) sizeof(int)); ret = FAILURE; } #endif #ifdef SIZEOF_LONG if (sizeof(long) != SIZEOF_LONG) { fprintf (stderr, "SIZEOF_LONG[%lu] is not equal to sizeof(long)[%lu]\n", (unsigned long) SIZEOF_LONG, (unsigned long) sizeof(long)); ret = FAILURE; } #endif #ifdef SIZEOF_LONG_LONG if (sizeof(long long) != SIZEOF_LONG_LONG) { fprintf (stderr, "SIZEOF_LONG_LONG[%lu] is not equal to sizeof(long long)[%lu]\n", (unsigned long) SIZEOF_LONG_LONG, (unsigned long) sizeof(long long)); ret = FAILURE; } #endif #ifdef SIZEOF_FLOAT if (sizeof(float) != SIZEOF_FLOAT) { fprintf (stderr, "SIZEOF_FLOAT[%lu] is not equal to sizeof(float)[%lu]\n", (unsigned long) SIZEOF_FLOAT, (unsigned long) sizeof(float)); ret = FAILURE; } #endif #ifdef SIZEOF_DOUBLE if (sizeof(double) != SIZEOF_DOUBLE) { fprintf (stderr, "SIZEOF_DOUBLE[%lu] is not equal to sizeof(double)[%lu]\n", (unsigned long) SIZEOF_DOUBLE, (unsigned long) sizeof(double)); ret = FAILURE; } #endif return ret; } jed-0.99-19/src/replace.h0000644002657400265740000000111111311317447014037 0ustar davisdavis/* Copyright (c) 1992, 1998, 2000, 2005, 2006 John E. Davis * This file is part of JED editor library source. * * You may distribute this file under the terms the GNU General Public * License. See the file COPYING for more information. */ extern int Replace_Preserve_Case; extern SLang_Intrin_Fun_Type Jed_Other_Intrinsics []; #ifndef SIXTEEN_BIT_SYSTEM extern void append_region_to_kill_array (int *); extern void prepend_region_to_kill_array (int *); extern void insert_from_kill_array (int *); extern void copy_region_to_kill_array (int *); extern int Kill_Array_Size; #endif jed-0.99-19/src/userinfo.h0000644002657400265740000000054011311317447014263 0ustar davisdavis/* Copyright (c) 1999, 2000, 2005, 2006 John E. Davis * This file is part of JED editor library source. * * You may distribute this file under the terms the GNU General Public * License. See the file COPYING for more information. */ extern int jed_init_userinfo (void); extern char *jed_get_hostname (void); extern char *jed_get_username (void); jed-0.99-19/src/screen.c0000644002657400265740000013413711311317447013715 0ustar davisdavis/* -*- mode: C; mode: fold; -*- */ /* Copyright (c) 1992, 1998, 2000, 2002, 2003, 2004, 2005, 2006 John E. Davis * This file is part of JED editor library source. * * You may distribute this file under the terms the GNU General Public * License. See the file COPYING for more information. */ #include "config.h" #include "jed-feat.h" #include #include #include "jdmacros.h" #include #if defined(IBMPC_SYSTEM) && !defined(__CYGWIN32__) && !defined(__IBMC__) # include #endif #include "buffer.h" #include "screen.h" #include "window.h" #include "paste.h" #include "ins.h" #include "ledit.h" #include "display.h" #include "sysdep.h" #include "misc.h" #include "file.h" #include "hooks.h" #include "menu.h" #include "version.h" #include "indent.h" #include "colors.h" #if JED_HAS_SUBPROCESSES # include "jprocess.h" #endif #include "sig.h" #if SLANG_VERSION < 20000 #define SLstack_depth _SLstack_depth extern int _SLstack_depth(void); #endif volatile int Jed_Resize_Pending; char *MiniBuf_Get_Response_String; int Jed_Simulate_Graphic_Chars; typedef struct Screen_Type { Line *line; /* buffer line structure */ int is_modified; unsigned char *hi0, *hi1; /* beg end of hilights */ } Screen_Type; static Screen_Type *JScreen; int Jed_Num_Screen_Rows; int Jed_Num_Screen_Cols; int Screen_Row = 1; int Screen_Col = 1; int Cursor_Motion; /* indicates cursor movement only -1 ^ v +1 < > */ int Jed_Dollar = '$'; int Jed_Highlight_WS = 0; int User_Prefers_Line_Numbers = 0; int Mode_Has_Syntax_Highlight; int Wants_Syntax_Highlight = 1; /* if non-zero, highlight the syntax. */ int Wants_Attributes = 1; int Wants_HScroll = 20; /* controls automatic horizontal * scrolling. If positive, scroll * only line, if negative, whole wind */ int Term_Supports_Color = 1; /* optimistic assumption */ int Goal_Column; int Want_Eob = 0; int Display_Time = 1; /* Turn on %t processing in status line */ void (*X_Update_Open_Hook)(void); /* hooks called when starting */ void (*X_Update_Close_Hook)(void); /* and finishing update */ /* site.sl should modify this */ char Default_Status_Line[80] = " ^Ke: quit, ^Kg: get file, ^K^W: write file | %b (%m%n%o) %p"; static Line *HScroll_Line; static int HScroll; /* amount to scroll line by */ static int Absolute_Column; static int Point_Cursor_Flag = 1; /* if non-zero, point cursor */ int Jed_Display_Initialized; static Line Eob_Line = { NULL, NULL, (unsigned char *) "[EOB]", 5 #ifdef KEEP_SPACE_INFO ,5 #endif #if JED_HAS_LINE_ATTRIBUTES , JED_LINE_IS_READONLY #endif }; #if SLANG_VERSION < 20000 static unsigned char Char_Width[256]; static int Display_Eight_Bit = 0x7FFF; # define FIX_CHAR_WIDTH \ if (SLsmg_Display_Eight_Bit != Display_Eight_Bit) fix_char_width () #endif static void display_line (Line *line, int sy, int sx) { unsigned int len; int hscroll_col; int is_mini; Screen_Type *s; #if JED_HAS_LINE_MARKS Mark *line_marks; #endif int num_columns; int color_set; SLsmg_Tab_Width = Buffer_Local.tab; #if SLANG_VERSION >= 20000 (void) SLsmg_embedded_escape_mode (CBuf->flags & SMG_EMBEDDED_ESCAPE); #endif is_mini = (sy + 1 == Jed_Num_Screen_Rows); SLsmg_gotorc (sy, sx); SLsmg_set_color (0); s = JScreen + sy; s->line = line; s->is_modified = 0; if (line == NULL) { SLsmg_erase_eol (); return; } hscroll_col = JWindow->hscroll_column - 1; if ((line == HScroll_Line) && Wants_HScroll && HScroll) hscroll_col += HScroll; num_columns = JWindow->width; if (hscroll_col || sx #if JED_HAS_DISPLAY_LINE_NUMBERS || (CBuf->line_num_display_size) #endif ) { int tmp = hscroll_col - sx; #if JED_HAS_DISPLAY_LINE_NUMBERS tmp -= CBuf->line_num_display_size; num_columns -= CBuf->line_num_display_size; #endif SLsmg_set_screen_start (NULL, &tmp); sx = 0; } len = line->len; if (is_mini) { SLsmg_Newline_Behavior = SLSMG_NEWLINE_PRINTABLE; SLsmg_write_string ((char *)Mini_Info.prompt); } else { SLsmg_Newline_Behavior = 0; if (len && (line->data[len - 1] == '\n')) len--; } color_set = 0; #if JED_HAS_LINE_ATTRIBUTES if (line->flags & JED_LINE_COLOR_BITS) { SLsmg_set_color (JED_GET_LINE_COLOR(line)); color_set = 1; } #endif #if JED_HAS_LINE_MARKS line_marks = CBuf->user_marks; if (color_set == 0) while (line_marks != NULL) { if ((line_marks->line == line) && (line_marks->flags & JED_LINE_MARK)) { SLsmg_set_color (line_marks->flags & MARK_COLOR_MASK); color_set = 1; break; } line_marks = line_marks->next; } #endif if (len) { if ((color_set == 0) && Mode_Has_Syntax_Highlight && (line != &Eob_Line) #if !defined(IBMPC_SYSTEM) && (*tt_Use_Ansi_Colors && Term_Supports_Color) #endif && Wants_Syntax_Highlight) write_syntax_highlight (sy, line, len); else { if ((is_mini == 0) && Jed_Highlight_WS & HIGHLIGHT_WS_TRAILING) { unsigned char *pmin = line->data; unsigned char *pmax = pmin + len; unsigned char *p = pmax; while (p > pmin) { p--; if ((*p != ' ') && (*p != '\t')) { p++; break; } } SLsmg_write_nchars ((char *)pmin, p - pmin); if (p != pmax) { SLsmg_set_color (JTWS_COLOR); SLsmg_write_nchars ((char *)p, pmax - p); SLsmg_set_color (0); } } else SLsmg_write_nchars ((char *)line->data, len); } } #if JED_HAS_LINE_ATTRIBUTES if ((line->next != NULL) && (line->next->flags & JED_LINE_HIDDEN)) { SLsmg_set_color (JDOTS_COLOR); SLsmg_write_string ("..."); SLsmg_set_color (0); } #endif SLsmg_erase_eol (); if (Jed_Dollar) { char dollar = (char) Jed_Dollar; if (hscroll_col + num_columns <= SLsmg_get_column ()) { SLsmg_gotorc (sy, hscroll_col + num_columns - 1); SLsmg_set_color (JDOLLAR_COLOR); SLsmg_write_nchars (&dollar, 1); } if (hscroll_col) { SLsmg_gotorc (sy, hscroll_col); SLsmg_set_color (JDOLLAR_COLOR); SLsmg_write_nchars (&dollar, 1); } } if ((s->hi0 != NULL) && Wants_Attributes) { int c; len = (int) (s->hi1 - s->hi0); if (len && (s->hi0[len - 1] == '\n')) len--; if (len) { c = jed_compute_effective_length (line->data, s->hi0); if (is_mini) c += Mini_Info.effective_prompt_len; SLsmg_gotorc (sy, c); SLsmg_set_color (JREGION_COLOR); SLsmg_write_nchars ((char *)s->hi0, len); } } /* if (hscroll_col + sx) */ SLsmg_set_screen_start (NULL, NULL); SLsmg_set_color (0); } #if JED_HAS_DISPLAY_LINE_NUMBERS static void display_line_numbers (void) { unsigned int i, imin, imax, linenum; Line *line_start, *line; char buf[32]; unsigned int c; imin = JWindow->sy; imax = imin + JWindow->rows; line = NULL; for (i = imin; i < imax; i++) { if (JScreen[i].line != CLine) continue; line = JScreen[i].line; break; } if (line == NULL) return; /* ??? */ line_start = JScreen[imin].line; linenum = LineNum + CBuf->nup; while (line != line_start) { if (line == NULL) return; /* ??? */ linenum--; line = line->prev; } SLsmg_set_color (JLINENUM_COLOR); c = JWindow->sx; for (i = imin; i < imax; i++) { line_start = JScreen[i].line; if (line_start == NULL) break; while (line != line_start) { if (line == NULL) return; /* ??? */ linenum++; line = line->next; } SLsmg_gotorc (i, c); sprintf (buf, "%*d ", CBuf->line_num_display_size-1, linenum); SLsmg_write_string (buf); line = line->next; linenum++; } if (i < imax) { memset (buf, ' ', CBuf->line_num_display_size); buf[CBuf->line_num_display_size] = 0; while (i < imax) { SLsmg_gotorc (i, c); SLsmg_write_string (buf); i++; } } SLsmg_set_color (0); } #endif #if JED_HAS_LINE_ATTRIBUTES static int Non_Hidden_Point; Line *jed_find_non_hidden_line (Line *l) { int dir; Line *cline; Non_Hidden_Point = 0; if (0 == (l->flags & JED_LINE_HIDDEN)) { return l; } cline = l; dir = 1; while ((cline != NULL) && (cline->flags & JED_LINE_HIDDEN)) cline = cline->prev; if (cline == NULL) { cline = l; dir = -1; while ((cline != NULL) && (cline->flags & JED_LINE_HIDDEN)) cline = cline->next; if (cline == NULL) return NULL; } if (dir == 1) { Non_Hidden_Point = cline->len; } return cline; } #endif Line *jed_find_top_to_recenter (Line *cline) { int n; Line *prev, *last_prev; n = JWindow->rows / 2; last_prev = prev = cline; while ((n > 0) && (prev != NULL)) { n--; last_prev = prev; #if JED_HAS_LINE_ATTRIBUTES do { prev = prev->prev; } while ((prev != NULL) && (prev->flags & JED_LINE_HIDDEN)); #else prev = prev->prev; #endif } if (prev != NULL) return prev; return last_prev; } Line *find_top (void) { int nrows, i; Line *cline, *prev, *next; Line *top_window_line; cline = CLine; #if JED_HAS_LINE_ATTRIBUTES if (cline->flags & JED_LINE_HIDDEN) cline = jed_find_non_hidden_line (cline); if (cline == NULL) return NULL; #endif nrows = JWindow->rows; if (nrows <= 1) return cline; /* Note: top_window_line might be a bogus pointer. This means that I cannot * access it unless it really corresponds to a pointer in the buffer. */ top_window_line = JScreen [JWindow->sy].line; if (top_window_line == NULL) return jed_find_top_to_recenter (cline); /* Chances are that the current line is visible in the window. This means * that the top window line should be above it. */ prev = cline; i = 0; while ((i < nrows) && (prev != NULL)) { if (prev == top_window_line) { return top_window_line; } #if JED_HAS_LINE_ATTRIBUTES do { prev = prev->prev; } while ((prev != NULL) && (prev->flags & JED_LINE_HIDDEN)); #else prev = prev->prev; #endif i++; } /* Now check the borders of the window. Perhaps the current line lies * outsider the border by a line. Only do this if terminal can scroll. */ if ((*tt_Term_Cannot_Scroll) && (*tt_Term_Cannot_Scroll != -1)) return jed_find_top_to_recenter (cline); next = cline->next; #if JED_HAS_LINE_ATTRIBUTES while ((next != NULL) && (next->flags & JED_LINE_HIDDEN)) next = next->next; #endif if ((next != NULL) && (next == top_window_line)) return cline; prev = cline->prev; #if JED_HAS_LINE_ATTRIBUTES while ((prev != NULL) && (prev->flags & JED_LINE_HIDDEN)) prev = prev->prev; #endif top_window_line = JScreen [nrows + JWindow->sy - 1].line; if ((prev == NULL) || (prev != top_window_line)) return jed_find_top_to_recenter (cline); /* It looks like cline is below window by one line. See what line should * be at top to scroll it into view. */ i = 2; while ((i < nrows) && (prev != NULL)) { #if JED_HAS_LINE_ATTRIBUTES do { prev = prev->prev; } while ((prev != NULL) && (prev->flags & JED_LINE_HIDDEN)); #else prev = prev->prev; #endif i++; } if (prev != NULL) return prev; return jed_find_top_to_recenter (cline); } #if SLANG_VERSION >= 20000 static void init_smg_for_buffer (int *rowp, int *colp) { SLsmg_Tab_Width = Buffer_Local.tab; if (IN_MINI_WINDOW) SLsmg_Newline_Behavior = SLSMG_NEWLINE_PRINTABLE; else SLsmg_Newline_Behavior = 0; (void) SLsmg_embedded_escape_mode (CBuf->flags & SMG_EMBEDDED_ESCAPE); *rowp = SLsmg_get_row (); *colp = SLsmg_get_column (); SLsmg_gotorc (0, 0); } void point_column (int n) { SLuchar_Type *p, *pmax; int row, col; /* Compensate for the prompt */ if (IN_MINI_WINDOW) n -= Mini_Info.effective_prompt_len; p = CLine->data; pmax = p + CLine->len; if (LINE_HAS_NEWLINE (CLine)) pmax--; init_smg_for_buffer (&row, &col); n = (int) SLsmg_strbytes (p, pmax, (unsigned int) n); SLsmg_gotorc (row, col); jed_set_point (n); } int jed_compute_effective_length (unsigned char *pos, unsigned char *pmax) { int len, row, col; init_smg_for_buffer (&row, &col); len = (int) SLsmg_strwidth (pos, pmax); SLsmg_gotorc (row, col); return len; } #else /* This function has to be consistent with SLsmg. */ static void fix_char_width(void) { int i, ebit; ebit = SLsmg_Display_Eight_Bit; if (ebit < 128) ebit = 128; /* Control Characters */ for (i = 0; i < 32; i++) Char_Width[i] = 2; for (i = 32; i < 127; i++) Char_Width[i] = 1; Char_Width[127] = 2; for (i = 128; i < ebit; i++) Char_Width[i] = 3; /* ~^X */ for (i = ebit; i < 256; i++) Char_Width[i] = 1; Display_Eight_Bit = ebit; } void point_column (int n) { register unsigned char *p, *pmax; register int i; int tab, w; FIX_CHAR_WIDTH; if (IN_MINI_WINDOW) n -= Mini_Info.effective_prompt_len; p = CLine->data; pmax = p + CLine->len; if (LINE_HAS_NEWLINE (CLine)) pmax--; tab = Buffer_Local.tab; i = 0; n--; /* start at 0 */ while (p < pmax) { unsigned int nconsumed = 1; if ((*p == '\t') && tab) { i = tab * (i / tab + 1); } else { w = Char_Width[*p]; i += w; } if (i > n) break; p += nconsumed; } jed_set_point (p - CLine->data); } int jed_compute_effective_length (unsigned char *pos, unsigned char *pmax) { int i; int tab, w; register unsigned char *cw = Char_Width; register unsigned char ch; FIX_CHAR_WIDTH; i = 0; tab = Buffer_Local.tab; while (pos < pmax) { ch = *pos++; if ((ch == '\t') && tab) { i = tab * (i/tab + 1); /* tab column tabs */ } else { w = cw[ch]; i += w; if (w == 0) pos++; } } return i; } #endif /* SLANG_VERSION >= 20000 */ int calculate_column (void) { int c; c = 1 + jed_compute_effective_length (CLine->data, CLine->data + Point); Absolute_Column = c; if (IN_MINI_WINDOW) c += Mini_Info.effective_prompt_len; Screen_Col = c; return (c); } void point_cursor (int c) { int r, row; Line *tthis, *cline; if (JWindow->trashed) return; cline = CLine; #if JED_HAS_LINE_ATTRIBUTES if (cline->flags & JED_LINE_HIDDEN) { cline = jed_find_non_hidden_line (cline); if (cline != NULL) c = Non_Hidden_Point; } #endif r = JWindow->sy + 1; Point_Cursor_Flag = 0; for (row = r; row < r + JWindow->rows; row++) { tthis = JScreen[row-1].line; if (tthis == NULL) break; if ((tthis == cline) || (tthis == &Eob_Line)) { r = row; break; } } if (Point >= CLine->len) { Point = CLine->len - 1; if (Point < 0) Point = 0; else if ((*(CLine->data + Point) != '\n') || (CBuf == MiniBuffer)) Point++; } if (c == 0) c = calculate_column (); c -= (JWindow->hscroll_column - 1); if (cline == HScroll_Line) c -= HScroll; if (c < 1) c = 1; else if (c > JWindow->width) c = JWindow->width; c += JWindow->sx; #if JED_HAS_DISPLAY_LINE_NUMBERS c += CBuf->line_num_display_size; #endif SLsmg_gotorc (r - 1, c - 1); Screen_Row = r; Screen_Col = c; SLsmg_refresh (); if (!Cursor_Motion) Goal_Column = c; } static unsigned long Status_Last_Time; static unsigned long Status_This_Time; static char *status_get_time(void) { static char status_time[10]; register char *t, ch, *t1; char am; int n; if (Display_Time == 0) return (NULL); if (Status_This_Time == 0) Status_This_Time = sys_time(); if (Status_This_Time - Status_Last_Time >= 30) { Status_Last_Time = Status_This_Time; am = 'a'; t = SLcurrent_time_string (); /* returns a string like: "Tue Nov 2 13:18:19 1993" */ t1 = status_time; while (ch = *t, (ch <= '0') || (ch > '9')) t++; /* on date number, skip it */ while (*t++ != ' '); if (*t == '0') t++; if (Display_Time > 0) { n = 0; while ((ch = *t++) != ':') { n = 10 * n + (int) (ch - '0'); } if (n >= 12) am = 'p'; n = n % 12; if (n == 0) n = 12; if (n >= 10) { n -= 10; *t1++ = '1'; } *t1++ = '0' + n; *t1++ = ':'; while ((*t1++ = *t++) != ':'); *(t1 - 1) = am; *t1++ = 'm'; *t1 = 0; } else { *t1++ = '['; while ((*t1++ = *t++) != ':'); while ((*t1++ = *t++) != ':'); *--t1 = ']'; *++t1 = 0; } } return (status_time); } static void finish_status(int col_flag) { char *v, ch; Line *l; int top, rows, narrows; char buf [256]; char *str; v = CBuf->status_line; if (*v == 0) v = Default_Status_Line; while (1) { char *v0 = v; while (1) { ch = *v; if (ch == 0) { SLsmg_write_nchars (v0, (unsigned int) (v-v0)); return; } if (ch == '%') { SLsmg_write_nchars (v0, (unsigned int) (v-v0)); break; } v++; } /* At this point *v == '%' */ v++; ch = *v++; switch (ch) { case 'F': SLsmg_write_string (CBuf->dir); str = CBuf->file; break; case 'S': /* stack depth */ sprintf(buf, "%03d", SLstack_depth()); str = buf; break; case 'a': if (CBuf->flags & ABBREV_MODE) str = " abbrev"; else str = NULL; break; case 'f': str = CBuf->file; break; case 'n': narrows = jed_count_narrows (); if (narrows) { sprintf (buf, " Narrow[%d]", narrows); str = buf; } else str = NULL; break; case 'o': if (CBuf->flags & OVERWRITE_MODE) str = " Ovwrt"; else str = NULL; break; case 'O': if (CBuf->flags & OVERWRITE_MODE) str = " ovr"; else str = " ins"; break; case 'b': str = CBuf->name; break; case 'p': str = buf; if (0 == User_Prefers_Line_Numbers) { top = JWindow->sy; rows = JWindow->rows - 1; l = JScreen[top + rows].line; if (l == CBuf->end) l = NULL; if (JScreen[top].line == CBuf->beg) { if (l == NULL) str = "All"; else str = "Top"; } else if (l == NULL) str = "Bot"; else { sprintf(buf, "%d%%", (int) ((LineNum * 100L) / (long) Max_LineNum)); } } else { if (User_Prefers_Line_Numbers == 1) sprintf(buf, "%d/%d", LineNum, Max_LineNum); else { if (col_flag) (void) calculate_column (); sprintf(buf, "%d/%d,%d", LineNum, Max_LineNum, Absolute_Column); } } break; case 'l': sprintf(buf, "%d", LineNum); str=buf; break; case 'L': sprintf(buf, "%d", Max_LineNum); str=buf; break; case 'v': #if JED_HAS_UTF8_SUPPORT SLsmg_write_string (Jed_Version_String); if (Jed_UTF8_Mode) str = "U"; else str = NULL; #else str = Jed_Version_String; #endif break; case 'm': str = CBuf->mode_string; break; case 't': str = status_get_time(); break; case 'c': if (col_flag) (void) calculate_column (); sprintf(buf, "%d", Absolute_Column); str = buf; break; case '%': str = "%"; break; case 0: return; default: str = NULL; } if (str != NULL) SLsmg_write_string (str); } } void set_status_format(char *f, int *local) { char *s; if (*local) s = Default_Status_Line; else s = CBuf->status_line; strncpy(s, f, 79); s[79] = 0; } static int update_status_line (int col_flag) { unsigned char star0, star1; char buf[32], *b; int num; if (IN_MINI_WINDOW) return 0; SLsmg_gotorc (JWindow->rows + JWindow->sy, 0); SLsmg_set_color (JSTATUS_COLOR); b = buf; if (JWindow->hscroll_column != 1) *b++ = '<'; else *b++ = '-'; if (CBuf->flags & BUFFER_MODIFIED) star0 = star1 = '*'; else star0 = star1 = '-'; if ((CBuf->flags & READ_ONLY) #if JED_HAS_LINE_ATTRIBUTES || (CLine->flags & JED_LINE_IS_READONLY) #endif ) star0 = star1 = '%'; #if JED_HAS_SUBPROCESSES if (CBuf->subprocess) star1 = 'S'; #endif *b++ = star0; *b++ = star1; if (CBuf->marks != NULL) *b++ = 'm'; else *b++ = '-'; if (CBuf->flags & FILE_MODIFIED) *b++ = 'd'; else *b++ = '-'; if (CBuf->spots != NULL) *b++ = 's'; else *b++ = '-'; if (CBuf->flags & BINARY_FILE) *b++ = 'B'; #ifdef IBMPC_SYSTEM else if ((CBuf->flags & ADD_CR_ON_WRITE_FLAG) == 0) *b++ = 'L'; #else # ifdef __unix__ else if (CBuf->flags & ADD_CR_ON_WRITE_FLAG) *b++ = 'C'; # endif #endif else *b++ = '-'; if (CBuf->flags & UNDO_ENABLED) *b++ = '+'; else *b++ = '-'; SLsmg_write_nchars (buf, (unsigned int) (b - buf)); finish_status (col_flag); if (Defining_Keyboard_Macro) SLsmg_write_string (" [Macro]"); num = Jed_Num_Screen_Cols - SLsmg_get_column (); star1 = '-'; while (num > 0) { SLsmg_write_nchars ((char *) &star1, 1); num--; } SLsmg_set_color (0); Point_Cursor_Flag = 1; return 1; } static int screen_input_pending (int tsec) { if (Input_Buffer_Len #ifdef HAS_RESIZE_PENDING || Jed_Resize_Pending #endif ) return 1; return input_pending (&tsec); } /* This routine is called before the window is updated. This means that the * line structures attached to the screen array cannot be trusted. However, * the current line (or nearest visible one) can be assumed to lie in * the window. */ static void mark_window_attributes (int wa) { register Screen_Type *s = &JScreen[JWindow->sy], *smax = s + JWindow->rows, *s1, *s2; Mark *m; register Line *l = JWindow->beg.line, *ml, *cline; unsigned char *hi0, *hi1; int mn, pn, dn, point, mpoint; s1 = s; #if JED_HAS_LINE_ATTRIBUTES cline = jed_find_non_hidden_line (CLine); if (cline != CLine) point = Non_Hidden_Point; /* updated by jed_find_non_hidden_line */ else point = Point; #else cline = CLine; point = Point; #endif if ((CBuf->vis_marks == 0) || (wa == 0) || (Wants_Attributes == 0) #if JED_HAS_LINE_ATTRIBUTES || (l->flags & JED_LINE_HIDDEN) #endif ) { s2 = s; goto done; /* I hate gotos but they are convenient */ } m = CBuf->marks; while ((m->flags & VISIBLE_MARK_MASK) == 0) m = m->next; ml = m->line; mn = m->n; /* already in canonical form */ pn = LineNum + CBuf->nup; /* not in canonical form */ dn = pn - mn; #if JED_HAS_LINE_ATTRIBUTES ml = jed_find_non_hidden_line (ml); if (ml == cline) dn = 0; if (ml != m->line) { mpoint = Non_Hidden_Point; /* updated by jed_find_non_hidden_line */ } else mpoint = m->point; #else mpoint = m->point; #endif /* find Screen Pos of point in window. It has to be there */ while (l != cline) { l = l->next; #if JED_HAS_LINE_ATTRIBUTES if (l->flags & JED_LINE_HIDDEN) continue; #endif s1++; } /* s1 now points at current line */ /* The whole point of all of this is to preserve the screen flags without * touching the screen. */ if (dn > 0) /* mark on prev lines */ { s2 = s1 + 1; hi0 = l->data; hi1 = l->data + point; if ((s1->hi0 != hi0) || (s1->hi1 != hi1)) { s1->hi0 = hi0; s1->hi1 = hi1; s1->is_modified = 1; } l = l->prev; s1--; while ((s1 >= s) && (l != ml) && (l != NULL)) { #if JED_HAS_LINE_ATTRIBUTES if (l->flags & JED_LINE_HIDDEN) { l = l->prev; continue; } #endif hi0 = l->data; hi1 = l->data + l->len; if ((s1->hi0 != hi0) || (s1->hi1 != hi1)) { s1->hi0 = hi0; s1->hi1 = hi1; s1->is_modified = 1; } s1--; l = l->prev; } if (s1 >= s) { hi0 = ml->data + mpoint; hi1 = ml->data + ml->len; if ((s1->hi0 != hi0) || (s1->hi1 != hi1)) { s1->hi0 = hi0; s1->hi1 = hi1; s1->is_modified = 1; } s1--; } } else if (dn < 0) /* mark ahead of point */ { s2 = s1; s1--; hi0 = l->data + point; hi1 = l->data + l->len; if ((s2->hi0 != hi0) || (s2->hi1 != hi1)) { s2->hi0 = hi0; s2->hi1 = hi1; s2->is_modified = 1; } l = l->next; s2++; while ((s2 < smax) && (l != ml) && (l != NULL)) { #if JED_HAS_LINE_ATTRIBUTES if (l->flags & JED_LINE_HIDDEN) { l = l->next; continue; } #endif hi0 = l->data; hi1 = l->data + l->len; if ((s2->hi0 != hi0) || (s2->hi1 != hi1)) { s2->hi0 = hi0; s2->hi1 = hi1; s2->is_modified = 1; } l = l->next; s2++; } if (s2 < smax) { hi0 = ml->data; hi1 = ml->data + mpoint; if ((s2->hi0 != hi0) || (s2->hi1 != hi1)) { s2->hi0 = hi0; s2->hi1 = hi1; s2->is_modified = 1; } s2++; } } else /* same line */ { if (point < mpoint) { s1->hi0 = l->data + point; s1->hi1 = l->data + mpoint; } else { s1->hi1 = l->data + point; s1->hi0 = l->data + mpoint; } s1->is_modified = 1; s2 = s1 + 1; s1--; } done: /* reached if there is no mark */ /* now do area outside the region */ while (s1 >= s) { if (s1->hi0 != NULL) { s2->hi1 = s1->hi0 = NULL; s1->is_modified = 1; } s1--; } while (s2 < smax) { if (s2->hi0 != NULL) { s2->hi1 = s2->hi0 = NULL; s2->is_modified = 1; } s2++; } } static void compute_line_display_size (void) { #if JED_HAS_DISPLAY_LINE_NUMBERS int max_num_len = 0; int n; if (CBuf->line_num_display_size == 0) return; n = Max_LineNum + CBuf->nup; while (n != 0) { n /= 10; max_num_len++; } max_num_len++; /* add one as a separator */ if (CBuf->line_num_display_size != max_num_len) { JWindow->trashed = 1; CBuf->line_num_display_size = max_num_len; } #endif } /* if force then do update otherwise return 1 if update or 0 if not */ static int update_1(Line *top, int force) { int i; Window_Type *start_win; int did_eob, time_has_expired = 0; if (Batch || (!force && (Executing_Keyboard_Macro || (Repeat_Factor != NULL) || screen_input_pending (0) || (Read_This_Character != NULL))) || (CBuf != JWindow->buffer)) { return(0); } if (Suspend_Screen_Update != 0) { Suspend_Screen_Update = 0; touch_screen (); } JWindow->mark.line = CLine; JWindow->mark.point = Point; JWindow->mark.n = LineNum + CBuf->nup; CBuf->linenum = LineNum; CBuf->max_linenum = Max_LineNum; if (Wants_Attributes && CBuf->vis_marks) { JWindow->trashed = 1; } /* Do not bother setting this unless it is really needed */ if (Display_Time) { Status_This_Time = sys_time(); time_has_expired = (Status_This_Time > Status_Last_Time + 45); } /* if cursor moves just left right, do not update status line */ if (!force && !JWindow->trashed && ((JWindow == JWindow->next) || (User_Prefers_Line_Numbers && Cursor_Motion)) /* if % wanted, assume user is like me and gets annoyed with * screen updates */ && (User_Prefers_Line_Numbers || time_has_expired)) { update_status_line(0); return(1); } if (!JWindow->trashed && Cursor_Motion) { #if JED_HAS_LINE_ATTRIBUTES if (CLine->flags & JED_LINE_IS_READONLY) update_status_line (0); #endif return 1; } start_win = JWindow; do { int imax; unsigned int start_column; #if JED_HAS_LINE_ATTRIBUTES if (CBuf->min_unparsed_line_num) jed_syntax_parse_buffer (0); #endif if (Wants_Syntax_Highlight) init_syntax_highlight (); #if JED_HAS_LINE_ATTRIBUTES if (top != NULL) top = jed_find_non_hidden_line (top); #endif #if SLANG_VERSION >= 20000 /* (void) SLsmg_utf8_enable (CBuf->local_vars.is_utf8); */ #endif if (top == NULL) { top = find_top(); if (top == NULL) top = CLine; } JWindow->beg.line = top; #if JED_HAS_LINE_ATTRIBUTES if (top->flags & JED_LINE_HIDDEN) top = NULL; else #endif mark_window_attributes ((start_win == JWindow) || (start_win->buffer != CBuf)); did_eob = 0; i = JWindow->sy; imax = i + JWindow->rows; compute_line_display_size (); start_column = JWindow->sx; while (i < imax) { #if JED_HAS_LINE_ATTRIBUTES if ((top != NULL) && (top->flags & JED_LINE_HIDDEN)) { top = top->next; continue; } #endif /* the next line is really optional */ #if 0 if (!force && (Exit_From_MiniBuffer || screen_input_pending (0))) break; #endif if ((JScreen[i].line != top) || JScreen[i].is_modified || (Want_Eob && !did_eob && (i != Jed_Num_Screen_Rows - 1) && (top == NULL))) { if (((top == NULL) || (top->len == 0)) && (Want_Eob && !did_eob && !(CBuf->flags & READ_ONLY))) { display_line(&Eob_Line, i, start_column); /* JScreen[i].line = top; */ did_eob = 1; } else display_line(top, i, start_column); } if (top != NULL) top = top->next; i++; } HScroll_Line = NULL; Mode_Has_Syntax_Highlight = 0; if (!force && screen_input_pending (0)) { while (JWindow != start_win) other_window(); JWindow->trashed = 1; /* since cursor not pointed */ #if SLANG_VERSION >= 20000 /* (void) SLsmg_utf8_enable (1); */ /* default state */ #endif return(0); } else update_status_line (start_win != JWindow); #if JED_HAS_DISPLAY_LINE_NUMBERS if (CBuf->line_num_display_size) display_line_numbers (); #endif JWindow->trashed = 0; other_window(); top = NULL; /* if (!JWindow->trashed) top = JWindow->beg.line; else top = NULL; */ } while (JWindow != start_win); #if SLANG_VERSION >= 20000 /* SLsmg_utf8_enable (1); */ /* default state */ #endif return 1; } int Mini_Ghost = 0; char Message_Buffer[256]; static void do_dialog(char *b) { char *quit = "Quit!"; if (Batch) return; #ifdef FIX_CHAR_WIDTH FIX_CHAR_WIDTH; #endif if (! *b) { if(!SLKeyBoard_Quit) return; b = quit; } if ((b == Error_Buffer) || (b == quit)) { SLsmg_set_color (JERROR_COLOR); touch_screen(); } else SLsmg_set_color (JMESSAGE_COLOR); SLsmg_Newline_Behavior = SLSMG_NEWLINE_PRINTABLE; SLsmg_gotorc (Jed_Num_Screen_Rows - 1, 0); SLsmg_write_string (b); SLsmg_set_color (0); SLsmg_erase_eol (); SLsmg_Newline_Behavior = 0; if ((b == Error_Buffer) || (SLKeyBoard_Quit)) { jed_beep(); flush_input(); } if (*b) { if (MiniBuffer != NULL) { SLsmg_refresh (); (void) input_pending(&Number_Ten); } Mini_Ghost = -1; } else Mini_Ghost = 0; } void clear_message (void) /*{{{*/ { message (NULL); } /*}}}*/ void message (char *msg) { if (Executing_Keyboard_Macro) return; if (msg == NULL) { if (Batch) return; msg = ""; } if (Batch) fprintf(stdout, "%s\n", msg); if (*msg == 0) Mini_Ghost = 1; strncpy(Message_Buffer, msg, sizeof(Message_Buffer)); Message_Buffer[sizeof(Message_Buffer)-1] = 0; } void flush_message (char *m) { message(m); if (Batch || (JWindow == NULL)) return; do_dialog(Message_Buffer); SLsmg_gotorc (Jed_Num_Screen_Rows - 1, strlen(Message_Buffer)); *Message_Buffer = 0; JWindow->trashed = 1; SLsmg_refresh (); } static void update_minibuffer(void) { Window_Type *w; if (Executing_Keyboard_Macro) return; if (MiniBuffer != NULL) { w = JWindow; while (!IN_MINI_WINDOW) other_window(); JWindow->beg.line = CLine; mark_window_attributes (1); display_line(CLine, Jed_Num_Screen_Rows-1, 0); while (w != JWindow) other_window(); Mini_Ghost = 1; } else if (Mini_Ghost && !*Error_Buffer && !*Message_Buffer) { /* if < 0, it is a result of flush message so let it pass this round */ if (Mini_Ghost < 0) Mini_Ghost = 1; else Mini_Ghost = 0; } else Mini_Ghost = ((*Message_Buffer) || (*Error_Buffer)); if (Mini_Ghost == 0) display_line(NULL, Jed_Num_Screen_Rows-1, 0); } #if 0 static void set_hscroll(int col) { int hdiff, whs = abs(Wants_HScroll), wc = JWindow->hscroll_column - 1; int sw = Jed_Num_Screen_Cols - 1; static Line *last; Line *tmp; #if JED_HAS_DISPLAY_LINE_NUMBERS sw -= CBuf->line_num_display_size; #endif if (sw < 1) sw = 1; /* take care of last effect of horizontal scroll */ if (last != NULL) { tmp = CLine; CLine = last; register_change(0); CLine = tmp; if (last != CLine) { #if 0 /* I need to think about this more */ if (Wants_HScroll < 0) { if (wc != 0) { JWindow->column = 1; wc = 0; touch_window (); } } #endif HScroll = 0; } last = NULL; } col--; /* use 0 origin */ hdiff = col - wc; if ((HScroll >= hdiff) || (HScroll <= hdiff - sw)) { if (hdiff >= sw) { HScroll = hdiff - sw + whs; } else if ((hdiff == 0) && (wc == 0)) HScroll = 0; else if (hdiff <= 1) { HScroll = hdiff - whs - 1; } else HScroll = 0; } if (HScroll) { if (wc + HScroll < 0) HScroll = -wc; if (Wants_HScroll < 0) { JWindow->hscroll_column += HScroll; touch_window(); HScroll = 0; } else { register_change(0); last = HScroll_Line = CLine; } } } #endif /* Let "|" denote the window edges, * "." denote text, "*" denotes the current location * * .........|....*..........|.... * <---- col ---> * <-- wc -><-------sw------> * The contraints are: wc >= 0, col >= 0, sw > 0. * Let whs be the value of abs(Wants_HScroll). We want to wc to satisfy * wc+1 <= col <= wc + sw - 1 * ==> col-sw+1 <= wc <= col-1 * However, if wc does not satisfy this, then set wc such that: * * wc + whs <= col <= wc + sw - whs * col+whs-sw <= wc <= col-whs * Evidently, this requires: * col+whs-sw < col-whs * whs-sw < -whs * 2whs < sw ==> whs < sw/2 * * As a special case, if col < sw, then set wc=0. */ static void set_hscroll(int col) { int whs = abs(Wants_HScroll), wc = JWindow->hscroll_column - 1; int sw = Jed_Num_Screen_Cols-1; static Line *last; Line *tmp; int wc_min, wc_max; #if JED_HAS_DISPLAY_LINE_NUMBERS sw -= CBuf->line_num_display_size; #endif if (sw < 2) sw = 2; if (Wants_HScroll > 0) wc += HScroll; /* only this line scrolled */ /* take care of last effect of horizontal scroll */ if (last != NULL) { tmp = CLine; CLine = last; register_change(0); CLine = tmp; if (last != CLine) HScroll = 0; last = NULL; } col--; /* use 0 origin */ if (2*whs > sw) whs = sw/2; wc_min = col - sw + 1; if (wc_min < 0) wc_min = 0; wc_max = col - 1; if (wc < wc_min) wc = wc_min + whs; if (wc > wc_max) wc = wc_max - whs; if (col < sw) { if ((CBuf->modes & WRAP_MODE) || (col <= sw - whs)) wc = 0; } if (Wants_HScroll < 0) { /* Scroll whole window */ if (wc + 1 != JWindow->hscroll_column) { JWindow->hscroll_column = wc + 1; touch_window(); } HScroll = 0; } else { /* Scroll just this line -- do not change hscroll_column */ register_change(0); last = HScroll_Line = CLine; HScroll = wc - (JWindow->hscroll_column-1); } } static char Top_Screen_Line_Buffer[132] = "If you see this, you have an installation problem."; void define_top_screen_line (char *neew) { SLang_push_string (Top_Screen_Line_Buffer); strncpy (Top_Screen_Line_Buffer, neew, sizeof (Top_Screen_Line_Buffer) - 1); Top_Screen_Line_Buffer[sizeof(Top_Screen_Line_Buffer) - 1] = 0; if (JScreen != NULL) JScreen[0].is_modified = 1; } static void update_top_screen_line (void) { #if JED_HAS_MENUS if (Jed_Menus_Active || (Top_Window_SY > 0)) { jed_redraw_menus (); return; } #else if (Top_Window_SY == 0) return; SLsmg_gotorc (0,0); SLsmg_set_color (JMENU_COLOR); SLsmg_write_string (Top_Screen_Line_Buffer); SLsmg_erase_eol (); JScreen[0].is_modified = 0; #endif } /* if flag is non-zero, do not touch the message/error buffers */ /* This routine is a mess and it, do_dialog, and the Mini_Ghost flag needs * to be totally redesigned. */ void update(Line *line, int force, int flag, int run_update_hook) { int pc_flag = 1; int col; static unsigned long last_time; Line *hscroll_line_save; if (0 == Jed_Display_Initialized) return; #if JED_HAS_SUBPROCESSES if (Child_Status_Changed_Flag) { jed_get_child_status (); force = 1; } #endif if (Batch) return; if (!force && !SLang_get_error () && !SLKeyBoard_Quit && (!*Error_Buffer)) { if (screen_input_pending (0)) { JWindow->trashed = 1; return; } } if (last_time + 30 < Status_This_Time) { if (last_time == 0) last_time = Status_This_Time; else { last_time = Status_This_Time; if (SLang_run_hooks ("update_timer_hook", 0)) flag = 0; } } if (run_update_hook && (CBuf->buffer_hooks != NULL) && (CBuf->buffer_hooks->update_hook != NULL) && (SLang_get_error () == 0)) { Suspend_Screen_Update = 1; SLexecute_function (CBuf->buffer_hooks->update_hook); if (SLang_get_error ()) CBuf->buffer_hooks->update_hook = NULL; } if (Suspend_Screen_Update != 0) { Suspend_Screen_Update = 0; touch_screen (); } if (X_Update_Open_Hook != NULL) (*X_Update_Open_Hook) (); #ifdef FIX_CHAR_WIDTH FIX_CHAR_WIDTH; #endif col = calculate_column (); HScroll_Line = NULL; if (Wants_HScroll) set_hscroll(col); else HScroll = 0; hscroll_line_save = HScroll_Line; if (SLang_get_error ()) flag = 0; /* update hook invalidates flag */ if (SLang_get_error () && !(*Error_Buffer || SLKeyBoard_Quit)) { #if SLANG_VERSION < 20000 SLang_doerror (""); #else SLang_verror (0, "%s", SLerr_strerror (0)); #endif } if (!flag && (*Error_Buffer || SLKeyBoard_Quit)) { do_dialog(Error_Buffer); #if 0 SLKeyBoard_Quit = 0; SLang_restart(0); SLang_set_error (0); #endif Mini_Ghost = 1; (void) update_1(line, 1); update_minibuffer(); } else if ((flag == 0) && *Message_Buffer) { if (!update_1(line, force)) goto done; do_dialog(Message_Buffer); Mini_Ghost = 1; update_minibuffer(); } else { pc_flag = JWindow->trashed || (JWindow != JWindow->next) || Cursor_Motion; if (!flag) update_minibuffer(); if (!update_1(line, force)) goto done; } if (!flag) *Error_Buffer = *Message_Buffer = 0; #if JED_HAS_MENUS update_top_screen_line (); #else if ((Top_Window_SY > 0) && JScreen[0].is_modified) { update_top_screen_line (); } #endif done: HScroll_Line = hscroll_line_save; if (MiniBuf_Get_Response_String != NULL) { do_dialog (MiniBuf_Get_Response_String); Mini_Ghost = 1; } else if (Point_Cursor_Flag || pc_flag) point_cursor(col); if (X_Update_Close_Hook != NULL) (*X_Update_Close_Hook) (); SLsmg_refresh (); } /* search for the CLine in the SCreen and flag it as changed */ /* n = 0 means line was changed, n = 1 means it was destroyed */ void register_change(int n) { Window_Type *w; register Screen_Type *s, *smax; register Line *cl = CLine; if (JScreen == NULL) return; JWindow->trashed = 1; if (Suspend_Screen_Update) return; if (No_Screen_Update) { No_Screen_Update = 0; if (((n == CINSERT) || (n == CDELETE)) && (JWindow->next == JWindow)) { /* Since no screen update, we are probably safe to do: */ /* JScreen[Screen_Row - 1].flags = 1; */ return; } w = JWindow->next; /* skip this window */ } else w = JWindow; do { s = &JScreen[w->sy]; smax = s + w->rows; while (s < smax) { if (s->line == cl) { s->is_modified = 1; if ((n == NLDELETE) || (n == LDELETE)) s->line = NULL; w->trashed = 1; } s++; } w = w->next; } while(w != JWindow); } int jed_get_screen_size (int *r, int *c) { if (tt_get_screen_size == NULL) { *r = 24; *c = 80; return 0; } (void) (*tt_get_screen_size) (r, c); if (*r <= 0) *r = 24; if (*c <= 0) *c = 80; if (*r > 1024) *r = 24; if (*c > 1024) *c = 80; /* Let's not be ridiculous */ if (*r <= 5) *r = 5; if (*c <= 5) *c = 5; return 0; } static void dealloc_display (void) { if (JScreen != NULL) { SLfree ((char *) JScreen); JScreen = NULL; } } void jed_reset_display (void) { if (Jed_Display_Initialized == 0) return; if (Batch) return; Jed_Display_Initialized = 0; #if defined(VMS) || defined(REAL_UNIX_SYSTEM) (void) jed_va_run_hooks ("_jed_reset_display_hooks", JED_HOOKS_RUN_ALL, 0); #endif dealloc_display (); SLsmg_reset_smg (); } static void alloc_display (void) { int r, c, i; jed_get_screen_size (&r, &c); jed_update_window_sizes (r, c); if (NULL == (JScreen = (Screen_Type *) jed_malloc0 (sizeof (Screen_Type) * r))) exit_error ("Out of memory", 0); for (i = 0; i < r; i++) JScreen[i].is_modified = 1; Jed_Num_Screen_Cols = c; Jed_Num_Screen_Rows = r; } void jed_init_display (void) { if (Batch) return; jed_reset_display (); alloc_display (); if (-1 == SLsmg_init_smg ()) exit_error ("init_display: error initializing display", 0); #if defined(VMS) || defined(REAL_UNIX_SYSTEM) (void) jed_va_run_hooks ("_jed_init_display_hooks", JED_HOOKS_RUN_ALL, 0); #endif Jed_Display_Initialized = 1; } void jed_resize_display (void) { Jed_Resize_Pending = 0; if (Jed_Display_Initialized == 0) return; dealloc_display (); alloc_display (); SLsmg_reinit_smg (); /* Add support for a resize-hook here */ /* (void) jed_va_run_hooks ("_jed_resize_display_hooks", JED_HOOKS_RUN_ALL, 0); */ jed_redraw_screen (0); } void jed_redraw_screen (int force) { int row, center; Window_Type *w; Line *l; if (Batch) return; SLsmg_set_color (0); SLsmg_cls (); if (JScreen == NULL) return; for (row = 0; row < Jed_Num_Screen_Rows; row++) { /* JScreen[row].line = NULL; */ JScreen[row].is_modified = 1; } if (NULL == (w = JWindow)) return; center = JWindow->trashed; do { w->trashed = 1; w = w->next; } while(w != JWindow); if (center) { for (row = 0; row < JWindow->rows; row++) { JScreen[row + JWindow->sy].line = NULL; } l = NULL; } else l = JWindow->beg.line; update(l, force, 0, 1); } void recenter(int *np) { Line *l = CLine; int i, n = *np; if (Batch) return; JWindow->trashed = 1; if (n == 0) { n = JWindow->rows / 2; i = 0; while (i < n) { if (l->prev == NULL) break; l = l->prev; #if JED_HAS_LINE_ATTRIBUTES if (l->flags & JED_LINE_HIDDEN) continue; #endif i++; } JWindow->beg.line = l; JWindow->beg.n -= i; JWindow->beg.point = 0; jed_redraw_screen (0); return; } if (CBuf != JWindow->buffer) return; if ((n <= 0) || (n > JWindow->rows)) n = JWindow->rows / 2; while (n > 1) { l = l->prev; if (l == NULL) { l = CBuf->beg; break; } #if JED_HAS_LINE_ATTRIBUTES if (l->flags & JED_LINE_HIDDEN) continue; #endif n--; } /* update(l, 1, 0, 1); */ JScreen [JWindow->sy].line = l; JScreen [JWindow->sy].is_modified = 1; } int window_line (void) { Line *cline; Line *top; int n; if (CBuf != JWindow->buffer) return 0; top = find_top (); #if JED_HAS_LINE_ATTRIBUTES cline = jed_find_non_hidden_line (CLine); #else cline = CLine; #endif n = 1; while ((top != NULL) && (top != cline)) { top = top->next; #if JED_HAS_LINE_ATTRIBUTES while ((top != NULL) && (top->flags & JED_LINE_HIDDEN)) top = top->next; #endif n++; } return n; } void touch_window (void) { Screen_Type *s, *smax; if (Suspend_Screen_Update) return; if (JScreen == NULL) return; s = JScreen + (JWindow->sy); if (JWindow->rows > Jed_Num_Screen_Rows) smax = s + Jed_Num_Screen_Rows; else smax = s + JWindow->rows; while (s < smax) { s->is_modified = 1; s++; } JWindow->trashed = 1; } void touch_screen (void) { Window_Type *w; No_Screen_Update = 0; if (Suspend_Screen_Update) return; if (JScreen == NULL) return; w = JWindow; do { touch_window(); JWindow = JWindow->next; } while(w != JWindow); if (Top_Window_SY > 0) JScreen[0].is_modified = 1; } void exit_error(char *str, int severity) { static int already_here; if (already_here) return; SLang_set_error (0); SLKeyBoard_Quit = 0; auto_save_all(); #if JED_HAS_EMACS_LOCKING (void) jed_unlock_buffer_files (); #endif jed_reset_display(); reset_tty(); fprintf (stderr, "***Fatal Error: %s\n\n", str); jed_show_version (stderr); if (*Error_Buffer) fprintf (stderr, "%s\n", Error_Buffer); if (CBuf != NULL) { if (Batch == 0) { fprintf(stderr, "CBuf: %p, CLine: %p, Point %d\n", (void *)CBuf, (void *) CLine, Point); if (CLine != NULL) fprintf(stderr, "CLine: data: %p, len = %d, next: %p, prev %p\n", (void *) CLine->data, CLine->len, (void *)CLine->next, (void *)CLine->prev); fprintf(stderr, "Max_LineNum: %d, LineNum: %d\n", Max_LineNum, LineNum); if (JWindow != NULL) fprintf(stderr, "JWindow: %p, top: %d, rows: %d, buffer: %p\n", (void *)JWindow, JWindow->sy, JWindow->rows, (void *)JWindow->buffer); } } if (severity) { #ifdef __unix__ fprintf(stderr, "Dumping Core."); abort (); #endif } exit (1); } void touch_window_hard(Window_Type *w, int all) { Window_Type *wsave = w; if (JScreen == NULL) return; do { Screen_Type *s, *smax; s = JScreen + (w->sy); if (w->rows > Jed_Num_Screen_Rows) smax = s + Jed_Num_Screen_Rows; else smax = s + w->rows; while (s < smax) { s->is_modified = 1; s->line = NULL; s++; } w->trashed = 1; w = w->next; } while (all && (w != wsave)); } #if 1 int jed_find_line_on_screen (Line *l, int min_line) { int i, imax; if (JScreen == NULL) return -1; imax = Jed_Num_Screen_Rows - 2; for (i = min_line; i < imax; i++) { if (JScreen[i].line == l) return i; } return -1; } #endif void update_cmd (int *force) { if (Batch) return; JWindow->trashed = 1; update((Line *) NULL, *force, 0, 1); } void update_sans_update_hook_cmd (int *force) { if (Batch) return; JWindow->trashed = 1; update((Line *) NULL, *force, 0, 0); } jed-0.99-19/src/file.c0000644002657400265740000011214411311317447013347 0ustar davisdavis/* -*- mode: C; mode: fold; -*- */ /* Copyright (c) 1992, 1998, 2000, 2002, 2003, 2004, 2005, 2006 John E. Davis * This file is part of JED editor library source. * * You may distribute this file under the terms the GNU General Public * License. See the file COPYING for more information. */ #include "config.h" #include "jed-feat.h" /*{{{ system include files */ #ifdef __WIN32__ /* This needs to go first before stdio is included. */ # include # include # include # include #endif #ifdef __IBMC__ #if SLANG_VERSION < 10308 # define sleep(x) sys_pause(1000 * (x)) #else /* sleep added to slang 10308 */ extern unsigned int sleep (unsigned int); #endif #endif #include #include #include "jdmacros.h" #include #include #ifdef HAVE_STDLIB_H # include #endif #ifdef HAVE_UNISTD_H # include #endif #ifdef __unix__ # include # include # include #endif #ifdef HAVE_UTIME # include #endif #ifdef HAVE_FCNTL_H # include #endif #ifdef HAVE_SYS_FCNTL_H # include #endif #ifdef __os2__ #include #include #include #include typedef struct HOLDFEA *PHOLDFEA; PHOLDFEA QueryEAs (char *name); int WriteEAs (char *name, PHOLDFEA pHoldFEA); #endif #ifdef __MSDOS__ #include #include #include #endif #if defined(__DECC) && defined(VMS) # include # include #endif #include #include #ifdef VMS # include # include #endif /* Was anything missed? */ #ifndef O_RDONLY # ifdef VMS # include # else # include # endif #endif #ifndef O_BINARY # define O_BINARY 0 #endif /*}}}*/ /*{{{ local inclue files */ #include "buffer.h" #include "file.h" #include "misc.h" #include "sysdep.h" #include "paste.h" #include "ins.h" #include "ledit.h" #include "userinfo.h" #include "hooks.h" #include "screen.h" #include "sig.h" /*}}}*/ #if defined (SIXTEEN_BIT_SYSTEM) #define MAX_LINE_LEN 1024 #else #define MAX_LINE_LEN 64 * 1024 #endif int Jed_Backup_By_Copying = 0; #ifdef VMS /*{{{ vms_stupid_open */ static int vms_max_rec_size; static int VMS_write_rfm_fixed; int vms_stupid_open(char *file) { struct stat s; char rat_buf[80], rfm_buf[80], mrs_buf[40], *rfm = "var"; unsigned short mode = 0, c; int ret; VMS_write_rfm_fixed = 0; strcpy(rfm_buf, "rfm="); if (0 == stat(file, &s)) { strcpy(rat_buf, "rat"); c = s.st_fab_rat; if (c & FAB$M_FTN) strcat(rat_buf, ",ftn"); if (c & FAB$M_CR) strcat(rat_buf, ",cr"); if (c & FAB$M_PRN) strcat(rat_buf, ",prn"); if (c & FAB$M_BLK) strcat(rat_buf, ",blk"); if (rat_buf[3] != 0) rat_buf[3] = '='; else *rat_buf = 0; c = s.st_fab_rfm; switch(c) { case FAB$C_UDF: rfm = "udf"; break; case FAB$C_FIX: rfm = "fix"; if (s.st_fab_rat & (FAB$M_CR | FAB$M_CR)) VMS_write_rfm_fixed = 1; break; case FAB$C_VAR: rfm = "var"; break; case FAB$C_VFC: rfm = "vfc"; break; case FAB$C_STM: rfm = "stm"; break; case FAB$C_STMLF: rfm = "stmlf"; break; case FAB$C_STMCR: rfm = "stmcr"; break; } mode = s.st_mode & 0777; } else strcpy (rat_buf, "rat=cr"); strcat(rfm_buf, rfm); if (vms_max_rec_size <= 0) vms_max_rec_size = 255; sprintf(mrs_buf, "mrs=%d", vms_max_rec_size); if (*rfm == 's') /* stream */ { ret = creat(file, mode, rfm_buf); } else { if (*rat_buf) ret = creat(file, mode, rfm_buf, mrs_buf, rat_buf); else ret = creat(file, mode, rfm_buf, mrs_buf); } if (ret >= 0) chmod(file, mode); return ret; } /*}}}*/ #endif int Require_Final_Newline = 0; #define _JED_OPEN_READ 0 #define _JED_OPEN_WRITE 1 #define _JED_OPEN_APPEND 2 #define _JED_OPEN_CREATE_EXCL 3 /* 0 = read, 1 = write , 2 = append... */ static int sys_open (char *file, int acces) /*{{{*/ { int flags; unsigned int perms; #ifdef VMS char *p, neew[JED_MAX_PATH_LEN]; #endif flags = file_status (file); if ((flags < 0) || (flags > 1)) return -1; /* directory? */ #ifdef VMS /* on VMS I cheat since I do not want to deal with RMS at this point */ VMS_write_rfm_fixed = 0; safe_strcpy(neew, file, sizeof (neew)); p = neew; while (*p) if (*p == ';') *p = 0; else p++; switch (acces) { case _JED_OPEN_READ: return open(file, O_RDONLY, "ctx=rec","mbf=8","mbc=32","rop=RAH","shr=upi,get,put"); case _JED_OPEN_WRITE: case _JED_OPEN_CREATE_EXCL: /* FIXME */ return vms_stupid_open (neew); case _JED_OPEN_APPEND: return open (file, O_WRONLY | O_APPEND | O_CREAT | O_BINARY); default: return -1; } #else # ifdef IBMPC_SYSTEM perms = S_IREAD | S_IWRITE; # else perms = 0666; # endif switch (acces) { case _JED_OPEN_READ: flags = O_RDONLY; break; case _JED_OPEN_WRITE: flags = O_WRONLY | O_CREAT | O_TRUNC; break; case _JED_OPEN_APPEND: flags = O_WRONLY | O_CREAT | O_APPEND; break; case _JED_OPEN_CREATE_EXCL: flags = O_WRONLY | O_CREAT | O_EXCL; #ifndef IBMPC_SYSTEM perms = 0600; #endif break; default: return -1; } flags |= O_BINARY; return open(file, flags, perms); #endif /* VMS */ } /*}}}*/ char *file_type (SLFUTURE_CONST char *file) /*{{{*/ { char *p, *psave; if ((file == NULL) || (*file == 0)) return NULL; file = extract_file(file); p = (char *) file; while (*p != 0) p++; psave = p; while((p != file) && (*p != '.')) p--; if (*p == '.') p++; if (p == file) return psave; return p; } /*}}}*/ void jed_set_buffer_ctime (Buffer *b) { char *file; if ((b->file == NULL) || (b->file[0] == 0)) { b->c_time = 0; return; } if (NULL == (file = SLang_concat_slstrings (b->dir, b->file))) { b->c_time = 0; return; } b->c_time = sys_file_mod_time (file); SLang_free_slstring (file); } #if (defined(__MSDOS__) || defined(__WIN32__)) && !defined(W_OK) # define W_OK 2 # define F_OK 0 #endif #ifdef __GO32__ # define access i386_access #endif int jed_file_is_readonly (char *file, int respect_perms) { int ro = 0; struct stat st; if (respect_perms) { /* respect the file's permissions. If any write permission bit is * is set, then consider it a writable candidate. */ #if defined(S_IWGRP) && defined(S_IWOTH) if (0 == stat (file, &st)) ro = (0 == (st.st_mode & (S_IWUSR|S_IWGRP|S_IWOTH))); #endif } #ifdef W_OK if (ro == 0) { if (0 == access(file, F_OK)) { if (-1 == access(file, W_OK)) ro = 1; } else { /* file does not exist. Can we write to the directory? */ char *dir; if (-1 == jed_dirfile_to_dir_file (file, &dir, NULL)) return -1; # if defined(IBMPC_SYSTEM) /* knock of slash since some primitive systems cannot handle the * final slash in a path name. */ { unsigned int len = strlen (dir); if (len > 3) /* allow C:/, but not C:/xx/ */ dir[len-1] = 0; } # endif if ((0 == access (dir, F_OK)) # ifdef VMS && (-1 == access (dir, X_OK)) #else && (-1 == access (dir, W_OK)) #endif ) ro = 1; SLfree (dir); } } #endif /* W_OK */ return ro; } int jed_buffer_file_is_readonly (Buffer *b) { char *file; int ro; if ((b->file == NULL) || (b->file[0] == 0)) return 0; file = jed_dir_file_merge (b->dir, b->file); if (file == NULL) return -1; ro = jed_file_is_readonly (file, 1); SLfree (file); return ro; } void set_file_modes (void) /*{{{*/ { char *type; if (CBuf == NULL) return; jed_set_buffer_ctime (CBuf); if (1 == jed_buffer_file_is_readonly (CBuf)) CBuf->flags |= READ_ONLY; type = NULL; if ((CBuf->file != NULL) && (CBuf->file[0] != 0)) { CBuf->flags |= AUTO_SAVE_BUFFER; CBuf->hits = 0; if (type == NULL) type = file_type (CBuf->file); } CBuf->modes = NO_MODE; #if JED_HAS_LINE_ATTRIBUTES CBuf->min_unparsed_line_num = 1; CBuf->max_unparsed_line_num = Max_LineNum + CBuf->nup; #endif if (type != NULL) { if (1 != jed_va_run_hooks ("_jed_set_mode_hooks", JED_HOOKS_RUN_UNTIL_NON_0, 1, type)) (void) SLang_run_hooks("mode_hook", 1, type); } } /*}}}*/ /*{{{ reading/inserting files */ int read_file(char *file) /*{{{*/ { int n, status; status = jed_va_run_hooks ("_jed_read_file_hooks", JED_HOOKS_RUN_UNTIL_NON_0, 1, file); if (status < 0) return -1; if (status > 0) /* FIXME!! Is this true? What if no lines have been read. */ n = Max_LineNum; else { int fp; if ((fp = sys_open(file, _JED_OPEN_READ)) < 0) { status = file_status(file); if (!status) return(-1); /* file does not exist */ return(-2); /* exists but not readable */ } n = read_file_pointer(fp); close(fp); } eob(); if ((Point < CLine->len) && ('\n' == *(CLine->data + Point))) make_line(2); VFile_Mode = VFILE_TEXT; return n; } /*}}}*/ int insert_file_pointer(VFILE *vp) /*{{{*/ { int n = 0; unsigned int num; unsigned char *vbuf; Suspend_Screen_Update = 1; while(NULL != (vbuf = (unsigned char *) vgets(vp, &num))) { n++; if (SLang_get_error ()) break; if (-1 == jed_quick_insert (vbuf, (int) num)) return -1; } return(n); } /*}}}*/ int insert_file(char *file) /*{{{*/ { VFILE *vp; int n; unsigned int un; un = Max_LineNum; if (1 == jed_va_run_hooks ("_jed_insert_file_hooks", JED_HOOKS_RUN_UNTIL_NON_0, 1, file)) return (int) (Max_LineNum - un); if (NULL == (vp = vopen(file, 0, VFile_Mode))) return -1; n = insert_file_pointer(vp); vclose(vp); return(n); } /*}}}*/ /*}}}*/ /*{{{ writing to files */ #ifdef __unix__ # define BUFSIZE 0x10000 #else #ifdef VMS # define BUFSIZE 0x3FFF #else # define BUFSIZE 512 #endif #endif static int Output_Buffer_Size = BUFSIZE; static char Output_Buffer[BUFSIZE]; static char *Output_Bufferp; static char *Output_Bufferp_max; /* definitely perform the write. Return number of chars written */ static int jed_write1(int fd, char *b, unsigned int n) /*{{{*/ { #if !defined(IBMPC_USE_ASM) int len; unsigned int total = 0; #ifdef VMS register char *bmax; #endif while (total < n) { int dlen; len = n - total; #ifdef VMS if (VMS_write_rfm_fixed) { } /* VMS wants to terminate a record with a cr so adjust for this * unfortunate fact. The len - 1 stuff is so *bmax does not peek * beyond its boundary. */ bmax = b + (len - 1); while ((bmax > b) && (*bmax != '\n')) bmax--; if (bmax == b) bmax = b + (len - 1); /* cannot be helped */ len = (int) (bmax - b) + 1; #endif while (-1 == (dlen = write (fd, b, len))) { #ifdef EINTR if (errno == EINTR) { if (0 == jed_handle_interrupt ()) continue; } #endif #ifdef EAGAIN if (errno == EAGAIN) { if (0 == jed_handle_interrupt ()) { jed_sleep (1); continue; } } #endif #ifdef ENOSPC if (errno == ENOSPC) { msg_error ("Write Failed: Disk Full."); return total; } #endif jed_verror ("Write Failed: (%d bytes attemped, errno = %d)", len, errno); return total; } total += (unsigned int) dlen; b += dlen; } return total; #else int num = -1; asm mov ah, 40h asm mov bx, fd asm mov cx, n asm push ds asm lds dx, dword ptr b asm int 21h asm pop ds asm jc L1 asm mov num, ax /* number of bytes written */ L1: return(num); #endif } /*}}}*/ /* RMS wants to start a NEW record after a write so just forget it! */ /* maybe do write-- return number of chars possibly written */ static int jed_write(int fd, char *b, unsigned int n) /*{{{*/ { int num, max, nl_flag = 0; unsigned int nsave = n; int cr_flag = CBuf->flags & ADD_CR_ON_WRITE_FLAG; #ifdef MAP_CR_TO_NL_FLAG if (CBuf->flags & MAP_CR_TO_NL_FLAG) { char *bmax = b + n; char *p, *pmax, ch; p = Output_Bufferp; pmax = Output_Bufferp_max; while (b < bmax) { ch = *b++; if ((ch == '\r') || (ch == '\n')) { if (cr_flag) { *p++ = ch; if (p == pmax) { num = (int) (Output_Bufferp_max - Output_Bufferp); if (num != jed_write1 (fd, Output_Bufferp, num)) return -1; Output_Bufferp = Output_Buffer; p = Output_Bufferp; } } *p++ = '\n'; } else *p++ = ch; if (p == pmax) { num = (int) (Output_Bufferp_max - Output_Bufferp); if (num != jed_write1 (fd, Output_Buffer, num)) return -1; Output_Bufferp = Output_Buffer; p = Output_Bufferp; } } Output_Bufferp = p; return nsave; } #endif /* amount of space left in buffer */ /* copy whats in b to the output buffer */ while (n > 0) { num = (int) (Output_Bufferp_max - Output_Bufferp); if ((int) n > num) { #ifdef VMS max = (int) (Output_Bufferp - Output_Buffer); if (max) { if (max != jed_write1(fd, Output_Buffer, max)) return(-1); Output_Bufferp = Output_Buffer; continue; } #endif max = num; SLMEMCPY(Output_Bufferp, b, max); Output_Bufferp += max; } else if (cr_flag && (*(b + (n - 1)) == '\n') && (VFile_Mode == VFILE_TEXT)) { max = n - 1; SLMEMCPY(Output_Bufferp, b, max); Output_Bufferp += max; *Output_Bufferp++ = '\r'; max++; /* can only write the \r */ if (n == (unsigned int) num) nl_flag = 1; else *Output_Bufferp++ = '\n'; } else { max = n; SLMEMCPY(Output_Bufferp, b, max); Output_Bufferp += max; } if (Output_Bufferp == Output_Bufferp_max) { Output_Bufferp = Output_Buffer; if (Output_Buffer_Size != jed_write1(fd, Output_Buffer, Output_Buffer_Size)) return(-1); if (nl_flag) { nl_flag = 0; *Output_Bufferp++ = '\n'; } } b += max; n -= max; } return(nsave); } /*}}}*/ /* returns -1 on failure */ int write_region_to_fp (int fp) /*{{{*/ { register int pnt, len; register Line *first, *last; int last_pnt, n = 0; char *err = "Write Failed!"; #ifndef VMS char nl = '\n'; #endif Output_Bufferp = Output_Buffer; Output_Bufferp_max = Output_Buffer + BUFSIZE; Output_Buffer_Size = BUFSIZE; #ifdef VMS if (VMS_write_rfm_fixed && (vms_max_rec_size <= BUFSIZE)) { Output_Buffer_Size = vms_max_rec_size; } else VMS_write_rfm_fixed = 0; #endif if (!check_region(&Number_One)) return(-1); last = CLine; last_pnt = Point; jed_pop_mark(1); first = CLine; pnt = Point; /* first should never be null without hitting last first. If this ever happens, check_region failed. */ while (first != last) { len = first->len - pnt; if (len != jed_write(fp, (char *) (first->data + pnt), len)) { msg_error(err); } /* This goes here inside the loop because it is possible for external events to set error_buffer */ pnt = 0; if (SLang_get_error ()) break; first = first->next; n++; } if (!SLang_get_error () && (last_pnt != 0)) { len = last_pnt - pnt; if (len != jed_write(fp, (char *) (last->data + pnt), len)) { msg_error(err); } n++; } #ifndef VMS if ((Require_Final_Newline) && (CBuf->end == last)) { eob(); if (Point) jed_write(fp, &nl, 1); } #endif /* Now flush output buffer if necessary */ len = (int) (Output_Bufferp - Output_Buffer); if (!SLang_get_error () && len) if (len != jed_write1(fp, Output_Buffer, len)) { msg_error(err); } Output_Bufferp = Output_Buffer; pop_spot(); VFile_Mode = VFILE_TEXT; if (SLang_get_error ()) return(-1); return(n); } /*}}}*/ static int jed_close (int fp) /*{{{*/ { while (-1 == close(fp)) { #ifdef EINTR #ifndef IBMPC_SYSTEM if (errno == EINTR) { if (-1 == jed_handle_interrupt ()) { errno = 0; jed_sleep (1); continue; } } #endif #endif msg_error ("Error closing file. File system may be full."); return -1; } return 0; } /*}}}*/ static int write_region_internal (char *file, int omode) /*{{{*/ { int fd; int n; unsigned int num_lines; #if JED_HAS_EMACS_LOCKING if (-1 == jed_lock_file (file)) return -1; #endif if (!check_region(&Number_Zero)) return -1; num_lines = jed_count_lines_in_region (); switch (omode) { case _JED_OPEN_WRITE: case _JED_OPEN_CREATE_EXCL: n = jed_va_run_hooks ("_jed_write_region_hooks", JED_HOOKS_RUN_UNTIL_NON_0, 1, file); break; default: n = jed_va_run_hooks ("_jed_append_region_hooks", JED_HOOKS_RUN_UNTIL_NON_0, 1, file); break; } if (n > 0) n = num_lines; else if (n < 0) n = -1; else if (n == 0) { if ((fd = sys_open(file, omode)) < 0) { jed_verror ("Unable to open %s for writing.", file); return -1; } n = write_region_to_fp (fd); if (n == -1) (void) jed_close (fd); else if (-1 == jed_close (fd)) n = -1; } #if JED_HAS_EMACS_LOCKING if (n != -1) jed_unlock_file (file); #endif return n; } /*}}}*/ int write_region (char *file) { return write_region_internal (file, _JED_OPEN_WRITE); } /* returns -1 on failure and number of lines on success */ static int write_file_internal (char *file, int omode) /*{{{*/ { Mark *m; int n; int fnl; #ifdef VMS register Line *l; register int len = 0, max = 0; #endif push_spot(); #if JED_HAS_SAVE_NARROW jed_push_narrow (); jed_widen_whole_buffer (CBuf); #endif #ifdef VMS l = CBuf->beg; while (l != NULL) { len = l->len; if (len > max) max = len; l = l->next; } vms_max_rec_size = max; #endif bob(); jed_push_mark(); m = CBuf->marks; eob(); fnl = Require_Final_Newline; if (CBuf->flags & BINARY_FILE) { VFile_Mode = VFILE_BINARY; Require_Final_Newline = 0; #ifdef VMS vms_max_rec_size = 512; #endif } n = write_region_internal (file, omode); Require_Final_Newline = fnl; VFile_Mode = VFILE_TEXT; if (m == CBuf->marks) jed_pop_mark(0); #if JED_HAS_SAVE_NARROW jed_pop_narrow (); #endif pop_spot(); return(n); } /*}}}*/ int append_to_file(char *file) /*{{{*/ { int status; status = write_region_internal (file, _JED_OPEN_APPEND); check_buffers(); return status; } /*}}}*/ /*}}}*/ static int make_autosave_filename(char *save, unsigned int buflen, char *dir, char *file) /*{{{*/ { char *s; if (*file == 0) return(0); if (1 == SLang_run_hooks ("make_autosave_filename", 2, dir, file)) { if (SLang_pop_slstring(&s)) return(0); strncpy(save, s, buflen); save[buflen - 1] = 0; SLang_free_slstring (s); } else { #if defined(IBMPC_SYSTEM) SLsnprintf (save, buflen, "%s#%s", dir, file); #else # ifdef VMS SLsnprintf (save, buflen, "%s_$%s;1", dir, file); # else SLsnprintf (save, buflen, "%s#%s#", dir, file); # endif #endif } return 1; } /*}}}*/ #ifndef VMS int jed_copy_file (char *from, char *to) /*{{{*/ { mode_t mode; uid_t uid; gid_t gid; FILE *fp0, *fp1; char buf[0x7FFF]; unsigned int readlen; int ret; struct stat st; #ifdef HAVE_UTIME struct utimbuf ut; #endif if (1 != sys_chmod (from, 0, &mode, &uid, &gid)) return -1; /* from does not exist as regular file */ /* Need file modification times so that they can be preserved. */ if (-1 == stat (from, &st)) return -1; fp0 = fopen (from, "rb"); if (fp0 == NULL) return -1; #ifdef REAL_UNIX_SYSTEM (void) sys_delete_file (to); /* Try to avoid a race condition (code derived from Colin Phipps . */ ret = sys_open (to, _JED_OPEN_CREATE_EXCL); if (ret == -1) { (void) fclose (fp0); return -1; } if (NULL == (fp1 = fdopen (ret, "wb"))) { (void) close (ret); (void) sys_delete_file (to); /* Drop */ } #else fp1 = fopen (to, "wb"); #endif if (fp1 == NULL) { (void) fclose (fp0); return -1; } (void) chmod (to, 0600); ret = 0; do { readlen = fread (buf, 1, sizeof(buf), fp0); if (readlen) { if (readlen != fwrite (buf, 1, readlen, fp1)) { ret = -1; break; } } } while (readlen == sizeof (buf)); fclose (fp0); if (EOF == fclose (fp1)) { ret = -1; } (void) sys_chmod (to, 1, &mode, &uid, &gid); #ifdef HAVE_UTIME /* Set file modification times */ ut.actime = st.st_atime; ut.modtime = st.st_mtime; (void) utime (to, &ut); #endif return ret; } /*}}}*/ #endif /* NOT VMS */ #ifndef VMS static int perform_backup (char *from, char *to, int try_force_rename) /*{{{*/ { int ret = -1; int use_copy = Jed_Backup_By_Copying; #ifdef REAL_UNIX_SYSTEM /* If the file has hardlinks, then backup by copying. */ struct stat st; if (0 == stat (from, &st)) { if (st.st_nlink > 1) use_copy = 1; } #endif if (try_force_rename || (use_copy == 0)) { (void) unlink(to); #ifdef __WIN32__ /* Rename is broken on win32 */ ret = jed_win32_rename (from, to); #else ret = rename (from, to); #endif } if (ret == -1) ret = jed_copy_file (from, to); return ret; } /*}}}*/ #endif unsigned long sys_file_mod_time(char *file) /*{{{*/ { struct stat buf; if (stat(file, &buf) < 0) return 0; return (unsigned long) buf.st_mtime; } /*}}}*/ int write_file_with_backup(char *dirfile) /*{{{*/ { char autosave_file[JED_MAX_PATH_LEN]; int n; int do_mode; uid_t uid; gid_t gid; mode_t mode; #ifndef VMS char *old = NULL; int backup_went_ok; #endif #ifdef __os2__ PHOLDFEA EAs; #endif char *dir, *file; if (NULL == (dirfile = jed_expand_link (dirfile))) return -1; if (-1 == jed_dirfile_to_dir_file (dirfile, &dir, &file)) { SLfree (dirfile); return -1; } if (*file == 0) { SLfree (dir); SLfree (dir); SLfree (dirfile); return -1; } *autosave_file = 0; if (CBuf->flags & AUTO_SAVE_BUFFER) (void) make_autosave_filename(autosave_file, sizeof (autosave_file), dir, file); do_mode = sys_chmod(dirfile, 0, &mode, &uid, &gid); if ((do_mode != 0) && (do_mode != 1)) { SLfree (dir); SLfree (file); SLfree (dirfile); return -1; } /* IF do_mode == 0, then the file does not exist. This means that * there is nothing to backup. If do_mode == 1, the file is a regular * file which we do want to backup. */ #ifndef VMS # ifdef __os2__ EAs = QueryEAs (dirfile); # endif backup_went_ok = 0; if (do_mode && ((CBuf->flags & NO_BACKUP_FLAG) == 0) && (1 == SLang_run_hooks("make_backup_filename", 2, dir, file))) { if ((0 == SLang_pop_slstring(&old)) && (*old != 0)) { backup_went_ok = (0 == perform_backup (dirfile, old, 0)); } } #endif /* NOT VMS */ n = write_file_internal (dirfile, _JED_OPEN_WRITE); /* This is for NFS time problems. Even if the write failed, modify the * buffer's ctime because otherwise what is on the disk (a partial file) * will appear newer than the buffer. */ CBuf->c_time = sys_file_mod_time(dirfile); if (n != -1) { if (*autosave_file) (void) sys_delete_file (autosave_file); if (do_mode) /* must be an existing file, so preserve mode */ { #if defined(__MSDOS__) /* Want the archive bit set since this is a new version */ mode |= 1 << 5; #endif sys_chmod (dirfile, 1, &mode, &uid, &gid); #ifdef __os2__ WriteEAs (dirfile, EAs); #endif } /* Since we wrote the buffer to the file, it is not modified. */ if (CBuf == find_file_buffer (dirfile)) CBuf->flags &= ~FILE_MODIFIED; mark_buffer_modified (CBuf, 0, 1); } #ifndef VMS /* error -- put it back */ else if (backup_went_ok) perform_backup (old, dirfile, 1); if (old != NULL) SLang_free_slstring (old); #endif #ifdef REAL_UNIX_SYSTEM (void) jed_get_inode_info (dirfile, &CBuf->device, &CBuf->inode); #endif SLfree (dir); SLfree (file); SLfree (dirfile); return(n); } /*}}}*/ void auto_save_buffer(Buffer *b) /*{{{*/ { char tmp[JED_MAX_PATH_LEN]; Buffer *old_buf; unsigned int vfm = VFile_Mode; char *dir, *file; if (b == NULL) return; b->hits = 0; if ((0 == (b->flags & BUFFER_MODIFIED)) || (0 == (b->flags & (AUTO_SAVE_BUFFER | AUTO_SAVE_JUST_SAVE)))) return; if (b->canonical_dirfile == NULL) return; #if !JED_HAS_SAVE_NARROW if (b->narrow != NULL) return; #endif if (-1 == jed_dirfile_to_dir_file (b->canonical_dirfile, &dir, &file)) return; old_buf = CBuf; switch_to_buffer(b); if (b->flags & BINARY_FILE) VFile_Mode = VFILE_BINARY; else VFile_Mode = VFILE_TEXT; if (b->flags & AUTO_SAVE_BUFFER) { if (make_autosave_filename(tmp, sizeof (tmp), dir, file)) { flush_message("autosaving..."); (void) sys_delete_file(tmp); (void) write_file_internal (tmp, _JED_OPEN_CREATE_EXCL); message("autosaving...done"); } } else (void) write_file_with_backup(b->canonical_dirfile); SLfree (file); SLfree (dir); switch_to_buffer(old_buf); VFile_Mode = vfm; } /*}}}*/ void auto_save_all (void) /*{{{*/ { Buffer *b; if (NULL == (b = CBuf)) return; do { jed_widen_whole_buffer (b); if (CBuf == NULL) return; if (*b->file != 0) auto_save_buffer(b); if (CBuf == NULL) return; b = b->next; } while (b != CBuf); } /*}}}*/ #ifdef REAL_UNIX_SYSTEM /*{{{ symbolic link stuff */ static int is_link(char *f, char *f1) /*{{{*/ { struct stat s; unsigned int l; int is_dir = 0; char work[JED_MAX_PATH_LEN]; l = strlen(f); if (l == 0) return 0; l--; if ((l > 1) && (f[l] == '/')) { safe_strcpy(work, f, sizeof (work)); is_dir = 1; f = work; f[l] = 0; } if (( lstat(f, &s) == -1 ) /* || ((s.st_mode & S_IFMT) S_IFLNK)) */ || (((s.st_mode & S_IFMT) & S_IFLNK) == 0)) return(0); l = JED_MAX_PATH_LEN - 1; if (is_dir) { /* This way, it will be expanded properly upon return */ *f1++ = '.'; *f1++ = '.'; *f1++ = '/'; l -= 4; /* 1 for final slash */ } if (-1 == (int) (l = readlink(f, f1, l))) return 0; if (is_dir) f1[l++] = '/'; f1[l] = 0; /* If the link is an absolute pathname (starts with /) then the * ../ prefix should not go there. */ if (is_dir && (*f1 == '/')) { char ch; f = f1 - 3; while (0 != (ch = *f1++)) *f++ = ch; *f = 0; } return(1); } /*}}}*/ /*}}}*/ #endif #ifdef REAL_UNIX_SYSTEM static char *expand_link_2(char *f) /*{{{*/ { char work[JED_MAX_PATH_LEN], lnk[JED_MAX_PATH_LEN]; char *d = jed_standardize_filename (f); unsigned int max_num = 20; while ((d != NULL) && is_link(d, lnk)) { char *w, *w1, ch; if (*lnk == '/') /* absolute */ safe_strcpy (work, lnk, sizeof (work)); else { safe_strcpy (work, d, sizeof (work)); *(extract_file(work)) = 0; safe_strcat (work, lnk, sizeof (work)); } /* Collapse multiple // since jed_standardize_filename_static will interpret them * differently. */ w = w1 = work; while ((ch = *w1++) != 0) { *w++ = ch; if (ch == '/') while (*w1 == '/') w1++; } *w = 0; SLfree (d); max_num--; if (max_num == 0) { jed_verror ("possible circular-link detected"); return NULL; } d = jed_standardize_filename(work); } return (d); } /*}}}*/ #endif /* REAL_UNIX_SYSTEM */ #ifdef REAL_UNIX_SYSTEM static char *expand_link_1(char *f) /*{{{*/ { char *d = SLmake_string (f); if (d == NULL) return d; f = d; while (1) { char *new_d, *d1; if (*f == '/') f++; while (*f && (*f != '/')) f++; if (*f == 0) break; *f++ = 0; new_d = expand_link_2 (d); if (new_d == NULL) { SLfree (d); return NULL; } d1 = SLpath_dircat (new_d, f); f = d1 + strlen (new_d); SLfree (d); SLfree (new_d); if (d1 == NULL) return NULL; d = d1; } /* Now get filename component */ f = expand_link_2 (d); SLfree (d); return f; } #endif /* REAL_UNIX_SYSTEM */ /* Malloced string returned */ char *jed_expand_link (char *f) { #ifndef REAL_UNIX_SYSTEM return jed_standardize_filename (f); #else char *f1, *f2; unsigned int len; /* Look for, e.g., /usr/local//tmp/foo and extract /tmp/foo. * Do this before attempting to expand a link since links could * contain such constructs where they have a different meaning. * * Do this only if // occurs because ../ constructs should be preserved * if a subdir is a link to another. That is consider: * * /path/a/b/../c.txt * * jed_standardize_filename will convert this to * * /path/a/c.txt * * However, if b is a symlink to /tmp/a/b then we really want the file * /tmp/a/c.txt. */ #if 1 len = strlen (f); if (NULL == (f = SLmake_nstring (f, len))) return NULL; f2 = f + len; while (f2 > f) { if ((*f2-- == '/') && (*f2 == '/')) { f2++; break; } } #else if (NULL == (f = jed_standardize_filename (f))) return NULL; f2 = f; #endif if (NULL == (f1 = expand_link_1 (f2))) { SLfree (f); return NULL; } if (0 == strcmp (f, f1)) { SLfree (f); return f1; } SLfree (f); f = f1; /* Keep expanding the link until nothing changes */ while (1) { if (NULL == (f1 = expand_link_1 (f))) { SLfree (f); return NULL; } if (0 == strcmp (f, f1)) { SLfree (f1); return f; } SLfree (f); f = f1; } #endif } /*}}}*/ void visit_file (char *dir, char *file) /*{{{*/ { #ifdef VMS char *ff; file = SLmake_string (file); if (file == NULL) return; ff = file; while (*ff) { if (*ff == ';') { *ff = 0; break; } ff++; } #endif if ( #if JED_FILE_PRESERVE_CASE strcmp(file, CBuf->file) || strcmp(dir, CBuf->dir) #else jed_case_strcmp (file, CBuf->file) || jed_case_strcmp (dir, CBuf->dir) #endif ) { buffer_filename (CBuf, dir, file); } /* We have already taken care of this in write buffer function. */ /* CBuf->c_time = sys_time(); */ check_buffers(); } /*}}}*/ char *jed_dir_file_merge(SLFUTURE_CONST char *dir, SLFUTURE_CONST char *file) /*{{{*/ /* * returns result of merging dir with file. If file is empty, dir is * considered to be whole file. */ { char *dirfile; if ((file == NULL) || (*file == 0)) return jed_standardize_filename (dir); dirfile = SLmalloc (strlen (dir) + strlen (file) + 2); if (dirfile == NULL) return NULL; strcpy (dirfile, dir); fixup_dir (dirfile); strcat (dirfile, file); file = jed_standardize_filename (dirfile); SLfree (dirfile); return (char *) file; } /*}}}*/ int file_status(SLFUTURE_CONST char *file) /*{{{*/ /* * Returns a coded integer about file. If the file does not exist, 0 is * returned. Meaning: * * 2 file is a directory * 1 file exists * 0 file does not exist. * -1 no access. * -2 path invalid * -3 unknown error */ { mode_t mode = 0; uid_t uid; gid_t gid; return sys_chmod(file, 0, &mode, &uid, &gid); } /*}}}*/ /* Returns 0 if unchanged, 1 if changed, or -1 if it does not exist * and buffer is unmodified. * * What does it mean for the file to be changed on the disk if the buffer * corresponds to a symlink? That is, imagine editing foo.c which is a * symlink to bar.c. If bar.c changes, then foo.c shold be flagged as * changed. But, what if the link foo.c is changed such that it nolonger * points to bar.c? Now the buffer foo.c is nolonger connected with * bar.c. * * To handle both situations, do not use the dirfile field of the buffer * structure, since that corresponds to bar.c and not the link foo.c. * Since the file_changed_on_disk function uses stat and not lstat, if foo.c * is a link to bar.c, then bar.c will be checked. * * If the file has changed, be sure to update the buffers dirfile field and * update the inode info. If another buffer has the same inode info, then * the user has shot himself in the foot by making foo.c a hardlink. */ int file_changed_on_disk (Buffer *buf, char *dirfile) /*{{{*/ { unsigned long t; /* If we are saving this to a different file, then skip the test -- * unless dirfile is a link. */ if ((buf->canonical_dirfile != NULL) #if JED_FILE_PRESERVE_CASE && (0 != strcmp (buf->canonical_dirfile, dirfile)) #else && (0 != jed_case_strcmp (buf->canonical_dirfile, dirfile)) #endif ) { #ifdef REAL_UNIX_SYSTEM struct stat s; if ((-1 == lstat(dirfile, &s)) || (0 == ((s.st_mode & S_IFMT) & S_IFLNK))) return 0; #else return 0; #endif } #ifdef REAL_UNIX_SYSTEM /* * The file may still have been changed via a rename operation. * Update (or even invalidate) inode information since directories may have * been renamed, etc... */ { int device, inode; (void) jed_get_inode_info (dirfile, &device, &inode); if ((buf->device != -1) && (buf->inode != -1)) { if ((device != buf->device) || (inode != buf->inode)) buf->flags |= FILE_MODIFIED; } buf->device = device; buf->inode = inode; } #endif t = sys_file_mod_time(dirfile); if (t == 0) { /* File does not exist. If the buffer has not been modified since * the last save, then the file has changed on the disk. */ if (buf->c_time == 0) return 0; if (buf->flags & BUFFER_MODIFIED) return 0; return -1; /* does not exist */ } if (t > buf->c_time) { #if 0 /* Commented out because if the file did not exist when the buffer was created * then c_time will be 0. But if t>0, then this would indicate that an * external process created/modified the file. */ if (buf->c_time == 0) /* new buffer, writing to existing file */ return 0; #endif return 1; } return 0; } /*}}}*/ int file_time_cmp(char *file1, char *file2) /*{{{*/ { unsigned long t1, t2; t1 = sys_file_mod_time(file1); t2 = sys_file_mod_time(file2); /*These times are modification times from 1970. Hence, the bigger * number represents the more recent change. Let '>' denote * 'more recent than'. This function returns: * 1: file1 > file2 * 0: file 1 == file2 * -1: otherwise. * So: */ if (t1 == t2) return(0); if (t1 > t2) return(1); return(-1); } /*}}}*/ void auto_save(void) /*{{{*/ { auto_save_buffer(CBuf); } /*}}}*/ void check_buffer(Buffer *b) /*{{{*/ { b->flags &= ~FILE_MODIFIED; if (*b->file) { char *dirfile = jed_dir_file_merge (b->dir, b->file); if (file_changed_on_disk (b, dirfile)) b->flags |= FILE_MODIFIED; SLfree (dirfile); } } /*}}}*/ void check_buffers() /*{{{*/ { Buffer *b = CBuf; do { check_buffer(b); b = b->next; } while (b != CBuf); } /*}}}*/ void set_file_trans(int *mode) /*{{{*/ { if (*mode) VFile_Mode = VFILE_BINARY; else VFile_Mode = VFILE_TEXT; } /*}}}*/ int read_file_pointer(int fp) /*{{{*/ { int n = 0; unsigned int num; unsigned char *vbuf; VFILE *vp; if (SLang_get_error () || (vp = vstream(fp, MAX_LINE_LEN, VFile_Mode)) == NULL) return(-1); if (NULL != (vbuf = (unsigned char *) vgets(vp, &num))) { n++; #ifdef KEEP_SPACE_INFO if (CLine->space < num) #endif remake_line(CLine->len + num + 1); SLMEMCPY((char *) CLine->data, (char *) vbuf, (int) num); CLine->len = num; while(NULL != (vbuf = (unsigned char *) vgets(vp, &num))) { n++; if ((num == 1) && (*vbuf == '\n')) make_line(num); else make_line(num + 1); SLMEMCPY((char *) CLine->data, (char *) vbuf, (int) num); CLine->len = num; if (SLang_get_error () || SLKeyBoard_Quit) break; } if (vp->cr_flag) CBuf->flags |= ADD_CR_ON_WRITE_FLAG; else CBuf->flags &= ~ADD_CR_ON_WRITE_FLAG; } if (vp->buf != NULL) SLfree(vp->buf); SLfree ((char *)vp); return n; } /*}}}*/ #ifdef REAL_UNIX_SYSTEM int jed_get_inode_info (char *dirfile, int *device, int *inode) { struct stat st; *inode = *device = -1; if ((dirfile == NULL) || (-1 == stat (dirfile, &st))) return -1; *inode = st.st_ino; *device = st.st_dev; return 0; } #endif void jed_set_umask (int mask) { #ifdef REAL_UNIX_SYSTEM static int default_umask; #endif if (mask == 0) { #ifdef REAL_UNIX_SYSTEM if (default_umask != 0) (void) umask (default_umask); #endif } else { #ifdef REAL_UNIX_SYSTEM int u; u = umask (mask & 07777); if (default_umask == 0) default_umask = u; #endif } } int jed_dirfile_to_dir_file (char *dirfile, char **dirp, char **filep) { char *dir, *file; unsigned int len; if (dirfile == NULL) return -1; file = extract_file (dirfile); len = (unsigned int) (file - dirfile); if (NULL == (dir = SLmake_nstring (dirfile, len))) return -1; if (filep != NULL) { if (NULL == (file = SLmake_string (file))) { SLfree (dir); return -1; } *filep = file; } *dirp = dir; return 0; } char *jed_get_canonical_pathname (char *file) { return jed_expand_link (file); }