Advertisement
Guest User

Untitled

a guest
Aug 19th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.86 KB | None | 0 0
  1. stock void GetTabulation(char[] str, char[] buffer, int maxlength)
  2. {
  3.     char symbols[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890.:- ";       //
  4.     int size[] = {6, 6, 6, 6, 6, 5, 6, 6, 2, 4, 6, 2, 10, 6, 6, 6, 6, 4, 6, 5, 6, 7, 9, 7, 7, 6, 9, 7, 7, 7, 7, 7, 7, 7, 2, 7, 7, 6, 9, 8, 7, 7, 7, 7, 7, 7, 7, 8, 12, 7, 8, 7, 5, 6, 6, 8, 6, 6, 6, 6, 6, 6, 2, 2, 2, 8};
  5.  
  6.     int totalWidth, idx;
  7.     for(int i, len = strlen(str); i < len; i++)
  8.     {
  9.         if((idx = FindCharInString(symbols, str[i])) != -1)
  10.         {
  11.             totalWidth += size[idx] + BTW_WIDTH;
  12.         }
  13.     }
  14.  
  15.     int tab = RoundFloat(float(BLOCK_WIDTH - totalWidth) / float(TAB_WIDTH));
  16.  
  17.     switch(tab)
  18.     {
  19.         case 1: FormatEx(buffer, maxlength, "\t");
  20.         case 2: FormatEx(buffer, maxlength, "\t\t");
  21.         case 3: FormatEx(buffer, maxlength, "\t\t\t");
  22.        
  23.         default: FormatEx(buffer, maxlength, "\t\t\t\t");
  24.     }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement