Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: ToDo widget text highlighting #2452

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

wshoy
Copy link
Contributor

@wshoy wshoy commented Oct 18, 2024

Where should I get color from?

  • fix color

@harshad1
Copy link
Collaborator

See how the text in the Todo txt dialogs are highlighted. This will be a 1 function call

@@ -86,4 +94,84 @@ public long getItemId(int position) {
public boolean hasStableIds() {
return false;
}

private Spannable getTaskSpannable(TodoTxtTask task) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This static function will return a highlighter callable which can apply todotxt highlighting to a spannable.

https://github.com/gsantner/markor/blob/master/app/src/main/java/net/gsantner/markor/frontend/MarkorDialogFactory.java#L758

So simply

final GsCallback.a1<Spannable> hl = getSttHighlighter();
for (Spannable s : lines) {
    hl.callback(s)
}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will highlight every line in lines

You will need to make getSttHighlighter public and move it somewhere appropriate.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

final GsCallback.a1<Spannable> hl = getSttHighlighter();
Spannable s = new SpannableString(_tasks.get(position).getLine());
hl.callback(s);
views.setTextViewText(R.id.todo_widget_item_text, s);

I couldn't make it work. What is wrong here?

It's also very important to remove creation dates, priority parentheses, etc. as they take up valuable space especially on narrower screens. How would that be achieved?,

@gsantner
Copy link
Owner

from me:

  • best reuse as much possible from existing highlighting stuff and colors
  • try to keep todo.txt specific a bit separated, with that in mind that it is to be expanded to other filetypes / other textedit widget in future

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Document editing launcher widget - Widget Show contents of 1 files
3 participants