Преглед на файлове

Fix File Dialog path; allow run on Windows from another directory

Arthur Yefimov преди 2 години
родител
ревизия
1331277a94
променени са 4 файла, в които са добавени 12 реда и са изтрити 9 реда
  1. 3 3
      src/Editor.Mod
  2. 2 0
      src/Env.Mod
  3. 1 1
      src/FreeOberon.Mod
  4. 6 5
      src/TermBox.Mod

+ 3 - 3
src/Editor.Mod

@@ -17,7 +17,7 @@ You should have received a copy of the GNU General Public License
 along with Free Oberon.  If not, see <http://www.gnu.org/licenses/>.
 *)
 IMPORT OV, T := TermBox, Text := EditorText, Config, Debug,
-  Int, Strings, FoStrings, StrList, Dir, Out;
+  Int, Strings, FoStrings, StrList, Dir, Out, Env;
 (** Free Oberon IDE Editor. Part of Free Oberon IDE internal code *)
 CONST
   dotChar = 0B7X; (* To higlight spaces *)
@@ -54,7 +54,7 @@ TYPE
     edtFilename*: OV.Edit;
     btnOk*, btnCancel*: OV.Button;
     path*: ARRAY 1024 OF CHAR; (* full path to current chosen dir *)
-    home*: ARRAY 1024 OF CHAR; (* i.e. 'C:/FreeOberon/Programs' *)
+    home*: ARRAY 1024 OF CHAR; (* i.e. 'C:/FreeOberon/Programs/' *)
     colFiles*: OV.ColumnList;
     onFileOk*: PROCEDURE (c: OV.Control; fname: ARRAY OF CHAR)
   END;
@@ -262,7 +262,7 @@ BEGIN OV.InitWindow(c); c.do := fileDialogMethod; c.type := type;
   c.btnCancel.do.resize(c.btnCancel, c.w - 13, 11, 9, 1);
   OV.Add(c, c.btnCancel);
 
-  Dir.GetCwd(c.home); L := 0;
+  Env.GetAppDir(c.home); L := 0;
   WHILE c.home[L] # 0X DO (* Replace \ with /, set L to length of c.home *)
     IF c.home[L] = '\' THEN c.home[L] := '/' END; INC(L)
   END; (* L = length of c.home; append / if it is not in the end *)

+ 2 - 0
src/Env.Mod

@@ -174,10 +174,12 @@ END GetAppDirUnix;
 
 (** Returns a full path to the application directory. That is the directory
     where the executable file of the currently running program resides.
+     The path ends with delimeter / or \ (in the case of Windows).
      It might not be logically possible to determine application directory
     in some cases on Linux/Unix systems
 %RU Возвращает полный путь к директории приложения. Это тот каталог, в котором
     находится исполняемый файл текущей запущенной программы.
+     Путь заканчивается разделителем / или \ (в случае Windows).
      В некоторых случаях определить каталог приложения может быть оказаться
     логически невозможным в ОС Linux/Unix *)
 PROCEDURE GetAppDir*(VAR s: ARRAY OF CHAR);

+ 1 - 1
src/FreeOberon.Mod

@@ -1035,7 +1035,7 @@ VAR success, fs, sw: BOOLEAN;
   opt: SET;
 BEGIN
   success := FALSE;
-  lastFileDialogDir := '';
+  lastFileDialogDir[0] := 0X;
   ParseArgs(fs, sw, w, h, lang, fnames);
   opt := {T.resizable, T.center};
   IF fs THEN INCL(opt, T.fullscreen) ELSE INCL(opt, T.window) END;

+ 6 - 5
src/TermBox.Mod

@@ -1,6 +1,6 @@
 MODULE TermBox;
 (** Termbox is a module for creating cross-platform text-based interfaces *)
-IMPORT G := Graph, Strings, Int, Out, Platform, Kernel;
+IMPORT G := Graph, Strings, Int, Out, Env, Platform;
 
 CONST
   partW = 512;
@@ -763,9 +763,9 @@ BEGIN
   f := G.LoadFontInfo(fontFile);
   IF f # NIL THEN 
     IF f IS G.MonoFont THEN font := f(G.MonoFont)
-    ELSE Out.String('The font is not monospaced.'); Out.Ln
+    ELSE Out.String('TermBox: The font is not monospaced.'); Out.Ln
     END
-  ELSE Out.String('Could not load font "');
+  ELSE Out.String('TermBox: Could not load font "');
     Out.String(fontFile); Out.String('".'); Out.Ln
   END
 RETURN font # NIL END PreloadFont;
@@ -938,6 +938,7 @@ END SetFontFile;
 
 BEGIN wantW := stdW; wantH := stdH; wantScaleX := 0.0; wantScaleY := 0.0;
   settings := {fullscreen}; Done := FALSE;
-  iconFile := 'Data/Images/Icon.png';
-  fontFile := 'Data/Fonts/Main'
+  Env.GetAppDir(iconFile); Strings.Copy(iconFile, fontFile);
+  Strings.Append('Data/Images/Icon.png', iconFile);
+  Strings.Append('Data/Fonts/Main', fontFile)
 END TermBox.