TinTin++ Mud Client The TinTin++ message board

 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
TinTin++ Mud Client

Default file

 
Post new topic   Reply to topic    The TinTin++ message board Forum Index -> Development
View previous topic :: View next topic  
Author Message
Faern



Joined: 02 Sep 2010
Posts: 2

PostPosted: Thu Sep 02, 2010 7:24 pm    Post subject: Default file Reply with quote

Why was the default file (i.e. .tintinrc) functionality removed from tintin++ but similar functionality remains in WinTin++? The last mention of either .tintinrc or tt.conf in the development history is about nine years ago and there is no indication of when it was removed. The only minor clue is May 2005 (v 1.94.2) states:
Quote:
tintin.h Removed unused macro DEFAULT_FILE_DIR


It appears to be fairly simple to hack the default file function back into tt++:
Code:
--- main.c.orig   2010-09-02 17:14:10.000000000 -0700
+++ main.c   2010-09-02 17:13:20.000000000 -0700
@@ -158,6 +158,7 @@
 int main(int argc, char **argv)
 {
     int greeting = TRUE;
+    int read_default = TRUE;
 
     #ifdef SOCKS
         SOCKSinit(argv[0]);
@@ -220,12 +221,16 @@
     {
         int c;
 
-        while ((c = getopt(argc, argv, "e: G h r: t: v")) != EOF)
+        while ((c = getopt(argc, argv, "e: G h r: n t: v")) != EOF)
         {
             if (c == 'G')
             {
                 greeting = FALSE;
             }
+            if (c == 'n' || c == 'r')
+            {
+                read_default = FALSE;
+            }
         }
 
         optind = 1;
@@ -256,7 +261,8 @@
                     tintin_printf(NULL, "  -e  Execute given command.");
                     tintin_printf(NULL, "  -G  Don't show the greeting screen.");
                     tintin_printf(NULL, "  -h  This help section.");
-                    tintin_printf(NULL, "  -r  Read given file.");
+                    tintin_printf(NULL, "  -n  Do not load default file.");
+                    tintin_printf(NULL, "  -r  Read given file (implies -n).");
                     tintin_printf(NULL, "  -t  Set given title.");
                     tintin_printf(NULL, "  -v  Enable verbose mode.");
 
@@ -287,6 +293,15 @@
             gtd->ses = do_read(gtd->ses, argv[optind]);
         }
     }
+    if (read_default)
+    {
+        if (getenv("HOME") != NULL)
+        {
+            char ttrc[256];
+            sprintf(ttrc, "%s/%s", getenv("HOME"), DEFAULT_FILE);
+            gtd->ses = do_read(gtd->ses, ttrc);
+        }
+    }
     check_all_events(gts, 0, 2, "PROGRAM START", CLIENT_NAME, CLIENT_VERSION);
     check_all_events(gts, 0, 2, "SCREEN RESIZE", ntos(gts->cols), ntos(gts->rows));
 
--- tintin.h.orig   2010-09-02 15:10:45.000000000 -0700
+++ tintin.h   2010-09-02 17:17:30.000000000 -0700
@@ -114,6 +114,7 @@
 #define COMMAND_SEPARATOR              ';'
 
 #define HISTORY_FILE         ".tt_history"
+#define DEFAULT_FILE           ".tintinrc"
 
 #define STRING_SIZE                  45000
 #define BUFFER_SIZE                  20000


In a relatively brief examination of the code, it appears that the current functionality (i.e. tt++ run.tin) is a shorthand version of tt++ -r run.tin. The attached diff would retain the existing behavior (although I'm not convinced that the shorthand version bit is desirable, it is what people are used to.) It introduces a new option (-n) which tells tt++ not to load ~/.tintinrc and also does not load .tintinrc on an explicit -r <file>
Back to top
View user's profile Send private message
Scandum
Site Admin


Joined: 03 Dec 2004
Posts: 3770

PostPosted: Thu Sep 02, 2010 8:34 pm    Post subject: Reply with quote

There's no default file in WinTin++ as it uses the exact same source code.

The WinTin++ program shortcut is set to execute:

"C:\Program Files\WinTin++\cygterm.exe" -cygterm bin/tt++ -t WinTin++ -r main.tin

Back in the days there was a special parser that read .tintinrc which had its own special format, when I added #config I got rid of that code. All things considered I'm not a big fan of the idea as I'm trying to keep bloat to a minimum.

If people want a default file one option is to edit .bash_profile or .bashrc and add:

alias tt++='tt++ -r $HOME/.tintinrc'
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    The TinTin++ message board Forum Index -> Development All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Get TinTin++ Mud Client at SourceForge.net. Fast, secure and Free Open Source software downloads Get TinTin++ Mud Client at SourceForge.net. Fast, secure and Free Open Source software downloads
TinTin++ Homepage

Powered by phpBB © 2001, 2002 phpBB Group