/** * comment.e * * Commands to comment a block with old-style comments, or with * a prompted slide-in string. * * Author: David Hughes [DJH] * dhughes@minolta.com, knuv@compuserve.com * * Revision History * ---------------- * 07/22/99 DJH module created. * */ #include "eel.h" /** * GLOBAL VARIABLES */ user char comment_slide_str[200] = ""; // slide in/out string user char comment_copyright_holder[200] = ""; // copyright holder user char comment_copyright_dates[200] = ""; // copyright dates user char comment_author[200] = ""; // software author user char comment_ifdef_condition[200] = ""; // #ifdef condition /** * comment_block * * Comments a highlighted block. */ command comment_block() { int beg_pos, end_pos; // starting/ending positions save_spot mark, point; // save mark, spot for later // determine if marked normal/reverse if (mark > point) { beg_pos = point; end_pos = mark; } else { beg_pos = mark; end_pos = point; } // set start of block point = beg_pos; to_begin_line(); beg_pos = point; // set end of block point = end_pos; nl_forward(); end_pos = point; // start of block comment point = beg_pos; stuff (comment_begin); insert ('\n'); // end of block comment point = end_pos; nl_forward(); stuff (comment_end); insert ('\n'); } /** * uncomment_block * * Uncomments a highlighted block. */ command uncomment_block() { int beg_pos, end_pos; // starting/ending positions int comment_found = 0; // 1 = found, 0 = not found save_spot mark, point; // save mark, spot for later // determine if marked normal/reverse if (mark > point) { beg_pos = point; end_pos = mark; } else { beg_pos = mark; end_pos = point; } // determine if comment_begin exists point = beg_pos; comment_found = search (1, comment_begin); // was the start comment found? if (comment_found) delete (matchstart, matchend); // determine if comment_end exists point = end_pos; comment_found = search (-1, comment_end); // was the end comment fouund? if (comment_found) delete (matchstart, matchend); } /** * ifdef_block * * Comments out a block using IFDEF instead of comments */ command ifdef_block() { int beg_pos, end_pos; // starting/ending positions int lines_to_skip; // lines to skip between #ifdef, #endif int i; // loop variable save_spot mark, point; // save mark, spot for later // determine if marked normal/reverse if (mark > point) { beg_pos = point; end_pos = mark; } else { beg_pos = mark; end_pos = point; } // get the IFDEF condition get_str_auto_def(comment_ifdef_condition, "#IFDEF Condition: "); // set start of block point = beg_pos; to_begin_line(); beg_pos = point; // set end of block point = end_pos; nl_forward(); end_pos = point; // write out the heading point = beg_pos; stuff("#ifdef "); stuff(comment_ifdef_condition); stuff("\n"); // determine lines to slide, and set start lines_to_skip = lines_between(beg_pos, end_pos, 0) + 1; point = beg_pos; for (i = 0; i <= lines_to_skip; i++) nl_forward(); stuff("#endif\n"); } /** * comment_slide_in * * Comments a highlighted block with the specified slide-in string. */ command comment_slide_in() { int beg_pos, end_pos; // starting/ending positions int lines_to_slide; // lines to slide between mark/point int i; // loop variable save_spot mark, point; // save mark, spot for later // determine if marked normal/reverse if (mark > point) { beg_pos = point; end_pos = mark; } else { beg_pos = mark; end_pos = point; } // get slide in string get_str_auto_def(comment_slide_str, "Slide-in: "); // set start of block point = beg_pos; to_begin_line(); beg_pos = point; // set end of block point = end_pos; nl_forward(); end_pos = point; // determine lines to slide, and set start lines_to_slide = lines_between(beg_pos, end_pos, 0); point = beg_pos; for (i = 1; i < lines_to_slide; i++) { stuff (comment_slide_str); nl_forward(); } } /** * comment_function * * Standard function comment block. */ command comment_function() { char func_name[200]; // function name get_string(func_name, "Function: "); to_begin_line(); stuff("/**\n *\t"); stuff(func_name); stuff("\n *\n *\n */\n"); } /** * comment_module * * Standard module comment block. */ command comment_module() { char mod_name[200]; // module name char mod_desc[200]; // module description get_string(mod_name, "Module: "); get_string(mod_desc, "Description: "); to_begin_line(); stuff("/**\n *\t"); stuff(mod_name); stuff("\n *\n *\t"); stuff(mod_desc); stuff("\n *\n *\t"); stuff("Copyright (C) "); stuff(comment_copyright_dates); stuff(" "); stuff(comment_copyright_holder); stuff("\n *\tAll rights reserved.\n *\n *\tCreated by:\n *\t\t"); stuff(comment_author); stuff("\n */\n"); }