Baixe o app para aproveitar ainda mais
Esta é uma pré-visualização de arquivo. Entre para ver o arquivo original
pascalzim/exemplos/AlocacaoDinamica.pas // ------------------------------------------------------------- // Este programa ilustra a alocacao dinamica com ponteiros. // // Problema. Alocar memória para um ponteiro, guardar nele // um valor, depois colocar este valor em uma variável. :~ // ------------------------------------------------------------- Program ExemploPzim ; Var p: ^integer; v : integer ; Begin new( p ); // Aloca memória para armazenar um inteiro p^ := 10 ; // Guarda um inteiro na posição apontada por p writeln( 'Valor armazenado na posicao de memoria: ', p^ ); v:= p^ ; //Guarda em v o inteiro apontado por p writeln( 'Valor armazenado em v: ', v ); dispose( p ); // Libera a memoria amarrada a p readln ; End. pascalzim/exemplos/Aritmetica.pas // ------------------------------------------------------------- // Programa que realiza operações aritméticas usando dados // fornecidos pelo usuário. :~ // // Autor : Rodrigo Garé Pissarro - Beta Tester // Contato : rodrigogare@uol.com.br // ------------------------------------------------------------- Program ExemploPzim ; Var valor1, valor2: Integer; Begin // Solicita dois valores ao usuário write('Informe o primeiro Valor: '); readln(valor1); write('Escreva o segundo Valor: '); readln(valor2); // Mostra resultado de operações aritméticas writeln('a) Soma dos dois números: ', valor1+valor2); writeln('b) Subtração do primeiro pelo segundo: ', valor1-valor2); writeln('c) Subtração do segundo pelo primeiro: ', valor2-valor1); writeln('d) Multiplicação dos dois números: ', valor1*valor2); writeln('e) Resto da divisão do primeiro pelo segundo: ', valor1 mod valor2); writeln('f) Resto da divisão do segundo pelo primeiro: ', valor2 mod valor1); End. pascalzim/exemplos/AtribuicaoPonteiro.pas // ------------------------------------------------------------- // Programa que mostra a utilização de ponteiros. // // Problema. Alterar o valor armazenado em uma variável usando // um ponteiro que aponta para o endereço dessa variável. :~ // ------------------------------------------------------------- Program ExemploPzim ; Var a: integer; p: ^integer; Begin a := 8 ; // Guarda o valor 8 em a p := nil; // O ponteiro não guarda nenhum endereço writeln( 'Valor armazenado em a: ' , a ); // Guarda no ponteiro o endereço da variável a p := @a ; writeln( 'Valor apontado por p: ' , p^ ); // O comando abaixo é equivalente a “a:= 2 * a ;” , pois p // guarda o endereço de a (p aponta para a) a:= 2 * p^ ; writeln( 'O valor de a agora: ' , a ); // Imprime 16 writeln( 'Valor apontado por p: ' , p^ ); // Imprime 16 readln ; End. pascalzim/exemplos/BandeiraFrancesa.pas // ------------------------------------------------------------- // Programa que mostra na tela a bandeira francesa. // // Desenvolvido pelo beta-tester Danilo Rafael Galetti :~ // ------------------------------------------------------------- Program Pzim ; var linha, coluna: integer; Begin // Percorre cada linha da tela de impressao... For linha:=1 to 25 do Begin // Imprime parte blue For coluna:=1 to 25 do Begin gotoxy (coluna,linha); textcolor (blue); write (#178); End; // Imprime parte branca For coluna:=26 to 54 do Begin gotoxy (coluna,linha); textcolor (white); write (#178); End; // Imprime parte vermelho For coluna:=55 to 80 do Begin gotoxy (coluna,linha); textcolor (red); write (#178); End; End; End. pascalzim/exemplos/BandeiraHolandesa.pas // ------------------------------------------------------------- // Programa que mostra na tela a bandeira holandesa. // // Desenvolvido pelo beta-tester Danilo Rafael Galetti :~ // ------------------------------------------------------------- Program Pzim ; var i: integer; Begin // Imprime faixa azul For i:=1 to 640 do begin textcolor (lightblue); write (#178); End; // Imprime faixa branca For i:=1 to 720 do begin textcolor (white); write (#178); End; // Imprime faixa vermelha For i:=1 to 640 do begin textcolor (red); write (#178); End; End. pascalzim/exemplos/BandeiraItaliana.pas // ------------------------------------------------------------- // Programa que mostra na tela a bandeira italiana. // // Desenvolvido pelo beta-tester Danilo Rafael Galetti :~ // ------------------------------------------------------------- Program Pzim ; var linha, coluna: integer; Begin // Percorre cada linha da tela de impressao... For linha:= 1 to 25 do Begin // Imprime parte verde For coluna:= 1 to 25 do Begin gotoxy(coluna,linha); textcolor (lightgreen); write (#178); end; // Imprime parte branca For coluna:= 26 to 54 do Begin gotoxy(coluna,linha); textcolor (white); write (#178); End; // Imprime parte vermelha For coluna:= 55 to 80 do Begin gotoxy(coluna,linha); textcolor (red); write (#178); End; end; End. pascalzim/exemplos/ComplexoTeste.pas // ------------------------------------------------------------------------- // // Programa: testeComplexo // // Versão: 1.0v // // Autor: Raphael Augusto // // Descrição: Algoritmo que testa a unidade complexo // // ------------------------------------------------------------------------- // Program testeComplexo ; uses Complexo; var z1, z2 : NumComplexo; Begin z1 := novo(8, -2); z2 := novo(4, -2); // 8 - 2i mostrar(z1); writeln; // 4 - 2i mostrar(z2); writeln; // 68 writeln(conjugado(z1)); // 4.47 writeln(modulo(z2)); // - 8 + 2i mostrar(oposto(z1)); writeln; // False writeln(igual(z1, z2)); // 12 - 4i mostrar(somar(z1, z2)); writeln; // 4 mostrar(subtrair(z1, z2)); writeln; // 28 - 24i mostrar(multiplicar(z1, z2)); writeln; // 1.8 + 0.4i mostrar(dividir(z1, z2)); writeln; readkey; End. pascalzim/exemplos/Cronometro.pas // ------------------------------------------------------------- // Programa que simula um cromômetro fazendo contagem regressiva // // Desenvolvido pelo beta-tester Danilo Rafael Galetti :~ // ------------------------------------------------------------- Program Pzim ; var tempo:integer; Begin // Solicita o tempo para o cronometro write ('Digite o tempo que você deseja que o programa cronometre (s): '); read (tempo); // Repeticao até o tempo chegar em zero while (tempo<>0) do Begin delay (1000); clrscr; writeln ('Cronometrando: ',tempo,' segundos'); tempo := tempo - 1; End; writeln (''); Write (' Tempo esgotado !'); End. pascalzim/exemplos/desenho/EditorHugo.pas program WASD_Paint; { INSTITUTO FEDERAL DA BAHIA - CAMPUS CAMAÇARI Curso: Técnico em Informática (TI) Autor: Hugo Deiró Data: 21/03/2012 - Este programa simula uma tela de desenho; Alteração: Hugo Deiró - 22/03/2012 - Início da implementação de novas cores; Alteração: Hugo Deiró - 23/03/2012 - Finalização da implementação de novas cores; - Implementação de estrela (*) ao comando E(estrela); Alteração: Hugo Deiró - 26/03/2012 - Implementação dos comandos em flecha(seta), Up(Cima), Down(Baixo), Left(Esquerda), Right(Direita). Alteração: Hugo Deiró - 20/04/2012 - Inserção no menu superior o comando E (desenhar *); - Correção de Design em cor do menu de comandos; } var i, x, y, cor : integer; comando : char; ponto : string; ativa : array[1..18] of boolean; procedure texto; begin gotoxy(22,2); textcolor(14); writeln('==== BEM VINDO AO QUADRO DE DESENHOS ===='); gotoxy(2,3); textcolor(10); writeln('W/UP - Move para cima;'); gotoxy(2,4); writeln('A/LEFT - Move para esquerda;'); gotoxy(2,5); writeln('S/DOWN - Move para baixo;'); gotoxy(31,3); writeln('D/RIGHT - Move para direita;'); gotoxy(31,4); writeln('B - Borracha;'); gotoxy(31,5); writeln('C - Apaga todo desenho;'); gotoxy(60,3); writeln('F - Encerra;'); gotoxy(60,4); write('E - Desenha '); textcolor(15); write('*'); textcolor(10); write(';'); gotoxy(55,5); textcolor(8); writeln('Desenvolvedor: Hugo Deiró'); gotoxy(4,27); textcolor(9); writeln('Azul(1)'); gotoxy(16,27); textcolor(10); writeln('Verde(2)'); gotoxy(28,27); textcolor(12); writeln('Vermelho(3)'); gotoxy(43,27); textcolor(14); writeln('Amarelo(4)'); gotoxy(58,27); textcolor(15); writeln('Branco(5)'); gotoxy(71,27); textcolor(13); writeln('Rosa(6)'); end; procedure layout; begin {-------- Caixa Superior -----------} textcolor(10); for i := 1 to 500 do begin textbackground(0); writeln(' '); end; for i := 2 to 79 do begin gotoxy(i,1); write('_'); gotoxy(i,6); write('_'); end; for i := 2 to 6 do begin gotoxy(1,i); write('|'); gotoxy(80,i); write('|'); end; { ------- Caixa Meio ------------} for i := 2 to 79 do begin gotoxy(i,7); write('_'); gotoxy(i,24); write('_'); end; for i := 8 to 24 do begin gotoxy(1,i); write('|'); gotoxy(80,i); write('|'); end; {------- Caixa Inferior ----------} for i := 2 to 79 do begin gotoxy(i,25); write('_'); gotoxy(i,29); write('_'); end; for i := 26 to 29 do begin gotoxy(1,i); write('|'); gotoxy(80,i); write('|'); end; texto; {Logo, os movimentos possíveis são de acordo com a caixa menor, não podem passar a linha 23 nem da coluna 78} end; procedure movimento; begin cor := 0; y := 8; x := 2; i := 1; ponto := ' '; repeat repeat comando := readkey; //Lê uma tecla qualquer que o usuário insira; comando := upcase(comando); //Atribui à própria variável o seu valor em caixa alta (pra facilitar o tratamento); if(comando = #80)then comando := 'S'; if(comando = #72)then comando := 'W'; if(comando = #77)then comando := 'D'; if(comando = #75)then comando := 'A'; until(comando = 'E') or (comando = '1') or (comando = '2') or (comando = '3') or (comando = '4') or (comando = '5') or (comando = '6') or(comando = 'W') or (comando = 'A') or (comando = 'S') or (comando = 'D') or (comando = 'C') or (comando = 'V') or (comando = 'F') or (comando = 'B'); {Atribuição de valor para o vetor booleano ativa} ativa[1] := (comando = 'W'); //Move o objeto uma posição acima; ativa[2] := (comando = 'A'); //Move o objeto uma posição pra esquerda; ativa[3] := (comando = 'S'); //Move o objeto uma posição pra baixo; ativa[4] := (comando = 'D'); //Move o objeto uma posição pra direita; ativa[5] := (comando = 'C'); //Limpa o rastro do objeto (Ativa clrscr);; ativa[6] := (comando = 'F'); //Encerra o programa; ativa[7] := (x > 78); //* ativa[8] := (x < 3); //* ativa[9] := (y < 9); //* ativa[10] := (y > 22); //***Garante que o objeto esteja dentro do espaço determinado. ativa[11] := (comando = 'B'); //Deleta o movimento através da mudança de cor para PRETO; ativa[12] := (comando = '1'); //* ativa[13] := (comando = '2'); //* ativa[14] := (comando = '3'); //* ativa[15] := (comando = '4'); //* ativa[16] := (comando = '5'); //* ativa[17] := (comando = '6'); //*****Muda a cor do objeto de acordo com o escolhido; ativa[18] := (comando = 'E'); // Desenha uma estrela; if(ativa[1])then //* y := y - 1; if(ativa[2])then //* x := x - 1; if(ativa[3])then //* y := y + 1; if(ativa[4])then //* Muda, a partir das teclas W, A, S, D o valor de X e Y pra mudar também a posição em coordenada cartesiana x(ordenadas)/y(abcissas); x := x + 1; if(ativa[5] = true)then begin clrscr; layout; end; if(ativa[7])then begin write(#7); x := 78; end; if(ativa[8])then begin write(#7); x := 3; end; if(ativa[9])then begin write(#7); y := 9; end; if(ativa[10])then begin write(#7); y := 22; end; if(ativa[11])then cor := 0; //* if(ativa[12])then cor := 9; //* if(ativa[13])then cor := 10; //* if(ativa[14])then cor := 12; //* if(ativa[15])then cor := 14; //* if(ativa[16])then cor := 15; //* if(ativa[17])then cor := 13; //****** Muda o valor da variável inteira COR, o textbackground(assim como o textcolor) trabalha com valores inteiros apenas; Quando você escreve "lightred", por exemplo, o compilador muda esse nome para o valor 10. if(ativa[18])then begin textcolor(15); ponto := '*'; end else ponto := ' '; gotoxy(x,y); //Move o objeto "ponto" pra X/Y equivalente. textbackground(cor); write(ponto); until(ativa[6]); //Fecha a etapa de desenho; end; begin layout; movimento; end. pascalzim/exemplos/desenho/PaintZim20.pas Program PaintZim20 ; { ------------------------------------------------------------- Programa que implementa um editor de imagens ASCII :~ PaintZim - versão 2.0 Autor : GRSa O programa é uma cortesia ao querido Pascalzim. ------------------------------------------------------------- Características e funcionalidades: O PaintZim é uma ferramenta para edição de ASCII Art. Manipula caracteres e cores para criação de desenhos baseados em ASCII. O programa dispõe de uma extensa área editável através de uma página rolável. É possível exportar os trabalhos para HTML ou para código em pascal. É possível importar caracteres de um arquivo de texto para trabalhar à partir deles. Notas da segunda versão: **A segunda versão do PaintZim conta com o conceito de seleção. Com isso é possível manipular grandes quantidade de caracteres de uma única vez. **Foi implementado suporte aos comandos Copiar e Colar e Desfazer e Refazer. **O programa foi incrementado com uma interface mais limpa e intuitiva. **Foi implementado a opção de exportar para código pascal, assim os desenhos podem ser transformados em código para serem reaproveitados em outros programas. **Foi adicionado cor aos desenhos exportados para HTML. **Foi adicionado a função de importar caracteres de arquivos de texto. Lista das rotinas em ordem: Procedure DesenhaContorno; Procedure DesenhaRetangulo; Procedure DesenhaPainel; Procedure DesenhaCampo; Function ObtemTeclaPressionada; Function LeDado; Function IntParaString; Function IntParaString; Function ObtemCadeia; Procedure ExibeTela; Procedure ExibeInformacao; Procedure MostraCursor; Procedure ExibeLimitesSelecao; Procedure InicializaDefinicoes; Procedure IncrementaHistoricoDesfazer; Procedure IncrementaHistoricoRefazer; Procedure DesfazUltimaAcao; Procedure RefazUltimaAcao; Procedure InsereElemento; Procedure RedefineFundoPagina; Procedure SelecionaCaractere; Procedure SelecionaCor; Procedure DefineAtalhos; Procedure GerenciaSelecao; Procedure ColaSelecao; Procedure ManipulaAreaSelecionada; Function RetornaReferencia; Function SalvaArquivoPaintZim20; Function CarregaArquivoPaintZim20; Function ExportaArquivoHTML; Function ExportaCodigoPascal; Function ImportaArquivoTXT; Procedure GerenciaMenu; Estrutura do arquivo paintzim Um arquivo paintzim possui um desenho/texto salvo pelo editor do programa. O arquivo gerado e carregado pelo PaintZim20 é estruturado de forma a armazenar os dados necessários dos trabalhos feitos no editor. O arquivo padrão manipulado pelo PaintZim20 possui a extensão .paintzim. Os dados são armazenados, quase que completamente, de forma numérica, ou seja através de números. A organização dos dados é feita da seguinte forma: As três primeiras linhas formam o cabeçalho do arquivo. E tem a seguinte estrutura: Versão do arquivo: "Arquivo PaintZim20" Estado do editor, no formato: AAABBBCCC Limites do desenho, no formato: DDDEEEFFFGGG AAA - Cor de fundo BBB - Posicao na coluna da página CCC - Posicao na linha da página DDD - Limite oeste do desenho na página (Coluna esquerda) EEE - Limite leste do desenho na página (Coluna direita) FFF - Limite norte do desenho na página (Linha superior) GGG - Limite sul do desenho na página (Linha inferior) As outras linhas após o cabeçalho armazenarão um registro por vez contendo os dados de cada "pixel" (caractere e seus atributos de cor) do desenho. Registro, no formato: HHHIIIJJJKKKLLL HHH - Posicão na coluna na página III - Posição na linha da página JJJ - Caractere KKK - Cor do caractere LLL - Cor de fundo do caractere O FORMATO PAINTZIM NÃO POSSUI PROPRIETÁRIO, PORTANTO PODE SER REUTILIZADO SEM RESTRIÇÕES, INCLUSIVE MODIFICADO SEM QUE HAJA PREJUÍZOS LEGAIS. ------------------------------------------------------------- } Uses crt; {---------------------------------------------------- CONSTANTES, VARIÁVEIS E REGISTROS ----------------------------------------------------} Const DIMENSAO_COL_TELA = 80 ; //Dimensão da tela (Col) DIMENSAO_LIN_TELA = 23 ; //Dimensão da tela (Lin) DIMENSAO_COL_PAGINA = 160 ; //Dimensão da página (Col) DIMENSAO_LIN_PAGINA = 80 ; //Dimensão da página (Lin) POSICAO_COL_TELA = 1 ; //Posição da tela no prompt (Col) POSICAO_LIN_TELA = 2 ; //Posição da tela no prompt (Lin) DIMENSAO_HISTORICO = DIMENSAO_COL_PAGINA * DIMENSAO_LIN_PAGINA * 4; DIMENSAO_AREA_TRANSFERENCIA = DIMENSAO_COL_PAGINA * DIMENSAO_LIN_PAGINA; TEMPO_MAX_TEMPORIZADOR = 20; COR_PAINEL = 7; //Cor do painel CARACTERE_NULO = 255; //Caractere nulo EXT_ARQUIVO_PAINTZIM = 'paintzim'; //Extensão do arquivo editável EXT_ARQUIVO_HTML = 'html'; EXT_ARQUIVO_PASCAL = 'pas'; NULO = '\NULO'; //CONSTANTES DE TECLAS TECLA_UP = '072'; TECLA_DOWN = '080'; TECLA_RIGHT = '077'; TECLA_LEFT = '075'; TECLA_DELETE = '083'; TECLA_ENTER = '13'; TECLA_ESC = '27'; TECLA_BACKSPACE = '8'; TECLA_TAB = '9'; TECLA_SPACE = '32'; TECLA_F1 = '059'; {TECLA_F2 = '060';} TECLA_F3 = '061'; TECLA_F4 = '062'; TECLA_F5 = '063'; TECLA_F6 = '064'; {TECLA_F7 = '065'; TECLA_F8 = '066';} TECLA_F9 = '067'; TECLA_F10 = '068'; {TECLA_F11 = '0133';} TECLA_F12 = '0134'; TECLA_0 = '48'; TECLA_1 = '49'; TECLA_2 = '50'; TECLA_3 = '51'; TECLA_4 = '52'; TECLA_5 = '53'; TECLA_6 = '54'; TECLA_7 = '55'; TECLA_8 = '56'; TECLA_9 = '57'; TECLA_CTRL_UP = '0141'; TECLA_CTRL_DOWN = '0145'; TECLA_CTRL_RIGHT = '0116'; TECLA_CTRL_LEFT = '0115'; {TECLA_CTRL_ALT_UP = '0152'; TECLA_CTRL_ALT_DOWN = '0160'; TECLA_CTRL_ALT_RIGHT = '0157'; TECLA_CTRL_ALT_LEFT = '0155';} TECLA_CTRL_E = '5'; TECLA_CTRL_Z = '26'; TECLA_CTRL_R = '18'; TECLA_CTRL_T = '20'; TECLA_CTRL_V = '22'; TECLA_CTRL_L = '12'; TECLA_CTRL_B = '2'; TECLA_CTRL_ALT_B = '048'; TECLA_CTRL_A = '1'; TECLA_ALT_V = '047'; TECLA_CTRL_ENTER = '10'; TECLA_CTRL_ALT_ENTER = '0166'; Type ElementoImagem = Record caractere, cor, corFundo : integer; End; ElementoHistorico = Record ciclo, posCol, posLin : integer; elemento : ElementoImagem; End; ElementoAreaTransferencia = Record posCol, posLin : integer; elemento : ElementoImagem; End; Var matriz : Record pagina : array [1..DIMENSAO_COL_PAGINA + 1, 1..DIMENSAO_LIN_PAGINA + 1] of ElementoImagem; tela : array [1..DIMENSAO_COL_TELA + 1, 1..DIMENSAO_LIN_TELA + 1] of ElementoImagem; End; editor : Record corFundo, corFundoCaractere, corCaractere : integer; {Manipulados em Procedure SelecionaCor} caractere : integer; temporizador : integer; grupoPredefinido : array [0..9] of integer; refGrupoPredefinido : integer; modoContinuo, modoAtalho : boolean; nomeArquivo, nomeArquivoAux : string; arquivoAberto : boolean; End; selecao : Record posCol, posLin : integer; dimCol, dimLin : integer; ativa : boolean; cachePosColCursor, cachePosLinCursor : integer; cacheRefColPagina, cacheRefLinPagina : integer; End; cursor : Record posCol, posLin : integer; formato : ElementoImagem; End; definicao : Record refColPagina, refLinPagina : integer; finalizarPrograma : boolean; tecla : string[5]; End; historico : Record lista : array[1..DIMENSAO_HISTORICO] of ElementoHistorico; quantElementosDesfazer, quantElementosRefazer : integer; refListaDesfazer, refListaRefazer : integer; refCicloDesfazer, refCicloRefazer : integer; trocarCiclo : boolean; End; areaTransferencia : Record matriz : array[1..DIMENSAO_AREA_TRANSFERENCIA] of ElementoAreaTransferencia; quantElementos : integer; End; {---------------------------------------------------- Procedure DesenhaContorno; -----------------------------------------------------} Procedure DesenhaContorno(posCol, posLin, dimCol, dimLin, corLinha, corFundoLinha : integer; sombreamento : boolean); Const CARAC_CANTO_NE = #191; CARAC_CANTO_NO = #218; CARAC_CANTO_SE = #217; CARAC_CANTO_SO = #192; CARAC_HORIZONT = #196; CARAC_VERTICAL = #179; Var cont : integer; cor1, cor2 : integer; Begin cont := 0; if (sombreamento) then begin cor1 := corLinha; cor2 := corLinha + 8; end else begin cor2 := corLinha; cor1 := corLinha + 8; end; textBackGround(corFundoLinha) ; while (cont < dimCol - 1) or (cont < dimLin - 1) do begin if (cont < dimCol - 1) then begin textColor(cor1); goToXY(posCol + cont, posLin); if (cont > 0) then write(CARAC_HORIZONT) else write(CARAC_CANTO_NO); //LINHA HORIZONTAL NORTE - ARESTA NOROESTE textColor(cor2); goToXY(posCol + dimCol - cont - 1, posLin + dimLin - 1) ; if (cont > 0) then write(CARAC_HORIZONT) else write(CARAC_CANTO_SE); //LINHA HORIZONTAL NORTE - ARESTA SUDESTE end; if (cont < dimLin - 1) then begin textColor(cor1); goToXY(posCol, posLin + dimLin - cont - 1); if (cont > 0) then write(CARAC_VERTICAL) else write(CARAC_CANTO_SO); //LINHA VERTICAL OESTE - ARESTA SUDOESTE textColor(cor2); goToXY(posCol + dimCol - 1, posLin + cont); if (cont > 0) then write(CARAC_VERTICAL) else write(CARAC_CANTO_NE); //LINHA VERTICAL LESTE - ARESTA NOROESTE end; inc(cont); end; textColor(black); End; {---------------------------------------------------- Procedure DesenhaRetangulo; -----------------------------------------------------} Procedure DesenhaRetangulo(posCol, posLin, dimCol, dimLin, cor : integer); {DESENHA UM RETÂNGULO MACIÇO COM O TAMANHO DE SEU PERÍMETRO 'posCol' e 'posLin' recebem a posição do retângulo 'dimCol' e 'dimLin' recebem a dimensão do retângulo 'cor' recebe a cor do retângulo} Const CARAC_PADRAO = #219; Var cont : integer; linha : string; Begin textcolor(cor) ; textbackground(cor) ; linha := ''; for cont := 1 to dimCol do if (cont > 1) then linha := concat(linha, CARAC_PADRAO) else linha := CARAC_PADRAO; for cont := 1 to dimLin do begin gotoxy(posCol, posLin + cont - 1) ; write(linha); end; End; {---------------------------------------------------- Procedure DesenhaPainel; -----------------------------------------------------} Procedure DesenhaPainel(posCol, posLin, dimCol, dimLin : integer; rotulo : string); {DESENHA UM PAINEL SOMBREADO COM UM NOME 'posCol' e 'posLin' recebem a dimensão do retãngulo 'dimCol' e 'dimLin' recebem a dimensão do retângulo 'cor' recebe a cor do retângulo} Begin DesenhaRetangulo(posCol + dimCol , posLin + 1, 2, dimLin - 1, 16); DesenhaRetangulo(posCol + 2, posLin + dimLin, dimCol, 1, 16); DesenhaRetangulo(posCol, posLin + 1, dimCol, dimLin - 1, 7); DesenhaContorno(posCol, posLin + 1, dimCol, dimLin - 1, 16, 7, false); DesenhaRetangulo(posCol, posLin, dimCol, 1, 1); textColor(15); textBackGround(1); goToXY(posCol + 1, posLin); write(rotulo); textColor(16); textBackGround(7); End; {---------------------------------------------------- Procedure DesenhaCampo; -----------------------------------------------------} Procedure DesenhaCampo(posCol, posLin, dimCol, dimLin, cor, corFundo, corRotulo : integer; horizontal : boolean; rotulo : string); {DESENHA UM CAMPO COM UM RÓTULO 'posCol' e 'posLin' recebem a posição do campo 'dimCol' e 'dimLin' recebem a dimensão do campo 'cor' recebe a cor do campo 'rotulo' recebe o rotulo do campo} Begin dimCol := dimCol + 2; dimLin := dimLin + 2; textbackground(corFundo); if horizontal then begin gotoxy(posCol, posLin + dimLin div 2); textcolor(corRotulo); write(rotulo); DesenhaContorno(posCol + length(rotulo), posLin, dimCol, dimLin, cor, corFundo, true); end else begin gotoxy(posCol + 1, posLin); textcolor(corRotulo); write(rotulo); DesenhaContorno(posCol, posLin + 1, dimCol, dimLin, cor, corFundo, true); end; End; {---------------------------------------------------- Function ObtemTeclaPressionada; -----------------------------------------------------} Function ObtemTeclaPressionada : string; {RETORNA A REFERENCIA À TECLA PRESSIONADA} Const COMANDO_ACENTUACAO_1 = #26; COMANDO_ACENTUACAO_2 = #40; Var refA, refB : char; tecla, auxA, auxB : string; Begin if (keypressed) then begin refA := readkey; case upcase(refA) of #0 : begin refB := readkey; if (refB <> COMANDO_ACENTUACAO_1) and (refB <> COMANDO_ACENTUACAO_2) then begin str(ord(refA), auxA); str(ord(refB), auxB); tecla := concat(auxA, auxB); end else tecla := NULO; end; else begin str(ord(refA), auxA); tecla := auxA; end; end; end else begin tecla := NULO; end; ObtemTeclaPressionada := tecla; End; {---------------------------------------------------- Function LeDado; -----------------------------------------------------} Function LeDado (var varRec : string; dimString : integer) : string; {LÊ UM DADO SEM ULTRAPASSAR O LIMITE DA DIMENSÃO DA STRING 'varRec' recebe a referência a variável que irá receber o dado lido 'dimString' recebe a dimensão da string que será lida} Const CARAC_NULO = #255; Var dimCadeia, refTecla, codErro, intA : integer; tecla, cadeia : string; carac : char; Begin dimCadeia := 0; cadeia := ''; CursorOn; while (true) do begin tecla := ObtemTeclaPressionada; if tecla <> NULO then begin if tecla <> TECLA_ESC then begin if (tecla <> TECLA_ENTER) and (tecla <> TECLA_TAB) then begin if tecla <> TECLA_BACKSPACE then begin if (tecla <> TECLA_UP) and (tecla <> TECLA_DOWN) and (tecla <> TECLA_RIGHT) and (tecla <> TECLA_LEFT) then begin if dimCadeia < dimString then begin inc(dimCadeia); gotoxy(whereX, whereY); val(tecla, refTecla, codErro); carac := chr(refTecla); cadeia := concat(cadeia, carac); write(carac); end; end; end else begin if dimCadeia > 0 then begin gotoxy(whereX - 1, whereY); write(CARAC_NULO); dec(dimCadeia); gotoxy(whereX - 1, whereY); cadeia := copy(cadeia, 1, length(cadeia) - 1); end; end; end else begin if dimCadeia > 0 then begin varRec := cadeia; val(cadeia, intA, codErro); str(codErro, cadeia); LeDado := cadeia; CursorOff; break; end; end; end else begin LeDado := NULO; CursorOff; break; end; end; end; End; {---------------------------------------------------- Function IntParaString; -----------------------------------------------------} Function IntParaString (num : integer) : string; Var resultado : string; Begin str(num, resultado); IntParaString := resultado; End; {---------------------------------------------------- Function StringParaInt; -----------------------------------------------------} Function StringParaInt (cadeia : string) : integer; Var resultado : integer; codErro : integer; Begin val(cadeia, resultado, codErro); StringParaInt := resultado; End; {---------------------------------------------------- Function ObtemCadeia; -----------------------------------------------------} Function ObtemCadeia (rotulo1, rotulo2 : string): string; Const POSICAO_COL_PAINEL = 2; POSICAO_LIN_PAINEL = 16; DIMENSAO_NOME = 50; Var dadoLido : string; Begin DesenhaPainel(POSICAO_COL_PAINEL, POSICAO_LIN_PAINEL, DIMENSAO_NOME + 4, 7, rotulo1); DesenhaCampo(POSICAO_COL_PAINEL + 1, POSICAO_LIN_PAINEL + 2, DIMENSAO_NOME, 1, 16, 7, 16, false, rotulo2); gotoxy(POSICAO_COL_PAINEL + 2, POSICAO_LIN_PAINEL + 4); textcolor(16); textbackground(7); if LeDado(dadoLido, DIMENSAO_NOME) <> NULO then ObtemCadeia := dadoLido else ObtemCadeia := NULO; End; {---------------------------------------------------- Procedure ExibeTela; -----------------------------------------------------} Procedure ExibeTela (posCol, posLin : integer; exibeTudo : boolean); Var col, lin : integer; Begin if ((posCol+DIMENSAO_COL_TELA-1) <= DIMENSAO_COL_PAGINA) and ((posLin+DIMENSAO_LIN_TELA-1) <= DIMENSAO_COL_PAGINA) and (posCol > 0) and (posLin > 0) then begin for lin := 1 to DIMENSAO_LIN_TELA do for col := 1 to DIMENSAO_COL_TELA do begin if (matriz.pagina[posCol-1+col, posLin-1+lin].caractere <> matriz.tela[col, lin].caractere) or (matriz.pagina[posCol-1+col, posLin-1+lin].cor <> matriz.tela[col, lin].cor) or (matriz.pagina[posCol-1+col, posLin-1+lin].corFundo <> matriz.tela[col, lin].corFundo) or (exibeTudo) then begin matriz.tela[col, lin].caractere := matriz.pagina[posCol-1+col, posLin-1+lin].caractere; matriz.tela[col, lin].cor := matriz.pagina[posCol-1+col, posLin-1+lin].cor; matriz.tela[col, lin].corFundo := matriz.pagina[posCol-1+col, posLin-1+lin].corFundo; gotoxy(POSICAO_COL_TELA-1+col, POSICAO_LIN_TELA-1+lin); textcolor(matriz.tela[col, lin].cor); textbackground(matriz.tela[col, lin].corFundo) ; write(chr(matriz.tela[col, lin].caractere)); end; end ; end; End; {Procedure ExibeTela (posCol, posLin : integer; tudo : boolean); Var col, lin : integer; elementoAtual: ElementoImagem; buffer : record cadeia : string[DIMENSAO_COL_TELA]; cadeiaVazia : boolean; posicao, cor, corFundo : integer; end; Function CaractereJaDefinido(posC, posL : integer; elemento : ElementoImagem) : boolean; Begin if (matriz.tela[posC, posL].caractere = elemento.caractere) and (matriz.tela[posC, posL].cor = elemento.cor) and (matriz.tela[posC, posL].corFundo = elemento.corFundo) then CaractereJaDefinido := true else CaractereJaDefinido := false; End; Function UltimoCaractereDaLinha : boolean; Begin if col = DIMENSAO_COL_TELA then UltimoCaractereDaLinha := true else UltimoCaractereDaLinha := false; End; Function CaractereTipoBuffer(elemento : ElementoImagem) : boolean; Begin if (elemento.cor = buffer.cor) and (elemento.corFundo = buffer.corFundo) then CaractereTipoBuffer := true else CaractereTipoBuffer := false; End; Procedure IncrementaBuffer(elemento : ElementoImagem); Begin if buffer.cadeiaVazia then begin buffer.cadeia := chr(elemento.caractere); buffer.cadeiaVazia := false; buffer.cor := elemento.cor; buffer.corFundo := elemento.corFundo; buffer.posicao := col; end else begin buffer.cadeia := buffer.cadeia + chr(elemento.caractere); end; End; Procedure LiberaBuffer; Begin gotoxy(POSICAO_COL_TELA - 1 + buffer.posicao, POSICAO_LIN_TELA - 1 + lin); textcolor(buffer.cor); textbackground(buffer.corFundo); write(buffer.cadeia); buffer.cadeiaVazia := true; End; Procedure AtualizaPosicao; Begin matriz.tela[col, lin] := elementoAtual; End; Begin if ((posCol + DIMENSAO_COL_TELA - 1) <= DIMENSAO_COL_PAGINA) and ((posLin + DIMENSAO_LIN_TELA - 1) <= DIMENSAO_LIN_PAGINA) and (posCol > 0) and (posLin > 0) then begin if tudo then begin for lin := 1 to DIMENSAO_LIN_TELA do for col := 1 to DIMENSAO_COL_TELA do begin matriz.tela[col, lin].cor := matriz.tela[col, lin].cor + 1; matriz.tela[col, lin].corFundo := matriz.tela[col, lin].corFundo + 1; end; end; buffer.cadeiaVazia := true; for lin := 1 to DIMENSAO_LIN_TELA do begin for col := 1 to DIMENSAO_COL_TELA do begin elementoAtual := matriz.pagina[posCol - 1 + col, posLin - 1 + lin]; if CaractereJaDefinido(col, lin, elementoAtual) then begin if not(buffer.cadeiaVazia) then LiberaBuffer; end else begin if buffer.cadeiaVazia then begin IncrementaBuffer(elementoAtual); if UltimoCaractereDaLinha then LiberaBuffer; AtualizaPosicao; end else begin if CaractereTipoBuffer(elementoAtual) then begin IncrementaBuffer(elementoAtual); if UltimoCaractereDaLinha then LiberaBuffer; AtualizaPosicao; end else begin LiberaBuffer; IncrementaBuffer(elementoAtual); if UltimoCaractereDaLinha then LiberaBuffer; AtualizaPosicao; end; end; end; end; end; end; End;} {---------------------------------------------------- Procedure ExibeInformacao; -----------------------------------------------------} Procedure ExibeInformacao (refInformacao : string); Var cadeia : string; posCol, posLin : integer; Procedure LimpaPainel; Begin DesenhaRetangulo(POSICAO_COL_TELA, POSICAO_LIN_TELA + DIMENSAO_LIN_TELA, DIMENSAO_COL_TELA - 1, 1, COR_PAINEL); gotoxy(POSICAO_COL_TELA + 1, POSICAO_LIN_TELA + DIMENSAO_LIN_TELA); textcolor(black); textbackground(COR_PAINEL); End; Begin if (refInformacao = 'PAINEL_CABECALHO_1') then begin gotoxy(1, 1); textcolor(black); textbackground(COR_PAINEL); write(' ',#16,'PaintZim20 Ctrl+A=Abrir Ctrl+B=Salvar Ctrl+E=Exportar Esc=Fechar'); end else if (refInformacao = 'PAINEL_CABECALHO_2') then begin gotoxy(1, 1); textcolor(black); textbackground(COR_PAINEL); write(' ',#16,'PaintZim20 '); end else if (refInformacao = 'PAINEL_PADRAO') then begin LimpaPainel; write('Digite ou insira caracteres com o Enter F9=Cores F1=Ajuda'); end else if (refInformacao = 'PAINEL_SELECAO') then begin LimpaPainel; write('Dimensione a area da selecao com as setas e pressione Enter Esc=Sair'); end else if (refInformacao = 'PAINEL_MENU_GENERICO') then begin ExibeInformacao('PAINEL_CABECALHO_2'); LimpaPainel; write('Escolha uma opcao e pressione Enter Esc=Sair'); end else if (refInformacao = 'PAINEL_CONFIRMACAO') then begin ExibeInformacao('PAINEL_CABECALHO_2'); LimpaPainel; write('Pressione qualquer tecla para continuar'); end else if (refInformacao = 'PAINEL_OBTER_DADO') then begin ExibeInformacao('PAINEL_CABECALHO_2'); LimpaPainel; write('Digite um nome para o arquivo sem a extensao ESC=Sair'); end else if (refInformacao = 'PAINEL_COR_CARACTERE') then begin ExibeInformacao('PAINEL_CABECALHO_2'); LimpaPainel; write('Selecione as cores e pressione Enter Esc=Sair Tab=Alternar'); end else if (refInformacao = 'PAINEL_COR_PAGINA') then begin ExibeInformacao('PAINEL_CABECALHO_2'); LimpaPainel; write('Selecione a cor e pressione Enter Esc=Sair'); end else if (refInformacao = 'PAINEL_CARACTERE') then begin ExibeInformacao('PAINEL_CABECALHO_2'); LimpaPainel; write('Selecione o caractere e pressione Enter Esc=Sair'); end else if (refInformacao = 'PAINEL_CONFIRMACAO_SALVAMENTO') then begin LimpaPainel; write('Todas as alteracoes foram salvas'); delay(1000); end else if (refInformacao = 'PAINEL_ATALHOS') then begin LimpaPainel; write('0=', chr(editor.grupoPredefinido[0]), ' 1=', chr(editor.grupoPredefinido[1]), ' 2=', chr(editor.grupoPredefinido[2]), ' 3=', chr(editor.grupoPredefinido[3]), ' 4=', chr(editor.grupoPredefinido[4]), ' 5=', chr(editor.grupoPredefinido[5]), ' 6=', chr(editor.grupoPredefinido[6]), ' 7=', chr(editor.grupoPredefinido[7]), ' 8=', chr(editor.grupoPredefinido[8]), ' 9=', chr(editor.grupoPredefinido[9]), ' F1=Ajuda'); end else if (refInformacao = 'PAINEL_BOM_AVISO') then begin ExibeInformacao('PAINEL_CABECALHO_2'); LimpaPainel; textcolor(yellow); textbackground(red); write('Programa criado como cortesia para o querido Pascalzim :-)'); end else if (refInformacao = 'PAINEL_STATUS') then begin textcolor(8); textbackground(COR_PAINEL); cadeia := concat(' ',IntParaString(definicao.refColPagina - 1 + cursor.posCol),',', IntParaString(definicao.refLinPagina - 1 + cursor.posLin)); gotoxy(DIMENSAO_COL_TELA - length(cadeia) - 5, POSICAO_LIN_TELA + DIMENSAO_LIN_TELA); write(cadeia); textcolor(editor.corCaractere); textbackground(editor.corFundoCaractere); gotoxy(DIMENSAO_COL_TELA - 3, POSICAO_LIN_TELA + DIMENSAO_LIN_TELA); write(#32, chr(editor.caractere), #32); end else if (refInformacao = 'PAINEL_DIMENSAO_SELECAO') then begin textcolor(lightred); textbackground(COR_PAINEL); cadeia := concat(' ',IntParaString(selecao.dimCol), 'x', IntParaString(selecao.dimLin)); gotoxy(DIMENSAO_COL_TELA - length(cadeia), POSICAO_LIN_TELA + DIMENSAO_LIN_TELA); write(cadeia); end else if (refInformacao = 'ERRO_GERAR_ARQUIVO') then begin posCol := 52; posLin := 3; DesenhaPainel(posCol, posLin, 24, 5, 'Erro'); ExibeInformacao('PAINEL_CONFIRMACAO'); textcolor(black); textbackground(COR_PAINEL); gotoxy(posCol + 1, posLin + 2); write('Ocorreu um problema ao'); gotoxy(posCol + 1, posLin + 3); write('tentar criar o arquivo'); readkey; ExibeTela(definicao.refColPagina, definicao.refLinPagina, true); end else if (refInformacao = 'ERRO_ABRIR_ARQUIVO') then begin posCol := 52; posLin := 3; DesenhaPainel(posCol, posLin, 25, 7, 'Erro'); ExibeInformacao('PAINEL_CONFIRMACAO'); textcolor(black); textbackground(COR_PAINEL); gotoxy(posCol + 1, posLin + 2); write('Ocorreu um problema ao'); gotoxy(posCol + 1, posLin + 3); write('tentar abrir o arquivo.'); gotoxy(posCol + 1, posLin + 4); write('Talvez o arquivo nao'); gotoxy(posCol + 1, posLin + 5); write('exista.'); readkey; ExibeTela(definicao.refColPagina, definicao.refLinPagina, true); end else if (refInformacao = 'ERRO_ABRIR_ARQUIVO_TXT_UNICODE') then begin posCol := 46; posLin := 3; DesenhaPainel(posCol, posLin, 31, 5, 'Erro'); ExibeInformacao('PAINEL_CONFIRMACAO'); textcolor(black); textbackground(COR_PAINEL); gotoxy(posCol + 1, posLin + 2); write('O PaintZim20 nao decodifica'); gotoxy(posCol + 1, posLin + 3); write('arquivos de texto UNICODE'); readkey; ExibeTela(definicao.refColPagina, definicao.refLinPagina, true); end else if (refInformacao = 'PAINEL_SOBRE') then begin posCol := 17; posLin := 7; DesenhaPainel(posCol, posLin, 46, 10, 'Sobre o PaintZim20'); ExibeInformacao('PAINEL_BOM_AVISO'); textcolor(black); textbackground(COR_PAINEL); gotoxy(posCol + 1, posLin + 2); write('Esta e uma ferramenta para programadores :-)'); gotoxy(posCol + 1, posLin + 3); write('Explore seu potencial!'); gotoxy(posCol + 1, posLin + 5); write('Autor: GRSa'); gotoxy(posCol + 1, posLin + 8); write('Construido em agosto de 2013'); readkey; ExibeTela(definicao.refColPagina, definicao.refLinPagina, true); end else if (refInformacao = 'PAINEL_AJUDA') then begin posCol := 14; posLin := 3; DesenhaPainel(posCol, posLin, 52, 20, 'Ajuda'); gotoxy(posCol + 1, posLin + 2); write('Setas - Mover cursor'); gotoxy(posCol + 1, posLin + 3); write('Ctrl+Setas - Mover tela'); gotoxy(posCol + 1, posLin + 4); write('Ctrl+Enter - Iniciar selecao'); gotoxy(posCol + 1, posLin + 5); write('Ctrl+Alt+Enter - Inserir somente cor'); gotoxy(posCol + 1, posLin + 6); write('Ctrl+Z - Desfazer'); gotoxy(posCol + 1, posLin + 7); write('Ctrl+R - Refazer'); gotoxy(posCol + 1, posLin + 8); write('Ctrl+L - Capturar caractere sob o cursor'); gotoxy(posCol + 1, posLin + 9); write('Ctrl+V - Colar (para Copiar use a selecao)'); gotoxy(posCol + 1, posLin + 11); write('F4 - Alterar modo de insercao'); gotoxy(posCol + 1, posLin + 12); write('F5 - Alterar caractere atual'); gotoxy(posCol + 1, posLin + 13); write('F6 - Importar TXT'); gotoxy(posCol + 1, posLin + 14); write('F9 - Alterar cores do caractere'); gotoxy(posCol + 1, posLin + 15); write('F10 - Alterar cor da pagina'); gotoxy(posCol + 1, posLin + 16); write('F12 - Alterar atalhos'); gotoxy(posCol + 1, posLin + 18); write('Outras opcoes estarao facilmente visiveis'); ExibeInformacao('PAINEL_CONFIRMACAO'); readkey; ExibeTela(definicao.refColPagina, definicao.refLinPagina, true); end else if (refInformacao = 'PAINEL_??') then begin end; End; {---------------------------------------------------- Procedure MostraCursor; -----------------------------------------------------} Procedure MostraCursor(mostra : boolean); Begin cursor.formato.corFundo := matriz.pagina[definicao.refColPagina - 1 + cursor.posCol, definicao.refLinPagina - 1 + cursor.posLin].corFundo; if matriz.pagina[definicao.refColPagina - 1 + cursor.posCol, definicao.refLinPagina - 1 + cursor.posLin].cor = 15 then cursor.formato.cor := 16 else cursor.formato.cor := 15; cursor.formato.caractere := 176; if mostra then //Desenha o cursor na tela begin textcolor(cursor.formato.cor); textbackground(cursor.formato.corFundo); gotoxy(POSICAO_COL_TELA - 1 + cursor.posCol, POSICAO_LIN_TELA - 1 + cursor.posLin); write(chr(cursor.formato.caractere)); end else begin textcolor(matriz.pagina[definicao.refColPagina - 1 + cursor.posCol, definicao.refLinPagina - 1 + cursor.posLin].cor); textbackground(matriz.pagina[definicao.refColPagina - 1 + cursor.posCol, definicao.refLinPagina - 1 + cursor.posLin].corFundo); gotoxy(POSICAO_COL_TELA - 1 + cursor.posCol, POSICAO_LIN_TELA - 1 + cursor.posLin); write(chr(matriz.pagina[definicao.refColPagina - 1 + cursor.posCol, definicao.refLinPagina - 1 + cursor.posLin].caractere)); end; End; {---------------------------------------------------- Procedure ExibeLimitesSelecao; -----------------------------------------------------} Procedure ExibeLimitesSelecao (posCol, posLin, dimCol, dimLin : integer; mostra : boolean); Const CARAC_NO = #43; CARAC_NE = #43; CARAC_SO = #43; Var aux, posColExtremidade, posLinExtremidade : integer; refColCursor, refLinCursor : integer; caractereExtremidade : char; Begin refColCursor := definicao.refColPagina + cursor.posCol - 1; refLinCursor := definicao.refLinPagina + cursor.posLin - 1; for aux := 1 to 3 do begin case(aux) of 1: begin //NOROESTE posColExtremidade := posCol; posLinExtremidade := posLin; if mostra then caractereExtremidade := CARAC_NO; end; 2: begin //NORDESTE if refColCursor >= selecao.posCol then posColExtremidade := posCol + dimCol - 1 else posColExtremidade := posCol - dimCol + 1; posLinExtremidade := posLin; if mostra then caractereExtremidade := CARAC_NE; end; 3: begin //SUDOESTE posColExtremidade := posCol; if refLinCursor >= selecao.posLin then posLinExtremidade := posLin + dimLin - 1 else posLinExtremidade := posLin - dimLin + 1; if mostra then caractereExtremidade := CARAC_SO; end; end; if (posColExtremidade >= definicao.refColPagina) and (posColExtremidade <= definicao.refColPagina + DIMENSAO_COL_TELA - 1) and (posLinExtremidade >= definicao.refLinPagina) and (posLinExtremidade <= definicao.refLinPagina + DIMENSAO_LIN_TELA - 1) then begin if mostra then begin if editor.temporizador = 1 then begin if matriz.pagina[posColExtremidade, posLinExtremidade].cor = 15 then textcolor(16) else textcolor(15); textbackground(matriz.pagina[posColExtremidade, posLinExtremidade].corFundo); gotoxy(posColExtremidade - definicao.refColPagina + 1 + POSICAO_COL_TELA - 1, posLinExtremidade - definicao.refLinPagina + 1 + POSICAO_LIN_TELA - 1); write(caractereExtremidade); end else if editor.temporizador = TEMPO_MAX_TEMPORIZADOR div 2 + 1 then begin caractereExtremidade := chr(matriz.pagina[posColExtremidade, posLinExtremidade].caractere); textcolor(matriz.pagina[posColExtremidade, posLinExtremidade].cor); textbackground(matriz.pagina[posColExtremidade, posLinExtremidade].corFundo); gotoxy(posColExtremidade - definicao.refColPagina + 1 + POSICAO_COL_TELA - 1, posLinExtremidade - definicao.refLinPagina + 1 + POSICAO_LIN_TELA - 1); write(caractereExtremidade); end; end else begin caractereExtremidade := chr(matriz.pagina[posColExtremidade, posLinExtremidade].caractere); textcolor(matriz.pagina[posColExtremidade, posLinExtremidade].cor); textbackground(matriz.pagina[posColExtremidade, posLinExtremidade].corFundo); gotoxy(posColExtremidade - definicao.refColPagina + 1 + POSICAO_COL_TELA - 1, posLinExtremidade - definicao.refLinPagina + 1 + POSICAO_LIN_TELA - 1); write(caractereExtremidade); end; end; end; End; {---------------------------------------------------- Procedure InicializaDefinicoes; -----------------------------------------------------} Procedure InicializaDefinicoes; Var auxIntA, auxIntB : integer; Begin cursorOff; textbackground(7); clrscr; editor.caractere := 219; editor.corCaractere := 14; editor.corFundoCaractere := 3; editor.corFundo := 3; editor.temporizador := 0; editor.modoContinuo := false; editor.arquivoAberto := false; editor.modoAtalho := false; editor.refGrupoPredefinido := 1; editor.grupoPredefinido[0] := 176; editor.grupoPredefinido[1] := 177; editor.grupoPredefinido[2] := 178; editor.grupoPredefinido[3] := 219; editor.grupoPredefinido[4] := 220; editor.grupoPredefinido[5] := 223; editor.grupoPredefinido[6] := 254; editor.grupoPredefinido[7] := 22; editor.grupoPredefinido[8] := 46; editor.grupoPredefinido[9] := 250; historico.quantElementosDesfazer := 0; historico.quantElementosRefazer := 0; historico.refListaDesfazer := 0; historico.refListaRefazer := 0; historico.refCicloDesfazer := 0; historico.refCicloRefazer := 0; historico.trocarCiclo := true; selecao.ativa := false; areaTransferencia.quantElementos := 0; for auxIntA := 1 to DIMENSAO_COL_PAGINA do begin for auxIntB := 1 to DIMENSAO_LIN_PAGINA do begin matriz.pagina[auxIntA, auxIntB].caractere := CARACTERE_NULO; matriz.pagina[auxIntA, auxIntB].cor := editor.corFundo; matriz.pagina[auxIntA, auxIntB].corFundo := editor.corFundo; end; end; for auxIntA := 1 to DIMENSAO_COL_TELA do begin for auxIntB := 1 to DIMENSAO_LIN_TELA do begin matriz.tela[auxIntA, auxIntB].caractere := CARACTERE_NULO; matriz.tela[auxIntA, auxIntB].cor := editor.corFundo; matriz.tela[auxIntA, auxIntB].corFundo := editor.corFundo; end; end; {randomize; for auxIntA := 10 to 50 do begin for auxIntB := 10 to 50 do begin matriz.pagina[auxIntA, auxIntB].caractere := random(5) + 50; matriz.pagina[auxIntA, auxIntB].cor := random(16) + 1; matriz.pagina[auxIntA, auxIntB].corFundo := random(16) + 1; end; end;} definicao.refColPagina := 1; definicao.refLinPagina := 1; definicao.finalizarPrograma := false; ExibeTela(definicao.refColPagina, definicao.refLinPagina, true); cursor.posCol := 2; cursor.posLin := 2; MostraCursor(true); ExibeInformacao('PAINEL_PADRAO'); ExibeInformacao('PAINEL_CABECALHO_1'); ExibeInformacao('PAINEL_STATUS'); End; {---------------------------------------------------- Procedure IncrementaHistoricoDesfazer; -----------------------------------------------------} Procedure IncrementaHistoricoDesfazer (elemento : ElementoImagem; posCol, posLin : integer; trocarCiclo : boolean); Begin if historico.quantElementosDesfazer < DIMENSAO_HISTORICO div 2 then inc(historico.quantElementosDesfazer); if historico.quantElementosDesfazer = 1 then historico.refCicloDesfazer := 1 else if trocarCiclo then inc(historico.refCicloDesfazer); inc(historico.refListaDesfazer); if historico.refListaDesfazer > DIMENSAO_HISTORICO div 2 then historico.refListaDesfazer := 1; historico.lista[historico.refListaDesfazer].elemento := elemento; historico.lista[historico.refListaDesfazer].posCol := posCol; historico.lista[historico.refListaDesfazer].posLin := posLin; historico.lista[historico.refListaDesfazer].ciclo := historico.refCicloDesfazer; End; {---------------------------------------------------- Procedure IncrementaHistoricoRefazer; -----------------------------------------------------} Procedure IncrementaHistoricoRefazer (elemento : ElementoImagem; posCol, posLin : integer); Begin if historico.quantElementosRefazer < DIMENSAO_HISTORICO div 2 then inc(historico.quantElementosRefazer); if historico.quantElementosRefazer = 1 then historico.refCicloRefazer := 1; inc(historico.refListaRefazer); if historico.refListaRefazer > DIMENSAO_HISTORICO div 2 then historico.refListaRefazer := 1; historico.lista[historico.refListaRefazer + DIMENSAO_HISTORICO div 2].elemento := elemento; historico.lista[historico.refListaRefazer + DIMENSAO_HISTORICO div 2].posCol := posCol; historico.lista[historico.refListaRefazer + DIMENSAO_HISTORICO div 2].posLin := posLin; historico.lista[historico.refListaRefazer + DIMENSAO_HISTORICO div 2].ciclo := historico.refCicloRefazer; End; {---------------------------------------------------- Procedure DesfazUltimaAcao; -----------------------------------------------------} Procedure DesfazUltimaAcao; Var posLista, refCiclo, posCol, posLin : integer; Begin {historico.trocarCiclo := true;} if historico.quantElementosDesfazer > 0 then begin posLista := historico.refListaDesfazer; refCiclo := historico.refCicloDesfazer; inc(historico.refCicloRefazer); while(true) do begin if (historico.lista[posLista].ciclo = refCiclo) and (historico.quantElementosDesfazer > 0) then begin posCol := historico.lista[posLista].posCol; posLin := historico.lista[posLista].posLin; IncrementaHistoricoRefazer(matriz.pagina[posCol, posLin], posCol, posLin); if historico.lista[posLista].elemento.caractere = CARACTERE_NULO then begin historico.lista[posLista].elemento.cor := editor.corFundo; historico.lista[posLista].elemento.corFundo := editor.corFundo; end; matriz.pagina[posCol, posLin] := historico.lista[posLista].elemento; dec(historico.quantElementosDesfazer); //Exibe na tela if (posCol >= definicao.refColPagina) and (posCol <= definicao.refColPagina + DIMENSAO_COL_TELA - 1) and (posLin >= definicao.refLinPagina) and (posLin <= definicao.refLinPagina + DIMENSAO_LIN_TELA - 1) then begin textcolor(matriz.pagina[posCol, posLin].cor); textbackground(matriz.pagina[posCol, posLin].corFundo); gotoxy(posCol - definicao.refColPagina + 1 + POSICAO_COL_TELA - 1, posLin - definicao.refLinPagina + 1 + POSICAO_LIN_TELA - 1); write(chr(matriz.pagina[posCol, posLin].caractere)); end; if posLista > 1 then begin dec(posLista); dec(historico.refListaDesfazer); end else begin posLista := DIMENSAO_HISTORICO div 2; historico.refListaDesfazer := DIMENSAO_HISTORICO div 2; end; end else begin //ExibeTela(definicao.refColPagina, definicao.refLinPagina); MostraCursor(true); if historico.quantElementosDesfazer > 0 then historico.refCicloDesfazer := historico.lista[posLista].ciclo else begin historico.refListaDesfazer := 0; historico.refCicloDesfazer := 0; end; break; end; end; end; End; {---------------------------------------------------- Procedure RefazUltimaAcao; -----------------------------------------------------} Procedure RefazUltimaAcao; Var posLista, refCiclo, posCol, posLin : integer; Begin if historico.quantElementosRefazer > 0 then begin posLista := historico.refListaRefazer; refCiclo := historico.refCicloRefazer; historico.trocarCiclo := true; while(true) do begin if (historico.lista[posLista + DIMENSAO_HISTORICO div 2].ciclo = refCiclo) and (historico.quantElementosRefazer > 0) then begin posCol := historico.lista[posLista + DIMENSAO_HISTORICO div 2].posCol; posLin := historico.lista[posLista + DIMENSAO_HISTORICO div 2].posLin; IncrementaHistoricoDesfazer(matriz.pagina[posCol, posLin], posCol, posLin, historico.trocarCiclo); historico.trocarCiclo := false; if historico.lista[posLista + DIMENSAO_HISTORICO div 2].elemento.caractere = CARACTERE_NULO then begin historico.lista[posLista + DIMENSAO_HISTORICO div 2].elemento.cor := editor.corFundo; historico.lista[posLista + DIMENSAO_HISTORICO div 2].elemento.corFundo := editor.corFundo; end; matriz.pagina[posCol, posLin] := historico.lista[posLista + DIMENSAO_HISTORICO div 2].elemento; dec(historico.quantElementosRefazer); //Exibe na tela {if (posCol >= definicao.refColPagina) and (posCol <= definicao.refColPagina + DIMENSAO_COL_TELA - 1) and (posLin >= definicao.refLinPagina) and (posLin <= definicao.refLinPagina + DIMENSAO_LIN_TELA - 1) then begin textcolor(matriz.pagina[posCol, posLin].cor); textbackground(matriz.pagina[posCol, posLin].corFundo); gotoxy(posCol - definicao.refColPagina + 1 + POSICAO_COL_TELA - 1, posLin - definicao.refLinPagina + 1 + POSICAO_LIN_TELA - 1); write(chr(matriz.pagina[posCol, posLin].caractere)); end;} if posLista > 1 then begin dec(posLista); dec(historico.refListaRefazer); end else begin posLista := DIMENSAO_HISTORICO div 2; historico.refListaRefazer := DIMENSAO_HISTORICO div 2; end; end else begin //ExibeTela(definicao.refColPagina, definicao.refLinPagina); //MostraCursor(true); if historico.quantElementosRefazer > 0 then historico.refCicloRefazer := historico.lista[posLista + DIMENSAO_HISTORICO div 2].ciclo else begin historico.refListaRefazer := 0; historico.refCicloRefazer := 0; end; break; end; historico.trocarCiclo := false; end; end; End; {---------------------------------------------------- Procedure InsereElemento; -----------------------------------------------------} Procedure InsereElemento(caractere, corCaractere, corFundoCaractere : integer; posCol, posLin : integer); Begin if (posCol > 0) and (posCol <= DIMENSAO_COL_PAGINA) and (posLin > 0) and (posLin <= DIMENSAO_LIN_PAGINA) and (caractere <> 7) and (caractere <> 8) and (caractere <> 10) and (caractere <> 13) then begin IncrementaHistoricoDesfazer(matriz.pagina[posCol, posLin], posCol, posLin, historico.trocarCiclo); matriz.pagina[posCol, posLin].caractere := caractere; matriz.pagina[posCol, posLin].cor := corCaractere; matriz.pagina[posCol, posLin].corFundo := corFundoCaractere; end; End; {---------------------------------------------------- Procedure RedefineFundoPagina; -----------------------------------------------------} Procedure RefineFundoPagina; Var auxIntA, auxIntB : integer; Begin for auxIntA := 1 to DIMENSAO_COL_PAGINA do begin for auxIntB := 1 to DIMENSAO_LIN_PAGINA do begin if matriz.pagina[auxIntA, auxIntB].caractere = 255 then begin matriz.pagina[auxIntA, auxIntB].cor := editor.corFundo; matriz.pagina[auxIntA, auxIntB].corFundo := editor.corFundo; end; end; end; End; {---------------------------------------------------- Procedure SelecionaCaractere; -----------------------------------------------------} Procedure SelecionaCaractere; Const POSICAO_COL_PAINEL = 7; POSICAO_LIN_PAINEL = 3; COR_SELECAO = 15; COR_FUNDO_SELECAO = 1; Var tecla : string; auxA, auxB, posColSelecao, posLinSelecao : integer; caractere : integer; Function CaractereEspecial(carac : integer) : boolean; Begin if (carac = 0) or (carac = 7) or (carac = 8) or (carac = 10) or (carac = 13) or (carac = 255) then CaractereEspecial := true else CaractereEspecial := false; End; Procedure ExibeSelecao(mostra : boolean); {Subrotina da rotina SelecionaCaractere} Var carac : integer; Begin carac := 32 * (posLinSelecao - 1) + posColSelecao - 1; if mostra then begin gotoxy(POSICAO_COL_PAINEL + 2 + (posColSelecao * 2 - 2), POSICAO_LIN_PAINEL + 2 + (posLinSelecao * 2 - 2)); textcolor(COR_SELECAO); textbackground(COR_FUNDO_SELECAO); if CaractereEspecial(carac) then write(chr(CARACTERE_NULO)) else write(chr(carac)); end else begin gotoxy(POSICAO_COL_PAINEL + 2 + (posColSelecao * 2 - 2), POSICAO_LIN_PAINEL + 2 + (posLinSelecao * 2 - 2)); textcolor(black); textbackground(COR_PAINEL); if CaractereEspecial(carac) then write(chr(CARACTERE_NULO)) else write(chr(carac)); end; End; Begin DesenhaPainel(POSICAO_COL_PAINEL, POSICAO_LIN_PAINEL, 67, 20, 'Caracteres'); for auxA := 1 to 8 do for auxB := 0 to 31 do begin caractere := (32 * (auxA - 1)) + auxB; if not(CaractereEspecial(caractere)) then begin gotoxy(POSICAO_COL_PAINEL + 3 + ((auxB * 2) - 1), POSICAO_LIN_PAINEL + ((auxA * 2))); write(chr(caractere)); end; end; if editor.caractere <= 31 then posLinSelecao := 1 else if editor.caractere <= 63 then posLinSelecao := 2 else if editor.caractere <= 95 then posLinSelecao := 3 else if editor.caractere <= 127 then posLinSelecao := 4 else if editor.caractere <= 159 then posLinSelecao := 5 else if editor.caractere <= 191 then posLinSelecao := 6 else if editor.caractere <= 223 then posLinSelecao := 7 else posLinSelecao := 8; posColSelecao := editor.caractere - (32 * (posLinSelecao - 1)) + 1; caractere := (32 * (posLinSelecao - 1) + posColSelecao - 1); ExibeSelecao(true); gotoxy(POSICAO_COL_PAINEL + 2, POSICAO_LIN_PAINEL + 18); textcolor(16); textbackground(7); write(caractere, ' '); while (true) do begin delay(10); tecla := ObtemTeclaPressionada; if (tecla <> NULO) then begin if (tecla = TECLA_UP) then begin ExibeSelecao(false); dec(posLinSelecao); if posLinSelecao = 0 then posLinSelecao := 8; end else if (tecla = TECLA_DOWN) then begin ExibeSelecao(false); inc(posLinSelecao); if posLinSelecao = 9 then posLinSelecao := 1; end else if (tecla = TECLA_RIGHT) then begin ExibeSelecao(false); inc(posColSelecao); if posColSelecao = 33 then posColSelecao := 1; end else if (tecla = TECLA_LEFT) then begin ExibeSelecao(false); dec(posColSelecao); if posColSelecao = 0 then posColSelecao := 32; end else if (tecla = TECLA_ENTER) then begin caractere := (32 * (posLinSelecao - 1) + posColSelecao - 1); if not(CaractereEspecial(caractere)) then begin editor.caractere := caractere; ExibeTela(definicao.refColPagina, definicao.refLinPagina, true); MostraCursor(true); Exit; end; end else if (tecla = TECLA_ESC) then begin ExibeTela(definicao.refColPagina, definicao.refLinPagina, true); MostraCursor(true); Exit; end; ExibeSelecao(true); caractere := (32 * (posLinSelecao - 1) + posColSelecao - 1); gotoxy(POSICAO_COL_PAINEL + 2, POSICAO_LIN_PAINEL + 18); if CaractereEspecial(caractere) then textcolor(lightred) else textcolor(16); textbackground(7); write(caractere, ' '); end; end; End; {---------------------------------------------------- Procedure SelecionaCor; -----------------------------------------------------} Procedure SelecionaCor(elemento : string); Const POSICAO_COL_PAINEL = POSICAO_COL_TELA + 66; POSICAO_LIN_PAINEL = POSICAO_LIN_TELA + 1; Var corCaractere, corFundoCaractere, corPagina, nivel, aux : integer; tecla : string; Procedure ExibePrevisualizacao; Begin gotoxy(POSICAO_COL_TELA + 64, POSICAO_LIN_TELA + DIMENSAO_LIN_TELA); textcolor(corCaractere); textbackground(corFundoCaractere); write('Previsualizacao'); End; Procedure DesenhaSetas; Begin DesenhaRetangulo(POSICAO_COL_PAINEL + 1, POSICAO_LIN_PAINEL + 2, 8, 1, COR_PAINEL); DesenhaRetangulo(POSICAO_COL_PAINEL + 1, POSICAO_LIN_PAINEL + 5, 8, 1, COR_PAINEL); DesenhaRetangulo(POSICAO_COL_PAINEL + 1, POSICAO_LIN_PAINEL + 6, 8, 1, COR_PAINEL); if (upcase(elemento) = 'CARACTERE') then begin textbackground(COR_PAINEL); if (nivel = 1) then textcolor(black) else textcolor(8); if corCaractere > 8 then begin gotoxy(POSICAO_COL_PAINEL + corCaractere - 8, POSICAO_LIN_PAINEL + 2); write(#31); end else begin gotoxy(POSICAO_COL_PAINEL + corCaractere, POSICAO_LIN_PAINEL + 5); write(#30); end; if (nivel = 2) then textcolor(black) else textcolor(8); gotoxy(POSICAO_COL_PAINEL + corFundoCaractere, POSICAO_LIN_PAINEL + 6); write(#31); end else begin gotoxy(POSICAO_COL_PAINEL + corPagina, POSICAO_LIN_PAINEL + 5); textbackground(COR_PAINEL); textcolor(black); write(#30); end; End; Begin DesenhaPainel(POSICAO_COL_PAINEL, POSICAO_LIN_PAINEL, 10, 9, 'Cores'); for aux := 1 to 8 do {Desenha a paleta de cores} begin if (upcase(elemento) = 'CARACTERE') then begin gotoxy(POSICAO_COL_PAINEL + aux, POSICAO_LIN_PAINEL + 3); textcolor(aux + 8); write(#219); gotoxy(POSICAO_COL_PAINEL + aux, POSICAO_LIN_PAINEL + 4); textcolor(aux); write(#219); gotoxy(POSICAO_COL_PAINEL + aux, POSICAO_LIN_PAINEL + 7); if (aux = 8) then textcolor(16) else textcolor(aux); write(#219); end else begin gotoxy(POSICAO_COL_PAINEL + aux, POSICAO_LIN_PAINEL + 3); if (aux = 8) then textcolor(16) else textcolor(aux); write(#219); gotoxy(POSICAO_COL_PAINEL + aux, POSICAO_LIN_PAINEL + 4); write(#219); end; end; corCaractere := editor.corCaractere; corFundoCaractere := editor.corFundoCaractere; corPagina := editor.corFundo; if (upcase(elemento) = 'CARACTERE') then nivel := 1 else nivel := 2; DesenhaSetas; if (upcase(elemento) = 'CARACTERE') then ExibePrevisualizacao; while (true) do begin delay(10); tecla := ObtemTeclaPressionada; if (tecla <> NULO) then begin if (tecla = TECLA_UP) and (upcase(elemento) = 'CARACTERE') then begin if (nivel = 2) then nivel := 1 else begin if (corCaractere > 8) then nivel := 2 else corCaractere := corCaractere + 8; end; end else if (tecla = TECLA_DOWN) and (upcase(elemento) = 'CARACTERE') then begin if (nivel = 2) then nivel := 1 else begin if (corCaractere > 8) then corCaractere := corCaractere - 8 else nivel := 2; end; end else if (tecla = TECLA_RIGHT) then begin if (upcase(elemento) = 'CARACTERE') then begin if (nivel = 2) then begin if (corFundoCaractere < 8) then inc(corFundoCaractere) else corFundoCaractere := 1; end else begin if (corCaractere < 16) then inc(corCaractere) else corCaractere := 1; end; end else begin if (corPagina < 8) then inc(corPagina) else corPagina := 1; end; end else if (tecla = TECLA_LEFT) then begin if (upcase(elemento) = 'CARACTERE') then begin if (nivel = 2) then begin if (corFundoCaractere > 1) then dec(corFundoCaractere) else corFundoCaractere := 8; end else begin if (corCaractere > 1) then dec(corCaractere) else corCaractere := 16; end; end else begin if (corPagina > 1) then dec(corPagina) else corPagina := 8; end; end else if (tecla = TECLA_TAB) then begin if (upcase(elemento) = 'CARACTERE') then begin if (nivel = 1) then nivel := 2 else nivel := 1; end; end else if (tecla = TECLA_ENTER) then begin if (upcase(elemento) = 'CARACTERE') then begin editor.corCaractere := corCaractere; editor.corFundoCaractere := corFundoCaractere; end else begin editor.corFundo := corPagina; RefineFundoPagina; end; ExibeTela(definicao.refColPagina, definicao.refLinPagina, true); MostraCursor(true); Exit; end else if (tecla = TECLA_ESC) then begin ExibeTela(definicao.refColPagina, definicao.refLinPagina, true); MostraCursor(true); Exit; end; if (upcase(elemento) = 'CARACTERE') then ExibePrevisualizacao; DesenhaSetas; end; end; End; {---------------------------------------------------- Procedure DefineAtalhos; -----------------------------------------------------} Procedure DefineAtalhos(refGrupoAtalho : integer); Begin case (refGrupoAtalho) of 1: begin //Retangulos editor.refGrupoPredefinido := 1; editor.grupoPredefinido[0] := 176; editor.grupoPredefinido[1] := 177; editor.grupoPredefinido[2] := 178; editor.grupoPredefinido[3] := 219; editor.grupoPredefinido[4] := 220; editor.grupoPredefinido[5] := 223; editor.grupoPredefinido[6] := 254; editor.grupoPredefinido[7] := 22; editor.grupoPredefinido[8] := 46; editor.grupoPredefinido[9] := 250; end; 2: begin //Retas editor.refGrupoPredefinido := 2; editor.grupoPredefinido[0] := 179; editor.grupoPredefinido[1] := 186; editor.grupoPredefinido[2] := 47; editor.grupoPredefinido[3] := 92; editor.grupoPredefinido[4] := 95; editor.grupoPredefinido[5] := 196; editor.grupoPredefinido[6] := 205; editor.grupoPredefinido[7] := 45; editor.grupoPredefinido[8] := 240; editor.grupoPredefinido[9] := 238; end; 3: begin //Conectores simples editor.refGrupoPredefinido := 3; editor.grupoPredefinido[0] := 218; editor.grupoPredefinido[1] := 191; editor.grupoPredefinido[2] := 192; editor.grupoPredefinido[3] := 217; editor.grupoPredefinido[4] := 194; editor.grupoPredefinido[5] := 193; editor.grupoPredefinido[6] := 195; editor.grupoPredefinido[7] := 180; editor.grupoPredefinido[8] := 197; editor.grupoPredefinido[9] := 197; end; 4: begin //Conectores duplos editor.refGrupoPredefinido := 4; editor.grupoPredefinido[0] := 201; editor.grupoPredefinido[1] := 187; editor.grupoPredefinido[2] := 200; editor.grupoPredefinido[3] := 188; editor.grupoPredefinido[4] := 203; editor.grupoPredefinido[5] := 202; editor.grupoPredefinido[6] := 204; editor.grupoPredefinido[7] := 185; editor.grupoPredefinido[8] := 206; editor.grupoPredefinido[9] := 206; end; 5: begin //Setas editor.refGrupoPredefinido := 5; editor.grupoPredefinido[0] := 25; editor.grupoPredefinido[1] := 24; editor.grupoPredefinido[2] := 27; editor.grupoPredefinido[3] := 26; editor.grupoPredefinido[4] := 18; editor.grupoPredefinido[5] := 29; editor.grupoPredefinido[6] := 31; editor.grupoPredefinido[7] := 30; editor.grupoPredefinido[8] := 17; editor.grupoPredefinido[9] := 16; end; end; End; {---------------------------------------------------- Procedure GerenciaSelecao; -----------------------------------------------------} Procedure GerenciaSelecao; Var refColCursor, refLinCursor : integer; Begin refColCursor := definicao.refColPagina + cursor.posCol - 1; refLinCursor := definicao.refLinPagina + cursor.posLin - 1; if (selecao.posCol < refColCursor) then selecao.dimCol := refColCursor - selecao.posCol + 1 else if (selecao.posCol > refColCursor) then selecao.dimCol := selecao.posCol - refColCursor + 1 else if (selecao.posCol = refColCursor) then selecao.dimCol := 1; if (selecao.posLin < refLinCursor) then selecao.dimLin := refLinCursor - selecao.posLin + 1 else if (selecao.posLin > refLinCursor) then selecao.dimLin := selecao.posLin - refLinCursor + 1 else if (selecao.posLin = refLinCursor) then selecao.dimLin := 1; End; {---------------------------------------------------- Procedure ColaSelecao; -----------------------------------------------------} Procedure ColaSelecao(exibeFundo : boolean); Var aux, refColCursor, refLinCursor : integer; corFundo : integer; Begin refColCursor := definicao.refColPagina + cursor.posCol - 1; refLinCursor := definicao.refLinPagina + cursor.posLin - 1; historico.trocarCiclo := true; for aux := 1 to areaTransferencia.quantElementos do begin if (areaTransferencia.matriz[aux].elemento.caractere <> CARACTERE_NULO) then begin if exibeFundo then corFundo := areaTransferencia.matriz[aux].elemento.corFundo else corFundo := matriz.pagina[refColCursor + areaTransferencia.matriz[aux].posCol - 1, refLinCursor + areaTransferencia.matriz[aux].posLin - 1].corFundo; InsereElemento(areaTransferencia.matriz[aux].elemento.caractere, areaTransferencia.matriz[aux].elemento.cor, corFundo, refColCursor + areaTransferencia.matriz[aux].posCol - 1, refLinCursor + areaTransferencia.matriz[aux].posLin - 1); historico.trocarCiclo := false; end; end; ExibeTela(definicao.refColPagina, definicao.refLinPagina, true); MostraCursor(true); End; {---------------------------------------------------- Procedure ManipulaAreaSelecionada; -----------------------------------------------------} Procedure ManipulaAreaSelecionada(acao : string); Var colPagina, linPagina : integer; refColCursor, refLinCursor : integer; refColAreaTransferencia, refLinAreaTransferencia : integer; refColA, refColB, refLinA, refLinB : integer; Begin refColCursor := definicao.refColPagina + cursor.posCol - 1; refLinCursor := definicao.refLinPagina + cursor.posLin - 1; historico.trocarCiclo := true; if refColCursor >= selecao.posCol then begin if refLinCursor >= selecao.posLin then begin refColA := selecao.posCol; refColB := refColCursor; refLinA := selecao.posLin; refLinB := refLinCursor; end else begin refColA := selecao.posCol; refColB := refColCursor; refLinA := refLinCursor; refLinB := selecao.posLin; end; end else begin if refLinCursor >= selecao.posLin then begin refColA := refColCursor; refColB := selecao.posCol; refLinA := selecao.posLin; refLinB := refLinCursor; end else begin refColA := refColCursor; refColB := selecao.posCol; refLinA := refLinCursor; refLinB := selecao.posLin; end; end; if (upcase(acao) = 'COPIAR') then begin if selecao.dimCol * selecao.dimLin > DIMENSAO_AREA_TRANSFERENCIA then {Não realiza o armazenamento da seleção na área de transferência caso a quantidade de dados exceda o máximo suportado} Exit; areaTransferencia.quantElementos := 0; refColAreaTransferencia := 0; refLinAreaTransferencia := 0; for colPagina := refColA to refColB do begin inc(refColAreaTransferencia); refLinAreaTransferencia := 0; for linPagina := refLinA to refLinB do begin inc(areaTransferencia.quantElementos); inc(refLinAreaTransferencia); areaTransferencia.matriz[areaTransferencia.quantElementos].elemento := matriz.pagina[colPagina, linPagina]; areaTransferencia.matriz[areaTransferencia.quantElementos].posCol
Compartilhar