
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);
}
Como atualizar sua versão estável do Debian
Cirurgia para acelerar o openSUSE em HD externo via USB
Void Server como Domain Control
Quer auto-organizar janelas (tiling) no seu Linux? Veja como no Plasma 6 e no Gnome
Copiando caminho atual do terminal direto para o clipboard do teclado
Script de montagem de chroot automatica
Instalar Dual Boot, Linux+Windows. (8)
Eaí? Já programou no windows? (2)
Erro ao enviar arquivos para o Storage Synology NAS (0)
Conky, alerta de temperatura alta (17)
De volta para o futuro - ou melhor, para o presente (parte 2) (3)









