📄 xrolo.c
字号:
if ((save_as_filename =/* (char *) malloc((unsigned) (strlen(filename) + 1))) != NULL) { strcpy(save_as_filename, filename);*/ (char *) XtNewString((String) filename)) != NULL) { save_as_rolodex_file(); } } XmStringFree(xmstring); XtFree(filename);} /* FileSelectionOK *//*FileSelectionCancel() simply unmaps the file selection box.*//*ARGSUSED*/static void FileSelectionCancel(w, client_data, call_data)Widget w;XtPointer client_data;XtPointer call_data;{ XtUnmanageChild(fileSelectionDialog);} /* FileSelectionCancel *//*SaveUnsavedChanges() handles the appropriate action if a userchooses the "OK" button, depending on application context.*//*ARGSUSED*/static void SaveUnsavedChanges(w, client_data, call_data)Widget w;XtPointer client_data;XtPointer call_data;{ if (!is_rolodex_active()) return; save_first_time(); save_current_text(); xrolo_db_save(); if ((int) client_data == xrolo_QUIT_WARNING) { dialog_deactivate(quitUnsavedDialog); cleanup_and_exit(w); } else if ((int) client_data == xrolo_OPEN_WARNING) { dialog_deactivate(openUnsavedDialog); XtManageChild(fileSelectionDialog); }} /* SaveUnsavedChanges *//*DiscardUnsavedChanges() handles the appropriate action if a userchooses the "Discard" button, depending on application context.*//*ARGSUSED*/static void DiscardUnsavedChanges(w, client_data, call_data)Widget w;XtPointer client_data;XtPointer call_data;{ if ((int) client_data == xrolo_QUIT_WARNING) { dialog_deactivate(quitUnsavedDialog); cleanup_and_exit(w); } else if ((int) client_data == xrolo_OPEN_WARNING) { dialog_deactivate(openUnsavedDialog); XtManageChild(fileSelectionDialog); }} /* DiscardUnsavedChanges *//*CancelUnsavedChanges() handles the appropriate action if a userchooses the "Cancel" button, depending on application context.*//*ARGSUSED*/static void CancelUnsavedChanges(w, client_data, call_data)Widget w;XtPointer client_data;XtPointer call_data;{ if ((int) client_data == xrolo_QUIT_WARNING) dialog_deactivate(quitUnsavedDialog); else if ((int) client_data == xrolo_OPEN_WARNING) dialog_deactivate(openUnsavedDialog);} /* CancelUnsavedChanges *//*OverwriteOK() handles the appropriate action if a userchooses the "OK" button during a "Save As" operationthat leads to the file-overwrite warning.*//*ARGSUSED*/static void OverwriteOK(w, client_data, call_data)Widget w;XtPointer client_data;XtPointer call_data;{ do_save_as_operation(save_as_filename);} /* OverwriteOK *//*OverwriteCancel() handles the appropriate action if a userchooses the "Cancel" button during a "Save As" operationthat leads to the file-overwrite warning.*//*ARGSUSED*/static void OverwriteCancel(w, client_data, call_data)Widget w;XtPointer client_data;XtPointer call_data;{ /* currently, nothing */} /* OverwriteCancel *//*FindForward() handles the search in the forward direction for anentry containing the specified text.*//*ARGSUSED*/static void FindForward(w, client_data, call_data)Widget w;XtPointer client_data;XtPointer call_data;{ if (!is_rolodex_active()) return; find_entry_containing_text_forward();} /* FindForward *//*FindReverse() handles the search in the reverse direction for anentry containing the specified text.*//*ARGSUSED*/static void FindReverse(w, client_data, call_data)Widget w;XtPointer client_data;XtPointer call_data;{ if (!is_rolodex_active()) return; find_entry_containing_text_reverse();} /* FindReverse *//*FindDismiss() simply removes the "Find" dialog.*//*ARGSUSED*/static void FindDismiss(w, client_data, call_data)Widget w;XtPointer client_data;XtPointer call_data;{ XtUnmapWidget(findShell);} /* FindDismiss *//*First() advances to the first entry in the rolodex database.*//*ARGSUSED*/static void First(w, client_data, call_data)Widget w;XtPointer client_data;XtPointer call_data;{ if (!is_rolodex_active()) return; save_current_text(); if (xrolo_db_current_entry_is_first_entry()) return; if ((temp_entry = xrolo_db_first_entry()) != NULL) update_current_entry(temp_entry);} /* First *//*Last() advances to the last entry in the rolodex database.*//*ARGSUSED*/static void Last(w, client_data, call_data)Widget w;XtPointer client_data;XtPointer call_data;{ if (!is_rolodex_active()) return; save_current_text(); if (xrolo_db_current_entry_is_last_entry()) return; if ((temp_entry = xrolo_db_last_entry()) != NULL) update_current_entry(temp_entry);} /* Last *//*Next() advances to the next entry in the rolodex database.*//*ARGSUSED*/static void Next(w, client_data, call_data)Widget w;XtPointer client_data;XtPointer call_data;{ if (!is_rolodex_active()) return; load_next_rolodex_entry();} /* Next *//*Previous() advances to the previous entry in the rolodex database.*//*ARGSUSED*/static void Previous(w, client_data, call_data)Widget w;XtPointer client_data;XtPointer call_data;{ if (!is_rolodex_active()) return; load_previous_rolodex_entry();} /* Previous *//*Index() invokes the rolodex index system for selecting aspecific rolodex entry.*//*ARGSUSED*/static void Index(w, client_data, call_data)Widget w;XtPointer client_data;XtPointer call_data;{ if (!is_rolodex_active()) return; save_current_text(); if (!xrolo_index_build(char_set)) return; listShell_activate(entryIndex);} /* Index *//*Find() locates the next occurence of the specified textacross rolodex entries, beginning with the next entry.*//*ARGSUSED*/static void Find(w, client_data, call_data)Widget w;XtPointer client_data;XtPointer call_data;{ if (!XtIsRealized(findShell)) return; XtMapWidget(findShell);} /* Find *//*NewIns() clears the rolodex entry area for new text.*//*ARGSUSED*/static void NewIns(w, client_data, call_data)Widget w;XtPointer client_data;XtPointer call_data;{ if (!is_rolodex_active()) return; new_entry(xrolo_INSERT);} /* NewIns *//*NewAdd() clears the rolodex entry area for new text.*//*ARGSUSED*/static void NewAdd(w, client_data, call_data)Widget w;XtPointer client_data;XtPointer call_data;{ if (!is_rolodex_active()) return; new_entry(xrolo_ADD);} /* NewAdd *//*Copy() inserts a new rolodex entry into the rolodex file.*//*ARGSUSED*/static void Copy(w, client_data, call_data)Widget w;XtPointer client_data;XtPointer call_data;{ if (!is_rolodex_active()) return; if (!current_entry) { user_message("Nothing to copy."); return; } save_current_text(); user_message("Inserting a duplicate entry."); insert_new_db_entry();} /* Copy *//*Delete() deletes the current rolodex entry from the rolodex file.*//*ARGSUSED*/static void Delete(w, client_data, call_data)Widget w;XtPointer client_data;XtPointer call_data;{ if (!is_rolodex_active()) return; listShell_deactivate(entryIndex); /* must be rebuilt */ if (editing_new_entry) { if (!current_entry) editor_set_text(entryEditWindow, ""); else { current_entry = xrolo_db_current_entry(); editor_set_text(entryEditWindow, xrolo_db_get_text(current_entry)); } editing_new_entry = entry_modified = FALSE; } else { /* it's possible to delete all entries: */ if ((current_entry = xrolo_db_delete_current_entry()) == NULL) editor_set_text(entryEditWindow, ""); else editor_set_text(entryEditWindow, xrolo_db_get_text(current_entry)); entry_modified = FALSE; }} /* Delete *//*Undelete() recovers the most recent rolodex entry deletion.*//*ARGSUSED*/static void Undelete(w, client_data, call_data)Widget w;XtPointer client_data;XtPointer call_data;{ if (!is_rolodex_active()) return; save_current_text(); if ((temp_entry = xrolo_db_recover_deleted_entry()) != NULL) update_current_entry(temp_entry);} /* Undelete *//*IndexSelection() chooses a new current rolodex entry fromthe rolodex file based on the user's selection in the itemselection box.*//*ARGSUSED*/static void IndexSelection(w, client_data, call_data)Widget w;XtPointer client_data;XmListCallbackStruct *call_data;{ /* already saved entry in Index() */ temp_entry = (!xrolo_db_current_entry_is_first_entry()) ? xrolo_db_first_entry() : current_entry; if (!temp_entry) return; if ((temp_entry = xrolo_db_nth_entry(call_data->item_position - 1)) != NULL) update_current_entry(temp_entry); else { if ((temp_entry = xrolo_db_first_entry()) != NULL) update_current_entry(temp_entry); }} /* IndexSelection *//*Sort() sorts the rolodex database entries.*//*ARGSUSED*/static void Sort(w, client_data, call_data)Widget w;XtPointer client_data;XtPointer call_data;{ if (!is_rolodex_active()) return; if (!current_entry) { user_message("Nothing to sort."); return; } save_current_text(); temp_entry = ((int) client_data == xrolo_ASCEND) ? xrolo_db_sort_ascending() : xrolo_db_sort_descending(); if (temp_entry) update_current_entry(temp_entry);} /* Sort *//*Private support functions:*//*check_for_unsaved_changes() raises the dialog box that signals
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -