#include "config.h" #include #include #include "most.h" #include "search.h" #include "window.h" #include "file.h" #include "keym.h" #include "display.h" #include "sysdep.h" static char getkey_nocase (void) { char ch = most_getkey (); if ((ch >= 'a') && (ch <= 'z')) ch = ch - ' '; return ch; } void most_next_file (void) { static int next = 1; char *msg = NULL; if (!Most_Num_Files) msg = "File ring is empty."; else if (Most_Num_Files == 1) msg = "There is only one file!"; else { most_do_next_file(&next); } if (msg != NULL) most_message (msg, 1); } void most_toggle_case (void) { char *msg; Most_Case_Sensitive = !Most_Case_Sensitive; if (Most_Case_Sensitive) msg = "Searches now respect case."; else msg = "Searches nolonger respect case."; most_message (msg, 0); } void most_delete_file_cmd (void) { int bell = 0; char ch; char *msg; if ('*' == *Most_Buf->file) return; if (Most_Secure_Mode) Most_D_Opt = 0; if (Most_D_Opt == 0) return; most_select_minibuffer (); most_send_string_to_term("Delete "); most_send_string_to_term(Most_Buf->file); most_send_string_to_term("? [n]:"); ch = getkey_nocase (); if (ch == 'Y') { if (!most_delete_file(Most_Buf->file)) { msg = "File could not be deleted."; bell = 1; } else msg = "File deleted."; } else msg = "File not deleted."; most_exit_minibuffer (); most_message(msg, bell); } void most_toggle_options (void) { char ch; char *msg = NULL; int n; unsigned char *save; most_select_minibuffer(); most_send_string_to_term("\rToggle option: b(binary) d(selective display) t(tab) v(verbose) w(wrap)"); fflush(stdout); ch = getkey_nocase(); switch (ch) { default: msg = "\007Invalid option!"; break; case 'B': Most_B_Opt = !Most_B_Opt; Most_Num_Lines = most_count_lines(Most_Beg,Most_Eob); break; case 'D': if (Most_W_Opt) { msg = "\007Selective Display illegal in wrap mode."; break; } if (Most_Digit_Arg == NULL) { msg = "Selective Display off. Prefix with integer to set."; n = 0; } else { msg = "Selective Display is set."; n = abs( *Most_Digit_Arg ); } if (Most_Selective_Display != n) { Most_Selective_Display = n; Most_Num_Lines = most_count_lines(Most_Beg,Most_Eob); most_forward_line (-1); /* This is duplicated below */ /* Most_C_Line = most_count_lines (Most_Beg, Most_C_Pos); */ } break; case 'S': if (Most_B_Opt) msg = "\007Squeezing not available in Binary mode."; else { Most_S_Opt = !Most_S_Opt; Most_Num_Lines = most_count_lines(Most_Beg,Most_Eob); if (Most_S_Opt) msg = "Lines are now squeezed."; else msg = "Line squeezing is turned off"; } break; case 'W': if (Most_Selective_Display) { msg = "\007Wrap mode cannot be enabled while selective display is on."; break; } Most_W_Opt = !Most_W_Opt; Most_Num_Lines = most_count_lines(Most_Beg, Most_Eob); if (Most_W_Opt) msg = "Wrap turned on."; else msg = "Wrap turned off."; break; case 'V': Most_V_Opt = !Most_V_Opt; if (Most_V_Opt) msg = "Control char display is turned on."; else msg = "Control char display is turned off."; break; case 'T': if (Most_Digit_Arg == NULL) Most_T_Opt = !Most_T_Opt; else { Most_Tab_Width = abs( *Most_Digit_Arg ); if (Most_Tab_Width == 0) Most_T_Opt = 1; } if (Most_T_Opt) msg = "Tabs are nolonger expanded."; else msg = "Tabs are now expanded."; break; } most_tt_erase_line(); most_exit_minibuffer(); if ((msg != NULL) && (*msg == '\007')) { most_message (msg + 1, 1); return; } if (!Most_Num_Lines) Most_Num_Lines = 1; most_save_win_flags(Most_Win); save = Most_C_Pos; Most_C_Pos = Most_Beg; Most_C_Line = 1; Most_C_Line = most_what_line(save); Most_C_Pos = save; Most_Win->beg_line = Most_C_Line; most_redraw_window(); most_update_status(0); if (msg != NULL) most_message (msg, 0); } /* ----------------------------------------------------------------------*/ void most_extended_key_cmd (void) { char ch; if (Most_Secure_Mode) Most_D_Opt = 0; most_select_minibuffer(); most_send_string_to_term (" N (next file), C (toggle case), O (toggle options)"); if (Most_D_Opt) most_send_string_to_term (" ,D (delete file)"); most_send_string_to_term ("\rChoose:"); fflush(stdout); ch = getkey_nocase(); most_tt_erase_line (); most_exit_minibuffer (); switch (ch) { case 'N': most_next_file (); break; case 'C': most_toggle_case (); break; case 'O': most_toggle_options (); break; case 'D': if (Most_D_Opt) { most_delete_file_cmd (); break; } /* drop */ default: most_message ("Invalid option.", 1); } }