Link to the mod (https://custom.simplemachines.org/index.php?mod=2925)
This script highlights syntax in code examples on your forum.
It is very easy to use because it works automatically: finds blocks of code, detects a language, highlights it.
Supported languages: HTML/XML, Javascript, CSS, PHP, Ruby, Perl, Python, C++, C#, Java, SQL, Bash, etc.
All supported languages and styles (https://highlightjs.org/static/demo/)
How to use? Very simply![code]your code[/code]
Advanced using[code=language]your code[/code]
One more way[code]your code[/code]
If you want numbering to start from some other value than 1, you can specify a numbering offset:
[code]your code[/code]
Features:
- You can choose code formatting scheme
- You can choose font size within code blocks
- Highlighting works automatically: finds blocks of code, detects a language, highlights it — you don't need to specify any language
Edit this CSS in /Themes/default/css/highlight.css to customize line numbers:
.hljs-ln-numbers {
text-align: center;
color: #f36;
border-right: 1px solid #f36;
vertical-align: top;
min-width: 25px;
}
Available translations:
- English
- Russian
- French
- Spanish
(https://img.shields.io/github/license/dragomano/highlight.js-for-smf?color=blue) (https://img.shields.io/badge/Donate-$-blue.svg?style=flat&logo=paypal) (https://www.buymeacoffee.com/bugo)
How do i make it look like the picture???? :(
PS. Good job :D
You can go to Modification settings and choose highlighting's template.
Hi there. Love the mod, but I have one small problem with it: It treats URLs like part of a comment due to the two forward slashes, which throws off the syntax highlighting more often than not. I've attached a small screenshot for example.
Any way to make it more intelligent about detecting comments?
Try edit *.css file of selected highlighting theme (see /Themes/default/css/highlight/). Or use [code=no-highlight] text [/code] to disable highlighting at all.
I don't think that will help. I like the syntax highlighting, but the fact that the mod doesn't know the difference between
// this is a comment
and
hxxp://this_is_not_a_comment
is in the mod itself. Just wondering if you can tweak the handling of the double forward slash in your regular expression, or whatever you're using to determine if it's a comment or not.
Quote from: Bugo on August 28, 2011, 01:18:09 PM
Link to Mod (http://custom.simplemachines.org/mods/index.php?mod=2925)
This script highlights syntax in code examples on your forum.
It is very easy to use because it works automatically: finds blocks of code, detects a language, highlights it.
Supported languages: HTML/XML, Javascript, CSS, PHP, Ruby, Perl, Python, C++, C#, Java, SQL, Bash etc.
Hi, is it possible to edit this mod to enable the support of additional languages ? I'm happy to do the work myself I just need some pointers on what I need to edit, for example I want numbers in green, function names, e.g. Print, Comment, etc in pink, comments in black . . .
To enable the support of all languages just download full highlight.pack.js (http://softwaremaniacs.org/soft/highlight/en/download/) and replace your /Themes/default/scripts/highlight.pack.js.
To change color of various elements just edit *.css file of your highlighting style (/Themes/default/css/highltight/).
Quote from: Bugo on October 23, 2011, 12:03:51 PM
To enable the support of all languages just download full highlight.pack.js (http://softwaremaniacs.org/soft/highlight/en/download/) and replace your /Themes/default/scripts/highlight.pack.js.
To change color of various elements just edit *.css file of your highlighting style (/Themes/default/css/highltight/).
The language I am interested in (mql4) isn't listed . . . what are my options to add it ?
Well, try write to author of highlight.js and ask him.
Quote from: Bugo on October 24, 2011, 12:42:58 AM
Well, try write to author of highlight.js and ask him.
Ah I see, I didn't realise you weren't the Author, many thanks.
Good mod
when update dont forget portuguese
Thanks, I'll not forget :)
Hello,
my problem big code no color
problem video : http://postimage.org/image/lxebl04ij/
normal smf code system no problem
thanks
(http://s17.postimage.org/ccuoy4f6l/Untitled.gif) (http://postimage.org/image/lxebl04ij/)
Nice mod, but it causes long lines to be wrapped, even when it's disabled.
To reproduce...
Add an SQL query that is one very long line. Note that in standard SMF the long line scrolls off the screen to the right, and a horizontal scroll bar is enabled.
After installing this mod the horizontal scroll bar is gone and the lines wrap. If you disable this mod by unchecking the "Enable syntax highlighting" box the syntax highlighting goes away, but the long lines are still wrapped with no horizontal scroll bar.
Edit: This is the version from April 11, 2012, 03:35:34 AM
I have this scrollbar. Which browser are you using? Can you attach your "very long SQL query" for example?
I'm using Firefox 11.0.
After further testing I found that it's only inside of the SA Knowledge Base mod where if I disable but don't uninstall the code highlighter, the wrap doesn't work. On a vanilla forum the wrap does work with Code Highlighter disabled. Apparently there's some interaction between SA Knowledge Base and Code Highlighter.
With Code Highlighter installed and active, the wrap no longer works even on a vanilla forum.
SELECT contact1.accountno, contact1.contact, count(*) as total FROM contact1 left outer join contsupp on contact1.accountno = contsupp.accountno WHERE contsupp.rectype = "P" and contsupp.contact = "E-mail Address" group by contact1.accountno, contact1.contact having count(*) > 1 order by total
Open highlight.css, find
white-space: pre-wrap;
and remove it.
@Bugo
big code add auto
[noae][code]
[noae] ? Code Highlighting not work
(http://s17.postimage.org/w7gqk8ue5/Untitled.gif)[/code]
Can you post this code here?
Quote from: Bugo on April 14, 2012, 10:18:45 PM
Can you post this code here?
;ALARM415.ASM 12DEC02 - COPYRIGHT JOHN BECKER - EPE INTRUDER ALARM
;PIC16F877-4, 3.2768MHz, WDT OFF, POR ON, XTAL XS
;Config register bits
; CP1 CP0 DBG NIL WRT CPD LVP BOR CP1 CP0 POR WDT OS1 OS0
; 1 1 1 1 1 1 0 0 1 1 0 0 0 1
;N.B. Logic 1/0 do NOT necessarily mean that the function is On/Off
;respectively - refer to PIC '87 data sheet.
#DEFINE PAGE0 BCF 0x03,5
#DEFINE PAGE1 BSF 0x03,5
List P = PIC16F877, R=DEC;
__CONFIG h'3F31'
INDF EQU 0x00 ;page 0, 1, 2, 3
OPTION_REG EQU 0x01 ;page 1, 3
PCL EQU 0x02 ;page 0, 1, 2, 3
STATUS EQU 0x03 ;page 0, 1, 2, 3
FSR EQU 0x04 ;page 0, 1, 2, 3
PORTA EQU 0x05 ;page 0
TRISA EQU 0x05 ;page 1
PORTB EQU 0x06 ;page 0, 2
TRISB EQU 0x06 ;page 1, 3
PORTC EQU 0x07 ;page 0
TRISC EQU 0x07 ;page 1
PORTD EQU 0x08 ;page 0
TRISD EQU 0x08 ;page 1
PORTE EQU 0x09 ;page 0
TRISE EQU 0x09 ;page 1
PCLATH EQU 0x0A ;page 0, 1, 2, 3
INTCON EQU 0x0B ;page 0, 1, 2, 3
EEDATA EQU 0x0C ;page 2
EECON1 EQU 0x0C ;page 3
PIR2 EQU 0x0D ;page 0
EEADR EQU 0x0D ;page 2
EECON2 EQU 0x0D ;page 3
ADCON1 EQU 0x1F ;page 1
SLOWIT EQU 0x20 ; pause counter
CLKCNT EQU 0x21
CLKSEC EQU 0x22
CLKMIN EQU 0x23
CLKHRS EQU 0x24
LOOP EQU 0x25
LOOPA EQU 0x26
RSLINE EQU 0x27
STORE EQU 0x28
STORE1 EQU 0x29
STORE2 EQU 0x2A
STORE3 EQU 0x2B
ZONESVAL EQU 0x2C ; current val of zones status
ALARMSTATUS EQU 0x2D ; controls the following
; bit 0 buzzer
; bit 1 strobe
; bit 2 bell
; bit 3 -
; bit 4 Panic flag
; bit 5 passive entry zone (just turns on buzzer when entered)
; bit 6 power interrupt flag
; bit 7 alarm on flag
SWITCH1 EQU 0x2E ; multiplex val for rows
SWVAL EQU 0x2F ; input val from RB0-RB3
COL EQU 0x30 ; column counter (inc in decimal)
ROW EQU 0x31 ; row counter (inc as matrix val)
ROWNUM EQU 0x32 ; row counter (inc in decimal)
ALARMZONE EQU 0x33 ; holds status of which zone triggered
KEYPRESS EQU 0x34 ; value of key pressed keypad1
PIN0 EQU 0x35 ; 1st pin number val FIRST KEYPAD
PIN1 EQU 0x36 ; 2nd pin number val
PIN2 EQU 0x37 ; 3rd pin number val
PIN3 EQU 0x38 ; 4th pin number val
EXITTIME EQU 0x39 ; entry/exit delay
EXITZONE EQU 0x3A ; entry/exit zone
INCLZONE EQU 0x3B ; zones to be included in monitoring
BELLTIME EQU 0x3C ; bell on time value in BCD mins
FLASH EQU 0x3D ; flag for flashing buzzer LED when zone incorrectly open during alarm setting
ZONENORMAL EQU 0x3E ; normal zone logic
ENGINEERSET EQU 0x3F ; flag to indicate if ENGINEER has been called
PREVALARMZONE EQU 0x40 ; previous alarm condition register
ENTRYDELAY EQU 0x41 ; counter for entry/exit delay
PIN4 EQU 0x42 ; 1st pin number val FOR 2ND KEYPAD
PIN5 EQU 0x43 ; 2nd pin number val
PIN6 EQU 0x44 ; 3rd pin number val
PIN7 EQU 0x45 ; 4th pin number val
KEYPRESS2 EQU 0x46 ; value of key pressed keypad2
ENTRYTIME2 EQU 0x47 ; entry time for keypad2
ENTRYDELAY2 EQU 0x48 ; counter for keypad2 entry delay
CLKCNT2 EQU 0x49
STORED EQU 0x4A ; temp store for keypad2
COUNT0 EQU 0x50 ;lsb
COUNT1 EQU 0x51
COUNT2 EQU 0x52 ;msb
DIGIT1 EQU 0x53 ;lsd
DIGIT2 EQU 0x54
BITCNT EQU 0x5B
DIGCNT EQU 0x5C
STOREX EQU 0x60
STOREY EQU 0x61
; locations up to 0x7F are available
;************************************************************
; Bit Definitions
;************************************************************
W EQU 0
F EQU 1
C EQU 0
DC EQU 1
Z EQU 2
RP0 EQU 5 ;STATUS reg
RP1 EQU 6 ;STATUS reg
GIE EQU 7 ;INTCON reg
RD EQU 0 ;EECON1 reg eeprom read enable flag
WR EQU 1 ;EECON1 reg eeprom write initiate flag
WREN EQU 2 ;EECON1 reg eeprom write enable flag
EEPGD EQU 7 ;EECON1 reg
EEIF EQU 4 ;PIR2 reg
BUZZER EQU 0
STROBE EQU 1
BELL EQU 2
PANIC EQU 4
RBIF EQU 0
;............. DATA EEPROM USE
; 0-3 PIN CODE
; 4 ZONES EXCLUDED
; 5 ENTRY/EXIT ZONE
; 6 ENTRY/EXIT DELAY
; 7 ZONES INTRUDED (AlarmZone)
; 8 ALARM ON/OFF & BELL, BUZZER, STROBE STATUS (AlarmStatus)
; 9 BELL ON TIME (MAX 15 MINS)
; 10 NORMAL ZONE STATUS
; 11-14 2ND PIN CODE
; 15 ENTRY DELAY VIA KEYPAD2
ORG 0x0004 ;Interrupt vector address
GOTO GIEOFF ;Jump to interrupt routine on interrupt
ORG 0x0005 ;Start of program memory
GIEOFF BCF INTCON,GIE ;turn off global interrupts
BTFSC INTCON,GIE
goto GIEOFF
goto START
TABLCD addwf PCL,F ;LCD initialisation table
retlw b'00110011' ;initialise lcd - first byte
retlw b'00110011' ;2nd byte (repeat of first)
retlw b'00110010' ;set for 4-bit operation
retlw b'00101100' ;set for 2 lines
retlw b'00000110' ;set entry mode to increment each address
retlw b'00001100' ;set display on, cursor off, blink off
retlw b'00000001' ;clear display
retlw b'00000010' ;return home, cursor & RAM to zero
;end inititalisation table
ALLOFF addwf PCL,F
retlw 'A'
retlw 'L'
retlw 'L'
retlw ' '
retlw 'O'
retlw 'F'
retlw 'F'
retlw ' '
MESSAGON addwf PCL,F
retlw 'A'
retlw 'L'
retlw 'A'
retlw 'R'
retlw 'M'
retlw ' '
retlw 'O'
retlw 'N'
retlw ' '
MESSAG2 addwf PCL,F
retlw ' '
retlw ' '
retlw 'E'
retlw 'N'
retlw 'T'
retlw 'R'
retlw 'Y'
retlw ' '
CHKVAL addwf PCL,F
retlw b'01011001' ;59 secs max
retlw b'01011001' ;59 mins max
retlw b'00100011' ;23 hours max
VALUE ADDWF PCL,F ;lookup table for key allocation
retlw '1'
retlw '2'
retlw '3'
retlw 'A'
retlw '4'
retlw '5'
retlw '6'
retlw 'B'
retlw '7'
retlw '8'
retlw '9'
retlw 'C'
retlw '-'
retlw '0'
retlw 'E'
retlw 'D'
BITVALUE ADDWF PCL,F ;lookup table for decimal to bit conversion
retlw .0
retlw .1
retlw .2
retlw .4
retlw .8
retlw .16
retlw .32
retlw .64
retlw .128
PINCODE ADDWF PCL,F ; change pin code message
retlw 'C'
retlw 'H'
retlw 'A'
retlw 'N'
retlw 'G'
retlw 'E'
retlw ' '
retlw 'P'
retlw 'I'
retlw 'N'
retlw ' '
retlw 'C'
retlw 'O'
retlw 'D'
retlw 'E'
retlw ' '
PIN2MSG ADDWF PCL,F ; change 2ND pin code message
retlw 'S'
retlw 'E'
retlw 'T'
retlw ' '
retlw '2'
retlw 'N'
retlw 'D'
retlw ' '
retlw 'P'
retlw 'I'
retlw 'N'
retlw ' '
retlw 'C'
retlw 'O'
retlw 'D'
retlw 'E'
ENTRYTIME ADDWF PCL,F ; change ENTRY/EXIT time message
retlw 'S'
retlw 'E'
retlw 'T'
retlw ' '
retlw 'I'
retlw 'N'
retlw '/'
retlw 'O'
retlw 'U'
retlw 'T'
retlw ' '
retlw 'T'
retlw 'I'
retlw 'M'
retlw 'E'
retlw ' '
BELLTIMEMSG ADDWF PCL,F ; change ENTRY/EXIT time message
retlw 'S'
retlw 'E'
retlw 'T'
retlw ' '
retlw 'B'
retlw 'E'
retlw 'L'
retlw 'L'
retlw ' '
retlw 'O'
retlw 'N'
retlw ' '
retlw 'T'
retlw 'I'
retlw 'M'
retlw 'E'
ENTRYZONE ADDWF PCL,F ; set ENTRY/EXIT zone message
retlw 'S'
retlw 'E'
retlw 'T'
retlw ' '
retlw 'I'
retlw 'N'
retlw '/'
retlw 'O'
retlw 'U'
retlw 'T'
retlw ' '
retlw 'Z'
retlw 'O'
retlw 'N'
retlw 'E'
retlw ' '
MODEMSG ADDWF PCL,F ; mode message
retlw 'S'
retlw 'E'
retlw 'L'
retlw 'E'
retlw 'C'
retlw 'T'
retlw ' '
retlw 'M'
retlw 'O'
retlw 'D'
retlw 'E'
retlw ' '
retlw ' '
retlw ' '
retlw ' '
retlw ' '
WATCHMSG ADDWF PCL,F ; zones to be watched message
retlw 'S'
retlw 'E'
retlw 'T'
retlw ' '
retlw 'W'
retlw 'A'
retlw 'T'
retlw 'C'
retlw 'H'
retlw ' '
retlw 'Z'
retlw 'O'
retlw 'N'
retlw 'E'
retlw 'S'
retlw ' '
OPENZONE ADDWF PCL,F ; zones incorrectly open when alarm is being set
retlw 'C'
retlw 'H'
retlw 'E'
retlw 'C'
retlw 'K'
retlw ' '
retlw 'O'
retlw 'P'
retlw 'E'
retlw 'N'
retlw ' '
retlw 'Z'
retlw 'O'
retlw 'N'
retlw 'E'
retlw 'S'
ZONELOGIC ADDWF PCL,F ; assess zone logic message (i.e normally open or normally closed)
retlw 'A'
retlw 'U'
retlw 'T'
retlw 'O'
retlw ' '
retlw 'Z'
retlw 'O'
retlw 'N'
retlw 'E'
retlw ' '
retlw 'A'
retlw 'S'
retlw 'S'
retlw 'E'
retlw 'S'
retlw 'S'
SHOWLOGIC ADDWF PCL,F ; assess zone logic message (i.e normally open or normally closed)
retlw 'N'
retlw 'O'
retlw 'R'
retlw 'M'
retlw ' '
retlw 'Z'
retlw 'O'
retlw 'N'
retlw 'E'
retlw ' '
retlw 'L'
retlw 'O'
retlw 'G'
retlw 'I'
retlw 'C'
retlw ' '
PASSIVEMSG ADDWF PCL,F ; passive alarm message
retlw 'M'
retlw 'O'
retlw 'N'
retlw 'I'
retlw 'T'
retlw 'O'
retlw 'R'
retlw ' '
START bcf STATUS,RP0
bcf STATUS,RP1
clrf PORTA
clrf PORTB
clrf PORTC
clrf PORTD
clrf PORTE
PAGE1
movlw b'11011111' ;RB0-RB4, RB6-RB7 as input, RB5 as output
movwf TRISB
movlw b'00001111' ;RC0-RC3 as input, RC4-RC7 as output
movwf TRISC
movlw .255
movwf TRISD ;PORTD as input
clrf TRISE ;PORTE as output
movlw b'00000111' ;PORT A/E as digital
movwf ADCON1 ;
movlw b'11000000' ;RA0-RA5 as outputs
movwf TRISA
movlw b'00000110' ;timer 1128 (1/25th sec)
movwf OPTION_REG
PAGE0
clrf INTCON
call PAUSIT ;1/5 sec delay
LCDSET clrf LOOP ;clr LCD set-up loop
clrf RSLINE ;clear RS line for instruction send
LCDST2 movf LOOP,W ;get table address
call TABLCD ;get set-up instruction
call LCDOUT ;perform it
incf LOOP,F ;inc loop
btfss LOOP,3 ;has last LCD set-up instruction now been done?
goto LCDST2 ;no
call PAUSIT ;1/5 sec delay
clrf ENGINEERSET
bsf ALARMSTATUS,6 ; set Power interruption flag
call KEYPAD1 ; is ENGINEER code to be entered following power-up
movf KEYPRESS,W ; with key 'D' pressed?
xorlw 'D'
btfss STATUS,Z
goto SETCLK ; no
clrf ALARMZONE
clrf ALARMSTATUS
bsf ENGINEERSET,0
bcf ALARMSTATUS,6 ; clear Power interruption flag
movlw b'10000001' ; default set INCLZONE for zones 1 & 8
movwf STORE1
movlw .4
call SETPRM
movlw b'00000001' ; default set entry/exit zone
movwf STORE1
movlw .5
call SETPRM
movlw .30 ; default set EXITTIME to 30 secs in binary
movwf STORE1
movlw .6
call SETPRM
clrf STORE1 ; default clear INTRUDED status
movlw .7
call SETPRM
clrf PORTE
clrf STORE1 ; default clear ALARMSTATUS (bell etc)
bcf STORE1,BELL
movlw .8
call SETPRM
movlw b'00010101' ; default set bell switch-off time to 15 mins in BCD
movwf STORE1
movlw .9
call SETPRM
movlw b'00000000' ; default set for "normal" zone status - all open
movwf STORE1
movlw .10
call SETPRM
movlw .30 ; default set ENTRYTIME to 30 secs in binary for keypad2
movwf STORE1
movlw .15
call SETPRM
call ENGINEER ; yes, set ENGINEER entry code and reset all defaults
SETCLK clrf CLKSEC ;clear seconds counter
clrf CLKMIN ;clear minutes counter
clrf CLKHRS ;clear hours counter
clrf PREVALARMZONE
clrf ENTRYDELAY
clrf ENTRYDELAY2
movlw .25 ;initial basic CLKCNT val for secs timing
movwf CLKCNT
movlw .0 ; RECALL PIN CODE
call PRMGET
movwf PIN0
movlw .1
call PRMGET
movwf PIN1
movlw .2
call PRMGET
movwf PIN2
movlw .3
call PRMGET
movwf PIN3
movlw .4 ; RECALL INCLUDED/EXCLUDED ZONES
call PRMGET
movwf INCLZONE
bsf INCLZONE,7 ; ensure bit 7 (1st PANIC zone) is always on
movlw .5 ; RECALL ENTRY/EXIT ZONE
call PRMGET
movwf EXITZONE
movlw .6 ; RECALL ENTRY/EXIT TIME
call PRMGET
movwf EXITTIME
movlw .7 ; RECALL ALARMZONE STATUS
call PRMGET
movwf ALARMZONE
movlw .8 ; RECALL ALARMSTATUS STATUS
call PRMGET
movwf ALARMSTATUS ; and activate buzzer/strobe if needed (but not bell)
andlw b'00000011'
movwf PORTE
movlw .9 ; RECALL BELL ON TIME
call PRMGET
movwf BELLTIME
movlw .10 ; RECALL "NORMAL ZONE STATUS
call PRMGET
movwf ZONENORMAL
movlw .11 ; RECALL PIN CODE 2
call PRMGET
movwf PIN4
movlw .12
call PRMGET
movwf PIN5
movlw .13
call PRMGET
movwf PIN6
movlw .14
call PRMGET
movwf PIN7
movlw .15 ; RECALL ENTRY TIME FOR KEYPAD2
call PRMGET
movwf ENTRYTIME2
btfss ALARMSTATUS,7 ; is alarm on?
goto ITSOFF
call CHECKZONE2
bsf ALARMSTATUS,6 ; set Power interruption flag
goto MAIN
ITSOFF call ALARMOFF ; show ALARM OFF message
btfsc ENGINEERSET,0 ; has ENGINEER been called?
goto MAIN ;yes
call LCD21 ;set address for line 1 cell 1
bsf RSLINE,4 ;set RS for data send
movlw 'P'
call LCDOUT
movlw 'O'
call LCDOUT
movlw 'W'
call LCDOUT
movlw 'E'
call LCDOUT
movlw 'R'
call LCDOUT
movlw ' '
call LCDOUT
movlw 'E'
call LCDOUT
movlw 'R'
call LCDOUT
movlw 'R'
call LCDOUT
movlw 'O'
call LCDOUT
movlw 'R'
call LCDOUT
clrf ENGINEERSET ; clear ENGINEER flag
;............................ END OF SETUP
MAIN call CHECKMODE
call PINENTRY2
movf ENTRYDELAY2,W ; has entry2 delay timed out?
btfss STATUS,Z
call CONTINUEENTRY2 ; no, continue countdown of entry2
goto MAIN
ALARMISON btfss ALARMSTATUS,7 ; is alarm on ?
return ; no
call MONITOR ; get current status of zones 1-8
call CHECKZONE ; compare current and preset zones status
call SETBELLS
call CLKIN
return
PASSIVEALARM
call MONITOR ; get current status of zones 1-8
call CHECKZONE ; compare current and preset zones status
movf ZONESVAL,W
btfss STATUS,Z
goto PAS1
bcf PORTE,BUZZER
goto PAS2
PAS1 bsf PORTE,BUZZER
PAS2 call LCD21 ;set address for line 1 cell 1
bsf RSLINE,4 ;set RS for data send
movf ZONESVAL,W
movwf STORE1 ; store INTRUDED status
call SHOWZONE
return
;******* CHECK MODE
CHECKMODE call KEYPAD1 ; is key pressed?
movf KEYPRESS,W
btfsc STATUS,Z
return ; no, so return
CHECKM2 call WAITKEYPRESS
movf KEYPRESS,W ; is keypress = pin number?
xorwf PIN0,W
btfss STATUS,Z
return
call WAITKEYRELEASE
call WAITKEYPRESS
movf KEYPRESS,W ; is keypress = pin number?
xorwf PIN1,W
btfss STATUS,Z
return
call WAITKEYRELEASE
call WAITKEYPRESS
movf KEYPRESS,W ; is keypress = pin number?
xorwf PIN2,W
btfss STATUS,Z
return
call WAITKEYRELEASE
call WAITKEYPRESS
movf KEYPRESS,W ; is keypress = pin number?
xorwf PIN3,W
btfss STATUS,Z
return
goto AMENDMODE ; yes
;*********** AMEND MODE **********
AMENDMODE clrf PORTE ; turn off bell, buzzer, strobe
btfss ALARMSTATUS,7 ; is alarm already in alarm mode?
goto AMEND0 ; no
goto AMEND2
AMEND0 call LCD1 ;set address for line 1 cell 1
bsf RSLINE,4 ;set RS for data send
clrf LOOP ;clear loop
bsf RSLINE,4 ;set RS for data send
AMEND1 movf LOOP,W ;get table address
call MODEMSG ;get message letter
call LCDOUT ;show it
incf LOOP,F ;inc loop
btfss LOOP,4 ;has last LCD letter been sent?
goto AMEND1 ;no
call CLRLINE2
AMEND2 clrf ALARMSTATUS
clrf ALARMZONE
clrf PREVALARMZONE
call WAITKEYRELEASE
call WAITKEYPRESS
movf KEYPRESS,W ; is keypress = '0' - alarm on?
xorlw '0'
btfsc STATUS,Z
goto ALARMON ; yes, so set alarm on and exit
CHECK12 movf KEYPRESS,W ; is keypress = '-' - cancel?
xorlw '-'
btfsc STATUS,Z
goto ALARMOFF ; general return to normal off status
CHECK0 movf KEYPRESS,W ; is keypress = '1' - change PIN code?
xorlw '1'
btfss STATUS,Z
goto CHECK1
call ENGINEER
goto AMEND0
CHECK1 movf KEYPRESS,W ; is keypress = '2' - change ENTRY/EXIT time?
xorlw '2'
btfss STATUS,Z
goto CHECK2
call CHANGEENTRY
goto AMEND0
CHECK2 movf KEYPRESS,W ; is keypress = '3' - change ENTRY/EXIT ZONE?
xorlw '3'
btfss STATUS,Z
goto CHECK3
call SETENTRY
goto AMEND0
CHECK3 movf KEYPRESS,W ; is keypress = '4' - select zones to monitored?
xorlw '4'
btfss STATUS,Z
goto CHECK4
call SETMONITOR
goto AMEND0
CHECK4 movf KEYPRESS,W ; is keypress = '5' - select bell on time (max 15 mins)
xorlw '5'
btfss STATUS,Z
goto CHECK5
call SETBELLTIME
goto AMEND0
CHECK5 movf KEYPRESS,W ; is keypress = '6' - assess normal zone logic
xorlw '6'
btfss STATUS,Z
goto CHECK6
call ASSESSLOGIC
goto AMEND0
CHECK6 movf KEYPRESS,W ; is keypress = '7' - preset normal zone logic
xorlw '7'
btfss STATUS,Z
goto CHECK7
call PRESETLOGIC
goto AMEND0
CHECK7 movf KEYPRESS,W ; is keypress = '8' - set 2nd pin code
xorlw '8'
btfss STATUS,Z
goto CHECK8
call PINCODE2
goto AMEND0
CHECK8 movf KEYPRESS,W ; is keypress = '9' - change ENTRY time for keypad2 ?
xorlw '9'
btfss STATUS,Z
goto CHECK14
call CHANGEENTRY2
goto AMEND0
CHECK14 movf KEYPRESS,W ; is keypress = '.' (coded 'E') - buzzer only monitor of entries
xorlw 'E'
btfss STATUS,Z
goto CHECK15
goto SETPASSIVE
CHECK15
goto AMEND2
; ******** PASSIVE MODE
SETPASSIVE call LCD1 ;set LCD for line 1, cell 1
bsf RSLINE,4 ;set LCD RS line high
clrf LOOP ;clear loop
SETP2 movf LOOP,W ;get table address
call PASSIVEMSG ;get message letter
call LCDOUT ;show it
incf LOOP,F ;inc loop
btfss LOOP,3 ;has last LCD letter been sent?
goto SETP2 ;no
movlw 'M'
call LCDOUT
movlw '0'
call LCDOUT
movlw 'D'
call LCDOUT
movlw 'E'
call LCDOUT
bsf ALARMSTATUS,5
return
;********* CHANGE ENTRY/EXIT TIME
CHANGEENTRY call LCD1 ;set LCD for line 1, cell 1
bsf RSLINE,4 ;set LCD RS line high
clrf LOOP ;clear loop
ENT2 movf LOOP,W ;get table address
call ENTRYTIME ;get message letter
call LCDOUT ;show it
incf LOOP,F ;inc loop
btfss LOOP,4 ;has last LCD letter been sent?
goto ENT2 ;no
call CLRLINE2
call LCD23 ;set LCD for line 2, cell 3
bsf RSLINE,4 ;set LCD RS line high
movlw ' '
call LCDOUT
movlw 'P'
call LCDOUT
movlw 'R'
call LCDOUT
movlw 'E'
call LCDOUT
movlw 'V'
call LCDOUT
movlw ' '
call LCDOUT
movf EXITTIME,W
movwf COUNT0
call BIN2DEC
movf DIGIT2,W
addlw .48
call LCDOUT
movf DIGIT1,W
addlw .48
call LCDOUT
call LCD21 ;set LCD for line 2, cell 1
bsf RSLINE,4 ;set LCD RS line high
call WAITKEYRELEASE
ENT3 call WAITKEYPRESS ; get first value (tens)
movf KEYPRESS,W ; is keypress = 12 - cancel?
xorlw '-'
btfsc STATUS,Z
return ; yes
btfsc KEYPRESS,6 ; is it >= 'A'?
goto ENT3 ; yes, so try again
movf KEYPRESS,W
andlw b'00001111'
movwf COUNT1
movwf COUNT2
movf KEYPRESS,W
call LCDOUT
call WAITKEYRELEASE
ENT4 call WAITKEYPRESS ; get 2nd val (units)
movf KEYPRESS,W ; is keypress = 12 - cancel?
xorlw '-'
btfsc STATUS,Z
return ; yes
btfsc KEYPRESS,6 ; is it >= 'A'?
goto ENT4 ; yes, so try again
movf KEYPRESS,W
andlw b'00001111'
movwf COUNT0
addwf COUNT1,W ; is total = 0?
btfsc STATUS,Z
goto ENT4 ; yes, so try again
movf KEYPRESS,W
call LCDOUT
ENT5 call WAITKEYRELEASE
call WAITKEYPRESS
movf KEYPRESS,W
xorlw 'D' ; is key = 15? - completion code number
btfsc STATUS,Z
goto ENT6 ; yes
movf KEYPRESS,W
xorlw '-' ; is key = 12? - error in number so start again
btfss STATUS,Z
goto ENT5 ; no
goto CHANGEENTRY ; yes
ENT6 call WAITKEYRELEASE
bcf STATUS,C
rlf COUNT1,F ; convert decimal to binary
rlf COUNT1,F
rlf COUNT1,W
addwf COUNT2,W
addwf COUNT2,W
addwf COUNT0,W
movwf EXITTIME
movf EXITTIME,W
movwf STORE1
movlw .6
call SETPRM
call STORIT
return
;********* MONITOR ZONES *********
MONITOR swapf PORTC,W ; get RC0-RC3, store it as MS nibble
andlw b'11110000'
movwf ZONESVAL
movf PORTD,W ; get RD0-RD3, store it as LS nibble
andlw b'00001111'
iorwf ZONESVAL,F
return
; ********* compare current and preset zones status
CHECKZONE movf ENTRYDELAY2,W ; has entry2 delay timed out?
btfss STATUS,Z
call CONTINUEENTRY2 ; no, continue countdown
movf ZONESVAL,W ; get current zones val
xorwf ZONENORMAL,W ; XOR with normal zones status
btfss STATUS,Z ; has a zone status been changed?
goto ZCH2 ; yes
movf ALARMZONE,W ; have any zones been triggered?
btfsc STATUS,Z ;
return ; no
ZCH2 movwf ZONESVAL ; yes
andwf INCLZONE,W ; is it a required zone?
btfsc STATUS,Z
return ; no
movwf ZONESVAL
btfsc ALARMSTATUS,5 ; yes, is alarm in passive status (just sets buzzer)?
return ; yes
iorwf ALARMZONE,W ; no, OR answer with previous zones triggered value
movwf ALARMZONE
btfsc ALARMSTATUS,STROBE ; has alarm already been triggered?
goto ZONEB ; yes
movf ALARMZONE,W
andwf EXITZONE,W ; has entry zone been triggered?
btfsc STATUS,Z
goto ZONEB ; no
movf ENTRYDELAY,W ; yes, has entry delay timed out?
btfsc STATUS,Z
goto ZONEB ; yes
bsf ALARMSTATUS,BUZZER ; no so continue countdown
call CONTINUEENTRY ;
call LCD21 ;set address for line 1 cell 1
bsf RSLINE,4 ;set RS for data send
movlw 'E'
call LCDOUT
movlw 'N'
call LCDOUT
movlw 'T'
call LCDOUT
movlw 'R'
call LCDOUT
movlw 'Y'
call LCDOUT
return
ZONEB movf ALARMZONE,W
xorwf PREVALARMZONE,W ; is it same as previous alarm zone setting?
btfsc STATUS,Z
return ; yes
movf ALARMZONE,W
movwf PREVALARMZONE
movwf STORE1 ; store INTRUDED status
movlw .7
call SETPRM
CHECKZONE2 ; called also from power up entry
call LCD1 ;set address for line 1 cell 1
bsf RSLINE,4 ;set RS for data send
movf ALARMZONE,W
movwf STORE1 ; store INTRUDED status
call SHOWZONE
clrf LOOP ;clear loop
bsf RSLINE,4 ;set RS for data send
btfss ALARMSTATUS,PANIC
goto LCDMS3 ; ...... TRIG
movlw 'P'
call LCDOUT
LCDMS3 movf LOOP,W ;get table address
call MESSAG2 ;get ENTERED message letter
call LCDOUT ;show it
incf LOOP,F ;inc loop
btfss LOOP,3 ;has last LCD letter been sent?
goto LCDMS3 ;no
TRIG btfss ALARMSTATUS,STROBE ; has alarm already been triggered?
bsf ALARMSTATUS,BELL ; no, so trigger bell
bsf ALARMSTATUS,BUZZER
bsf ALARMSTATUS,STROBE
movf ALARMSTATUS,W ; store ALARMSTATUS (but with bell off) to eeprom
movwf STORE1
bcf STORE1,BELL
movlw .8
call SETPRM
return
; ****** SETS BELL BUZZER STROBE with ALARMSTATUS value
SETBELLS movf ALARMSTATUS,W
andlw b'00000111'
movwf PORTE
return
;********* CLOCK UPDATING
CLKIN btfss ALARMSTATUS,STROBE ; clock only used if strobe active
return ; allowing elapsed time since first zone triggered to be shown
btfss INTCON,2 ; has timer rollover occurred?
return ; no
BCF INTCON,2 ; yes, clear timer flag
decfsz CLKCNT,F ; increment clock routine. Is it = 0?
return ; no
CLKADD movlw .25 ; reset start value of CLKCNT
movwf CLKCNT
SECCLK movlw CLKSEC
movwf FSR
movlw .3
movwf LOOPA
ADDCLK incf INDF,F ;inc units
movlw .6
addwf INDF,W ;if 6 is added is there a digit carry?
btfss STATUS,DC
goto CHK15 ;no
movwf INDF ;yes
movlw .160
addwf INDF,W ;if 160 is added is there a carry
btfss STATUS,C ;(adding 160 checks if tens of units = 6)
goto CHK15 ;no
clrf INDF ;yes
incf FSR,F
decfsz LOOPA,F
goto ADDCLK
CHK15 movf CLKMIN,W ; has bell been on for set number of mins?
xorwf BELLTIME,W ; mins in BCD (max 20)
btfsc STATUS,Z
bcf ALARMSTATUS,BELL
CLKSHW call LCD21 ;set address for line 1 cell 9
bsf RSLINE,4 ;set RS for data send
movf CLKHRS,W ;get hrs
call LCDFRM ;format and send it
movlw ' ' ;insert colon
call LCDOUT
movf CLKMIN,W ;get mins
call LCDFRM
movlw '.' ;insert colon
call LCDOUT
movf CLKSEC,W ;get secs
call LCDFRM
btfss ALARMSTATUS,6 ; has there been a power interruption?
return ;no
movlw ' ' ; yes
call LCDOUT
movlw 'P'
call LCDOUT
movlw 'S'
call LCDOUT
movlw 'U'
call LCDOUT
movlw ' '
call LCDOUT
movlw 'E'
call LCDOUT
movlw 'R'
call LCDOUT
movlw 'R'
call LCDOUT
return
;..........GET KEYPAD 1 VAL ROUTINE........
KEYPAD1 clrf KEYPRESS
btfss INTCON,RBIF ; has Panic been pushed
goto KP2 ; no
call PANICSET
KP2 btfsc ALARMSTATUS,7 ; is alarm on?
call ALARMISON ; yes
btfsc ALARMSTATUS,5 ; is alarm on?
call PASSIVEALARM ; yes
; goto KEYPAD2
movlw b'00001111'
movwf PORTC
movwf STORE
nop ;pause to allow PORTC to stabilise
comf PORTB,W ;get & invert PORTB
andlw b'00001111' ;isolate bits 0-3
btfsc STATUS,Z ;is result NOT zero (keys pressed)?
return ;no, so return to main prog
movlw b'10000000' ;yes, a key is pressed so get it
movwf SWITCH1 ;initial val for RC4-7
movlw .3 ;initial val for COL
movwf COL
clrf ROW ;initial val for ROW
GETIT comf SWITCH1,W ;get and invert val for PORTC
iorwf STORE,W
movwf PORTC ;output to PORTC
nop ;pause to allow PORTC to stabilise
comf PORTB,W ;get and invert val from PORTB
andlw .15 ;isolate bits 0-3
btfss STATUS,Z ;is it zero?
goto GET2 ;no, so goto analysis routine
decf COL,F ;dec col val
bcf STATUS,C ;clear carry flag
rrf SWITCH1,F ;divide RC7-4 val by 2
movf SWITCH1,W ;
andlw b'11110000'
btfss STATUS,C ;is it zero?
goto GETIT ;no, so continue loop
return ;yes, so return to main program
GET2 movwf SWVAL ;store PORTB val
clrf ROW ;clear row count
clrf ROWNUM ;clear row number count
GET3 rrf SWVAL,F ;rotate right PORTB store val
btfsc STATUS,C ;is carry flag set?
goto SUMIT ;yes so key pressed, go & finish answer
movlw .4
addwf ROW,F ;add matrix val to ROW count
incf ROWNUM,F ;inc row number count
btfss ROWNUM,2
goto GET3
SUMIT movf ROW,W ;sum up results to single answer
addwf COL,W ;add ROW to COL (total of 0-15)
call VALUE
movwf KEYPRESS ; store result into KEYPRESS
call DEBOUNCE
return ;return to main program
;********* SET ENGINEER'S PIN CODE
ENGINEER call LCD1 ;set LCD for line 1, cell 1
bsf RSLINE,4 ;set LCD RS line high
clrf LOOP ;clear loop
ENG2 movf LOOP,W ;get table address
call PINCODE ;get message letter
call LCDOUT ;show it
incf LOOP,F ;inc loop
btfss LOOP,4 ;has last LCD letter been sent?
goto ENG2 ;no
call CLRLINE2
call LCD21 ;set LCD for line 2, cell 1
bsf RSLINE,4 ;set LCD RS line high
movlw PIN0
movwf FSR
clrf LOOP
ENG3 call WAITKEYRELEASE
call WAITKEYPRESS
movf KEYPRESS,W
xorlw '-' ; is key = 12? - error in number so start again
btfss STATUS,Z ; ... c
goto ENG4 ; ... ENG
I have no problem with this.
Dear mod-master,
thanks a lot for your mod! Works fine. Suki brought me here in my "Display layout for [ code ] BBC in notepad++ style (http://www.simplemachines.org/community/index.php?topic=519544)" request and the "desire" to make the outlook a little more html friendly. So I just try to bring it into the usual notepad style.
I could not see trough it in regard of splitting certain text parts in different colors. Especially the text part of htmls. Is there one special id included which serves this part?
Much gratitude for your service.
/me edited, because nearly forgot:
German "formal-utf8"
<?php
$txt['ch_title'] = 'Syntax Hervorhebung: Highlight';
$txt['ch_settings'] = 'Highlight Einstellungen';
$txt['ch_desc'] = 'In diesem Bereich können Sie die Hervorhebungen aktivieren/deaktivieren, ein bevorzugtes Theme wählen, usw.';
$txt['ch_enable'] = 'Aktivieren von Syntax Highlighting';
$txt['ch_style'] = 'Hervorhebungsstile (Theme)';
$txt['ch_style_set'] = array(
'arta' => 'Arta',
'ascetic' => 'Ascetic',
'brown_paper' => 'Brown Paper',
'dark' => 'Dark',
'default' => 'Default',
'far' => 'FAR',
'github' => 'GitHub',
'googlecode' => 'Google Code',
'hemisu-light' => 'Hemisu Light',
'idea' => 'IDEA',
'ir_black' => 'IR_Black',
'magula' => 'Magula',
'monokai' => 'Monokai',
'pojoaque' => 'Pojoaque',
'rainbow' => 'Rainbow',
'school_book' => 'School Book',
'solarized_dark' => 'Solarized Dark',
'solarized_light' => 'Solarized Light',
'sunburst' => 'Sunburst',
'tomorrow' => 'Tomorrow',
'tomorrow-night' => 'Tomorrow Night',
'tomorrow-night-blue' => 'Tomorrow Night Blue',
'tomorrow-night-bright' => 'Tomorrow Night Bright',
'tomorrow-night-eighties' => 'Tomorrow Night Eighties',
'vs' => 'Visual Studio',
'xcode' => 'XCode',
'zenburn' => 'Zenburn'
);
$txt['ch_tab'] = 'Anzahl der Zeichen zwischen den Kolonnen';
$txt['ch_fontsize'] = 'Schriftgröße';
$txt['ch_example'] = 'Vorschau';
?>
works with version 2.1? :C
Made translation into French and French-utf8.
Added CSS property for bug correcting in longs lines:
word-wrap: break-word;
Download here : code_highlighting.zip (http://ovh.to/xCEyhC)
Please add these languages and CSS correction to the mod, please, and then remove this post.
Traduction française effectuée vers french et french-utf8
Ajout d'une propriété CSS pour corriger un bug en cas le lignes longues sans espaces :
word-wrap: break-word;
Téléchargez ici : code_highlighting.zip (http://ovh.to/xCEyhC)
Merci d'ajouter ces langues et la correction CSS au mod, SVP, et de supprimer ce post ensuite.
Just had a quick question, Is there a SIZE LIMIT, Character wise?? When I did the Install/Test I just so happened to have Subs.php in Notepad++ and cut and pasted it in and the bottom half was cut off and the {/code} was omitted due to the cut off which pretty much breaks the {code}/{/code} structure...
Other wise love the MOD!
Also I've Downloaded the highlight.js from the link provided on page 1, And I Found the Java File, But Can't find "/css/highlight/" Directory to add the styles that came with the Download from Highlight.js??
Should I just make it?? I see you have styles in yours and can't locate them anywhere...
Mike
Salut,
Sorry, i'm not speak english.
I speak french...
Les fichiers de style sont chargés à distance sur la plateforme web http://cdnjs.cloudflare.com (The style files are loaded remotely on the web platform cloudflare.com)
Tu trouveras dans le fichier /sources/Subs-Highlight.php à la ligne 72. (You will find in the file line 72)
Cette procédure ne m'a pas fait plaisir quand je l'ai remarqué. (This procedure I was not pleased when I noticed it.)
J'ai donc copié tous les fichiers css stockés chez cloudflare.com pour les installer sur mon site. (I then copied all the css files that are stored in cloudflare.com for install on my site.)
Il suffit juste de modifier la ligne 72 pour qu'elle charge le css depuis ton site. (Simply just change line 72 so it loads the css from your site.)
Original :
<link rel="stylesheet" type="text/css" href="http://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.4/styles/' . $modSettings['ch_style'] . '.min.css" />
Modified : (css stocké dans le dossier /Themes/css/highlight/)
<link rel="stylesheet" type="text/css" href="'. $settings['default_theme_url']. '/css/highlight/'. $modSettings['ch_style'] . '.min.css" />
Si tu veux tous les fichiers CSS, tu peux les télécharger ici : (If you want all the CSS files, you can download them here:)
http://ovh.to/ZkmqXC (http://ovh.to/ZkmqXC) (this directory is protected with a index.php)
Install the directory /highlight/ in /Themes/default/css/
Enjoy ! ;)
EDIT
Translate French to English attempt... :-[
Ok, Google Translate est notre ven
Qui fonctionne bien, et de très bonnes informations, merci!
mike
FOR OTHERS:
QuoteHi,
Sorry, i'm not speak English.
I speak french ...
Style files are loaded remotely on the web platform http://cdnjs.cloudflare.com (The style files are loaded remotely on the web platform cloudflare.com)
You will find in the /sources/Subs-Highlight.php file in line 72. (You will find in the file line 72)
This procedure does not make me happy when I noticed. (This procedure I Was not pleased when i Noticed it.)
So I copied all the css files stored in cloudflare.com to install on my site. (Then I copied all the css files are Stored in That cloudflare.com for install on my site.)
You just have to change the line 72 so that it loads the CSS from your site. (Just 72 Simply change line so it loads the CSS from your site.)
Original:
Code: [Select]
<Link rel = "stylesheet" type = "text / css" href = "http://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.4/styles/ '. $ ModSettings [' ch_style '].' .min.css "/>
Modified (CSS stored in the / Themes / css / highlight /)
Code: [Select]
<Link rel = "stylesheet" type = "text / css" href = "'. $ Settings [' default_theme_url '].' / Css / highlight / '. $ ModSettings [' ch_style '].' .min.css" / >
If you want all the CSS files, you can download them here: (If you want all the CSS files, you can download 'em here :)
http://ovh.to/ZkmqXC (this directory is protected with a index.php)
Install the directory / highlight / in / Themes / default / css /
Enjoy! ;)
Quote from: alexetgus on August 05, 2015, 06:58:38 PM
Salut,
Sorry, i'm not speak english.
I speak french...
Les fichiers de style sont chargés à distance sur la plateforme web http://cdnjs.cloudflare.com (The style files are loaded remotely on the web platform cloudflare.com)
Tu trouveras dans le fichier /sources/Subs-Highlight.php à la ligne 72. (You will find in the file line 72)
Cette procédure ne m'a pas fait plaisir quand je l'ai remarqué. (This procedure I was not pleased when I noticed it.)
J'ai donc copié tous les fichiers css stockés chez cloudflare.com pour les installer sur mon site. (I then copied all the css files that are stored in cloudflare.com for install on my site.)
Il suffit juste de modifier la ligne 72 pour qu'elle charge le css depuis ton site. (Simply just change line 72 so it loads the css from your site.)
Original :
<link rel="stylesheet" type="text/css" href="http://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.4/styles/' . $modSettings['ch_style'] . '.min.css" />
Modified : (css stocké dans le dossier /Themes/css/highlight/)
<link rel="stylesheet" type="text/css" href="'. $settings['default_theme_url']. '/css/highlight/'. $modSettings['ch_style'] . '.min.css" />
Si tu veux tous les fichiers CSS, tu peux les télécharger ici : (If you want all the CSS files, you can download them here:)
http://ovh.to/ZkmqXC (http://ovh.to/ZkmqXC) (this directory is protected with a index.php)
Install the directory /highlight/ in /Themes/default/css/
Enjoy ! ;)
EDIT
Translate French to English attempt... :-[
LOL, n'a pas vu ce que vous avez traduit que vous êtes allé Désolé.
Je essayé cela et cela n'a pas fonctionné, perdu toute évidence et il n'a même pas montrer de nouvelles Css en menu déroulant, je ai même essayé de coder en dur l'URL et il ne fonctionne toujours pas, a bien fonctionné quand je remets le lien original cloudflare ....
Des Idées ??
mike
LOL, Didn't see that you translated as you went Sorry.
I tried this and it didn't work, Lost all Highlighting and It didn't even show new .css in drop down, I even tried HARD-CODING the URL and it still didn't work, Worked fine when I put it back to the original cloudflare link....
Any Ideas??
Mike
Quote from: Miker1029 on August 05, 2015, 11:00:26 AM
Just had a quick question, Is there a SIZE LIMIT, Character wise?? When I did the Install/Test I just so happened to have Subs.php in Notepad++ and cut and pasted it in and the bottom half was cut off and the {/code} was omitted due to the cut off which pretty much breaks the {code}/{/code} structure...
Other wise love the MOD!
Also I've Downloaded the highlight.js from the link provided on page 1, And I Found the Java File, But Can't find "/css/highlight/" Directory to add the styles that came with the Download from Highlight.js??
Should I just make it?? I see you have styles in yours and can't locate them anywhere...
Mike
BUMP?
Salut !
On va retenter.
- Télécharge les fichiers CSS ici : http://ovh.to/ZkmqXC (http://ovh.to/ZkmqXC)
- Extrait le contenu du fichier zip dans le répertoire : /Themes/default/css/
Tu obtiendras un répertoire : /Themes/default/css/highlight/
- Ouvre avec un éditeur de texte le fichier : /sources/Subs-Highlight.php
Recherche la ligne :
<link rel="stylesheet" type="text/css" href="http://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.4/styles/' . $modSettings['ch_style'] . '.min.css" />
Et remplace la par :
<link rel="stylesheet" type="text/css" href="'. $settings['default_theme_url']. '/css/highlight/'. $modSettings['ch_style'] . '.min.css" />
- Enregistre.
- Vide le cache de ton navigateur.
Et voilà ! :)
! EDIT !
Ne touche pas le fichier /Themes/default/css/highlight.css !
Quote from: alexetgus on August 21, 2015, 03:34:51 PM
Salut !
On va retenter.
- Télécharge les fichiers CSS ici : http://ovh.to/ZkmqXC (http://ovh.to/ZkmqXC)
- Extrait le contenu du fichier zip dans le répertoire : /Themes/default/css/
Tu obtiendras un répertoire : /Themes/default/css/highlight/
- Ouvre avec un éditeur de texte le fichier : /sources/Subs-Highlight.php
Recherche la ligne :
<link rel="stylesheet" type="text/css" href="http://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.4/styles/' . $modSettings['ch_style'] . '.min.css" />
Et remplace la par :
<link rel="stylesheet" type="text/css" href="'. $settings['default_theme_url']. '/css/highlight/'. $modSettings['ch_style'] . '.min.css" />
- Enregistre.
- Vide le cache de ton navigateur.
Et voilà ! :)
Ya je l'ai fait, mais je suis allé sur le site qui contient le nouveau code de surligneur, et ils ont un .ZIP là qui a des couleurs de surbrillance Plus, qui pourrait être le problème, mais je ne faire tout cela, et comme je l'ai dit, il ne fonctionne pas avec le thème TOUT clou ...
Donc je suppose que je vais essayer à partir du lien de DL que vous avez fournis et de lui donner un coup de feu à nouveau, Parce que je ne l'aime vraiment 3ème intervention d'un tiers ...
Je vous le ferai savoir, et peut-être peux comprendre un moyen d'obtenir les nouveaux points forts dans ...
Merci!
Mike
Ya I Did that but, I went to the website that contained the new Highlighter code, and they have a .ZIP in there that has MORE Highlight colors, which could be the issue, But I did do all that, and as I said, It didn't work with ANY highlight theme ...
So I guess I'll try it from the DL link you provided and give it a shot again, Because I really don't like 3rd party intervention...
I'll let you know, and maybe can figure a way to get the new highlights in...
Thanks!
Mike
Le code que je te donne n'est pas pour le nouveau mod.
Donne moi des nouvelles. ;)
-----------
The code that I give you is not for the new mod on the website.
Give me the news. ;)
No news ? Bah...
Hi,
This mod load CSS and JS on all pages. It's bad for site performance.
JS and CSS should be loaded only on messages, not elsewhere.
To load CSS and JS only in the messages, open the file /Sources/Subs-Highlight.php
Search (line 71 to 81) :
$context['html_headers'] .= '
<link rel="stylesheet" type="text/css" href="http://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.4/styles/' . $modSettings['ch_style'] . '.min.css" />
<link rel="stylesheet" type="text/css" href="' . $settings['default_theme_url'] . '/css/highlight.css" />';
if (isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'showoperations')
return;
if (!WIRELESS && !in_array($context['current_action'], array('helpadmin', 'printpage')))
$context['insert_after_template'] .= '
<script type="text/javascript" src="' . $settings['default_theme_url'] . '/scripts/highlight.pack.js"></script>
<script type="text/javascript">hljs.tabReplace = "' . $tab . '"; hljs.initHighlightingOnLoad();</script>';
Replace for :
$hl = preg_match('/topic|msg|action=recent|action=unreadreplies|action=admin/i', $_SERVER['REQUEST_URI']) ? TRUE : FALSE;
if($hl) $context['html_headers'] .= '
<link rel="stylesheet" type="text/css" href="http://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.4/styles/' . $modSettings['ch_style'] . '.min.css" />
<link rel="stylesheet" type="text/css" href="'. $settings['default_theme_url']. '/css/highlight/highlight.css" />';
if (isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'showoperations')
return;
if (!WIRELESS && !in_array($context['current_action'], array('helpadmin', 'printpage')))
if($hl)
{
$context['insert_after_template'] .= '
<script type="text/javascript" src="' . $settings['default_theme_url'] . '/scripts/highlight.pack.js"></script>
<script type="text/javascript">hljs.tabReplace = "' . $tab . '"; hljs.initHighlightingOnLoad();</script>';
}
From now on, the mod will not be charged on all pages. :)
PS :
If the CSS is hosted on your site as explained above.
REPLACE line :
<link rel="stylesheet" type="text/css" href="http://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.4/styles/' . $modSettings['ch_style'] . '.min.css" />
For :
<link rel="stylesheet" type="text/css" href="'. $settings['default_theme_url']. '/css/highlight/'. $modSettings['ch_style'] . '.min.css" />
Sorry for my english. I not speak english. I'm french... :-[
Recall.
Directory /highlight/ contened CSS files for local storage in your website.
https://copy.com/1roGnaxqHSaqE71p (https://copy.com/1roGnaxqHSaqE71p)
Mod translated into French and French-utf8
https://copy.com/eeRnYYPOfwblSNtx (https://copy.com/eeRnYYPOfwblSNtx)
Enjoy ! :)
Thanks for translation and your suggestions :)
It's a gift. ;)
I am not sure if this was answered in here before, part of posts is in other languages, but I have a tiny problem
After I installed this addon if worked fine, but when I do commenting of the code with two backslashes it doesn't seem to work, as it greys out everything in the next lines past the comments too.
(https://image.ibb.co/eCtjt5/Capture.png)
Is there a fix for this?
@T-Bone225
The responsible is the JavaScript...
Fix error in PHP 7.x => "Parameter 1 to ch_buffer() expected to be a reference, value given"
Open file /Sources/Subs-Highlight.php in your text editor.
Search : (line 109 in version 1.1)
function ch_buffer(&$buffer)
Replace with :
function ch_buffer($buffer)
Enjoy! :)
Quote from: alexetgus on May 23, 2017, 07:05:52 AM
@T-Bone225
The responsible is the JavaScript...
Fix error in PHP 7.x => "Parameter 1 to ch_buffer() expected to be a reference, value given"
Open file /Sources/Subs-Highlight.php in your text editor.
Search : (line 109 in version 1.1)
function ch_buffer(&$buffer)
Replace with :
function ch_buffer($buffer)
Enjoy! :)
I tried just that, didn't seem to resolve the issue. Nothing changed.
But thanks for attempt to help :)
The mod is a fork of https://highlightjs.org/ (https://highlightjs.org/).
The Github repository is https://github.com/isagalaev/highlight.js (https://github.com/isagalaev/highlight.js)
Thanks, Bugo, for your working ! ;)
French translation
Traduction française.
French
<?php
/**
* .french.php
*
* @package Code Highlighting
* @author Bugo https://dragomano.ru/mods/code-highlighting
* @French translation by Alex - https://chez-oim.org
*
*/
$txt['ch_title'] = 'Coloration de la syntaxe';
$txt['ch_settings'] = 'Paramètres de la coloration';
$txt['ch_desc'] = 'Ici, vous pouvez activer/désactiver la mise en surbrillance, choisir le thème de style préféré, etc.';
$txt['ch_enable'] = 'Activer la coloration syntaxique';
$txt['ch_cdn_use'] = 'Utiliser un CDN pour charger les scripts et styles';
$txt['ch_style'] = 'Style de la coloration syntaxique';
$txt['ch_tab'] = 'Nombre de d\'espaces pour les tabulations (indentation)';
$txt['ch_fontsize'] = 'Taille des caractères';
$txt['ch_example'] = 'Exemple';
$txt['ch_copy'] = 'Copier';
French-utf8
(ATTENTION ! Copie non recommandée, téléchargez le fichier ci dessous. C'est plus prudent.
WARNING ! Copy not recommended, download the file below. It's more careful.)
<?php
/**
* .french-utf8.php
*
* @package Code Highlighting
* @author Bugo https://dragomano.ru/mods/code-highlighting
* @French translation by Alex - https://chez-oim.org
*
*/
$txt['ch_title'] = 'Coloration de la syntaxe';
$txt['ch_settings'] = 'Paramètres de la coloration';
$txt['ch_desc'] = 'Ici, vous pouvez activer/désactiver la mise en surbrillance, choisir le thème de style préféré, etc.';
$txt['ch_enable'] = 'Activer la coloration syntaxique';
$txt['ch_cdn_use'] = 'Utiliser un CDN pour charger les scripts et styles';
$txt['ch_style'] = 'Style de la coloration syntaxique';
$txt['ch_tab'] = 'Nombre d\'espaces pour les tabulations (indentation)';
$txt['ch_fontsize'] = 'Taille des caractères';
$txt['ch_example'] = 'Exemple';
$txt['ch_copy'] = 'Copier';
Stoquer les fichiers dans le dossier /Themes/default/languages/Highlight
Stock the files in the directory /Themes/default/languages/Highlight
.french.php (https://drive.google.com/open?id=1McmysE2ls0lNiwEG4pfMfugzvc2a5n_i)
.french-utf8.php (https://drive.google.com/open?id=1zdF76nnm-X5glXHMQxLXLka3I5Kw9fw2)
I leave the translation attached to the normal Latin Spanish and utf-8, they should put it inside the folder ../Themes/default/languages/Highlight/
Regards!
Thanks. The mod has updated.
Thanks for all users! :)
Hi Bugo!
Can you help me to integrate your mod into the knwoledge base mod https://custom.simplemachines.org/mods/index.php?mod=3185 ?
In my forum your mod works perfectly, but I would like to have the highlighting inside the kb mod too, if it's possible.
Open Sources/Subs-Highlight.php, find
$hl = preg_match('/topic|msg|action=post|action=recent|action=unreadreplies|action=admin/i', $_SERVER['REQUEST_URI']) ? true : false;
and replace with
$hl = preg_match('/topic|msg|action=post|action=recent|action=unreadreplies|action=admin|action=kb/i', $_SERVER['REQUEST_URI']) ? true : false;
Thank you!
That helped me alot!
Dear Bugo.
Big Problem. Hope you can help me?! Version 1.2 does not work anymore. But has worked wonderfully before. Now I have made an update to Version 1.3. Does not work too. I can not find a mistake . ??? ::).
Erikson
What is your SMF version?
Please, make a screenshot of your settings.
Dear Bugo ;)
SMF Version: - 2.0.15
Screenshot of Settings:
(http://s01.geekpic.net/di-GA3BC2.png)
Notice! - * - You see the Black and White... ??? ::)
Erikson ???
Check these paths:
/Themes/default/scripts/highlight.pack.js
/Themes/default/css/highlight.css
/Themes/default/css/highlight dir
Make sure they exist and not empty.
Dear Bugo,
I checked. Everything okay.
Quote from: Bugo on September 02, 2018, 04:03:14 AM
Check these paths:
/Themes/default/scripts/highlight.pack.js
/Themes/default/css/highlight.css
/Themes/default/css/highlight dir
Make sure they exist and not empty.
Erikson
Well, send me via PM or post here a link to any example message with code on your forum.
Dear Bugo.
PM was send! ;)
Quote from: Bugo on September 03, 2018, 01:18:07 AM
Well, send me via PM or post here a link to any example message with code on your forum.
Erikson
Hi,
This is great, i appreciate your work. However there is a bug where if you include the cdn, the format you choose is not displayed, not including the cdn option will show the style.
I also request you add a line number system to the far left, so you can clearly see the code per line and maybe a "preview" option to show without lines that you can toggle.
Quote from: SilverKnight on January 15, 2021, 11:40:59 PM
However there is a bug where if you include the cdn, the format you choose is not displayed, not including the cdn option will show the style.
Can you provide a screenshot of this bug?
Quote from: Bugo on January 16, 2021, 12:39:06 AM
Quote from: SilverKnight on January 15, 2021, 11:40:59 PM
However there is a bug where if you include the cdn, the format you choose is not displayed, not including the cdn option will show the style.
Can you provide a screenshot of this bug?
If "Use CDN service to load highlight scripts and styles is ticked, then it shows basic style":
https://i.imgur.com/lnjuIg5.png
Also , i presume the example in the options should show how the style will look like however is simply stays white regardless of cdn option, as shown:
https://i.imgur.com/BboInWW.png
Regardless of cdn, if you edit a message and preview the post, it will show the correct format aka this:
https://i.imgur.com/sVFni8q.png
Hope this helps.
Well, about your request to display line numbering - I will try to add this as a feature. However, read the opinion of the highlight script developer (https://highlightjs.readthedocs.io/en/latest/line-numbers.html).
As for your problem - the script does not load all languages, but only the selected ones. You should go on https://highlightjs.org/download/ and select desired languages, then upload highligh.pack.js into your /Themes/default/scripts dir. Then disable "Use CDN service..." option.
(https://i.imgur.com/fcsK5yt.png)
Hi,
Smf 2.1 does not scroll right, left mobile
Is there a solution to the problem?
Disable line numbers.
Thanks @Bugo
Alternative solution - replace highlight.css:
.block_code {
position: relative;
}
.block_code pre code {
display: block;
font-family: "DejaVu Sans Mono", Monaco, Consolas, monospace;
white-space: pre-wrap;
}
pre {
overflow: auto;
max-height: 20em;
background: #f6f6f6;
border: 2px solid #ddd;
border-radius: 2px;
position: relative;
}
.bd-clipboard {
position: relative;
display: none;
}
@media (min-width: 768px) {
.bd-clipboard {
display: block;
}
}
.bd-clipboard+pre{
margin-top:0;
}
pre .btn-clipboard {
position: absolute;
right: 4px;
top: 4px;
background-color: #eee;
border-color: #ddd;
border-radius: 2px;
background-image: url(../images/clippy.svg);
background-position: 50% 50%;
background-size: 16px 16px;
background-repeat: no-repeat;
width: 27px;
height: 1.525rem;
display: inline-block;
vertical-align: middle;
background-color: #f9f2f4;
margin-left: -.2rem;
cursor: pointer;
}
.btn-clipboard:hover {
background-color: #d9d9d9;
}
.hljs-ln-numbers {
text-align: center;
color: #f36;
border-right: 1px solid #f36;
vertical-align: top;
min-width: 25px;
}
.hljs-ln-code {
padding-left: 10px !important;
}
Hi, I tried adding Code Highlighting (https://custom.simplemachines.org/mods/index.php?mod=2925) in my forum (https://alkisg.mysch.gr/steki/), but I had the following problem:
sudo -i
apt update && apt full-upgrade --yes && apt purge --auto-remove $(dpkg -l | awk '/^rc/ { print $2 }')
In the above example, when code highlighting is active, it displays "print Bash" instead of "print $2". I guess Bash comes from the language, code=Bash.
So I disabled the highlighting until we can find a solution. Any workarounds? Thank you!
Hello,
@Bugo
Php, css, html etc. nice to color highlight.js
But not sensible coloring in other languages. (Even though i tried Custom package)
Prism.js coloring sensible. https://prismjs.com/test.html
How can I use prism.js instead of highlight.pack.js
@alkisg, try to use [code]your code[/code] instead of [code=Bash]your code[/code]. Perhaps I will solve this issue in the future.
Hi Bugo, unfortunately I can't do that because I would have to modify hundreds of existing posts. We were using the geshi plugin in the past, so we already have a lot of such posts.
For now, I completely disabled code highlighting. Thank you for your feedback!
Hi there,
With the latest mod (v1.4.1) for SMF 2.0, line breaks no longer exist if you enable line numbering!
That's a shame! :'(
When the hooks are installed, nothing goes right...
Before:
(https://i.imgur.com/MzgAgfz.png)
After :
(https://i.imgur.com/cgGpp8d.png)
number-lines-off.png
number-lines-on.png
v1.0 (SMF 2.1), v1.5 (SMF 2.0)- Updated the script and styles
- Fixed found issues
Cool, the bug is gone! :)
Thanks Bugo. ;)
Hi,
@Bugo old topic have line issues. Displaying contiguous without line spaces.
SMF 2.1.1
Code Highlighting 1.0 (2.1)
Old topic;Untitled 1.png
Edit topic (without changes) Untitled 2.png
Refresh the page Untitled 3.png
Send me the current and the correct versions of this code via https://www.toptal.com/developers/hastebin/
https://www.toptal.com/developers/hastebin/havebimato.cpp
Note: In the new topic, these codes do not cause problems.
Are you using automatic language detection or specify lang by manual via [code=cpp][/code]?
Try to disable line numbers or disable the whole syntax highlighting — does it resolve the problem?
Alternatively, try the PrismJS (https://github.com/dragomano/PrismJS-for-SMF) mod.
I am using automatic language detection. I tried disabling numbering it didn't work
This issue only appears on old topic.
I'm trying Prismjs now thanks.
"Old topics" - do you mean those topics that were created in SMF 2.0?
Look into your database and compare an old and a new topic with the same content.
I'm currently trying to use prismjs-for-SMF and I bumped into a similar issue. The reason was that older posts use `<br />` instead of `<br>`. The fix would be to change this line (https://github.com/dragomano/highlight.js-for-SMF/blob/master/Sources/Class-Highlighting.php#L167):
// from:
return str_replace('<br>', "\n", $matches[0]);
// to:
return str_replace(['<br>', '<br />'], "\n", $matches[0]);
Hi,
@Bugo Long texts are not visible on mobile. add right left scrollbar?
1.png
2.png
Hi,
@Bugo thanks for the update.
Does this mod work for 2.0.19? If not, is there any alternative? Thanks.
Quote from: ramcor on September 06, 2022, 07:00:06 AMDoes this mod work for 2.0.19? If not, is there any alternative? Thanks.
Yes, this mod works in 2.0.19
Personally, I modified the CSS. It didn't really suit me.
But everyone does as they please. ;)
Hi all! I installed the mod in SMF 2.1.3 and I can't see the highlight in the code
(https://i.imgur.com/codknva.png)
Thanks in advanced
Try to disable loading from CDN.
Quote from: alexetgus on September 06, 2022, 10:17:18 AMYes, this mod works in 2.0.19
When I try and install 1.2.3 on SMF 2.0.19 it says its incompatible or corrupt :(
Quote from: Bugo on February 08, 2023, 11:14:39 PMTry to disable loading from CDN.
I tried, but is not working..
Well, try to install a similar mod - https://github.com/dragomano/PrismJS-for-SMF
Quote from: Bugo on February 10, 2023, 12:47:23 AMWell, try to install a similar mod - https://github.com/dragomano/PrismJS-for-SMF
Yes it works! thanks!
If anyone has a copy of code_highlighting_1.5_smf20.zip that would be handy! I can see in on the WayBackMachine but I cant actually download it!
@Bugo Its fine that you don't wanna support older versions - but it would be helpful if you provided an archive of unsupported past versions of your mods.
You are lucky, Melonking, I found your happiness in my archives. :)
code_highlighting_1.5_smf20.zip
Quote from: alexetgus on February 12, 2023, 10:42:36 AMYou are lucky, Melonking, I found your happiness in my archives. :)
[url="https://www.simplemachines.org/community/index.php?action=dlattach;attach=285684;type=preview;file"]code_highlighting_1.5_smf20.zip[/url]
This is great thank you - it works! AND I love all the themes ;D ;D