Closed GoogleCodeExporter closed 8 years ago
Sorry,I'm busy lately.
Current you can try this(not in debug off mode)
color | set c=
set c=%c:~15,2%
if "%c:~-1%"=="," set c=%c:~0,-1%
set standard=0x%c%
Original comment by chenall.cn
on 13 Oct 2013 at 1:25
Thanks! I didn't know that color command displayed current standard color!
Original comment by Steve6375
on 13 Oct 2013 at 7:59
If you just want to change the text colour but not the background color, then
you have to do something like this. Would be easier if color values where at
known locations???
!BAT
# USAGE: set emsg=your message set emsgcol=4 call /PrintMsg.g4b
# Note: debug is turned on
# assumes emsg is the text we want to display at current cursor position -
background text colour is not altered
if "%emsg%"=="" set emsg=\nWARNING\n\x20 No emsg variable set before calling
%0 \x20\n
# emsgcol is the TEXT colour 0-F only or rrggbb (must be either 1 hex digit or
3+hex digits but not 2 hex digits) - e.g. red text = 4 or ff0000
#if "%emsgcol%"=="" set emsgcol=ff4032
if "%emsgcol%"=="" echo -e -n %emsg% && exit
debug on
color | set c= ;; set stdb=%c:~15,1% ;; set stdf=%c:~16,1% ;; if "%stdf%"==","
set stdf=%stdb% && set stdb=0
set stdh=%c:~18,10% ;; set stdh=0x%stdh%
set /A e=0x%emsgcol%+0 > nul
if %emsgcol%>=0x100 color standard %e% || color standard 0x%stdb%%%emsgcol%
echo -e -n %emsg%
color standard 0x%stdb%%%stdf% ;; color standard %stdh%
set c= ;; set e= ;; set stdh= ;; set stdb= ;; set stdf=
Original comment by Steve6375
on 15 Oct 2013 at 2:07
There is another way to get current color
//32bit color
#define current_color ((*(int **)0x8304)[42])
//64bit color
#define foreground ((*(int **)0x8304)[43])
//64bit color
#define background ((*(int **)0x8304)[44])
so it's easy to get the color
eg
calc 44<<2 + *0x8304 ;; read %@retval% ;; set color_bg=%@retval%
calc 43<<2 + *0x8304 ;; read %@retval% ;; set color_fg=%@retval%
Original comment by chenall.cn
on 15 Oct 2013 at 5:10
Thats much better and I don't have to turn on debug :-)
thanks!
Original comment by Steve6375
on 15 Oct 2013 at 6:13
Original comment by chenall.cn
on 16 Oct 2013 at 2:11
Original issue reported on code.google.com by
Steve6375
on 11 Sep 2013 at 8:00