Author Topic: Code blocks  (Read 9269 times)

0 Members and 1 Guest are viewing this topic.

JohnK

  • Administrator
  • Seagull
  • Posts: 10549
Re: Code blocks
« Reply #15 on: April 19, 2013, 08:46:41 AM »
*bump*
I have contacted the author of the MOD and he stated that he has a fix. w00t!

Quote
I already have a fix and will update the mod by the weekend.

Thank you.
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

JohnK

  • Administrator
  • Seagull
  • Posts: 10549
Re: Code blocks
« Reply #16 on: April 20, 2013, 09:44:18 PM »
update:

The GeSHi mod has been updated on the SMF site. I will have to redo the mod on our end but at least we won't be getting all these errors. ...Thank you everyone for being so patient I know this bug has been a pain in the butt.

I will get started redoing the mod tomorrow.
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

JohnK

  • Administrator
  • Seagull
  • Posts: 10549
Re: Code blocks
« Reply #17 on: April 22, 2013, 08:00:02 AM »
Code - C++: [Select]
  1. const std::string trim(const std::string& pString, const std::string& pWhitespace = " \t") /*{{{*/
  2. {
  3.     const size_t beginStr = pString.find_first_not_of(pWhitespace);
  4.     if (beginStr == std::string::npos)
  5.         // no content
  6.         return "";
  7.  
  8.     const size_t endStr = pString.find_last_not_of(pWhitespace);
  9.     const size_t range = endStr - beginStr + 1;
  10.  
  11.     return pString.substr(beginStr, range);
  12. }
  13.  
« Last Edit: April 22, 2013, 08:25:10 AM by Se7en »
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

ElpanovEvgeniy

  • Water Moccasin
  • Posts: 1569
  • Moscow (Russia)
Re: Code blocks
« Reply #18 on: April 22, 2013, 08:13:53 AM »
Please add a link [Select] to block the syntax highlighter code.
For example:
Code = C++:  [Select]
Code = Auto/Visual Lisp:  [Select]

ElpanovEvgeniy

  • Water Moccasin
  • Posts: 1569
  • Moscow (Russia)
Re: Code blocks
« Reply #19 on: April 22, 2013, 08:21:36 AM »
As Administrator, look in the settings of the theme:
"Header above GeSHi Code Container:
You can use {CODE}, {TAG} and {LANGUAGE} keywords. For reference please see cb|GeSHi-mod help."

Replace the line of code generation titles:
Code: [Select]
{CODE} - {LANGUAGE}: <a href="javascript:void(0);" onclick="return smfSelectText(this);" class="codeoperation">[Select]</a>

JohnK

  • Administrator
  • Seagull
  • Posts: 10549
Re: Code blocks
« Reply #20 on: April 22, 2013, 08:26:29 AM »
As Administrator, look in the settings of the theme:
"Header above GeSHi Code Container:
You can use {CODE}, {TAG} and {LANGUAGE} keywords. For reference please see cb|GeSHi-mod help."

Replace the line of code generation titles:
Code: [Select]
{CODE} - {LANGUAGE}: <a href="javascript:void(0);" onclick="return smfSelectText(this);" class="codeoperation">[Select]</a>

Done.
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

ElpanovEvgeniy

  • Water Moccasin
  • Posts: 1569
  • Moscow (Russia)
Re: Code blocks
« Reply #21 on: April 22, 2013, 08:28:21 AM »
Thank you!
There's much more convenient!
 :-)

JohnK

  • Administrator
  • Seagull
  • Posts: 10549
Re: Code blocks
« Reply #22 on: April 22, 2013, 08:33:35 AM »
:-)
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

TheMaster

  • Guest
Re: Code blocks
« Reply #23 on: April 22, 2013, 09:23:49 AM »
:-)

How about search terms that include things like angle braces, etc.?

That doesn't seem to work for me

JohnK

  • Administrator
  • Seagull
  • Posts: 10549
Re: Code blocks
« Reply #24 on: April 22, 2013, 09:43:02 AM »
How about search terms that include things like angle braces, etc.?

That doesn't seem to work for me

I'm not sure I follow your meaning TT; `search terms'?

The `Select' doesn't work for you?
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

TheMaster

  • Guest
Re: Code blocks
« Reply #25 on: April 22, 2013, 01:47:41 PM »
How about search terms that include things like angle braces, etc.?

That doesn't seem to work for me

I'm not sure I follow your meaning TT; `search terms'?

