Can now receive code snippets from a phone!
Font adjustment tries (cheaply) to account for newlines
This commit is contained in:
parent
dd7efae6b1
commit
c0f7213110
|
@ -21,7 +21,10 @@
|
|||
},
|
||||
"projectType": "native",
|
||||
"uuid": "70ec170a-8e1b-11ea-bc55-0242ac130003",
|
||||
"messageKeys": {},
|
||||
"messageKeys": {
|
||||
"ScriptNum": 0,
|
||||
"ScriptText": 1
|
||||
},
|
||||
"enableMultiJS": false,
|
||||
"displayName": "PebbLisp",
|
||||
"watchapp": {
|
||||
|
|
25
src/calc.c
25
src/calc.c
|
@ -64,10 +64,15 @@ static const int smallestFont = 3;
|
|||
static void adjustFont()
|
||||
{
|
||||
int i = 0;
|
||||
while(temptext[i++]) {}
|
||||
int f = i < 50 ? smallestFont - 3 :
|
||||
i < 100 ? smallestFont - 2 :
|
||||
i < 130 ? smallestFont - 1 :
|
||||
int size = 0;
|
||||
while(temptext[i++]) {
|
||||
if(temptext[i] == '\n')
|
||||
size += 10;
|
||||
size++;
|
||||
}
|
||||
int f = size < 50 ? smallestFont - 3 :
|
||||
size < 100 ? smallestFont - 2 :
|
||||
size < 130 ? smallestFont - 1 :
|
||||
smallestFont;
|
||||
text_layer_set_font(s_input_text_layer,
|
||||
fonts_get_system_font(fonts[f]));
|
||||
|
@ -321,6 +326,16 @@ Object add_window(Object obj1, Object obj2, struct Environment *env)
|
|||
return numberObject(1);
|
||||
}
|
||||
|
||||
static void inbox_received_callback(DictionaryIterator *iter, void *context) {
|
||||
Tuple *script_tuple = dict_find(iter, MESSAGE_KEY_ScriptText);
|
||||
if(script_tuple) {
|
||||
char *script_text = script_tuple->value->cstring;
|
||||
snprintf(temptext, sizeof(temptext), "%s", script_text);
|
||||
snprintf(mytext, sizeof(mytext), "%s", script_text);
|
||||
updateText();
|
||||
}
|
||||
}
|
||||
|
||||
/** General **/
|
||||
|
||||
static struct Environment pebbleEnv()
|
||||
|
@ -341,6 +356,8 @@ static void init(void)
|
|||
.unload = menu_unload
|
||||
});
|
||||
window_stack_push(s_menu_window, true);
|
||||
app_message_open(inbox_size, outbox_size);
|
||||
app_message_register_inbox_received(inbox_received_callback);
|
||||
}
|
||||
|
||||
static void deinit(void)
|
||||
|
|
|
@ -64,6 +64,9 @@ const char *func_tokens[] = {
|
|||
"sq ", "cube ", "exp "
|
||||
};
|
||||
|
||||
const uint32_t inbox_size = 1024;
|
||||
const uint32_t outbox_size = 64;
|
||||
|
||||
bool using_func_tokens = false;
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue