Pular para o conteúdo principal
2008-07-23: resolve melhorar um pouquinho o StrEditor e criei este método, getInfo(), que retorna um array de inteiros com várias informações a respeito dos ponteiros, offsets e tamanhos. No início temos o inteiro array que receberá as informações calculadas; declarei também várias variáveis que as descrevem cada índice do array. No fim retornamos o array int para ser utilizado com outros métodos.


private int[] getInfo(){
int[] info = new int[6];
try {
final int LINHA = 0;
final int INICIOOFFSETLINHA = 1;
final int FIMOFFSETLINHA = 2;
final int OFFSETTEXTO = 3;
final int TAMANHOTEXTO = 4;
final int TAMANHOPONTEIRO = 5;

info[LINHA] = getLine();
info[INICIOOFFSETLINHA] = txtMain.getLineStartOffset(info[LINHA]);
info[FIMOFFSETLINHA] = txtMain.getLineEndOffset(info[LINHA]);
info[OFFSETTEXTO] = info[INICIOOFFSETLINHA];
info[TAMANHOTEXTO] = (info[FIMOFFSETLINHA]-1) - info[OFFSETTEXTO];
info[TAMANHOPONTEIRO] = info[TAMANHOTEXTO];

} catch (BadLocationException ex) {
Logger.getLogger(StrEditorView.class.getName()).log(Level.SEVERE, null, ex);
}
return info;
}

Esta parte aqui foi colocada dentro dos métodos de evento de mouse e teclado. O que fazemos aqui é receber o array int do método getInfo() e trabalhar essas informações, no final passando os parâmetros necessário para o método writeChanges(), que irá atualizar os novos valores do ponteiro e seu conteúdo.

int info[] = getInfo();
try {
String texto = txtMain.getText(info[3], info[4]);
jLabel1.setText("Linha: " + info[0]);
System.out.println("Inicio linha offset: "+info[1]);
System.out.println("Fim linha offset: "+info[2]);
System.out.println(txtMain.getText(info[3], info[4]));
System.out.println("Tamanho para pegar o texto: "+info[4]);
lblTexto.setText("\""+texto+"\"");
lblTamanho.setText("Tamanho: "+String.valueOf(info[5]));

writeChanges( info[0], (short)info[5], texto);

} catch (BadLocationException ex) {
Logger.getLogger(StrEditorView.class.getName()).log(Level.SEVERE, null, ex);
}

Comentários

Postagens mais visitadas deste blog

Instalar Módulo de Proteção Santander no Mac OSX Mountain Lion

Repararam que o módulo de proteção do banco Santander parou de funcionar? Isso, no meu caso foi quando atualizei o OSX para o Mountain Lion. Há quem diga que parou quando da atualização do navegador Safari. Enfin, depois de brigar um pouco com versões Java, consegui encontrar no forum da Apple a solução: Após atualizar o meu MacBook Pro para o Mountain Lion, o módulo de proteção do Santander parou de funcionar no Google Chrome. Ao clicar no botão instalar módulo de proteção, nada acontecia. Olhando o javascript mais a fundo, achei uma chamada a URL ' https://wwws.santandernet.com.br/MPS/moduloJava.html '. Ao inserir ela no browser e pressionar <ENTER>, recebia uma mensagem 'plugin inactive'. Pare resolver o problema, abri uma nova aba e entrei no endereço 'chrome://plugins/'. Naveguei até o plugin do Java, desabilitei o mesmo e reiniciei o chrome. Feito isso, entrei novamente no endereço e ativei este plugin. Ao entrar novamente no s...

GameDev Tutorial - Basic Circle Chain Engine Using Unity3D Part 1

Circle Chain ( http://www.emanueleferonato.com/stuff/circle_chain/ ) is a simple game developed in 2007 by Emanuele Feronato ( http://www.emanueleferonato.com ) as a monetization test in Flash Games. In fact it's based on Boomshine ( http://www.k2xl.com/games/boomshine/ ) Emanuele has since, ported his game tutorial for lots of platforms: AS3: (complete)  http://www.emanueleferonato.com/2012/02/20/circle-chain-ported-to-as3-with-commented-source-code-available-ready-to-jump-to-the-iphone/ Game Maker: (basic)  http://www.emanueleferonato.com/2012/06/07/circle-chain-engine-made-with-game-maker/ Construct2 HTML5:  http://www.emanueleferonato.com/2012/03/14/html5-version-of-circle-chain-engine-using-scirras-construct2/ Corona SDK:  http://www.emanueleferonato.com/2012/02/24/basic-circle-chain-engine-using-corona-sdk/ Gideros Studio:  http://www.emanueleferonato.com/2012/04/12/basic-circle-chain-engine-using-gideros-studio/ Stencyl:  http://www.emanueleferonato.com/2012/02/29/ba...

GameDev Tutorial - Basic Circle Chain Engine Using Unity3D Part 2

This part 2 is not so detailed like before, so If you need you can see the part 1 here:  http://alxcancado.tumblr.com/post/62482465038/gamedev-tutorial-basic-circle-chain-engine-using Once again I want say that this is my port for Unity3D from Emanuele Feronato's tutorial:  http://www.emanueleferonato.com/2013/05/21/from-zero-to-a-complete-game-with-cocos2d-html5-step-2-mouse-interaction/   Okay, time to put some mouse interaction. 1. add the new textures: red circle, bullet red; configure texture type to advanced, uncheck generate mipmap and filter mode to point. 2. drag and drop the greencircleprefab from prefab folder to the hierarchy. drag and drop the red circle texture to this and rename to RedCircle. Remove the GreenCricle script from it. We will create a script to this object later. 3. But we still need create our Bullet prefab. To make it simple, just duplicate the RedCircle object from hierarchy panel with Command+D or (Control+D in windows?). Then rename this ...