Skip to main content
Code Review

Return to Question

deleted 5 characters in body
Source Link
Edenia
  • 1.6k
  • 8
  • 24
void
write_ui
(char nodes[], int FOREGROUND, int BACKGROUND)
{
 int i;
 char buff[strlen(nodes)];
 strcpy(buff, nodes);
 HANDLE Handle = GetConsoleWindow();
 SetConsoleTextAttribute (GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND | BACKGROUND);
 for(i=0; buff[i] != '0円'; i++)
 {
 if(buff[i] == '-') { printf("%c", 196); } // Horizontal line
 else if(buff[i] != '|' && buff[i] != '_' &&
 buff[i] != '^' && buff[i] != '~') { printf("%c", buff[i]); } // Any other character
 if(buff[i] == '|' && buff[i-1] != '-' && buff[i+1] != '-' &&
 buff[i-1] != '_' && buff[i+1] != '^' && buff[i-1] != '^') { printf("%c", 179); } // vertical line && !isdigit(buff[i])
 if(buff[i] == '|' && buff[i+1] == '_') { printf("\n%c", 192); } // bottom right corner
 if(buff[i] == '_' && buff[i+1] == '|') { printf("%c", 217); } // bottom left corner
 if(buff[i] == '|' && buff[i+1] == '^') { printf("%c", 218); } // top left corner
 if(buff[i] == '^' && buff[i+1] == '|') { printf("%c", 191); } // top right corner
 if(buff[i] == '-' && buff[i+1] == '|') { printf("%c", 180); } // ┤
 if(buff[i] == '|' && buff[i+1] == '-') { printf("%c", 195); } // ├
 if(buff[i] == '~')
 {
 int spaces = 0, len = 0, l = 0, multiplier = 1;
 do { len++; multiplier *= 10; } while(isdigit(buff[i+(len+1)])); multiplier /= 10;
 l = len;
 do { spaces += (chrtodigit(buff[(i+len+1)-l]) * multiplier); l--; multiplier /= 10; } while( l != -1 );
 splice_away(buff, i, i+len); // To cut the number passed as number of spaces from screen
 l = 0;
 do { l++; printfputchar("%c", ' '); } while(l != spaces);
 }
 }
}
int chrtodigit (char chr)
{
 if(chr >= '0' && chr <= '9') { return chr-48; }
 else return 0;
}
int intlen (int integer)
{
 int number, len;
 for(number = integer; number != 0; len++, number/=10);
 return len;
}
void splice_away(char str[], int from, int to)
{
 memmove(str + from, str + to, 1 + strlen(str + to));
}
void
write_ui
(char nodes[], int FOREGROUND, int BACKGROUND)
{
 int i;
 char buff[strlen(nodes)];
 strcpy(buff, nodes);
 HANDLE Handle = GetConsoleWindow();
 SetConsoleTextAttribute (GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND | BACKGROUND);
 for(i=0; buff[i] != '0円'; i++)
 {
 if(buff[i] == '-') { printf("%c", 196); } // Horizontal line
 else if(buff[i] != '|' && buff[i] != '_' &&
 buff[i] != '^' && buff[i] != '~') { printf("%c", buff[i]); } // Any other character
 if(buff[i] == '|' && buff[i-1] != '-' && buff[i+1] != '-' &&
 buff[i-1] != '_' && buff[i+1] != '^' && buff[i-1] != '^') { printf("%c", 179); } // vertical line && !isdigit(buff[i])
 if(buff[i] == '|' && buff[i+1] == '_') { printf("\n%c", 192); } // bottom right corner
 if(buff[i] == '_' && buff[i+1] == '|') { printf("%c", 217); } // bottom left corner
 if(buff[i] == '|' && buff[i+1] == '^') { printf("%c", 218); } // top left corner
 if(buff[i] == '^' && buff[i+1] == '|') { printf("%c", 191); } // top right corner
 if(buff[i] == '-' && buff[i+1] == '|') { printf("%c", 180); } // ┤
 if(buff[i] == '|' && buff[i+1] == '-') { printf("%c", 195); } // ├
 if(buff[i] == '~')
 {
 int spaces = 0, len = 0, l = 0, multiplier = 1;
 do { len++; multiplier *= 10; } while(isdigit(buff[i+(len+1)])); multiplier /= 10;
 l = len;
 do { spaces += (chrtodigit(buff[(i+len+1)-l]) * multiplier); l--; multiplier /= 10; } while( l != -1 );
 splice_away(buff, i, i+len); // To cut the number passed as number of spaces from screen
 l = 0;
 do { l++; printf("%c", ' '); } while(l != spaces);
 }
 }
}
int chrtodigit (char chr)
{
 if(chr >= '0' && chr <= '9') { return chr-48; }
 else return 0;
}
int intlen (int integer)
{
 int number, len;
 for(number = integer; number != 0; len++, number/=10);
 return len;
}
void splice_away(char str[], int from, int to)
{
 memmove(str + from, str + to, 1 + strlen(str + to));
}
void
write_ui
(char nodes[], int FOREGROUND, int BACKGROUND)
{
 int i;
 char buff[strlen(nodes)];
 strcpy(buff, nodes);
 HANDLE Handle = GetConsoleWindow();
 SetConsoleTextAttribute (GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND | BACKGROUND);
 for(i=0; buff[i] != '0円'; i++)
 {
 if(buff[i] == '-') { printf("%c", 196); } // Horizontal line
 else if(buff[i] != '|' && buff[i] != '_' &&
 buff[i] != '^' && buff[i] != '~') { printf("%c", buff[i]); } // Any other character
 if(buff[i] == '|' && buff[i-1] != '-' && buff[i+1] != '-' &&
 buff[i-1] != '_' && buff[i+1] != '^' && buff[i-1] != '^') { printf("%c", 179); } // vertical line && !isdigit(buff[i])
 if(buff[i] == '|' && buff[i+1] == '_') { printf("\n%c", 192); } // bottom right corner
 if(buff[i] == '_' && buff[i+1] == '|') { printf("%c", 217); } // bottom left corner
 if(buff[i] == '|' && buff[i+1] == '^') { printf("%c", 218); } // top left corner
 if(buff[i] == '^' && buff[i+1] == '|') { printf("%c", 191); } // top right corner
 if(buff[i] == '-' && buff[i+1] == '|') { printf("%c", 180); } // ┤
 if(buff[i] == '|' && buff[i+1] == '-') { printf("%c", 195); } // ├
 if(buff[i] == '~')
 {
 int spaces = 0, len = 0, l = 0, multiplier = 1;
 do { len++; multiplier *= 10; } while(isdigit(buff[i+(len+1)])); multiplier /= 10;
 l = len;
 do { spaces += (chrtodigit(buff[(i+len+1)-l]) * multiplier); l--; multiplier /= 10; } while( l != -1 );
 splice_away(buff, i, i+len); // To cut the number passed as number of spaces from screen
 l = 0;
 do { l++; putchar(' '); } while(l != spaces);
 }
 }
}
int chrtodigit (char chr)
{
 if(chr >= '0' && chr <= '9') { return chr-48; }
 else return 0;
}
int intlen (int integer)
{
 int number, len;
 for(number = integer; number != 0; len++, number/=10);
 return len;
}
void splice_away(char str[], int from, int to)
{
 memmove(str + from, str + to, 1 + strlen(str + to));
}
Add alt text for image and link to full size version of image.
Source Link