The `Select' doesn't work for you?

I was referring to searching, not selecting the code. 

It can't find code that contains embedded characters like angle braces in code blocks with formatting, because the search is being done (apparently) on the HTML (the 'view'), rather than on the original unformatted code (the 'model'), which is heavily-fragmented by HTML tags.

Try searching the '.NET' forum for 'GetObjects<T>', and you'll not find anything, even though there are plenty of posts with code that contains that string.



« Last Edit: April 22, 2013, 02:41:36 PM by TT »

JohnK

  • Administrator
  • Seagull
  • Posts: 10549
Re: Code blocks
« Reply #26 on: April 22, 2013, 03:45:06 PM »
...

Try searching the '.NET' forum for 'GetObjects<T>', and you'll not find anything, even though there are plenty of posts with code that contains that string.

Oh, yes; the code is heavily reformatted by GeSHi and that would make searches a problem. Here's a "how long is a string question" for you; Are there a lot of instances (in .NET, I guess) where a user could be doing a search like that or would they mostly search `GetObjects' instead?  ...Actually, I can see that happening quite a bit now that I think about it.

I know this isn't the answer your looking for, and I'm not trying to belittle the thought either, but I think that we will have to force the age-old "ask better questions" stance and force people to use better subject lines and whatnot.
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

TheMaster

  • Guest
Re: Code blocks
« Reply #27 on: April 22, 2013, 05:12:00 PM »
...

Try searching the '.NET' forum for 'GetObjects<T>', and you'll not find anything, even though there are plenty of posts with code that contains that string.

Oh, yes; the code is heavily reformatted by GeSHi and that would make searches a problem. Here's a "how long is a string question" for you; Are there a lot of instances (in .NET, I guess) where a user could be doing a search like that or would they mostly search `GetObjects' instead?  ...Actually, I can see that happening quite a bit now that I think about it.

I know this isn't the answer your looking for, and I'm not trying to belittle the thought either, but I think that we will have to force the age-old "ask better questions" stance and force people to use better subject lines and whatnot.

Code that uses generics is fairly-common in .NET code nowadays, and the problem with angle braces specifically, is not only an problem in searches, but also when posting code snippets on brain-dead blogging platforms (like TypePad), where they are just gobbled-up.

I guess it's just one of those things.


Lee Mac

  • Seagull
  • Posts: 12892
  • London, England
Re: Code blocks
« Reply #28 on: April 22, 2013, 06:04:28 PM »
Thank you for your time on this Se7en, and also for adding the 'Select' option - much appreciated.

The only (very minor) issue that I've noticed with GeShi is that when copying code from code blocks, an indentation of 4-spaces is added to the front of every line, except those with leading spaces, to which only 3-spaces are added (or 4 are added and 1 existing is removed).

For example, when copying your code from Reply#17 to a code editor (Notepad++), I receive (using FF20.0.1):
Code: [Select]
    const std::string trim(const std::string& pString, const std::string& pWhitespace = " \t") /*{{{*/
    {
       const size_t beginStr = pString.find_first_not_of(pWhitespace);
       if (beginStr == std::string::npos)
           // no content
           return "";
     
       const size_t endStr = pString.find_last_not_of(pWhitespace);
       const size_t range = endStr - beginStr + 1;
     
       return pString.substr(beginStr, range);
    }
     
Note the extra 4 spaces of indentation on every line and removal of a leading space for the middle lines.

IE still copies the line numbers, but I guess this is unavoidable and simply how IE handles copying of HTML ordered lists.

JohnK

  • Administrator
  • Seagull
  • Posts: 10549
Re: Code blocks
« Reply #29 on: April 23, 2013, 08:31:44 AM »
No problem. Thank you for the thanks.

That's weird behavior from Firefox; it's usually pretty good with encodings an whatnot (I think it's really just an encoding issue in the end). ...The server and PHP is telling your browser to use ISO-8859-1 and we could get by with just UTF-8 (wikipedia does it right?). I will snoop around the forum settings and see if I cant find anything.

Off hand: I use xombrero now-a-days; A lot of it is keyboard driven (and the bookmarks will be a big shock to you) but maybe give it a whirl. I don't seem to have near as many issuse as you guys talk about.
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org