Skip to content

Commit ff5902f

Browse files
authored
Merge branch 'main' into pixelbuf-iterable
2 parents 1b7709f + a28d0f6 commit ff5902f

File tree

96 files changed

+5384
-286
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

96 files changed

+5384
-286
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,7 @@ jobs:
253253
- "pca10100"
254254
- "pewpew10"
255255
- "pewpew_m4"
256+
- "picoplanet"
256257
- "pirkey_m0"
257258
- "pitaya_go"
258259
- "pyb_nano_v2"

.readthedocs.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88

99
version: 2
1010

11+
submodules:
12+
include:
13+
- extmod/ulab
14+
1115
python:
1216
version: 3
1317
install:

lib/mp-readline/readline.c

Lines changed: 58 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,16 @@ STATIC char *str_dup_maybe(const char *str) {
5858
return s2;
5959
}
6060

61+
STATIC size_t count_cont_bytes(char *start, char *end) {
62+
int count = 0;
63+
for (char *pos = start; pos < end; pos++) {
64+
if(UTF8_IS_CONT(*pos)) {
65+
count++;
66+
}
67+
}
68+
return count;
69+
}
70+
6171
// By default assume terminal which implements VT100 commands...
6272
#ifndef MICROPY_HAL_HAS_VT100
6373
#define MICROPY_HAL_HAS_VT100 (1)
@@ -92,14 +102,16 @@ typedef struct _readline_t {
92102
int escape_seq;
93103
int hist_cur;
94104
size_t cursor_pos;
105+
uint8_t utf8_cont_chars;
95106
char escape_seq_buf[1];
96107
const char *prompt;
97108
} readline_t;
98109

99110
STATIC readline_t rl;
100111

