+ Reply to Thread
Results 1 to 5 of 5

Thread: Forum now has syntax highlighting

  1. #1
    Administrator tcarr's Avatar
    Join Date
    Dec 2007
    Posts
    7,214
    Thanks
    80
    Thanked 1,087 Times in 1,076 Posts

    Forum now has syntax highlighting

    We have always been able to use CODE tags in the forum to give plain monospaced formatting to code snippets in posts. I just finished adding the ability to do syntax highlighting for the following languages:
    • PHP (as [PHPS])
    • JavaScript (as [JSS])
    • CSS (as [CSSS])
    • SQL (as [SQLS])
    • C++ (as [CPPS])
    • HTML (as [HTMLS])
    • Java (as [JAVAS])
    • Tcl (as [TCLS])
    • BASH (as [BASHS])

    I will be investigating how to add ActionScript since we use that frequently. The above options were from a forum mod. Here's an example of Java:
    Java Code:
     
            if (useTwoStepLogin) {
                // no DB lookup here
                if (evictGhostUsers && getApi().isUserLoggedIn(userName)) {
                    // we assume that this other user is a ghost.  
                    // Evict doesn't really send the evicted user any message.
                    getApi().evictUserFromServer(userName, response);
                    return ChainAction.OkAndContinue;
                } else if (getApi().isUserLoggedIn(userName)) {
                    response.setString(LoginResultEnum.Status.name(), LoginResultEnum.AlreadyLoggedOn.name());
                    return ChainAction.Fail;
                }
            }
    Last edited by tcarr; 08-02-2012 at 01:33 PM.
    Teresa Carrigan
    Senior Engineer
    Electrotank, Inc.

  2. #2
    Administrator tcarr's Avatar
    Join Date
    Dec 2007
    Posts
    7,214
    Thanks
    80
    Thanked 1,087 Times in 1,076 Posts
    AS3 snippet uses [AS3S]:
    ActionScript3 Code:
     
    			private function onPluginMessageEvent(e:PluginMessageEvent):void {
    				var esob:EsObject = e.parameters;
    				var action:String = esob.getString(PluginConstants.ACTION);
     
    				switch (action) {
    					case PluginConstants.TAG_ADD_TO_RANK:
    					case PluginConstants.TAG_GET_RANK:
    						var rank:int = esob.getInteger(PluginConstants.TAG_GET_RANK);
    						rankValueField.text = rank.toString();
    						break;
    					case PluginConstants.TAG_ERROR:
    						var err:String = esob.getString(PluginConstants.TAG_ERROR);
    						trace(err);
    						break;
    				}
    			}


    I'm trying to decide whether I want to keep line numbers enabled or disable them. Enabled makes it useful for discussing a particular line of the code snippet, but then if you copy and paste the snippet you have to edit out the line numbers.
    Teresa Carrigan
    Senior Engineer
    Electrotank, Inc.

  3. #3
    Administrator tcarr's Avatar
    Join Date
    Dec 2007
    Posts
    7,214
    Thanks
    80
    Thanked 1,087 Times in 1,076 Posts
    And C# uses [CSHARPS]:
    C# Code:
     
    	private void OnLogin (LoginResponse response)
    	{
    		if (response.Successful) {
     
    			/*
    			 * Create a room request with the specific properties
    			 * of the request.
    			 */
    			CreateRoomRequest req = new CreateRoomRequest ();
    			req.Capacity = -1;
    			req.ZoneName = "ElectroChatZone";
    			req.ZoneId = -1;
    			req.CreateOrJoinRoom = true;
    			req.ReceivingUserListUpdates = true;
    			req.Persistent = false;
    			req.RoomName = "ElectroChat";
     
    			// Send room request to Electroserver
    			es.Engine.Send (req);
    		}
    	}
    Teresa Carrigan
    Senior Engineer
    Electrotank, Inc.

  4. #4
    Administrator tcarr's Avatar
    Join Date
    Dec 2007
    Posts
    7,214
    Thanks
    80
    Thanked 1,087 Times in 1,076 Posts
    I've decided that I do not like the line numbers. Now to try to remember how I turned the line numbers on, so that I can turn them off again....
    Teresa Carrigan
    Senior Engineer
    Electrotank, Inc.

  5. #5
    Administrator tcarr's Avatar
    Join Date
    Dec 2007
    Posts
    7,214
    Thanks
    80
    Thanked 1,087 Times in 1,076 Posts
    Fixed! Older posts that had the line numbers will keep them, I think, but new posts will not have the line numbers.

    C# Code:
     
    	private void OnLogin (LoginResponse response)
    	{
    		if (response.Successful) {
     
    			/*
    			 * Create a room request with the specific properties
    			 * of the request.
    			 */
    			CreateRoomRequest req = new CreateRoomRequest ();
    			req.Capacity = -1;
    			req.ZoneName = "ElectroChatZone";
    			req.ZoneId = -1;
    			req.CreateOrJoinRoom = true;
    			req.ReceivingUserListUpdates = true;
    			req.Persistent = false;
    			req.RoomName = "ElectroChat";
     
    			// Send room request to Electroserver
    			es.Engine.Send (req);
    		}
    	}
    Teresa Carrigan
    Senior Engineer
    Electrotank, Inc.

+ Reply to Thread

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts