[tuhopuu-devel] tabcomplete

Joilnen Batista Leite tuhopuu-devel@blender.org
Sun, 11 Jul 2004 09:41:08 -0700 (PDT)


--0-1834869511-1089564068=:70783
Content-Type: text/plain; charset=us-ascii
Content-Id: 
Content-Disposition: inline

thanks to consider

TAB to complete namefiles type senssitive 
SHIFT+TAb to complete namefiles

Joilnen




		
__________________________________
Do you Yahoo!?
Take Yahoo! Mail with you! Get it on your mobile phone.
http://mobile.yahoo.com/maildemo 
--0-1834869511-1089564068=:70783
Content-Type: text/plain; name="tabpatch.blender"
Content-Description: tabpatch.blender
Content-Disposition: inline; filename="tabpatch.blender"

--- blender/source/blender/src/filesel.c	2004-06-14 16:20:40.000000000 -0300
+++ tuhopuu2/source/blender/src/filesel.c	2004-06-15 16:52:15.000000000 -0300
@@ -133,6 +141,7 @@
 static void filesel_select_objects(struct SpaceFile *sfile);
 static void active_file_object(struct SpaceFile *sfile);
 static int groupname_to_code(char *group);
+static short my_strspn(char *d, char *s);
 
 /* local globals */
 
@@ -2605,3 +2554,77 @@
 	}
 }
 
+int find_filename(int ext){
+	SpaceFile *sfile;
+	short a, flag=0, c=0, tmp=0, tmp_ini=0;
+	struct direntry *file;
+
+	sfile = curarea->spacedata.first;
+	if( !sfile->filelist )
+		return 0;
+	file = sfile->filelist;
+	for(a=0; a<sfile->totfile; a++, file++) {
+		if( (!S_ISDIR(file->type) && ((strstr(file->relname, sfile->file) == file->relname)) ||
+			(!S_ISDIR(file->type) && (flag == 1)) ) ){
+		/* if ext != 0 press TAB scan only supported files types */
+			if(ext){
+				if( !strncmp(sfile->title, "Open File", 9) && file->flags != BLENDERFILE )
+					continue;
+
+				if( !strncmp(sfile->title, "SELECT FONT", 11) && file->flags != FTFONTFILE )
+					continue;
+
+				if( !strncmp(sfile->title, "Select Movie", 12 ) && file->flags != MOVIEFILE )
+					continue;
+				
+				if( ( !strncmp(sfile->title,"SELECT WAV FILE", 15 ) ||
+					!strncmp(sfile->title,"Select Wav", 10 )) && 
+					file->flags != SOUNDFILE ) 
+						continue;
+
+				if( ( !strncmp(sfile->title,"SELECT FILE", 11) ||
+					!strncmp(sfile->title,"Open Image", 10) ||
+					!strncmp(sfile->title,"Select Images", 13)) &&
+					file->flags != IMAGEFILE ) 
+						continue;
+			}			
+			
+			if(!flag){
+				tmp = strlen(sfile->file);
+				tmp_ini = tmp;
+				strcpy(sfile->file, file->relname);
+				flag = 1;
+				continue;
+			}
+
+			/* return identic n of chars */
+			c = my_strspn(sfile->file, file->relname);
+			if(c && (c>=tmp || c>=tmp_ini)){
+
+				/* take last pattern */
+				strncpy(sfile->file, file->relname, c);
+				*(sfile->file+c) = '\0';
+				tmp = c;
+			}else if(flag == 1) break;	
+		}
+            
+		if(tmp){
+
+			/* keep right pattern */
+			strncpy(sfile->file, file->relname, tmp);
+			*(sfile->file+tmp) = '\0';
+		}
+	}
+	return 1;
+}
+
+static short my_strspn(char *d, char *s){
+	short count = 0;
+	while(*d && *s && *d==*s){
+		d++;
+		s++;
+		count++;
+	}
+	return count;
+}
+
--- blender/source/blender/src/interface.c	2004-06-14 16:20:40.000000000 -0300
+++ tuhopuu2/source/blender/src/interface.c	2004-06-15 06:49:32.000000000 -0300
@@ -1268,6 +1268,19 @@
 					}
 				} 
 				break;
+			case TABKEY:
+				if(G.qual & LR_SHIFTKEY){ 
+				     if(find_filename(0)) {
+					  but->pos=len= strlen(str);
+					  dodraw= 1;
+			             }
+				}
+				else
+				     if(find_filename(1)) {
+					  but->pos=len= strlen(str);
+					  dodraw= 1;
+			             }
+					
 			}
 		}
 
		
