Minor code updates.

This commit is contained in:
Michael James Gratton 2017-01-01 15:19:58 +11:00
parent 503ca3b478
commit 536fb04840
2 changed files with 18 additions and 10 deletions

View file

@ -6,6 +6,14 @@
* (version 2.1 or later). See the COPYING file in this distribution.
*/
/**
* Base class for all WebKit2 WebView instances used by the Geary client.
*
* This provides common functionality expected by the client for
* displaying HTML, such as common WebKit settings, desktop font
* integration, Inspector support, and remote and inline image
* handling.
*/
public class ClientWebView : WebKit.WebView {
@ -237,9 +245,11 @@ public class ClientWebView : WebKit.WebView {
register_message_handler(REMOTE_IMAGE_LOAD_BLOCKED_MESSAGE);
register_message_handler(SELECTION_CHANGED_MESSAGE);
// Manage zoom level
config.bind(Configuration.CONVERSATION_VIEWER_ZOOM_KEY, this, "zoom_level");
this.scroll_event.connect(on_scroll_event);
// Watch desktop font settings
Settings system_settings = config.gnome_interface;
system_settings.bind("document-font-name", this,
"document-font", SettingsBindFlags.DEFAULT);

View file

@ -113,12 +113,10 @@ ComposerPageState.htmlToFlowedText = function(root) {
for (let i = nbq - 1; i >= 0; i--) {
let bq = blockquotes.item(i);
let text = bq.innerText;
console.log("Line: " + text);
if (text.substr(-1, 1) == "\n") {
text = text.slice(0, -1);
console.log(" found expected newline at end of quote!");
} else {
console.log(
console.debug(
" no newline at end of quote: " +
text.length > 0
? "0x" + text.codePointAt(text.length - 1).toString(16)
@ -201,21 +199,21 @@ ComposerPageState.resolveNesting = function(text, values) {
);
return text.replace(tokenregex, function(match, p1, p2, p3, offset, str) {
let key = new Number(p2);
let prevChar = p1;
let nextChar = p3;
let prevChars = p1;
let nextChars = p3;
let insertNext = "";
// Make sure there's a newline before and after the quote.
if (prevChar != "" && prevChar != "\n")
prevChar = prevChar + "\n";
if (nextChar != "" && nextChar != "\n")
if (prevChars != "" && prevChars != "\n")
prevChars = prevChars + "\n";
if (nextChars != "" && nextChars != "\n")
insertNext = "\n";
let value = "";
if (key >= 0 && key < values.length) {
let nested = ComposerPageState.resolveNesting(values[key], values);
value = prevChar + ComposerPageState.quoteLines(nested) + insertNext;
value = prevChars + ComposerPageState.quoteLines(nested) + insertNext;
} else {
console.log("Regex error in denesting blockquotes: Invalid key");
console.error("Regex error in denesting blockquotes: Invalid key");
}
return value;
});