]> icculus.org git repositories - divverent/nexuiz.git/blob - data/menuqc/util/text.qc
rename menu directories
[divverent/nexuiz.git] / data / menuqc / util / text.qc
1 // NG Menu
2 // util/text.qc
3
4 //INFO: I only care about \n and \0 and the col if in wrapped mode
5 vector( string pText, vector pLast ) Util_GetEndOfLine =
6 {
7         local string lChar;
8
9         pLast_x = pLast_y;
10         pLast_z = 0;
11         while( 1 ) {
12                 lChar = substring( pText, pLast_x, 1 );
13
14                 // newline -> the current char isnt valid
15                 if( lChar == "\n" ) {
16                         // the next valid is char can only be after the \n
17                         pLast_y = pLast_x + 1;
18                         --pLast_x;
19                         return pLast;
20                 } else if( lChar == "" ) {
21                         pLast_y = --pLast_x;
22                         return pLast;
23                 } else {
24                         ++pLast_x;
25                         ++pLast_z;
26                 }
27         }
28 };
29
30 vector( string pText, vector pLast, float pWrapLength ) Util_GetEndOfWrappedLine =
31 {
32         local string lChar;
33
34         pLast_x = pLast_y;
35         pLast_z = 0;
36         while( 1 ) {
37                 lChar = substring( pText, pLast_x, 1 );
38
39                 // newline -> the current char isnt valid
40                 if( lChar == "\n" ) {
41                         --pLast_x;
42                         // the next valid is char can only be after the \n
43                         pLast_y = pLast_x + 2;
44                         return pLast;
45                 } else if( lChar == "" ) {
46                         pLast_y = --pLast_x;
47                         return pLast;
48                 } else {
49                         ++pLast_x;
50                         ++pLast_z;
51                         if( !--pWrapLength ) {
52                                 // the current char is one too much
53                                 pLast_y = pLast_x;
54                                 --pLast_x;
55                                 return pLast;
56                         }
57                 }
58         }
59 };