--- blender/source/blender/include/BSE_filesel.h	2004-06-14 16:20:40.000000000 -0300
+++ tuhopuu2/source/blender/include/BSE_filesel.h	2004-06-15 06:49:32.000000000 -0300
@@ -1,5 +1,5 @@
 /**
- * $Id: BSE_filesel.h,v 1.8 2003/07/17 14:19:55 sirdude Exp $
+ * $Id: BSE_filesel.h,v 1.2 2004/04/14 21:38:30 jiri Exp $
  *
  * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
  *
@@ -59,5 +59,6 @@
 void main_to_filelist(struct SpaceFile *sfile);   
 
 void clever_numbuts_filesel(void);
+int find_filename(int ext);
 #endif
 

--0-1834869511-1089564068=:70783
Content-Type: text/plain; name="tabpatch.tuhopuu2"
Content-Description: tabpatch.tuhopuu2
Content-Disposition: inline; filename="tabpatch.tuhopuu2"

--- tuhopuu2/source/blender/src/filesel.c	2004-06-05 19:09:14.000000000 -0300
+++ tuhopuu2_old/source/blender/src/filesel.c	2004-06-02 22:09:01.000000000 -0300
@@ -2553,7 +2552,7 @@
 	}
 }
 
-int find_filename(){
+int find_filename(int ext){
 	SpaceFile *sfile;
 	short a, flag=0, c=0, tmp=0, tmp_ini=0;
 	struct direntry *file;
@@ -2563,7 +2562,30 @@
 		return 0;
 	file = sfile->filelist;
 	for(a=0; a<sfile->totfile; a++, file++) {
-		if( !S_ISDIR(file->type) && (strstr(file->relname, sfile->file) == file->relname) || (flag == 1)){
+		if( !S_ISDIR(file->type) && ((strstr(file->relname, sfile->file) == file->relname) || (flag == 1)) ){
+		/* if ext != 0 press TAB scan only supported files types */
+			if(ext){
+				if( !strncmp(sfile->title, "LOAD FILE", 9) && file->flags != BLENDERFILE )
+					continue;
+
+				if( !strncmp(sfile->title, "SELECT FONT", 11) && file->flags != FTFONTFILE )
+					continue;
+
+				if( !strncmp(sfile->title, "SELECT MOVIE", 12 ) && file->flags != MOVIEFILE )
+					continue;
+				
+				if( ( !strncmp(sfile->title,"SELECT WAV FILE", 15 ) ||
+					!strncmp(sfile->title,"SELECT WAV", 10 )) && 
+					file->flags != SOUNDFILE ) 
+						continue;
+
+				if( ( !strncmp(sfile->title,"SELECT FILE", 11) ||
+					!strncmp(sfile->title,"SELECT IMAGE", 12) ||
+					!strncmp(sfile->title,"SELECT IMAGES", 13)) &&
+					file->flags != IMAGEFILE ) 
+						continue;
+			}			
+			
 			if(!flag){
 				tmp = strlen(sfile->file);
 				tmp_ini = tmp;
@@ -2602,3 +2624,4 @@
 	}
 	return count;
 }
+
--- tuhopuu2/source/blender/src/interface.c	2004-06-05 19:09:14.000000000 -0300
+++ tuhopuu2_old/source/blender/src/interface.c	2004-05-31 18:15:33.000000000 -0300
@@ -1,5 +1,5 @@
 /**
- * $Id: interface.c,v 1.20 2004/06/05 22:09:14 hos Exp $
+ * $Id: interface.c,v 1.17 2004/05/01 18:58:34 hos Exp $
  *
  * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
  *
@@ -1269,11 +1269,18 @@
 				} 
 				break;
 			case TABKEY:
-                        	if(find_filename()) {
-                        		but->pos= strlen(str);
-                        		len= strlen(str);
-                        		dodraw= 1;
-                        	}
+				if(G.qual & LR_SHIFTKEY){ 
+				     if(find_filename(0)) {
+					  but->pos=len= strlen(str);
+					  dodraw= 1;
+			             }
+				}
+				else
+				     if(find_filename(1)) {
+					  but->pos=len= strlen(str);
+					  dodraw= 1;
+			             }
+					
 			}
 		}
 
--- tuhopuu2/source/blender/include/BSE_filesel.h	2004-04-14 18:38:30.000000000 -0300
+++ tuhopuu2_old/source/blender/include/BSE_filesel.h	2004-05-31 18:13:19.000000000 -0300
@@ -59,6 +59,6 @@
 void main_to_filelist(struct SpaceFile *sfile);   
 
 void clever_numbuts_filesel(void);
-int find_filename();
+int find_filename(int ext);
 #endif
 

--0-1834869511-1089564068=:70783--