OnlyPain's blog

By OnlyPain, history, 3 years ago, In English

Can someone tell me how to add(parse) contest information in my code editor before submitting to any OJ as it is done in Cp Editor?

For Eg.

Thanks in advance.

  • Vote: I like it
  • 0
  • Vote: I do not like it

»
3 years ago, # |
  Vote: I like it +3 Vote: I do not like it

Luckily CpEditor is open source... So we can take a look to see how it actually happens!

  1. First clue: settings.json:533. Seems to be the string resource format for the lines maybe? I didn't look too much into this.
  2. Second clue: CompanionServer.cpp:131. Appears to populate a struct for info for CpEditor... I'm assuming it's coming from Competitive Companion.
  3. Third clue: appwindow.cpp:1130. This function is called via CompanionServer's emit of onRequestArrived (you can see them being linked together in AppWindow::setConnections())
  4. Finally: mainwindow.cpp:507. finalComments is the final string outputted to the editor as content (you can trace to see where it adds comment prefixes per language for each line, and even calls editor.setText() here on line 555)

Hope this helps!