enter image description hereCropped screenshot of fake UI window

enter image description here

added 2 characters in body; edited title
Source Link
Edenia
  • 1.6k
  • 8
  • 24

Code *Code for fake UI

  • | For vertical line
  • - For horizontal line
  • -| For left pause (break for titles etc)
  • |- For right pause
  • |_ Bottom left corner
  • _| Bottom right corner
  • |^ Top left corner
  • ^| Top left corner
  • ~x Any number to represent count of spaces

Code for fake UI

  • | For vertical line
  • - For horizontal line
  • -| For left pause (break for titles etc)
  • |- For right pause
  • |_ Bottom left corner
  • _| Bottom right corner
  • |^ Top left corner
  • ^| Top left corner~x Any number to represent count of spaces

*Code for fake UI

  • | For vertical line
  • - For horizontal line
  • -| For left pause (break for titles etc)
  • |- For right pause
  • |_ Bottom left corner
  • _| Bottom right corner
  • |^ Top left corner
  • ^| Top left corner
  • ~x Any number to represent count of spaces
added 12 characters in body
Source Link
Jamal
  • 35.2k
  • 13
  • 134
  • 238
Loading
edited body
Source Link
Edenia
  • 1.6k
  • 8
  • 24
Loading
Source Link
Edenia
  • 1.6k
  • 8
  • 24
Loading
lang-c

AltStyle によって変換されたページ (->オリジナル) /