Enviado em 14/11/2018 - 20:17h
Olá pessoal !
void Draw (EDITOR *o) {
int pos_x = o->r.x + 10;
int pos_y = o->r.y + 10;
int line_top = 0;
if (key == SDLK_UP && o->line_top > 0) {
o->line_top--;
}
else
if (key == SDLK_DOWN && o->line_top < o->line_count-1) {
o->line_top++;
}
state = STATE_DEFAULT;
// NO DRAW ... find the first line displayed:
str = o->text;
while (*str) {
if (line_top == o->line_top)
break;
if (*str == '\n') { // <-- new line
line_top++;
}
SetTextColor();
str++;
}
//
// HERE DRAW: DrawChar (...);
//
SDL_FillRect (screen, &o->r, 8); // bg blue
while (*str) {
// size h:
if (pos_y > (o->r.y + o->r.h)-LINE_DISTANCE)
break;
SetTextColor();
// Draw char in area of editor
if (pos_x < o->r.x+o->r.w-8) {
if (state == STATE_DEFAULT) {
if (isperator(*str)) {
color = COLOR_WHITE;
}
else
if (!is_reserved_word && !iswordchar(str[-1])) {
if ((*str >= 'a' && *str <= 'g') || *str=='i' || *str=='l' || *str=='o' || (*str >= 'r' && *str <= 'v') || *str=='w') {
// COLORIZE WORD: void
//
if (str[0]=='v' && str[1]=='o' && str[2]=='i' && str[3]=='d' && !iswordchar(str[4])) {
is_reserved_word = 4;
}
else
// COLORIZE WORD: int
if (str[0]=='i' && str[1]=='n' && str[2]=='t' && !iswordchar(str[3])) {
is_reserved_word = 3;
}
else
// COLORIZE WORD: return
if (str[0]=='r' && str[1]=='e' && str[2]=='t' && str[3]=='u' && str[4]=='r' && str[5]=='n' && !iswordchar(str[6])) {
is_reserved_word = 6;
}
}
}// if (!is_reserved_word && !iswordchar(str[-1]))
if (is_reserved_word) {
color = C_WORD; // Torn color of sintax
is_reserved_word--;
}
} // if (state == STATE_DEFAULT)
DrawChar (screen, *str, pos_x, pos_y, color);
}
pos_x += 8;
if (*str == '\n') {
pos_x = o->r.x + 10;
pos_y += LINE_DISTANCE;
}
str++;
}
SDL_UpdateRect (screen, o->r.x, o->r.y, o->r.w, o->r.h);
}
Aprenda a Gerenciar Permissões de Arquivos no Linux
Como transformar um áudio em vídeo com efeito de forma de onda (wave form)
Como aprovar Pull Requests em seu repositório Github via linha de comando
Aplicativo simples para gravar tela
Quebra de linha na data e hora no Linux Mint
Firefox não abre em usuário não administradores (0)
Sempre que vou baixar algum pacote acontece o erro dpkg (8)
tentando instalar em um notebook antigo o Linux LegacyOS_2023... [RESO... (8)
Problema com Conexão Outlook via Firewall (OpenSUSE) com Internet Fibr... (5)