0

What I'm Doing

I am currently working on creating a SWI-Prolog module that adds tab-completion capability to the swipl-win window. So far I've actually gotten it to where it reads a single character at a time without stopping/returning anything until a tab character is typed. I have also already written a predicate that returns all possible completions of an incompletely typed term by using substring-matching on a list of current terms (obtained via current_functor/2, current_arithmetic_function/1, current_predicate/2, etc [the predicate used will eventually be based off of context]).

If you want to see my code, it is here...just keep in mind that I'm not exactly a Prolog master yet (friendly tips are more than welcome).


What I'm Thinking

I've long abandoned any efforts at using XPCE to do popup-dropdown-completion in the swipl-win window (I'll eventually try to get that into Pce-Emacs [it won't be as polished as Visual Studio --picture something more like Python's IDLE], but I don't know if that's really even practical since I'm starting to use actual Emacs a lot more nowadays anyway), but is there any way to modify the output color in the swipl-win window? I know syntax highlighting has already been implemented in other Prolog systems' command-prompt windows, but I really just want to have it so that when tabber.pl suggests a completion, it also shows the arity (and perhaps the rest of the partially-typed term) of the suggested term in light gray. I know there is already color output from the system (like when it starts up), but I don't know how to hook into output stuff to control it myself. (Obviously, I'd probably define print/1 but...) I know I could write my own SWI-Prolog console like one guy has done with C#, but I really wanted it so people (including me) could just load the tabber module somewhere in their config file and continue to use the swipl-win window, rather than having it be a completely different executable... Would I have to use some kind of C API?

Note: The actual implementation will likely be influenced by the answers that I get to this question, because I'm going to base my decision on the use of strings and/or atoms in this project off of them.


What I'm Asking

Is there a way or something (even if it's really low-level) I can implement to colorize output in the swipl-win window?

Community
  • 1
  • 1
ksoo
  • 434
  • 1
  • 3
  • 15

1 Answers1

0

AFAIU the question you have to deal with is to avoid calling the fontify-function every seconds as common buffers do. I.e. call it only once when output arrived and restrict fontification to previous prompt in buffer.

Andreas Röhler
  • 4,804
  • 14
  • 18
  • Thanks for answering (nobody else has so far)....but I'm not talking about Emacs here :) I understand that I did mention PCE-Emacs in one sentence but even in the question title I hope I was clear enough: "Colorized output _in the swipl-win window_"....is there a fontify function in the swipl-win window that I don't know about? (There certainly aren't buffers.) – ksoo Jun 30 '13 at 18:40
  • @AsianSquirrel Ah, okay. BTW there is a certain confusion at Emacs with windows and buffers. Also there are that many modes out... Played with swi-prolog from inside Emacs some times ago, which was awesome. – Andreas Röhler Jul 01 '13 at 19:59
  • Yes, many Prolog modes for Emacs were recommended in the SWIPL documentation...unfortunately, it seems that many of these are now obsolete (and in many cases, not even available anymore). There might be new/better things out there, but I don't know of them yet I guess... – ksoo Jul 02 '13 at 16:51