101112
int readline_process_char(int c) {
102-
size_t last_line_len = rl.line->len;
113+
size_t last_line_len = utf8_charlen((byte *)rl.line->buf, rl.line->len);
114+
int cont_chars = 0;
103115
int redraw_step_back = 0;
104116
bool redraw_from_cursor = false;
105117
int redraw_step_forward = 0;
@@ -178,6 +190,12 @@ int readline_process_char(int c) {
178190
int nspace = 1;
179191
#endif
180192

193+
// Check if we have moved into a UTF-8 continuation byte
194+
while (UTF8_IS_CONT(rl.line->buf[rl.cursor_pos-nspace])) {
195+
nspace++;
196+
cont_chars++;
197+
}
198+
181199
// do the backspace
182200
vstr_cut_out_bytes(rl.line, rl.cursor_pos - nspace, nspace);
183201
// set redraw parameters
@@ -206,12 +224,27 @@ int readline_process_char(int c) {
206224
redraw_step_forward = compl_len;
207225
}
208226
#endif
209-
} else if (32 <= c ) {
227+
} else if (32 <= c) {
210228
// printable character
211-
vstr_ins_char(rl.line, rl.cursor_pos, c);
212-
// set redraw parameters
213-
redraw_from_cursor = true;
214-
redraw_step_forward = 1;
229+
char lcp = rl.line->buf[rl.cursor_pos];
230+
uint8_t cont_need = 0;
231+
if (!UTF8_IS_CONT(c)) {
232+
// ASCII or Lead code point
233+
rl.utf8_cont_chars = 0;
234+
lcp = c;
235+
}else {
236+
rl.utf8_cont_chars += 1;
237+
}
238+
if (lcp >= 0xc0 && lcp < 0xf8) {
239+
cont_need = (0xe5 >> ((lcp >> 3) & 0x6)) & 3; // From unicode.c L195
240+
}
241+
vstr_ins_char(rl.line, rl.cursor_pos+rl.utf8_cont_chars, c);
242+
// set redraw parameters if we have the entire character
243+
if (rl.utf8_cont_chars == cont_need) {
244+
redraw_from_cursor = true;
245+
redraw_step_forward = rl.utf8_cont_chars+1;
246+
cont_chars = rl.utf8_cont_chars;
247+
}
215248
}
216249
} else if (rl.escape_seq == ESEQ_ESC) {
217250
switch (c) {
@@ -237,6 +270,8 @@ int readline_process_char(int c) {
237270
#endif
238271
// up arrow
239272
if (rl.hist_cur + 1 < (int)READLINE_HIST_SIZE && MP_STATE_PORT(readline_hist)[rl.hist_cur + 1] != NULL) {
273+
// Check for continuation characters
274+
cont_chars = count_cont_bytes(rl.line->buf+rl.orig_line_len, rl.line->buf+rl.cursor_pos);
240275
// increase hist num
241276
rl.hist_cur += 1;
242277
// set line to history
@@ -253,6 +288,8 @@ int readline_process_char(int c) {
253288
#endif
254289
// down arrow
255290
if (rl.hist_cur >= 0) {
291+
// Check for continuation characters
292+
cont_chars = count_cont_bytes(rl.line->buf+rl.orig_line_len, rl.line->buf+rl.cursor_pos);
256293
// decrease hist num
257294
rl.hist_cur -= 1;
258295
// set line to history
@@ -272,6 +309,11 @@ int readline_process_char(int c) {
272309
// right arrow
273310
if (rl.cursor_pos < rl.line->len) {
274311
redraw_step_forward = 1;
312+
// Check if we have moved into a UTF-8 continuation byte
313+
while (UTF8_IS_CONT(rl.line->buf[rl.cursor_pos+redraw_step_forward]) &&
314+
rl.cursor_pos+redraw_step_forward < rl.line->len) {
315+
redraw_step_forward++;
316+
}
275317
}
276318
} else if (c == 'D') {
277319
#if MICROPY_REPL_EMACS_KEYS
@@ -280,6 +322,11 @@ int readline_process_char(int c) {
280322
// left arrow
281323
if (rl.cursor_pos > rl.orig_line_len) {
282324
redraw_step_back = 1;
325+
// Check if we have moved into a UTF-8 continuation byte
326+
while (UTF8_IS_CONT(rl.line->buf[rl.cursor_pos-redraw_step_back])) {
327+
redraw_step_back++;
328+
cont_chars++;
329+
}
283330
}
284331
} else if (c == 'H') {
285332
// home
@@ -331,18 +378,20 @@ int readline_process_char(int c) {
331378

332379
// redraw command prompt, efficiently
333380
if (redraw_step_back > 0) {
334-
mp_hal_move_cursor_back(redraw_step_back);
381+
mp_hal_move_cursor_back(redraw_step_back-cont_chars);
335382
rl.cursor_pos -= redraw_step_back;
336383
}
337384
if (redraw_from_cursor) {
338-
if (rl.line->len < last_line_len) {
385+
if (utf8_charlen((byte *)rl.line->buf, rl.line->len) < last_line_len) {
339386
// erase old chars
340387
mp_hal_erase_line_from_cursor(last_line_len - rl.cursor_pos);
341388
}
389+
// Check for continuation characters
390+
cont_chars = count_cont_bytes(rl.line->buf+rl.cursor_pos+redraw_step_forward, rl.line->buf+rl.line->len);
342391
// draw new chars
343392
mp_hal_stdout_tx_strn(rl.line->buf + rl.cursor_pos, rl.line->len - rl.cursor_pos);
344393
// move cursor forward if needed (already moved forward by length of line, so move it back)
345-
mp_hal_move_cursor_back(rl.line->len - (rl.cursor_pos + redraw_step_forward));
394+
mp_hal_move_cursor_back(rl.line->len - (rl.cursor_pos + redraw_step_forward) - cont_chars);
346395
rl.cursor_pos += redraw_step_forward;
347396
} else if (redraw_step_forward > 0) {
348397
// draw over old chars to move cursor forwards

locale/ID.po

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ msgid ""
55
msgstr ""
66
"Project-Id-Version: PACKAGE VERSION\n"
77
"Report-Msgid-Bugs-To: \n"
8-
"POT-Creation-Date: 2020-07-30 07:23-0500\n"
8+
"POT-Creation-Date: 2020-07-28 16:57-0500\n"
99
"PO-Revision-Date: 2020-07-06 18:10+0000\n"
1010
"Last-Translator: oon arfiandwi <[email protected]>\n"
1111
"Language-Team: LANGUAGE <[email protected]>\n"
@@ -882,10 +882,6 @@ msgstr "operasi I/O pada file tertutup"
882882
msgid "I2C Init Error"
883883
msgstr "Gagal Inisialisasi I2C"
884884

885-
#: shared-bindings/audiobusio/I2SOut.c
886-
msgid "I2SOut not available"
887-
msgstr ""
888-
889885
#: shared-bindings/aesio/aes.c
890886
#, c-format
891887
msgid "IV must be %d bytes long"

locale/circuitpython.pot

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ msgid ""
88
msgstr ""
99
"Project-Id-Version: PACKAGE VERSION\n"
1010
"Report-Msgid-Bugs-To: \n"
11-
"POT-Creation-Date: 2020-08-08 18:40-0400\n"
11+
"POT-Creation-Date: 2020-08-11 15:37-0500\n"
1212
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
1313
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
1414
"Language-Team: LANGUAGE <[email protected]>\n"
@@ -447,6 +447,10 @@ msgstr ""
447447
msgid "Buffer length must be a multiple of 512"
448448
msgstr ""
449449

450+
#: ports/stm/common-hal/sdioio/SDCard.c
451+
msgid "Buffer must be a multiple of 512 bytes"
452+
msgstr ""
453+
450454
#: shared-bindings/bitbangio/I2C.c shared-bindings/busio/I2C.c
451455
msgid "Buffer must be at least length 1"
452456
msgstr ""
@@ -819,6 +823,11 @@ msgstr ""
819823
msgid "File exists"
820824
msgstr ""
821825

826+
#: shared-module/framebufferio/FramebufferDisplay.c
827+
#, c-format
828+
msgid "Framebuffer requires %d bytes"
829+
msgstr ""
830+
822831
#: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c
823832
msgid "Frequency captured is above capability. Capture Paused."
824833
msgstr ""
@@ -843,7 +852,7 @@ msgid "Group full"
843852
msgstr ""
844853

845854
#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/I2C.c
846-
#: ports/stm/common-hal/busio/SPI.c
855+
#: ports/stm/common-hal/busio/SPI.c ports/stm/common-hal/sdioio/SDCard.c
847856
msgid "Hardware busy, try alternative pins"
848857
msgstr ""
849858

@@ -908,6 +917,11 @@ msgstr ""
908917
msgid "Invalid %q pin"
909918
msgstr ""
910919

920+
#: ports/stm/common-hal/busio/I2C.c ports/stm/common-hal/busio/SPI.c
921+
#: ports/stm/common-hal/busio/UART.c ports/stm/common-hal/sdioio/SDCard.c
922+
msgid "Invalid %q pin selection"
923+
msgstr ""
924+
911925
#: ports/stm/common-hal/analogio/AnalogIn.c
912926
msgid "Invalid ADC Unit value"
913927
msgstr ""
@@ -920,24 +934,12 @@ msgstr ""
920934
msgid "Invalid DAC pin supplied"
921935
msgstr ""
922936

923-
#: ports/stm/common-hal/busio/I2C.c
924-
msgid "Invalid I2C pin selection"
925-
msgstr ""
926-
927937
#: ports/atmel-samd/common-hal/pulseio/PWMOut.c
928938
#: ports/cxd56/common-hal/pulseio/PWMOut.c
929939
#: ports/nrf/common-hal/pulseio/PWMOut.c shared-bindings/pulseio/PWMOut.c
930940
msgid "Invalid PWM frequency"
931941
msgstr ""
932942

933-
#: ports/stm/common-hal/busio/SPI.c
934-
msgid "Invalid SPI pin selection"
935-
msgstr ""
936-
937-
#: ports/stm/common-hal/busio/UART.c
938-
msgid "Invalid UART pin selection"
939-
msgstr ""
940-
941943
#: py/moduerrno.c shared-module/rgbmatrix/RGBMatrix.c
942944
msgid "Invalid argument"
943945
msgstr ""
@@ -1406,6 +1408,16 @@ msgstr ""
14061408
msgid "SDA or SCL needs a pull up"
14071409
msgstr ""
14081410

1411+
#: ports/stm/common-hal/sdioio/SDCard.c
1412+
#, c-format
1413+
msgid "SDIO GetCardInfo Error %d"
1414+
msgstr ""
1415+
1416+
#: ports/stm/common-hal/sdioio/SDCard.c
1417+
#, c-format
1418+
msgid "SDIO Init Error %d"
1419+
msgstr ""
1420+
14091421
#: ports/stm/common-hal/busio/SPI.c
14101422
msgid "SPI Init Error"
14111423
msgstr ""

locale/cs.po

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ msgid ""
55
msgstr ""
66
"Project-Id-Version: PACKAGE VERSION\n"
77
"Report-Msgid-Bugs-To: \n"
8-
"POT-Creation-Date: 2020-07-30 07:23-0500\n"
8+
"POT-Creation-Date: 2020-07-28 16:57-0500\n"
99
"PO-Revision-Date: 2020-05-24 03:22+0000\n"
1010
"Last-Translator: dronecz <[email protected]>\n"
1111
"Language-Team: LANGUAGE <[email protected]>\n"
@@ -44,11 +44,11 @@ msgstr ""
4444

4545
#: py/obj.c
4646
msgid " File \"%q\""
47-
msgstr "  Soubor \"%q\""
47+
msgstr "  Soubor \"% q\""
4848

4949
#: py/obj.c
5050
msgid " File \"%q\", line %d"
51-
msgstr "  Soubor \"%q\", řádek %d"
51+
msgstr "  Soubor \"% q\", řádek% d"
5252

5353
#: main.c
5454
msgid " output:\n"
@@ -57,7 +57,7 @@ msgstr " výstup:\n"
5757
#: py/objstr.c
5858
#, c-format
5959
msgid "%%c requires int or char"
60-
msgstr "%%c vyžaduje int nebo char"
60+
msgstr "%% c vyžaduje int nebo char"
6161

6262
#: shared-bindings/rgbmatrix/RGBMatrix.c
6363
#, c-format
@@ -78,11 +78,11 @@ msgstr "%q index je mimo rozsah"
7878

7979
#: py/obj.c
8080
msgid "%q indices must be integers, not %s"
81-
msgstr "Indexy %q musí být celá čísla, nikoli %s"
81+
msgstr "Indexy% q musí být celá čísla, nikoli% s"
8282

8383
#: shared-bindings/vectorio/Polygon.c
8484
msgid "%q list must be a list"
85-
msgstr "Seznam %q musí být seznam"
85+
msgstr "Seznam% q musí být seznam"
8686

8787
#: shared-bindings/memorymonitor/AllocationAlarm.c
8888
msgid "%q must be >= 0"
@@ -94,19 +94,19 @@ msgstr ""
9494
#: shared-bindings/memorymonitor/AllocationAlarm.c
9595
#: shared-bindings/vectorio/Circle.c shared-bindings/vectorio/Rectangle.c
9696
msgid "%q must be >= 1"
97-
msgstr " %q musí být > = 1"
97+
msgstr "% q musí být > = 1"
9898

9999
#: shared-module/vectorio/Polygon.c
100100
msgid "%q must be a tuple of length 2"
101-
msgstr " %q musí být n-tice délky 2"
101+
msgstr "% q musí být n-tice délky 2"
102102

103103
#: ports/atmel-samd/common-hal/sdioio/SDCard.c
104104
msgid "%q pin invalid"
105105
msgstr ""
106106

107107
#: shared-bindings/fontio/BuiltinFont.c
108108
msgid "%q should be an int"
109-
msgstr " %q by měl být int"
109+
msgstr "% q by měl být int"
110110

111111
#: py/bc.c py/objnamedtuple.c
112112
msgid "%q() takes %d positional arguments but %d were given"
@@ -867,10 +867,6 @@ msgstr ""
867867
msgid "I2C Init Error"
868868
msgstr ""
869869

870-
#: shared-bindings/audiobusio/I2SOut.c
871-
msgid "I2SOut not available"
872-
msgstr ""
873-
874870
#: shared-bindings/aesio/aes.c
875871
#, c-format
876872
msgid "IV must be %d bytes long"

locale/de_DE.po

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ msgid ""
55
msgstr ""
66
"Project-Id-Version: \n"
77
"Report-Msgid-Bugs-To: \n"
8-
"POT-Creation-Date: 2020-07-30 07:23-0500\n"
8+
"POT-Creation-Date: 2020-07-28 16:57-0500\n"
99
"PO-Revision-Date: 2020-06-16 18:24+0000\n"
1010
"Last-Translator: Andreas Buchen <[email protected]>\n"
1111
"Language: de_DE\n"
@@ -882,10 +882,6 @@ msgstr "Lese/Schreibe-operation an geschlossener Datei"
882882
msgid "I2C Init Error"
883883
msgstr "I2C-Init-Fehler"
884884

885-
#: shared-bindings/audiobusio/I2SOut.c
886-
msgid "I2SOut not available"
887-
msgstr ""
888-
889885
#: shared-bindings/aesio/aes.c
890886
#, c-format
891887
msgid "IV must be %d bytes long"
@@ -3487,12 +3483,12 @@ msgstr ""
34873483
#~ msgid "'async for' or 'async with' outside async function"
34883484
#~ msgstr "'async for' oder 'async with' außerhalb der asynchronen Funktion"
34893485

3490-
#~ msgid "PulseIn not supported on this chip"
3491-
#~ msgstr "PulseIn wird auf diesem Chip nicht unterstützt"
3492-
34933486
#~ msgid "PulseOut not supported on this chip"
34943487
#~ msgstr "PulseOut wird auf diesem Chip nicht unterstützt"
34953488

3489+
#~ msgid "PulseIn not supported on this chip"
3490+
#~ msgstr "PulseIn wird auf diesem Chip nicht unterstützt"
3491+
34963492
#~ msgid "AP required"
34973493
#~ msgstr "AP erforderlich"
34983494

0 commit comments

Comments
 (0)