diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/app.c | 18 | ||||
-rw-r--r-- | src/gmdocument.c | 2 | ||||
-rw-r--r-- | src/history.c | 10 | ||||
-rw-r--r-- | src/history.h | 9 | ||||
-rw-r--r-- | src/ui/inputwidget.c | 8 | ||||
-rw-r--r-- | src/ui/inputwidget.h | 25 |
6 files changed, 50 insertions, 22 deletions
@@ -882,13 +882,25 @@ const iString *debugInfo_App(void) { | |||
882 | extern char **environ; /* The environment variables. */ | 882 | extern char **environ; /* The environment variables. */ |
883 | iApp *d = &app_; | 883 | iApp *d = &app_; |
884 | iString *msg = collectNew_String(); | 884 | iString *msg = collectNew_String(); |
885 | iObjectList *docs = iClob(listDocuments_App(NULL)); | ||
885 | format_String(msg, "# Debug information\n"); | 886 | format_String(msg, "# Debug information\n"); |
887 | appendFormat_String(msg, "## Memory usage\n"); { | ||
888 | iMemInfo total = { 0, 0 }; | ||
889 | iForEach(ObjectList, i, docs) { | ||
890 | iDocumentWidget *doc = i.object; | ||
891 | iMemInfo usage = memoryUsage_History(history_DocumentWidget(doc)); | ||
892 | total.cacheSize += usage.cacheSize; | ||
893 | total.memorySize += usage.memorySize; | ||
894 | } | ||
895 | appendFormat_String(msg, "Total cache: %.3f MB\n", total.cacheSize / 1.0e6f); | ||
896 | appendFormat_String(msg, "Total memory: %.3f MB\n", total.memorySize / 1.0e6f); | ||
897 | } | ||
886 | appendFormat_String(msg, "## Documents\n"); | 898 | appendFormat_String(msg, "## Documents\n"); |
887 | iForEach(ObjectList, k, iClob(listDocuments_App(NULL))) { | 899 | iForEach(ObjectList, k, docs) { |
888 | iDocumentWidget *doc = k.object; | 900 | iDocumentWidget *doc = k.object; |
889 | appendFormat_String(msg, "### Tab %d.%zu: %s\n", | 901 | appendFormat_String(msg, "### Tab %d.%zu: %s\n", |
890 | constAs_Widget(doc)->root == get_Window()->roots[0] ? 0 : 1, | 902 | constAs_Widget(doc)->root == get_Window()->roots[0] ? 1 : 2, |
891 | childIndex_Widget(constAs_Widget(doc)->parent, k.object), | 903 | childIndex_Widget(constAs_Widget(doc)->parent, k.object) + 1, |
892 | cstr_String(bookmarkTitle_DocumentWidget(doc))); | 904 | cstr_String(bookmarkTitle_DocumentWidget(doc))); |
893 | append_String(msg, collect_String(debugInfo_History(history_DocumentWidget(doc)))); | 905 | append_String(msg, collect_String(debugInfo_History(history_DocumentWidget(doc)))); |
894 | } | 906 | } |
diff --git a/src/gmdocument.c b/src/gmdocument.c index 4fc0dd5e..3daa4714 100644 --- a/src/gmdocument.c +++ b/src/gmdocument.c | |||
@@ -1505,7 +1505,7 @@ static void normalize_GmDocument(iGmDocument *d) { | |||
1505 | set_String(&d->source, collect_String(normalized)); | 1505 | set_String(&d->source, collect_String(normalized)); |
1506 | printf("orig:%zu norm:%zu\n", size_String(&d->unormSource), size_String(&d->source)); | 1506 | printf("orig:%zu norm:%zu\n", size_String(&d->unormSource), size_String(&d->source)); |
1507 | /* normalized source has an extra newline at the end */ | 1507 | /* normalized source has an extra newline at the end */ |
1508 | iAssert(wasNormalized || equal_String(&d->unormSource, &d->source)); | 1508 | // iAssert(wasNormalized || equal_String(&d->unormSource, &d->source)); |
1509 | } | 1509 | } |
1510 | 1510 | ||
1511 | void setUrl_GmDocument(iGmDocument *d, const iString *url) { | 1511 | void setUrl_GmDocument(iGmDocument *d, const iString *url) { |
diff --git a/src/history.c b/src/history.c index 58ffa5c4..87cf28e6 100644 --- a/src/history.c +++ b/src/history.c | |||
@@ -108,6 +108,16 @@ iHistory *copy_History(const iHistory *d) { | |||
108 | return copy; | 108 | return copy; |
109 | } | 109 | } |
110 | 110 | ||
111 | iMemInfo memoryUsage_History(const iHistory *d) { | ||
112 | iMemInfo mem = { 0, 0 }; | ||
113 | iConstForEach(Array, i, &d->recent) { | ||
114 | const iRecentUrl *item = i.value; | ||
115 | mem.cacheSize += cacheSize_RecentUrl(item); | ||
116 | mem.memorySize += memorySize_RecentUrl(item); | ||
117 | } | ||
118 | return mem; | ||
119 | } | ||
120 | |||
111 | iString *debugInfo_History(const iHistory *d) { | 121 | iString *debugInfo_History(const iHistory *d) { |
112 | iString *str = new_String(); | 122 | iString *str = new_String(); |
113 | format_String(str, | 123 | format_String(str, |
diff --git a/src/history.h b/src/history.h index 1acf7049..ccc19d27 100644 --- a/src/history.h +++ b/src/history.h | |||
@@ -41,6 +41,13 @@ struct Impl_RecentUrl { | |||
41 | iGmDocument *cachedDoc; /* cached copy of the presentation: layout and media (not serialized) */ | 41 | iGmDocument *cachedDoc; /* cached copy of the presentation: layout and media (not serialized) */ |
42 | }; | 42 | }; |
43 | 43 | ||
44 | iDeclareType(MemInfo) | ||
45 | |||
46 | struct Impl_MemInfo { | ||
47 | size_t cacheSize; /* number of bytes stored persistently */ | ||
48 | size_t memorySize; /* number of bytes stored in RAM */ | ||
49 | }; | ||
50 | |||
44 | /*----------------------------------------------------------------------------------------------*/ | 51 | /*----------------------------------------------------------------------------------------------*/ |
45 | 52 | ||
46 | iDeclareType(History) | 53 | iDeclareType(History) |
@@ -78,4 +85,4 @@ const iGmResponse * | |||
78 | size_t cacheSize_History (const iHistory *); | 85 | size_t cacheSize_History (const iHistory *); |
79 | 86 | ||
80 | iString * debugInfo_History (const iHistory *); | 87 | iString * debugInfo_History (const iHistory *); |
81 | 88 | iMemInfo memoryUsage_History (const iHistory *); | |
diff --git a/src/ui/inputwidget.c b/src/ui/inputwidget.c index 5f86f5bf..6719fb40 100644 --- a/src/ui/inputwidget.c +++ b/src/ui/inputwidget.c | |||
@@ -658,12 +658,12 @@ void setCursor_InputWidget(iInputWidget *d, size_t pos) { | |||
658 | } | 658 | } |
659 | 659 | ||
660 | static size_t indexForRelativeX_InputWidget_(const iInputWidget *d, int x, const iInputLine *line) { | 660 | static size_t indexForRelativeX_InputWidget_(const iInputWidget *d, int x, const iInputLine *line) { |
661 | size_t index = line->offset; | ||
661 | if (x <= 0) { | 662 | if (x <= 0) { |
662 | return line->offset; | 663 | return index; |
663 | } | 664 | } |
664 | const char *endPos; | 665 | const char *endPos; |
665 | tryAdvanceNoWrap_Text(d->font, range_String(&line->text), x, &endPos); | 666 | tryAdvanceNoWrap_Text(d->font, range_String(&line->text), x, &endPos); |
666 | size_t index = line->offset; | ||
667 | if (endPos == constEnd_String(&line->text)) { | 667 | if (endPos == constEnd_String(&line->text)) { |
668 | index += length_String(&line->text); | 668 | index += length_String(&line->text); |
669 | } | 669 | } |
@@ -691,10 +691,10 @@ static iBool moveCursorByLine_InputWidget_(iInputWidget *d, int dir) { | |||
691 | } | 691 | } |
692 | if (newCursor != iInvalidPos) { | 692 | if (newCursor != iInvalidPos) { |
693 | /* Clamp it to the current line. */ | 693 | /* Clamp it to the current line. */ |
694 | newCursor = iMax(newCursor, line->offset); | ||
695 | newCursor = iMin(newCursor, line->offset + length_String(&line->text) - | 694 | newCursor = iMin(newCursor, line->offset + length_String(&line->text) - |
696 | /* last line is allowed to go to the cursorMax */ | 695 | /* last line is allowed to go to the cursorMax */ |
697 | ((const void *) line < constAt_Array(&d->lines, numLines - 1) ? 1 : 0)); | 696 | ((const void *) line < constAt_Array(&d->lines, numLines - 1) ? 1 : 0)); |
697 | newCursor = iMax(newCursor, line->offset); | ||
698 | setCursor_InputWidget(d, newCursor); | 698 | setCursor_InputWidget(d, newCursor); |
699 | return iTrue; | 699 | return iTrue; |
700 | } | 700 | } |
@@ -1311,7 +1311,7 @@ static void draw_InputWidget_(const iInputWidget *d) { | |||
1311 | .x; | 1311 | .x; |
1312 | fillRect_Paint(&p, | 1312 | fillRect_Paint(&p, |
1313 | (iRect){ addX_I2(drawPos, iMin(m1, m2)), | 1313 | (iRect){ addX_I2(drawPos, iMin(m1, m2)), |
1314 | init_I2(iAbs(m2 - m1), lineHeight_Text(d->font)) }, | 1314 | init_I2(iMax(gap_UI / 3, iAbs(m2 - m1)), lineHeight_Text(d->font)) }, |
1315 | uiMarked_ColorId); | 1315 | uiMarked_ColorId); |
1316 | } | 1316 | } |
1317 | } | 1317 | } |
diff --git a/src/ui/inputwidget.h b/src/ui/inputwidget.h index cb32a29c..70553488 100644 --- a/src/ui/inputwidget.h +++ b/src/ui/inputwidget.h | |||
@@ -41,20 +41,20 @@ struct Impl_InputWidgetContentPadding { | |||
41 | 41 | ||
42 | typedef void (*iInputWidgetValidatorFunc)(iInputWidget *, void *context); | 42 | typedef void (*iInputWidgetValidatorFunc)(iInputWidget *, void *context); |
43 | 43 | ||
44 | void setHint_InputWidget (iInputWidget *, const char *hintText); | 44 | void setHint_InputWidget (iInputWidget *, const char *hintText); |
45 | void setMode_InputWidget (iInputWidget *, enum iInputMode mode); | 45 | void setMode_InputWidget (iInputWidget *, enum iInputMode mode); |
46 | void setMaxLen_InputWidget (iInputWidget *, size_t maxLen); | 46 | void setMaxLen_InputWidget (iInputWidget *, size_t maxLen); |
47 | void setText_InputWidget (iInputWidget *, const iString *text); | 47 | void setText_InputWidget (iInputWidget *, const iString *text); |
48 | void setTextCStr_InputWidget (iInputWidget *, const char *cstr); | 48 | void setTextCStr_InputWidget (iInputWidget *, const char *cstr); |
49 | void setFont_InputWidget (iInputWidget *, int fontId); | 49 | void setFont_InputWidget (iInputWidget *, int fontId); |
50 | void setCursor_InputWidget (iInputWidget *, size_t pos); | 50 | void setCursor_InputWidget (iInputWidget *, size_t pos); |
51 | void setContentPadding_InputWidget (iInputWidget *, int left, int right); /* only affects the text entry */ | 51 | void setContentPadding_InputWidget (iInputWidget *, int left, int right); /* only affects the text entry */ |
52 | void setMaxLayoutLines_InputWidget (iInputWidget *, size_t maxLayoutLines); | 52 | void setMaxLayoutLines_InputWidget (iInputWidget *, size_t maxLayoutLines); |
53 | void setValidator_InputWidget (iInputWidget *, iInputWidgetValidatorFunc validator, void *context); | 53 | void setValidator_InputWidget (iInputWidget *, iInputWidgetValidatorFunc validator, void *context); |
54 | void setEnterKeyEnabled_InputWidget (iInputWidget *, iBool enterKeyEnabled); | 54 | void setEnterKeyEnabled_InputWidget (iInputWidget *, iBool enterKeyEnabled); |
55 | void begin_InputWidget (iInputWidget *); | 55 | void begin_InputWidget (iInputWidget *); |
56 | void end_InputWidget (iInputWidget *, iBool accept); | 56 | void end_InputWidget (iInputWidget *, iBool accept); |
57 | void selectAll_InputWidget (iInputWidget *); | 57 | void selectAll_InputWidget (iInputWidget *); |
58 | 58 | ||
59 | void setSelectAllOnFocus_InputWidget (iInputWidget *, iBool selectAllOnFocus); | 59 | void setSelectAllOnFocus_InputWidget (iInputWidget *, iBool selectAllOnFocus); |
60 | void setSensitiveContent_InputWidget (iInputWidget *, iBool isSensitive); | 60 | void setSensitiveContent_InputWidget (iInputWidget *, iBool isSensitive); |
@@ -62,9 +62,8 @@ void setUrlContent_InputWidget (iInputWidget *, iBool isUrl); | |||
62 | void setNotifyEdits_InputWidget (iInputWidget *, iBool notifyEdits); | 62 | void setNotifyEdits_InputWidget (iInputWidget *, iBool notifyEdits); |
63 | void setEatEscape_InputWidget (iInputWidget *, iBool eatEscape); | 63 | void setEatEscape_InputWidget (iInputWidget *, iBool eatEscape); |
64 | 64 | ||
65 | const iString * text_InputWidget (const iInputWidget *); | 65 | iInputWidgetContentPadding contentPadding_InputWidget (const iInputWidget *); |
66 | iInputWidgetContentPadding | 66 | const iString * text_InputWidget (const iInputWidget *); |
67 | contentPadding_InputWidget (const iInputWidget *); | ||
68 | 67 | ||
69 | iLocalDef iInputWidget *newHint_InputWidget(size_t maxLen, const char *hint) { | 68 | iLocalDef iInputWidget *newHint_InputWidget(size_t maxLen, const char *hint) { |
70 | iInputWidget *d = new_InputWidget(maxLen); | 69 | iInputWidget *d = new_InputWidget(maxLen); |