0

I am working on a small application on Linux using gtk and python. A part of the application contains a notepad and text in the notepad can be modified with font styles, font sizes, and colors. I would like to save the contents of the text view to a file with all the modifications and access the modified data when needed. I could save the text into a text file but I need to save its attributes. The next time if we access the file and view it on the text buffer, the textbuffer should contain text as well as the modifications(font style, color, size, family).

Hoping for a positive response. Thank you.

closed as unclear what you're asking by dessert, Kevin Bowen, wjandrea, N0rbert, karel Dec 24 '18 at 22:45

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    This question is more suitable for StackOverflow. – NPsoft Dec 24 '18 at 19:21
1

Why not use tags? Consider the text : "This is a sample text."

In the text file you can save it as : This is a <bold>{sample} text.

Similar keywords can be <fsize=24>, <color=blue> and so on. All that remains now is to write a Parser for evaluating the text-file.

  • 2
    Regex for a tag-based system? Therein lies madness... ;) – wjandrea Dec 24 '18 at 21:00
  • @wjandrea Appreciate your comment. I know about Chomsky hierarchy and why regex will cause problems. However, the no. of tags look very less. The OP will have to take special care and ensure that the resultant Grammar does not become a CFG and remains a Regular one. You are right. In order to avoid all the fuss and extra care, it would be better to write a parser. I have made the necessary edits. – NPsoft Dec 25 '18 at 11:32

Not the answer you're looking for? Browse other questions tagged or ask your own question.