⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bmfed.pas

📁 bmf汉字预览显示
💻 PAS
📖 第 1 页 / 共 2 页
字号:
      bmf.loadAsFN(str);
      filename:=system.copy(lcased(filename),1,length(filename)-3)+'.bmf';
    end else bmf.load(str);
    str.done;
  end else begin
    bmf.tablo['A'].resize(10,10);
    zoom:=4;
  end;
  WINH:=ScrHeight-20;
  scr.init(0,0,ScrWidth,ScrHeight);
  InitMouse; evAutoLimit:=1;
  with ed do begin
    init(0,ScrHeight-50,ScrWidth,50,@bmf,ofs(fontpals[fpMAIN]));
    blcolor:=nearestColor(32,32,63,fontmethod);
    text:=bmf.name;
  end;
  color:=bmf.colorsUsed shr 16; PAD0CHAR:=' ';
  repeat
    with bmf.tablo[c] do begin
    scr.paint(0); if moving then scr.quad(0,ScrHeight-3,256,3,243);
    fw(0,0,'char dec hex   relx   rely  width height  shift addspc szover szundr lnhigh',249,1);
    drawPalBelt; bmf.dest:=@scr; bmf.writexy(ed.x,ed.y,ed.text);
    fw(12,7,c+' '
     +pad0(ord(c),3)+'  '
     +system.copy(hex(ord(c)),7,2)+'    '
     +pad0(relx,3)+'    '
     +pad0(rely,3)+'    '
     +pad0(w,3)+'    '
     +pad0(h,3)+'    '
     +pad0(shift,3)+'    '
     +pad0(bmf.addspace,3)+'  '
     +pad0(bmf.sizeover,5)+'  '
     +pad0(bmf.sizeunder,5)+'  '
     +pad0(bmf.lineheight,5),254,1);
    scr.quad(WINX-1,WINY-1,w*zoom+2,h*zoom+2,243);
    showchar(c);
    if e.typ=evMOUSE then begin
      mx:=e.x;
      my:=e.y;
    end;
    for i:=0 to 255 do begin
      if selected[i] or (i=ord(c)) then scr.quad(ScrWidth-16*8+i and 15*8,CHARBELTY+i and $F0 shr 1,8,8,either(i=ord(c),253,247));
      fw(ScrWidth-16*8+i and 15*8,CHARBELTY+i and $F0 shr 1,char(i),244-byte(selected[i]),0);
    end;
    inside:=contains((mx-WINX) div zoom,(my-WINY) div zoom); j:=1;
    if inside then i:=getPoint((mx-WINX) div zoom,(my-WINY) div zoom) else i:=-1;
    if isin(mx,0,PALDOT-1) and isin(my,WINY,WINY+PALDOT*32) then i:=(my-WINY) div PALDOT else j:=0;
    fw(192,14,'['+inttostr(either(inside,(mx-WINX) div zoom,mx))+','+inttostr(either(inside,(my-WINY) div zoom,my))+']='+inttostr(i)+eitherS(j=0,'',' {'+inttostr(pal[i*3])+','+inttostr(pal[i*3+1])+','+inttostr(pal[i*3+2])+'}'),243,1);
    fw(300,0,timestr,243,1); fw(300,7,chr(either(mem[ROM_KEYFLAGS] and kfNUMLOCK<>0,ord('N'),32))+chr(either(mem[ROM_KEYFLAGS] and kfCAPSLOCK<>0,ord('C'),32))+chr(either(mem[ROM_KEYFLAGS] and kfSCROLLLOCK<>0,ord('S'),32))+chr(either(mem[ROM_KEYFLAGS] and kfINSERT<>0,ord('I'),32)),244,1);
    xorcursor(mx,my);
    flip;
    repeat until GetEvent(e);
    case e.typ of
    evKEYBOARD:
      case e.key of
      #0:
        case e.keyext of
        'H': if my<=16 then dowithchars('81') else if not moving then dec(c,16) else if mem[ROM_KEYFLAGS] and kfANYSHIFT=0 then dowithchars('82') else dowithchars('83');
        'P': if my<=16 then dowithchars('21') else if not moving then inc(c,16) else if mem[ROM_KEYFLAGS] and kfANYSHIFT=0 then dowithchars('22') else dowithchars('23');
        'K': if my<=16 then dowithchars('41') else if not moving then dec(c) else if mem[ROM_KEYFLAGS] and kfANYSHIFT=0 then dowithchars('42') else dowithchars('43');
        'M': if my<=16 then dowithchars('61') else if not moving then inc(c) else if mem[ROM_KEYFLAGS] and kfANYSHIFT=0 then dowithchars('62') else dowithchars('63');
        's','t',#18,#19,#20,#21,#22,#23,#25,#32,#35,#47,#16,#30,#31,#38,'S',#49,'0':
          begin
            undo.copyToMe(@bmf.tablo[c]);
            dowithchars(e.keyext);
          end;
        'G': c:=#32;
        'O': c:=#127;
        '<': {F2}
          begin
            bmf.name:=ed.text;
            fw(120,96,'Saving...',254,1);
            str.openOrCreate(eitherS(e.keyext='<',filename,'out.bmf'));
            bmf.save(str);
            str.truncate;
            fw(120,104,eitherS(str.ok,'Saved.','Error!'),254,1); flip;
            waitflicks(either(str.ok,20,70));
            str.done;
          end;
        '=': {F3}
          begin
            str.init(filename);
            bmf.init0;
            bmf.load(str);
            str.done;
          end;
        'i': {alt-F2}
          repeat
            str.openOrCreate('bmfed.tmp');
            str.truncate;
            for i:=0 to 255 do
              if selected[i] then begin
                str.write(i,1);
                fw(120,104,eitherS(str.ok,'Saving char #'+inttostr(i),'Error saving chars!'),254,$81); flip;
                bmf.tablo[char(i)].save(str);
              end;
            str.truncate;
            str.done;
          until true;
        'j': {alt-F3}
          repeat
            str.init('bmfed.tmp'); i:=0;
            while str.ok do begin
              str.read(i,1);
              fw(120,104,eitherS(str.ok,'Loading char #'+inttostr(i),'Error loading chars!'),254,$81); flip;
              selected[i]:=true;
              with bmf.tablo[chr(i)] do begin
                free;
                load(str);
              end;
            end;
            str.done;
          until true;
        'I': if inside then dowithchars('5+') else dowithchars('5^');
        'Q': if inside then dowithchars('5-') else dowithchars('5v');
        #132:color:=bounded(color-1,0,31);
        'v': if e.keyflags and kfANYSHIFT=0 then color:=bounded(color+1,0,31) else dowithchars('5*');
        '!': {alt-f}
          if inside and (e.keyflags and kfCTRL=0) then begin
            j:=getpoint((mx-WINX) div zoom,(my-WINY) div zoom);
            if e.keyflags and kfSCROLLLOCK=0 then
              for i:=0 to w-1 do
                if getpoint(i,(my-WINY) div zoom)=j then setpoint(i,(my-WINY) div zoom,color) else
            else
              for k:=0 to 255 do with bmf.tablo[char(k)] do
                for i:=0 to w-1 do
                  if getpoint(i,(my-WINY) div zoom-rely+bmf.tablo[c].rely)=j then setpoint(i,(my-WINY) div zoom-rely+bmf.tablo[c].rely,color);
          end else begin
            m:=bmf.colorsUsed shr 16; k:=0;
            for c:=#0 to #255 do with bmf.tablo[c] do
              if k<>0 then break else
                for j:=0 to h-1 do
                  if k<>0 then break else
                    for i:=0 to w-1 do
                      if getPoint(i,j)=m then begin
                        dec(c);
                        placeMouseCursor(WINX+i*zoom,WINY+j*zoom);
                        k:=1;
                        break;
                      end;
          end;
        'R': {Insert}
          begin
            scr.quad(0,ScrHeight-3,256,3,248);
            k:=bounded(tb.x,0,w-tb.w); l:=bounded(tb.y,0,h-tb.h);
            undo.copyToMe(@bmf.tablo[c]);
            repeat
              if empty or tb.empty then break;
              bmf.tablo[c].copyToMe(@undo);
              bmf.tablo[c].pasteInMe(k,l,@tb);
              fw(192,14,'PASTE '+inttostr(k)+','+inttostr(l)+'  ',244,$81);
              for j:=0 to pred(h) do
                for i:=0 to pred(w) do
                  scr.quad(WINX+i*zoom,WINY+j*zoom,zoom,zoom,getpoint(i,j));
              flip;
              repeat until getEvent(e);
              if e.typ=evKEYBOARD then
                case e.key of
                #27: begin bmf.tablo[c].copyToMe(@undo); break; end;
                #13: break;
                #0:
                  case e.keyext of
                  'H': l:=bounded(l-1,-tb.h,h);
                  'P': l:=bounded(l+1,-tb.h,h);
                  'K': k:=bounded(k-1,-tb.w,w);
                  'M': k:=bounded(k+1,-tb.w,w);
                  'I': l:=0;
                  'Q': l:=h-tb.h;
                  'G': k:=0;
                  'O': k:=w-tb.w;
                  'R': tb.method:=either(tb.method=mtTransparent,mtMovsd,mtTransparent);
                  '/': tb.flipV;
                  '#': tb.flipH;
                  #20: tb.turnRight;
                  #23: for j:=0 to tb.h-1 do for i:=0 to tb.w-1 do tb.setpoint(i,j,color-tb.getpoint(i,j));
                  'S': begin bmf.tablo[c].copyToMe(@undo); break; end;
                  end;
                end;
            until false;
          end;
      '2': //alt-m, macro
        if e.keyflags=0 then
          for k:=0 to 255 do with bmf.tablo[char(k)] do
            if (w or h=0) and (k<>32)
            then shift:=0
            else begin relx:=(bmf.tablo[' '].shift-w) div 2; shift:=bmf.tablo[' '].shift; end
        else if e.keyflags and kfANYSHIFT<>0 then
          if e.keyflags and kfRIGHTSHIFT<>0 then cz_macro2 else cz_macro;
      end;
      #26: bmf.tablo[c].copyToMe(@undo); {ctrl-z}
      #27: {ctrl-[ or escape}
        if e.keyscan=1 then begin
          e.typ:=evMESSAGE;
          e.msgCode:=msgQuit;
        end else begin
          tc:=bmf.tablo[#255];
          for i:=255 downto 1 do bmf.tablo[char(i)]:=bmf.tablo[char(pred(i))];
          bmf.tablo[#0]:=tc;
          tc.init0;
        end;
      #29: {ctrl-]}
        begin
          tc:=bmf.tablo[#0];
          for i:=0 to 254 do bmf.tablo[char(i)]:=bmf.tablo[char(succ(i))];
          bmf.tablo[#255]:=tc;
          tc.init0;
        end;
      #1: {ctrl-a}
        tb.copyToMe(@bmf.tablo[c]);
      '+': {if e.keyscan<>78 then c:='+' else} if zoom<16 then inc(zoom);
      '-': {if e.keyscan<>74 then c:='-' else} if zoom>1 then dec(zoom);
      '?': if inside then color:=getPoint((mx-WINX) div zoom,(my-WINY) div zoom);
      #13: if my<=16 then dowithchars('31') else ed.text:=ed.input(ed.text,255,255);
      ' ': if (mx>=ScrWidth-16*8) and isin(my,CHARBELTY,CHARBELTY+16*8-1) then selected[ord(c)]:=not selected[ord(c)] else moving:=not moving;
      #127: {ctrl-backspace}
        if mx>=WINX then begin
          undo.copyToMe(@bmf.tablo[c]);
          dowithchars(#127);
        end;
      #3,#24: {ctrl-c, ctrl-x}
           begin
             tc.copyToMe(@bmf.tablo[c]);
             if e.key=#24 then bmf.tablo[c].free;
           end;
      #22: if e.keyscan<>47 then c:=#22 else begin undo.copyToMe(@bmf.tablo[c]); bmf.tablo[c].copyToMe(@tc); end; {ctrl-v}
      'r': if mx<WINX then setRGB(color,(pal[color*3]+1) and 63,pal[color*3+1],pal[color*3+2]) else c:='r';
      'R': if mx<WINX then setRGB(color,(pal[color*3]-1) and 63,pal[color*3+1],pal[color*3+2]) else c:='R';
      'g': if mx<WINX then setRGB(color,pal[color*3],(pal[color*3+1]+1) and 63,pal[color*3+2]) else c:='g';
      'G': if mx<WINX then setRGB(color,pal[color*3],(pal[color*3+1]-1) and 63,pal[color*3+2]) else c:='G';
      'b': if mx<WINX then setRGB(color,pal[color*3],pal[color*3+1],(pal[color*3+2]+1) and 63) else c:='b';
      'B': if mx<WINX then setRGB(color,pal[color*3],pal[color*3+1],(pal[color*3+2]-1) and 63) else c:='B';
      'a': if mx<WINX then setRGB(color,(pal[color*3]+1) and 63,(pal[color*3+1]+1) and 63,(pal[color*3+2]+1) and 63) else c:='a';
      'A': if mx<WINX then setRGB(color,(pal[color*3]-1) and 63,(pal[color*3+1]-1) and 63,(pal[color*3+2]-1) and 63) else c:='A';
      'o': if mx<WINX then dowithchars('O/') else c:=e.key;
      'x','X':
           if mx>=WINX then c:=e.key else begin
             dowithchars(#128);
             if e.keyflags and kfANYSHIFT<>0 then begin
               i:=(my-WINY) div PALDOT;
               xchg(pal[color*3],pal[i*3],3);
               setRGB(color,pal[color*3],pal[color*3+1],pal[color*3+2]);
               setRGB(i,pal[i*3],pal[i*3+1],pal[i*3+2]);
             end;
           end;
      #16: if e.keyflags and kfANYSHIFT<>0 then {ctrl-p}
             for i:=0 to 31 do setRGB(i,i*2,i*2,i*2)
           else begin
             str.init('bmfed.col');
             if str.ok then
               for i:=0 to pred(max(str.size div 3,64)) do begin
                 str.read(j,3);
                 setRGB(i,byte(j),byte(j shr 8),byte(j shr 16));
               end;
             str.done;
           end;
      else c:=e.key;
      end;
    evMOUSE:
      begin
        if (mx>=ScrWidth-16*8) and isin(my,CHARBELTY,CHARBELTY+16*8-1) then begin
          k:=(my-CHARBELTY) shr 3 shl 4+(mx-(ScrWidth-16*8)) shr 3;
          if e.buttons and mbLEFT<>0 then c:=char(k)
          else if e.action and evRIGHTPRESSED<>0 then selected[k]:=not selected[k];
        end;
        if isin(mx,0,3) and isin(my,WINY,WINY+32*3-1) then
          if e.action and evLEFTPRESSED<>0 then color:=(my-WINY) div 3 else else
        if (e.buttons and (mbLEFT or mbRIGHT)<>0) and inside then
          if mem[ROM_KEYFLAGS] and kfANYALT<>0 then begin
            k:=(e.x-WINX) div zoom; l:=(e.y-WINY) div zoom;
            xorcursor(mx,my);
            repeat
              if e.typ=evMOUSE then begin
                mx:=bounded((e.x-WINX) div zoom,0,w-1);
                my:=bounded((e.y-WINY) div zoom,0,h-1);
                if e.buttons<>0 then m:=e.buttons;
              end;
              undo.copyToMe(@bmf.tablo[c]); line(k,l,mx,my,color); showchar(c);
              fw(192,14,'LINE '+inttostr(abs(mx-k)+1)+'x'+inttostr(abs(my-l)+1)+' ',248,$81);
              flip;
              bmf.tablo[c].copyToMe(@undo);
              repeat until GetEvent(e);
              if (e.typ=evMOUSE) and (e.buttons and (mbLEFT or mbRIGHT)=0) then break;
              if (e.typ=evKEYBOARD) and (e.keyscan=1) then break;
            until false;
            mx:=(bounded(e.x,WINX,WINX+width*zoom-1)-WINX) div zoom; my:=(bounded(e.y,WINY,WINY+height*zoom-1)-WINY) div zoom;
            undo.copyToMe(@bmf.tablo[c]);
            line(k,l,mx,my,color);
          end else if mem[ROM_KEYFLAGS] and kfANYSHIFT=0 then
            if (e.action and (evMOUSEAUTO or evRIGHTPRESSED)<>0) then
              if mem[ROM_KEYFLAGS] and kfCAPSLOCK<>0 then begin
                mx:=(mx-WINX) div zoom; my:=(my-WINY) div zoom;
                l:=9; k:=getpoint(mx,my);
                if contains(mx-1,my-1) then inc(k,getpoint(mx-1,my-1)) else dec(l);
                if contains(mx-1,my+1) then inc(k,getpoint(mx-1,my+1)) else dec(l);
                if contains(mx+1,my-1) then inc(k,getpoint(mx+1,my-1)) else dec(l);
                if contains(mx+1,my+1) then inc(k,getpoint(mx+1,my+1)) else dec(l);
                if contains(mx,my-1) then inc(k,getpoint(mx,my-1)) else dec(l);
                if contains(mx,my+1) then inc(k,getpoint(mx,my+1)) else dec(l);
                if contains(mx-1,my) then inc(k,getpoint(mx-1,my)) else dec(l);
                if contains(mx+1,my) then inc(k,getpoint(mx+1,my)) else dec(l);
                setpoint(mx,my,k div l)
              end else setpoint((mx-WINX) div zoom,(my-WINY) div zoom,either(e.buttons and mbRIGHT<>0,0,color)) else
          else if e.buttons and (mbLEFT or mbRIGHT)<>0 then begin
            k:=(e.x-WINX) div zoom; l:=(e.y-WINY) div zoom;
            xorcursor(mx,my);
            repeat
              if e.typ=evMOUSE then begin
                mx:=bounded((e.x-WINX) div zoom,0,w-1);
                my:=bounded((e.y-WINY) div zoom,0,h-1);
                if e.buttons<>0 then m:=e.buttons;
              end;
              xorcursor(WINX+mx*zoom,WINY+my*zoom);
              for j:=min(l,my) to max(l,my) do for i:=min(k,mx) to max(k,mx) do scr.xorpoint(WINX+i*zoom,WINY+j*zoom,$1F);
              fw(192,14,'QUAD '+inttostr(abs(mx-k)+1)+'x'+inttostr(abs(my-l)+1)+' ',248,$81);
              flip;
              xorcursor(WINX+mx*zoom,WINY+my*zoom);
              for j:=min(l,my) to max(l,my) do for i:=min(k,mx) to max(k,mx) do scr.xorpoint(WINX+i*zoom,WINY+j*zoom,$1F);
              repeat until GetEvent(e);
              if (e.typ=evMOUSE) and (e.buttons and (mbLEFT or mbRIGHT)=0) then break;
              if (e.typ=evKEYBOARD) and (e.keyscan=1) then break;
            until false;
            mx:=(bounded(e.x,WINX,WINX+width*zoom-1)-WINX) div zoom; my:=(bounded(e.y,WINY,WINY+height*zoom-1)-WINY) div zoom;
            if e.typ<>evKEYBOARD then
              if m and (mbLEFT or mbRIGHT)=mbLEFT then begin
                undo.copyToMe(@bmf.tablo[c]);
                quad(min(k,mx),min(l,my),abs(mx-k)+1,abs(my-l)+1,color);
              end else if m and (mbLEFT or mbRIGHT)=mbRIGHT then begin
                tb.free;
                tb.init(abs(mx-k)+1,abs(my-l)+1);
                tb.pasteInMe(-min(k,mx),-min(l,my),@bmf.tablo[c]);
                tb.moveto(min(mx,k),min(my,l));
              end;
          end;
      end;
    end;
    end;
  until MessageCode(e)=msgQuit;
  bmf.done;
  die(errOk);
end.

//'5^' a '5v' - add/sub to/from all pixels

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -