Пример #1
0
void LCD_PrintString(const char *str)
{
    while(*str != 0) {
        u32 ch;
        str = utf8_to_u32(str, &ch);
        LCD_PrintChar(ch);
    }
}
Пример #2
0
/**
 * Process a request coming from the client and update the response object with
 * the results of the request.
 */
void ProjectHandler::process(spRequest &request, spResponse &response) {
  // Message error
  if (!request->IsInitialized()) {
    response->set_code(Response::ERROR);
    response->set_body("Invalid message");
    return;
  }

  u32string projectId = utf8_to_u32(request->projectid());
  spProject project = getProject(projectId);

  // Project information request
  if (request->action() == Request::PROJECT) {
    response->set_code(Response::OK_PROJECT);
    // TODO: set body
    return;
  }

  // Compilation request
  if (request->action() == Request::COMPILE) {
    Request::CompilationUnit unit = request->unit();

    u32string filename = utf8_to_u32(unit.filename());
    u32string buffer = utf8_to_u32(unit.buffer());

    spCompilation comp = make_shared<Compilation>(filename, buffer);
    project->compile(comp);

    response->set_code(Response::OK_COMPILE);
    string output = u32_to_utf8(comp->output);
    response->set_body(output);
    return;
  }

  // invalid action
  response->set_code(Response::ERROR);
  response->set_body("Invalid action");
  return;
}
Пример #3
0
void LCD_GetStringDimensions(const u8 *str, u16 *width, u16 *height) {
    int line_width = 0;
    *height = HEIGHT(cur_str.font);
    *width = 0;
    //printf("String: %s\n", str);
    while(*str) {
        u32 ch;
        str = (const u8 *)utf8_to_u32((const char *)str, &ch);
        if(ch == '\n') {
            *height += HEIGHT(cur_str.font) + LINE_SPACING;
            if(line_width > *width)
                *width = line_width;
            line_width = 0;
        } else {
            line_width += get_width(ch) + CHAR_SPACING;
        }
    }
    if(line_width > *width)
        *width = line_width;
    //printf("W: %d   H: %d\n",(int)*width,(int)*height);
}