Skip to content

Commit

Permalink
fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
alainm23 committed Jun 1, 2024
1 parent 6cb1ffd commit b732366
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 61 deletions.
2 changes: 1 addition & 1 deletion core/Objects/Item.vala
Original file line number Diff line number Diff line change
Expand Up @@ -1537,7 +1537,7 @@ public class Objects.Item : Objects.BaseObject {
}

public string to_markdown (int level = 0) {
string text = "%*s- %s%s%s\n".printf (level * 2, "", checked ? "[x]" : "[ ]", Utils.Datetime.get_markdown_format_date(this), content);
string text = "%*s- %s%s%s\n".printf (level * 2, "", checked ? "[x]" : "[ ]", Utils.Datetime.get_markdown_format_date (this), content);

foreach (Objects.Item item in items) {
text += item.to_markdown (level + 1);
Expand Down
14 changes: 7 additions & 7 deletions core/Util/Util.vala
Original file line number Diff line number Diff line change
Expand Up @@ -1073,30 +1073,30 @@ We hope you’ll enjoy using Planify!""");
try {
Regex mailto_regex = /(?P<mailto>[a-zA-Z0-9\._\%\+\-]+@[a-zA-Z0-9\-\.]+\.[a-zA-Z]+(\S*))/;
Regex url_regex = /(?P<url>(http|https)\:\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z]+(\/\S*))/;
Regex url_markdown = new Regex("\\[([^\\]]+)\\]\\(([^\\)]+)\\)");
Regex url_markdown = new Regex ("\\[([^\\]]+)\\]\\(([^\\)]+)\\)");

Regex italic_bold_regex = /\*\*\*(.*?)\*\*\*/;
Regex bold_regex = /\*\*(.*?)\*\*/;
Regex italic_regex = /\*(.*?)\*/;

MatchInfo info;

List<string> emails = new List<string>();
List<string> emails = new List<string> ();
if (mailto_regex.match (text, 0, out info)) {
do {
var email = info.fetch_named ("mailto");
emails.append (email);
} while (info.next ());
}

Gee.ArrayList<RegexMarkdown> markdown_urls = new Gee.ArrayList<RegexMarkdown>();
Gee.ArrayList<RegexMarkdown> markdown_urls = new Gee.ArrayList<RegexMarkdown> ();
if (url_markdown.match (text, 0, out info)) {
do {
markdown_urls.add (new RegexMarkdown (info.fetch (0), info.fetch (1), info.fetch (2)));
} while (info.next ());
}

List<string> urls = new List<string>();
List<string> urls = new List<string> ();
if (url_regex.match (text, 0, out info)) {
do {
var url = info.fetch_named ("url");
Expand All @@ -1107,21 +1107,21 @@ We hope you’ll enjoy using Planify!""");
} while (info.next ());
}

Gee.ArrayList<RegexMarkdown> bolds_01 = new Gee.ArrayList<RegexMarkdown>();
Gee.ArrayList<RegexMarkdown> bolds_01 = new Gee.ArrayList<RegexMarkdown> ();
if (bold_regex.match (text, 0, out info)) {
do {
bolds_01.add (new RegexMarkdown (info.fetch (0), info.fetch (1)));
} while (info.next ());
}

Gee.ArrayList<RegexMarkdown> italics_01 = new Gee.ArrayList<RegexMarkdown>();
Gee.ArrayList<RegexMarkdown> italics_01 = new Gee.ArrayList<RegexMarkdown> ();
if (italic_regex.match (text, 0, out info)) {
do {
italics_01.add (new RegexMarkdown (info.fetch (0), info.fetch (1)));
} while (info.next ());
}

Gee.ArrayList<RegexMarkdown> italic_bold = new Gee.ArrayList<RegexMarkdown>();
Gee.ArrayList<RegexMarkdown> italic_bold = new Gee.ArrayList<RegexMarkdown> ();
if (italic_bold_regex.match (text, 0, out info)) {
do {
italic_bold.add (new RegexMarkdown (info.fetch (0), info.fetch (1)));
Expand Down
16 changes: 8 additions & 8 deletions core/Widgets/Markdown/Color.vala
Original file line number Diff line number Diff line change
Expand Up @@ -36,33 +36,33 @@ namespace Color {
}

public inline HSL rgb_to_hsl (RGB rgb, out HSL hsl = null) {
hsl = HSL();
hsl = HSL ();
float s, v;
Gtk.rgb_to_hsv(rgb.r, rgb.g, rgb.b, out hsl.h, out s, out v);
Gtk.rgb_to_hsv (rgb.r, rgb.g, rgb.b, out hsl.h, out s, out v);
hsl.l = v - v * s / 2;
float m = float.min (hsl.l, 1 - hsl.l);
hsl.s = (m != 0) ? (v-hsl.l)/m : 0;
hsl.s = (m != 0) ? (v-hsl.l) / m : 0;
return hsl;
}

public inline RGB hsl_to_rgb (HSL hsl, out RGB rgb = null) {
rgb = RGB();
rgb = RGB ();
float v = hsl.s * float.min (hsl.l, 1 - hsl.l) + hsl.l;
float s = (v != 0) ? 2-2*hsl.l/v : 0;
Gtk.hsv_to_rgb(hsl.h, s, v, out rgb.r, out rgb.g, out rgb.b);
float s = (v != 0) ? 2 - 2 * hsl.l / v : 0;
Gtk.hsv_to_rgb (hsl.h, s, v, out rgb.r, out rgb.g, out rgb.b);
return rgb;
}

public inline RGB RGBA_to_rgb (Gdk.RGBA rgba, out RGB rgb = null) {
rgb = RGB();
rgb = RGB ();
rgb.r = rgba.red;
rgb.g = rgba.green;
rgb.b = rgba.blue;
return rgb;
}

public inline Gdk.RGBA rgb_to_RGBA (RGB rgb, out Gdk.RGBA rgba = null) {
rgba = Gdk.RGBA();
rgba = Gdk.RGBA ();
rgba.red = rgb.r;
rgba.green = rgb.g;
rgba.blue = rgb.b;
Expand Down
4 changes: 2 additions & 2 deletions core/Widgets/Markdown/MarkdownBuffer.vala
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ public class Widgets.Markdown.Buffer : GtkSource.Buffer {
Gtk.TextIter start, end;
get_start_iter (out start);
get_end_iter (out end);
return get_text(start, end, true);
return get_text (start, end, true);
}
}
}
18 changes: 9 additions & 9 deletions core/Widgets/Markdown/MarkdownEditView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@
public void on_dark_changed (bool dark) {
markdown_view.dark = dark;
}

private void format_selection (string affix, string second_affix) {
var buffer = markdown_view.buffer;

Expand Down Expand Up @@ -258,19 +258,19 @@
}

public void format_selection_bold () {
format_selection("**", "__");
format_selection ("**", "__");
}

public void format_selection_italic () {
format_selection("_", "*");
format_selection ("_", "*");
}

public void format_selection_strikethrough () {
format_selection("~~", "~");
format_selection ("~~", "~");
}

public void format_selection_highlight () {
format_selection("==", "");
format_selection ("==", "");
}

public void insert_link () {
Expand Down Expand Up @@ -335,7 +335,7 @@
}

public void insert_code_span () {
format_selection("`", "");
format_selection ("`", "");
}

public void insert_horizontal_rule () {
Expand Down Expand Up @@ -389,14 +389,14 @@
}
// Since we are now on the end condition, move forward one character as long as
// we're not at the very begining of the buffer.
if (!selection_start.is_start()) {
selection_start.forward_char();
if (!selection_start.is_start ()) {
selection_start.forward_char ();
}
current_char = selection_end.get_char ();
// If we're at the end of line, we're done.
if( current_char != '\n') {
while (current_char != '\n' && current_char != ' ' && current_char != '\t' && !selection_end.is_end ()) {
selection_end.forward_char();
selection_end.forward_char ();
current_char = selection_end.get_char ();
}
}
Expand Down
62 changes: 31 additions & 31 deletions core/Widgets/Markdown/MarkdownView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public class Widgets.Markdown.View : GtkSource.View {
}
Gtk.TextIter start;
buffer.get_iter_at_line (out start, (int) line);
var str = string.nfill(level - old_title_level, '#');
var str = string.nfill (level - old_title_level, '#');
buffer.insert (ref start, str, str.length);
} else {
Gtk.TextIter start;
Expand All @@ -144,7 +144,7 @@ public class Widgets.Markdown.View : GtkSource.View {
public bool check_if_bare_link (string text) {
MatchInfo matches;
try {
if( is_bare_link.match_full (text, text.length, 0, 0, out matches) ) {
if( is_bare_link.match_full (text, text.length, 0, 0, out matches)) {
return true;
}
} catch (Error e) {}
Expand All @@ -154,7 +154,7 @@ public class Widgets.Markdown.View : GtkSource.View {
public bool check_if_email_link (string text) {
MatchInfo matches;
try {
if( is_email_link.match_full (text, text.length, 0, 0, out matches) ) {
if (is_email_link.match_full (text, text.length, 0, 0, out matches)) {
return true;
}
} catch (Error e) {}
Expand All @@ -176,7 +176,7 @@ public class Widgets.Markdown.View : GtkSource.View {
link_url = "";

try {
if (is_link.match_full (buffer_text, buffer_text.length, 0, 0, out matches) ) {
if (is_link.match_full (buffer_text, buffer_text.length, 0, 0, out matches)) {
do {
int start_text_pos, end_text_pos;
int start_url_pos, end_url_pos;
Expand All @@ -188,12 +188,12 @@ public class Widgets.Markdown.View : GtkSource.View {
start_text_pos = buffer_text.char_count ((ssize_t) start_text_pos);
end_url_pos = buffer_text.char_count ((ssize_t) end_url_pos);

if( cursor_offset <= end_url_pos && cursor_offset >= start_text_pos ) {
if (cursor_offset <= end_url_pos && cursor_offset >= start_text_pos) {
found_match = true;
link_url = buffer_text.slice (start_url_pos + 1, end_url_pos - 1);
}
}
} while (matches.next());
} while (matches.next ());
}
} catch (RegexError e) {}

Expand All @@ -204,7 +204,7 @@ public class Widgets.Markdown.View : GtkSource.View {
var buffer = markdown_view.buffer;
Regex affix_regex;

switch( affix ) {
switch (affix) {
case "**":
affix_regex = is_bold_0;
break;
Expand Down Expand Up @@ -249,8 +249,8 @@ public class Widgets.Markdown.View : GtkSource.View {
if (affix_regex.match_full (buffer_text, buffer_text.length, 0, 0, out matches) ) {
do {
int start_before_pos, end_before_pos;
int start_code_pos, end_code_pos;
int start_after_pos, end_after_pos;
int start_code_pos, end_code_pos;
int start_after_pos, end_after_pos;
bool have_code_start = matches.fetch_pos (1, out start_before_pos, out end_before_pos);
bool have_code = matches.fetch_pos (2, out start_code_pos, out end_code_pos);
bool have_code_close = matches.fetch_pos (3, out start_after_pos, out end_after_pos);
Expand All @@ -265,16 +265,16 @@ public class Widgets.Markdown.View : GtkSource.View {

// Convert the character offsets to TextIter's
Gtk.TextIter start_before_iter, end_before_iter;
Gtk.TextIter start_code_iter, end_code_iter;
Gtk.TextIter start_after_iter, end_after_iter;
Gtk.TextIter start_code_iter, end_code_iter;
Gtk.TextIter start_after_iter, end_after_iter;
buffer.get_iter_at_offset (out start_before_iter, start_before_pos);
buffer.get_iter_at_offset (out end_before_iter, end_before_pos);
buffer.get_iter_at_offset (out start_code_iter, start_code_pos);
buffer.get_iter_at_offset (out end_code_iter, end_code_pos);
buffer.get_iter_at_offset (out start_after_iter, start_after_pos);
buffer.get_iter_at_offset (out end_after_iter, end_after_pos);

if( cursor_offset <= end_after_pos && cursor_offset >= start_before_pos ) {
if (cursor_offset <= end_after_pos && cursor_offset >= start_before_pos) {
// First remove the tag from the text buffer.
buffer.remove_tag (buffer.tag_table.lookup ("markdown-bold"), start_before_iter, end_after_iter);

Expand All @@ -297,7 +297,7 @@ public class Widgets.Markdown.View : GtkSource.View {
found_match = true;
}
}
} while (matches.next());
} while (matches.next ());
}
} catch (Error e) {}

Expand Down Expand Up @@ -522,7 +522,7 @@ public class Widgets.Markdown.View : GtkSource.View {
var bold_f = (last_i - int.min (i, last_i - 1) - 1) / (float) last_i;
tag.weight = 600 + (int) (bold_f * 300);
var scale_f = (last_i - i) / (float) last_i;
tag.scale = 1.0f + interpolate(scale_f) * 1.4f;
tag.scale = 1.0f + interpolate (scale_f) * 1.4f;
if (i == last_i)
tag.foreground_rgba = h6_color;
tags[i] = tag;
Expand Down Expand Up @@ -1024,7 +1024,7 @@ public class Widgets.Markdown.View : GtkSource.View {
end_pos = buffer_text.char_count ((ssize_t) end_pos);

// Convert the character offsets to TextIter's
Gtk.TextIter start_iter, end_iter;
Gtk.TextIter start_iter, end_iter;
buffer.get_iter_at_offset (out start_iter, start_pos);
buffer.get_iter_at_offset (out end_iter, end_pos);

Expand Down Expand Up @@ -1055,7 +1055,7 @@ public class Widgets.Markdown.View : GtkSource.View {

// Convert the character offsets to TextIter's
Gtk.TextIter start_marker_iter, end_marker_iter;
Gtk.TextIter start_full_iter, end_full_iter;
Gtk.TextIter start_full_iter, end_full_iter;
buffer.get_iter_at_offset (out start_marker_iter, start_marker_pos);
buffer.get_iter_at_offset (out end_marker_iter, end_marker_pos);
buffer.get_iter_at_offset (out start_full_iter, start_full_pos);
Expand Down Expand Up @@ -1183,8 +1183,8 @@ public class Widgets.Markdown.View : GtkSource.View {
if (is_code_block.match_full (buffer_text, buffer_text.length, 0, 0, out matches)) {
do {
int start_before_pos, end_before_pos;
int start_code_pos, end_code_pos;
int start_after_pos, end_after_pos;
int start_code_pos, end_code_pos;
int start_after_pos, end_after_pos;
bool have_code_start = matches.fetch_pos (1, out start_before_pos, out end_before_pos);
bool have_code = matches.fetch_pos (2, out start_code_pos, out end_code_pos);
bool have_code_close = matches.fetch_pos (3, out start_after_pos, out end_after_pos);
Expand All @@ -1199,8 +1199,8 @@ public class Widgets.Markdown.View : GtkSource.View {

// Convert the character offsets to TextIter's
Gtk.TextIter start_before_iter, end_before_iter;
Gtk.TextIter start_code_iter, end_code_iter;
Gtk.TextIter start_after_iter, end_after_iter;
Gtk.TextIter start_code_iter, end_code_iter;
Gtk.TextIter start_after_iter, end_after_iter;
buffer.get_iter_at_offset (out start_before_iter, start_before_pos);
buffer.get_iter_at_offset (out end_before_iter, end_before_pos);
buffer.get_iter_at_offset (out start_code_iter, start_code_pos);
Expand Down Expand Up @@ -1233,8 +1233,8 @@ public class Widgets.Markdown.View : GtkSource.View {
if (regex.match_full (buffer_text, buffer_text.length, 0, 0, out matches)) {
do {
int start_before_pos, end_before_pos;
int start_code_pos, end_code_pos;
int start_after_pos, end_after_pos;
int start_code_pos, end_code_pos;
int start_after_pos, end_after_pos;
bool have_code_start = matches.fetch_pos (1, out start_before_pos, out end_before_pos);
bool have_code = matches.fetch_pos (2, out start_code_pos, out end_code_pos);
bool have_code_close = matches.fetch_pos (3, out start_after_pos, out end_after_pos);
Expand All @@ -1249,8 +1249,8 @@ public class Widgets.Markdown.View : GtkSource.View {

// Convert the character offsets to TextIter's
Gtk.TextIter start_before_iter, end_before_iter;
Gtk.TextIter start_code_iter, end_code_iter;
Gtk.TextIter start_after_iter, end_after_iter;
Gtk.TextIter start_code_iter, end_code_iter;
Gtk.TextIter start_after_iter, end_after_iter;
buffer.get_iter_at_offset (out start_before_iter, start_before_pos);
buffer.get_iter_at_offset (out end_before_iter, end_before_pos);
buffer.get_iter_at_offset (out start_code_iter, start_code_pos);
Expand All @@ -1259,9 +1259,9 @@ public class Widgets.Markdown.View : GtkSource.View {
buffer.get_iter_at_offset (out end_after_iter, end_after_pos);

// Check to see if the tag has already been applied, if so, skip it.
if (start_code_iter.has_tag (text_tag) &&
end_code_iter.has_tag (text_tag) &&
start_before_iter.has_tag (text_tag_around) &&
if (start_code_iter.has_tag (text_tag) &&
end_code_iter.has_tag (text_tag) &&
start_before_iter.has_tag (text_tag_around) &&
start_after_iter.has_tag (text_tag_around)
) {
continue;
Expand Down Expand Up @@ -1289,8 +1289,8 @@ public class Widgets.Markdown.View : GtkSource.View {
if (regex.match_full (buffer_text, buffer_text.length, 0, 0, out matches)) {
do {
int start_before_pos, end_before_pos;
int start_code_pos, end_code_pos;
int start_after_pos, end_after_pos;
int start_code_pos, end_code_pos;
int start_after_pos, end_after_pos;
bool have_code_start = matches.fetch_pos (1, out start_before_pos, out end_before_pos);
bool have_code = matches.fetch_pos (2, out start_code_pos, out end_code_pos);
bool have_code_close = matches.fetch_pos (3, out start_after_pos, out end_after_pos);
Expand All @@ -1305,8 +1305,8 @@ public class Widgets.Markdown.View : GtkSource.View {

// Convert the character offsets to TextIter's
Gtk.TextIter start_before_iter, end_before_iter;
Gtk.TextIter start_code_iter, end_code_iter;
Gtk.TextIter start_after_iter, end_after_iter;
Gtk.TextIter start_code_iter, end_code_iter;
Gtk.TextIter start_after_iter, end_after_iter;
buffer.get_iter_at_offset (out start_before_iter, start_before_pos);
buffer.get_iter_at_offset (out end_before_iter, end_before_pos);
buffer.get_iter_at_offset (out start_code_iter, start_code_pos);
Expand Down
3 changes: 1 addition & 2 deletions search-provider/search-provider.vala
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,4 @@ public class Planify.SearchProvider : Gtk.Application {

return true;
}

}
}
Loading

0 comments on commit b732366

Please sign in to comment.