UNIXworkcode

1 /******************************************************************************* 2 * * 3 * file.h -- Nirvana Editor File Header File * 4 * * 5 * Copyright 2004 The NEdit Developers * 6 * * 7 * This is free software; you can redistribute it and/or modify it under the * 8 * terms of the GNU General Public License as published by the Free Software * 9 * Foundation; either version 2 of the License, or (at your option) any later * 10 * version. In addition, you may distribute versions of this program linked to * 11 * Motif or Open Motif. See README for details. * 12 * * 13 * This software is distributed in the hope that it will be useful, but WITHOUT * 14 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * 15 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * 16 * more details. * 17 * * 18 * You should have received a copy of the GNU General Public License along with * 19 * software; if not, write to the Free Software Foundation, Inc., 59 Temple * 20 * Place, Suite 330, Boston, MA 02111-1307 USA * 21 * * 22 * Nirvana Text Editor * 23 * July 31, 2001 * 24 * * 25 *******************************************************************************/ 26 27 #ifndef NEDIT_FILE_H_INCLUDED 28 #define NEDIT_FILE_H_INCLUDED 29 30 #include "nedit.h" 31 32 #include "../util/getfiles.h" 33 34 #include <X11/Intrinsic.h> 35 36 /* flags for EditExistingFile */ 37 #define CREATE 1 38 #define SUPPRESS_CREATE_WARN 2 39 #define PREF_READ_ONLY 4 40 41 #define PROMPT_SBC_DIALOG_RESPONSE 0 42 #define YES_SBC_DIALOG_RESPONSE 1 43 #define NO_SBC_DIALOG_RESPONSE 2 44 45 typedef struct DefaultEncoding { 46 char *locale; 47 char *encoding; 48 } DefaultEncoding; 49 50 typedef struct FileContent { 51 struct stat statbuf; 52 char *content; 53 size_t length; 54 int readonly; 55 int hasBOM; 56 int fileFormat; 57 int isdir; 58 int isblk; 59 int allocerror; 60 int iconverror; 61 int closeerror; 62 int skipped; 63 int err; 64 EncError *enc_errors; 65 size_t num_enc_errors; 66 char encoding[MAX_ENCODING_LENGTH]; 67 } FileContent; 68 69 70 WindowInfo *EditNewFile(WindowInfo *inWindow, char *geometry, int iconic, 71 const char *languageMode, const char *defaultPath); 72 WindowInfo *EditExistingFile(WindowInfo *inWindow, const char *name, 73 const char *path, const char *encoding, const char *filter, int flags, 74 char *geometry, int iconic, const char *languageMode, int tabbed, 75 int bgOpen); 76 void RevertToSaved(WindowInfo *window, char *newEncoding); 77 int SaveWindow(WindowInfo *window); 78 int SaveWindowAs(WindowInfo *window, FileSelection *file); 79 int CloseAllFilesAndWindows(void); 80 int CloseFileAndWindow(WindowInfo *window, int preResponse); 81 void PrintWindow(WindowInfo *window, int selectedOnly); 82 void PrintString(const char *string, int length, Widget parent, const char *jobName); 83 int WriteBackupFile(WindowInfo *window); 84 int IncludeFile(WindowInfo *window, const char *name, const char *encoding, const char *filter_name); 85 int PromptForExistingFile(WindowInfo *window, char *prompt, FileSelection *file); 86 int PromptForNewFile(WindowInfo *window, char *prompt, FileSelection *file, 87 int *fileFormat); 88 int CheckReadOnly(WindowInfo *window); 89 void RemoveBackupFile(WindowInfo *window); 90 void UniqueUntitledName(char *name); 91 void CheckForChangesToFile(WindowInfo *window); 92 93 const char * DetectEncoding(const char *buf, size_t len, const char *def); 94 95 int GetFileContent(Widget shell, const char *path, const char *encoding, const char *filter_name, FileContent *content); 96 97 #endif /* NEDIT_FILE_H_INCLUDED */ 98