Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
The look of forum code
#1
I wish the copy for QM forum posts would look like this!
Code:
Copy      Help
|It would be really neat if QM forum posts could looks exactly like they do in the editor...
out
int i=2
sel i
||||case [1,3,5,7,9]
||||out("%i is Odd" i)
||||case [2,4,6,8]
||||out("%i is Even" i)
||||case [0]
||||out "The number is Zero"
sel i
||||case [0,2,1,3,5,7,9]
||||if i<9
||||||||out "Don't for get that's a prime number too!"

Just setting the color to white to match the background in the code box for "||||" to show a tab and "|" to show a space.
Looks right in all the view options for the forum using Firefox on XP...
Figure could parse the data in QM when pasting...maybe every past too, that way you wouldn't have to use the correct pasted code that pops up in the output section. I've never seen any reason to start code with "|" could be any character though...crazy ones that you would never start a line of code with. QM would findreplace tab with four characters to space in the monospaced [ code] bbCode tag.
#2
This isn't perfect, but it's an idea!
Function Copy_BBCode
Trigger CSc /QM     Help - how to add the trigger to the macro
Code:
Copy      Help
men 33353 id(2213 win("" "QM_Editor")) ;;Copy BBCode
str s.getclip()
s.findreplace(";" "[color=#FFFFFF]|[color=#008000]")
s.findreplace("[color=#e0e0e0],,," "[color=#FFFFFF]||||||||||||")
s.findreplace("[color=#e0e0e0],," "[color=#FFFFFF]||||||||")
s.findreplace("[color=#e0e0e0]," "[color=#FFFFFF]||||")
s.from("[code]" s (`s)"
"(`)(`p))(`)
(`c);out s(`)
s.setclip(`p)()(`)
[/code]

I don't see why doing this on every paste would really be much of a problem...unless "|" was trying to be copied and pasted. Anyways...just an idea.

I know that Gintaras can make this run a lot smoother, he has mastered the "Copy BBCode" I could do neater things if I knew what was all involved with that...then also he has "copy for QM forum"...which looks even more complex. So like I said, only an idea...


Here is an example of code I copied using the above script:
Code:
Copy      Help
out
int i=2
sel i
||||case [1,3,5,7,9]
||||out("%i is Odd" i)
||||case [2,4,6,8]
||||out("%i is Even" i)
||||case [0]
||||out "The number is Zero"
sel i
||||case [0,2,1,3,5,7,9]
||||if i<9
||||||||out "Don't for get that's a prime number too!"

Here is the code for pasting back into QM:
Function Paste_BBCode
Trigger CSv /QM     Help - how to add the trigger to the macro
Code:
Copy      Help
str s.getclip()
out "-------------------"
out "Original text"
out "-------------------"
out s
s.findreplace("||||" "[9]")
_s.get(s 0 1)
if _s="|"
,s.findreplace("|" " " 4)
outp s


Forum Jump:


Users browsing this thread: 1 Guest(s)